@zephyr3d/scene 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (723) hide show
  1. package/README.md +1 -1
  2. package/dist/animation/animation.js +149 -27
  3. package/dist/animation/animation.js.map +1 -1
  4. package/dist/animation/animationset.js +173 -73
  5. package/dist/animation/animationset.js.map +1 -1
  6. package/dist/animation/animationtrack.js +65 -10
  7. package/dist/animation/animationtrack.js.map +1 -1
  8. package/dist/animation/eulerrotationtrack.js +41 -20
  9. package/dist/animation/eulerrotationtrack.js.map +1 -1
  10. package/dist/animation/morphtarget.js +14 -38
  11. package/dist/animation/morphtarget.js.map +1 -1
  12. package/dist/animation/morphtrack.js +59 -22
  13. package/dist/animation/morphtrack.js.map +1 -1
  14. package/dist/animation/proptrack.js +190 -0
  15. package/dist/animation/proptrack.js.map +1 -0
  16. package/dist/animation/rotationtrack.js +29 -11
  17. package/dist/animation/rotationtrack.js.map +1 -1
  18. package/dist/animation/scaletrack.js +29 -11
  19. package/dist/animation/scaletrack.js.map +1 -1
  20. package/dist/animation/skeleton.js +241 -78
  21. package/dist/animation/skeleton.js.map +1 -1
  22. package/dist/animation/translationtrack.js +30 -11
  23. package/dist/animation/translationtrack.js.map +1 -1
  24. package/dist/app/api.js +43 -0
  25. package/dist/app/api.js.map +1 -0
  26. package/dist/app/app.js +153 -0
  27. package/dist/app/app.js.map +1 -0
  28. package/dist/app/engine.js +312 -0
  29. package/dist/app/engine.js.map +1 -0
  30. package/dist/app/inputmgr.js +351 -0
  31. package/dist/app/inputmgr.js.map +1 -0
  32. package/dist/app/runtimescript.js +62 -0
  33. package/dist/app/runtimescript.js.map +1 -0
  34. package/dist/app/scriptingsystem.js +220 -0
  35. package/dist/app/scriptingsystem.js.map +1 -0
  36. package/dist/app/scriptregistry.js +432 -0
  37. package/dist/app/scriptregistry.js.map +1 -0
  38. package/dist/asset/assetmanager.js +772 -291
  39. package/dist/asset/assetmanager.js.map +1 -1
  40. package/dist/asset/builtin.js +7 -43
  41. package/dist/asset/builtin.js.map +1 -1
  42. package/dist/asset/loaders/dds/dds.js +17 -93
  43. package/dist/asset/loaders/dds/dds.js.map +1 -1
  44. package/dist/asset/loaders/dds/dds_loader.js +8 -18
  45. package/dist/asset/loaders/dds/dds_loader.js.map +1 -1
  46. package/dist/asset/loaders/gltf/gltf_loader.js +36 -42
  47. package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
  48. package/dist/asset/loaders/gltf/helpers.js +27 -14
  49. package/dist/asset/loaders/gltf/helpers.js.map +1 -1
  50. package/dist/asset/loaders/hdr/hdr.js +17 -12
  51. package/dist/asset/loaders/hdr/hdr.js.map +1 -1
  52. package/dist/asset/loaders/image/tga_Loader.js +13 -16
  53. package/dist/asset/loaders/image/tga_Loader.js.map +1 -1
  54. package/dist/asset/loaders/image/webimage_loader.js +51 -50
  55. package/dist/asset/loaders/image/webimage_loader.js.map +1 -1
  56. package/dist/asset/loaders/loader.js.map +1 -1
  57. package/dist/asset/model.js +158 -4
  58. package/dist/asset/model.js.map +1 -1
  59. package/dist/blitter/bilateralblur.js +0 -1
  60. package/dist/blitter/bilateralblur.js.map +1 -1
  61. package/dist/blitter/blitter.js +22 -23
  62. package/dist/blitter/blitter.js.map +1 -1
  63. package/dist/blitter/box.js.map +1 -1
  64. package/dist/blitter/copy.js.map +1 -1
  65. package/dist/blitter/gaussianblur.js +23 -23
  66. package/dist/blitter/gaussianblur.js.map +1 -1
  67. package/dist/camera/base.js +141 -34
  68. package/dist/camera/base.js.map +1 -1
  69. package/dist/camera/camera.js +653 -149
  70. package/dist/camera/camera.js.map +1 -1
  71. package/dist/camera/fps.js +2 -10
  72. package/dist/camera/fps.js.map +1 -1
  73. package/dist/camera/orbit.js +132 -59
  74. package/dist/camera/orbit.js.map +1 -1
  75. package/dist/camera/orthocamera.js +37 -12
  76. package/dist/camera/orthocamera.js.map +1 -1
  77. package/dist/camera/perspectivecamera.js +37 -20
  78. package/dist/camera/perspectivecamera.js.map +1 -1
  79. package/dist/index.d.ts +18268 -6982
  80. package/dist/index.js +49 -16
  81. package/dist/index.js.map +1 -1
  82. package/dist/material/blinn.js +5 -0
  83. package/dist/material/blinn.js.map +1 -1
  84. package/dist/material/grassmaterial.js +6 -1
  85. package/dist/material/grassmaterial.js.map +1 -1
  86. package/dist/material/lambert.js +6 -1
  87. package/dist/material/lambert.js.map +1 -1
  88. package/dist/material/material.js +346 -73
  89. package/dist/material/material.js.map +1 -1
  90. package/dist/material/meshmaterial.js +498 -156
  91. package/dist/material/meshmaterial.js.map +1 -1
  92. package/dist/material/mixins/albedocolor.js +5 -1
  93. package/dist/material/mixins/albedocolor.js.map +1 -1
  94. package/dist/material/mixins/foliage.js +3 -3
  95. package/dist/material/mixins/foliage.js.map +1 -1
  96. package/dist/material/mixins/lightmodel/blinnphong.js +18 -5
  97. package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
  98. package/dist/material/mixins/lightmodel/lambert.js +6 -6
  99. package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
  100. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +235 -0
  101. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -0
  102. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +52 -15
  103. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  104. package/dist/material/mixins/lightmodel/pbrspecularglossness.js +27 -9
  105. package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
  106. package/dist/material/mixins/lit.js +16 -4
  107. package/dist/material/mixins/lit.js.map +1 -1
  108. package/dist/material/mixins/pbr/brdf.js +134 -0
  109. package/dist/material/mixins/pbr/brdf.js.map +1 -0
  110. package/dist/material/mixins/pbr/common.js +68 -85
  111. package/dist/material/mixins/pbr/common.js.map +1 -1
  112. package/dist/material/mixins/texture.js +98 -83
  113. package/dist/material/mixins/texture.js.map +1 -1
  114. package/dist/material/mixins/vertexcolor.js +6 -2
  115. package/dist/material/mixins/vertexcolor.js.map +1 -1
  116. package/dist/material/particle.js +272 -0
  117. package/dist/material/particle.js.map +1 -0
  118. package/dist/material/pbrblueprint.js +186 -0
  119. package/dist/material/pbrblueprint.js.map +1 -0
  120. package/dist/material/pbrmr.js +10 -0
  121. package/dist/material/pbrmr.js.map +1 -1
  122. package/dist/material/pbrsg.js +10 -0
  123. package/dist/material/pbrsg.js.map +1 -1
  124. package/dist/material/shader/helper.js +521 -287
  125. package/dist/material/shader/helper.js.map +1 -1
  126. package/dist/material/terrain-cm.js +607 -0
  127. package/dist/material/terrain-cm.js.map +1 -0
  128. package/dist/material/terrainmaterial.js +59 -54
  129. package/dist/material/terrainmaterial.js.map +1 -1
  130. package/dist/material/unlit.js +5 -0
  131. package/dist/material/unlit.js.map +1 -1
  132. package/dist/material/water.js +415 -0
  133. package/dist/material/water.js.map +1 -0
  134. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +38 -0
  135. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +1 -0
  136. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +10 -0
  137. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +1 -0
  138. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +127 -0
  139. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +1 -0
  140. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +263 -0
  141. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +1 -0
  142. package/dist/node_modules/es-module-lexer/dist/lexer.js +5 -0
  143. package/dist/node_modules/es-module-lexer/dist/lexer.js.map +1 -0
  144. package/dist/posteffect/bloom.js +39 -54
  145. package/dist/posteffect/bloom.js.map +1 -1
  146. package/dist/posteffect/compositor.js +95 -128
  147. package/dist/posteffect/compositor.js.map +1 -1
  148. package/dist/posteffect/fxaa.js +10 -18
  149. package/dist/posteffect/fxaa.js.map +1 -1
  150. package/dist/posteffect/grayscale.js +9 -17
  151. package/dist/posteffect/grayscale.js.map +1 -1
  152. package/dist/posteffect/motionblur.js +105 -0
  153. package/dist/posteffect/motionblur.js.map +1 -0
  154. package/dist/posteffect/posteffect.js +66 -35
  155. package/dist/posteffect/posteffect.js.map +1 -1
  156. package/dist/posteffect/sao.js +13 -21
  157. package/dist/posteffect/sao.js.map +1 -1
  158. package/dist/posteffect/ssr.js +60 -100
  159. package/dist/posteffect/ssr.js.map +1 -1
  160. package/dist/posteffect/taa.js +175 -0
  161. package/dist/posteffect/taa.js.map +1 -0
  162. package/dist/posteffect/tonemap.js +12 -20
  163. package/dist/posteffect/tonemap.js.map +1 -1
  164. package/dist/render/abuffer_oit.js +30 -19
  165. package/dist/render/abuffer_oit.js.map +1 -1
  166. package/dist/render/clipmap.js +429 -101
  167. package/dist/render/clipmap.js.map +1 -1
  168. package/dist/render/cluster_light.js +7 -5
  169. package/dist/render/cluster_light.js.map +1 -1
  170. package/dist/render/cull_visitor.js +43 -3
  171. package/dist/render/cull_visitor.js.map +1 -1
  172. package/dist/render/depthpass.js +14 -5
  173. package/dist/render/depthpass.js.map +1 -1
  174. package/dist/render/drawable_mixin.js +113 -40
  175. package/dist/render/drawable_mixin.js.map +1 -1
  176. package/dist/render/envlight.js +86 -141
  177. package/dist/render/envlight.js.map +1 -1
  178. package/dist/render/fbm_wavegenerator.js +234 -0
  179. package/dist/render/fbm_wavegenerator.js.map +1 -0
  180. package/dist/render/fft_wavegenerator.js +64 -50
  181. package/dist/render/fft_wavegenerator.js.map +1 -1
  182. package/dist/render/fullscreenquad.js +2 -2
  183. package/dist/render/fullscreenquad.js.map +1 -1
  184. package/dist/render/gerstner_wavegenerator.js +98 -48
  185. package/dist/render/gerstner_wavegenerator.js.map +1 -1
  186. package/dist/render/globalbindgroup_allocator.js +4 -2
  187. package/dist/render/globalbindgroup_allocator.js.map +1 -1
  188. package/dist/render/hzb.js +6 -3
  189. package/dist/render/hzb.js.map +1 -1
  190. package/dist/render/lightpass.js +19 -18
  191. package/dist/render/lightpass.js.map +1 -1
  192. package/dist/render/objectcolorpass.js +4 -4
  193. package/dist/render/objectcolorpass.js.map +1 -1
  194. package/dist/render/primitive.js +213 -104
  195. package/dist/render/primitive.js.map +1 -1
  196. package/dist/render/render_queue.js +40 -20
  197. package/dist/render/render_queue.js.map +1 -1
  198. package/dist/render/renderbundle_wrapper.js +65 -15
  199. package/dist/render/renderbundle_wrapper.js.map +1 -1
  200. package/dist/render/renderer.js +326 -185
  201. package/dist/render/renderer.js.map +1 -1
  202. package/dist/render/renderpass.js +20 -36
  203. package/dist/render/renderpass.js.map +1 -1
  204. package/dist/render/shadowmap_pass.js +3 -3
  205. package/dist/render/shadowmap_pass.js.map +1 -1
  206. package/dist/render/sky.js +864 -541
  207. package/dist/render/sky.js.map +1 -1
  208. package/dist/render/weightedblended_oit.js +13 -15
  209. package/dist/render/weightedblended_oit.js.map +1 -1
  210. package/dist/scene/batchgroup.js +18 -5
  211. package/dist/scene/batchgroup.js.map +1 -1
  212. package/dist/scene/environment.js +78 -48
  213. package/dist/scene/environment.js.map +1 -1
  214. package/dist/scene/graph_node.js +2 -3
  215. package/dist/scene/graph_node.js.map +1 -1
  216. package/dist/scene/light.js +28 -89
  217. package/dist/scene/light.js.map +1 -1
  218. package/dist/scene/mesh.js +218 -87
  219. package/dist/scene/mesh.js.map +1 -1
  220. package/dist/scene/octree.js +371 -162
  221. package/dist/scene/octree.js.map +1 -1
  222. package/dist/scene/particlesys.js +684 -0
  223. package/dist/scene/particlesys.js.map +1 -0
  224. package/dist/scene/raycast_visitor.js +34 -5
  225. package/dist/scene/raycast_visitor.js.map +1 -1
  226. package/dist/scene/scene.js +309 -85
  227. package/dist/scene/scene.js.map +1 -1
  228. package/dist/scene/scene_node.js +675 -102
  229. package/dist/scene/scene_node.js.map +1 -1
  230. package/dist/scene/terrain/grass.js +48 -49
  231. package/dist/scene/terrain/grass.js.map +1 -1
  232. package/dist/scene/terrain/heightfield.js +46 -44
  233. package/dist/scene/terrain/heightfield.js.map +1 -1
  234. package/dist/scene/terrain/patch.js +20 -29
  235. package/dist/scene/terrain/patch.js.map +1 -1
  236. package/dist/scene/terrain/quadtree.js +58 -27
  237. package/dist/scene/terrain/quadtree.js.map +1 -1
  238. package/dist/scene/terrain/terrain.js +31 -45
  239. package/dist/scene/terrain/terrain.js.map +1 -1
  240. package/dist/scene/terrain-cm/grass.js +603 -0
  241. package/dist/scene/terrain-cm/grass.js.map +1 -0
  242. package/dist/scene/terrain-cm/grassmaterial.js +160 -0
  243. package/dist/scene/terrain-cm/grassmaterial.js.map +1 -0
  244. package/dist/scene/terrain-cm/terrain-cm.js +533 -0
  245. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -0
  246. package/dist/scene/water.js +378 -0
  247. package/dist/scene/water.js.map +1 -0
  248. package/dist/shaders/atmosphere.js +957 -0
  249. package/dist/shaders/atmosphere.js.map +1 -0
  250. package/dist/shaders/fog.js +116 -0
  251. package/dist/shaders/fog.js.map +1 -0
  252. package/dist/shaders/misc.js.map +1 -1
  253. package/dist/shaders/noise.js +217 -8
  254. package/dist/shaders/noise.js.map +1 -1
  255. package/dist/shaders/pbr.js.map +1 -1
  256. package/dist/shaders/shadow.js +8 -8
  257. package/dist/shaders/shadow.js.map +1 -1
  258. package/dist/shaders/ssr.js +87 -39
  259. package/dist/shaders/ssr.js.map +1 -1
  260. package/dist/shaders/temporal.js +216 -0
  261. package/dist/shaders/temporal.js.map +1 -0
  262. package/dist/shaders/water.js +42 -20
  263. package/dist/shaders/water.js.map +1 -1
  264. package/dist/shadow/esm.js +31 -13
  265. package/dist/shadow/esm.js.map +1 -1
  266. package/dist/shadow/pcf_opt.js +12 -13
  267. package/dist/shadow/pcf_opt.js.map +1 -1
  268. package/dist/shadow/pcf_pd.js +12 -13
  269. package/dist/shadow/pcf_pd.js.map +1 -1
  270. package/dist/shadow/shader.js +38 -0
  271. package/dist/shadow/shader.js.map +1 -0
  272. package/dist/shadow/shadow_impl.js.map +1 -1
  273. package/dist/shadow/shadowmapper.js +67 -26
  274. package/dist/shadow/shadowmapper.js.map +1 -1
  275. package/dist/shadow/ssm.js +15 -16
  276. package/dist/shadow/ssm.js.map +1 -1
  277. package/dist/shadow/vsm.js +33 -16
  278. package/dist/shadow/vsm.js.map +1 -1
  279. package/dist/shapes/box.js +181 -83
  280. package/dist/shapes/box.js.map +1 -1
  281. package/dist/shapes/cylinder.js +101 -43
  282. package/dist/shapes/cylinder.js.map +1 -1
  283. package/dist/shapes/plane.js +70 -29
  284. package/dist/shapes/plane.js.map +1 -1
  285. package/dist/shapes/shape.js +120 -17
  286. package/dist/shapes/shape.js.map +1 -1
  287. package/dist/shapes/sphere.js +78 -44
  288. package/dist/shapes/sphere.js.map +1 -1
  289. package/dist/shapes/tetrahedron.js +256 -0
  290. package/dist/shapes/tetrahedron.js.map +1 -0
  291. package/dist/shapes/torus.js +76 -55
  292. package/dist/shapes/torus.js.map +1 -1
  293. package/dist/src/animation/animation.js +127 -0
  294. package/dist/src/animation/animation.js.map +1 -0
  295. package/dist/src/animation/animationset.js +255 -0
  296. package/dist/src/animation/animationset.js.map +1 -0
  297. package/dist/src/animation/animationtrack.js +34 -0
  298. package/dist/src/animation/animationtrack.js.map +1 -0
  299. package/dist/src/animation/eulerrotationtrack.js +52 -0
  300. package/dist/src/animation/eulerrotationtrack.js.map +1 -0
  301. package/dist/src/animation/morphtarget.js +93 -0
  302. package/dist/src/animation/morphtarget.js.map +1 -0
  303. package/dist/src/animation/morphtrack.js +70 -0
  304. package/dist/src/animation/morphtrack.js.map +1 -0
  305. package/dist/src/animation/proptrack.js +161 -0
  306. package/dist/src/animation/proptrack.js.map +1 -0
  307. package/dist/src/animation/rotationtrack.js +51 -0
  308. package/dist/src/animation/rotationtrack.js.map +1 -0
  309. package/dist/src/animation/scaletrack.js +50 -0
  310. package/dist/src/animation/scaletrack.js.map +1 -0
  311. package/dist/src/animation/skeleton.js +204 -0
  312. package/dist/src/animation/skeleton.js.map +1 -0
  313. package/dist/src/animation/translationtrack.js +50 -0
  314. package/dist/src/animation/translationtrack.js.map +1 -0
  315. package/dist/{app.js → src/app/app.js} +18 -40
  316. package/dist/src/app/app.js.map +1 -0
  317. package/dist/{input → src/app}/inputmgr.js +41 -16
  318. package/dist/src/app/inputmgr.js.map +1 -0
  319. package/dist/src/asset/assetmanager.js +404 -0
  320. package/dist/src/asset/assetmanager.js.map +1 -0
  321. package/dist/src/asset/builtin.js +337 -0
  322. package/dist/src/asset/builtin.js.map +1 -0
  323. package/dist/src/asset/loaders/dds/dds.js +470 -0
  324. package/dist/src/asset/loaders/dds/dds.js.map +1 -0
  325. package/dist/src/asset/loaders/dds/dds_loader.js +28 -0
  326. package/dist/src/asset/loaders/dds/dds_loader.js.map +1 -0
  327. package/dist/src/asset/loaders/gltf/gltf_loader.js +1265 -0
  328. package/dist/src/asset/loaders/gltf/gltf_loader.js.map +1 -0
  329. package/dist/src/asset/loaders/gltf/helpers.js +327 -0
  330. package/dist/src/asset/loaders/gltf/helpers.js.map +1 -0
  331. package/dist/src/asset/loaders/hdr/hdr.js +180 -0
  332. package/dist/src/asset/loaders/hdr/hdr.js.map +1 -0
  333. package/dist/src/asset/loaders/image/tga_Loader.js +116 -0
  334. package/dist/src/asset/loaders/image/tga_Loader.js.map +1 -0
  335. package/dist/src/asset/loaders/image/webimage_loader.js +63 -0
  336. package/dist/src/asset/loaders/image/webimage_loader.js.map +1 -0
  337. package/dist/src/asset/loaders/loader.js +45 -0
  338. package/dist/src/asset/loaders/loader.js.map +1 -0
  339. package/dist/src/asset/model.js +414 -0
  340. package/dist/src/asset/model.js.map +1 -0
  341. package/dist/{blitter/depthlimitedgaussion.js → src/blitter/bilateralblur.js} +1 -2
  342. package/dist/src/blitter/bilateralblur.js.map +1 -0
  343. package/dist/src/blitter/blitter.js +390 -0
  344. package/dist/src/blitter/blitter.js.map +1 -0
  345. package/dist/src/blitter/box.js +118 -0
  346. package/dist/src/blitter/box.js.map +1 -0
  347. package/dist/src/blitter/copy.js +22 -0
  348. package/dist/src/blitter/copy.js.map +1 -0
  349. package/dist/src/blitter/gaussianblur.js +228 -0
  350. package/dist/src/blitter/gaussianblur.js.map +1 -0
  351. package/dist/src/camera/base.js +92 -0
  352. package/dist/src/camera/base.js.map +1 -0
  353. package/dist/src/camera/camera.js +1005 -0
  354. package/dist/src/camera/camera.js.map +1 -0
  355. package/dist/src/camera/fps.js +238 -0
  356. package/dist/src/camera/fps.js.map +1 -0
  357. package/dist/src/camera/orbit.js +245 -0
  358. package/dist/src/camera/orbit.js.map +1 -0
  359. package/dist/src/camera/orthocamera.js +167 -0
  360. package/dist/src/camera/orthocamera.js.map +1 -0
  361. package/dist/src/camera/perspectivecamera.js +141 -0
  362. package/dist/src/camera/perspectivecamera.js.map +1 -0
  363. package/dist/src/index.js +120 -0
  364. package/dist/src/index.js.map +1 -0
  365. package/dist/src/material/blinn.js +81 -0
  366. package/dist/src/material/blinn.js.map +1 -0
  367. package/dist/src/material/grassmaterial.js +113 -0
  368. package/dist/src/material/grassmaterial.js.map +1 -0
  369. package/dist/src/material/lambert.js +92 -0
  370. package/dist/src/material/lambert.js.map +1 -0
  371. package/dist/src/material/material.js +301 -0
  372. package/dist/src/material/material.js.map +1 -0
  373. package/dist/src/material/meshmaterial.js +704 -0
  374. package/dist/src/material/meshmaterial.js.map +1 -0
  375. package/dist/src/material/mixins/albedocolor.js +76 -0
  376. package/dist/src/material/mixins/albedocolor.js.map +1 -0
  377. package/dist/src/material/mixins/foliage.js +47 -0
  378. package/dist/src/material/mixins/foliage.js.map +1 -0
  379. package/dist/src/material/mixins/lightmodel/blinnphong.js +112 -0
  380. package/dist/src/material/mixins/lightmodel/blinnphong.js.map +1 -0
  381. package/dist/src/material/mixins/lightmodel/lambert.js +58 -0
  382. package/dist/src/material/mixins/lightmodel/lambert.js.map +1 -0
  383. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +178 -0
  384. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -0
  385. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +139 -0
  386. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -0
  387. package/dist/src/material/mixins/lit.js +476 -0
  388. package/dist/src/material/mixins/lit.js.map +1 -0
  389. package/dist/src/material/mixins/pbr/common.js +918 -0
  390. package/dist/src/material/mixins/pbr/common.js.map +1 -0
  391. package/dist/src/material/mixins/texture.js +172 -0
  392. package/dist/src/material/mixins/texture.js.map +1 -0
  393. package/dist/src/material/mixins/vertexcolor.js +56 -0
  394. package/dist/src/material/mixins/vertexcolor.js.map +1 -0
  395. package/dist/src/material/particle.js +178 -0
  396. package/dist/src/material/particle.js.map +1 -0
  397. package/dist/src/material/pbrmr.js +97 -0
  398. package/dist/src/material/pbrmr.js.map +1 -0
  399. package/dist/src/material/pbrsg.js +97 -0
  400. package/dist/src/material/pbrsg.js.map +1 -0
  401. package/dist/src/material/shader/helper.js +1209 -0
  402. package/dist/src/material/shader/helper.js.map +1 -0
  403. package/dist/src/material/terrain-cm.js +606 -0
  404. package/dist/src/material/terrain-cm.js.map +1 -0
  405. package/dist/src/material/terrainmaterial.js +375 -0
  406. package/dist/src/material/terrainmaterial.js.map +1 -0
  407. package/dist/src/material/unlit.js +41 -0
  408. package/dist/src/material/unlit.js.map +1 -0
  409. package/dist/src/material/water.js +417 -0
  410. package/dist/src/material/water.js.map +1 -0
  411. package/dist/src/posteffect/bloom.js +361 -0
  412. package/dist/src/posteffect/bloom.js.map +1 -0
  413. package/dist/src/posteffect/compositor.js +226 -0
  414. package/dist/src/posteffect/compositor.js.map +1 -0
  415. package/dist/src/posteffect/fxaa.js +273 -0
  416. package/dist/src/posteffect/fxaa.js.map +1 -0
  417. package/dist/src/posteffect/grayscale.js +69 -0
  418. package/dist/src/posteffect/grayscale.js.map +1 -0
  419. package/dist/src/posteffect/motionblur.js +96 -0
  420. package/dist/src/posteffect/motionblur.js.map +1 -0
  421. package/dist/src/posteffect/posteffect.js +126 -0
  422. package/dist/src/posteffect/posteffect.js.map +1 -0
  423. package/dist/src/posteffect/sao.js +324 -0
  424. package/dist/src/posteffect/sao.js.map +1 -0
  425. package/dist/src/posteffect/ssr.js +489 -0
  426. package/dist/src/posteffect/ssr.js.map +1 -0
  427. package/dist/src/posteffect/taa.js +172 -0
  428. package/dist/src/posteffect/taa.js.map +1 -0
  429. package/dist/src/posteffect/tonemap.js +94 -0
  430. package/dist/src/posteffect/tonemap.js.map +1 -0
  431. package/dist/src/render/abuffer_oit.js +361 -0
  432. package/dist/src/render/abuffer_oit.js.map +1 -0
  433. package/dist/src/render/clipmap.js +851 -0
  434. package/dist/src/render/clipmap.js.map +1 -0
  435. package/dist/src/render/cluster_light.js +333 -0
  436. package/dist/src/render/cluster_light.js.map +1 -0
  437. package/dist/src/render/cull_visitor.js +187 -0
  438. package/dist/src/render/cull_visitor.js.map +1 -0
  439. package/dist/src/render/depthpass.js +68 -0
  440. package/dist/src/render/depthpass.js.map +1 -0
  441. package/dist/src/render/drawable_mixin.js +227 -0
  442. package/dist/src/render/drawable_mixin.js.map +1 -0
  443. package/dist/src/render/envlight.js +463 -0
  444. package/dist/src/render/envlight.js.map +1 -0
  445. package/dist/src/render/fbm_wavegenerator.js +251 -0
  446. package/dist/src/render/fbm_wavegenerator.js.map +1 -0
  447. package/dist/src/render/fft_wavegenerator.js +1006 -0
  448. package/dist/src/render/fft_wavegenerator.js.map +1 -0
  449. package/dist/src/render/fullscreenquad.js +38 -0
  450. package/dist/src/render/fullscreenquad.js.map +1 -0
  451. package/dist/src/render/gerstner_wavegenerator.js +314 -0
  452. package/dist/src/render/gerstner_wavegenerator.js.map +1 -0
  453. package/dist/src/render/globalbindgroup_allocator.js +60 -0
  454. package/dist/src/render/globalbindgroup_allocator.js.map +1 -0
  455. package/dist/src/render/hzb.js +273 -0
  456. package/dist/src/render/hzb.js.map +1 -0
  457. package/dist/src/render/lightpass.js +172 -0
  458. package/dist/src/render/lightpass.js.map +1 -0
  459. package/dist/src/render/objectcolorpass.js +51 -0
  460. package/dist/src/render/objectcolorpass.js.map +1 -0
  461. package/dist/src/render/primitive.js +364 -0
  462. package/dist/src/render/primitive.js.map +1 -0
  463. package/dist/src/render/render_queue.js +467 -0
  464. package/dist/src/render/render_queue.js.map +1 -0
  465. package/dist/src/render/renderbundle_wrapper.js +152 -0
  466. package/dist/src/render/renderbundle_wrapper.js.map +1 -0
  467. package/dist/src/render/renderer.js +455 -0
  468. package/dist/src/render/renderer.js.map +1 -0
  469. package/dist/src/render/renderpass.js +200 -0
  470. package/dist/src/render/renderpass.js.map +1 -0
  471. package/dist/src/render/shadowmap_pass.js +56 -0
  472. package/dist/src/render/shadowmap_pass.js.map +1 -0
  473. package/dist/src/render/sky.js +1103 -0
  474. package/dist/src/render/sky.js.map +1 -0
  475. package/dist/src/render/weightedblended_oit.js +168 -0
  476. package/dist/src/render/weightedblended_oit.js.map +1 -0
  477. package/dist/src/scene/batchgroup.js +162 -0
  478. package/dist/src/scene/batchgroup.js.map +1 -0
  479. package/dist/src/scene/environment.js +209 -0
  480. package/dist/src/scene/environment.js.map +1 -0
  481. package/dist/src/scene/graph_node.js +72 -0
  482. package/dist/src/scene/graph_node.js.map +1 -0
  483. package/dist/src/scene/light.js +416 -0
  484. package/dist/src/scene/light.js.map +1 -0
  485. package/dist/src/scene/mesh.js +341 -0
  486. package/dist/src/scene/mesh.js.map +1 -0
  487. package/dist/src/scene/octree.js +649 -0
  488. package/dist/src/scene/octree.js.map +1 -0
  489. package/dist/src/scene/particlesys.js +738 -0
  490. package/dist/src/scene/particlesys.js.map +1 -0
  491. package/dist/src/scene/raycast_visitor.js +103 -0
  492. package/dist/src/scene/raycast_visitor.js.map +1 -0
  493. package/dist/src/scene/scene.js +284 -0
  494. package/dist/src/scene/scene.js.map +1 -0
  495. package/dist/src/scene/scene_node.js +732 -0
  496. package/dist/src/scene/scene_node.js.map +1 -0
  497. package/dist/src/scene/terrain/grass.js +278 -0
  498. package/dist/src/scene/terrain/grass.js.map +1 -0
  499. package/dist/src/scene/terrain/heightfield.js +475 -0
  500. package/dist/src/scene/terrain/heightfield.js.map +1 -0
  501. package/dist/src/scene/terrain/patch.js +530 -0
  502. package/dist/src/scene/terrain/patch.js.map +1 -0
  503. package/dist/src/scene/terrain/quadtree.js +461 -0
  504. package/dist/src/scene/terrain/quadtree.js.map +1 -0
  505. package/dist/src/scene/terrain/terrain.js +246 -0
  506. package/dist/src/scene/terrain/terrain.js.map +1 -0
  507. package/dist/src/scene/terrain-cm/grass.js +594 -0
  508. package/dist/src/scene/terrain-cm/grass.js.map +1 -0
  509. package/dist/src/scene/terrain-cm/grassmaterial.js +159 -0
  510. package/dist/src/scene/terrain-cm/grassmaterial.js.map +1 -0
  511. package/dist/src/scene/terrain-cm/terrain-cm.js +538 -0
  512. package/dist/src/scene/terrain-cm/terrain-cm.js.map +1 -0
  513. package/dist/src/scene/water.js +374 -0
  514. package/dist/src/scene/water.js.map +1 -0
  515. package/dist/src/shaders/atmosphere.js +957 -0
  516. package/dist/src/shaders/atmosphere.js.map +1 -0
  517. package/dist/src/shaders/fog.js +112 -0
  518. package/dist/src/shaders/fog.js.map +1 -0
  519. package/dist/src/shaders/misc.js +266 -0
  520. package/dist/src/shaders/misc.js.map +1 -0
  521. package/dist/src/shaders/noise.js +222 -0
  522. package/dist/src/shaders/noise.js.map +1 -0
  523. package/dist/src/shaders/pbr.js +51 -0
  524. package/dist/src/shaders/pbr.js.map +1 -0
  525. package/dist/src/shaders/shadow.js +636 -0
  526. package/dist/src/shaders/shadow.js.map +1 -0
  527. package/dist/src/shaders/ssr.js +490 -0
  528. package/dist/src/shaders/ssr.js.map +1 -0
  529. package/dist/src/shaders/temporal.js +215 -0
  530. package/dist/src/shaders/temporal.js.map +1 -0
  531. package/dist/src/shaders/water.js +756 -0
  532. package/dist/src/shaders/water.js.map +1 -0
  533. package/dist/src/shadow/esm.js +237 -0
  534. package/dist/src/shadow/esm.js.map +1 -0
  535. package/dist/src/shadow/pcf_opt.js +181 -0
  536. package/dist/src/shadow/pcf_opt.js.map +1 -0
  537. package/dist/src/shadow/pcf_pd.js +189 -0
  538. package/dist/src/shadow/pcf_pd.js.map +1 -0
  539. package/dist/src/shadow/shader.js +37 -0
  540. package/dist/src/shadow/shader.js.map +1 -0
  541. package/dist/src/shadow/shadow_impl.js +15 -0
  542. package/dist/src/shadow/shadow_impl.js.map +1 -0
  543. package/dist/src/shadow/shadowmapper.js +790 -0
  544. package/dist/src/shadow/shadowmapper.js.map +1 -0
  545. package/dist/src/shadow/ssm.js +159 -0
  546. package/dist/src/shadow/ssm.js.map +1 -0
  547. package/dist/src/shadow/vsm.js +297 -0
  548. package/dist/src/shadow/vsm.js.map +1 -0
  549. package/dist/src/shapes/box.js +386 -0
  550. package/dist/src/shapes/box.js.map +1 -0
  551. package/dist/src/shapes/cylinder.js +125 -0
  552. package/dist/src/shapes/cylinder.js.map +1 -0
  553. package/dist/src/shapes/plane.js +88 -0
  554. package/dist/src/shapes/plane.js.map +1 -0
  555. package/dist/src/shapes/shape.js +87 -0
  556. package/dist/src/shapes/shape.js.map +1 -0
  557. package/dist/src/shapes/sphere.js +114 -0
  558. package/dist/src/shapes/sphere.js.map +1 -0
  559. package/dist/src/shapes/tetrahedron.js +188 -0
  560. package/dist/src/shapes/tetrahedron.js.map +1 -0
  561. package/dist/src/shapes/torus.js +111 -0
  562. package/dist/src/shapes/torus.js.map +1 -0
  563. package/dist/src/utility/aabbtree.js +400 -0
  564. package/dist/src/utility/aabbtree.js.map +1 -0
  565. package/dist/src/utility/bounding_volume.js +29 -0
  566. package/dist/src/utility/bounding_volume.js.map +1 -0
  567. package/dist/src/utility/debug.js +28 -0
  568. package/dist/src/utility/debug.js.map +1 -0
  569. package/dist/src/utility/draco/decoder.js +116 -0
  570. package/dist/src/utility/draco/decoder.js.map +1 -0
  571. package/dist/src/utility/misc.js +105 -0
  572. package/dist/src/utility/misc.js.map +1 -0
  573. package/dist/src/utility/panorama.js +163 -0
  574. package/dist/src/utility/panorama.js.map +1 -0
  575. package/dist/src/utility/pmrem.js +354 -0
  576. package/dist/src/utility/pmrem.js.map +1 -0
  577. package/dist/src/utility/rendermipmap.js +115 -0
  578. package/dist/src/utility/rendermipmap.js.map +1 -0
  579. package/dist/src/utility/serialization/json.js +402 -0
  580. package/dist/src/utility/serialization/json.js.map +1 -0
  581. package/dist/src/utility/serialization/manager.js +623 -0
  582. package/dist/src/utility/serialization/manager.js.map +1 -0
  583. package/dist/src/utility/serialization/scene/animation.js +248 -0
  584. package/dist/src/utility/serialization/scene/animation.js.map +1 -0
  585. package/dist/src/utility/serialization/scene/batch.js +59 -0
  586. package/dist/src/utility/serialization/scene/batch.js.map +1 -0
  587. package/dist/src/utility/serialization/scene/camera.js +790 -0
  588. package/dist/src/utility/serialization/scene/camera.js.map +1 -0
  589. package/dist/src/utility/serialization/scene/common.js +222 -0
  590. package/dist/src/utility/serialization/scene/common.js.map +1 -0
  591. package/dist/src/utility/serialization/scene/light.js +575 -0
  592. package/dist/src/utility/serialization/scene/light.js.map +1 -0
  593. package/dist/src/utility/serialization/scene/material.js +1111 -0
  594. package/dist/src/utility/serialization/scene/material.js.map +1 -0
  595. package/dist/src/utility/serialization/scene/mesh.js +148 -0
  596. package/dist/src/utility/serialization/scene/mesh.js.map +1 -0
  597. package/dist/src/utility/serialization/scene/misc.js +39 -0
  598. package/dist/src/utility/serialization/scene/misc.js.map +1 -0
  599. package/dist/src/utility/serialization/scene/node.js +451 -0
  600. package/dist/src/utility/serialization/scene/node.js.map +1 -0
  601. package/dist/src/utility/serialization/scene/particle.js +425 -0
  602. package/dist/src/utility/serialization/scene/particle.js.map +1 -0
  603. package/dist/src/utility/serialization/scene/primitive.js +692 -0
  604. package/dist/src/utility/serialization/scene/primitive.js.map +1 -0
  605. package/dist/src/utility/serialization/scene/scene.js +704 -0
  606. package/dist/src/utility/serialization/scene/scene.js.map +1 -0
  607. package/dist/src/utility/serialization/scene/terrain.js +488 -0
  608. package/dist/src/utility/serialization/scene/terrain.js.map +1 -0
  609. package/dist/src/utility/serialization/scene/water.js +465 -0
  610. package/dist/src/utility/serialization/scene/water.js.map +1 -0
  611. package/dist/src/utility/shprojector.js +297 -0
  612. package/dist/src/utility/shprojector.js.map +1 -0
  613. package/dist/{material/mixins → src/utility/textures}/ggxlut.js +1 -1
  614. package/dist/src/utility/textures/ggxlut.js.map +1 -0
  615. package/dist/src/utility/textures/gradientnoise.js +62 -0
  616. package/dist/src/utility/textures/gradientnoise.js.map +1 -0
  617. package/dist/src/utility/textures/randomnoise.js +41 -0
  618. package/dist/src/utility/textures/randomnoise.js.map +1 -0
  619. package/dist/src/values.js +162 -0
  620. package/dist/src/values.js.map +1 -0
  621. package/dist/utility/aabbtree.js +15 -5
  622. package/dist/utility/aabbtree.js.map +1 -1
  623. package/dist/utility/blueprint/common/constants.js +851 -0
  624. package/dist/utility/blueprint/common/constants.js.map +1 -0
  625. package/dist/utility/blueprint/common/math.js +2045 -0
  626. package/dist/utility/blueprint/common/math.js.map +1 -0
  627. package/dist/utility/blueprint/common.js +7 -0
  628. package/dist/utility/blueprint/common.js.map +1 -0
  629. package/dist/utility/blueprint/material/common.js +7 -0
  630. package/dist/utility/blueprint/material/common.js.map +1 -0
  631. package/dist/utility/blueprint/material/func.js +521 -0
  632. package/dist/utility/blueprint/material/func.js.map +1 -0
  633. package/dist/utility/blueprint/material/inputs.js +1659 -0
  634. package/dist/utility/blueprint/material/inputs.js.map +1 -0
  635. package/dist/utility/blueprint/material/ir.js +1311 -0
  636. package/dist/utility/blueprint/material/ir.js.map +1 -0
  637. package/dist/utility/blueprint/material/pbr.js +362 -0
  638. package/dist/utility/blueprint/material/pbr.js.map +1 -0
  639. package/dist/utility/blueprint/material/texture.js +1099 -0
  640. package/dist/utility/blueprint/material/texture.js.map +1 -0
  641. package/dist/utility/blueprint/node.js +187 -0
  642. package/dist/utility/blueprint/node.js.map +1 -0
  643. package/dist/utility/bounding_volume.js +0 -1
  644. package/dist/utility/bounding_volume.js.map +1 -1
  645. package/dist/utility/debug.js +26 -0
  646. package/dist/utility/debug.js.map +1 -0
  647. package/dist/utility/draco/decoder.js +1 -1
  648. package/dist/utility/draco/decoder.js.map +1 -1
  649. package/dist/utility/misc.js +18 -6
  650. package/dist/utility/misc.js.map +1 -1
  651. package/dist/utility/panorama.js +8 -6
  652. package/dist/utility/panorama.js.map +1 -1
  653. package/dist/utility/pmrem.js +30 -18
  654. package/dist/utility/pmrem.js.map +1 -1
  655. package/dist/utility/rendermipmap.js +116 -0
  656. package/dist/utility/rendermipmap.js.map +1 -0
  657. package/dist/utility/serialization/blueprint/constants.js +255 -0
  658. package/dist/utility/serialization/blueprint/constants.js.map +1 -0
  659. package/dist/utility/serialization/blueprint/material/constants.js +203 -0
  660. package/dist/utility/serialization/blueprint/material/constants.js.map +1 -0
  661. package/dist/utility/serialization/blueprint/material/texture.js +165 -0
  662. package/dist/utility/serialization/blueprint/material/texture.js.map +1 -0
  663. package/dist/utility/serialization/json.js +402 -0
  664. package/dist/utility/serialization/json.js.map +1 -0
  665. package/dist/utility/serialization/manager.js +1176 -0
  666. package/dist/utility/serialization/manager.js.map +1 -0
  667. package/dist/utility/serialization/scene/animation.js +699 -0
  668. package/dist/utility/serialization/scene/animation.js.map +1 -0
  669. package/dist/utility/serialization/scene/batch.js +53 -0
  670. package/dist/utility/serialization/scene/batch.js.map +1 -0
  671. package/dist/utility/serialization/scene/camera.js +808 -0
  672. package/dist/utility/serialization/scene/camera.js.map +1 -0
  673. package/dist/utility/serialization/scene/common.js +224 -0
  674. package/dist/utility/serialization/scene/common.js.map +1 -0
  675. package/dist/utility/serialization/scene/light.js +589 -0
  676. package/dist/utility/serialization/scene/light.js.map +1 -0
  677. package/dist/utility/serialization/scene/material.js +942 -0
  678. package/dist/utility/serialization/scene/material.js.map +1 -0
  679. package/dist/utility/serialization/scene/mesh.js +374 -0
  680. package/dist/utility/serialization/scene/mesh.js.map +1 -0
  681. package/dist/utility/serialization/scene/misc.js +39 -0
  682. package/dist/utility/serialization/scene/misc.js.map +1 -0
  683. package/dist/utility/serialization/scene/node.js +391 -0
  684. package/dist/utility/serialization/scene/node.js.map +1 -0
  685. package/dist/utility/serialization/scene/particle.js +425 -0
  686. package/dist/utility/serialization/scene/particle.js.map +1 -0
  687. package/dist/utility/serialization/scene/primitive.js +582 -0
  688. package/dist/utility/serialization/scene/primitive.js.map +1 -0
  689. package/dist/utility/serialization/scene/scene.js +763 -0
  690. package/dist/utility/serialization/scene/scene.js.map +1 -0
  691. package/dist/utility/serialization/scene/terrain.js +495 -0
  692. package/dist/utility/serialization/scene/terrain.js.map +1 -0
  693. package/dist/utility/serialization/scene/water.js +465 -0
  694. package/dist/utility/serialization/scene/water.js.map +1 -0
  695. package/dist/utility/shprojector.js +313 -0
  696. package/dist/utility/shprojector.js.map +1 -0
  697. package/dist/utility/textures/ggxlut.js +4 -5
  698. package/dist/utility/textures/ggxlut.js.map +1 -1
  699. package/dist/utility/textures/gradientnoise.js +2 -1
  700. package/dist/utility/textures/gradientnoise.js.map +1 -1
  701. package/dist/utility/textures/randomnoise.js +1 -0
  702. package/dist/utility/textures/randomnoise.js.map +1 -1
  703. package/dist/values.js +91 -4
  704. package/dist/values.js.map +1 -1
  705. package/package.json +29 -15
  706. package/dist/app.js.map +0 -1
  707. package/dist/blitter/depthlimitedgaussion.js.map +0 -1
  708. package/dist/input/inputmgr.js.map +0 -1
  709. package/dist/material/mixins/ggxlut.js.map +0 -1
  710. package/dist/posteffect/water.js +0 -508
  711. package/dist/posteffect/water.js.map +0 -1
  712. package/dist/render/oit.js +0 -16
  713. package/dist/render/oit.js.map +0 -1
  714. package/dist/render/scatteringlut.js +0 -634
  715. package/dist/render/scatteringlut.js.map +0 -1
  716. package/dist/render/watermesh.js +0 -193
  717. package/dist/render/watermesh.js.map +0 -1
  718. package/dist/render/wavegenerator.js +0 -8
  719. package/dist/render/wavegenerator.js.map +0 -1
  720. package/dist/scene/xform.js +0 -247
  721. package/dist/scene/xform.js.map +0 -1
  722. package/dist/utility/shprojection.js +0 -442
  723. package/dist/utility/shprojection.js.map +0 -1
