@zephyr3d/scene 0.9.25 → 0.9.27

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 (299) hide show
  1. package/dist/animation/animationset.js +92 -30
  2. package/dist/animation/animationset.js.map +1 -1
  3. package/dist/animation/hair/gpu_hair_simulation.js +1090 -0
  4. package/dist/animation/hair/gpu_hair_simulation.js.map +1 -0
  5. package/dist/animation/joint_dynamics/controller.js +7 -5
  6. package/dist/animation/joint_dynamics/controller.js.map +1 -1
  7. package/dist/animation/joint_dynamics/convex_collider.js +320 -0
  8. package/dist/animation/joint_dynamics/convex_collider.js.map +1 -0
  9. package/dist/animation/joint_dynamics/joint_dynamics_system.js +81 -5
  10. package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
  11. package/dist/animation/morphtrack.js +3 -4
  12. package/dist/animation/morphtrack.js.map +1 -1
  13. package/dist/animation/skeleton.js +79 -25
  14. package/dist/animation/skeleton.js.map +1 -1
  15. package/dist/animation/spring/multi_chain_spring_system.js +577 -179
  16. package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
  17. package/dist/animation/spring/spring_collider.js +4 -3
  18. package/dist/animation/spring/spring_collider.js.map +1 -1
  19. package/dist/animation/spring/spring_node_pose_tracker.js +40 -0
  20. package/dist/animation/spring/spring_node_pose_tracker.js.map +1 -0
  21. package/dist/animation/spring/spring_particle.js +2 -0
  22. package/dist/animation/spring/spring_particle.js.map +1 -1
  23. package/dist/animation/spring/spring_system.js +11 -3
  24. package/dist/animation/spring/spring_system.js.map +1 -1
  25. package/dist/animation/spring_modifier.js +10 -0
  26. package/dist/animation/spring_modifier.js.map +1 -1
  27. package/dist/app/engine.js +53 -43
  28. package/dist/app/engine.js.map +1 -1
  29. package/dist/app/scriptingsystem.js +119 -6
  30. package/dist/app/scriptingsystem.js.map +1 -1
  31. package/dist/app/scriptregistry.js +3 -2
  32. package/dist/app/scriptregistry.js.map +1 -1
  33. package/dist/asset/assetmanager.js +284 -67
  34. package/dist/asset/assetmanager.js.map +1 -1
  35. package/dist/asset/loaders/zhair/zhair_format.js +288 -0
  36. package/dist/asset/loaders/zhair/zhair_format.js.map +1 -0
  37. package/dist/asset/loaders/zhair/zhair_loader.js +221 -0
  38. package/dist/asset/loaders/zhair/zhair_loader.js.map +1 -0
  39. package/dist/asset/model.js +184 -69
  40. package/dist/asset/model.js.map +1 -1
  41. package/dist/camera/camera.js +268 -44
  42. package/dist/camera/camera.js.map +1 -1
  43. package/dist/camera/perspectivecamera.js +3 -1
  44. package/dist/camera/perspectivecamera.js.map +1 -1
  45. package/dist/index.d.ts +9044 -5139
  46. package/dist/index.js +17 -6
  47. package/dist/index.js.map +1 -1
  48. package/dist/material/eye.js +932 -0
  49. package/dist/material/eye.js.map +1 -0
  50. package/dist/material/hair.js +917 -0
  51. package/dist/material/hair.js.map +1 -0
  52. package/dist/material/hairstrand.js +842 -0
  53. package/dist/material/hairstrand.js.map +1 -0
  54. package/dist/material/hairstrand_data.js +162 -0
  55. package/dist/material/hairstrand_data.js.map +1 -0
  56. package/dist/material/lambert.js +5 -2
  57. package/dist/material/lambert.js.map +1 -1
  58. package/dist/material/material.js +48 -10
  59. package/dist/material/material.js.map +1 -1
  60. package/dist/material/meshmaterial.js +120 -19
  61. package/dist/material/meshmaterial.js.map +1 -1
  62. package/dist/material/mixins/albedocolor.js +1 -1
  63. package/dist/material/mixins/albedocolor.js.map +1 -1
  64. package/dist/material/mixins/lightmodel/blinnphong.js +5 -3
  65. package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
  66. package/dist/material/mixins/lightmodel/lambert.js +5 -4
  67. package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
  68. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +3 -3
  69. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
  70. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +5 -5
  71. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  72. package/dist/material/mixins/lightmodel/pbrspecularglossness.js +3 -3
  73. package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
  74. package/dist/material/mixins/lit.js +106 -19
  75. package/dist/material/mixins/lit.js.map +1 -1
  76. package/dist/material/mixins/pbr/common.js +4 -4
  77. package/dist/material/mixins/pbr/common.js.map +1 -1
  78. package/dist/material/mixins/texture.js +48 -11
  79. package/dist/material/mixins/texture.js.map +1 -1
  80. package/dist/material/mtoon.js +6 -5
  81. package/dist/material/mtoon.js.map +1 -1
  82. package/dist/material/pbrblueprint.js +146 -28
  83. package/dist/material/pbrblueprint.js.map +1 -1
  84. package/dist/material/pbrblueprint_instance.js +501 -0
  85. package/dist/material/pbrblueprint_instance.js.map +1 -0
  86. package/dist/material/pbrmr.js +15 -16
  87. package/dist/material/pbrmr.js.map +1 -1
  88. package/dist/material/shader/helper.js +734 -23
  89. package/dist/material/shader/helper.js.map +1 -1
  90. package/dist/material/shader/terrain_blend.js +55 -0
  91. package/dist/material/shader/terrain_blend.js.map +1 -0
  92. package/dist/material/skin.js +192 -32
  93. package/dist/material/skin.js.map +1 -1
  94. package/dist/material/spriteblueprint.js +16 -1
  95. package/dist/material/spriteblueprint.js.map +1 -1
  96. package/dist/material/subsurfaceprofile.js +86 -23
  97. package/dist/material/subsurfaceprofile.js.map +1 -1
  98. package/dist/material/water.js +2059 -72
  99. package/dist/material/water.js.map +1 -1
  100. package/dist/posteffect/bloom.js +167 -7
  101. package/dist/posteffect/bloom.js.map +1 -1
  102. package/dist/posteffect/coloradjust.js +2 -1
  103. package/dist/posteffect/coloradjust.js.map +1 -1
  104. package/dist/posteffect/compositor.js.map +1 -1
  105. package/dist/posteffect/fxaa.js +2 -1
  106. package/dist/posteffect/fxaa.js.map +1 -1
  107. package/dist/posteffect/grayscale.js +3 -1
  108. package/dist/posteffect/grayscale.js.map +1 -1
  109. package/dist/posteffect/motionblur.js +664 -56
  110. package/dist/posteffect/motionblur.js.map +1 -1
  111. package/dist/posteffect/posteffect.js +12 -1
  112. package/dist/posteffect/posteffect.js.map +1 -1
  113. package/dist/posteffect/sao.js +46 -44
  114. package/dist/posteffect/sao.js.map +1 -1
  115. package/dist/posteffect/skinsss.js +368 -69
  116. package/dist/posteffect/skinsss.js.map +1 -1
  117. package/dist/posteffect/ssgi.js +16 -9
  118. package/dist/posteffect/ssgi.js.map +1 -1
  119. package/dist/posteffect/ssr.js +3 -0
  120. package/dist/posteffect/ssr.js.map +1 -1
  121. package/dist/posteffect/sss.js +121 -36
  122. package/dist/posteffect/sss.js.map +1 -1
  123. package/dist/posteffect/taa.js.map +1 -1
  124. package/dist/posteffect/tonemap.js +44 -1
  125. package/dist/posteffect/tonemap.js.map +1 -1
  126. package/dist/render/abuffer_oit.js +8 -2
  127. package/dist/render/abuffer_oit.js.map +1 -1
  128. package/dist/render/clipmap.js +156 -5
  129. package/dist/render/clipmap.js.map +1 -1
  130. package/dist/render/cull_visitor.js +20 -0
  131. package/dist/render/cull_visitor.js.map +1 -1
  132. package/dist/render/depthpass.js +36 -2
  133. package/dist/render/depthpass.js.map +1 -1
  134. package/dist/render/drawable_mixin.js +26 -1
  135. package/dist/render/drawable_mixin.js.map +1 -1
  136. package/dist/render/dualdepthpeeling_oit.js +3 -2
  137. package/dist/render/dualdepthpeeling_oit.js.map +1 -1
  138. package/dist/render/envlight.js +1 -1
  139. package/dist/render/envlight.js.map +1 -1
  140. package/dist/render/fbm_wavegenerator.js +6 -3
  141. package/dist/render/fbm_wavegenerator.js.map +1 -1
  142. package/dist/render/fft_wavegenerator.js +57 -15
  143. package/dist/render/fft_wavegenerator.js.map +1 -1
  144. package/dist/render/gerstner_wavegenerator.js +130 -20
  145. package/dist/render/gerstner_wavegenerator.js.map +1 -1
  146. package/dist/render/globalbindgroup_allocator.js +3 -0
  147. package/dist/render/globalbindgroup_allocator.js.map +1 -1
  148. package/dist/render/hzb.js +80 -22
  149. package/dist/render/hzb.js.map +1 -1
  150. package/dist/render/lightpass.js +6 -3
  151. package/dist/render/lightpass.js.map +1 -1
  152. package/dist/render/oit.js +29 -0
  153. package/dist/render/oit.js.map +1 -0
  154. package/dist/render/render_queue.js +39 -0
  155. package/dist/render/render_queue.js.map +1 -1
  156. package/dist/render/renderer.js +4 -0
  157. package/dist/render/renderer.js.map +1 -1
  158. package/dist/render/rendergraph/blackboard.js +1 -0
  159. package/dist/render/rendergraph/blackboard.js.map +1 -1
  160. package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
  161. package/dist/render/rendergraph/executor.js +2 -0
  162. package/dist/render/rendergraph/executor.js.map +1 -1
  163. package/dist/render/rendergraph/forward_plus_builder.js +379 -10
  164. package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
  165. package/dist/render/rendergraph/frame_resource_requirements.js +1 -0
  166. package/dist/render/rendergraph/frame_resource_requirements.js.map +1 -1
  167. package/dist/render/rendergraph/history_resources.js +8 -1
  168. package/dist/render/rendergraph/history_resources.js.map +1 -1
  169. package/dist/render/rendergraph/rendergraph.js.map +1 -1
  170. package/dist/render/rendergraph/texture_affinity_cache.js +1 -1
  171. package/dist/render/rendergraph/texture_affinity_cache.js.map +1 -1
  172. package/dist/render/rendergraph/types.js.map +1 -1
  173. package/dist/render/shadow_mask_pass.js +73 -8
  174. package/dist/render/shadow_mask_pass.js.map +1 -1
  175. package/dist/render/sky.js +166 -126
  176. package/dist/render/sky.js.map +1 -1
  177. package/dist/render/underwater.js +624 -0
  178. package/dist/render/underwater.js.map +1 -0
  179. package/dist/render/water_caustics.js +1380 -0
  180. package/dist/render/water_caustics.js.map +1 -0
  181. package/dist/render/weightedblended_oit.js +3 -2
  182. package/dist/render/weightedblended_oit.js.map +1 -1
  183. package/dist/scene/basesprite.js +8 -0
  184. package/dist/scene/basesprite.js.map +1 -1
  185. package/dist/scene/batchgroup.js +3 -0
  186. package/dist/scene/batchgroup.js.map +1 -1
  187. package/dist/scene/environment.js +4 -1
  188. package/dist/scene/environment.js.map +1 -1
  189. package/dist/scene/hair.js +963 -0
  190. package/dist/scene/hair.js.map +1 -0
  191. package/dist/scene/light.js +5 -1
  192. package/dist/scene/light.js.map +1 -1
  193. package/dist/scene/mesh.js +481 -47
  194. package/dist/scene/mesh.js.map +1 -1
  195. package/dist/scene/meshdrawable.js +6 -0
  196. package/dist/scene/meshdrawable.js.map +1 -1
  197. package/dist/scene/msdftext.js +3 -0
  198. package/dist/scene/msdftext.js.map +1 -1
  199. package/dist/scene/msdftextsprite.js +3 -0
  200. package/dist/scene/msdftextsprite.js.map +1 -1
  201. package/dist/scene/particlesys.js +6 -0
  202. package/dist/scene/particlesys.js.map +1 -1
  203. package/dist/scene/scene.js +3 -0
  204. package/dist/scene/scene.js.map +1 -1
  205. package/dist/scene/scene_node.js +6 -1
  206. package/dist/scene/scene_node.js.map +1 -1
  207. package/dist/scene/terrain-cm/grass.js +3 -0
  208. package/dist/scene/terrain-cm/grass.js.map +1 -1
  209. package/dist/scene/terrain-cm/grassmaterial.js +3 -0
  210. package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
  211. package/dist/scene/terrain-cm/terrain-cm.js +6 -0
  212. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
  213. package/dist/scene/terrain-cm/texture_cache.js +309 -0
  214. package/dist/scene/terrain-cm/texture_cache.js.map +1 -0
  215. package/dist/scene/water.js +546 -4
  216. package/dist/scene/water.js.map +1 -1
  217. package/dist/shaders/atmosphere.js.map +1 -1
  218. package/dist/shaders/diffusion.js +54 -0
  219. package/dist/shaders/diffusion.js.map +1 -0
  220. package/dist/shaders/shadow.js +33 -21
  221. package/dist/shaders/shadow.js.map +1 -1
  222. package/dist/shaders/temporal.js +71 -33
  223. package/dist/shaders/temporal.js.map +1 -1
  224. package/dist/shaders/water.js +22 -19
  225. package/dist/shaders/water.js.map +1 -1
  226. package/dist/shaders/water_medium.js +56 -0
  227. package/dist/shaders/water_medium.js.map +1 -0
  228. package/dist/shadow/dom.js +546 -0
  229. package/dist/shadow/dom.js.map +1 -0
  230. package/dist/shadow/pcf_opt.js +3 -5
  231. package/dist/shadow/pcf_opt.js.map +1 -1
  232. package/dist/shadow/pcf_pd.js +1 -1
  233. package/dist/shadow/pcf_pd.js.map +1 -1
  234. package/dist/shadow/receiver_bias.js +41 -0
  235. package/dist/shadow/receiver_bias.js.map +1 -0
  236. package/dist/shadow/shader.js +20 -60
  237. package/dist/shadow/shader.js.map +1 -1
  238. package/dist/shadow/shadow_impl.js +89 -0
  239. package/dist/shadow/shadow_impl.js.map +1 -1
  240. package/dist/shadow/shadow_region.js +1 -1
  241. package/dist/shadow/shadow_region.js.map +1 -1
  242. package/dist/shadow/shadowmapper.js +150 -37
  243. package/dist/shadow/shadowmapper.js.map +1 -1
  244. package/dist/shapes/shape.js +11 -2
  245. package/dist/shapes/shape.js.map +1 -1
  246. package/dist/shapes/sphere.js +50 -9
  247. package/dist/shapes/sphere.js.map +1 -1
  248. package/dist/utility/blueprint/common/constants.js +112 -2
  249. package/dist/utility/blueprint/common/constants.js.map +1 -1
  250. package/dist/utility/blueprint/material/func.js +142 -49
  251. package/dist/utility/blueprint/material/func.js.map +1 -1
  252. package/dist/utility/blueprint/material/ir.js +490 -25
  253. package/dist/utility/blueprint/material/ir.js.map +1 -1
  254. package/dist/utility/blueprint/material/texture.js +898 -4
  255. package/dist/utility/blueprint/material/texture.js.map +1 -1
  256. package/dist/utility/serialization/manager.js +434 -101
  257. package/dist/utility/serialization/manager.js.map +1 -1
  258. package/dist/utility/serialization/scene/animation.js +401 -5
  259. package/dist/utility/serialization/scene/animation.js.map +1 -1
  260. package/dist/utility/serialization/scene/batch.js +4 -0
  261. package/dist/utility/serialization/scene/batch.js.map +1 -1
  262. package/dist/utility/serialization/scene/camera.js +186 -26
  263. package/dist/utility/serialization/scene/camera.js.map +1 -1
  264. package/dist/utility/serialization/scene/common.js +26 -5
  265. package/dist/utility/serialization/scene/common.js.map +1 -1
  266. package/dist/utility/serialization/scene/hair.js +1141 -0
  267. package/dist/utility/serialization/scene/hair.js.map +1 -0
  268. package/dist/utility/serialization/scene/light.js +84 -4
  269. package/dist/utility/serialization/scene/light.js.map +1 -1
  270. package/dist/utility/serialization/scene/material.js +1867 -166
  271. package/dist/utility/serialization/scene/material.js.map +1 -1
  272. package/dist/utility/serialization/scene/mesh.js +231 -14
  273. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  274. package/dist/utility/serialization/scene/node.js +141 -7
  275. package/dist/utility/serialization/scene/node.js.map +1 -1
  276. package/dist/utility/serialization/scene/particle.js +4 -0
  277. package/dist/utility/serialization/scene/particle.js.map +1 -1
  278. package/dist/utility/serialization/scene/primitive.js +18 -0
  279. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  280. package/dist/utility/serialization/scene/sprite.js +4 -0
  281. package/dist/utility/serialization/scene/sprite.js.map +1 -1
  282. package/dist/utility/serialization/scene/terrain.js +4 -0
  283. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  284. package/dist/utility/serialization/scene/text.js +4 -0
  285. package/dist/utility/serialization/scene/text.js.map +1 -1
  286. package/dist/utility/serialization/scene/water.js +1105 -21
  287. package/dist/utility/serialization/scene/water.js.map +1 -1
  288. package/dist/utility/serialization/types.js.map +1 -1
  289. package/dist/utility/shprojector.js +9 -8
  290. package/dist/utility/shprojector.js.map +1 -1
  291. package/dist/values.js +49 -2
  292. package/dist/values.js.map +1 -1
  293. package/package.json +3 -3
  294. package/dist/render/rendergraph/frame_graph_context.js +0 -41
  295. package/dist/render/rendergraph/frame_graph_context.js.map +0 -1
  296. package/dist/shaders/ssgi.js +0 -63
  297. package/dist/shaders/ssgi.js.map +0 -1
  298. package/dist/shaders/ssgi_reprojection.js +0 -118
  299. package/dist/shaders/ssgi_reprojection.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"water.js","sources":["../../../../src/utility/serialization/scene/water.ts"],"sourcesContent":["import type { Nullable } from '@zephyr3d/base';\r\nimport { Vector2 } from '@zephyr3d/base';\r\nimport type { SceneNode } from '../../../scene';\r\nimport { GraphNode } from '../../../scene';\r\nimport { Water } from '../../../scene/water';\r\nimport { defineProps, type SerializableClass } from '../types';\r\nimport type { WaveGenerator } from '../../../render';\r\nimport { FBMWaveGenerator, FFTWaveGenerator } from '../../../render';\r\nimport type { Texture2D } from '@zephyr3d/device';\r\nimport type { ResourceManager } from '../manager';\r\n\r\n/** @internal */\r\nexport function getFBMWaveGeneratorClass(): SerializableClass {\r\n return {\r\n ctor: FBMWaveGenerator,\r\n name: 'FBMWaveGenerator',\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'NumOctaves',\r\n description: 'Number of FBM noise octaves used to build the wave pattern',\r\n type: 'int',\r\n options: { minValue: 1, maxValue: 8 },\r\n default: 4,\r\n get(this: FBMWaveGenerator, value) {\r\n value.num[0] = this.numOctaves;\r\n },\r\n set(this: FBMWaveGenerator, value) {\r\n this.numOctaves = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Wind',\r\n description: 'Wind direction and speed that drive the FBM waves',\r\n type: 'vec2',\r\n default: [0.1, 0],\r\n options: {\r\n animatable: true\r\n },\r\n get(this: FBMWaveGenerator, value) {\r\n value.num[0] = this.wind.x;\r\n value.num[1] = this.wind.y;\r\n },\r\n set(this: FBMWaveGenerator, value) {\r\n this.wind = new Vector2(value.num[0], value.num[1]);\r\n }\r\n },\r\n {\r\n name: 'Amplitude',\r\n description: 'Wave height amplitude for the FBM wave generator',\r\n type: 'float',\r\n options: { animatable: true, minValue: 0, maxValue: 5 },\r\n default: 0.3,\r\n get(this: FBMWaveGenerator, value) {\r\n value.num[0] = this.amplitude;\r\n },\r\n set(this: FBMWaveGenerator, value) {\r\n this.amplitude = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Frequency',\r\n description: 'Wave frequency for the FBM wave generator',\r\n type: 'float',\r\n options: { animatable: true, minValue: 0, maxValue: 16 },\r\n default: 3,\r\n get(this: FBMWaveGenerator, value) {\r\n value.num[0] = this.frequency;\r\n },\r\n set(this: FBMWaveGenerator, value) {\r\n this.frequency = value.num[0];\r\n }\r\n }\r\n ]);\r\n }\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport function getFFTWaveGeneratorClass(): SerializableClass {\r\n return {\r\n ctor: FFTWaveGenerator,\r\n name: 'FFTWaveGenerator',\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'Alignment',\r\n description: 'How strongly FFT waves align with the wind direction',\r\n type: 'float',\r\n options: { animatable: true, minValue: 0, maxValue: 1 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.alignment;\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.alignment = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Wind',\r\n description: 'Wind direction and speed that drive the FFT waves',\r\n type: 'vec2',\r\n options: {\r\n animatable: true\r\n },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.wind.x;\r\n value.num[1] = this.wind.y;\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.wind = new Vector2(value.num[0], value.num[1]);\r\n }\r\n },\r\n {\r\n name: 'FoamWidth',\r\n description: 'Width of foam bands generated on the wave crests',\r\n type: 'float',\r\n default: 1.2,\r\n options: { animatable: true, minValue: 0, maxValue: 10 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.foamWidth;\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.foamWidth = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'FoamContrast',\r\n description: 'Contrast of the foam pattern on FFT waves',\r\n type: 'float',\r\n default: 7.2,\r\n options: { animatable: true, minValue: 0, maxValue: 10 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.foamContrast;\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.foamContrast = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'WaveLengthCascades',\r\n description: 'Wavelength values for the three FFT wave cascades',\r\n type: 'vec3',\r\n default: [400, 100, 15],\r\n options: { animatable: true, minValue: 0, maxValue: 1000 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.getWaveLength(0);\r\n value.num[1] = this.getWaveLength(1);\r\n value.num[2] = this.getWaveLength(2);\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.setWaveLength(0, value.num[0]);\r\n this.setWaveLength(1, value.num[1]);\r\n this.setWaveLength(2, value.num[2]);\r\n }\r\n },\r\n {\r\n name: 'WaveStrengthCascades',\r\n description: 'Strength values for the three FFT wave cascades',\r\n type: 'vec3',\r\n default: [0.4, 0.4, 0.2],\r\n options: { animatable: true, minValue: 0, maxValue: 1 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.getWaveStrength(0);\r\n value.num[1] = this.getWaveStrength(1);\r\n value.num[2] = this.getWaveStrength(2);\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.setWaveStrength(0, value.num[0]);\r\n this.setWaveStrength(1, value.num[1]);\r\n this.setWaveStrength(2, value.num[2]);\r\n }\r\n },\r\n {\r\n name: 'WaveCroppinessCascades',\r\n description: 'Croppiness values for the three FFT wave cascades',\r\n type: 'vec3',\r\n default: [-1.5, -1.2, -0.5],\r\n options: { animatable: true, minValue: -4, maxValue: 0 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.getWaveCroppiness(0);\r\n value.num[1] = this.getWaveCroppiness(1);\r\n value.num[2] = this.getWaveCroppiness(2);\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.setWaveCroppiness(0, value.num[0]);\r\n this.setWaveCroppiness(1, value.num[1]);\r\n this.setWaveCroppiness(2, value.num[2]);\r\n }\r\n }\r\n ]);\r\n }\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport function getWaterClass(manager: ResourceManager): SerializableClass {\r\n return {\r\n ctor: Water,\r\n name: 'Water',\r\n parent: GraphNode,\r\n createFunc(ctx: SceneNode) {\r\n const node = new Water(ctx.scene!);\r\n node.parent = ctx;\r\n return { obj: node };\r\n },\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'WaveGenerator',\r\n description: 'Wave generator used to drive the water surface',\r\n type: 'object',\r\n default: null,\r\n options: {\r\n objectTypes: [FFTWaveGenerator, FBMWaveGenerator]\r\n },\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: Water, value) {\r\n value.object[0] = this.waveGenerator ?? null;\r\n },\r\n set(this: Water, value) {\r\n if (!value.object[0]) {\r\n this.waveGenerator = null;\r\n } else {\r\n this.waveGenerator = value.object[0] as WaveGenerator;\r\n }\r\n }\r\n },\r\n {\r\n name: 'GridScale',\r\n description: 'Scale of the water simulation grid',\r\n type: 'float',\r\n default: 1,\r\n options: { minValue: 0, maxValue: 1 },\r\n get(this: Water, value) {\r\n value.num[0] = this.gridScale;\r\n },\r\n set(this: Water, value) {\r\n this.gridScale = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Wireframe',\r\n description: 'If true, renders the water surface as wireframe',\r\n type: 'bool',\r\n default: false,\r\n get(this: Water, value) {\r\n value.bool[0] = this.wireframe;\r\n },\r\n set(this: Water, value) {\r\n this.wireframe = value.bool[0];\r\n }\r\n },\r\n {\r\n name: 'AnimationSpeed',\r\n description: 'Playback speed of wave animation',\r\n type: 'float',\r\n default: 1,\r\n options: { animatable: true, minValue: 0, maxValue: 100 },\r\n get(this: Water, value) {\r\n value.num[0] = this.animationSpeed;\r\n },\r\n set(this: Water, value) {\r\n this.animationSpeed = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'DepthScale',\r\n description: 'Depth attenuation scale for the water material',\r\n type: 'float',\r\n default: 10,\r\n options: { animatable: true, minValue: 0, maxValue: 100 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.depthMulti;\r\n },\r\n set(this: Water, value) {\r\n this.material.depthMulti = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'RefractionStrength',\r\n description: 'Strength of underwater refraction',\r\n type: 'float',\r\n default: 0,\r\n options: { animatable: true, minValue: 0, maxValue: 1 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.refractionStrength;\r\n },\r\n set(this: Water, value) {\r\n this.material.refractionStrength = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Displace',\r\n description: 'Vertex displacement scale for water waves',\r\n type: 'float',\r\n default: 16,\r\n options: { minValue: 1, maxValue: 256 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.displace;\r\n },\r\n set(this: Water, value) {\r\n this.material.displace = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'TAAStrength',\r\n description: 'Temporal anti-aliasing strength for the water surface',\r\n type: 'float',\r\n default: 0.4,\r\n options: { minValue: 0, maxValue: 1 },\r\n get(this: Water, value) {\r\n value.num[0] = this.TAAStrength;\r\n },\r\n set(this: Water, value) {\r\n this.TAAStrength = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'ScatterRampTexture',\r\n description: 'Ramp texture used for water scatter lighting',\r\n type: 'object',\r\n default: null,\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: Water, value) {\r\n value.str[0] = manager.getAssetId(this.material.scatterRampTexture) ?? '';\r\n },\r\n async set(value) {\r\n if (!value) {\r\n this.material.scatterRampTexture = null;\r\n } else {\r\n if (value.str[0]) {\r\n const assetId = value.str[0];\r\n let tex: Nullable<Texture2D>;\r\n try {\r\n tex = await manager.fetchTexture<Texture2D>(assetId);\r\n } catch (err) {\r\n console.error(`Load asset failed: ${value.str[0]}: ${err}`);\r\n tex = null;\r\n }\r\n if (tex?.isTexture2D()) {\r\n this.material.scatterRampTexture = tex;\r\n } else {\r\n console.error('Invalid texture type');\r\n }\r\n }\r\n }\r\n }\r\n },\r\n {\r\n name: 'AbsorptionRampTexture',\r\n description: 'Ramp texture used for water absorption',\r\n type: 'object',\r\n default: null,\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: Water, value) {\r\n value.str[0] = manager.getAssetId(this.material.absorptionRampTexture) ?? '';\r\n },\r\n async set(this: Water, value) {\r\n if (!value) {\r\n this.material.absorptionRampTexture = null;\r\n } else {\r\n if (value.str[0]) {\r\n const assetId = value.str[0];\r\n let tex: Nullable<Texture2D>;\r\n try {\r\n tex = await manager.fetchTexture<Texture2D>(assetId);\r\n } catch (err) {\r\n console.error(`Load asset failed: ${value.str[0]}: ${err}`);\r\n tex = null;\r\n }\r\n if (tex?.isTexture2D()) {\r\n this.material.absorptionRampTexture = tex;\r\n } else {\r\n console.error('Invalid texture type');\r\n }\r\n }\r\n }\r\n }\r\n }\r\n ]);\r\n }\r\n };\r\n}\r\n"],"names":["getFBMWaveGeneratorClass","ctor","FBMWaveGenerator","name","getProps","defineProps","description","type","options","minValue","maxValue","default","get","value","num","numOctaves","set","animatable","wind","x","y","Vector2","amplitude","frequency","getFFTWaveGeneratorClass","FFTWaveGenerator","alignment","foamWidth","foamContrast","getWaveLength","setWaveLength","getWaveStrength","setWaveStrength","getWaveCroppiness","setWaveCroppiness","getWaterClass","manager","Water","parent","GraphNode","createFunc","ctx","node","scene","obj","objectTypes","isNullable","object","waveGenerator","gridScale","bool","wireframe","animationSpeed","material","depthMulti","refractionStrength","displace","TAAStrength","str","getAssetId","scatterRampTexture","assetId","tex","fetchTexture","err","console","error","isTexture2D","absorptionRampTexture"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,iBACO,SAASA,wBAAAA,GAAAA;IACd,OAAO;QACLC,IAAMC,EAAAA,gBAAAA;QACNC,IAAM,EAAA,kBAAA;AACNC,QAAAA,QAAAA,CAAAA,GAAAA;AACE,YAAA,OAAOC,WAAY,CAAA;AACjB,gBAAA;oBACEF,IAAM,EAAA,YAAA;oBACNG,WAAa,EAAA,4DAAA;oBACbC,IAAM,EAAA,KAAA;oBACNC,OAAS,EAAA;wBAAEC,QAAU,EAAA,CAAA;wBAAGC,QAAU,EAAA;AAAE,qBAAA;oBACpCC,OAAS,EAAA,CAAA;AACTC,oBAAAA,GAAAA,CAAAA,CAA4BC,KAAK,EAAA;AAC/BA,wBAAAA,KAAAA,CAAMC,GAAG,CAAC,CAAA,CAAE,GAAG,IAAI,CAACC,UA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AAUhD,GAAAA,KAAAA,CAAM6C,GAAG,CAAC,CAAE,CAAA;gCAC5B,IAAII,GAAAA;gCACJ,IAAI;oCACFA,GAAM,GAAA,MAAM1B,OAAQ2B,CAAAA,YAAY,CAAYF,OAAAA,CAAAA;AAC9C,iCAAA,CAAE,OAAOG,GAAK,EAAA;AACZC,oCAAAA,OAAAA,CAAQC,KAAK,CAAC,CAAC,mBAAmB,EAAErD,KAAAA,CAAM6C,GAAG,CAAC,CAAE,CAAA,CAAC,EAAE,EAAEM,GAAK,CAAA,CAAA,CAAA;oCAC1DF,GAAM,GAAA,IAAA;AACR;AACA,gCAAA,IAAIA,KAAKK,WAAe,EAAA,EAAA;AACtB,oCAAA,IAAI,CAACd,QAAQ,CAACe,qBAAqB,GAAGN,GAAAA;iCACjC,MAAA;AACLG,oCAAAA,OAAAA,CAAQC,KAAK,CAAC,sBAAA,CAAA;AAChB;AACF;AACF;AACF;AACF;AACD,aAAA,CAAA;AACH;AACF,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"water.js","sources":["../../../../src/utility/serialization/scene/water.ts"],"sourcesContent":["import type { Nullable } from '@zephyr3d/base';\r\nimport { Vector2, Vector3 } from '@zephyr3d/base';\r\nimport type { SceneNode } from '../../../scene';\r\nimport { GraphNode } from '../../../scene';\r\nimport { Water } from '../../../scene/water';\r\nimport { defineProps, type SerializableClass } from '../types';\r\nimport type { WaveGenerator } from '../../../render';\r\nimport { FBMWaveGenerator, FFTWaveGenerator, GerstnerWaveGenerator } from '../../../render';\r\nimport { MAX_GERSTNER_WAVE_COUNT } from '../../../values';\r\nimport type { WaterDebugOutput, WaterMediumMode, WaterRefractionMode } from '../../../material/water';\r\nimport { DEFAULT_SCATTER_ANISOTROPY, WATER_DEBUG_OUTPUTS } from '../../../material/water';\r\nimport type { Texture2D } from '@zephyr3d/device';\r\nimport type { ResourceManager } from '../manager';\r\n\r\n/** @internal */\r\nexport function getFBMWaveGeneratorClass(): SerializableClass {\r\n return {\r\n ctor: FBMWaveGenerator,\r\n name: 'FBMWaveGenerator',\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'NumOctaves',\r\n description: 'Number of FBM noise octaves used to build the wave pattern',\r\n type: 'int',\r\n options: { minValue: 1, maxValue: 8 },\r\n default: 4,\r\n get(this: FBMWaveGenerator, value) {\r\n value.num[0] = this.numOctaves;\r\n },\r\n set(this: FBMWaveGenerator, value) {\r\n this.numOctaves = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Wind',\r\n description: 'Wind direction and speed that drive the FBM waves',\r\n type: 'vec2',\r\n default: [0.1, 0],\r\n options: {\r\n animatable: true\r\n },\r\n get(this: FBMWaveGenerator, value) {\r\n value.num[0] = this.wind.x;\r\n value.num[1] = this.wind.y;\r\n },\r\n set(this: FBMWaveGenerator, value) {\r\n this.wind = new Vector2(value.num[0], value.num[1]);\r\n }\r\n },\r\n {\r\n name: 'Amplitude',\r\n description: 'Wave height amplitude for the FBM wave generator',\r\n type: 'float',\r\n options: { animatable: true, minValue: 0, maxValue: 5 },\r\n default: 0.3,\r\n get(this: FBMWaveGenerator, value) {\r\n value.num[0] = this.amplitude;\r\n },\r\n set(this: FBMWaveGenerator, value) {\r\n this.amplitude = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Frequency',\r\n description: 'Wave frequency for the FBM wave generator',\r\n type: 'float',\r\n options: { animatable: true, minValue: 0, maxValue: 16 },\r\n default: 3,\r\n get(this: FBMWaveGenerator, value) {\r\n value.num[0] = this.frequency;\r\n },\r\n set(this: FBMWaveGenerator, value) {\r\n this.frequency = value.num[0];\r\n }\r\n }\r\n ]);\r\n }\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport function getFFTWaveGeneratorClass(): SerializableClass {\r\n return {\r\n ctor: FFTWaveGenerator,\r\n name: 'FFTWaveGenerator',\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'Alignment',\r\n description: 'How strongly FFT waves align with the wind direction',\r\n type: 'float',\r\n options: { animatable: true, minValue: 0, maxValue: 1 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.alignment;\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.alignment = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Wind',\r\n description: 'Wind direction and speed that drive the FFT waves',\r\n type: 'vec2',\r\n options: {\r\n animatable: true\r\n },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.wind.x;\r\n value.num[1] = this.wind.y;\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.wind = new Vector2(value.num[0], value.num[1]);\r\n }\r\n },\r\n {\r\n name: 'FoamWidth',\r\n description: 'Width of foam bands generated on the wave crests',\r\n type: 'float',\r\n default: 1.2,\r\n options: { animatable: true, minValue: 0, maxValue: 10 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.foamWidth;\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.foamWidth = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'FoamContrast',\r\n description: 'Contrast of the foam pattern on FFT waves',\r\n type: 'float',\r\n default: 7.2,\r\n options: { animatable: true, minValue: 0, maxValue: 10 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.foamContrast;\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.foamContrast = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'WaveLengthCascades',\r\n description: 'Wavelength values for the three FFT wave cascades',\r\n type: 'vec3',\r\n default: [400, 100, 15],\r\n options: { animatable: true, minValue: 0, maxValue: 1000 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.getWaveLength(0);\r\n value.num[1] = this.getWaveLength(1);\r\n value.num[2] = this.getWaveLength(2);\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.setWaveLength(0, value.num[0]);\r\n this.setWaveLength(1, value.num[1]);\r\n this.setWaveLength(2, value.num[2]);\r\n }\r\n },\r\n {\r\n name: 'WaveStrengthCascades',\r\n description: 'Strength values for the three FFT wave cascades',\r\n type: 'vec3',\r\n default: [0.4, 0.4, 0.2],\r\n options: { animatable: true, minValue: 0, maxValue: 1 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.getWaveStrength(0);\r\n value.num[1] = this.getWaveStrength(1);\r\n value.num[2] = this.getWaveStrength(2);\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.setWaveStrength(0, value.num[0]);\r\n this.setWaveStrength(1, value.num[1]);\r\n this.setWaveStrength(2, value.num[2]);\r\n }\r\n },\r\n {\r\n name: 'WaveCroppinessCascades',\r\n description: 'Croppiness values for the three FFT wave cascades',\r\n type: 'vec3',\r\n default: [-1.5, -1.2, -0.5],\r\n options: { animatable: true, minValue: -4, maxValue: 0 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.getWaveCroppiness(0);\r\n value.num[1] = this.getWaveCroppiness(1);\r\n value.num[2] = this.getWaveCroppiness(2);\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.setWaveCroppiness(0, value.num[0]);\r\n this.setWaveCroppiness(1, value.num[1]);\r\n this.setWaveCroppiness(2, value.num[2]);\r\n }\r\n }\r\n ]);\r\n }\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport function getGerstnerWaveGeneratorClass(): SerializableClass {\r\n return {\r\n ctor: GerstnerWaveGenerator,\r\n name: 'GerstnerWaveGenerator',\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'NumWaves',\r\n description: 'Number of independent Gerstner waves summed to form the surface',\r\n type: 'int',\r\n options: { minValue: 1, maxValue: MAX_GERSTNER_WAVE_COUNT },\r\n get(this: GerstnerWaveGenerator, value) {\r\n value.num[0] = this.numWaves;\r\n },\r\n set(this: GerstnerWaveGenerator, value) {\r\n this.numWaves = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Waves',\r\n description: 'Per-wave parameters, one entry per wave in NumWaves order',\r\n type: 'object_array',\r\n options: {\r\n objectTypes: [GerstnerWave]\r\n },\r\n get(this: GerstnerWaveGenerator, value) {\r\n value.object = [];\r\n for (let i = 0; i < this.numWaves; i++) {\r\n const wave = new GerstnerWave();\r\n wave.bind(this, i);\r\n value.object.push(wave);\r\n }\r\n },\r\n set(this: GerstnerWaveGenerator, value) {\r\n const waves = value.object as GerstnerWave[];\r\n // The wave count is ground truth for how many slots the shader\r\n // reads. NumWaves and Waves are applied concurrently during\r\n // deserialization, so this setter must leave the generator in the\r\n // state this array implies regardless of which one runs first.\r\n this.numWaves = waves.length;\r\n for (let i = 0; i < waves.length; i++) {\r\n waves[i].applyTo(this, i);\r\n }\r\n },\r\n add(this: GerstnerWaveGenerator, value, index) {\r\n const wave = value?.object?.[0] as Nullable<GerstnerWave>;\r\n const insertAt = index ?? this.numWaves;\r\n this.insertWave(insertAt);\r\n wave?.applyTo(this, insertAt);\r\n },\r\n delete(this: GerstnerWaveGenerator, index) {\r\n this.deleteWave(index);\r\n }\r\n },\r\n {\r\n name: 'FoamWidth',\r\n description: 'Width of foam bands generated on the wave crests',\r\n type: 'float',\r\n default: 1.2,\r\n options: { animatable: true, minValue: 0, maxValue: 10 },\r\n get(this: GerstnerWaveGenerator, value) {\r\n value.num[0] = this.foamWidth;\r\n },\r\n set(this: GerstnerWaveGenerator, value) {\r\n this.foamWidth = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'FoamContrast',\r\n description: 'Contrast of the foam pattern on Gerstner waves',\r\n type: 'float',\r\n default: 7.2,\r\n options: { animatable: true, minValue: 0, maxValue: 10 },\r\n get(this: GerstnerWaveGenerator, value) {\r\n value.num[0] = this.foamContrast;\r\n },\r\n set(this: GerstnerWaveGenerator, value) {\r\n this.foamContrast = value.num[0];\r\n }\r\n }\r\n ]);\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * A single Gerstner wave, as the editor sees one entry of the\r\n * `Waves` object array on a {@link GerstnerWaveGenerator}.\r\n *\r\n * It behaves as a live view while it is bound: the field setters write the new\r\n * value straight through to the generator's wave buffer, which is what makes an\r\n * edit in the property panel take effect on the water immediately. Without that\r\n * the editor would only touch this object's own fields and the surface would\r\n * keep the previous wave until something else bumped the generator's version.\r\n *\r\n * The binding is transient and scoped to one editor session: `_owner` and\r\n * `_index` are set when the `Waves` getter builds the entry, and the editor\r\n * rebuilds the whole array from that getter after every add/delete. A copy that\r\n * survives a list mutation is never reused, so the cached index cannot drift\r\n * onto a different wave - the same reason it is safe to write through with it.\r\n */\r\nclass GerstnerWave {\r\n private _owner: Nullable<GerstnerWaveGenerator>;\r\n private _index: number;\r\n _direction: number;\r\n _steepness: number;\r\n _amplitude: number;\r\n _length: number;\r\n _omni: boolean;\r\n _originX: number;\r\n _originZ: number;\r\n constructor() {\r\n this._owner = null;\r\n this._index = -1;\r\n this._direction = 0;\r\n this._steepness = 0;\r\n this._amplitude = 0;\r\n this._length = 1;\r\n this._omni = false;\r\n this._originX = 0;\r\n this._originZ = 0;\r\n }\r\n /**\r\n * Binds this entry to a slot of `owner`, so the field setters write through\r\n * to the generator. Called by the `Waves` getter and by `add`; the index is\r\n * the slot the entry currently represents.\r\n * @internal\r\n */\r\n bind(owner: GerstnerWaveGenerator, index: number) {\r\n this._owner = owner;\r\n this._index = index;\r\n this.loadFromOwner(owner, index);\r\n }\r\n /**\r\n * Copies the values in slot `index` of `owner` into this object, refreshing\r\n * the cached fields without writing back.\r\n * @internal\r\n */\r\n loadFromOwner(owner: GerstnerWaveGenerator, index: number) {\r\n this._direction = owner.getWaveDirection(index);\r\n this._steepness = owner.getWaveSteepness(index);\r\n this._amplitude = owner.getWaveAmplitude(index);\r\n this._length = owner.getWaveLength(index);\r\n this._omni = owner.isOmniWave(index);\r\n this._originX = owner.getOriginX(index);\r\n this._originZ = owner.getOriginZ(index);\r\n }\r\n /**\r\n * Writes this object's values into slot `index` of `owner`, unconditionally.\r\n *\r\n * Used by the `Waves` setter for a serialised-in array, whose entries were\r\n * constructed without an owner, and by `add` for a freshly created one. It is\r\n * distinct from the write-through in the field setters, which fire on each\r\n * individual edit.\r\n * @internal\r\n */\r\n applyTo(owner: GerstnerWaveGenerator, index: number) {\r\n owner.setWaveDirection(index, this._direction);\r\n owner.setWaveSteepness(index, this._steepness);\r\n owner.setWaveAmplitude(index, this._amplitude);\r\n owner.setWaveLength(index, this._length);\r\n owner.setOmniWave(index, this._omni);\r\n owner.setOrigin(index, this._originX, this._originZ);\r\n this._owner = owner;\r\n this._index = index;\r\n }\r\n /** @internal */\r\n private writethrough(\r\n setter: (owner: GerstnerWaveGenerator, index: number, val: number) => void,\r\n val: number\r\n ) {\r\n const owner = this._owner;\r\n if (owner) {\r\n setter(owner, this._index, val);\r\n }\r\n }\r\n /** Gets the wave direction angle in radians. */\r\n get direction() {\r\n return this._direction;\r\n }\r\n set direction(val) {\r\n this._direction = val;\r\n this.writethrough((o, i, v) => o.setWaveDirection(i, v), val);\r\n }\r\n /** Gets the wave steepness. */\r\n get steepness() {\r\n return this._steepness;\r\n }\r\n set steepness(val) {\r\n this._steepness = val;\r\n this.writethrough((o, i, v) => o.setWaveSteepness(i, v), val);\r\n }\r\n /** Gets the wave amplitude. */\r\n get amplitude() {\r\n return this._amplitude;\r\n }\r\n set amplitude(val) {\r\n this._amplitude = val;\r\n this.writethrough((o, i, v) => o.setWaveAmplitude(i, v), val);\r\n }\r\n /** Gets the wave length in meters. */\r\n get length() {\r\n return this._length;\r\n }\r\n set length(val) {\r\n this._length = val;\r\n this.writethrough((o, i, v) => o.setWaveLength(i, v), val);\r\n }\r\n /** Gets whether the wave is omni-directional. */\r\n get omni() {\r\n return this._omni;\r\n }\r\n set omni(val) {\r\n this._omni = val;\r\n if (this._owner) {\r\n this._owner.setOmniWave(this._index, val);\r\n }\r\n }\r\n /** Gets the origin X of an omni-directional wave. */\r\n get originX() {\r\n return this._originX;\r\n }\r\n set originX(val) {\r\n this._originX = val;\r\n if (this._owner) {\r\n this._owner.setOrigin(this._index, val, this._originZ);\r\n }\r\n }\r\n /** Gets the origin Z of an omni-directional wave. */\r\n get originZ() {\r\n return this._originZ;\r\n }\r\n set originZ(val) {\r\n this._originZ = val;\r\n if (this._owner) {\r\n this._owner.setOrigin(this._index, this._originX, val);\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function getGerstnerWaveClass(): SerializableClass {\r\n return {\r\n ctor: GerstnerWave,\r\n name: 'GerstnerWave',\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'Direction',\r\n description: 'Wave direction angle in radians',\r\n type: 'float',\r\n options: { animatable: true, minValue: -3.14, maxValue: 3.14 },\r\n get(this: GerstnerWave, value) {\r\n value.num[0] = this.direction;\r\n },\r\n set(this: GerstnerWave, value) {\r\n this.direction = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Steepness',\r\n description: 'Wave steepness. The sum of steepness across waves sets how sharply crests fold',\r\n type: 'float',\r\n options: { animatable: true, minValue: 0, maxValue: 2 },\r\n get(this: GerstnerWave, value) {\r\n value.num[0] = this.steepness;\r\n },\r\n set(this: GerstnerWave, value) {\r\n this.steepness = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Amplitude',\r\n description: 'Wave height amplitude',\r\n type: 'float',\r\n options: { animatable: true, minValue: 0, maxValue: 5 },\r\n get(this: GerstnerWave, value) {\r\n value.num[0] = this.amplitude;\r\n },\r\n set(this: GerstnerWave, value) {\r\n this.amplitude = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Length',\r\n description: 'Wave length in meters',\r\n type: 'float',\r\n options: { animatable: true, minValue: 0, maxValue: 100 },\r\n get(this: GerstnerWave, value) {\r\n value.num[0] = this.length;\r\n },\r\n set(this: GerstnerWave, value) {\r\n this.length = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Omni',\r\n description: 'If true, radiates outward from an origin rather than travelling in one direction',\r\n type: 'bool',\r\n get(this: GerstnerWave, value) {\r\n value.bool[0] = this.omni;\r\n },\r\n set(this: GerstnerWave, value) {\r\n this.omni = value.bool[0];\r\n }\r\n },\r\n {\r\n name: 'Origin',\r\n description: 'Origin of an omni-directional wave, ignored by directional waves',\r\n type: 'vec2',\r\n options: { animatable: true, minValue: -1000, maxValue: 1000 },\r\n get(this: GerstnerWave, value) {\r\n value.num[0] = this.originX;\r\n value.num[1] = this.originZ;\r\n },\r\n set(this: GerstnerWave, value) {\r\n this.originX = value.num[0];\r\n this.originZ = value.num[1];\r\n }\r\n }\r\n ]);\r\n }\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport function getWaterClass(manager: ResourceManager): SerializableClass {\r\n return {\r\n ctor: Water,\r\n name: 'Water',\r\n parent: GraphNode,\r\n createFunc(ctx: SceneNode) {\r\n const node = new Water(ctx.scene!);\r\n node.parent = ctx;\r\n return { obj: node };\r\n },\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'WaveGenerator',\r\n description: 'Wave generator used to drive the water surface',\r\n type: 'object',\r\n default: null,\r\n options: {\r\n objectTypes: [FFTWaveGenerator, FBMWaveGenerator, GerstnerWaveGenerator]\r\n },\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: Water, value) {\r\n value.object[0] = this.waveGenerator ?? null;\r\n },\r\n set(this: Water, value) {\r\n if (!value.object[0]) {\r\n this.waveGenerator = null;\r\n } else {\r\n this.waveGenerator = value.object[0] as WaveGenerator;\r\n }\r\n }\r\n },\r\n {\r\n name: 'GridScale',\r\n description: 'Scale of the water simulation grid',\r\n type: 'float',\r\n default: 1,\r\n options: { minValue: 0, maxValue: 1 },\r\n get(this: Water, value) {\r\n value.num[0] = this.gridScale;\r\n },\r\n set(this: Water, value) {\r\n this.gridScale = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Wireframe',\r\n description: 'If true, renders the water surface as wireframe',\r\n type: 'bool',\r\n default: false,\r\n get(this: Water, value) {\r\n value.bool[0] = this.wireframe;\r\n },\r\n set(this: Water, value) {\r\n this.wireframe = value.bool[0];\r\n }\r\n },\r\n {\r\n name: 'AnimationSpeed',\r\n description: 'Playback speed of wave animation',\r\n type: 'float',\r\n default: 1,\r\n options: { animatable: true, minValue: 0, maxValue: 100 },\r\n get(this: Water, value) {\r\n value.num[0] = this.animationSpeed;\r\n },\r\n set(this: Water, value) {\r\n this.animationSpeed = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Infinite',\r\n description:\r\n 'Draw the surface as an unbounded ocean reaching the horizon instead of a body of water ending at the node extent. Reaches the horizon without enlarging the camera far plane, so near-scene depth precision is unaffected. Leave off for ponds, lakes and pools, which have an edge.',\r\n type: 'bool',\r\n default: false,\r\n get(this: Water, value) {\r\n value.bool[0] = this.infinite;\r\n },\r\n set(this: Water, value) {\r\n this.infinite = value.bool[0];\r\n }\r\n },\r\n {\r\n name: 'ViewDistance',\r\n description:\r\n 'How far the surface is built out from the camera, in meters, or 0 to derive it from the true horizon distance for the camera height. Keep the sky AerialPerspectiveDistance at least this large, or the far water stops converging towards the sky colour and the hard band comes back.',\r\n type: 'float',\r\n default: 0,\r\n options: { minValue: 0, maxValue: 100000 },\r\n isHidden(this: Water) {\r\n return !this.infinite;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.viewDistance;\r\n },\r\n set(this: Water, value) {\r\n this.viewDistance = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'CausticsEnabled',\r\n description: 'Whether the water projects caustics onto the geometry below it',\r\n type: 'bool',\r\n default: true,\r\n get(this: Water, value) {\r\n value.bool[0] = this.causticsEnabled;\r\n },\r\n set(this: Water, value) {\r\n this.causticsEnabled = value.bool[0];\r\n }\r\n },\r\n {\r\n name: 'CausticsIntensity',\r\n description: 'Strength of the caustic contrast',\r\n type: 'float',\r\n default: 1,\r\n options: { animatable: true, minValue: 0, maxValue: 5 },\r\n isHidden(this: Water) {\r\n return !this.causticsEnabled;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.causticsIntensity;\r\n },\r\n set(this: Water, value) {\r\n this.causticsIntensity = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'CausticsDepth',\r\n description: 'Depth in meters below the surface where the caustics are in focus',\r\n type: 'float',\r\n default: 4,\r\n options: { animatable: true, minValue: 0.01, maxValue: 100 },\r\n isHidden(this: Water) {\r\n return !this.causticsEnabled;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.causticsDepth;\r\n },\r\n set(this: Water, value) {\r\n this.causticsDepth = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'CausticsRange',\r\n description: 'Furthest distance in meters from the camera the caustic map reaches',\r\n type: 'float',\r\n default: 4,\r\n options: { minValue: 1, maxValue: 1000 },\r\n isHidden(this: Water) {\r\n return !this.causticsEnabled;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.causticsRange;\r\n },\r\n set(this: Water, value) {\r\n this.causticsRange = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'CausticsFadeDistance',\r\n description:\r\n 'Width in meters the caustics fade out over at the edge of the map, or 0 to derive it from the range',\r\n type: 'float',\r\n default: 0,\r\n options: { minValue: 0, maxValue: 100 },\r\n isHidden(this: Water) {\r\n return !this.causticsEnabled;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.causticsFadeDistance;\r\n },\r\n set(this: Water, value) {\r\n this.causticsFadeDistance = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'CausticsSceneDepth',\r\n description:\r\n 'Land caustics on the scene instead of on a plane at CausticsDepth. Reuses the sun shadow cascade, so it costs no extra geometry pass; WebGL2 keeps the plane, which its shadow map format cannot avoid.',\r\n type: 'bool',\r\n default: true,\r\n get(this: Water, value) {\r\n value.bool[0] = this.causticsSceneDepth;\r\n },\r\n set(this: Water, value) {\r\n this.causticsSceneDepth = value.bool[0];\r\n }\r\n },\r\n {\r\n name: 'CausticsWarp',\r\n description:\r\n 'How strongly caustic map texels are concentrated near the camera; ignored while the map already fits the water within range',\r\n type: 'float',\r\n default: 1.5,\r\n options: { minValue: 0, maxValue: 8 },\r\n isHidden(this: Water) {\r\n return !this.causticsEnabled;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.causticsWarp;\r\n },\r\n set(this: Water, value) {\r\n this.causticsWarp = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'UnderwaterEnabled',\r\n description:\r\n 'Whether a camera inside this water sees it from the inside: the medium over the whole scene, the sky replaced by water, and the surface read from below with its Snell window. Atmospheric fog is suppressed while submerged.',\r\n type: 'bool',\r\n default: true,\r\n get(this: Water, value) {\r\n value.bool[0] = this.underwaterEnabled;\r\n },\r\n set(this: Water, value) {\r\n this.underwaterEnabled = value.bool[0];\r\n }\r\n },\r\n {\r\n name: 'UnderwaterAmbientIntensity',\r\n description:\r\n 'Scale on the downwelling sky light filling the water column. This is what the water fades to in the distance, so it sets how bright the underwater haze reads.',\r\n type: 'float',\r\n default: 1,\r\n options: { animatable: true, minValue: 0, maxValue: 5 },\r\n isHidden(this: Water) {\r\n return !this.underwaterEnabled;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.underwaterAmbientIntensity;\r\n },\r\n set(this: Water, value) {\r\n this.underwaterAmbientIntensity = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'UnderwaterGodRays',\r\n description:\r\n 'Whether shafts of sunlight are marched through the water column. Reads the caustic map as the surface transmittance, so the shafts carry the pattern that lands on the sea bed; needs CausticsEnabled.',\r\n type: 'bool',\r\n default: true,\r\n isHidden(this: Water) {\r\n return !this.underwaterEnabled;\r\n },\r\n get(this: Water, value) {\r\n value.bool[0] = this.underwaterGodRays;\r\n },\r\n set(this: Water, value) {\r\n this.underwaterGodRays = value.bool[0];\r\n }\r\n },\r\n {\r\n name: 'UnderwaterGodRayIntensity',\r\n description: 'Strength of the light shafts, 1 for the value the medium implies',\r\n type: 'float',\r\n default: 1,\r\n options: { animatable: true, minValue: 0, maxValue: 5 },\r\n isHidden(this: Water) {\r\n return !this.underwaterEnabled || !this.underwaterGodRays;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.underwaterGodRayIntensity;\r\n },\r\n set(this: Water, value) {\r\n this.underwaterGodRayIntensity = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'UnderwaterGodRaySteps',\r\n description:\r\n 'Samples taken along each view ray for the light shafts. Raise it when the shafts read as grain rather than as beams.',\r\n type: 'int',\r\n default: 24,\r\n options: { minValue: 4, maxValue: 96 },\r\n isHidden(this: Water) {\r\n return !this.underwaterEnabled || !this.underwaterGodRays;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.underwaterGodRaySteps;\r\n },\r\n set(this: Water, value) {\r\n this.underwaterGodRaySteps = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'UnderwaterGodRayShadow',\r\n description:\r\n 'Whether geometry standing in the water breaks the light shafts. The shafts come from the caustic map, which knows only what the surface did to the sunlight, so without this a shaft runs straight through a piling. Costs a shadow map lookup per march step.',\r\n type: 'bool',\r\n default: false,\r\n isHidden(this: Water) {\r\n return !this.underwaterEnabled || !this.underwaterGodRays;\r\n },\r\n get(this: Water, value) {\r\n value.bool[0] = this.underwaterGodRayShadow;\r\n },\r\n set(this: Water, value) {\r\n this.underwaterGodRayShadow = value.bool[0];\r\n }\r\n },\r\n {\r\n name: 'UnderwaterHysteresis',\r\n description:\r\n 'Half-width in meters of the dead band around the surface the submerged test uses, so a camera at water level does not flip state every frame',\r\n type: 'float',\r\n default: 0.05,\r\n options: { minValue: 0, maxValue: 2 },\r\n isHidden(this: Water) {\r\n return !this.underwaterEnabled;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.underwaterHysteresis;\r\n },\r\n set(this: Water, value) {\r\n this.underwaterHysteresis = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'MediumMode',\r\n description:\r\n 'How the water medium attenuates light: physical coefficients, or the legacy ramp textures',\r\n type: 'string',\r\n default: 'physical',\r\n options: {\r\n enum: {\r\n labels: ['Physical', 'Ramp'],\r\n values: ['physical', 'ramp']\r\n }\r\n },\r\n get(this: Water, value) {\r\n value.str[0] = this.material.mediumMode;\r\n },\r\n set(this: Water, value) {\r\n this.material.mediumMode = value.str[0] as WaterMediumMode;\r\n }\r\n },\r\n {\r\n name: 'RefractionMode',\r\n description:\r\n 'How the refracted view sample is located. March walks the refracted ray against the scene depth and samples where it lands, which keeps the sample on the object behind the water; Offset skips the search and displaces the screen UV by the wave normal, which costs no depth fetches but samples the wrong point. Use Offset on hardware that cannot afford the search.',\r\n type: 'string',\r\n default: 'march',\r\n options: {\r\n enum: {\r\n labels: ['March (accurate)', 'Offset (cheap)'],\r\n values: ['march', 'offset']\r\n }\r\n },\r\n get(this: Water, value) {\r\n value.str[0] = this.material.refractionMode;\r\n },\r\n set(this: Water, value) {\r\n this.material.refractionMode = value.str[0] as WaterRefractionMode;\r\n }\r\n },\r\n {\r\n name: 'DebugOutput',\r\n description:\r\n 'Debugging aid: replaces the water colour with one of the shading terms it is built from, so a broken term can be identified by eye',\r\n type: 'string',\r\n default: 'none',\r\n options: {\r\n enum: {\r\n labels: WATER_DEBUG_OUTPUTS.map((e) => e.label),\r\n values: WATER_DEBUG_OUTPUTS.map((e) => e.value)\r\n }\r\n },\r\n get(this: Water, value) {\r\n value.str[0] = this.debugOutput;\r\n },\r\n set(this: Water, value) {\r\n this.debugOutput = value.str[0] as WaterDebugOutput;\r\n }\r\n },\r\n {\r\n name: 'Absorption',\r\n description: 'Absorption coefficient sigma_a of the water medium, per meter, per channel',\r\n type: 'rgb',\r\n default: [1.0, 0.25, 0.15],\r\n options: { animatable: true, minValue: 0, maxValue: 10 },\r\n isHidden(this: Water) {\r\n return this.material.mediumMode !== 'physical';\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.absorption.x;\r\n value.num[1] = this.material.absorption.y;\r\n value.num[2] = this.material.absorption.z;\r\n },\r\n set(this: Water, value) {\r\n this.material.absorption = new Vector3(value.num[0], value.num[1], value.num[2]);\r\n }\r\n },\r\n {\r\n name: 'AbsorptionScale',\r\n description: 'Scale for the absorption coefficient',\r\n type: 'float',\r\n default: 1,\r\n options: { animatable: true, minValue: 0, maxValue: 10 },\r\n isHidden(this: Water) {\r\n return this.material.mediumMode !== 'physical';\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.absorptionScale;\r\n },\r\n set(this: Water, value) {\r\n this.material.absorptionScale = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Scattering',\r\n description: 'Scattering coefficient sigma_s of the water medium, per meter, per channel',\r\n type: 'rgb',\r\n default: [0.05, 0.12, 0.18],\r\n options: { animatable: true, minValue: 0, maxValue: 10 },\r\n isHidden(this: Water) {\r\n return this.material.mediumMode !== 'physical';\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.scattering.x;\r\n value.num[1] = this.material.scattering.y;\r\n value.num[2] = this.material.scattering.z;\r\n },\r\n set(this: Water, value) {\r\n this.material.scattering = new Vector3(value.num[0], value.num[1], value.num[2]);\r\n }\r\n },\r\n {\r\n name: 'ScatteringScale',\r\n description: 'Scale for the scattering coefficient',\r\n type: 'float',\r\n default: 1,\r\n options: { animatable: true, minValue: 0, maxValue: 10 },\r\n isHidden(this: Water) {\r\n return this.material.mediumMode !== 'physical';\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.scatteringScale;\r\n },\r\n set(this: Water, value) {\r\n this.material.scatteringScale = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'DepthScale',\r\n description: 'Depth attenuation scale for the water material (ramp medium only)',\r\n type: 'float',\r\n default: 10,\r\n options: { animatable: true, minValue: 0, maxValue: 100 },\r\n isHidden(this: Water) {\r\n return this.material.mediumMode !== 'ramp';\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.depthMulti;\r\n },\r\n set(this: Water, value) {\r\n this.material.depthMulti = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'ReflectionStrength',\r\n description:\r\n 'Scale on the Fresnel reflectance, 1 for the physical value. Lower it to trade the reflection away and show more of what is beneath the surface.',\r\n type: 'float',\r\n default: 1,\r\n options: { animatable: true, minValue: 0, maxValue: 1 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.reflectionStrength;\r\n },\r\n set(this: Water, value) {\r\n this.material.reflectionStrength = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'SubsurfaceIntensity',\r\n description:\r\n 'Strength of the sunlight scattered forward through a wave crest, which is what makes a backlit crest glow. Grazing views of a low sun show it; looking down at the water does not.',\r\n type: 'float',\r\n default: 1.5,\r\n options: { animatable: true, minValue: 0, maxValue: 10 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.subsurfaceIntensity;\r\n },\r\n set(this: Water, value) {\r\n this.material.subsurfaceIntensity = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'SubsurfaceSteepness',\r\n description:\r\n 'How sharply surface tilt gates the subsurface glow. Higher makes gentle swell glow too; lower restricts it to steep wave flanks.',\r\n type: 'float',\r\n default: 60,\r\n options: { animatable: true, minValue: 0, maxValue: 100 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.subsurfaceSteepness;\r\n },\r\n set(this: Water, value) {\r\n this.material.subsurfaceSteepness = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'SunScatteringIntensity',\r\n description:\r\n 'Strength of the sunlight scattered out of the water column towards the eye, 1 for the value the medium coefficients imply. This is what makes a shadow on the water darken the water itself and a low sun tint it; 0 leaves the body lit by the environment alone.',\r\n type: 'float',\r\n default: 1,\r\n options: { animatable: true, minValue: 0, maxValue: 4 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.sunScatteringIntensity;\r\n },\r\n set(this: Water, value) {\r\n this.material.sunScatteringIntensity = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'FoamAmount',\r\n description:\r\n 'Coverage of the foam on breaking wave crests, mapped from the folding the wave generator reports. 0 disables crest foam. Independent of ShoreFoamAmount.',\r\n type: 'float',\r\n default: 1,\r\n options: { animatable: true, minValue: 0, maxValue: 4 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.foamAmount;\r\n },\r\n set(this: Water, value) {\r\n this.material.foamAmount = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'FoamFalloff',\r\n description:\r\n 'Falloff applied to crest foam coverage. Above 1 pushes light folding towards no foam at all, so only a genuinely broken crest shows - which is what keeps a windy sea from turning uniformly white.',\r\n type: 'float',\r\n default: 1.5,\r\n options: { animatable: true, minValue: 0.01, maxValue: 8 },\r\n isHidden(this: Water) {\r\n return this.material.foamAmount <= 0;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.foamFalloff;\r\n },\r\n set(this: Water, value) {\r\n this.material.foamFalloff = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'FoamColor',\r\n description:\r\n 'Diffuse albedo of the foam, shared by the crest foam and the shoreline foam. Slightly off-white and slightly blue - sea foam is water and air, and a pure white one reads as snow.',\r\n type: 'rgb',\r\n default: [0.92, 0.95, 0.97],\r\n options: { animatable: true, minValue: 0, maxValue: 1 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.foamColor.x;\r\n value.num[1] = this.material.foamColor.y;\r\n value.num[2] = this.material.foamColor.z;\r\n },\r\n set(this: Water, value) {\r\n this.material.foamColor = new Vector3(value.num[0], value.num[1], value.num[2]);\r\n }\r\n },\r\n {\r\n name: 'ShoreFoamAmount',\r\n description:\r\n 'Coverage of the foam that collects where the water meets a surface - the waterline on a shelving bed, and the collar around a piling or a hull. 0 disables it, which also removes its cost. Independent of the crest foam the wave generator produces. Requires WebGL2 or WebGPU.',\r\n type: 'float',\r\n default: 0,\r\n // Deliberately not animatable: crossing zero switches the whole\r\n // feature in and out of the shader, so an animation curve driving this\r\n // through zero rebuilds the program on the way past.\r\n options: { minValue: 0, maxValue: 4 },\r\n get(this: Water, value) {\r\n value.num[0] = this.shoreFoamAmount;\r\n },\r\n set(this: Water, value) {\r\n this.shoreFoamAmount = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'ShoreFoamDepth',\r\n description:\r\n 'How far the foam band reaches from the surface behind it, in meters. Over a bed this is a depth of water; against something vertical it is the horizontal distance to its side, and one value serves both. How wide that is on screen depends on the geometry: a thin line on a steep drop-off, a broad stretch on a flat shelf.',\r\n type: 'float',\r\n default: 0.5,\r\n options: { animatable: true, minValue: 0.001, maxValue: 20 },\r\n isHidden(this: Water) {\r\n return this.shoreFoamAmount <= 0;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.shoreFoamDepth;\r\n },\r\n set(this: Water, value) {\r\n this.shoreFoamDepth = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'ShoreFoamFalloff',\r\n description:\r\n 'Falloff across the foam band. Above 1 pushes the coverage towards the contact line and keeps the outer edge thin and broken.',\r\n type: 'float',\r\n default: 1.5,\r\n options: { animatable: true, minValue: 0.01, maxValue: 8 },\r\n isHidden(this: Water) {\r\n return this.shoreFoamAmount <= 0;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.shoreFoamFalloff;\r\n },\r\n set(this: Water, value) {\r\n this.shoreFoamFalloff = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'ShoreFoamScale',\r\n description:\r\n 'Size of the clumps the band breaks into, as cycles across the band rather than cycles per meter. Being relative to the band width, one value reads the same on a shoreline metres across and on a collar a handspan wide.',\r\n type: 'float',\r\n default: 2.5,\r\n options: { animatable: true, minValue: 0, maxValue: 20 },\r\n isHidden(this: Water) {\r\n return this.shoreFoamAmount <= 0;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.shoreFoamScale;\r\n },\r\n set(this: Water, value) {\r\n this.shoreFoamScale = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'ShoreFoamWashAmount',\r\n description:\r\n 'How far the waterline runs up and back, as a fraction of ShoreFoamDepth. This is what makes the band read as surf rather than as a painted rim; 0 leaves it static. Above 1 the band closes completely at the bottom of the cycle, which looks like the foam blinking out.',\r\n type: 'float',\r\n default: 0.5,\r\n options: { animatable: true, minValue: 0, maxValue: 2 },\r\n isHidden(this: Water) {\r\n return this.shoreFoamAmount <= 0;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.shoreFoamWashAmount;\r\n },\r\n set(this: Water, value) {\r\n this.shoreFoamWashAmount = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'ShoreFoamWashSpeed',\r\n description: 'Run-up cycles per second. Swell rather than wind waves, so well under 1.',\r\n type: 'float',\r\n default: 0.12,\r\n options: { animatable: true, minValue: 0, maxValue: 2 },\r\n isHidden(this: Water) {\r\n return this.shoreFoamAmount <= 0;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.shoreFoamWashSpeed;\r\n },\r\n set(this: Water, value) {\r\n this.shoreFoamWashSpeed = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'ShoreFoamWashScale',\r\n description:\r\n 'Spatial frequency of the run-up phase, in cycles per meter. At 0 the whole waterline rises and falls in lockstep, which reads as the water level itself changing; a cycle every few tens of meters breaks a long shoreline into sections that run out of step with one another.',\r\n type: 'float',\r\n default: 0.03,\r\n options: { animatable: true, minValue: 0, maxValue: 1 },\r\n isHidden(this: Water) {\r\n return this.shoreFoamAmount <= 0;\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.shoreFoamWashScale;\r\n },\r\n set(this: Water, value) {\r\n this.shoreFoamWashScale = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'CheapRefractionDepth',\r\n description:\r\n 'Depth in meters the cheap refraction mode assumes the water is. Sets how strong the distortion looks when RefractionMode is Offset; ignored by March. A constant rather than the measured distance to the bottom, because an offset scaled by that distance paints a second copy of any object breaking the surface.',\r\n type: 'float',\r\n default: 1,\r\n options: { animatable: true, minValue: 0, maxValue: 20 },\r\n isHidden(this: Water) {\r\n return this.material.refractionMode !== 'offset';\r\n },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.cheapRefractionDepth;\r\n },\r\n set(this: Water, value) {\r\n this.material.cheapRefractionDepth = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'RefractionBlur',\r\n description:\r\n 'Scale on how much the medium blurs what is seen through it, 1 for the width the scattering coefficient and the path length imply. Turbid or deep water smudges the bottom; 0 keeps it sharp at any depth.',\r\n type: 'float',\r\n default: 1,\r\n options: { animatable: true, minValue: 0, maxValue: 4 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.refractionBlur;\r\n },\r\n set(this: Water, value) {\r\n this.material.refractionBlur = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'ScatterAnisotropy',\r\n description:\r\n 'Mean cosine of a single scattering event. 0 scatters equally in all directions; higher brightens the water when looking towards the sun through it. Sea water measures near 0.9, but a turbid column blends towards isotropic on its own.',\r\n type: 'float',\r\n default: DEFAULT_SCATTER_ANISOTROPY,\r\n options: { animatable: true, minValue: 0, maxValue: 0.95 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.scatterAnisotropy;\r\n },\r\n set(this: Water, value) {\r\n this.material.scatterAnisotropy = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'RefractionScale',\r\n description:\r\n 'Artistic scale on the refracted view offset. 1 is physical: the view ray is bent by Snell’s law and followed to whatever is behind the water, so the incidence angle, the depth and the perspective are already accounted for. 0 disables refraction.',\r\n type: 'float',\r\n default: 1,\r\n options: { animatable: true, minValue: 0, maxValue: 4 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.refractionScale;\r\n },\r\n set(this: Water, value) {\r\n this.material.refractionScale = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'TAAStrength',\r\n description: 'Temporal anti-aliasing strength for the water surface',\r\n type: 'float',\r\n default: 0.4,\r\n options: { minValue: 0, maxValue: 1 },\r\n get(this: Water, value) {\r\n value.num[0] = this.TAAStrength;\r\n },\r\n set(this: Water, value) {\r\n this.TAAStrength = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'ScatterRampTexture',\r\n description: 'Ramp texture used for water scatter lighting',\r\n type: 'object',\r\n default: null,\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: Water, value) {\r\n value.str[0] = manager.getAssetId(this.material.scatterRampTexture) ?? '';\r\n },\r\n async set(value) {\r\n if (!value) {\r\n this.material.scatterRampTexture = null;\r\n } else {\r\n if (value.str[0]) {\r\n const assetId = value.str[0];\r\n let tex: Nullable<Texture2D>;\r\n try {\r\n tex = await manager.fetchTexture<Texture2D>(assetId);\r\n } catch (err) {\r\n console.error(`Load asset failed: ${value.str[0]}: ${err}`);\r\n tex = null;\r\n }\r\n if (tex?.isTexture2D()) {\r\n this.material.scatterRampTexture = tex;\r\n } else {\r\n console.error('Invalid texture type');\r\n }\r\n }\r\n }\r\n }\r\n },\r\n {\r\n name: 'AbsorptionRampTexture',\r\n description: 'Ramp texture used for water absorption',\r\n type: 'object',\r\n default: null,\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: Water, value) {\r\n value.str[0] = manager.getAssetId(this.material.absorptionRampTexture) ?? '';\r\n },\r\n async set(this: Water, value) {\r\n if (!value) {\r\n this.material.absorptionRampTexture = null;\r\n } else {\r\n if (value.str[0]) {\r\n const assetId = value.str[0];\r\n let tex: Nullable<Texture2D>;\r\n try {\r\n tex = await manager.fetchTexture<Texture2D>(assetId);\r\n } catch (err) {\r\n console.error(`Load asset failed: ${value.str[0]}: ${err}`);\r\n tex = null;\r\n }\r\n if (tex?.isTexture2D()) {\r\n this.material.absorptionRampTexture = tex;\r\n } else {\r\n console.error('Invalid texture type');\r\n }\r\n }\r\n }\r\n }\r\n }\r\n ]);\r\n }\r\n };\r\n}\r\n"],"names":["getFBMWaveGeneratorClass","ctor","FBMWaveGenerator","name","getProps","defineProps","description","type","options","minValue","maxValue","default","get","value","num","numOctaves","set","animatable","wind","x","y","Vector2","amplitude","frequency","getFFTWaveGeneratorClass","FFTWaveGenerator","alignment","foamWidth","foamContrast","getWaveLength","setWaveLength","getWaveStrength","setWaveStrength","getWaveCroppiness","setWaveCroppiness","getGerstnerWaveGeneratorClass","GerstnerWaveGenerator","MAX_GERSTNER_WAVE_COUNT","numWaves","objectTypes","GerstnerWave","object","i","wave","bind","push","waves","length","applyTo","add","index","insertAt","insertWave","delete","deleteWave","_owner","_index","_direction","_steepness","_amplitude","_length","_omni","_originX","_originZ","owner","loadFromOwner","getWaveDirection","getWaveSteepness","getWaveAmplitude","isOmniWave","getOriginX","getOriginZ","setWaveDirection","setWaveSteepness","setWaveAmplitude","setOmniWave","setOrigin","writethrough","setter","val","direction","o","v","steepness","omni","originX","originZ","getGerstnerWaveClass","bool","getWaterClass","manager","Water","parent","GraphNode","createFunc","ctx","node","scene","obj","isNullable","waveGenerator","gridScale","wireframe","animationSpeed","infinite","isHidden","viewDistance","causticsEnabled","causticsIntensity","causticsDepth","causticsRange","causticsFadeDistance","causticsSceneDepth","causticsWarp","underwaterEnabled","underwaterAmbientIntensity","underwaterGodRays","underwaterGodRayIntensity","underwaterGodRaySteps","underwaterGodRayShadow","underwaterHysteresis","enum","labels","values","str","material","mediumMode","refractionMode","WATER_DEBUG_OUTPUTS","map","e","label","debugOutput","absorption","z","Vector3","absorptionScale","scattering","scatteringScale","depthMulti","reflectionStrength","subsurfaceIntensity","subsurfaceSteepness","sunScatteringIntensity","foamAmount","foamFalloff","foamColor","shoreFoamAmount","shoreFoamDepth","shoreFoamFalloff","shoreFoamScale","shoreFoamWashAmount","shoreFoamWashSpeed","shoreFoamWashScale","cheapRefractionDepth","refractionBlur","DEFAULT_SCATTER_ANISOTROPY","scatterAnisotropy","refractionScale","TAAStrength","getAssetId","scatterRampTexture","assetId","tex","fetchTexture","err","console","error","isTexture2D","absorptionRampTexture"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,iBACO,SAASA,wBAAAA,GAAAA;IACd,OAAO;QACLC,IAAMC,EAAAA,gBAAAA;QACNC,IAAM,EAAA,kBAAA;AACNC,QAAAA,QAAAA,CAAAA,GAAAA;AACE,YAAA,OAAOC,WAAY,CAAA;AACjB,gBAAA;oBACEF,IAAM,EAAA,YAAA;oBACNG,WAAa,EAAA,4DAAA;oBACbC,IAAM,EAAA,KAAA;oBACNC,OAAS,EAAA;wBAAEC,QAAU,EAAA,CAAA;wBAAGC,QAAU,EAAA;AAAE,qBAAA;oBACpCC,OAAS,EAAA,CAAA;AACTC,oBAAAA,GAAAA,CAAAA,CAA4BC,KAAK,EAAA;AAC/BA,wBAAAA,KAAAA,CAAMC,GAAG,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AAA,CAAQC,KAAK,CAAC,CAAC,mBAAmB,EAAE1J,KAAAA,CAAM+G,GAAG,CAAC,CAAE,CAAA,CAAC,EAAE,EAAEyC,GAAK,CAAA,CAAA,CAAA;oCAC1DF,GAAM,GAAA,IAAA;AACR;AACA,gCAAA,IAAIA,KAAKK,WAAe,EAAA,EAAA;AACtB,oCAAA,IAAI,CAAC3C,QAAQ,CAAC4C,qBAAqB,GAAGN,GAAAA;iCACjC,MAAA;AACLG,oCAAAA,OAAAA,CAAQC,KAAK,CAAC,sBAAA,CAAA;AAChB;AACF;AACF;AACF;AACF;AACD,aAAA,CAAA;AACH;AACF,KAAA;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../src/utility/serialization/types.ts"],"sourcesContent":["import type { GenericConstructor, Nullable, RequireOptionals } from '@zephyr3d/base';\r\n\r\n/**\r\n * Enumerates supported data types for serializable properties.\r\n *\r\n * This type informs serializers/editors how to interpret and encode values.\r\n * 'bool'|'int'|'float'|'vec2'|'vec3'|'vec4'|'int2'|'int3'|'int4'|'string'|'rgb'|'rgba'|'object'|'object_array'|'embedded'|'command';\r\n *\r\n * @public\r\n */\r\nexport type PropertyType = string;\r\n\r\n/**\r\n * Maps a property type discriminator to the corresponding value lane key.\r\n *\r\n * @public\r\n */\r\nexport type PropertyToType<T extends string> = T extends\r\n | 'float'\r\n | 'vec2'\r\n | 'vec3'\r\n | 'vec4'\r\n | 'int'\r\n | 'int2'\r\n | 'int3'\r\n | 'int4'\r\n | 'rgb'\r\n | 'rgba'\r\n ? 'num'\r\n : T extends 'bool'\r\n ? 'bool'\r\n : T extends 'string'\r\n ? 'str'\r\n : T extends 'object' | 'object_array'\r\n ? 'object'\r\n : 'num' | 'bool' | 'str' | 'object';\r\n/**\r\n * Container for a serializable property's value.\r\n *\r\n * Values are carried in typed arrays (even for single values) to support\r\n * both scalar and array-like properties in a unified shape.\r\n *\r\n * Conventions:\r\n * - `num` carries numeric data for types like `int`, `float`, `vec*`, `int*`, `rgb`, `rgba`\r\n * - `str` carries string data for `string`\r\n * - `bool` carries boolean data for `bool`\r\n * - `object` carries references/instances for `object`, `object_array`, `embedded`\r\n *\r\n * Only the relevant field(s) for the property's {@link PropertyType} will be populated.\r\n *\r\n * @public\r\n */\r\nexport type PropertyValue = {\r\n /** Numeric lane(s) for numeric, vector, or color types. */\r\n num?: number[];\r\n /** String lane(s) for text properties. */\r\n str?: string[];\r\n /** Boolean lane(s) for boolean properties. */\r\n bool?: boolean[];\r\n /** Object lane(s) for object references or embedded objects. */\r\n object?: Nullable<object>[];\r\n};\r\n\r\n/**\r\n * Editor-oriented edit types that augment how a property is presented/edited.\r\n *\r\n * This is orthogonal to {@link PropertyType} and is purely an editor hint.\r\n *\r\n * @public\r\n */\r\nexport type PropEdit = 'aabb' | 'quaternion' | 'proptrack' | 'curve1f';\r\n\r\n/**\r\n * Extra scene-node picker hints for a property.\r\n *\r\n * @public\r\n */\r\nexport type PropertySceneNodeOptions = {\r\n kind?: 'node' | 'mesh';\r\n};\r\n\r\n/**\r\n * Additional options controlling how a property is displayed, constrained, and edited.\r\n *\r\n * These options are consumed primarily by an editor/inspector UI, but may\r\n * also influence validation and tooling behavior.\r\n *\r\n * @public\r\n */\r\nexport type PropertyAccessorOptions = {\r\n /** Human-friendly label for UI. Defaults to `name` if omitted. */\r\n label?: string;\r\n /** Logical grouping/category in UI. */\r\n group?: string;\r\n /** Editor presentation hint (e.g., quaternion gizmo, animation track). */\r\n edit?: PropEdit;\r\n /** Minimum numeric value (for sliders/spinners). */\r\n minValue?: number;\r\n /** Maximum numeric value (for sliders/spinners). */\r\n maxValue?: number;\r\n /** Whether string property is multiline. */\r\n multiline?: boolean;\r\n /** Step/speed for numeric editing UI. */\r\n speed?: number;\r\n /** Whether the property can be animated/keyframed. */\r\n animatable?: boolean;\r\n /** Allowed MIME types for file-picker-like editors. */\r\n mimeTypes?: string[];\r\n /** Accept scene hierarchy node drag-drop in the inspector. */\r\n sceneNode?: PropertySceneNodeOptions;\r\n /** Render object-array entries inline instead of expandable nested groups. */\r\n inlineObjectArray?: boolean;\r\n /** Allowed constructor types when choosing/creating object references. */\r\n objectTypes?: GenericConstructor[];\r\n /**\r\n * Optional enumeration metadata.\r\n * `labels[i]` corresponds to `values[i]`.\r\n */\r\n enum?: { labels: string[]; values: unknown[] };\r\n};\r\n\r\n/**\r\n * Returns the property accessor list unchanged while preserving typing.\r\n *\r\n * @public\r\n */\r\nexport function defineProps(accessors: PropertyAccessor<any, 'DUMMY'>[]): PropertyAccessor[] {\r\n return accessors;\r\n}\r\n\r\n/**\r\n * Descriptor for a serializable property of a class/type.\r\n *\r\n * This binds together:\r\n * - Metadata: `type`, `name`, `default`, `readonly`, `persistent`, `options`\r\n * - Accessors: `get`, `set`, `add`, `delete`, `create` for manipulating the underlying object state\r\n * - Predicates: `isValid`, `isNullable`, `isHidden` to control UI and validation\r\n * - Commands: `command` for action-style properties (`type: 'command'`)\r\n * - Utilities: `getDefaultValue` to compute defaults dynamically\r\n *\r\n * The accessors are invoked with `this` bound to the owning object instance.\r\n *\r\n * @typeParam T - The instance type that owns the property.\r\n * @public\r\n */\r\nexport type PropertyAccessor<T = object, U extends string = ''> = {\r\n /** The storage/serialization data type. */\r\n type: PropertyType;\r\n /** Unique property name (stable identifier for tooling/serialization). */\r\n name: string;\r\n /** Description of this property */\r\n description?: string;\r\n /**\r\n * Optional evaluation phase/order hint (lower runs earlier).\r\n * Useful for staged initialization or batched updates in editors.\r\n */\r\n phase?: number;\r\n /** If true, the property is read-only in UI and programmatic setters may be disallowed. */\r\n readonly?: boolean;\r\n /** Default value used if none is provided. Can be a primitive, array, or object. */\r\n default?: any;\r\n /**\r\n * If true, the property is persisted during save/serialize.\r\n * Non-persistent properties may be computed or session-only.\r\n */\r\n //persistent?: boolean;\r\n /** Editor and validation options for this property. */\r\n options?: PropertyAccessorOptions;\r\n /**\r\n * Reads the current value from `this` into the provided `value` container.\r\n *\r\n * Implementations should fully populate the appropriate lane(s) (e.g., `num`, `str`, etc.)\r\n * according to the property's {@link PropertyType}.\r\n *\r\n * @param value - Output container to be filled by the getter.\r\n */\r\n get: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>\r\n ) => void;\r\n /**\r\n * Writes an incoming value to `this`.\r\n *\r\n * For array-like properties, `index` can target a specific element.\r\n * Implementations should read from the appropriate lane(s) of `value` according to {@link PropertyType}.\r\n *\r\n * @param value - Input container carrying the new value.\r\n * @param index - Optional element index for array-like properties.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n set?: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>,\r\n index?: number\r\n ) => void | Promise<void>;\r\n /**\r\n * Creates a new embedded/contained object for object-like properties.\r\n *\r\n * Typically used for `embedded` or `object_array` to instantiate an element.\r\n *\r\n * @param ctor - Constructor to instantiate.\r\n * @param index - Target index where the new object will be inserted.\r\n * @returns The newly created object instance.\r\n */\r\n create?: (this: T, ctor: GenericConstructor, index: number) => Nullable<object>;\r\n /**\r\n * Deletes an element from an array-like property or clears a value.\r\n *\r\n * @param index - Target element index.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n delete?: (this: T, index: number) => void | Promise<void>;\r\n /**\r\n * Adds a new element/value to an array-like property.\r\n *\r\n * If `index` is omitted, implementations may append to the end.\r\n *\r\n * @param value - The value to add (read appropriate lane(s) per {@link PropertyType}).\r\n * @param index - Optional insertion index.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n add?: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>,\r\n index?: number\r\n ) => void | Promise<void>;\r\n /**\r\n * Validates the current state of `this` with respect to this property.\r\n *\r\n * Returning `false` may block serialization or UI confirmation.\r\n *\r\n * @returns `true` if valid, otherwise `false`.\r\n */\r\n isValid?: (this: T) => boolean;\r\n /**\r\n * Indicates whether this property is serializable. Default is serializable if not present.\r\n *\r\n * @returns `true` if persistent, otherwise `false`.\r\n */\r\n isPersistent?: (this: T) => boolean;\r\n /**\r\n * Indicates whether a specific element or slot may be `null` or `undefined`.\r\n *\r\n * Applies to array-like or optional properties.\r\n *\r\n * @param index - Target element index.\r\n * @returns `true` if nullable, otherwise `false`.\r\n */\r\n isNullable?: (this: T, index: number) => boolean;\r\n /**\r\n * Controls visibility of a specific element or the property in UI.\r\n *\r\n * @param index - Target element index.\r\n * @param obj - Value at index\r\n * @returns `true` if hidden, otherwise `false`.\r\n */\r\n isHidden?: (this: T, index: number, obj?: unknown) => boolean;\r\n /**\r\n * Executes a command-style property.\r\n *\r\n * Only meaningful for `type: 'command'`. Return value may indicate success or toggle state.\r\n *\r\n * @param index - Optional command index for multi-command groups.\r\n * @returns Command result, commonly a boolean for toggle-like actions.\r\n */\r\n command?: (this: T, index: number) => boolean;\r\n /**\r\n * Supplies a default value dynamically at runtime.\r\n *\r\n * If provided, this takes precedence over the static `default` field.\r\n */\r\n getDefaultValue?: (this: T) => any;\r\n};\r\n\r\n/**\r\n * Descriptor for a serializable class/type.\r\n *\r\n * This defines how a class is identified, constructed, and inspected for properties.\r\n * Editors and serializers can use this metadata to instantiate objects, load initial\r\n * parameters, and enumerate property accessors.\r\n *\r\n * @public\r\n */\r\nexport type SerializableClass = {\r\n /** Concrete constructor for the serializable class. */\r\n ctor: GenericConstructor;\r\n /** Optional parent/superclass constructor to represent inheritance in tooling. */\r\n parent?: GenericConstructor;\r\n /** If true, suppresses title rendering in UI for compact displays. */\r\n noTitle?: boolean;\r\n /** Display name used by tooling and editors. */\r\n name: string;\r\n /**\r\n * Custom factory to create an instance and optionally control property loading.\r\n *\r\n * If `loadProps` is `false`, the caller may skip default property loading\r\n * (useful for lazy or staged initialization).\r\n *\r\n * @param ctx - Optional construction context (editor/runtime-specific).\r\n * @param init - Optional initialization payload.\r\n * @returns The created object and a `loadProps` hint.\r\n */\r\n createFunc?: (\r\n ctx?: any,\r\n init?: any\r\n ) => { obj: any; loadProps?: boolean } | Promise<{ obj: any; loadProps?: boolean }>;\r\n /**\r\n * Extracts initialization parameters from an instance suitable for re-creation.\r\n *\r\n * This is the inverse of `createFunc`'s `init` argument, enabling round-trip\r\n * serialization of constructor/initializer data.\r\n *\r\n * @param obj - The instance to introspect.\r\n * @returns An initialization payload (serializable).\r\n */\r\n getInitParams?: (obj: any, flags: { saveProps: boolean }) => any;\r\n /**\r\n * Enumerates property accessors for this class.\r\n *\r\n * The returned list defines the full set of serializable/editor-visible properties.\r\n *\r\n * @returns Array of property accessors.\r\n */\r\n getProps: () => PropertyAccessor<any>[];\r\n};\r\n"],"names":["defineProps","accessors"],"mappings":"AAyHA;;;;IAKO,SAASA,WAAAA,CAAYC,SAA2C,EAAA;IACrE,OAAOA,SAAAA;AACT;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../src/utility/serialization/types.ts"],"sourcesContent":["import type { GenericConstructor, Nullable, RequireOptionals } from '@zephyr3d/base';\r\n\r\n/**\r\n * Enumerates supported data types for serializable properties.\r\n *\r\n * This type informs serializers/editors how to interpret and encode values.\r\n * 'bool'|'int'|'float'|'vec2'|'vec3'|'vec4'|'int2'|'int3'|'int4'|'string'|'rgb'|'rgba'|'object'|'object_array'|'embedded'|'command';\r\n *\r\n * @public\r\n */\r\nexport type PropertyType = string;\r\n\r\n/**\r\n * Maps a property type discriminator to the corresponding value lane key.\r\n *\r\n * @public\r\n */\r\nexport type PropertyToType<T extends string> = T extends\r\n | 'float'\r\n | 'vec2'\r\n | 'vec3'\r\n | 'vec4'\r\n | 'int'\r\n | 'int2'\r\n | 'int3'\r\n | 'int4'\r\n | 'rgb'\r\n | 'rgba'\r\n ? 'num'\r\n : T extends 'bool'\r\n ? 'bool'\r\n : T extends 'string'\r\n ? 'str'\r\n : T extends 'object' | 'object_array'\r\n ? 'object'\r\n : 'num' | 'bool' | 'str' | 'object';\r\n/**\r\n * Container for a serializable property's value.\r\n *\r\n * Values are carried in typed arrays (even for single values) to support\r\n * both scalar and array-like properties in a unified shape.\r\n *\r\n * Conventions:\r\n * - `num` carries numeric data for types like `int`, `float`, `vec*`, `int*`, `rgb`, `rgba`\r\n * - `str` carries string data for `string`\r\n * - `bool` carries boolean data for `bool`\r\n * - `object` carries references/instances for `object`, `object_array`, `embedded`\r\n *\r\n * Only the relevant field(s) for the property's {@link PropertyType} will be populated.\r\n *\r\n * @public\r\n */\r\nexport type PropertyValue = {\r\n /** Numeric lane(s) for numeric, vector, or color types. */\r\n num?: number[];\r\n /** String lane(s) for text properties. */\r\n str?: string[];\r\n /** Boolean lane(s) for boolean properties. */\r\n bool?: boolean[];\r\n /** Object lane(s) for object references or embedded objects. */\r\n object?: Nullable<object>[];\r\n};\r\n\r\n/**\r\n * Editor-oriented edit types that augment how a property is presented/edited.\r\n *\r\n * This is orthogonal to {@link PropertyType} and is purely an editor hint.\r\n *\r\n * @public\r\n */\r\nexport type PropEdit = 'aabb' | 'quaternion' | 'proptrack' | 'curve1f';\r\n\r\n/**\r\n * Extra scene-node picker hints for a property.\r\n *\r\n * @public\r\n */\r\nexport type PropertySceneNodeOptions = {\r\n kind?: 'node' | 'mesh';\r\n};\r\n\r\n/**\r\n * Additional options controlling how a property is displayed, constrained, and edited.\r\n *\r\n * These options are consumed primarily by an editor/inspector UI, but may\r\n * also influence validation and tooling behavior.\r\n *\r\n * @public\r\n */\r\nexport type PropertyAccessorOptions = {\r\n /** Human-friendly label for UI. Defaults to `name` if omitted. */\r\n label?: string;\r\n /** Logical grouping/category in UI. */\r\n group?: string;\r\n /** Whether the inspector group should be expanded by default. */\r\n defaultOpen?: boolean;\r\n /** Editor presentation hint (e.g., quaternion gizmo, animation track). */\r\n edit?: PropEdit;\r\n /** Minimum numeric value (for sliders/spinners). */\r\n minValue?: number;\r\n /** Maximum numeric value (for sliders/spinners). */\r\n maxValue?: number;\r\n /** Whether string property is multiline. */\r\n multiline?: boolean;\r\n /** Step/speed for numeric editing UI. */\r\n speed?: number;\r\n /** Whether the property can be animated/keyframed. */\r\n animatable?: boolean;\r\n /** Allowed MIME types for file-picker-like editors. */\r\n mimeTypes?: string[];\r\n /** Accept scene hierarchy node drag-drop in the inspector. */\r\n sceneNode?: PropertySceneNodeOptions;\r\n /** Render object-array entries inline instead of expandable nested groups. */\r\n inlineObjectArray?: boolean;\r\n /** Allowed constructor types when choosing/creating object references. */\r\n objectTypes?: GenericConstructor[];\r\n /**\r\n * Optional enumeration metadata.\r\n * `labels[i]` corresponds to `values[i]`.\r\n */\r\n enum?: { labels: string[]; values: unknown[] };\r\n};\r\n\r\n/**\r\n * Returns the property accessor list unchanged while preserving typing.\r\n *\r\n * @public\r\n */\r\nexport function defineProps(accessors: PropertyAccessor<any, 'DUMMY'>[]): PropertyAccessor[] {\r\n return accessors;\r\n}\r\n\r\n/**\r\n * Descriptor for a serializable property of a class/type.\r\n *\r\n * This binds together:\r\n * - Metadata: `type`, `name`, `default`, `readonly`, `persistent`, `options`\r\n * - Accessors: `get`, `set`, `add`, `delete`, `create` for manipulating the underlying object state\r\n * - Predicates: `isValid`, `isNullable`, `isHidden` to control UI and validation\r\n * - Commands: `command` for action-style properties (`type: 'command'`)\r\n * - Utilities: `getDefaultValue` to compute defaults dynamically\r\n *\r\n * The accessors are invoked with `this` bound to the owning object instance.\r\n *\r\n * @typeParam T - The instance type that owns the property.\r\n * @public\r\n */\r\nexport type PropertyAccessor<T = object, U extends string = ''> = {\r\n /** The storage/serialization data type. */\r\n type: PropertyType;\r\n /** Unique property name (stable identifier for tooling/serialization). */\r\n name: string;\r\n /** Description of this property */\r\n description?: string;\r\n /**\r\n * Optional evaluation phase/order hint (lower runs earlier).\r\n * Useful for staged initialization or batched updates in editors.\r\n */\r\n phase?: number;\r\n /** If true, the property is read-only in UI and programmatic setters may be disallowed. */\r\n readonly?: boolean;\r\n /** Default value used if none is provided. Can be a primitive, array, or object. */\r\n default?: any;\r\n /**\r\n * If true, the property is persisted during save/serialize.\r\n * Non-persistent properties may be computed or session-only.\r\n */\r\n //persistent?: boolean;\r\n /** Editor and validation options for this property. */\r\n options?: PropertyAccessorOptions;\r\n /**\r\n * Reads the current value from `this` into the provided `value` container.\r\n *\r\n * Implementations should fully populate the appropriate lane(s) (e.g., `num`, `str`, etc.)\r\n * according to the property's {@link PropertyType}.\r\n *\r\n * @param value - Output container to be filled by the getter.\r\n */\r\n get: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>\r\n ) => void;\r\n /**\r\n * Writes an incoming value to `this`.\r\n *\r\n * For array-like properties, `index` can target a specific element.\r\n * Implementations should read from the appropriate lane(s) of `value` according to {@link PropertyType}.\r\n *\r\n * @param value - Input container carrying the new value.\r\n * @param index - Optional element index for array-like properties.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n set?: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>,\r\n index?: number\r\n ) => void | Promise<void>;\r\n /**\r\n * Creates a new embedded/contained object for object-like properties.\r\n *\r\n * Typically used for `embedded` or `object_array` to instantiate an element.\r\n *\r\n * @param ctor - Constructor to instantiate.\r\n * @param index - Target index where the new object will be inserted.\r\n * @returns The newly created object instance.\r\n */\r\n create?: (this: T, ctor: GenericConstructor, index: number) => Nullable<object>;\r\n /**\r\n * Deletes an element from an array-like property or clears a value.\r\n *\r\n * @param index - Target element index.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n delete?: (this: T, index: number) => void | Promise<void>;\r\n /**\r\n * Adds a new element/value to an array-like property.\r\n *\r\n * If `index` is omitted, implementations may append to the end.\r\n *\r\n * @param value - The value to add (read appropriate lane(s) per {@link PropertyType}).\r\n * @param index - Optional insertion index.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n add?: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>,\r\n index?: number\r\n ) => void | Promise<void>;\r\n /**\r\n * Validates the current state of `this` with respect to this property.\r\n *\r\n * Returning `false` may block serialization or UI confirmation.\r\n *\r\n * @returns `true` if valid, otherwise `false`.\r\n */\r\n isValid?: (this: T) => boolean;\r\n /**\r\n * Indicates whether this property is serializable. Default is serializable if not present.\r\n *\r\n * @returns `true` if persistent, otherwise `false`.\r\n */\r\n isPersistent?: (this: T) => boolean;\r\n /**\r\n * Indicates whether a specific element or slot may be `null` or `undefined`.\r\n *\r\n * Applies to array-like or optional properties.\r\n *\r\n * @param index - Target element index.\r\n * @returns `true` if nullable, otherwise `false`.\r\n */\r\n isNullable?: (this: T, index: number) => boolean;\r\n /**\r\n * Controls visibility of a specific element or the property in UI.\r\n *\r\n * @param index - Target element index.\r\n * @param obj - Value at index\r\n * @returns `true` if hidden, otherwise `false`.\r\n */\r\n isHidden?: (this: T, index: number, obj?: unknown) => boolean;\r\n /**\r\n * Executes a command-style property.\r\n *\r\n * Only meaningful for `type: 'command'`. Return value may indicate success or toggle state.\r\n *\r\n * @param index - Optional command index for multi-command groups.\r\n * @returns Command result, commonly a boolean for toggle-like actions.\r\n */\r\n command?: (this: T, index: number) => boolean;\r\n /**\r\n * Supplies a default value dynamically at runtime.\r\n *\r\n * If provided, this takes precedence over the static `default` field.\r\n */\r\n getDefaultValue?: (this: T) => any;\r\n};\r\n\r\n/**\r\n * Descriptor for a serializable class/type.\r\n *\r\n * This defines how a class is identified, constructed, and inspected for properties.\r\n * Editors and serializers can use this metadata to instantiate objects, load initial\r\n * parameters, and enumerate property accessors.\r\n *\r\n * @public\r\n */\r\nexport type SerializableClass = {\r\n /** Concrete constructor for the serializable class. */\r\n ctor: GenericConstructor;\r\n /** Optional parent/superclass constructor to represent inheritance in tooling. */\r\n parent?: GenericConstructor;\r\n /** If true, suppresses title rendering in UI for compact displays. */\r\n noTitle?: boolean;\r\n /** Display name used by tooling and editors. */\r\n name: string;\r\n /**\r\n * Custom factory to create an instance and optionally control property loading.\r\n *\r\n * If `loadProps` is `false`, the caller may skip default property loading\r\n * (useful for lazy or staged initialization).\r\n *\r\n * @param ctx - Optional construction context (editor/runtime-specific).\r\n * @param init - Optional initialization payload.\r\n * @returns The created object and a `loadProps` hint.\r\n */\r\n createFunc?: (\r\n ctx?: any,\r\n init?: any\r\n ) => { obj: any; loadProps?: boolean } | Promise<{ obj: any; loadProps?: boolean }>;\r\n /**\r\n * Extracts initialization parameters from an instance suitable for re-creation.\r\n *\r\n * This is the inverse of `createFunc`'s `init` argument, enabling round-trip\r\n * serialization of constructor/initializer data.\r\n *\r\n * @param obj - The instance to introspect.\r\n * @returns An initialization payload (serializable).\r\n */\r\n getInitParams?: (obj: any, flags: { saveProps: boolean }) => any;\r\n /**\r\n * Enumerates property accessors for this class.\r\n *\r\n * The returned list defines the full set of serializable/editor-visible properties.\r\n *\r\n * @returns Array of property accessors.\r\n */\r\n getProps: () => PropertyAccessor<any>[];\r\n};\r\n"],"names":["defineProps","accessors"],"mappings":"AA2HA;;;;IAKO,SAASA,WAAAA,CAAYC,SAA2C,EAAA;IACrE,OAAOA,SAAAA;AACT;;;;"}
@@ -59,6 +59,15 @@ import { getDevice } from '../app/api.js';
59
59
  * projector.projectCubemap(environmentMap, shBuffer);
60
60
  * ```
61
61
  */ projectCubemap(cubemap, outBuffer, radianceSource = true) {
62
+ const device = getDevice();
63
+ if (!this._renderTarget.get()) {
64
+ const texture = device.createTexture2D('rgba32f', 3, 3, {
65
+ mipmapping: false
66
+ });
67
+ this._renderTarget.set(device.createFrameBuffer([
68
+ texture
69
+ ], null));
70
+ }
62
71
  this.projectCubemapToTexture(cubemap, this._renderTarget.get(), radianceSource);
63
72
  this._renderTarget.get().getColorAttachments()[0].readPixelsToBuffer(0, 0, 3, 3, 0, 0, outBuffer);
64
73
  }
@@ -154,14 +163,6 @@ import { getDevice } from '../app/api.js';
154
163
  primitive.primitiveType = 'point-list';
155
164
  this._primitive.set(primitive);
156
165
  }
157
- if (!this._renderTarget.get()) {
158
- const texture = device.createTexture2D('rgba32f', 3, 3, {
159
- mipmapping: false
160
- });
161
- this._renderTarget.set(device.createFrameBuffer([
162
- texture
163
- ], null));
164
- }
165
166
  if (!CubemapSHProjector._renderStats) {
166
167
  CubemapSHProjector._renderStats = device.createRenderStateSet();
167
168
  CubemapSHProjector._renderStats.useDepthState().enableTest(false).enableWrite(false);
@@ -1 +1 @@
1
- {"version":3,"file":"shprojector.js","sources":["../../src/utility/shprojector.ts"],"sourcesContent":["import type {\r\n AbstractDevice,\r\n BindGroup,\r\n FrameBuffer,\r\n GPUDataBuffer,\r\n GPUProgram,\r\n RenderStateSet,\r\n TextureCube\r\n} from '@zephyr3d/device';\r\nimport { Primitive } from '../render/primitive';\r\nimport type { Nullable } from '@zephyr3d/base';\r\nimport { Disposable, DRef, Vector4 } from '@zephyr3d/base';\r\nimport { fetchSampler } from './misc';\r\nimport { getDevice } from '../app/api';\r\n\r\n/**\r\n * CubemapSHProjector is responsible for projecting a cubemap texture into spherical harmonics (SH) coefficients.\r\n * This is commonly used for efficient environment lighting approximation in real-time rendering.\r\n *\r\n * The class uses Monte Carlo sampling to compute the first 9 spherical harmonics coefficients (up to order 2)\r\n * from a cubemap texture, which can then be used for ambient lighting calculations.\r\n *\r\n * @example\r\n * ```typescript\r\n * const projector = new CubemapSHProjector(10000);\r\n * const shBuffer = device.createBuffer(4 * 4 * 9, { usage: 'uniform' });\r\n * projector.projectCubemap(environmentCubemap, shBuffer);\r\n * // shBuffer now contains the 9 SH coefficients as RGB values\r\n * projector.dispose();\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class CubemapSHProjector extends Disposable {\r\n private static _programInst: Nullable<GPUProgram> = null;\r\n private static _bindGroupInst: Nullable<BindGroup> = null;\r\n private static _renderStats: Nullable<RenderStateSet> = null;\r\n private readonly _primitive: DRef<Primitive>;\r\n private readonly _renderTarget: DRef<FrameBuffer>;\r\n private readonly _numSamples: number;\r\n /**\r\n * Creates a new CubemapSHProjector instance.\r\n *\r\n * @param numSamples - Number of Monte Carlo samples to use for SH projection.\r\n * Higher values provide better accuracy but slower computation.\r\n * Default is 10000.\r\n */\r\n constructor(numSamples = 10000) {\r\n super();\r\n this._numSamples = numSamples;\r\n this._primitive = new DRef();\r\n this._renderTarget = new DRef();\r\n }\r\n /**\r\n * Projects a cubemap texture into spherical harmonics coefficients and stores them in a GPUBuffer.\r\n *\r\n * The method performs Monte Carlo integration over the sphere to compute the first 9 SH coefficients.\r\n * The results are written to a 3x3 render target where each pixel contains RGB values for one SH coefficient.\r\n * The layout is:\r\n * - (0,0): Y₀₀ (0,1): Y₁₋₁ (0,2): Y₁₀\r\n * - (1,0): Y₁₁ (1,1): Y₂₋₂ (1,2): Y₂₋₁\r\n * - (2,0): Y₂₀ (2,1): Y₂₁ (2,2): Y₂₂\r\n *\r\n * @param cubemap - The input cubemap texture to project\r\n * @param outBuffer - GPU data buffer to receive the computed SH coefficients.\r\n * Must be large enough to hold 9 RGB values (36 floats for RGBA32F format).\r\n *\r\n * @example\r\n * ```typescript\r\n * const shBuffer = device.createDataBuffer(9 * 4 * 4); // 9 coefficients * 4 components * 4 bytes\r\n * projector.projectCubemap(environmentMap, shBuffer);\r\n * ```\r\n */\r\n projectCubemap(cubemap: TextureCube, outBuffer: GPUDataBuffer, radianceSource = true) {\r\n this.projectCubemapToTexture(cubemap, this._renderTarget.get()!, radianceSource);\r\n this._renderTarget.get()!.getColorAttachments()[0].readPixelsToBuffer(0, 0, 3, 3, 0, 0, outBuffer);\r\n }\r\n /**\r\n * Projects a cubemap texture into spherical harmonics coefficients and stores them in a 3x3 texture.\r\n *\r\n * The method performs Monte Carlo integration over the sphere to compute the first 9 SH coefficients.\r\n * The results are written to a 3x3 render target where each pixel contains RGB values for one SH coefficient.\r\n * The layout is:\r\n * - (0,0): Y₀₀ (0,1): Y₁₋₁ (0,2): Y₁₀\r\n * - (1,0): Y₁₁ (1,1): Y₂₋₂ (1,2): Y₂₋₁\r\n * - (2,0): Y₂₀ (2,1): Y₂₁ (2,2): Y₂₂\r\n *\r\n * @param cubemap - The input cubemap texture to project\r\n * @param outFramebuffer - Framebuffer that contains the 3x3 texture to receive the computed SH coefficients in color attachment slot 0.\r\n *\r\n * @example\r\n * ```typescript\r\n * const shTexture = device.createTexture2D('rgba32f', 3, 3); // 9 coefficients * 4 components * 4 bytes\r\n * const shFramebuffer = device.createFrameBuffer([shTexture], null);\r\n * projector.projectCubemapToTexture(environmentMap, shFramebuffer);\r\n * ```\r\n */\r\n projectCubemapToTexture(cubemap: TextureCube, framebuffer: FrameBuffer, radianceSource = true) {\r\n const device = getDevice();\r\n const clearColor = new Vector4(0, 0, 0, 1);\r\n this.init(device);\r\n device.pushDeviceStates();\r\n device.setRenderStates(CubemapSHProjector._renderStats);\r\n device.setProgram(CubemapSHProjector._programInst);\r\n device.setFramebuffer(framebuffer);\r\n device.clearFrameBuffer(clearColor, null, null);\r\n const bindGroup = CubemapSHProjector._bindGroupInst!;\r\n bindGroup.setTexture('cubemap', cubemap, fetchSampler('clamp_linear_nomip'));\r\n bindGroup.setValue('scale', radianceSource ? 1.0 : Math.PI);\r\n device.setBindGroup(0, bindGroup);\r\n this._primitive.get()!.drawInstanced(9);\r\n device.popDeviceStates();\r\n }\r\n /**\r\n * Disposes of all resources allocated by this projector instance.\r\n * Should be called when the projector is no longer needed to prevent memory leaks.\r\n */\r\n protected onDispose() {\r\n super.onDispose();\r\n this._primitive.dispose();\r\n if (this._renderTarget.get()) {\r\n this._renderTarget.get()!.getColorAttachments()[0].dispose();\r\n this._renderTarget.dispose();\r\n }\r\n }\r\n /**\r\n * Initializes the GPU resources needed for SH projection.\r\n * This method is called automatically by projectCubemap() and sets up:\r\n * - Sample directions primitive (Monte Carlo samples on unit sphere)\r\n * - Render target (3x3 RGBA32F texture)\r\n * - Render states (additive blending, no depth test)\r\n * - GPU program for SH evaluation\r\n *\r\n * @param device - The graphics device to create resources with\r\n * @internal\r\n */\r\n private init(device: AbstractDevice) {\r\n if (!this._primitive.get()) {\r\n const samples = new Float32Array(this._numSamples * 4);\r\n for (let i = 0; i < this._numSamples; i++) {\r\n let x1: number, x2: number, s: number;\r\n do {\r\n x1 = Math.random() * 2 - 1;\r\n x2 = Math.random() * 2 - 1;\r\n s = x1 * x1 + x2 * x2;\r\n } while (s >= 1);\r\n const sqrtS = Math.sqrt(1 - s);\r\n samples[i * 4 + 0] = 2 * x1 * sqrtS;\r\n samples[i * 4 + 1] = 2 * x2 * sqrtS;\r\n samples[i * 4 + 2] = 1 - 2 * s;\r\n samples[i * 4 + 3] = (4 * Math.PI) / this._numSamples;\r\n }\r\n const primitive = new Primitive();\r\n primitive.createAndSetVertexBuffer('position_f32x4', samples);\r\n if (device.type === 'webgl') {\r\n primitive.createAndSetVertexBuffer(\r\n 'tex0_f32',\r\n new Float32Array([0, 1, 2, 3, 4, 5, 6, 7, 8]),\r\n 'instance'\r\n );\r\n }\r\n primitive.indexCount = this._numSamples;\r\n primitive.indexStart = 0;\r\n primitive.primitiveType = 'point-list';\r\n this._primitive.set(primitive);\r\n }\r\n\r\n if (!this._renderTarget.get()) {\r\n const texture = device.createTexture2D('rgba32f', 3, 3, {\r\n mipmapping: false\r\n })!;\r\n this._renderTarget.set(device.createFrameBuffer([texture], null));\r\n }\r\n\r\n if (!CubemapSHProjector._renderStats) {\r\n CubemapSHProjector._renderStats = device.createRenderStateSet();\r\n CubemapSHProjector._renderStats.useDepthState().enableTest(false).enableWrite(false);\r\n CubemapSHProjector._renderStats\r\n .useBlendingState()\r\n .enable(true)\r\n .setBlendEquation('add', 'add')\r\n .setBlendFuncRGB('one', 'one')\r\n .setBlendFuncAlpha('zero', 'one');\r\n CubemapSHProjector._renderStats.useRasterizerState().setCullMode('none');\r\n }\r\n\r\n if (!CubemapSHProjector._programInst) {\r\n CubemapSHProjector._programInst = CubemapSHProjector._createProgram(device)!;\r\n CubemapSHProjector._bindGroupInst = device.createBindGroup(\r\n CubemapSHProjector._programInst.bindGroupLayouts[0]\r\n );\r\n }\r\n }\r\n /**\r\n * Creates the GPU program for spherical harmonics evaluation.\r\n *\r\n * The vertex shader uses instanced rendering to generate 9 instances (one per SH coefficient).\r\n * Each instance renders all sample points, but the vertex shader maps them to different\r\n * pixels in the 3x3 output texture based on the instance ID.\r\n *\r\n * The fragment shader evaluates the appropriate SH basis function based on the pixel location,\r\n * samples the cubemap in the sample direction, and multiplies by the integration weight.\r\n *\r\n * @param device - The graphics device to create the program with\r\n * @returns The compiled GPU program\r\n * @internal\r\n */\r\n private static _createProgram(device: AbstractDevice) {\r\n const program = device.buildRenderProgram({\r\n vertex(pb) {\r\n this.$inputs.directionWeight = pb.vec4().attrib('position');\r\n if (device.type === 'webgl') {\r\n this.$inputs.instanceId = pb.float().attrib('texCoord0');\r\n }\r\n pb.main(function () {\r\n this.$outputs.direction = this.$inputs.directionWeight.xyz;\r\n this.$outputs.weight = this.$inputs.directionWeight.w;\r\n if (pb.getDevice().type !== 'webgpu') {\r\n this.$builtins.pointSize = 1;\r\n }\r\n this.$outputs.shIndex =\r\n device.type === 'webgl' ? this.$inputs.instanceId : pb.int(this.$builtins.instanceIndex);\r\n this.$l.x = pb.mod(this.$outputs.shIndex, 3);\r\n this.$l.y = pb.div(this.$outputs.shIndex, 3);\r\n this.$l.ndcX = pb.sub(pb.div(pb.add(pb.float(this.x), 0.5), 1.5), 1);\r\n this.$l.ndcY = pb.sub(pb.div(pb.add(pb.float(this.y), 0.5), 1.5), 1);\r\n this.$l.$builtins.position = pb.vec4(this.ndcX, this.ndcY, 0, 1);\r\n if (pb.getDevice().type === 'webgpu') {\r\n this.$builtins.position = pb.mul(this.$builtins.position, pb.vec4(1, -1, 1, 1));\r\n }\r\n });\r\n },\r\n fragment(pb) {\r\n this.$outputs.color = pb.vec4();\r\n this.cubemap = pb.texCube().uniform(0);\r\n this.scale = pb.float().uniform(0);\r\n pb.func('cosineLobeBandFactor', [pb.int('l')], function () {\r\n this.$if(pb.equal(this.l, 0), function () {\r\n this.$return(pb.float(1));\r\n });\r\n this.$if(pb.lessThanEqual(this.l, 3), function () {\r\n this.$return(2 / 3);\r\n });\r\n this.$return(1 / 4);\r\n });\r\n pb.func('Y0', [pb.vec3('v')], function () {\r\n this.$return(0.282094791773878);\r\n });\r\n pb.func('Y1', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.y, -0.4886025119));\r\n });\r\n pb.func('Y2', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.z, 0.4886025119));\r\n });\r\n pb.func('Y3', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.x, -0.4886025119));\r\n });\r\n pb.func('Y4', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.x, this.v.y, 1.0925484306));\r\n });\r\n pb.func('Y5', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.y, this.v.z, -1.0925484306));\r\n });\r\n pb.func('Y6', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(pb.sub(pb.mul(this.v.z, this.v.z, 3), 1), 0.3153915652));\r\n });\r\n pb.func('Y7', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.x, this.v.z, -1.0925484306));\r\n });\r\n pb.func('Y8', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(pb.sub(pb.mul(this.v.x, this.v.x), pb.mul(this.v.y, this.v.y)), 0.5462742153));\r\n });\r\n pb.func('evalBasis', [pb.vec3('dir'), pb.int('c')], function () {\r\n this.$if(pb.equal(this.c, 0), function () {\r\n this.$return(this.Y0(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 1), function () {\r\n this.$return(this.Y1(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 2), function () {\r\n this.$return(this.Y2(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 3), function () {\r\n this.$return(this.Y3(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 4), function () {\r\n this.$return(this.Y4(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 5), function () {\r\n this.$return(this.Y5(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 6), function () {\r\n this.$return(this.Y6(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 7), function () {\r\n this.$return(this.Y7(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 8), function () {\r\n this.$return(this.Y8(this.dir));\r\n })\r\n .$else(function () {\r\n this.$return(0);\r\n });\r\n });\r\n pb.main(function () {\r\n this.$l.radiance = pb.textureSampleLevel(this.cubemap, this.$inputs.direction, 0).rgb;\r\n this.$l.bandFactor = this.cosineLobeBandFactor(\r\n pb.getDevice().type === 'webgl' ? pb.int(this.$inputs.shIndex) : this.$inputs.shIndex\r\n );\r\n this.$l.sh = this.evalBasis(\r\n this.$inputs.direction,\r\n pb.getDevice().type === 'webgl' ? pb.int(this.$inputs.shIndex) : this.$inputs.shIndex\r\n );\r\n this.$outputs.color = pb.vec4(\r\n pb.mul(this.radiance, this.sh, this.$inputs.weight, this.bandFactor, this.scale),\r\n 1\r\n );\r\n });\r\n }\r\n })!;\r\n program.name = '@CubemapSHProjector_SHProject';\r\n return program;\r\n }\r\n}\r\n"],"names":["CubemapSHProjector","Disposable","_programInst","_bindGroupInst","_renderStats","_primitive","_renderTarget","_numSamples","numSamples","DRef","projectCubemap","cubemap","outBuffer","radianceSource","projectCubemapToTexture","get","getColorAttachments","readPixelsToBuffer","framebuffer","device","getDevice","clearColor","Vector4","init","pushDeviceStates","setRenderStates","setProgram","setFramebuffer","clearFrameBuffer","bindGroup","setTexture","fetchSampler","setValue","Math","PI","setBindGroup","drawInstanced","popDeviceStates","onDispose","dispose","samples","Float32Array","i","x1","x2","s","random","sqrtS","sqrt","primitive","Primitive","createAndSetVertexBuffer","type","indexCount","indexStart","primitiveType","set","texture","createTexture2D","mipmapping","createFrameBuffer","createRenderStateSet","useDepthState","enableTest","enableWrite","useBlendingState","enable","setBlendEquation","setBlendFuncRGB","setBlendFuncAlpha","useRasterizerState","setCullMode","_createProgram","createBindGroup","bindGroupLayouts","program","buildRenderProgram","vertex","pb","$inputs","directionWeight","vec4","attrib","instanceId","float","main","$outputs","direction","xyz","weight","w","$builtins","pointSize","shIndex","int","instanceIndex","$l","x","mod","y","div","ndcX","sub","add","ndcY","position","mul","fragment","color","texCube","uniform","scale","func","$if","equal","l","$return","lessThanEqual","vec3","v","z","c","Y0","dir","$elseif","Y1","Y2","Y3","Y4","Y5","Y6","Y7","Y8","$else","radiance","textureSampleLevel","rgb","bandFactor","cosineLobeBandFactor","sh","evalBasis","name"],"mappings":";;;;;AAeA;;;;;;;;;;;;;;;;;IAkBO,MAAMA,kBAA2BC,SAAAA,UAAAA,CAAAA;AACtC,IAAA,OAAeC,eAAqC,IAAK;AACzD,IAAA,OAAeC,iBAAsC,IAAK;AAC1D,IAAA,OAAeC,eAAyC,IAAK;IAC5CC,UAA4B;IAC5BC,aAAiC;IACjCC,WAAoB;AACrC;;;;;;MAOA,WAAA,CAAYC,UAAa,GAAA,KAAK,CAAE;QAC9B,KAAK,EAAA;QACL,IAAI,CAACD,WAAW,GAAGC,UAAAA;QACnB,IAAI,CAACH,UAAU,GAAG,IAAII,IAAAA,EAAAA;QACtB,IAAI,CAACH,aAAa,GAAG,IAAIG,IAAAA,EAAAA;AAC3B;AACA;;;;;;;;;;;;;;;;;;;AAmBC,MACDC,eAAeC,OAAoB,EAAEC,SAAwB,EAAEC,cAAAA,GAAiB,IAAI,EAAE;QACpF,IAAI,CAACC,uBAAuB,CAACH,OAAAA,EAAS,IAAI,CAACL,aAAa,CAACS,GAAG,EAAKF,EAAAA,cAAAA,CAAAA;AACjE,QAAA,IAAI,CAACP,aAAa,CAACS,GAAG,EAAA,CAAIC,mBAAmB,EAAE,CAAC,CAAE,CAAA,CAACC,kBAAkB,CAAC,CAAA,EAAG,GAAG,CAAG,EAAA,CAAA,EAAG,GAAG,CAAGL,EAAAA,SAAAA,CAAAA;A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D,EAAAA,CAAGyD,kBAAkB,CAAC,IAAI,CAAC5H,OAAO,EAAE,IAAI,CAACoE,OAAO,CAACQ,SAAS,EAAE,GAAGiD,GAAG;AACrF,oBAAA,IAAI,CAACxC,EAAE,CAACyC,UAAU,GAAG,IAAI,CAACC,oBAAoB,CAC5C5D,EAAAA,CAAG1D,SAAS,EAAA,CAAGgC,IAAI,KAAK,OAAU0B,GAAAA,EAAAA,CAAGgB,GAAG,CAAC,IAAI,CAACf,OAAO,CAACc,OAAO,CAAA,GAAI,IAAI,CAACd,OAAO,CAACc,OAAO,CAAA;AAEvF,oBAAA,IAAI,CAACG,EAAE,CAAC2C,EAAE,GAAG,IAAI,CAACC,SAAS,CACzB,IAAI,CAAC7D,OAAO,CAACQ,SAAS,EACtBT,EAAG1D,CAAAA,SAAS,EAAGgC,CAAAA,IAAI,KAAK,OAAA,GAAU0B,EAAGgB,CAAAA,GAAG,CAAC,IAAI,CAACf,OAAO,CAACc,OAAO,CAAI,GAAA,IAAI,CAACd,OAAO,CAACc,OAAO,CAAA;AAEvF,oBAAA,IAAI,CAACP,QAAQ,CAACsB,KAAK,GAAG9B,EAAGG,CAAAA,IAAI,CAC3BH,EAAAA,CAAG4B,GAAG,CAAC,IAAI,CAAC4B,QAAQ,EAAE,IAAI,CAACK,EAAE,EAAE,IAAI,CAAC5D,OAAO,CAACU,MAAM,EAAE,IAAI,CAACgD,UAAU,EAAE,IAAI,CAAC1B,KAAK,CAC/E,EAAA,CAAA,CAAA;AAEJ,iBAAA,CAAA;AACF;AACF,SAAA,CAAA;AACApC,QAAAA,OAAAA,CAAQkE,IAAI,GAAG,+BAAA;QACf,OAAOlE,OAAAA;AACT;AACF;;;;"}
1
+ {"version":3,"file":"shprojector.js","sources":["../../src/utility/shprojector.ts"],"sourcesContent":["import type {\r\n AbstractDevice,\r\n BindGroup,\r\n FrameBuffer,\r\n GPUDataBuffer,\r\n GPUProgram,\r\n RenderStateSet,\r\n TextureCube\r\n} from '@zephyr3d/device';\r\nimport { Primitive } from '../render/primitive';\r\nimport type { Nullable } from '@zephyr3d/base';\r\nimport { Disposable, DRef, Vector4 } from '@zephyr3d/base';\r\nimport { fetchSampler } from './misc';\r\nimport { getDevice } from '../app/api';\r\n\r\n/**\r\n * CubemapSHProjector is responsible for projecting a cubemap texture into spherical harmonics (SH) coefficients.\r\n * This is commonly used for efficient environment lighting approximation in real-time rendering.\r\n *\r\n * The class uses Monte Carlo sampling to compute the first 9 spherical harmonics coefficients (up to order 2)\r\n * from a cubemap texture, which can then be used for ambient lighting calculations.\r\n *\r\n * @example\r\n * ```typescript\r\n * const projector = new CubemapSHProjector(10000);\r\n * const shBuffer = device.createBuffer(4 * 4 * 9, { usage: 'uniform' });\r\n * projector.projectCubemap(environmentCubemap, shBuffer);\r\n * // shBuffer now contains the 9 SH coefficients as RGB values\r\n * projector.dispose();\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class CubemapSHProjector extends Disposable {\r\n private static _programInst: Nullable<GPUProgram> = null;\r\n private static _bindGroupInst: Nullable<BindGroup> = null;\r\n private static _renderStats: Nullable<RenderStateSet> = null;\r\n private readonly _primitive: DRef<Primitive>;\r\n private readonly _renderTarget: DRef<FrameBuffer>;\r\n private readonly _numSamples: number;\r\n /**\r\n * Creates a new CubemapSHProjector instance.\r\n *\r\n * @param numSamples - Number of Monte Carlo samples to use for SH projection.\r\n * Higher values provide better accuracy but slower computation.\r\n * Default is 10000.\r\n */\r\n constructor(numSamples = 10000) {\r\n super();\r\n this._numSamples = numSamples;\r\n this._primitive = new DRef();\r\n this._renderTarget = new DRef();\r\n }\r\n /**\r\n * Projects a cubemap texture into spherical harmonics coefficients and stores them in a GPUBuffer.\r\n *\r\n * The method performs Monte Carlo integration over the sphere to compute the first 9 SH coefficients.\r\n * The results are written to a 3x3 render target where each pixel contains RGB values for one SH coefficient.\r\n * The layout is:\r\n * - (0,0): Y₀₀ (0,1): Y₁₋₁ (0,2): Y₁₀\r\n * - (1,0): Y₁₁ (1,1): Y₂₋₂ (1,2): Y₂₋₁\r\n * - (2,0): Y₂₀ (2,1): Y₂₁ (2,2): Y₂₂\r\n *\r\n * @param cubemap - The input cubemap texture to project\r\n * @param outBuffer - GPU data buffer to receive the computed SH coefficients.\r\n * Must be large enough to hold 9 RGB values (36 floats for RGBA32F format).\r\n *\r\n * @example\r\n * ```typescript\r\n * const shBuffer = device.createDataBuffer(9 * 4 * 4); // 9 coefficients * 4 components * 4 bytes\r\n * projector.projectCubemap(environmentMap, shBuffer);\r\n * ```\r\n */\r\n projectCubemap(cubemap: TextureCube, outBuffer: GPUDataBuffer, radianceSource = true) {\r\n const device = getDevice();\r\n if (!this._renderTarget.get()) {\r\n const texture = device.createTexture2D('rgba32f', 3, 3, {\r\n mipmapping: false\r\n })!;\r\n this._renderTarget.set(device.createFrameBuffer([texture], null));\r\n }\r\n this.projectCubemapToTexture(cubemap, this._renderTarget.get()!, radianceSource);\r\n this._renderTarget.get()!.getColorAttachments()[0].readPixelsToBuffer(0, 0, 3, 3, 0, 0, outBuffer);\r\n }\r\n /**\r\n * Projects a cubemap texture into spherical harmonics coefficients and stores them in a 3x3 texture.\r\n *\r\n * The method performs Monte Carlo integration over the sphere to compute the first 9 SH coefficients.\r\n * The results are written to a 3x3 render target where each pixel contains RGB values for one SH coefficient.\r\n * The layout is:\r\n * - (0,0): Y₀₀ (0,1): Y₁₋₁ (0,2): Y₁₀\r\n * - (1,0): Y₁₁ (1,1): Y₂₋₂ (1,2): Y₂₋₁\r\n * - (2,0): Y₂₀ (2,1): Y₂₁ (2,2): Y₂₂\r\n *\r\n * @param cubemap - The input cubemap texture to project\r\n * @param outFramebuffer - Framebuffer that contains the 3x3 texture to receive the computed SH coefficients in color attachment slot 0.\r\n *\r\n * @example\r\n * ```typescript\r\n * const shTexture = device.createTexture2D('rgba32f', 3, 3); // 9 coefficients * 4 components * 4 bytes\r\n * const shFramebuffer = device.createFrameBuffer([shTexture], null);\r\n * projector.projectCubemapToTexture(environmentMap, shFramebuffer);\r\n * ```\r\n */\r\n projectCubemapToTexture(cubemap: TextureCube, framebuffer: FrameBuffer, radianceSource = true) {\r\n const device = getDevice();\r\n const clearColor = new Vector4(0, 0, 0, 1);\r\n this.init(device);\r\n device.pushDeviceStates();\r\n device.setRenderStates(CubemapSHProjector._renderStats);\r\n device.setProgram(CubemapSHProjector._programInst);\r\n device.setFramebuffer(framebuffer);\r\n device.clearFrameBuffer(clearColor, null, null);\r\n const bindGroup = CubemapSHProjector._bindGroupInst!;\r\n bindGroup.setTexture('cubemap', cubemap, fetchSampler('clamp_linear_nomip'));\r\n bindGroup.setValue('scale', radianceSource ? 1.0 : Math.PI);\r\n device.setBindGroup(0, bindGroup);\r\n this._primitive.get()!.drawInstanced(9);\r\n device.popDeviceStates();\r\n }\r\n /**\r\n * Disposes of all resources allocated by this projector instance.\r\n * Should be called when the projector is no longer needed to prevent memory leaks.\r\n */\r\n protected onDispose() {\r\n super.onDispose();\r\n this._primitive.dispose();\r\n if (this._renderTarget.get()) {\r\n this._renderTarget.get()!.getColorAttachments()[0].dispose();\r\n this._renderTarget.dispose();\r\n }\r\n }\r\n /**\r\n * Initializes the GPU resources needed for SH projection.\r\n * This method is called automatically by projectCubemap() and sets up:\r\n * - Sample directions primitive (Monte Carlo samples on unit sphere)\r\n * - Render target (3x3 RGBA32F texture)\r\n * - Render states (additive blending, no depth test)\r\n * - GPU program for SH evaluation\r\n *\r\n * @param device - The graphics device to create resources with\r\n * @internal\r\n */\r\n private init(device: AbstractDevice) {\r\n if (!this._primitive.get()) {\r\n const samples = new Float32Array(this._numSamples * 4);\r\n for (let i = 0; i < this._numSamples; i++) {\r\n let x1: number, x2: number, s: number;\r\n do {\r\n x1 = Math.random() * 2 - 1;\r\n x2 = Math.random() * 2 - 1;\r\n s = x1 * x1 + x2 * x2;\r\n } while (s >= 1);\r\n const sqrtS = Math.sqrt(1 - s);\r\n samples[i * 4 + 0] = 2 * x1 * sqrtS;\r\n samples[i * 4 + 1] = 2 * x2 * sqrtS;\r\n samples[i * 4 + 2] = 1 - 2 * s;\r\n samples[i * 4 + 3] = (4 * Math.PI) / this._numSamples;\r\n }\r\n const primitive = new Primitive();\r\n primitive.createAndSetVertexBuffer('position_f32x4', samples);\r\n if (device.type === 'webgl') {\r\n primitive.createAndSetVertexBuffer(\r\n 'tex0_f32',\r\n new Float32Array([0, 1, 2, 3, 4, 5, 6, 7, 8]),\r\n 'instance'\r\n );\r\n }\r\n primitive.indexCount = this._numSamples;\r\n primitive.indexStart = 0;\r\n primitive.primitiveType = 'point-list';\r\n this._primitive.set(primitive);\r\n }\r\n\r\n if (!CubemapSHProjector._renderStats) {\r\n CubemapSHProjector._renderStats = device.createRenderStateSet();\r\n CubemapSHProjector._renderStats.useDepthState().enableTest(false).enableWrite(false);\r\n CubemapSHProjector._renderStats\r\n .useBlendingState()\r\n .enable(true)\r\n .setBlendEquation('add', 'add')\r\n .setBlendFuncRGB('one', 'one')\r\n .setBlendFuncAlpha('zero', 'one');\r\n CubemapSHProjector._renderStats.useRasterizerState().setCullMode('none');\r\n }\r\n\r\n if (!CubemapSHProjector._programInst) {\r\n CubemapSHProjector._programInst = CubemapSHProjector._createProgram(device)!;\r\n CubemapSHProjector._bindGroupInst = device.createBindGroup(\r\n CubemapSHProjector._programInst.bindGroupLayouts[0]\r\n );\r\n }\r\n }\r\n /**\r\n * Creates the GPU program for spherical harmonics evaluation.\r\n *\r\n * The vertex shader uses instanced rendering to generate 9 instances (one per SH coefficient).\r\n * Each instance renders all sample points, but the vertex shader maps them to different\r\n * pixels in the 3x3 output texture based on the instance ID.\r\n *\r\n * The fragment shader evaluates the appropriate SH basis function based on the pixel location,\r\n * samples the cubemap in the sample direction, and multiplies by the integration weight.\r\n *\r\n * @param device - The graphics device to create the program with\r\n * @returns The compiled GPU program\r\n * @internal\r\n */\r\n private static _createProgram(device: AbstractDevice) {\r\n const program = device.buildRenderProgram({\r\n vertex(pb) {\r\n this.$inputs.directionWeight = pb.vec4().attrib('position');\r\n if (device.type === 'webgl') {\r\n this.$inputs.instanceId = pb.float().attrib('texCoord0');\r\n }\r\n pb.main(function () {\r\n this.$outputs.direction = this.$inputs.directionWeight.xyz;\r\n this.$outputs.weight = this.$inputs.directionWeight.w;\r\n if (pb.getDevice().type !== 'webgpu') {\r\n this.$builtins.pointSize = 1;\r\n }\r\n this.$outputs.shIndex =\r\n device.type === 'webgl' ? this.$inputs.instanceId : pb.int(this.$builtins.instanceIndex);\r\n this.$l.x = pb.mod(this.$outputs.shIndex, 3);\r\n this.$l.y = pb.div(this.$outputs.shIndex, 3);\r\n this.$l.ndcX = pb.sub(pb.div(pb.add(pb.float(this.x), 0.5), 1.5), 1);\r\n this.$l.ndcY = pb.sub(pb.div(pb.add(pb.float(this.y), 0.5), 1.5), 1);\r\n this.$l.$builtins.position = pb.vec4(this.ndcX, this.ndcY, 0, 1);\r\n if (pb.getDevice().type === 'webgpu') {\r\n this.$builtins.position = pb.mul(this.$builtins.position, pb.vec4(1, -1, 1, 1));\r\n }\r\n });\r\n },\r\n fragment(pb) {\r\n this.$outputs.color = pb.vec4();\r\n this.cubemap = pb.texCube().uniform(0);\r\n this.scale = pb.float().uniform(0);\r\n pb.func('cosineLobeBandFactor', [pb.int('l')], function () {\r\n this.$if(pb.equal(this.l, 0), function () {\r\n this.$return(pb.float(1));\r\n });\r\n this.$if(pb.lessThanEqual(this.l, 3), function () {\r\n this.$return(2 / 3);\r\n });\r\n this.$return(1 / 4);\r\n });\r\n pb.func('Y0', [pb.vec3('v')], function () {\r\n this.$return(0.282094791773878);\r\n });\r\n pb.func('Y1', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.y, -0.4886025119));\r\n });\r\n pb.func('Y2', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.z, 0.4886025119));\r\n });\r\n pb.func('Y3', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.x, -0.4886025119));\r\n });\r\n pb.func('Y4', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.x, this.v.y, 1.0925484306));\r\n });\r\n pb.func('Y5', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.y, this.v.z, -1.0925484306));\r\n });\r\n pb.func('Y6', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(pb.sub(pb.mul(this.v.z, this.v.z, 3), 1), 0.3153915652));\r\n });\r\n pb.func('Y7', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.x, this.v.z, -1.0925484306));\r\n });\r\n pb.func('Y8', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(pb.sub(pb.mul(this.v.x, this.v.x), pb.mul(this.v.y, this.v.y)), 0.5462742153));\r\n });\r\n pb.func('evalBasis', [pb.vec3('dir'), pb.int('c')], function () {\r\n this.$if(pb.equal(this.c, 0), function () {\r\n this.$return(this.Y0(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 1), function () {\r\n this.$return(this.Y1(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 2), function () {\r\n this.$return(this.Y2(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 3), function () {\r\n this.$return(this.Y3(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 4), function () {\r\n this.$return(this.Y4(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 5), function () {\r\n this.$return(this.Y5(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 6), function () {\r\n this.$return(this.Y6(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 7), function () {\r\n this.$return(this.Y7(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 8), function () {\r\n this.$return(this.Y8(this.dir));\r\n })\r\n .$else(function () {\r\n this.$return(0);\r\n });\r\n });\r\n pb.main(function () {\r\n this.$l.radiance = pb.textureSampleLevel(this.cubemap, this.$inputs.direction, 0).rgb;\r\n this.$l.bandFactor = this.cosineLobeBandFactor(\r\n pb.getDevice().type === 'webgl' ? pb.int(this.$inputs.shIndex) : this.$inputs.shIndex\r\n );\r\n this.$l.sh = this.evalBasis(\r\n this.$inputs.direction,\r\n pb.getDevice().type === 'webgl' ? pb.int(this.$inputs.shIndex) : this.$inputs.shIndex\r\n );\r\n this.$outputs.color = pb.vec4(\r\n pb.mul(this.radiance, this.sh, this.$inputs.weight, this.bandFactor, this.scale),\r\n 1\r\n );\r\n });\r\n }\r\n })!;\r\n program.name = '@CubemapSHProjector_SHProject';\r\n return program;\r\n }\r\n}\r\n"],"names":["CubemapSHProjector","Disposable","_programInst","_bindGroupInst","_renderStats","_primitive","_renderTarget","_numSamples","numSamples","DRef","projectCubemap","cubemap","outBuffer","radianceSource","device","getDevice","get","texture","createTexture2D","mipmapping","set","createFrameBuffer","projectCubemapToTexture","getColorAttachments","readPixelsToBuffer","framebuffer","clearColor","Vector4","init","pushDeviceStates","setRenderStates","setProgram","setFramebuffer","clearFrameBuffer","bindGroup","setTexture","fetchSampler","setValue","Math","PI","setBindGroup","drawInstanced","popDeviceStates","onDispose","dispose","samples","Float32Array","i","x1","x2","s","random","sqrtS","sqrt","primitive","Primitive","createAndSetVertexBuffer","type","indexCount","indexStart","primitiveType","createRenderStateSet","useDepthState","enableTest","enableWrite","useBlendingState","enable","setBlendEquation","setBlendFuncRGB","setBlendFuncAlpha","useRasterizerState","setCullMode","_createProgram","createBindGroup","bindGroupLayouts","program","buildRenderProgram","vertex","pb","$inputs","directionWeight","vec4","attrib","instanceId","float","main","$outputs","direction","xyz","weight","w","$builtins","pointSize","shIndex","int","instanceIndex","$l","x","mod","y","div","ndcX","sub","add","ndcY","position","mul","fragment","color","texCube","uniform","scale","func","$if","equal","l","$return","lessThanEqual","vec3","v","z","c","Y0","dir","$elseif","Y1","Y2","Y3","Y4","Y5","Y6","Y7","Y8","$else","radiance","textureSampleLevel","rgb","bandFactor","cosineLobeBandFactor","sh","evalBasis","name"],"mappings":";;;;;AAeA;;;;;;;;;;;;;;;;;IAkBO,MAAMA,kBAA2BC,SAAAA,UAAAA,CAAAA;AACtC,IAAA,OAAeC,eAAqC,IAAK;A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