@zephyr3d/scene 0.7.1 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (441) hide show
  1. package/dist/animation/animation.js +0 -18
  2. package/dist/animation/animation.js.map +1 -1
  3. package/dist/animation/animationset.js +200 -3
  4. package/dist/animation/animationset.js.map +1 -1
  5. package/dist/animation/ik/ccd_solver.js +371 -0
  6. package/dist/animation/ik/ccd_solver.js.map +1 -0
  7. package/dist/animation/ik/fabrik_solver.js +398 -0
  8. package/dist/animation/ik/fabrik_solver.js.map +1 -0
  9. package/dist/animation/ik/ik_angle_constraint.js +181 -0
  10. package/dist/animation/ik/ik_angle_constraint.js.map +1 -0
  11. package/dist/animation/ik/ik_chain.js +163 -0
  12. package/dist/animation/ik/ik_chain.js.map +1 -0
  13. package/dist/animation/ik/ik_constraint.js +25 -0
  14. package/dist/animation/ik/ik_constraint.js.map +1 -0
  15. package/dist/animation/ik/ik_pole_constraint.js +128 -0
  16. package/dist/animation/ik/ik_pole_constraint.js.map +1 -0
  17. package/dist/animation/ik/ik_solver.js +48 -0
  18. package/dist/animation/ik/ik_solver.js.map +1 -0
  19. package/dist/animation/ik/ik_track.js +96 -0
  20. package/dist/animation/ik/ik_track.js.map +1 -0
  21. package/dist/animation/ik/ik_utils.js +191 -0
  22. package/dist/animation/ik/ik_utils.js.map +1 -0
  23. package/dist/animation/ik/two_bone_ik_solver.js +331 -0
  24. package/dist/animation/ik/two_bone_ik_solver.js.map +1 -0
  25. package/dist/animation/ik_modifier.js +61 -0
  26. package/dist/animation/ik_modifier.js.map +1 -0
  27. package/dist/animation/ik_postprocessor.js +71 -0
  28. package/dist/animation/ik_postprocessor.js.map +1 -0
  29. package/dist/animation/manual_transform_processor.js +156 -0
  30. package/dist/animation/manual_transform_processor.js.map +1 -0
  31. package/dist/animation/skeleton.js +55 -51
  32. package/dist/animation/skeleton.js.map +1 -1
  33. package/dist/animation/skeleton_modifier.js +38 -0
  34. package/dist/animation/skeleton_modifier.js.map +1 -0
  35. package/dist/animation/skeleton_postprocessor.js +50 -0
  36. package/dist/animation/skeleton_postprocessor.js.map +1 -0
  37. package/dist/animation/spring/multi_chain_spring_system.js +503 -0
  38. package/dist/animation/spring/multi_chain_spring_system.js.map +1 -0
  39. package/dist/animation/spring/spring_bone.js +240 -0
  40. package/dist/animation/spring/spring_bone.js.map +1 -0
  41. package/dist/animation/spring/spring_bone_collider.js +198 -0
  42. package/dist/animation/spring/spring_bone_collider.js.map +1 -0
  43. package/dist/animation/spring/spring_bone_constraint.js +170 -0
  44. package/dist/animation/spring/spring_bone_constraint.js.map +1 -0
  45. package/dist/animation/spring/spring_bone_system.js +328 -0
  46. package/dist/animation/spring/spring_bone_system.js.map +1 -0
  47. package/dist/animation/spring/spring_chain.js +103 -0
  48. package/dist/animation/spring/spring_chain.js.map +1 -0
  49. package/dist/animation/spring/spring_collider.js +247 -0
  50. package/dist/animation/spring/spring_collider.js.map +1 -0
  51. package/dist/animation/spring/spring_constraint.js +21 -0
  52. package/dist/animation/spring/spring_constraint.js.map +1 -0
  53. package/dist/animation/spring/spring_particle.js +20 -0
  54. package/dist/animation/spring/spring_particle.js.map +1 -0
  55. package/dist/animation/spring/spring_system.js +526 -0
  56. package/dist/animation/spring/spring_system.js.map +1 -0
  57. package/dist/animation/spring_modifier.js +45 -0
  58. package/dist/animation/spring_modifier.js.map +1 -0
  59. package/dist/animation/spring_postprocessor.js +54 -0
  60. package/dist/animation/spring_postprocessor.js.map +1 -0
  61. package/dist/app/screen.js +1 -1
  62. package/dist/app/screen.js.map +1 -1
  63. package/dist/asset/model.js +10 -6
  64. package/dist/asset/model.js.map +1 -1
  65. package/dist/camera/perspectivecamera.js +3 -3
  66. package/dist/camera/perspectivecamera.js.map +1 -1
  67. package/dist/index.d.ts +1400 -4
  68. package/dist/index.js +16 -0
  69. package/dist/index.js.map +1 -1
  70. package/dist/material/mixins/lightmodel/blinnphong.js +66 -4
  71. package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
  72. package/dist/material/mixins/pbr/common.js +20 -17
  73. package/dist/material/mixins/pbr/common.js.map +1 -1
  74. package/dist/material/shader/helper.js +5 -3
  75. package/dist/material/shader/helper.js.map +1 -1
  76. package/dist/render/gpu_picking.js +100 -0
  77. package/dist/render/gpu_picking.js.map +1 -0
  78. package/dist/render/rendergraph/device_pool_allocator.js +41 -0
  79. package/dist/render/rendergraph/device_pool_allocator.js.map +1 -0
  80. package/dist/render/rendergraph/executor.js +146 -0
  81. package/dist/render/rendergraph/executor.js.map +1 -0
  82. package/dist/render/rendergraph/forward_plus_builder.js +414 -0
  83. package/dist/render/rendergraph/forward_plus_builder.js.map +1 -0
  84. package/dist/render/rendergraph/rendergraph.js +306 -0
  85. package/dist/render/rendergraph/rendergraph.js.map +1 -0
  86. package/dist/render/rendergraph/types.js +57 -0
  87. package/dist/render/rendergraph/types.js.map +1 -0
  88. package/dist/render/sky_motion_vector.js +85 -0
  89. package/dist/render/sky_motion_vector.js.map +1 -0
  90. package/dist/scene/mesh.js +15 -23
  91. package/dist/scene/mesh.js.map +1 -1
  92. package/dist/utility/serialization/scene/animation.js +24 -23
  93. package/dist/utility/serialization/scene/animation.js.map +1 -1
  94. package/dist/utility/serialization/scene/material.js +62 -0
  95. package/dist/utility/serialization/scene/material.js.map +1 -1
  96. package/dist/utility/serialization/scene/node.js +1 -1
  97. package/package.json +3 -3
  98. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +0 -38
  99. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +0 -1
  100. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +0 -10
  101. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +0 -1
  102. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +0 -127
  103. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +0 -1
  104. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +0 -263
  105. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +0 -1
  106. package/dist/src/animation/animation.js +0 -127
  107. package/dist/src/animation/animation.js.map +0 -1
  108. package/dist/src/animation/animationset.js +0 -255
  109. package/dist/src/animation/animationset.js.map +0 -1
  110. package/dist/src/animation/animationtrack.js +0 -34
  111. package/dist/src/animation/animationtrack.js.map +0 -1
  112. package/dist/src/animation/eulerrotationtrack.js +0 -52
  113. package/dist/src/animation/eulerrotationtrack.js.map +0 -1
  114. package/dist/src/animation/morphtarget.js +0 -93
  115. package/dist/src/animation/morphtarget.js.map +0 -1
  116. package/dist/src/animation/morphtrack.js +0 -70
  117. package/dist/src/animation/morphtrack.js.map +0 -1
  118. package/dist/src/animation/proptrack.js +0 -161
  119. package/dist/src/animation/proptrack.js.map +0 -1
  120. package/dist/src/animation/rotationtrack.js +0 -51
  121. package/dist/src/animation/rotationtrack.js.map +0 -1
  122. package/dist/src/animation/scaletrack.js +0 -50
  123. package/dist/src/animation/scaletrack.js.map +0 -1
  124. package/dist/src/animation/skeleton.js +0 -204
  125. package/dist/src/animation/skeleton.js.map +0 -1
  126. package/dist/src/animation/translationtrack.js +0 -50
  127. package/dist/src/animation/translationtrack.js.map +0 -1
  128. package/dist/src/app/app.js +0 -129
  129. package/dist/src/app/app.js.map +0 -1
  130. package/dist/src/app/inputmgr.js +0 -267
  131. package/dist/src/app/inputmgr.js.map +0 -1
  132. package/dist/src/asset/assetmanager.js +0 -404
  133. package/dist/src/asset/assetmanager.js.map +0 -1
  134. package/dist/src/asset/builtin.js +0 -337
  135. package/dist/src/asset/builtin.js.map +0 -1
  136. package/dist/src/asset/loaders/dds/dds.js +0 -470
  137. package/dist/src/asset/loaders/dds/dds.js.map +0 -1
  138. package/dist/src/asset/loaders/dds/dds_loader.js +0 -28
  139. package/dist/src/asset/loaders/dds/dds_loader.js.map +0 -1
  140. package/dist/src/asset/loaders/gltf/gltf_loader.js +0 -1265
  141. package/dist/src/asset/loaders/gltf/gltf_loader.js.map +0 -1
  142. package/dist/src/asset/loaders/gltf/helpers.js +0 -327
  143. package/dist/src/asset/loaders/gltf/helpers.js.map +0 -1
  144. package/dist/src/asset/loaders/hdr/hdr.js +0 -180
  145. package/dist/src/asset/loaders/hdr/hdr.js.map +0 -1
  146. package/dist/src/asset/loaders/image/tga_Loader.js +0 -116
  147. package/dist/src/asset/loaders/image/tga_Loader.js.map +0 -1
  148. package/dist/src/asset/loaders/image/webimage_loader.js +0 -63
  149. package/dist/src/asset/loaders/image/webimage_loader.js.map +0 -1
  150. package/dist/src/asset/loaders/loader.js +0 -45
  151. package/dist/src/asset/loaders/loader.js.map +0 -1
  152. package/dist/src/asset/model.js +0 -414
  153. package/dist/src/asset/model.js.map +0 -1
  154. package/dist/src/blitter/bilateralblur.js +0 -221
  155. package/dist/src/blitter/bilateralblur.js.map +0 -1
  156. package/dist/src/blitter/blitter.js +0 -390
  157. package/dist/src/blitter/blitter.js.map +0 -1
  158. package/dist/src/blitter/box.js +0 -118
  159. package/dist/src/blitter/box.js.map +0 -1
  160. package/dist/src/blitter/copy.js +0 -22
  161. package/dist/src/blitter/copy.js.map +0 -1
  162. package/dist/src/blitter/gaussianblur.js +0 -228
  163. package/dist/src/blitter/gaussianblur.js.map +0 -1
  164. package/dist/src/camera/base.js +0 -92
  165. package/dist/src/camera/base.js.map +0 -1
  166. package/dist/src/camera/camera.js +0 -1005
  167. package/dist/src/camera/camera.js.map +0 -1
  168. package/dist/src/camera/fps.js +0 -238
  169. package/dist/src/camera/fps.js.map +0 -1
  170. package/dist/src/camera/orbit.js +0 -245
  171. package/dist/src/camera/orbit.js.map +0 -1
  172. package/dist/src/camera/orthocamera.js +0 -167
  173. package/dist/src/camera/orthocamera.js.map +0 -1
  174. package/dist/src/camera/perspectivecamera.js +0 -141
  175. package/dist/src/camera/perspectivecamera.js.map +0 -1
  176. package/dist/src/index.js +0 -120
  177. package/dist/src/index.js.map +0 -1
  178. package/dist/src/material/blinn.js +0 -81
  179. package/dist/src/material/blinn.js.map +0 -1
  180. package/dist/src/material/grassmaterial.js +0 -113
  181. package/dist/src/material/grassmaterial.js.map +0 -1
  182. package/dist/src/material/lambert.js +0 -92
  183. package/dist/src/material/lambert.js.map +0 -1
  184. package/dist/src/material/material.js +0 -301
  185. package/dist/src/material/material.js.map +0 -1
  186. package/dist/src/material/meshmaterial.js +0 -704
  187. package/dist/src/material/meshmaterial.js.map +0 -1
  188. package/dist/src/material/mixins/albedocolor.js +0 -76
  189. package/dist/src/material/mixins/albedocolor.js.map +0 -1
  190. package/dist/src/material/mixins/foliage.js +0 -47
  191. package/dist/src/material/mixins/foliage.js.map +0 -1
  192. package/dist/src/material/mixins/lightmodel/blinnphong.js +0 -112
  193. package/dist/src/material/mixins/lightmodel/blinnphong.js.map +0 -1
  194. package/dist/src/material/mixins/lightmodel/lambert.js +0 -58
  195. package/dist/src/material/mixins/lightmodel/lambert.js.map +0 -1
  196. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +0 -178
  197. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +0 -1
  198. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +0 -139
  199. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +0 -1
  200. package/dist/src/material/mixins/lit.js +0 -476
  201. package/dist/src/material/mixins/lit.js.map +0 -1
  202. package/dist/src/material/mixins/pbr/common.js +0 -918
  203. package/dist/src/material/mixins/pbr/common.js.map +0 -1
  204. package/dist/src/material/mixins/texture.js +0 -172
  205. package/dist/src/material/mixins/texture.js.map +0 -1
  206. package/dist/src/material/mixins/vertexcolor.js +0 -56
  207. package/dist/src/material/mixins/vertexcolor.js.map +0 -1
  208. package/dist/src/material/particle.js +0 -178
  209. package/dist/src/material/particle.js.map +0 -1
  210. package/dist/src/material/pbrmr.js +0 -97
  211. package/dist/src/material/pbrmr.js.map +0 -1
  212. package/dist/src/material/pbrsg.js +0 -97
  213. package/dist/src/material/pbrsg.js.map +0 -1
  214. package/dist/src/material/shader/helper.js +0 -1209
  215. package/dist/src/material/shader/helper.js.map +0 -1
  216. package/dist/src/material/terrain-cm.js +0 -606
  217. package/dist/src/material/terrain-cm.js.map +0 -1
  218. package/dist/src/material/terrainmaterial.js +0 -375
  219. package/dist/src/material/terrainmaterial.js.map +0 -1
  220. package/dist/src/material/unlit.js +0 -41
  221. package/dist/src/material/unlit.js.map +0 -1
  222. package/dist/src/material/water.js +0 -417
  223. package/dist/src/material/water.js.map +0 -1
  224. package/dist/src/posteffect/bloom.js +0 -361
  225. package/dist/src/posteffect/bloom.js.map +0 -1
  226. package/dist/src/posteffect/compositor.js +0 -226
  227. package/dist/src/posteffect/compositor.js.map +0 -1
  228. package/dist/src/posteffect/fxaa.js +0 -273
  229. package/dist/src/posteffect/fxaa.js.map +0 -1
  230. package/dist/src/posteffect/grayscale.js +0 -69
  231. package/dist/src/posteffect/grayscale.js.map +0 -1
  232. package/dist/src/posteffect/motionblur.js +0 -96
  233. package/dist/src/posteffect/motionblur.js.map +0 -1
  234. package/dist/src/posteffect/posteffect.js +0 -126
  235. package/dist/src/posteffect/posteffect.js.map +0 -1
  236. package/dist/src/posteffect/sao.js +0 -324
  237. package/dist/src/posteffect/sao.js.map +0 -1
  238. package/dist/src/posteffect/ssr.js +0 -489
  239. package/dist/src/posteffect/ssr.js.map +0 -1
  240. package/dist/src/posteffect/taa.js +0 -172
  241. package/dist/src/posteffect/taa.js.map +0 -1
  242. package/dist/src/posteffect/tonemap.js +0 -94
  243. package/dist/src/posteffect/tonemap.js.map +0 -1
  244. package/dist/src/render/abuffer_oit.js +0 -361
  245. package/dist/src/render/abuffer_oit.js.map +0 -1
  246. package/dist/src/render/clipmap.js +0 -851
  247. package/dist/src/render/clipmap.js.map +0 -1
  248. package/dist/src/render/cluster_light.js +0 -333
  249. package/dist/src/render/cluster_light.js.map +0 -1
  250. package/dist/src/render/cull_visitor.js +0 -187
  251. package/dist/src/render/cull_visitor.js.map +0 -1
  252. package/dist/src/render/depthpass.js +0 -68
  253. package/dist/src/render/depthpass.js.map +0 -1
  254. package/dist/src/render/drawable_mixin.js +0 -227
  255. package/dist/src/render/drawable_mixin.js.map +0 -1
  256. package/dist/src/render/envlight.js +0 -463
  257. package/dist/src/render/envlight.js.map +0 -1
  258. package/dist/src/render/fbm_wavegenerator.js +0 -251
  259. package/dist/src/render/fbm_wavegenerator.js.map +0 -1
  260. package/dist/src/render/fft_wavegenerator.js +0 -1006
  261. package/dist/src/render/fft_wavegenerator.js.map +0 -1
  262. package/dist/src/render/fullscreenquad.js +0 -38
  263. package/dist/src/render/fullscreenquad.js.map +0 -1
  264. package/dist/src/render/gerstner_wavegenerator.js +0 -314
  265. package/dist/src/render/gerstner_wavegenerator.js.map +0 -1
  266. package/dist/src/render/globalbindgroup_allocator.js +0 -60
  267. package/dist/src/render/globalbindgroup_allocator.js.map +0 -1
  268. package/dist/src/render/hzb.js +0 -273
  269. package/dist/src/render/hzb.js.map +0 -1
  270. package/dist/src/render/lightpass.js +0 -172
  271. package/dist/src/render/lightpass.js.map +0 -1
  272. package/dist/src/render/objectcolorpass.js +0 -51
  273. package/dist/src/render/objectcolorpass.js.map +0 -1
  274. package/dist/src/render/primitive.js +0 -364
  275. package/dist/src/render/primitive.js.map +0 -1
  276. package/dist/src/render/render_queue.js +0 -467
  277. package/dist/src/render/render_queue.js.map +0 -1
  278. package/dist/src/render/renderbundle_wrapper.js +0 -152
  279. package/dist/src/render/renderbundle_wrapper.js.map +0 -1
  280. package/dist/src/render/renderer.js +0 -455
  281. package/dist/src/render/renderer.js.map +0 -1
  282. package/dist/src/render/renderpass.js +0 -200
  283. package/dist/src/render/renderpass.js.map +0 -1
  284. package/dist/src/render/shadowmap_pass.js +0 -56
  285. package/dist/src/render/shadowmap_pass.js.map +0 -1
  286. package/dist/src/render/sky.js +0 -1103
  287. package/dist/src/render/sky.js.map +0 -1
  288. package/dist/src/render/weightedblended_oit.js +0 -168
  289. package/dist/src/render/weightedblended_oit.js.map +0 -1
  290. package/dist/src/scene/batchgroup.js +0 -162
  291. package/dist/src/scene/batchgroup.js.map +0 -1
  292. package/dist/src/scene/environment.js +0 -209
  293. package/dist/src/scene/environment.js.map +0 -1
  294. package/dist/src/scene/graph_node.js +0 -72
  295. package/dist/src/scene/graph_node.js.map +0 -1
  296. package/dist/src/scene/light.js +0 -416
  297. package/dist/src/scene/light.js.map +0 -1
  298. package/dist/src/scene/mesh.js +0 -341
  299. package/dist/src/scene/mesh.js.map +0 -1
  300. package/dist/src/scene/octree.js +0 -649
  301. package/dist/src/scene/octree.js.map +0 -1
  302. package/dist/src/scene/particlesys.js +0 -738
  303. package/dist/src/scene/particlesys.js.map +0 -1
  304. package/dist/src/scene/raycast_visitor.js +0 -103
  305. package/dist/src/scene/raycast_visitor.js.map +0 -1
  306. package/dist/src/scene/scene.js +0 -284
  307. package/dist/src/scene/scene.js.map +0 -1
  308. package/dist/src/scene/scene_node.js +0 -732
  309. package/dist/src/scene/scene_node.js.map +0 -1
  310. package/dist/src/scene/terrain/grass.js +0 -278
  311. package/dist/src/scene/terrain/grass.js.map +0 -1
  312. package/dist/src/scene/terrain/heightfield.js +0 -475
  313. package/dist/src/scene/terrain/heightfield.js.map +0 -1
  314. package/dist/src/scene/terrain/patch.js +0 -530
  315. package/dist/src/scene/terrain/patch.js.map +0 -1
  316. package/dist/src/scene/terrain/quadtree.js +0 -461
  317. package/dist/src/scene/terrain/quadtree.js.map +0 -1
  318. package/dist/src/scene/terrain/terrain.js +0 -246
  319. package/dist/src/scene/terrain/terrain.js.map +0 -1
  320. package/dist/src/scene/terrain-cm/grass.js +0 -594
  321. package/dist/src/scene/terrain-cm/grass.js.map +0 -1
  322. package/dist/src/scene/terrain-cm/grassmaterial.js +0 -159
  323. package/dist/src/scene/terrain-cm/grassmaterial.js.map +0 -1
  324. package/dist/src/scene/terrain-cm/terrain-cm.js +0 -538
  325. package/dist/src/scene/terrain-cm/terrain-cm.js.map +0 -1
  326. package/dist/src/scene/water.js +0 -374
  327. package/dist/src/scene/water.js.map +0 -1
  328. package/dist/src/shaders/atmosphere.js +0 -957
  329. package/dist/src/shaders/atmosphere.js.map +0 -1
  330. package/dist/src/shaders/fog.js +0 -112
  331. package/dist/src/shaders/fog.js.map +0 -1
  332. package/dist/src/shaders/misc.js +0 -266
  333. package/dist/src/shaders/misc.js.map +0 -1
  334. package/dist/src/shaders/noise.js +0 -222
  335. package/dist/src/shaders/noise.js.map +0 -1
  336. package/dist/src/shaders/pbr.js +0 -51
  337. package/dist/src/shaders/pbr.js.map +0 -1
  338. package/dist/src/shaders/shadow.js +0 -636
  339. package/dist/src/shaders/shadow.js.map +0 -1
  340. package/dist/src/shaders/ssr.js +0 -490
  341. package/dist/src/shaders/ssr.js.map +0 -1
  342. package/dist/src/shaders/temporal.js +0 -215
  343. package/dist/src/shaders/temporal.js.map +0 -1
  344. package/dist/src/shaders/water.js +0 -756
  345. package/dist/src/shaders/water.js.map +0 -1
  346. package/dist/src/shadow/esm.js +0 -237
  347. package/dist/src/shadow/esm.js.map +0 -1
  348. package/dist/src/shadow/pcf_opt.js +0 -181
  349. package/dist/src/shadow/pcf_opt.js.map +0 -1
  350. package/dist/src/shadow/pcf_pd.js +0 -189
  351. package/dist/src/shadow/pcf_pd.js.map +0 -1
  352. package/dist/src/shadow/shader.js +0 -37
  353. package/dist/src/shadow/shader.js.map +0 -1
  354. package/dist/src/shadow/shadow_impl.js +0 -15
  355. package/dist/src/shadow/shadow_impl.js.map +0 -1
  356. package/dist/src/shadow/shadowmapper.js +0 -790
  357. package/dist/src/shadow/shadowmapper.js.map +0 -1
  358. package/dist/src/shadow/ssm.js +0 -159
  359. package/dist/src/shadow/ssm.js.map +0 -1
  360. package/dist/src/shadow/vsm.js +0 -297
  361. package/dist/src/shadow/vsm.js.map +0 -1
  362. package/dist/src/shapes/box.js +0 -386
  363. package/dist/src/shapes/box.js.map +0 -1
  364. package/dist/src/shapes/cylinder.js +0 -125
  365. package/dist/src/shapes/cylinder.js.map +0 -1
  366. package/dist/src/shapes/plane.js +0 -88
  367. package/dist/src/shapes/plane.js.map +0 -1
  368. package/dist/src/shapes/shape.js +0 -87
  369. package/dist/src/shapes/shape.js.map +0 -1
  370. package/dist/src/shapes/sphere.js +0 -114
  371. package/dist/src/shapes/sphere.js.map +0 -1
  372. package/dist/src/shapes/tetrahedron.js +0 -188
  373. package/dist/src/shapes/tetrahedron.js.map +0 -1
  374. package/dist/src/shapes/torus.js +0 -111
  375. package/dist/src/shapes/torus.js.map +0 -1
  376. package/dist/src/utility/aabbtree.js +0 -400
  377. package/dist/src/utility/aabbtree.js.map +0 -1
  378. package/dist/src/utility/bounding_volume.js +0 -29
  379. package/dist/src/utility/bounding_volume.js.map +0 -1
  380. package/dist/src/utility/debug.js +0 -28
  381. package/dist/src/utility/debug.js.map +0 -1
  382. package/dist/src/utility/draco/decoder.js +0 -116
  383. package/dist/src/utility/draco/decoder.js.map +0 -1
  384. package/dist/src/utility/misc.js +0 -105
  385. package/dist/src/utility/misc.js.map +0 -1
  386. package/dist/src/utility/panorama.js +0 -163
  387. package/dist/src/utility/panorama.js.map +0 -1
  388. package/dist/src/utility/pmrem.js +0 -354
  389. package/dist/src/utility/pmrem.js.map +0 -1
  390. package/dist/src/utility/rendermipmap.js +0 -115
  391. package/dist/src/utility/rendermipmap.js.map +0 -1
  392. package/dist/src/utility/serialization/json.js +0 -402
  393. package/dist/src/utility/serialization/json.js.map +0 -1
  394. package/dist/src/utility/serialization/manager.js +0 -623
  395. package/dist/src/utility/serialization/manager.js.map +0 -1
  396. package/dist/src/utility/serialization/scene/animation.js +0 -248
  397. package/dist/src/utility/serialization/scene/animation.js.map +0 -1
  398. package/dist/src/utility/serialization/scene/batch.js +0 -59
  399. package/dist/src/utility/serialization/scene/batch.js.map +0 -1
  400. package/dist/src/utility/serialization/scene/camera.js +0 -790
  401. package/dist/src/utility/serialization/scene/camera.js.map +0 -1
  402. package/dist/src/utility/serialization/scene/common.js +0 -222
  403. package/dist/src/utility/serialization/scene/common.js.map +0 -1
  404. package/dist/src/utility/serialization/scene/light.js +0 -575
  405. package/dist/src/utility/serialization/scene/light.js.map +0 -1
  406. package/dist/src/utility/serialization/scene/material.js +0 -1111
  407. package/dist/src/utility/serialization/scene/material.js.map +0 -1
  408. package/dist/src/utility/serialization/scene/mesh.js +0 -148
  409. package/dist/src/utility/serialization/scene/mesh.js.map +0 -1
  410. package/dist/src/utility/serialization/scene/misc.js +0 -39
  411. package/dist/src/utility/serialization/scene/misc.js.map +0 -1
  412. package/dist/src/utility/serialization/scene/node.js +0 -451
  413. package/dist/src/utility/serialization/scene/node.js.map +0 -1
  414. package/dist/src/utility/serialization/scene/particle.js +0 -425
  415. package/dist/src/utility/serialization/scene/particle.js.map +0 -1
  416. package/dist/src/utility/serialization/scene/primitive.js +0 -692
  417. package/dist/src/utility/serialization/scene/primitive.js.map +0 -1
  418. package/dist/src/utility/serialization/scene/scene.js +0 -704
  419. package/dist/src/utility/serialization/scene/scene.js.map +0 -1
  420. package/dist/src/utility/serialization/scene/terrain.js +0 -488
  421. package/dist/src/utility/serialization/scene/terrain.js.map +0 -1
  422. package/dist/src/utility/serialization/scene/water.js +0 -465
  423. package/dist/src/utility/serialization/scene/water.js.map +0 -1
  424. package/dist/src/utility/shprojector.js +0 -297
  425. package/dist/src/utility/shprojector.js.map +0 -1
  426. package/dist/src/utility/textures/ggxlut.js +0 -213
  427. package/dist/src/utility/textures/ggxlut.js.map +0 -1
  428. package/dist/src/utility/textures/gradientnoise.js +0 -62
  429. package/dist/src/utility/textures/gradientnoise.js.map +0 -1
  430. package/dist/src/utility/textures/randomnoise.js +0 -41
  431. package/dist/src/utility/textures/randomnoise.js.map +0 -1
  432. package/dist/src/values.js +0 -162
  433. package/dist/src/values.js.map +0 -1
  434. package/dist/utility/blueprint/material/common.js +0 -7
  435. package/dist/utility/blueprint/material/common.js.map +0 -1
  436. package/dist/utility/serialization/blueprint/constants.js +0 -255
  437. package/dist/utility/serialization/blueprint/constants.js.map +0 -1
  438. package/dist/utility/serialization/blueprint/material/constants.js +0 -203
  439. package/dist/utility/serialization/blueprint/material/constants.js.map +0 -1
  440. package/dist/utility/serialization/blueprint/material/texture.js +0 -165
  441. package/dist/utility/serialization/blueprint/material/texture.js.map +0 -1