@@ -1,102 +1,214 @@
1
- import { Matrix4x4, Vector4, Vector3, Ray, Frustum } from '@zephyr3d/base';
1
+ import { halton23, Matrix4x4, Vector4, DRef, Vector2, Vector3, Ray, Frustum } from '@zephyr3d/base';
2
2
  import { SceneNode } from '../scene/scene_node.js';
3
- import { Application } from '../app.js';
4
- import '../scene/octree.js';
5
- import '../values.js';
6
- import '@zephyr3d/device';
7
- import '../material/shader/helper.js';
8
- import '../material/lambert.js';
9
- import '../material/blinn.js';
10
- import '../material/unlit.js';
11
- import '../material/meshmaterial.js';
12
- import '../material/grassmaterial.js';
13
- import '../material/terrainmaterial.js';
14
- import '../material/pbrmr.js';
15
- import '../material/pbrsg.js';
16
- import { SceneRenderer } from '../render/renderer.js';
17
- import '../render/sky.js';
18
- import '../render/clipmap.js';
3
+ import { Compositor } from '../posteffect/compositor.js';
4
+ import { TAA } from '../posteffect/taa.js';
5
+ import { SSR } from '../posteffect/ssr.js';
6
+ import { Tonemap } from '../posteffect/tonemap.js';
7
+ import { FXAA } from '../posteffect/fxaa.js';
8
+ import { Bloom } from '../posteffect/bloom.js';
9
+ import { SAO } from '../posteffect/sao.js';
10
+ import { MotionBlur } from '../posteffect/motionblur.js';
11
+ import { getDevice } from '../app/api.js';
19
12
 