@@ -0,0 +1,306 @@
1
+ import { RGHandle, RGPass, RGResource } from './types.js';
2
+
3
+ /**
4
+ * Render Graph — declarative, configurable render pipeline.
5
+ *
6
+ * Usage:
7
+ * ```ts
8
+ * const graph = new RenderGraph();
9
+ * const backbuffer = graph.importTexture('backbuffer');
10
+ *
11
+ * let linearDepth: RGHandle;
12
+ * graph.addPass('DepthPrepass', (builder) => {
13
+ * linearDepth = builder.createTexture({ format: 'r32f', label: 'linearDepth' });
14
+ * builder.setExecute(() => { ... });
15
+ * });
16
+ *
17
+ * graph.addPass('LightPass', (builder) => {
18
+ * builder.read(linearDepth);
19
+ * builder.write(backbuffer);
20
+ * builder.setExecute(() => { ... });
21
+ * });
22
+ *
23
+ * const compiled = graph.compile([backbuffer]);
24
+ * graph.execute(compiled);
25
+ * graph.reset();
26
+ * ```
27
+ *
28
+ * @public
29
+ */ class RenderGraph {
30
+ /** @internal */ _nextResourceId = 0;
31
+ /** @internal */ _resources = new Map();
32
+ /** @internal */ _passes = [];
33
+ /** @internal */ _compiled = null;
34
+ // ─── Graph Building ─────────────────────────────────────────────────
35
+ /**
36
+ * Import an external (persistent) texture into the graph.
37
+ *
38
+ * Imported resources are not allocated or released by the graph.
39
+ * Typically used for the backbuffer or any texture that outlives a single frame.
40
+ *
41
+ * @param name - Debug label for the imported resource.
42
+ * @returns A handle referencing the imported resource.
43
+ */ importTexture(name) {
44
+ const id = this._nextResourceId++;
45
+ const resource = new RGResource(id, name, 'imported', null);
46
+ this._resources.set(id, resource);
47
+ this._compiled = null;
48
+ return new RGHandle(id, name);
49
+ }
50
+ /**
51
+ * Add a render pass to the graph.
52
+ *
53
+ * The setup callback receives a {@link RGPassBuilder} to declare resource
54
+ * dependencies. Call `builder.setExecute(fn)` inside setup to provide the
55
+ * execution callback.
56
+ *
57
+ * @param name - Debug label for the pass.
58
+ * @param setup - Setup callback that declares resources and sets the execute function.
59
+ */ addPass(name, setup) {
60
+ const pass = new RGPass(this._passes.length, name);
61
+ const builder = this._createBuilder(pass);
62
+ const data = setup(builder);
63
+ pass.data = data;
64
+ this._passes.push(pass);
65
+ this._compiled = null;
66
+ return data;
67
+ }
68
+ // ─── Compilation ────────────────────────────────────────────────────
69
+ /**
70
+ * Compile the render graph.
71
+ *
72
+ * Performs dead-pass culling, topological sorting, and resource lifetime analysis.
73
+ *
74
+ * @param outputs - Handles of resources that must be produced (graph sinks).
75
+ * Passes that do not contribute to these outputs (directly or transitively)
76
+ * are culled, unless marked as side-effect passes.
77
+ * @returns The compiled graph ready for execution.
78
+ */ compile(outputs) {
79
+ if (this._compiled) {
80
+ return this._compiled;
81
+ }
82
+ // 1. Mark alive passes via backward traversal from outputs + side-effect passes
83
+ this._cullDeadPasses(outputs);
84
+ // 2. Topological sort of alive passes
85
+ const ordered = this._topologicalSort();
86
+ // 3. Resource lifetime analysis
87
+ const lifetimes = this._analyzeLifetimes(ordered);
88
+ this._compiled = {
89
+ orderedPasses: ordered,
90
+ lifetimes
91
+ };
92
+ return this._compiled;
93
+ }
94
+ /**
95
+ * Execute a compiled render graph (simple mode, no resource management).
96
+ *
97
+ * For automatic resource allocation/release, use {@link RenderGraphExecutor} instead.
98
+ *
99
+ * @param compiled - The compiled graph from {@link compile}.
100
+ */ execute(compiled) {
101
+ const noopCtx = {
102
+ getTexture () {
103
+ throw new Error('RenderGraph.execute(): resource resolution not available. Use RenderGraphExecutor for managed execution.');
104
+ }
105
+ };
106
+ for (const pass of compiled.orderedPasses){
107
+ if (pass.executeFn) {
108
+ pass.executeFn(noopCtx, pass.data);
109
+ }
110
+ }
111
+ }
112
+ /**
113
+ * Reset the graph for the next frame.
114
+ *
115
+ * Clears all passes, transient resources, and compiled state.
116
+ * Imported resources are also cleared — re-import them each frame.
117
+ */ reset() {
118
+ this._passes.length = 0;
119
+ this._resources.clear();
120
+ this._nextResourceId = 0;
121
+ this._compiled = null;
122
+ }
123
+ // ─── Accessors (for testing / debugging) ────────────────────────────
124
+ /** @internal */ getResource(handle) {
125
+ return this._resources.get(handle._id);
126
+ }
127
+ /** @internal */ get passes() {
128
+ return this._passes;
129
+ }
130
+ /** @internal */ get resources() {
131
+ return this._resources;
132
+ }
133
+ // ─── Private: Builder ───────────────────────────────────────────────
134
+ /** @internal */ _createBuilder(pass) {
135
+ const graph = this;
136
+ return {
137
+ read (handle) {
138
+ const res = graph._resources.get(handle._id);
139
+ if (!res) {
140
+ throw new Error(`RenderGraph: unknown resource "${handle.name}" (id=${handle._id})`);
141
+ }
142
+ pass.reads.push(res);
143
+ res.consumers.push(pass);
144
+ },
145
+ write (handle) {
146
+ const res = graph._resources.get(handle._id);
147
+ if (!res) {
148
+ throw new Error(`RenderGraph: unknown resource "${handle.name}" (id=${handle._id})`);
149
+ }
150
+ if (res.producer && res.producer !== pass) {
151
+ throw new Error(`RenderGraph: resource "${res.name}" already produced by pass "${res.producer.name}", ` + `cannot be written by pass "${pass.name}"`);
152
+ }
153
+ res.producer = pass;
154
+ pass.writes.push(res);
155
+ },
156
+ createTexture (desc) {
157
+ const id = graph._nextResourceId++;
158
+ const name = desc.label ?? `_tex_${id}`;
159
+ const res = new RGResource(id, name, 'transient', desc);
160
+ res.producer = pass;
161
+ graph._resources.set(id, res);
162
+ pass.writes.push(res);
163
+ return new RGHandle(id, name);
164
+ },
165
+ sideEffect () {
166
+ pass.hasSideEffect = true;
167
+ },
168
+ setExecute (fn) {
169
+ pass.executeFn = fn;
170
+ }
171
+ };
172
+ }
173
+ // ─── Private: Dead Pass Culling ─────────────────────────────────────
174
+ /** @internal */ _cullDeadPasses(outputs) {
175
+ // Start with all passes marked dead
176
+ for (const pass of this._passes){
177
+ pass.alive = false;
178
+ }
179
+ // Seed: resources that are requested outputs
180
+ const neededResources = new Set();
181
+ const stack = [];
182
+ for (const handle of outputs){
183
+ const res = this._resources.get(handle._id);
184
+ if (res) {
185
+ neededResources.add(res.id);
186
+ stack.push(res);
187
+ }
188
+ }
189
+ // Seed: side-effect passes (always alive) — push their read dependencies
190
+ for (const pass of this._passes){
191
+ if (pass.hasSideEffect) {
192
+ pass.alive = true;
193
+ for (const res of pass.reads){
194
+ if (!neededResources.has(res.id)) {
195
+ neededResources.add(res.id);
196
+ stack.push(res);
197
+ }
198
+ }
199
+ }
200
+ }
201
+ // Backward traversal: for each needed resource, mark its producer alive
202
+ // and recursively mark the producer's read dependencies as needed
203
+ while(stack.length > 0){
204
+ const res = stack.pop();
205
+ const producer = res.producer;
206
+ if (producer && !producer.alive) {
207
+ producer.alive = true;
208
+ for (const dep of producer.reads){
209
+ if (!neededResources.has(dep.id)) {
210
+ neededResources.add(dep.id);
211
+ stack.push(dep);
212
+ }
213
+ }
214
+ }
215
+ }
216
+ }
217
+ // ─── Private: Topological Sort (Kahn's Algorithm) ───────────────────
218
+ /** @internal */ _topologicalSort() {
219
+ const alivePasses = this._passes.filter((p)=>p.alive);
220
+ if (alivePasses.length === 0) {
221
+ return [];
222
+ }
223
+ // Build adjacency: producer -> consumers (only among alive passes)
224
+ const aliveSet = new Set(alivePasses);
225
+ const inDegree = new Map();
226
+ const adjacency = new Map();
227
+ for (const pass of alivePasses){
228
+ inDegree.set(pass, 0);
229
+ adjacency.set(pass, []);
230
+ }
231
+ // For each resource, its producer has an edge to each of its consumers
232
+ for (const res of this._resources.values()){
233
+ if (!res.producer || !aliveSet.has(res.producer)) {
234
+ continue;
235
+ }
236
+ for (const consumer of res.consumers){
237
+ if (!aliveSet.has(consumer)) {
238
+ continue;
239
+ }
240
+ adjacency.get(res.producer).push(consumer);
241
+ inDegree.set(consumer, inDegree.get(consumer) + 1);
242
+ }
243
+ }
244
+ // Kahn's algorithm
245
+ const queue = [];
246
+ for (const pass of alivePasses){
247
+ if (inDegree.get(pass) === 0) {
248
+ queue.push(pass);
249
+ }
250
+ }
251
+ const result = [];
252
+ while(queue.length > 0){
253
+ const pass = queue.shift();
254
+ result.push(pass);
255
+ for (const neighbor of adjacency.get(pass)){
256
+ const deg = inDegree.get(neighbor) - 1;
257
+ inDegree.set(neighbor, deg);
258
+ if (deg === 0) {
259
+ queue.push(neighbor);
260
+ }
261
+ }
262
+ }
263
+ if (result.length !== alivePasses.length) {
264
+ throw new Error(`RenderGraph: circular dependency detected. ` + `Sorted ${result.length} of ${alivePasses.length} alive passes.`);
265
+ }
266
+ return result;
267
+ }
268
+ // ─── Private: Resource Lifetime Analysis ────────────────────────────
269
+ /** @internal */ _analyzeLifetimes(orderedPasses) {
270
+ const lifetimes = new Map();
271
+ // Build pass -> order index map
272
+ const orderMap = new Map();
273
+ for(let i = 0; i < orderedPasses.length; i++){
274
+ orderMap.set(orderedPasses[i], i);
275
+ }
276
+ for (const res of this._resources.values()){
277
+ let first = Infinity;
278
+ let last = -Infinity;
279
+ // Producer
280
+ if (res.producer && orderMap.has(res.producer)) {
281
+ const idx = orderMap.get(res.producer);
282
+ first = Math.min(first, idx);
283
+ last = Math.max(last, idx);
284
+ }
285
+ // Consumers
286
+ for (const consumer of res.consumers){
287
+ if (orderMap.has(consumer)) {
288
+ const idx = orderMap.get(consumer);
289
+ first = Math.min(first, idx);
290
+ last = Math.max(last, idx);
291
+ }
292
+ }
293
+ if (first !== Infinity) {
294
+ lifetimes.set(res.id, {
295
+ resource: res,
296
+ firstUse: first,
297
+ lastUse: last
298
+ });
299
+ }
300
+ }
301
+ return lifetimes;
302
+ }
303
+ }
304
+
305
+ export { RenderGraph };
306
+ //# sourceMappingURL=rendergraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rendergraph.js","sources":["../../../src/render/rendergraph/rendergraph.ts"],"sourcesContent":["import {\r\n RGHandle,\r\n RGResource,\r\n RGPass,\r\n type RGTextureDesc,\r\n type RGPassBuilder,\r\n type RGExecuteFn,\r\n type RGExecuteContext,\r\n type CompiledRenderGraph,\r\n type RGResourceLifetime\r\n} from './types';\r\n\r\n/**\r\n * Render Graph — declarative, configurable render pipeline.\r\n *\r\n * Usage:\r\n * ```ts\r\n * const graph = new RenderGraph();\r\n * const backbuffer = graph.importTexture('backbuffer');\r\n *\r\n * let linearDepth: RGHandle;\r\n * graph.addPass('DepthPrepass', (builder) => {\r\n * linearDepth = builder.createTexture({ format: 'r32f', label: 'linearDepth' });\r\n * builder.setExecute(() => { ... });\r\n * });\r\n *\r\n * graph.addPass('LightPass', (builder) => {\r\n * builder.read(linearDepth);\r\n * builder.write(backbuffer);\r\n * builder.setExecute(() => { ... });\r\n * });\r\n *\r\n * const compiled = graph.compile([backbuffer]);\r\n * graph.execute(compiled);\r\n * graph.reset();\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class RenderGraph {\r\n /** @internal */\r\n private _nextResourceId = 0;\r\n /** @internal */\r\n private _resources: Map<number, RGResource> = new Map();\r\n /** @internal */\r\n private _passes: RGPass[] = [];\r\n /** @internal */\r\n private _compiled: CompiledRenderGraph | null = null;\r\n\r\n // ─── Graph Building ─────────────────────────────────────────────────\r\n\r\n /**\r\n * Import an external (persistent) texture into the graph.\r\n *\r\n * Imported resources are not allocated or released by the graph.\r\n * Typically used for the backbuffer or any texture that outlives a single frame.\r\n *\r\n * @param name - Debug label for the imported resource.\r\n * @returns A handle referencing the imported resource.\r\n */\r\n importTexture(name: string): RGHandle {\r\n const id = this._nextResourceId++;\r\n const resource = new RGResource(id, name, 'imported', null);\r\n this._resources.set(id, resource);\r\n this._compiled = null;\r\n return new RGHandle(id, name);\r\n }\r\n\r\n /**\r\n * Add a render pass to the graph.\r\n *\r\n * The setup callback receives a {@link RGPassBuilder} to declare resource\r\n * dependencies. Call `builder.setExecute(fn)` inside setup to provide the\r\n * execution callback.\r\n *\r\n * @param name - Debug label for the pass.\r\n * @param setup - Setup callback that declares resources and sets the execute function.\r\n */\r\n addPass<T = void>(name: string, setup: (builder: RGPassBuilder) => T): T {\r\n const pass = new RGPass(this._passes.length, name);\r\n const builder = this._createBuilder(pass);\r\n const data = setup(builder);\r\n pass.data = data;\r\n this._passes.push(pass);\r\n this._compiled = null;\r\n return data;\r\n }\r\n\r\n // ─── Compilation ────────────────────────────────────────────────────\r\n\r\n /**\r\n * Compile the render graph.\r\n *\r\n * Performs dead-pass culling, topological sorting, and resource lifetime analysis.\r\n *\r\n * @param outputs - Handles of resources that must be produced (graph sinks).\r\n * Passes that do not contribute to these outputs (directly or transitively)\r\n * are culled, unless marked as side-effect passes.\r\n * @returns The compiled graph ready for execution.\r\n */\r\n compile(outputs: RGHandle[]): CompiledRenderGraph {\r\n if (this._compiled) {\r\n return this._compiled;\r\n }\r\n // 1. Mark alive passes via backward traversal from outputs + side-effect passes\r\n this._cullDeadPasses(outputs);\r\n // 2. Topological sort of alive passes\r\n const ordered = this._topologicalSort();\r\n // 3. Resource lifetime analysis\r\n const lifetimes = this._analyzeLifetimes(ordered);\r\n\r\n this._compiled = { orderedPasses: ordered, lifetimes };\r\n return this._compiled;\r\n }\r\n\r\n /**\r\n * Execute a compiled render graph (simple mode, no resource management).\r\n *\r\n * For automatic resource allocation/release, use {@link RenderGraphExecutor} instead.\r\n *\r\n * @param compiled - The compiled graph from {@link compile}.\r\n */\r\n execute(compiled: CompiledRenderGraph): void {\r\n const noopCtx: RGExecuteContext = {\r\n getTexture() {\r\n throw new Error(\r\n 'RenderGraph.execute(): resource resolution not available. Use RenderGraphExecutor for managed execution.'\r\n );\r\n }\r\n };\r\n for (const pass of compiled.orderedPasses) {\r\n if (pass.executeFn) {\r\n (pass.executeFn as RGExecuteFn<unknown>)(noopCtx, pass.data);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Reset the graph for the next frame.\r\n *\r\n * Clears all passes, transient resources, and compiled state.\r\n * Imported resources are also cleared — re-import them each frame.\r\n */\r\n reset(): void {\r\n this._passes.length = 0;\r\n this._resources.clear();\r\n this._nextResourceId = 0;\r\n this._compiled = null;\r\n }\r\n\r\n // ─── Accessors (for testing / debugging) ────────────────────────────\r\n\r\n /** @internal */\r\n getResource(handle: RGHandle): RGResource | undefined {\r\n return this._resources.get(handle._id);\r\n }\r\n\r\n /** @internal */\r\n get passes(): ReadonlyArray<RGPass> {\r\n return this._passes;\r\n }\r\n\r\n /** @internal */\r\n get resources(): ReadonlyMap<number, RGResource> {\r\n return this._resources;\r\n }\r\n\r\n // ─── Private: Builder ───────────────────────────────────────────────\r\n\r\n /** @internal */\r\n private _createBuilder(pass: RGPass): RGPassBuilder {\r\n const graph = this;\r\n return {\r\n read(handle: RGHandle): void {\r\n const res = graph._resources.get(handle._id);\r\n if (!res) {\r\n throw new Error(`RenderGraph: unknown resource \"${handle.name}\" (id=${handle._id})`);\r\n }\r\n pass.reads.push(res);\r\n res.consumers.push(pass);\r\n },\r\n write(handle: RGHandle): void {\r\n const res = graph._resources.get(handle._id);\r\n if (!res) {\r\n throw new Error(`RenderGraph: unknown resource \"${handle.name}\" (id=${handle._id})`);\r\n }\r\n if (res.producer && res.producer !== pass) {\r\n throw new Error(\r\n `RenderGraph: resource \"${res.name}\" already produced by pass \"${res.producer.name}\", ` +\r\n `cannot be written by pass \"${pass.name}\"`\r\n );\r\n }\r\n res.producer = pass;\r\n pass.writes.push(res);\r\n },\r\n createTexture(desc: RGTextureDesc): RGHandle {\r\n const id = graph._nextResourceId++;\r\n const name = desc.label ?? `_tex_${id}`;\r\n const res = new RGResource(id, name, 'transient', desc);\r\n res.producer = pass;\r\n graph._resources.set(id, res);\r\n pass.writes.push(res);\r\n return new RGHandle(id, name);\r\n },\r\n sideEffect(): void {\r\n pass.hasSideEffect = true;\r\n },\r\n setExecute<D>(fn: RGExecuteFn<D>): void {\r\n pass.executeFn = fn as RGExecuteFn<unknown>;\r\n }\r\n };\r\n }\r\n\r\n // ─── Private: Dead Pass Culling ─────────────────────────────────────\r\n\r\n /** @internal */\r\n private _cullDeadPasses(outputs: RGHandle[]): void {\r\n // Start with all passes marked dead\r\n for (const pass of this._passes) {\r\n pass.alive = false;\r\n }\r\n\r\n // Seed: resources that are requested outputs\r\n const neededResources = new Set<number>();\r\n const stack: RGResource[] = [];\r\n\r\n for (const handle of outputs) {\r\n const res = this._resources.get(handle._id);\r\n if (res) {\r\n neededResources.add(res.id);\r\n stack.push(res);\r\n }\r\n }\r\n\r\n // Seed: side-effect passes (always alive) — push their read dependencies\r\n for (const pass of this._passes) {\r\n if (pass.hasSideEffect) {\r\n pass.alive = true;\r\n for (const res of pass.reads) {\r\n if (!neededResources.has(res.id)) {\r\n neededResources.add(res.id);\r\n stack.push(res);\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Backward traversal: for each needed resource, mark its producer alive\r\n // and recursively mark the producer's read dependencies as needed\r\n while (stack.length > 0) {\r\n const res = stack.pop()!;\r\n const producer = res.producer;\r\n if (producer && !producer.alive) {\r\n producer.alive = true;\r\n for (const dep of producer.reads) {\r\n if (!neededResources.has(dep.id)) {\r\n neededResources.add(dep.id);\r\n stack.push(dep);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // ─── Private: Topological Sort (Kahn's Algorithm) ───────────────────\r\n\r\n /** @internal */\r\n private _topologicalSort(): RGPass[] {\r\n const alivePasses = this._passes.filter((p) => p.alive);\r\n if (alivePasses.length === 0) {\r\n return [];\r\n }\r\n\r\n // Build adjacency: producer -> consumers (only among alive passes)\r\n const aliveSet = new Set(alivePasses);\r\n const inDegree = new Map<RGPass, number>();\r\n const adjacency = new Map<RGPass, RGPass[]>();\r\n\r\n for (const pass of alivePasses) {\r\n inDegree.set(pass, 0);\r\n adjacency.set(pass, []);\r\n }\r\n\r\n // For each resource, its producer has an edge to each of its consumers\r\n for (const res of this._resources.values()) {\r\n if (!res.producer || !aliveSet.has(res.producer)) {\r\n continue;\r\n }\r\n for (const consumer of res.consumers) {\r\n if (!aliveSet.has(consumer)) {\r\n continue;\r\n }\r\n adjacency.get(res.producer)!.push(consumer);\r\n inDegree.set(consumer, inDegree.get(consumer)! + 1);\r\n }\r\n }\r\n\r\n // Kahn's algorithm\r\n const queue: RGPass[] = [];\r\n for (const pass of alivePasses) {\r\n if (inDegree.get(pass) === 0) {\r\n queue.push(pass);\r\n }\r\n }\r\n\r\n const result: RGPass[] = [];\r\n while (queue.length > 0) {\r\n const pass = queue.shift()!;\r\n result.push(pass);\r\n for (const neighbor of adjacency.get(pass)!) {\r\n const deg = inDegree.get(neighbor)! - 1;\r\n inDegree.set(neighbor, deg);\r\n if (deg === 0) {\r\n queue.push(neighbor);\r\n }\r\n }\r\n }\r\n\r\n if (result.length !== alivePasses.length) {\r\n throw new Error(\r\n `RenderGraph: circular dependency detected. ` +\r\n `Sorted ${result.length} of ${alivePasses.length} alive passes.`\r\n );\r\n }\r\n\r\n return result;\r\n }\r\n\r\n // ─── Private: Resource Lifetime Analysis ────────────────────────────\r\n\r\n /** @internal */\r\n private _analyzeLifetimes(orderedPasses: RGPass[]): Map<number, RGResourceLifetime> {\r\n const lifetimes = new Map<number, RGResourceLifetime>();\r\n\r\n // Build pass -> order index map\r\n const orderMap = new Map<RGPass, number>();\r\n for (let i = 0; i < orderedPasses.length; i++) {\r\n orderMap.set(orderedPasses[i], i);\r\n }\r\n\r\n for (const res of this._resources.values()) {\r\n let first = Infinity;\r\n let last = -Infinity;\r\n\r\n // Producer\r\n if (res.producer && orderMap.has(res.producer)) {\r\n const idx = orderMap.get(res.producer)!;\r\n first = Math.min(first, idx);\r\n last = Math.max(last, idx);\r\n }\r\n\r\n // Consumers\r\n for (const consumer of res.consumers) {\r\n if (orderMap.has(consumer)) {\r\n const idx = orderMap.get(consumer)!;\r\n first = Math.min(first, idx);\r\n last = Math.max(last, idx);\r\n }\r\n }\r\n\r\n if (first !== Infinity) {\r\n lifetimes.set(res.id, { resource: res, firstUse: first, lastUse: last });\r\n }\r\n }\r\n\r\n return lifetimes;\r\n }\r\n}\r\n"],"names":["RenderGraph","_nextResourceId","_resources","Map","_passes","_compiled","importTexture","name","id","resource","RGResource","set","RGHandle","addPass","setup","pass","RGPass","length","builder","_createBuilder","data","push","compile","outputs","_cullDeadPasses","ordered","_topologicalSort","lifetimes","_analyzeLifetimes","orderedPasses","execute","compiled","noopCtx","getTexture","Error","executeFn","reset","clear","getResource","handle","get","_id","passes","resources","graph","read","res","reads","consumers","write","producer","writes","createTexture","desc","label","sideEffect","hasSideEffect","setExecute","fn","alive","neededResources","Set","stack","add","has","pop","dep","alivePasses","filter","p","aliveSet","inDegree","adjacency","values","consumer","queue","result","shift","neighbor","deg","orderMap","i","first","Infinity","last","idx","Math","min","max","firstUse","lastUse"],"mappings":";;AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BC,IACM,MAAMA,WAAAA,CAAAA;qBAEX,eAAQC,GAAkB,CAAE;AAC5B,qBACQC,UAAsC,GAAA,IAAIC,GAAM,EAAA;AACxD,qBACQC,OAAoB,GAAA,EAAE;qBAE9B,SAAQC,GAAwC,IAAK;;AAIrD;;;;;;;;MASAC,aAAAA,CAAcC,IAAY,EAAY;QACpC,MAAMC,EAAAA,GAAK,IAAI,CAACP,eAAe,EAAA;AAC/B,QAAA,MAAMQ,QAAW,GAAA,IAAIC,UAAWF,CAAAA,EAAAA,EAAID,MAAM,UAAY,EAAA,IAAA,CAAA;AACtD,QAAA,IAAI,CAACL,UAAU,CAACS,GAAG,CAACH,EAAIC,EAAAA,QAAAA,CAAAA;QACxB,IAAI,CAACJ,SAAS,GAAG,IAAA;QACjB,OAAO,IAAIO,SAASJ,EAAID,EAAAA,IAAAA,CAAAA;AAC1B;AAEA;;;;;;;;;AASC,MACDM,OAAkBN,CAAAA,IAAY,EAAEO,KAAoC,EAAK;QACvE,MAAMC,IAAAA,GAAO,IAAIC,MAAO,CAAA,IAAI,CAACZ,OAAO,CAACa,MAAM,EAAEV,IAAAA,CAAAA;AAC7C,QAAA,MAAMW,OAAU,GAAA,IAAI,CAACC,cAAc,CAACJ,IAAAA,CAAAA;AACpC,QAAA,MAAMK,OAAON,KAAMI,CAAAA,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AAIH,UAAUC,QAAU,EAAA;AACtBxD,gBAAAA,SAAAA,CAAUhB,GAAG,CAACmC,GAAItC,CAAAA,EAAE,EAAE;oBAAEC,QAAUqC,EAAAA,GAAAA;oBAAK2C,QAAUP,EAAAA,KAAAA;oBAAOQ,OAASN,EAAAA;AAAK,iBAAA,CAAA;AACxE;AACF;QAEA,OAAOzD,SAAAA;AACT;AACF;;;;"}
@@ -0,0 +1,57 @@
1
+ // ─── Handles ────────────────────────────────────────────────────────────
2
+ /**
3
+ * Opaque handle referencing a resource within the render graph.
4
+ *
5
+ * Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RenderGraph.importTexture},
6
+ * or {@link RGPassBuilder.write}. They are lightweight identifiers used to declare
7
+ * dependencies between passes.
8
+ *
9
+ * @public
10
+ */ class RGHandle {
11
+ /** @internal */ _id;
12
+ /** @internal */ _name;
13
+ /** @internal */ constructor(id, name){
14
+ this._id = id;
15
+ this._name = name;
16
+ }
17
+ /** Debug-friendly name of the referenced resource. */ get name() {
18
+ return this._name;
19
+ }
20
+ }
21
+ /**
22
+ * Internal bookkeeping for a resource within the render graph.
23
+ * @internal
24
+ */ class RGResource {
25
+ id;
26
+ name;
27
+ kind;
28
+ desc;
29
+ /** The pass that creates / writes this resource (null for imported until written). */ producer = null;
30
+ /** Passes that read this resource. */ consumers = [];
31
+ constructor(id, name, kind, desc){
32
+ this.id = id;
33
+ this.name = name;
34
+ this.kind = kind;
35
+ this.desc = desc;
36
+ }
37
+ }
38
+ /**
39
+ * Internal bookkeeping for a pass within the render graph.
40
+ * @internal
41
+ */ class RGPass {
42
+ index;
43
+ name;
44
+ /** Resources this pass reads (dependencies). */ reads = [];
45
+ /** Resources this pass creates or writes. */ writes = [];
46
+ /** Whether this pass has side effects and must not be culled. */ hasSideEffect = false;
47
+ /** User data returned from the setup function. */ data = null;
48
+ /** Execute callback. */ executeFn = null;
49
+ /** Set during compilation: true if this pass is needed. */ alive = true;
50
+ constructor(index, name){
51
+ this.index = index;
52
+ this.name = name;
53
+ }
54
+ }
55
+
56
+ export { RGHandle, RGPass, RGResource };
57
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../src/render/rendergraph/types.ts"],"sourcesContent":["import type { TextureFormat } from '@zephyr3d/device';\r\n\r\n// ─── Resource Descriptors ───────────────────────────────────────────────\r\n\r\n/**\r\n * Sizing mode for render graph textures.\r\n *\r\n * - 'absolute': fixed pixel dimensions\r\n * - 'backbuffer-relative': scaled relative to the backbuffer size\r\n *\r\n * @public\r\n */\r\nexport type RGSizeMode = 'absolute' | 'backbuffer-relative';\r\n\r\n/**\r\n * Descriptor for a transient texture resource within the render graph.\r\n *\r\n * Transient textures are allocated and released automatically by the graph compiler.\r\n *\r\n * @public\r\n */\r\nexport interface RGTextureDesc {\r\n /** Debug label for this resource. */\r\n label?: string;\r\n /** Texture format (e.g. 'rgba8unorm', 'r32f', 'rgba16f'). */\r\n format: TextureFormat;\r\n /** Sizing mode. Default 'backbuffer-relative'. */\r\n sizeMode?: RGSizeMode;\r\n /** Width in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n width?: number;\r\n /** Height in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n height?: number;\r\n /** Number of mip levels. Default 1. */\r\n mipLevels?: number;\r\n}\r\n\r\n// ─── Handles ────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Opaque handle referencing a resource within the render graph.\r\n *\r\n * Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RenderGraph.importTexture},\r\n * or {@link RGPassBuilder.write}. They are lightweight identifiers used to declare\r\n * dependencies between passes.\r\n *\r\n * @public\r\n */\r\nexport class RGHandle {\r\n /** @internal */\r\n readonly _id: number;\r\n /** @internal */\r\n readonly _name: string;\r\n\r\n /** @internal */\r\n constructor(id: number, name: string) {\r\n this._id = id;\r\n this._name = name;\r\n }\r\n\r\n /** Debug-friendly name of the referenced resource. */\r\n get name(): string {\r\n return this._name;\r\n }\r\n}\r\n\r\n// ─── Internal Resource Tracking ─────────────────────────────────────────\r\n\r\n/** @internal */\r\nexport type RGResourceKind = 'transient' | 'imported';\r\n\r\n/**\r\n * Internal bookkeeping for a resource within the render graph.\r\n * @internal\r\n */\r\nexport class RGResource {\r\n readonly id: number;\r\n readonly name: string;\r\n readonly kind: RGResourceKind;\r\n readonly desc: RGTextureDesc | null;\r\n /** The pass that creates / writes this resource (null for imported until written). */\r\n producer: RGPass | null = null;\r\n /** Passes that read this resource. */\r\n readonly consumers: RGPass[] = [];\r\n\r\n constructor(id: number, name: string, kind: RGResourceKind, desc: RGTextureDesc | null) {\r\n this.id = id;\r\n this.name = name;\r\n this.kind = kind;\r\n this.desc = desc;\r\n }\r\n}\r\n\r\n// ─── Internal Pass Tracking ─────────────────────────────────────────────\r\n\r\n// ─── Execution Context ──────────────────────────────────────────────\r\n\r\n/**\r\n * Context passed to pass execute callbacks during graph execution.\r\n *\r\n * Provides access to resolved GPU resources by their handles.\r\n *\r\n * @public\r\n */\r\nexport interface RGExecuteContext {\r\n /**\r\n * Resolve a handle to the actual GPU texture object.\r\n *\r\n * For transient resources, this returns the texture allocated by the executor.\r\n * For imported resources, this returns the texture registered via\r\n * {@link RenderGraphExecutor.setImportedTexture}.\r\n *\r\n * @param handle - Handle of the resource to resolve.\r\n * @returns The resolved texture object (type depends on the allocator).\r\n */\r\n getTexture<TTexture = unknown>(handle: RGHandle): TTexture;\r\n}\r\n\r\n/**\r\n * Execute callback signature.\r\n *\r\n * The callback receives a context for resolving handles to GPU resources,\r\n * plus the user data returned from the setup function.\r\n *\r\n * @public\r\n */\r\nexport type RGExecuteFn<T = void> = (ctx: RGExecuteContext, data: T) => void;\r\n\r\n/**\r\n * Internal bookkeeping for a pass within the render graph.\r\n * @internal\r\n */\r\nexport class RGPass<T = unknown> {\r\n readonly index: number;\r\n readonly name: string;\r\n /** Resources this pass reads (dependencies). */\r\n readonly reads: RGResource[] = [];\r\n /** Resources this pass creates or writes. */\r\n readonly writes: RGResource[] = [];\r\n /** Whether this pass has side effects and must not be culled. */\r\n hasSideEffect = false;\r\n /** User data returned from the setup function. */\r\n data: T | null = null;\r\n /** Execute callback. */\r\n executeFn: RGExecuteFn<T> | null = null;\r\n /** Set during compilation: true if this pass is needed. */\r\n alive = true;\r\n\r\n constructor(index: number, name: string) {\r\n this.index = index;\r\n this.name = name;\r\n }\r\n}\r\n\r\n// ─── Pass Builder ───────────────────────────────────────────────────────\r\n\r\n/**\r\n * Builder interface used within the setup callback of {@link RenderGraph.addPass}\r\n * to declare a pass's resource requirements.\r\n *\r\n * @public\r\n */\r\nexport interface RGPassBuilder {\r\n /**\r\n * Declare a read dependency on an existing resource.\r\n *\r\n * The resource must have been created by a prior pass or imported into the graph.\r\n *\r\n * @param handle - Handle of the resource to read.\r\n */\r\n read(handle: RGHandle): void;\r\n\r\n /**\r\n * Declare that this pass writes to an existing resource (typically an imported resource).\r\n *\r\n * @param handle - Handle of the resource to write to.\r\n */\r\n write(handle: RGHandle): void;\r\n\r\n /**\r\n * Create a new transient texture resource that this pass will produce.\r\n *\r\n * @param desc - Texture descriptor.\r\n * @returns A handle referencing the newly created resource.\r\n */\r\n createTexture(desc: RGTextureDesc): RGHandle;\r\n\r\n /**\r\n * Mark this pass as having side effects.\r\n *\r\n * Side-effect passes are never culled by the graph compiler, regardless of\r\n * whether their outputs are consumed. Use this for GPU readback, picking,\r\n * debug overlays, etc.\r\n */\r\n sideEffect(): void;\r\n\r\n /**\r\n * Set the execution callback for this pass.\r\n *\r\n * @param fn - Callback invoked during graph execution.\r\n */\r\n setExecute<D>(fn: RGExecuteFn<D>): void;\r\n}\r\n\r\n// ─── Compiled Graph ─────────────────────────────────────────────────────\r\n\r\n/**\r\n * Lifetime information for a resource within the compiled graph.\r\n *\r\n * @public\r\n */\r\nexport interface RGResourceLifetime {\r\n /** The resource. */\r\n readonly resource: RGResource;\r\n /** Index of the first pass that uses (produces or reads) this resource. */\r\n readonly firstUse: number;\r\n /** Index of the last pass that uses this resource. */\r\n readonly lastUse: number;\r\n}\r\n\r\n/**\r\n * Result of compiling a render graph.\r\n *\r\n * Contains the ordered list of passes to execute and lifetime information\r\n * for automatic resource management.\r\n *\r\n * @public\r\n */\r\nexport interface CompiledRenderGraph {\r\n /** Topologically sorted passes (only non-culled passes). */\r\n readonly orderedPasses: ReadonlyArray<RGPass>;\r\n /** Resource lifetime information keyed by resource ID. */\r\n readonly lifetimes: ReadonlyMap<number, RGResourceLifetime>;\r\n}\r\n\r\n// ─── Texture Allocator ──────────────────────────────────────────────\r\n\r\n/**\r\n * Resolved dimensions for a texture allocation.\r\n * @public\r\n */\r\nexport interface RGResolvedSize {\r\n width: number;\r\n height: number;\r\n}\r\n\r\n/**\r\n * Interface for allocating and releasing transient textures.\r\n *\r\n * Implement this to bridge the render graph with your GPU device's resource pool.\r\n * The executor calls {@link allocate} before a resource's first use and\r\n * {@link release} after its last use.\r\n *\r\n * @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).\r\n * @public\r\n */\r\nexport interface RGTextureAllocator<TTexture = unknown> {\r\n /**\r\n * Allocate a transient texture matching the given descriptor and resolved size.\r\n *\r\n * @param desc - The texture descriptor from the pass builder.\r\n * @param size - The resolved pixel dimensions.\r\n * @returns The allocated texture object.\r\n */\r\n allocate(desc: RGTextureDesc, size: RGResolvedSize): TTexture;\r\n\r\n /**\r\n * Release a previously allocated transient texture back to the pool.\r\n *\r\n * @param texture - The texture to release.\r\n */\r\n release(texture: TTexture): void;\r\n}\r\n"],"names":["RGHandle","id","name","_id","_name","RGResource","kind","desc","producer","consumers","RGPass","index","reads","writes","hasSideEffect","data","executeFn","alive"],"mappings":"AAoCA;AAEA;;;;;;;;AAQC,IACM,MAAMA,QAAAA,CAAAA;qBAEX,GAAqB;qBAErB,KAAuB;AAEvB,qBACA,WAAA,CAAYC,EAAU,EAAEC,IAAY,CAAE;QACpC,IAAI,CAACC,GAAG,GAAGF,EAAAA;QACX,IAAI,CAACG,KAAK,GAAGF,IAAAA;AACf;2DAGA,IAAIA,IAAe,GAAA;QACjB,OAAO,IAAI,CAACE,KAAK;AACnB;AACF;AAOA;;;AAGC,IACM,MAAMC,UAAAA,CAAAA;IACFJ,EAAW;IACXC,IAAa;IACbI,IAAqB;IACrBC,IAA2B;2FAEpCC,WAA0B,IAAK;AAC/B,2CACSC,SAAsB,GAAA,EAAE;AAEjC,IAAA,WAAA,CAAYR,EAAU,EAAEC,IAAY,EAAEI,IAAoB,EAAEC,IAA0B,CAAE;QACtF,IAAI,CAACN,EAAE,GAAGA,EAAAA;QACV,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACI,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACC,IAAI,GAAGA,IAAAA;AACd;AACF;AAqCA;;;AAGC,IACM,MAAMG,MAAAA,CAAAA;IACFC,KAAc;IACdT,IAAa;AACtB,qDACSU,KAAsB,GAAA,EAAE;AACjC,kDACSC,MAAuB,GAAA,EAAE;sEAElCC,gBAAgB,KAAM;uDAEtBC,OAAiB,IAAK;6BAEtBC,YAAmC,IAAK;gEAExCC,QAAQ,IAAK;IAEb,WAAYN,CAAAA,KAAa,EAAET,IAAY,CAAE;QACvC,IAAI,CAACS,KAAK,GAAGA,KAAAA;QACb,IAAI,CAACT,IAAI,GAAGA,IAAAA;AACd;AACF;;;;"}
@@ -0,0 +1,85 @@
1
+ import { AbstractPostEffect } from '../posteffect/posteffect.js';
2
+ import '@zephyr3d/base';
3
+ import './primitive.js';
4
+ import { BoxShape } from '../shapes/box.js';
5
+ import '../shapes/cylinder.js';
6
+ import '../shapes/torus.js';
7
+ import '../shapes/plane.js';
8
+ import '../shapes/sphere.js';
9
+ import '../shapes/tetrahedron.js';
10
+
11
+ let _skyMotionVectorProgram = null;
12
+ let _skyMotionVectorBindGroup = null;
13
+ let _box = null;
14
+ function getSkyMotionVectorProgram(ctx) {
15
+ if (!_skyMotionVectorProgram) {
16
+ _skyMotionVectorProgram = ctx.device.buildRenderProgram({
17
+ vertex (pb) {
18
+ this.$inputs.pos = pb.vec3().attrib('position');
19
+ this.VPMatrix = pb.mat4().uniform(0);
20
+ this.prevVPMatrix = pb.mat4().uniform(0);
21
+ this.cameraPos = pb.vec3().uniform(0);
22
+ this.prevCameraPos = pb.vec3().uniform(0);
23
+ pb.main(function() {
24
+ this.$l.worldPos = pb.add(this.$inputs.pos, this.cameraPos);
25
+ this.$l.prevWorldPos = pb.add(this.$inputs.pos, this.prevCameraPos);
26
+ this.$l.clipPos = pb.mul(this.VPMatrix, pb.vec4(this.worldPos, 1));
27
+ this.$l.prevClipPos = pb.mul(this.prevVPMatrix, pb.vec4(this.prevWorldPos, 1));
28
+ this.clipPos.z = this.clipPos.w;
29
+ this.$builtins.position = this.clipPos;
30
+ this.$outputs.currentPos = this.clipPos;
31
+ this.$outputs.prevPos = this.prevClipPos;
32
+ });
33
+ },
34
+ fragment (pb) {
35
+ this.$outputs.color = pb.vec4();
36
+ pb.main(function() {
37
+ this.$l.motionVector = pb.mul(pb.sub(pb.div(this.$inputs.currentPos.xy, this.$inputs.currentPos.w), pb.div(this.$inputs.prevPos.xy, this.$inputs.prevPos.w)), 0.5);
38
+ this.$outputs.color = pb.vec4(this.motionVector, 0, 1);
39
+ });
40
+ }
41
+ });
42
+ _skyMotionVectorProgram.name = '@TAA_SkyMotionVector';
43
+ }
44
+ return _skyMotionVectorProgram;
45
+ }
46
+ function getBox() {
47
+ if (!_box) {
48
+ _box = new BoxShape({
49
+ size: 2,
50
+ needNormal: false,
51
+ needUV: false
52
+ });
53
+ }
54
+ return _box;
55
+ }
56
+ /**
57
+ * Renders sky motion vectors into ctx.motionVectorTexture.
58
+ * Must be called after opaque pass with ctx.motionVectorTexture set.
59
+ * @internal
60
+ */ function renderSkyMotionVectors(ctx) {
61
+ if (!ctx.motionVectorTexture) {
62
+ return;
63
+ }
64
+ const fb = ctx.device.pool.fetchTemporalFramebuffer(false, 0, 0, ctx.motionVectorTexture, ctx.depthTexture);
65
+ const program = getSkyMotionVectorProgram(ctx);
66
+ if (!_skyMotionVectorBindGroup) {
67
+ _skyMotionVectorBindGroup = ctx.device.createBindGroup(program.bindGroupLayouts[0]);
68
+ }
69
+ const box = getBox();
70
+ _skyMotionVectorBindGroup.setValue('VPMatrix', ctx.camera.viewProjectionMatrix);
71
+ _skyMotionVectorBindGroup.setValue('prevVPMatrix', ctx.camera.prevVPMatrix);
72
+ _skyMotionVectorBindGroup.setValue('cameraPos', ctx.camera.getWorldPosition());
73
+ _skyMotionVectorBindGroup.setValue('prevCameraPos', ctx.camera.prevPosition);
74
+ ctx.device.pushDeviceStates();
75
+ ctx.device.setProgram(program);
76
+ ctx.device.setBindGroup(0, _skyMotionVectorBindGroup);
77
+ ctx.device.setRenderStates(AbstractPostEffect.getDefaultRenderState(ctx, 'le'));
78
+ ctx.device.setFramebuffer(fb);
79
+ box.draw();
80
+ ctx.device.popDeviceStates();
81
+ ctx.device.pool.releaseFrameBuffer(fb);
82
+ }
83
+
84
+ export { renderSkyMotionVectors };
85
+ //# sourceMappingURL=sky_motion_vector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sky_motion_vector.js","sources":["../../src/render/sky_motion_vector.ts"],"sourcesContent":["import type { BindGroup, GPUProgram } from '@zephyr3d/device';\nimport type { Nullable } from '@zephyr3d/base';\nimport { AbstractPostEffect } from '../posteffect/posteffect';\nimport { BoxShape } from '../shapes';\nimport type { DrawContext } from './drawable';\nimport type { Primitive } from '.';\n\nlet _skyMotionVectorProgram: Nullable<GPUProgram> = null;\nlet _skyMotionVectorBindGroup: Nullable<BindGroup> = null;\nlet _box: Nullable<Primitive> = null;\n\nfunction getSkyMotionVectorProgram(ctx: DrawContext): GPUProgram {\n if (!_skyMotionVectorProgram) {\n _skyMotionVectorProgram = ctx.device.buildRenderProgram({\n vertex(pb) {\n this.$inputs.pos = pb.vec3().attrib('position');\n this.VPMatrix = pb.mat4().uniform(0);\n this.prevVPMatrix = pb.mat4().uniform(0);\n this.cameraPos = pb.vec3().uniform(0);\n this.prevCameraPos = pb.vec3().uniform(0);\n pb.main(function () {\n this.$l.worldPos = pb.add(this.$inputs.pos, this.cameraPos);\n this.$l.prevWorldPos = pb.add(this.$inputs.pos, this.prevCameraPos);\n this.$l.clipPos = pb.mul(this.VPMatrix, pb.vec4(this.worldPos, 1));\n this.$l.prevClipPos = pb.mul(this.prevVPMatrix, pb.vec4(this.prevWorldPos, 1));\n this.clipPos.z = this.clipPos.w;\n this.$builtins.position = this.clipPos;\n this.$outputs.currentPos = this.clipPos;\n this.$outputs.prevPos = this.prevClipPos;\n });\n },\n fragment(pb) {\n this.$outputs.color = pb.vec4();\n pb.main(function () {\n this.$l.motionVector = pb.mul(\n pb.sub(\n pb.div(this.$inputs.currentPos.xy, this.$inputs.currentPos.w),\n pb.div(this.$inputs.prevPos.xy, this.$inputs.prevPos.w)\n ),\n 0.5\n );\n this.$outputs.color = pb.vec4(this.motionVector, 0, 1);\n });\n }\n })!;\n _skyMotionVectorProgram.name = '@TAA_SkyMotionVector';\n }\n return _skyMotionVectorProgram;\n}\n\nfunction getBox(): Primitive {\n if (!_box) {\n _box = new BoxShape({ size: 2, needNormal: false, needUV: false });\n }\n return _box;\n}\n\n/**\n * Renders sky motion vectors into ctx.motionVectorTexture.\n * Must be called after opaque pass with ctx.motionVectorTexture set.\n * @internal\n */\nexport function renderSkyMotionVectors(ctx: DrawContext): void {\n if (!ctx.motionVectorTexture) {\n return;\n }\n const fb = ctx.device.pool.fetchTemporalFramebuffer(false, 0, 0, ctx.motionVectorTexture, ctx.depthTexture);\n const program = getSkyMotionVectorProgram(ctx);\n if (!_skyMotionVectorBindGroup) {\n _skyMotionVectorBindGroup = ctx.device.createBindGroup(program.bindGroupLayouts[0]);\n }\n const box = getBox();\n _skyMotionVectorBindGroup.setValue('VPMatrix', ctx.camera.viewProjectionMatrix);\n _skyMotionVectorBindGroup.setValue('prevVPMatrix', ctx.camera.prevVPMatrix!);\n _skyMotionVectorBindGroup.setValue('cameraPos', ctx.camera.getWorldPosition());\n _skyMotionVectorBindGroup.setValue('prevCameraPos', ctx.camera.prevPosition!);\n ctx.device.pushDeviceStates();\n ctx.device.setProgram(program);\n ctx.device.setBindGroup(0, _skyMotionVectorBindGroup);\n ctx.device.setRenderStates(AbstractPostEffect.getDefaultRenderState(ctx, 'le'));\n ctx.device.setFramebuffer(fb);\n box.draw();\n ctx.device.popDeviceStates();\n ctx.device.pool.releaseFrameBuffer(fb);\n}\n"],"names":["_skyMotionVectorProgram","_skyMotionVectorBindGroup","_box","getSkyMotionVectorProgram","ctx","device","buildRenderProgram","vertex","pb","$inputs","pos","vec3","attrib","VPMatrix","mat4","uniform","prevVPMatrix","cameraPos","prevCameraPos","main","$l","worldPos","add","prevWorldPos","clipPos","mul","vec4","prevClipPos","z","w","$builtins","position","$outputs","currentPos","prevPos","fragment","color","motionVector","sub","div","xy","name","getBox","BoxShape","size","needNormal","needUV","renderSkyMotionVectors","motionVectorTexture","fb","pool","fetchTemporalFramebuffer","depthTexture","program","createBindGroup","bindGroupLayouts","box","setValue","camera","viewProjectionMatrix","getWorldPosition","prevPosition","pushDeviceStates","setProgram","setBindGroup","setRenderStates","AbstractPostEffect","getDefaultRenderState","setFramebuffer","draw","popDeviceStates","releaseFrameBuffer"],"mappings":";;;;;;;;;;AAOA,IAAIA,uBAAgD,GAAA,IAAA;AACpD,IAAIC,yBAAiD,GAAA,IAAA;AACrD,IAAIC,IAA4B,GAAA,IAAA;AAEhC,SAASC,0BAA0BC,GAAgB,EAAA;AACjD,IAAA,IAAI,CAACJ,uBAAyB,EAAA;AAC5BA,QAAAA,uBAAAA,GAA0BI,GAAIC,CAAAA,MAAM,CAACC,kBAAkB,CAAC;AACtDC,YAAAA,MAAAA,CAAAA,CAAOC,EAAE,EAAA;gBACP,IAAI,CAACC,OAAO,CAACC,GAAG,GAAGF,EAAGG,CAAAA,IAAI,EAAGC,CAAAA,MAAM,CAAC,UAAA,CAAA;AACpC,gBAAA,IAAI,CAACC,QAAQ,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AAc,CAACnB,EAAAA,CAAAA;AAC1BO,IAAAA,GAAAA,CAAIa,IAAI,EAAA;IACRjE,GAAIC,CAAAA,MAAM,CAACiE,eAAe,EAAA;AAC1BlE,IAAAA,GAAAA,CAAIC,MAAM,CAAC6C,IAAI,CAACqB,kBAAkB,CAACtB,EAAAA,CAAAA;AACrC;;;;"}
@@ -308,10 +308,12 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
308
308
  * @param weight - The weight of the morph target
309
309
  */ setMorphWeight(name, weight) {
310
310
  const index = this._morphInfo?.names?.[name];
311
- if (index !== undefined && index >= 0 && index < this._morphInfo.data[3] && this._morphInfo.data[4 + index] !== weight) {
312
- this._morphInfo.data[4 + index] = weight;
313
- this._morphDirty = true;
314
- this.scene.queueUpdateNode(this);
311
+ if (index !== undefined && index >= 0 && index < this._morphInfo.data[3]) {
312
+ if (this._morphInfo.data[4 + index] !== weight) {
313
+ this._morphInfo.data[4 + index] = weight;
314
+ this._morphDirty = true;
315
+ this.scene.queueUpdateNode(this);
316
+ }
315
317
  } else {
316
318
  console.warn(`Morph target ${name} not found`);
317
319
  }
@@ -371,34 +373,24 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
371
373
  }
372
374
  /** @internal */ updateMorphState() {
373
375
  if (this._morphInfo && this._morphDirty) {
376
+ console.log(`jawOpen: ${this._morphInfo.data[20]}`);
374
377
  this._morphInfo.buffer.get().bufferSubData(4 * 4, this._morphInfo.data, 4, this._morphInfo.data[3]);
375
378
  this._morphDirty = false;
376
379
  }
377
380
  }
378
381
  /** @internal */ updateSkeletonState() {
379
- if (this._skeletonName) {
380
- const skeleton = this.findSkeletonById(this._skeletonName);
381
- if (skeleton?.playing) {
382
- this.setBoneMatrices(skeleton.jointTexture);
383
- skeleton.computeBoundingBox(this._skinnedBoundingInfo, this.invWorldMatrix);
384
- this.setAnimatedBoundingBox(this._skinnedBoundingInfo.boundingBox);
385
- } else if (skeleton) {
386
- const prefab = this.getPrefabNode();
387
- if (prefab) {
388
- skeleton.computeBindPose(prefab);
389
- this.setBoneMatrices(skeleton.jointTexture);
390
- skeleton.computeBoundingBox(this._skinnedBoundingInfo, this.invWorldMatrix);
391
- this.setAnimatedBoundingBox(this._skinnedBoundingInfo.boundingBox);
392
- }
393
- } else {
394
- this.setBoneMatrices(null);
395
- this.setAnimatedBoundingBox(null);
396
- }
397
- this.scene.queueUpdateNode(this);
382
+ const skeleton = this._skeletonName && this.findSkeletonById(this._skeletonName);
383
+ if (skeleton) {
384
+ this.setBoneMatrices(skeleton.jointTexture);
385
+ skeleton.computeBoundingBox(this._skinnedBoundingInfo, this.invWorldMatrix);
386
+ this.setAnimatedBoundingBox(this._skinnedBoundingInfo.boundingBox);
398
387
  } else {
399
388
  this.setBoneMatrices(null);
400
389
  this.setAnimatedBoundingBox(null);
401
390
  }
391
+ if (this._skeletonName) {
392
+ this.scene.queueUpdateNode(this);
393
+ }
402
394
  }
403
395
  /**
404
396
  * {@inheritDoc Drawable.draw}