20
13
  /**
21
- * The camera node class
14
+ * A renderable camera node that manages view/projection math, frusta,
15
+ * input control, picking, and a post-processing chain via a compositor.
16
+ *
17
+ * Key features:
18
+ * - Maintains projection, view, VP, and inverse VP matrices and lazily recomputes them when invalidated.
19
+ * - Provides world- and view-space frusta for culling and clipping.
20
+ * - Supports perspective and orthographic projections.
21
+ * - Integrates with post effects (Tonemap, FXAA, TAA, Bloom, SSR, SSAO, Motion Blur) through an internal `Compositor`.
22
+ * - Handles temporal jitter and history state when TAA or motion blur are enabled.
23
+ * - Emits picking rays from screen coordinates and supports async GPU picking.
24
+ * - Optional controller integration for user input handling.
25
+ *
26
+ * Performance notes:
27
+ * - Matrices/frusta are computed on demand and cached until invalidation.
28
+ * - Temporal jitter and history are set up only when required by enabled features and device support.
29
+ *
22
30
  * @public
23
31
  */ class Camera extends SceneNode {
24
- /** @internal */ _projMatrix;
25
- /** @internal */ _viewMatrix;
26
- /** @internal */ _viewProjMatrix;
27
- /** @internal */ _rotationMatrix;
28
- /** @internal */ _invViewProjMatrix;
29
- /** @internal */ _clipPlane;
30
- /** @internal */ _controller;
31
- /** @internal */ _frustum;
32
- /** @internal */ _frustumV;
33
- /** @internal */ _dirty;
34
- /** @internal */ _sampleCount;
35
- /** @internal */ _framebuffer;
36
- /** @internal */ _viewport;
37
- /** @internal */ _scissor;
38
- /** @internal */ _clearColor;
39
- /** @internal */ _clipMask;
40
- /** @internal */ _oit;
41
- /** @internal */ _depthPrePass;
42
- /** @internal */ _commandBufferReuse;
43
- /** @internal */ _HiZ;
44
- /** @internal */ _SSR;
45
- /** @internal */ _ssrParams;
46
- /** @internal */ _ssrMaxRoughness;
47
- /** @internal */ _ssrRoughnessFactor;
48
- /** @internal */ _ssrStride;
49
- /** @internal */ _ssrCalcThickness;
50
- /** @internal */ _ssrBlurriness;
51
- /** @internal */ _ssrBlurDepthCutoff;
52
- /** @internal */ _ssrBlurKernelSize;
53
- /** @internal */ _ssrBlurStdDev;
54
- /** @internal */ _picking;
55
- /** @internal */ _pickPosX;
56
- /** @internal */ _pickPosY;
57
- /** @internal */ _pickResultPromise;
58
- /** @internal */ _pickResult;
59
- /**
60
- * Creates a new camera node
32
+ /** @internal Halton 2-3 sequence used for TAA jittering. */ static _halton23 = halton23(16);
33
+ /** @internal Per-camera history resources. */ static _historyData = new WeakMap();
34
+ /** @internal Projection matrix. */ _projMatrix;
35
+ /** @internal Inverse projection matrix. */ _invProjMatrix;
36
+ /** @internal View matrix (world -\> camera). */ _viewMatrix;
37
+ /** @internal View-projection matrix. */ _viewProjMatrix;
38
+ /** @internal Rotation matrix derived from world transform (camera conventions). */ _rotationMatrix;
39
+ /** @internal Inverse view-projection matrix. */ _invViewProjMatrix;
40
+ /** @internal Framebuffer clear color, disabled when null. Default is null */ _clearColor;
41
+ /** @internal Framebuffer depth clear value, disabled when null. Default is 1 */ _clearDepth;
42
+ /** @internal Framebuffer stencil clear value, disabled when null. Default is 0 */ _clearStencil;
43
+ /** @internal Optional clip plane in camera space. */ _clipPlane;
44
+ /** @internal Camera controller (input). */ _controller;
45
+ /** @internal World-space frustum (from VP). */ _frustum;
46
+ /** @internal View-space frustum (from P). */ _frustumV;
47
+ /** @internal Dirty flag indicating derived matrices/frusta need recompute. */ _dirty;
48
+ /** @internal Viewport [x, y, w, h]; null uses full framebuffer. */ _viewport;
49
+ /** @internal Scissor rectangle [x, y, w, h]; null uses viewport. */ _scissor;
50
+ /** @internal Clip plane mask for custom clipping schemes. */ _clipMask;
51
+ /** @internal Order-Independent Transparency reference. */ _oit;
52
+ /** @internal Whether to perform a depth pre-pass. */ _depthPrePass;
53
+ /** @internal Whether command buffers may be reused for optimization. */ _commandBufferReuse;
54
+ /** @internal Hi-Z acceleration enable (primarily for SSR). */ _HiZ;
55
+ /** @internal If true, a float point backbuffer will be used. The default value is true */ _HDR;
56
+ /** @internal Tonemap enable flag (via post effect). */ _toneMap;
57
+ /** @internal Tonemap post effect reference. */ _postEffectTonemap;
58
+ /** @internal Tonemap exposure. */ _tonemapExposure;
59
+ /** @internal Motion blur enable flag (via post effect). */ _motionBlur;
60
+ /** @internal Motion blur post effect reference. */ _postEffectMotionBlur;
61
+ /** @internal Motion blur strength. */ _motionBlurStrength;
62
+ /** @internal Bloom enable flag (via post effect). */ _bloom;
63
+ /** @internal Bloom post effect reference. */ _postEffectBloom;
64
+ /** @internal Bloom downsample level cap. */ _bloomMaxDownsampleLevels;
65
+ /** @internal Bloom downsample resolution limit. */ _bloomDownsampleLimit;
66
+ /** @internal Bloom threshold. */ _bloomThreshold;
67
+ /** @internal Bloom threshold knee (soft thresholding). */ _bloomThresholdKnee;
68
+ /** @internal Bloom intensity. */ _bloomIntensity;
69
+ /** @internal FXAA enable flag (via post effect). */ _FXAA;
70
+ /** @internal FXAA post effect reference. */ _postEffectFXAA;
71
+ /** @internal TAA enable flag (via post effect). */ _TAA;
72
+ /** @internal TAA post effect reference. */ _postEffectTAA;
73
+ /** @internal TAA debug mode (implementation-defined). */ _TAADebug;
74
+ /** @internal SSR enable flag (via post effect). */ _SSR;
75
+ /** @internal SSR post effect reference. */ _postEffectSSR;
76
+ /** @internal SSR parameter vector: (maxDistance, iterations, thickness, reserved). */ _ssrParams;
77
+ /** @internal SSR roughness cutoff; above this SSR is suppressed. */ _ssrMaxRoughness;
78
+ /** @internal SSR roughness factor scaling. */ _ssrRoughnessFactor;
79
+ /** @internal SSR stride for ray marching. */ _ssrStride;
80
+ /** @internal Whether SSR thickness is computed automatically. */ _ssrCalcThickness;
81
+ /** @internal SSR blur scale. */ _ssrBlurriness;
82
+ /** @internal SSR blur depth cutoff. */ _ssrBlurDepthCutoff;
83
+ /** @internal SSR blur kernel size. */ _ssrBlurKernelSize;
84
+ /** @internal SSR Gaussian blur standard deviation. */ _ssrBlurStdDev;
85
+ /** @internal SSAO enable flag (via post effect). */ _SSAO;
86
+ /** @internal SSAO post effect reference. */ _postEffectSSAO;
87
+ /** @internal SSAO scale (sampling radius multiplier). */ _SSAOScale;
88
+ /** @internal SSAO bias (self-shadowing reduction). */ _SSAOBias;
89
+ /** @internal SSAO sample radius. */ _SSAORadius;
90
+ /** @internal SSAO intensity. */ _SSAOIntensity;
91
+ /** @internal SSAO blur depth cutoff. */ _SSAOBlurDepthCutoff;
92
+ /** @internal Pending GPU-pick promise (one-shot). */ _pickResultPromise;
93
+ /** @internal Resolver for the pending pick promise. */ _pickResultResolve;
94
+ /** @internal Last pick X position (viewport-relative). */ _pickPosX;
95
+ /** @internal Last pick Y position (viewport-relative). */ _pickPosY;
96
+ /** @internal Last resolved pick result (optional cache). */ _pickResult;
97
+ /** @internal Current jitter value in clip space (x, y). */ _jitterValue;
98
+ /** @internal Previous frame’s jitter value. */ _prevJitterValue;
99
+ /** @internal Current jittered VP matrix. */ _jitteredVPMatrix;
100
+ /** @internal Inverse of the current jittered VP matrix. */ _jitteredInvVPMatrix;
101
+ /** @internal Previous frame’s non-jittered VP matrix. */ _prevVPMatrix;
102
+ /** @internal Previous frame’s camera world position. */ _prevPosition;
103
+ /** @internal Previous frame’s jittered VP matrix. */ _prevJitteredVPMatrix;
104
+ /** @internal Post-processing compositor attached to this camera. */ _compositor;
105
+ /** @internal Pointer interaction rectangle in css pixels (relative to canvas) */ _interactionRect;
106
+ /** @internal captured by which mouse button (-1 if not captured) */ _capturedButton;
107
+ /**
108
+ * Creates a new camera node.
109
+ *
110
+ * Initializes projection/view matrices, temporal fields, controller linkage, and
111
+ * builds the default post-processing pipeline on the internal compositor.
61
112
  *
62
- * @param scene - The scene that the camera belongs to
63
- * @param projectionMatrix - Projection matrix for this camera
113
+ * @param scene - The scene that owns this camera.
114
+ * @param projectionMatrix - Optional projection matrix to initialize with.
64
115
  */ constructor(scene, projectionMatrix){
65
116
  super(scene);
66
117
  this._projMatrix = projectionMatrix || Matrix4x4.identity();
118
+ this._invProjMatrix = Matrix4x4.invert(this._projMatrix);
67
119
  this._viewMatrix = Matrix4x4.identity();
68
120
  this._viewProjMatrix = Matrix4x4.identity();
69
121
  this._invViewProjMatrix = Matrix4x4.identity();
70
122
  this._clipPlane = null;
123
+ this._clearColor = new Vector4(0, 0, 0, 1);
124
+ this._clearDepth = 1;
125
+ this._clearStencil = 0;
71
126
  this._dirty = true;
72
127
  this._controller = null;
73
- this._framebuffer = null;
74
128
  this._viewport = null;
75
129
  this._scissor = null;
76
- this._clearColor = new Vector4(0, 0, 0, 1);
77
130
  this._clipMask = 0;
78
- this._sampleCount = 1;
79
131
  this._frustum = null;
80
132
  this._frustumV = null;
81
- this._oit = null;
133
+ this._oit = new DRef();
82
134
  this._depthPrePass = false;
83
- this._pickPosX = 0;
84
- this._pickPosY = 0;
85
135
  this._HiZ = false;
136
+ this._HDR = true;
137
+ this._toneMap = true;
138
+ this._postEffectTonemap = new DRef();
139
+ this._tonemapExposure = 1;
140
+ this._motionBlur = false;
141
+ this._postEffectMotionBlur = new DRef();
142
+ this._motionBlurStrength = 1;
143
+ this._bloom = false;
144
+ this._postEffectBloom = new DRef();
145
+ this._bloomMaxDownsampleLevels = 4;
146
+ this._bloomDownsampleLimit = 32;
147
+ this._bloomThreshold = 0.8;
148
+ this._bloomThresholdKnee = 0;
149
+ this._bloomIntensity = 1;
150
+ this._FXAA = false;
151
+ this._postEffectFXAA = new DRef();
152
+ this._TAA = false;
153
+ this._postEffectTAA = new DRef();
154
+ this._TAADebug = 0;
86
155
  this._SSR = false;
156
+ this._postEffectSSR = new DRef();
87
157
  this._ssrParams = new Vector4(100, 120, 0.5, 0);
88
158
  this._ssrMaxRoughness = 0.8;
89
159
  this._ssrRoughnessFactor = 1;
90
160
  this._ssrStride = 2;
91
161
  this._ssrCalcThickness = false;
92
- this._ssrBlurriness = 0.05;
162
+ this._ssrBlurriness = 0.01;
93
163
  this._ssrBlurDepthCutoff = 2;
94
- this._ssrBlurKernelSize = 17;
164
+ this._ssrBlurKernelSize = 10;
95
165
  this._ssrBlurStdDev = 10;
166
+ this._SSAO = false;
167
+ this._postEffectSSAO = new DRef();
168
+ this._SSAOScale = 10;
169
+ this._SSAOBias = 1;
170
+ this._SSAOIntensity = 0.025;
171
+ this._SSAORadius = 100;
172
+ this._SSAOBlurDepthCutoff = 2;
96
173
  this._pickResult = null;
97
174
  this._commandBufferReuse = true;
175
+ this._jitteredVPMatrix = new Matrix4x4();
176
+ this._jitteredInvVPMatrix = new Matrix4x4();
177
+ this._jitterValue = new Vector2(0, 0);
178
+ this._prevVPMatrix = null;
179
+ this._prevPosition = null;
180
+ this._prevJitteredVPMatrix = null;
181
+ this._prevJitterValue = null;
182
+ this._pickResultPromise = null;
183
+ this._pickResultResolve = null;
184
+ this._pickPosX = 0;
185
+ this._pickPosY = 0;
186
+ this._compositor = new Compositor();
187
+ this._capturedButton = -1;
188
+ this._interactionRect = null;
189
+ this.updatePostProcessing();
190
+ if (scene && !scene.mainCamera) {
191
+ scene.mainCamera = this;
192
+ }
193
+ }
194
+ /**
195
+ * The compositor that owns and runs the camera's post-processing chain.
196
+ */ get compositor() {
197
+ return this._compositor;
198
+ }
199
+ /**
200
+ * Pointer interaction rectangle in css pixels (relative to canvas)
201
+ */ get interactionRect() {
202
+ return this._interactionRect;
98
203
  }
99
- /** Clip plane in camera space */ get clipPlane() {
204
+ set interactionRect(rect) {
205
+ this._interactionRect = rect;
206
+ }
207
+ /**
208
+ * Clip plane in camera space.
209
+ *
210
+ * Setting this invalidates derived data. Shaders should respect `clipMask` and plane.
211
+ */ get clipPlane() {
100
212
  return this._clipPlane;
101
213
  }
102
214
  set clipPlane(plane) {
@@ -104,8 +216,33 @@ import '../render/clipmap.js';
104
216
  this._invalidate(false);
105
217
  }
106
218
  /**
107
- * Gets whether Hi-Z acceleration is enabled.
108
- * When enabled, it can significantly improve SSR performance with minimal quality impact.
219
+ * Framebuffer clear color, or `null` to disable.
220
+ */ get clearColor() {
221
+ return this._clearColor;
222
+ }
223
+ set clearColor(v) {
224
+ this._clearColor = v?.clone() ?? null;
225
+ }
226
+ /**
227
+ * Framebuffer stencil clear value, disabled when null. Default is 0.
228
+ */ get clearDepth() {
229
+ return this._clearDepth;
230
+ }
231
+ set clearDepth(v) {
232
+ this._clearDepth = v;
233
+ }
234
+ /**
235
+ * Framebuffer stencil clear value, disabled when null. Default is 0.
236
+ */ get clearStencil() {
237
+ return this._clearStencil;
238
+ }
239
+ set clearStencil(v) {
240
+ this._clearStencil = v;
241
+ }
242
+ /**
243
+ * Whether Hi-Z acceleration is enabled.
244
+ *
245
+ * Often improves SSR performance with little quality impact when supported.
109
246
  */ get HiZ() {
110
247
  return this._HiZ;
111
248
  }
@@ -113,12 +250,145 @@ import '../render/clipmap.js';
113
250
  this._HiZ = !!val;
114
251
  }
115
252
  /**
253
+ * Whether HDR backbuffer is enabled.
254
+ *
255
+ * Tonemap should be disabled when not using HDR backbuffer.
256
+ */ get HDR() {
257
+ return this._HDR;
258
+ }
259
+ set HDR(val) {
260
+ this._HDR = !!val;
261
+ }
262
+ /**
263
+ * Whether tonemapping is enabled via the post effect.
264
+ */ get toneMap() {
265
+ return this._postEffectTonemap.get().enabled;
266
+ }
267
+ set toneMap(val) {
268
+ this._postEffectTonemap.get().enabled = !!val;
269
+ }
270
+ /**
271
+ * Whether motion blur is enabled via the post effect.
272
+ */ get motionBlur() {
273
+ return this._postEffectMotionBlur.get().enabled;
274
+ }
275
+ set motionBlur(val) {
276
+ this._postEffectMotionBlur.get().enabled = !!val;
277
+ }
278
+ /** Motion blur strength */ get motionBlurStrength() {
279
+ return this._motionBlurStrength;
280
+ }
281
+ set motionBlurStrength(val) {
282
+ this._motionBlurStrength = val;
283
+ if (this._postEffectMotionBlur.get()) {
284
+ this._postEffectMotionBlur.get().strength = this._motionBlurStrength;
285
+ }
286
+ }
287
+ /**
288
+ * Gets whether Bloom is enabled.
289
+ */ get bloom() {
290
+ return this._postEffectBloom.get().enabled;
291
+ }
292
+ set bloom(val) {
293
+ this._postEffectBloom.get().enabled = !!val;
294
+ }
295
+ /**
296
+ * Maximum bloom downsample levels
297
+ */ get bloomMaxDownsampleLevels() {
298
+ return this._bloomMaxDownsampleLevels;
299
+ }
300
+ set bloomMaxDownsampleLevels(val) {
301
+ this._bloomMaxDownsampleLevels = val;
302
+ if (this._postEffectBloom.get()) {
303
+ this._postEffectBloom.get().maxDownsampleLevel = val;
304
+ }
305
+ }
306
+ /**
307
+ * Bloom downsample limit
308
+ */ get bloomDownsampleLimit() {
309
+ return this._bloomDownsampleLimit;
310
+ }
311
+ set bloomDownsampleLimit(val) {
312
+ this._bloomDownsampleLimit = val;
313
+ if (this._postEffectBloom.get()) {
314
+ this._postEffectBloom.get().downsampleLimit = val;
315
+ }
316
+ }
317
+ /**
318
+ * Bloom threshold
319
+ */ get bloomThreshold() {
320
+ return this._bloomThreshold;
321
+ }
322
+ set bloomThreshold(val) {
323
+ this._bloomThreshold = val;
324
+ if (this._postEffectBloom.get()) {
325
+ this._postEffectBloom.get().threshold = val;
326
+ }
327
+ }
328
+ /**
329
+ * Bloom threshold knee
330
+ */ get bloomThresholdKnee() {
331
+ return this._bloomThresholdKnee;
332
+ }
333
+ set bloomThresholdKnee(val) {
334
+ this._bloomThresholdKnee = val;
335
+ if (this._postEffectBloom.get()) {
336
+ this._postEffectBloom.get().thresholdKnee = val;
337
+ }
338
+ }
339
+ /**
340
+ * Bloom intensity
341
+ */ get bloomIntensity() {
342
+ return this._bloomIntensity;
343
+ }
344
+ set bloomIntensity(val) {
345
+ this._bloomIntensity = val;
346
+ if (this._postEffectBloom.get()) {
347
+ this._postEffectBloom.get().intensity = val;
348
+ }
349
+ }
350
+ /**
351
+ * Gets whether FXAA is enabled.
352
+ */ get FXAA() {
353
+ return this._postEffectFXAA.get().enabled;
354
+ }
355
+ set FXAA(val) {
356
+ this._postEffectFXAA.get().enabled = !!val;
357
+ }
358
+ /**
359
+ * Tonemap exposure
360
+ */ get toneMapExposure() {
361
+ return this._tonemapExposure;
362
+ }
363
+ set toneMapExposure(val) {
364
+ this._tonemapExposure = val;
365
+ if (this._postEffectTonemap.get()) {
366
+ this._postEffectTonemap.get().exposure = val;
367
+ }
368
+ }
369
+ /**
370
+ * Gets whether TAA is enabled.
371
+ */ get TAA() {
372
+ return this._postEffectTAA.get().enabled;
373
+ }
374
+ set TAA(val) {
375
+ this._postEffectTAA.get().enabled = !!val;
376
+ }
377
+ /**
378
+ * Gets the debug flag for TAA
379
+ */ get TAADebug() {
380
+ return this._TAADebug;
381
+ }
382
+ set TAADebug(val) {
383
+ this._TAADebug = val;
384
+ }
385
+ /**
116
386
  * Gets whether Screen Space Reflections (SSR) is enabled.
117
387
  */ get SSR() {
118
- return this._SSR;
388
+ return this._postEffectSSR.get().enabled;
119
389
  }
120
390
  set SSR(val) {
121
- this._SSR = !!val;
391
+ this._postEffectSSR.get().enabled = !!val;
122
392
  }
123
393
  /**
124
394
  * Gets the maximum roughness value for screen space reflections.
@@ -222,68 +492,76 @@ import '../render/clipmap.js';
222
492
  /** @internal */ get ssrParams() {
223
493
  return this._ssrParams;
224
494
  }
225
- /** Whether to perform a depth pass */ get depthPrePass() {
226
- return this._depthPrePass;
495
+ /**
496
+ * Gets whether SSAO is enabled.
497
+ */ get SSAO() {
498
+ return this._postEffectSSAO.get().enabled;
227
499
  }
228
- set depthPrePass(val) {
229
- this._depthPrePass = !!val;
500
+ set SSAO(val) {
501
+ this._postEffectSSAO.get().enabled = !!val;
230
502
  }
231
- /** Whether to allow command buffer reuse optimization */ get commandBufferReuse() {
232
- return this._commandBufferReuse;
503
+ /** SSAO scale */ get SSAOScale() {
504
+ return this._SSAOScale;
233
505
  }
234
- set commandBufferReuse(val) {
235
- this._commandBufferReuse = !!val;
506
+ set SSAOScale(val) {
507
+ this._SSAOScale = val;
508
+ if (this._postEffectSSAO.get()) {
509
+ this._postEffectSSAO.get().scale = val;
510
+ }
236
511
  }
237
- /** Whether GPU picking is enabled for this camera */ get enablePicking() {
238
- return this._picking;
512
+ /** SSAO bias */ get SSAOBias() {
513
+ return this._SSAOBias;
239
514
  }
240
- set enablePicking(enable) {
241
- this._picking = !!enable;
515
+ set SSAOBias(val) {
516
+ this._SSAOBias = val;
517
+ if (this._postEffectSSAO.get()) {
518
+ this._postEffectSSAO.get().bias = val;
519
+ }
242
520
  }
243
- /** X coordinate for picking related to viewport */ get pickPosX() {
244
- return this._pickPosX;
521
+ /** SSAO radius */ get SSAORadius() {
522
+ return this._SSAORadius;
245
523
  }
246
- set pickPosX(val) {
247
- this._pickPosX = val;
524
+ set SSAORadius(val) {
525
+ this._SSAORadius = val;
526
+ if (this._postEffectSSAO.get()) {
527
+ this._postEffectSSAO.get().radius = val;
528
+ }
248
529
  }
249
- /** Y coordinate for picking related to viewport */ get pickPosY() {
250
- return this._pickPosY;
530
+ /** SSAO intensity */ get SSAOIntensity() {
531
+ return this._SSAOIntensity;
251
532
  }
252
- set pickPosY(val) {
253
- this._pickPosY = val;
533
+ set SSAOIntensity(val) {
534
+ this._SSAOIntensity = val;
535
+ if (this._postEffectSSAO.get()) {
536
+ this._postEffectSSAO.get().intensity = val;
537
+ }
254
538
  }
255
- /** Pick result */ get pickResult() {
256
- return this._pickResult;
539
+ /** SSAO depth cutoff */ get SSAOBlurDepthCutoff() {
540
+ return this._SSAOBlurDepthCutoff;
257
541
  }
258
- set pickResult(val) {
259
- this._pickResult = val;
542
+ set SSAOBlurDepthCutoff(val) {
543
+ this._SSAOBlurDepthCutoff = val;
544
+ if (this._postEffectSSAO.get()) {
545
+ this._postEffectSSAO.get().blurDepthCutoff = val;
546
+ }
260
547
  }
261
- /** @internal */ get pickResultAsync() {
262
- return this._pickResultPromise;
548
+ /** Whether to perform a depth pass */ get depthPrePass() {
549
+ return this._depthPrePass;
263
550
  }
264
- set pickResultAsync(val) {
265
- this._pickResultPromise = val;
551
+ set depthPrePass(val) {
552
+ this._depthPrePass = !!val;
266
553
  }
267
- /**
268
- * Sample count for MSAA
269
- *
270
- * @remarks
271
- * If greater than one, force the scene to be rendered using multisampled framebuffer
272
- */ get sampleCount() {
273
- return this._sampleCount;
554
+ /** Whether to allow command buffer reuse optimization */ get commandBufferReuse() {
555
+ return this._commandBufferReuse;
274
556
  }
275
- set sampleCount(val) {
276
- if (val !== 1 && val !== 4) {
277
- console.error(`Invalid sample count: ${val}`);
278
- } else {
279
- this._sampleCount = val;
280
- }
557
+ set commandBufferReuse(val) {
558
+ this._commandBufferReuse = !!val;
281
559
  }
282
560
  /** OIT */ get oit() {
283
- return this._oit;
561
+ return this._oit.get();
284
562
  }
285
563
  set oit(val) {
286
- this._oit = val;
564
+ this._oit.set(val);
287
565
  }
288
566
  /** Clip plane mask */ get clipMask() {
289
567
  return this._clipMask;
@@ -291,12 +569,6 @@ import '../render/clipmap.js';
291
569
  set clipMask(val) {
292
570
  this._clipMask = val;
293
571
  }
294
- /** Framebuffer object into which the scene will be rendered */ get framebuffer() {
295
- return this._framebuffer;
296
- }
297
- set framebuffer(fb) {
298
- this._framebuffer = fb ?? null;
299
- }
300
572
  /** Viewport used for rendering, if null, use full framebuffer size */ get viewport() {
301
573
  return this._viewport ? [
302
574
  ...this._viewport
@@ -313,16 +585,6 @@ import '../render/clipmap.js';
313
585
  set scissor(rect) {
314
586
  this._scissor = rect?.slice() ?? null;
315
587
  }
316
- /** Color value used to clear color buffer before rendering, if null, color buffer will not be cleared */ get clearColor() {
317
- return this._clearColor;
318
- }
319
- set clearColor(val) {
320
- if (!val) {
321
- this._clearColor = null;
322
- } else {
323
- this._clearColor.set(val);
324
- }
325
- }
326
588
  /**
327
589
  * Handle input events
328
590
  * @param ev - input event object
@@ -331,11 +593,20 @@ import '../render/clipmap.js';
331
593
  */ handleEvent(ev, type) {
332
594
  let handled = false;
333
595
  if (this._controller) {
596
+ if (this._capturedButton < 0 && (ev instanceof PointerEvent || ev instanceof WheelEvent) && !this.posInViewport(ev.offsetX, ev.offsetY)) {
597
+ return false;
598
+ }
334
599
  type = type ?? ev.type;
335
600
  if (type === 'pointerdown') {
601
+ if (this._capturedButton < 0) {
602
+ this._capturedButton = ev.button;
603
+ }
336
604
  handled = this._controller.onMouseDown(ev);
337
605
  } else if (type === 'pointerup') {
338
606
  handled = this._controller.onMouseUp(ev);
607
+ if (this._capturedButton === ev.button) {
608
+ this._capturedButton = -1;
609
+ }
339
610
  } else if (type === 'pointermove') {
340
611
  handled = this._controller.onMouseMove(ev);
341
612
  } else if (type === 'wheel') {
@@ -345,7 +616,7 @@ import '../render/clipmap.js';
345
616
  } else if (type === 'keyup') {
346
617
  handled = this._controller.onKeyUp(ev);
347
618
  }
348
- if (handled) {
619
+ if (handled && ev.preventDefault) {
349
620
  ev.preventDefault();
350
621
  }
351
622
  }
@@ -358,13 +629,20 @@ import '../render/clipmap.js';
358
629
  * @param y - The y-component of the screen coordinates, relative to the top-left corner of the viewport.
359
630
  * @returns The ray originating from the camera position and passing through the given screen coordinates.
360
631
  */ constructRay(x, y) {
361
- const width = this.viewport ? this.viewport[2] : Application.instance.device.getViewport().width;
362
- const height = this.viewport ? this.viewport[3] : Application.instance.device.getViewport().height;
363
- const vClip = new Vector4(2 * x / width - 1, 1 - 2 * y / height, 1, 1);
364
- const vWorld = this.invViewProjectionMatrix.transform(vClip);
365
- vWorld.scaleBy(1 / vWorld.w);
366
- const vEye = this.getWorldPosition();
367
- const vDir = Vector3.sub(vWorld.xyz(), vEye).inplaceNormalize();
632
+ const width = this.viewport ? this.viewport[2] : getDevice().getViewport().width;
633
+ const height = this.viewport ? this.viewport[3] : getDevice().getViewport().height;
634
+ const ndcX = 2 * x / width - 1;
635
+ const ndcY = 1 - 2 * y / height;
636
+ const nearClip = new Vector4(ndcX, ndcY, 0, 1);
637
+ const farClip = new Vector4(ndcX, ndcY, 1, 1);
638
+ const nearWorld = this.invViewProjectionMatrix.transform(nearClip);
639
+ const farWorld = this.invViewProjectionMatrix.transform(farClip);
640
+ if (this.isPerspective()) {
641
+ nearWorld.scaleBy(1 / nearWorld.w);
642
+ farWorld.scaleBy(1 / farWorld.w);
643
+ }
644
+ const vEye = this.isPerspective() ? this.getWorldPosition() : nearWorld.xyz();
645
+ const vDir = Vector3.sub(farWorld.xyz(), vEye).inplaceNormalize();
368
646
  return new Ray(vEye, vDir);
369
647
  }
370
648
  /**
@@ -393,6 +671,7 @@ import '../render/clipmap.js';
393
671
  * @returns self
394
672
  */ setPerspective(fovY, aspect, zNear, zFar) {
395
673
  this._projMatrix.perspective(fovY, aspect, zNear, zFar);
674
+ Matrix4x4.invert(this._projMatrix, this._invProjMatrix);
396
675
  this._invalidate(true);
397
676
  return this;
398
677
  }
@@ -407,6 +686,7 @@ import '../render/clipmap.js';
407
686
  * @returns self
408
687
  */ setOrtho(left, right, bottom, top, near, far) {
409
688
  this._projMatrix.ortho(left, right, bottom, top, near, far);
689
+ Matrix4x4.invert(this._projMatrix, this._invProjMatrix);
410
690
  this._invalidate(true);
411
691
  return this;
412
692
  }
@@ -415,7 +695,8 @@ import '../render/clipmap.js';
415
695
  * @param matrix - The projection matrix
416
696
  */ setProjectionMatrix(matrix) {
417
697
  if (matrix && matrix !== this._projMatrix) {
418
- this._projMatrix.set(matrix);
698
+ this._projMatrix = matrix;
699
+ Matrix4x4.invert(this._projMatrix, this._invProjMatrix);
419
700
  this._invalidate(true);
420
701
  }
421
702
  }
@@ -429,6 +710,16 @@ import '../render/clipmap.js';
429
710
  }
430
711
  return this._projMatrix;
431
712
  }
713
+ /**
714
+ * Gets the inverse projection matrix of the camera
715
+ * @returns The projection matrix
716
+ */ getInvProjectionMatrix() {
717
+ if (this._dirty) {
718
+ this._dirty = false;
719
+ this._compute();
720
+ }
721
+ return this._invProjMatrix;
722
+ }
432
723
  getRotationMatrix() {
433
724
  const rotationMatrix = new Matrix4x4();
434
725
  this.worldMatrix.decompose(null, rotationMatrix, null);
@@ -498,32 +789,191 @@ import '../render/clipmap.js';
498
789
  return true;
499
790
  }
500
791
  /** Gets the near clip plane of the camera */ getNearPlane() {
501
- return this._projMatrix.getNearPlane();
792
+ return this.getProjectionMatrix().getNearPlane();
502
793
  }
503
794
  /** Gets the far clip plane of the camera */ getFarPlane() {
504
- return this._projMatrix.getFarPlane();
795
+ return this.getProjectionMatrix().getFarPlane();
505
796
  }
506
797
  /** Gets the vertical field of view of the camera */ getFOV() {
507
- return this._projMatrix.getFov();
798
+ return this.getProjectionMatrix().getFov();
508
799
  }
509
800
  /** Gets the tangent of half of the vertical field of view */ getTanHalfFovy() {
510
- return this._projMatrix.getTanHalfFov();
801
+ return this.getProjectionMatrix().getTanHalfFov();
511
802
  }
512
803
  /** Gets the aspect ratio */ getAspect() {
513
- return this._projMatrix.getAspect();
804
+ return this.getProjectionMatrix().getAspect();
805
+ }
806
+ /** Returns true if the camera is perspective */ isPerspective() {
807
+ return this.getProjectionMatrix().isPerspective();
808
+ }
809
+ /** Returns true if the camera is orthographic */ isOrtho() {
810
+ return this.getProjectionMatrix().isOrtho();
811
+ }
812
+ /**
813
+ * Gets the camera history data which is used in temporal reprojection
814
+ * @returns Camera history data
815
+ */ getHistoryData() {
816
+ let data = Camera._historyData.get(this);
817
+ if (!data) {
818
+ data = {
819
+ prevColorTex: null,
820
+ prevMotionVectorTex: null
821
+ };
822
+ Camera._historyData.set(this, data);
823
+ }
824
+ return data;
825
+ }
826
+ /**
827
+ * Clears the camera history data which is used in temporal reprojection
828
+ */ clearHistoryData() {
829
+ const data = Camera._historyData.get(this);
830
+ if (data) {
831
+ if (data.prevColorTex) {
832
+ getDevice().pool.releaseTexture(data.prevColorTex);
833
+ }
834
+ if (data.prevMotionVectorTex) {
835
+ getDevice().pool.releaseTexture(data.prevMotionVectorTex);
836
+ }
837
+ Camera._historyData.delete(this);
838
+ }
839
+ this._prevVPMatrix = null;
840
+ this._prevPosition = null;
841
+ this._prevJitteredVPMatrix = null;
842
+ this._prevJitterValue = null;
843
+ }
844
+ /** @internal */ updatePostProcessing() {
845
+ this._compositor.clear();
846
+ if (!this._postEffectSSR.get()) {
847
+ const ssr = new SSR();
848
+ ssr.enabled = false;
849
+ this._postEffectSSR.set(ssr);
850
+ this._compositor.appendPostEffect(ssr);
851
+ }
852
+ if (!this._postEffectSSAO.get()) {
853
+ const ssao = new SAO();
854
+ ssao.enabled = false;
855
+ ssao.scale = this._SSAOScale;
856
+ ssao.bias = this._SSAOBias;
857
+ ssao.radius = this._SSAORadius;
858
+ ssao.intensity = this._SSAOIntensity;
859
+ ssao.blurDepthCutoff = this._SSAOBlurDepthCutoff;
860
+ this._postEffectSSAO.set(ssao);
861
+ this._compositor.appendPostEffect(ssao);
862
+ }
863
+ if (!this._postEffectTAA.get()) {
864
+ const taa = new TAA();
865
+ taa.enabled = false;
866
+ this._postEffectTAA.set(taa);
867
+ this._compositor.appendPostEffect(taa);
868
+ }
869
+ if (!this._postEffectMotionBlur.get()) {
870
+ const motionBlur = new MotionBlur();
871
+ motionBlur.enabled = false;
872
+ motionBlur.strength = this._motionBlurStrength;
873
+ this._postEffectMotionBlur.set(motionBlur);
874
+ this._compositor.appendPostEffect(motionBlur);
875
+ }
876
+ if (!this._postEffectTonemap.get()) {
877
+ const tonemap = new Tonemap();
878
+ tonemap.enabled = true;
879
+ tonemap.exposure = this._tonemapExposure;
880
+ this._postEffectTonemap.set(tonemap);
881
+ this._compositor.appendPostEffect(tonemap);
882
+ }
883
+ if (!this._postEffectFXAA.get()) {
884
+ const fxaa = new FXAA();
885
+ fxaa.enabled = false;
886
+ this._postEffectFXAA.set(fxaa);
887
+ this._compositor.appendPostEffect(fxaa);
888
+ }
889
+ if (!this._postEffectBloom.get()) {
890
+ const bloom = new Bloom();
891
+ bloom.enabled = false;
892
+ bloom.maxDownsampleLevel = this._bloomMaxDownsampleLevels;
893
+ bloom.downsampleLimit = this._bloomDownsampleLimit;
894
+ bloom.threshold = this._bloomThreshold;
895
+ bloom.thresholdKnee = this._bloomThresholdKnee;
896
+ bloom.intensity = this._bloomIntensity;
897
+ this._postEffectBloom.set(bloom);
898
+ this._compositor.appendPostEffect(bloom);
899
+ }
514
900
  }
515
901
  /**
516
902
  * Renders a scene
517
903
  * @param scene - The scene to be rendered
518
904
  * @param compositor - Compositor instance that will be used to apply postprocess effects
519
- */ render(scene, compositor) {
520
- const device = Application.instance.device;
905
+ */ render(scene) {
906
+ const device = getDevice();
907
+ //this.updatePostProcessing(device);
908
+ const useMotionVector = (this.TAA || this.motionBlur) && device.type !== 'webgl';
909
+ const useTAA = useMotionVector && this.TAA;
910
+ scene.dispatchEvent('startrender', scene, this, this._compositor);
911
+ if (useMotionVector) {
912
+ const width = device.getDrawingBufferWidth();
913
+ const height = device.getDrawingBufferHeight();
914
+ if (useTAA) {
915
+ const halton = Camera._halton23[device.frameInfo.frameCounter % Camera._halton23.length];
916
+ this._jitterValue.setXY(halton[0] * 2 / width, halton[1] * 2 / height);
917
+ } else {
918
+ this._jitterValue.setXY(0, 0);
919
+ }
920
+ this._jitteredVPMatrix.set(this.getProjectionMatrix());
921
+ this._jitteredVPMatrix[8] += this._jitterValue.x;
922
+ this._jitteredVPMatrix[9] += this._jitterValue.y;
923
+ this._jitteredVPMatrix.multiplyRight(this.viewMatrix);
924
+ Matrix4x4.invert(this._jitteredVPMatrix, this._jitteredInvVPMatrix);
925
+ if (!this._prevJitteredVPMatrix) {
926
+ this._prevJitteredVPMatrix = new Matrix4x4();
927
+ this._prevJitteredVPMatrix.set(this._jitteredVPMatrix);
928
+ this._prevJitterValue = new Vector2(this._jitterValue);
929
+ }
930
+ if (!this._prevVPMatrix) {
931
+ this._prevVPMatrix = new Matrix4x4();
932
+ this._prevVPMatrix.set(this.viewProjectionMatrix);
933
+ this._prevPosition = this.getWorldPosition();
934
+ }
935
+ } else {
936
+ this._jitterValue.setXY(0, 0);
937
+ this._prevVPMatrix = null;
938
+ this._prevPosition = null;
939
+ this._prevJitteredVPMatrix = null;
940
+ this._prevJitterValue = null;
941
+ this._jitteredInvVPMatrix.set(this.invViewProjectionMatrix);
942
+ }
521
943
  device.pushDeviceStates();
522
944
  device.reverseVertexWindingOrder(false);
523
- device.setFramebuffer(this._framebuffer);
524
- SceneRenderer.setClearColor(this._clearColor);
525
- SceneRenderer.renderScene(scene, this, compositor);
945
+ scene.getRenderer().renderScene(scene, this);
526
946
  device.popDeviceStates();
947
+ if (useMotionVector) {
948
+ this._prevJitteredVPMatrix.set(this._jitteredVPMatrix);
949
+ this._prevJitterValue.set(this._jitterValue);
950
+ this._prevVPMatrix.set(this.viewProjectionMatrix);
951
+ this._prevPosition = this.getWorldPosition();
952
+ }
953
+ scene.dispatchEvent('endrender', scene, this, this._compositor);
954
+ }
955
+ async pickAsync(posX, posY) {
956
+ this._pickPosX = posX;
957
+ this._pickPosY = posY;
958
+ if (!this._pickResultPromise) {
959
+ this._pickResultPromise = new Promise((resolve)=>{
960
+ this._pickResultResolve = (result)=>{
961
+ resolve(result);
962
+ this._pickResultPromise = null;
963
+ this._pickResultResolve = null;
964
+ };
965
+ });
966
+ }
967
+ return this._pickResultPromise;
968
+ }
969
+ /** @internal */ getPickResultResolveFunc() {
970
+ return this._pickResultResolve;
971
+ }
972
+ /** @internal */ getPickPosX() {
973
+ return this._pickPosX;
974
+ }
975
+ /** @internal */ getPickPosY() {
976
+ return this._pickPosY;
527
977
  }
528
978
  /**
529
979
  * Updates the controller state
@@ -535,6 +985,27 @@ import '../render/clipmap.js';
535
985
  */ resetController() {
536
986
  this._controller?.reset();
537
987
  }
988
+ /** @internal */ get jitteredVPMatrix() {
989
+ return this._jitteredVPMatrix;
990
+ }
991
+ /** @internal */ get jitteredInvVPMatrix() {
992
+ return this._jitteredInvVPMatrix;
993
+ }
994
+ /** @internal */ get jitterValue() {
995
+ return this._jitterValue;
996
+ }
997
+ /** @internal */ get prevJitteredVPMatrix() {
998
+ return this._prevJitteredVPMatrix;
999
+ }
1000
+ /** @internal */ get prevJitterValue() {
1001
+ return this._prevJitterValue;
1002
+ }
1003
+ /** @internal */ get prevVPMatrix() {
1004
+ return this._prevVPMatrix;
1005
+ }
1006
+ /** @internal */ get prevPosition() {
1007
+ return this._prevPosition;
1008
+ }
538
1009
  /** @internal */ setController(controller) {
539
1010
  if (this._controller !== controller) {
540
1011
  if (controller && controller._getCamera() && controller._getCamera() !== this) {
@@ -568,11 +1039,44 @@ import '../render/clipmap.js';
568
1039
  super._onTransformChanged(invalidateLocal);
569
1040
  this._invalidate(false);
570
1041
  }
571
- /** {@inheritdoc SceneNode.dispose} */ dispose() {
1042
+ /** {@inheritdoc SceneNode.onDispose} */ onDispose() {
1043
+ super.onDispose();
572
1044
  this.setController(null);
1045
+ this.clearHistoryData();
573
1046
  this._projMatrix = null;
574
1047
  this._viewMatrix = null;
575
1048
  this._viewProjMatrix = null;
1049
+ this._postEffectBloom.dispose();
1050
+ this._postEffectFXAA.dispose();
1051
+ this._postEffectMotionBlur.dispose();
1052
+ this._postEffectSSAO.dispose();
1053
+ this._postEffectSSR.dispose();
1054
+ this._postEffectTAA.dispose();
1055
+ this._postEffectTonemap.dispose();
1056
+ this._oit.dispose();
1057
+ }
1058
+ /** @internal */ posInViewport(x, y) {
1059
+ let rect = this._interactionRect;
1060
+ if (!rect && this.viewport) {
1061
+ const cvs = getDevice().canvas;
1062
+ const vp = this.viewport;
1063
+ const vp_x = vp[0];
1064
+ const vp_y = cvs.clientHeight - vp[1] - vp[3];
1065
+ const vp_w = vp[2];
1066
+ const vp_h = vp[3];
1067
+ rect = [
1068
+ vp_x,
1069
+ vp_y,
1070
+ vp_w,
1071
+ vp_h
1072
+ ];
1073
+ }
1074
+ if (!rect) {
1075
+ return true;
1076
+ }
1077
+ x -= rect[0];
1078
+ y -= rect[1];
1079
+ return x >= 0 && x < rect[2] && y >= 0 && y < rect[3];
576
1080
  }
577
1081
  }
578
1082