@zephyr3d/scene 0.6.1 → 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 (722) hide show
  1. package/dist/animation/animation.js +149 -27
  2. package/dist/animation/animation.js.map +1 -1
  3. package/dist/animation/animationset.js +173 -73
  4. package/dist/animation/animationset.js.map +1 -1
  5. package/dist/animation/animationtrack.js +65 -10
  6. package/dist/animation/animationtrack.js.map +1 -1
  7. package/dist/animation/eulerrotationtrack.js +41 -20
  8. package/dist/animation/eulerrotationtrack.js.map +1 -1
  9. package/dist/animation/morphtarget.js +14 -38
  10. package/dist/animation/morphtarget.js.map +1 -1
  11. package/dist/animation/morphtrack.js +59 -22
  12. package/dist/animation/morphtrack.js.map +1 -1
  13. package/dist/animation/proptrack.js +190 -0
  14. package/dist/animation/proptrack.js.map +1 -0
  15. package/dist/animation/rotationtrack.js +29 -11
  16. package/dist/animation/rotationtrack.js.map +1 -1
  17. package/dist/animation/scaletrack.js +29 -11
  18. package/dist/animation/scaletrack.js.map +1 -1
  19. package/dist/animation/skeleton.js +241 -78
  20. package/dist/animation/skeleton.js.map +1 -1
  21. package/dist/animation/translationtrack.js +30 -11
  22. package/dist/animation/translationtrack.js.map +1 -1
  23. package/dist/app/api.js +43 -0
  24. package/dist/app/api.js.map +1 -0
  25. package/dist/app/app.js +153 -0
  26. package/dist/app/app.js.map +1 -0
  27. package/dist/app/engine.js +312 -0
  28. package/dist/app/engine.js.map +1 -0
  29. package/dist/app/inputmgr.js +351 -0
  30. package/dist/app/inputmgr.js.map +1 -0
  31. package/dist/app/runtimescript.js +62 -0
  32. package/dist/app/runtimescript.js.map +1 -0
  33. package/dist/app/scriptingsystem.js +220 -0
  34. package/dist/app/scriptingsystem.js.map +1 -0
  35. package/dist/app/scriptregistry.js +432 -0
  36. package/dist/app/scriptregistry.js.map +1 -0
  37. package/dist/asset/assetmanager.js +772 -291
  38. package/dist/asset/assetmanager.js.map +1 -1
  39. package/dist/asset/builtin.js +7 -43
  40. package/dist/asset/builtin.js.map +1 -1
  41. package/dist/asset/loaders/dds/dds.js +17 -93
  42. package/dist/asset/loaders/dds/dds.js.map +1 -1
  43. package/dist/asset/loaders/dds/dds_loader.js +8 -18
  44. package/dist/asset/loaders/dds/dds_loader.js.map +1 -1
  45. package/dist/asset/loaders/gltf/gltf_loader.js +36 -42
  46. package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
  47. package/dist/asset/loaders/gltf/helpers.js +27 -14
  48. package/dist/asset/loaders/gltf/helpers.js.map +1 -1
  49. package/dist/asset/loaders/hdr/hdr.js +17 -12
  50. package/dist/asset/loaders/hdr/hdr.js.map +1 -1
  51. package/dist/asset/loaders/image/tga_Loader.js +13 -16
  52. package/dist/asset/loaders/image/tga_Loader.js.map +1 -1
  53. package/dist/asset/loaders/image/webimage_loader.js +51 -50
  54. package/dist/asset/loaders/image/webimage_loader.js.map +1 -1
  55. package/dist/asset/loaders/loader.js.map +1 -1
  56. package/dist/asset/model.js +158 -4
  57. package/dist/asset/model.js.map +1 -1
  58. package/dist/blitter/bilateralblur.js +0 -1
  59. package/dist/blitter/bilateralblur.js.map +1 -1
  60. package/dist/blitter/blitter.js +22 -23
  61. package/dist/blitter/blitter.js.map +1 -1
  62. package/dist/blitter/box.js.map +1 -1
  63. package/dist/blitter/copy.js.map +1 -1
  64. package/dist/blitter/gaussianblur.js +23 -23
  65. package/dist/blitter/gaussianblur.js.map +1 -1
  66. package/dist/camera/base.js +141 -34
  67. package/dist/camera/base.js.map +1 -1
  68. package/dist/camera/camera.js +653 -149
  69. package/dist/camera/camera.js.map +1 -1
  70. package/dist/camera/fps.js +2 -10
  71. package/dist/camera/fps.js.map +1 -1
  72. package/dist/camera/orbit.js +132 -59
  73. package/dist/camera/orbit.js.map +1 -1
  74. package/dist/camera/orthocamera.js +37 -12
  75. package/dist/camera/orthocamera.js.map +1 -1
  76. package/dist/camera/perspectivecamera.js +37 -20
  77. package/dist/camera/perspectivecamera.js.map +1 -1
  78. package/dist/index.d.ts +18268 -6982
  79. package/dist/index.js +49 -16
  80. package/dist/index.js.map +1 -1
  81. package/dist/material/blinn.js +5 -0
  82. package/dist/material/blinn.js.map +1 -1
  83. package/dist/material/grassmaterial.js +6 -1
  84. package/dist/material/grassmaterial.js.map +1 -1
  85. package/dist/material/lambert.js +6 -1
  86. package/dist/material/lambert.js.map +1 -1
  87. package/dist/material/material.js +346 -73
  88. package/dist/material/material.js.map +1 -1
  89. package/dist/material/meshmaterial.js +498 -156
  90. package/dist/material/meshmaterial.js.map +1 -1
  91. package/dist/material/mixins/albedocolor.js +5 -1
  92. package/dist/material/mixins/albedocolor.js.map +1 -1
  93. package/dist/material/mixins/foliage.js +3 -3
  94. package/dist/material/mixins/foliage.js.map +1 -1
  95. package/dist/material/mixins/lightmodel/blinnphong.js +18 -5
  96. package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
  97. package/dist/material/mixins/lightmodel/lambert.js +6 -6
  98. package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
  99. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +235 -0
  100. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -0
  101. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +52 -15
  102. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  103. package/dist/material/mixins/lightmodel/pbrspecularglossness.js +27 -9
  104. package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
  105. package/dist/material/mixins/lit.js +16 -4
  106. package/dist/material/mixins/lit.js.map +1 -1
  107. package/dist/material/mixins/pbr/brdf.js +134 -0
  108. package/dist/material/mixins/pbr/brdf.js.map +1 -0
  109. package/dist/material/mixins/pbr/common.js +68 -85
  110. package/dist/material/mixins/pbr/common.js.map +1 -1
  111. package/dist/material/mixins/texture.js +98 -83
  112. package/dist/material/mixins/texture.js.map +1 -1
  113. package/dist/material/mixins/vertexcolor.js +6 -2
  114. package/dist/material/mixins/vertexcolor.js.map +1 -1
  115. package/dist/material/particle.js +272 -0
  116. package/dist/material/particle.js.map +1 -0
  117. package/dist/material/pbrblueprint.js +186 -0
  118. package/dist/material/pbrblueprint.js.map +1 -0
  119. package/dist/material/pbrmr.js +10 -0
  120. package/dist/material/pbrmr.js.map +1 -1
  121. package/dist/material/pbrsg.js +10 -0
  122. package/dist/material/pbrsg.js.map +1 -1
  123. package/dist/material/shader/helper.js +521 -287
  124. package/dist/material/shader/helper.js.map +1 -1
  125. package/dist/material/terrain-cm.js +607 -0
  126. package/dist/material/terrain-cm.js.map +1 -0
  127. package/dist/material/terrainmaterial.js +59 -54
  128. package/dist/material/terrainmaterial.js.map +1 -1
  129. package/dist/material/unlit.js +5 -0
  130. package/dist/material/unlit.js.map +1 -1
  131. package/dist/material/water.js +415 -0
  132. package/dist/material/water.js.map +1 -0
  133. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +38 -0
  134. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +1 -0
  135. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +10 -0
  136. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +1 -0
  137. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +127 -0
  138. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +1 -0
  139. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +263 -0
  140. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +1 -0
  141. package/dist/node_modules/es-module-lexer/dist/lexer.js +5 -0
  142. package/dist/node_modules/es-module-lexer/dist/lexer.js.map +1 -0
  143. package/dist/posteffect/bloom.js +39 -54
  144. package/dist/posteffect/bloom.js.map +1 -1
  145. package/dist/posteffect/compositor.js +95 -128
  146. package/dist/posteffect/compositor.js.map +1 -1
  147. package/dist/posteffect/fxaa.js +10 -18
  148. package/dist/posteffect/fxaa.js.map +1 -1
  149. package/dist/posteffect/grayscale.js +9 -17
  150. package/dist/posteffect/grayscale.js.map +1 -1
  151. package/dist/posteffect/motionblur.js +105 -0
  152. package/dist/posteffect/motionblur.js.map +1 -0
  153. package/dist/posteffect/posteffect.js +66 -35
  154. package/dist/posteffect/posteffect.js.map +1 -1
  155. package/dist/posteffect/sao.js +13 -21
  156. package/dist/posteffect/sao.js.map +1 -1
  157. package/dist/posteffect/ssr.js +60 -100
  158. package/dist/posteffect/ssr.js.map +1 -1
  159. package/dist/posteffect/taa.js +175 -0
  160. package/dist/posteffect/taa.js.map +1 -0
  161. package/dist/posteffect/tonemap.js +12 -20
  162. package/dist/posteffect/tonemap.js.map +1 -1
  163. package/dist/render/abuffer_oit.js +30 -19
  164. package/dist/render/abuffer_oit.js.map +1 -1
  165. package/dist/render/clipmap.js +429 -101
  166. package/dist/render/clipmap.js.map +1 -1
  167. package/dist/render/cluster_light.js +7 -5
  168. package/dist/render/cluster_light.js.map +1 -1
  169. package/dist/render/cull_visitor.js +43 -3
  170. package/dist/render/cull_visitor.js.map +1 -1
  171. package/dist/render/depthpass.js +14 -5
  172. package/dist/render/depthpass.js.map +1 -1
  173. package/dist/render/drawable_mixin.js +113 -40
  174. package/dist/render/drawable_mixin.js.map +1 -1
  175. package/dist/render/envlight.js +86 -141
  176. package/dist/render/envlight.js.map +1 -1
  177. package/dist/render/fbm_wavegenerator.js +234 -0
  178. package/dist/render/fbm_wavegenerator.js.map +1 -0
  179. package/dist/render/fft_wavegenerator.js +64 -50
  180. package/dist/render/fft_wavegenerator.js.map +1 -1
  181. package/dist/render/fullscreenquad.js +2 -2
  182. package/dist/render/fullscreenquad.js.map +1 -1
  183. package/dist/render/gerstner_wavegenerator.js +98 -48
  184. package/dist/render/gerstner_wavegenerator.js.map +1 -1
  185. package/dist/render/globalbindgroup_allocator.js +4 -2
  186. package/dist/render/globalbindgroup_allocator.js.map +1 -1
  187. package/dist/render/hzb.js +6 -3
  188. package/dist/render/hzb.js.map +1 -1
  189. package/dist/render/lightpass.js +19 -18
  190. package/dist/render/lightpass.js.map +1 -1
  191. package/dist/render/objectcolorpass.js +4 -4
  192. package/dist/render/objectcolorpass.js.map +1 -1
  193. package/dist/render/primitive.js +213 -104
  194. package/dist/render/primitive.js.map +1 -1
  195. package/dist/render/render_queue.js +40 -20
  196. package/dist/render/render_queue.js.map +1 -1
  197. package/dist/render/renderbundle_wrapper.js +65 -15
  198. package/dist/render/renderbundle_wrapper.js.map +1 -1
  199. package/dist/render/renderer.js +326 -185
  200. package/dist/render/renderer.js.map +1 -1
  201. package/dist/render/renderpass.js +20 -36
  202. package/dist/render/renderpass.js.map +1 -1
  203. package/dist/render/shadowmap_pass.js +3 -3
  204. package/dist/render/shadowmap_pass.js.map +1 -1
  205. package/dist/render/sky.js +864 -541
  206. package/dist/render/sky.js.map +1 -1
  207. package/dist/render/weightedblended_oit.js +13 -15
  208. package/dist/render/weightedblended_oit.js.map +1 -1
  209. package/dist/scene/batchgroup.js +18 -5
  210. package/dist/scene/batchgroup.js.map +1 -1
  211. package/dist/scene/environment.js +78 -48
  212. package/dist/scene/environment.js.map +1 -1
  213. package/dist/scene/graph_node.js +2 -3
  214. package/dist/scene/graph_node.js.map +1 -1
  215. package/dist/scene/light.js +28 -89
  216. package/dist/scene/light.js.map +1 -1
  217. package/dist/scene/mesh.js +218 -87
  218. package/dist/scene/mesh.js.map +1 -1
  219. package/dist/scene/octree.js +371 -162
  220. package/dist/scene/octree.js.map +1 -1
  221. package/dist/scene/particlesys.js +684 -0
  222. package/dist/scene/particlesys.js.map +1 -0
  223. package/dist/scene/raycast_visitor.js +34 -5
  224. package/dist/scene/raycast_visitor.js.map +1 -1
  225. package/dist/scene/scene.js +309 -85
  226. package/dist/scene/scene.js.map +1 -1
  227. package/dist/scene/scene_node.js +675 -102
  228. package/dist/scene/scene_node.js.map +1 -1
  229. package/dist/scene/terrain/grass.js +48 -49
  230. package/dist/scene/terrain/grass.js.map +1 -1
  231. package/dist/scene/terrain/heightfield.js +46 -44
  232. package/dist/scene/terrain/heightfield.js.map +1 -1
  233. package/dist/scene/terrain/patch.js +20 -29
  234. package/dist/scene/terrain/patch.js.map +1 -1
  235. package/dist/scene/terrain/quadtree.js +58 -27
  236. package/dist/scene/terrain/quadtree.js.map +1 -1
  237. package/dist/scene/terrain/terrain.js +31 -45
  238. package/dist/scene/terrain/terrain.js.map +1 -1
  239. package/dist/scene/terrain-cm/grass.js +603 -0
  240. package/dist/scene/terrain-cm/grass.js.map +1 -0
  241. package/dist/scene/terrain-cm/grassmaterial.js +160 -0
  242. package/dist/scene/terrain-cm/grassmaterial.js.map +1 -0
  243. package/dist/scene/terrain-cm/terrain-cm.js +533 -0
  244. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -0
  245. package/dist/scene/water.js +378 -0
  246. package/dist/scene/water.js.map +1 -0
  247. package/dist/shaders/atmosphere.js +957 -0
  248. package/dist/shaders/atmosphere.js.map +1 -0
  249. package/dist/shaders/fog.js +116 -0
  250. package/dist/shaders/fog.js.map +1 -0
  251. package/dist/shaders/misc.js.map +1 -1
  252. package/dist/shaders/noise.js +217 -8
  253. package/dist/shaders/noise.js.map +1 -1
  254. package/dist/shaders/pbr.js.map +1 -1
  255. package/dist/shaders/shadow.js +8 -8
  256. package/dist/shaders/shadow.js.map +1 -1
  257. package/dist/shaders/ssr.js +87 -39
  258. package/dist/shaders/ssr.js.map +1 -1
  259. package/dist/shaders/temporal.js +216 -0
  260. package/dist/shaders/temporal.js.map +1 -0
  261. package/dist/shaders/water.js +42 -20
  262. package/dist/shaders/water.js.map +1 -1
  263. package/dist/shadow/esm.js +31 -13
  264. package/dist/shadow/esm.js.map +1 -1
  265. package/dist/shadow/pcf_opt.js +12 -13
  266. package/dist/shadow/pcf_opt.js.map +1 -1
  267. package/dist/shadow/pcf_pd.js +12 -13
  268. package/dist/shadow/pcf_pd.js.map +1 -1
  269. package/dist/shadow/shader.js +38 -0
  270. package/dist/shadow/shader.js.map +1 -0
  271. package/dist/shadow/shadow_impl.js.map +1 -1
  272. package/dist/shadow/shadowmapper.js +67 -26
  273. package/dist/shadow/shadowmapper.js.map +1 -1
  274. package/dist/shadow/ssm.js +15 -16
  275. package/dist/shadow/ssm.js.map +1 -1
  276. package/dist/shadow/vsm.js +33 -16
  277. package/dist/shadow/vsm.js.map +1 -1
  278. package/dist/shapes/box.js +181 -83
  279. package/dist/shapes/box.js.map +1 -1
  280. package/dist/shapes/cylinder.js +101 -43
  281. package/dist/shapes/cylinder.js.map +1 -1
  282. package/dist/shapes/plane.js +70 -29
  283. package/dist/shapes/plane.js.map +1 -1
  284. package/dist/shapes/shape.js +120 -17
  285. package/dist/shapes/shape.js.map +1 -1
  286. package/dist/shapes/sphere.js +78 -44
  287. package/dist/shapes/sphere.js.map +1 -1
  288. package/dist/shapes/tetrahedron.js +256 -0
  289. package/dist/shapes/tetrahedron.js.map +1 -0
  290. package/dist/shapes/torus.js +76 -55
  291. package/dist/shapes/torus.js.map +1 -1
  292. package/dist/src/animation/animation.js +127 -0
  293. package/dist/src/animation/animation.js.map +1 -0
  294. package/dist/src/animation/animationset.js +255 -0
  295. package/dist/src/animation/animationset.js.map +1 -0
  296. package/dist/src/animation/animationtrack.js +34 -0
  297. package/dist/src/animation/animationtrack.js.map +1 -0
  298. package/dist/src/animation/eulerrotationtrack.js +52 -0
  299. package/dist/src/animation/eulerrotationtrack.js.map +1 -0
  300. package/dist/src/animation/morphtarget.js +93 -0
  301. package/dist/src/animation/morphtarget.js.map +1 -0
  302. package/dist/src/animation/morphtrack.js +70 -0
  303. package/dist/src/animation/morphtrack.js.map +1 -0
  304. package/dist/src/animation/proptrack.js +161 -0
  305. package/dist/src/animation/proptrack.js.map +1 -0
  306. package/dist/src/animation/rotationtrack.js +51 -0
  307. package/dist/src/animation/rotationtrack.js.map +1 -0
  308. package/dist/src/animation/scaletrack.js +50 -0
  309. package/dist/src/animation/scaletrack.js.map +1 -0
  310. package/dist/src/animation/skeleton.js +204 -0
  311. package/dist/src/animation/skeleton.js.map +1 -0
  312. package/dist/src/animation/translationtrack.js +50 -0
  313. package/dist/src/animation/translationtrack.js.map +1 -0
  314. package/dist/{app.js → src/app/app.js} +18 -40
  315. package/dist/src/app/app.js.map +1 -0
  316. package/dist/{input → src/app}/inputmgr.js +41 -16
  317. package/dist/src/app/inputmgr.js.map +1 -0
  318. package/dist/src/asset/assetmanager.js +404 -0
  319. package/dist/src/asset/assetmanager.js.map +1 -0
  320. package/dist/src/asset/builtin.js +337 -0
  321. package/dist/src/asset/builtin.js.map +1 -0
  322. package/dist/src/asset/loaders/dds/dds.js +470 -0
  323. package/dist/src/asset/loaders/dds/dds.js.map +1 -0
  324. package/dist/src/asset/loaders/dds/dds_loader.js +28 -0
  325. package/dist/src/asset/loaders/dds/dds_loader.js.map +1 -0
  326. package/dist/src/asset/loaders/gltf/gltf_loader.js +1265 -0
  327. package/dist/src/asset/loaders/gltf/gltf_loader.js.map +1 -0
  328. package/dist/src/asset/loaders/gltf/helpers.js +327 -0
  329. package/dist/src/asset/loaders/gltf/helpers.js.map +1 -0
  330. package/dist/src/asset/loaders/hdr/hdr.js +180 -0
  331. package/dist/src/asset/loaders/hdr/hdr.js.map +1 -0
  332. package/dist/src/asset/loaders/image/tga_Loader.js +116 -0
  333. package/dist/src/asset/loaders/image/tga_Loader.js.map +1 -0
  334. package/dist/src/asset/loaders/image/webimage_loader.js +63 -0
  335. package/dist/src/asset/loaders/image/webimage_loader.js.map +1 -0
  336. package/dist/src/asset/loaders/loader.js +45 -0
  337. package/dist/src/asset/loaders/loader.js.map +1 -0
  338. package/dist/src/asset/model.js +414 -0
  339. package/dist/src/asset/model.js.map +1 -0
  340. package/dist/{blitter/depthlimitedgaussion.js → src/blitter/bilateralblur.js} +1 -2
  341. package/dist/src/blitter/bilateralblur.js.map +1 -0
  342. package/dist/src/blitter/blitter.js +390 -0
  343. package/dist/src/blitter/blitter.js.map +1 -0
  344. package/dist/src/blitter/box.js +118 -0
  345. package/dist/src/blitter/box.js.map +1 -0
  346. package/dist/src/blitter/copy.js +22 -0
  347. package/dist/src/blitter/copy.js.map +1 -0
  348. package/dist/src/blitter/gaussianblur.js +228 -0
  349. package/dist/src/blitter/gaussianblur.js.map +1 -0
  350. package/dist/src/camera/base.js +92 -0
  351. package/dist/src/camera/base.js.map +1 -0
  352. package/dist/src/camera/camera.js +1005 -0
  353. package/dist/src/camera/camera.js.map +1 -0
  354. package/dist/src/camera/fps.js +238 -0
  355. package/dist/src/camera/fps.js.map +1 -0
  356. package/dist/src/camera/orbit.js +245 -0
  357. package/dist/src/camera/orbit.js.map +1 -0
  358. package/dist/src/camera/orthocamera.js +167 -0
  359. package/dist/src/camera/orthocamera.js.map +1 -0
  360. package/dist/src/camera/perspectivecamera.js +141 -0
  361. package/dist/src/camera/perspectivecamera.js.map +1 -0
  362. package/dist/src/index.js +120 -0
  363. package/dist/src/index.js.map +1 -0
  364. package/dist/src/material/blinn.js +81 -0
  365. package/dist/src/material/blinn.js.map +1 -0
  366. package/dist/src/material/grassmaterial.js +113 -0
  367. package/dist/src/material/grassmaterial.js.map +1 -0
  368. package/dist/src/material/lambert.js +92 -0
  369. package/dist/src/material/lambert.js.map +1 -0
  370. package/dist/src/material/material.js +301 -0
  371. package/dist/src/material/material.js.map +1 -0
  372. package/dist/src/material/meshmaterial.js +704 -0
  373. package/dist/src/material/meshmaterial.js.map +1 -0
  374. package/dist/src/material/mixins/albedocolor.js +76 -0
  375. package/dist/src/material/mixins/albedocolor.js.map +1 -0
  376. package/dist/src/material/mixins/foliage.js +47 -0
  377. package/dist/src/material/mixins/foliage.js.map +1 -0
  378. package/dist/src/material/mixins/lightmodel/blinnphong.js +112 -0
  379. package/dist/src/material/mixins/lightmodel/blinnphong.js.map +1 -0
  380. package/dist/src/material/mixins/lightmodel/lambert.js +58 -0
  381. package/dist/src/material/mixins/lightmodel/lambert.js.map +1 -0
  382. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +178 -0
  383. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -0
  384. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +139 -0
  385. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -0
  386. package/dist/src/material/mixins/lit.js +476 -0
  387. package/dist/src/material/mixins/lit.js.map +1 -0
  388. package/dist/src/material/mixins/pbr/common.js +918 -0
  389. package/dist/src/material/mixins/pbr/common.js.map +1 -0
  390. package/dist/src/material/mixins/texture.js +172 -0
  391. package/dist/src/material/mixins/texture.js.map +1 -0
  392. package/dist/src/material/mixins/vertexcolor.js +56 -0
  393. package/dist/src/material/mixins/vertexcolor.js.map +1 -0
  394. package/dist/src/material/particle.js +178 -0
  395. package/dist/src/material/particle.js.map +1 -0
  396. package/dist/src/material/pbrmr.js +97 -0
  397. package/dist/src/material/pbrmr.js.map +1 -0
  398. package/dist/src/material/pbrsg.js +97 -0
  399. package/dist/src/material/pbrsg.js.map +1 -0
  400. package/dist/src/material/shader/helper.js +1209 -0
  401. package/dist/src/material/shader/helper.js.map +1 -0
  402. package/dist/src/material/terrain-cm.js +606 -0
  403. package/dist/src/material/terrain-cm.js.map +1 -0
  404. package/dist/src/material/terrainmaterial.js +375 -0
  405. package/dist/src/material/terrainmaterial.js.map +1 -0
  406. package/dist/src/material/unlit.js +41 -0
  407. package/dist/src/material/unlit.js.map +1 -0
  408. package/dist/src/material/water.js +417 -0
  409. package/dist/src/material/water.js.map +1 -0
  410. package/dist/src/posteffect/bloom.js +361 -0
  411. package/dist/src/posteffect/bloom.js.map +1 -0
  412. package/dist/src/posteffect/compositor.js +226 -0
  413. package/dist/src/posteffect/compositor.js.map +1 -0
  414. package/dist/src/posteffect/fxaa.js +273 -0
  415. package/dist/src/posteffect/fxaa.js.map +1 -0
  416. package/dist/src/posteffect/grayscale.js +69 -0
  417. package/dist/src/posteffect/grayscale.js.map +1 -0
  418. package/dist/src/posteffect/motionblur.js +96 -0
  419. package/dist/src/posteffect/motionblur.js.map +1 -0
  420. package/dist/src/posteffect/posteffect.js +126 -0
  421. package/dist/src/posteffect/posteffect.js.map +1 -0
  422. package/dist/src/posteffect/sao.js +324 -0
  423. package/dist/src/posteffect/sao.js.map +1 -0
  424. package/dist/src/posteffect/ssr.js +489 -0
  425. package/dist/src/posteffect/ssr.js.map +1 -0
  426. package/dist/src/posteffect/taa.js +172 -0
  427. package/dist/src/posteffect/taa.js.map +1 -0
  428. package/dist/src/posteffect/tonemap.js +94 -0
  429. package/dist/src/posteffect/tonemap.js.map +1 -0
  430. package/dist/src/render/abuffer_oit.js +361 -0
  431. package/dist/src/render/abuffer_oit.js.map +1 -0
  432. package/dist/src/render/clipmap.js +851 -0
  433. package/dist/src/render/clipmap.js.map +1 -0
  434. package/dist/src/render/cluster_light.js +333 -0
  435. package/dist/src/render/cluster_light.js.map +1 -0
  436. package/dist/src/render/cull_visitor.js +187 -0
  437. package/dist/src/render/cull_visitor.js.map +1 -0
  438. package/dist/src/render/depthpass.js +68 -0
  439. package/dist/src/render/depthpass.js.map +1 -0
  440. package/dist/src/render/drawable_mixin.js +227 -0
  441. package/dist/src/render/drawable_mixin.js.map +1 -0
  442. package/dist/src/render/envlight.js +463 -0
  443. package/dist/src/render/envlight.js.map +1 -0
  444. package/dist/src/render/fbm_wavegenerator.js +251 -0
  445. package/dist/src/render/fbm_wavegenerator.js.map +1 -0
  446. package/dist/src/render/fft_wavegenerator.js +1006 -0
  447. package/dist/src/render/fft_wavegenerator.js.map +1 -0
  448. package/dist/src/render/fullscreenquad.js +38 -0
  449. package/dist/src/render/fullscreenquad.js.map +1 -0
  450. package/dist/src/render/gerstner_wavegenerator.js +314 -0
  451. package/dist/src/render/gerstner_wavegenerator.js.map +1 -0
  452. package/dist/src/render/globalbindgroup_allocator.js +60 -0
  453. package/dist/src/render/globalbindgroup_allocator.js.map +1 -0
  454. package/dist/src/render/hzb.js +273 -0
  455. package/dist/src/render/hzb.js.map +1 -0
  456. package/dist/src/render/lightpass.js +172 -0
  457. package/dist/src/render/lightpass.js.map +1 -0
  458. package/dist/src/render/objectcolorpass.js +51 -0
  459. package/dist/src/render/objectcolorpass.js.map +1 -0
  460. package/dist/src/render/primitive.js +364 -0
  461. package/dist/src/render/primitive.js.map +1 -0
  462. package/dist/src/render/render_queue.js +467 -0
  463. package/dist/src/render/render_queue.js.map +1 -0
  464. package/dist/src/render/renderbundle_wrapper.js +152 -0
  465. package/dist/src/render/renderbundle_wrapper.js.map +1 -0
  466. package/dist/src/render/renderer.js +455 -0
  467. package/dist/src/render/renderer.js.map +1 -0
  468. package/dist/src/render/renderpass.js +200 -0
  469. package/dist/src/render/renderpass.js.map +1 -0
  470. package/dist/src/render/shadowmap_pass.js +56 -0
  471. package/dist/src/render/shadowmap_pass.js.map +1 -0
  472. package/dist/src/render/sky.js +1103 -0
  473. package/dist/src/render/sky.js.map +1 -0
  474. package/dist/src/render/weightedblended_oit.js +168 -0
  475. package/dist/src/render/weightedblended_oit.js.map +1 -0
  476. package/dist/src/scene/batchgroup.js +162 -0
  477. package/dist/src/scene/batchgroup.js.map +1 -0
  478. package/dist/src/scene/environment.js +209 -0
  479. package/dist/src/scene/environment.js.map +1 -0
  480. package/dist/src/scene/graph_node.js +72 -0
  481. package/dist/src/scene/graph_node.js.map +1 -0
  482. package/dist/src/scene/light.js +416 -0
  483. package/dist/src/scene/light.js.map +1 -0
  484. package/dist/src/scene/mesh.js +341 -0
  485. package/dist/src/scene/mesh.js.map +1 -0
  486. package/dist/src/scene/octree.js +649 -0
  487. package/dist/src/scene/octree.js.map +1 -0
  488. package/dist/src/scene/particlesys.js +738 -0
  489. package/dist/src/scene/particlesys.js.map +1 -0
  490. package/dist/src/scene/raycast_visitor.js +103 -0
  491. package/dist/src/scene/raycast_visitor.js.map +1 -0
  492. package/dist/src/scene/scene.js +284 -0
  493. package/dist/src/scene/scene.js.map +1 -0
  494. package/dist/src/scene/scene_node.js +732 -0
  495. package/dist/src/scene/scene_node.js.map +1 -0
  496. package/dist/src/scene/terrain/grass.js +278 -0
  497. package/dist/src/scene/terrain/grass.js.map +1 -0
  498. package/dist/src/scene/terrain/heightfield.js +475 -0
  499. package/dist/src/scene/terrain/heightfield.js.map +1 -0
  500. package/dist/src/scene/terrain/patch.js +530 -0
  501. package/dist/src/scene/terrain/patch.js.map +1 -0
  502. package/dist/src/scene/terrain/quadtree.js +461 -0
  503. package/dist/src/scene/terrain/quadtree.js.map +1 -0
  504. package/dist/src/scene/terrain/terrain.js +246 -0
  505. package/dist/src/scene/terrain/terrain.js.map +1 -0
  506. package/dist/src/scene/terrain-cm/grass.js +594 -0
  507. package/dist/src/scene/terrain-cm/grass.js.map +1 -0
  508. package/dist/src/scene/terrain-cm/grassmaterial.js +159 -0
  509. package/dist/src/scene/terrain-cm/grassmaterial.js.map +1 -0
  510. package/dist/src/scene/terrain-cm/terrain-cm.js +538 -0
  511. package/dist/src/scene/terrain-cm/terrain-cm.js.map +1 -0
  512. package/dist/src/scene/water.js +374 -0
  513. package/dist/src/scene/water.js.map +1 -0
  514. package/dist/src/shaders/atmosphere.js +957 -0
  515. package/dist/src/shaders/atmosphere.js.map +1 -0
  516. package/dist/src/shaders/fog.js +112 -0
  517. package/dist/src/shaders/fog.js.map +1 -0
  518. package/dist/src/shaders/misc.js +266 -0
  519. package/dist/src/shaders/misc.js.map +1 -0
  520. package/dist/src/shaders/noise.js +222 -0
  521. package/dist/src/shaders/noise.js.map +1 -0
  522. package/dist/src/shaders/pbr.js +51 -0
  523. package/dist/src/shaders/pbr.js.map +1 -0
  524. package/dist/src/shaders/shadow.js +636 -0
  525. package/dist/src/shaders/shadow.js.map +1 -0
  526. package/dist/src/shaders/ssr.js +490 -0
  527. package/dist/src/shaders/ssr.js.map +1 -0
  528. package/dist/src/shaders/temporal.js +215 -0
  529. package/dist/src/shaders/temporal.js.map +1 -0
  530. package/dist/src/shaders/water.js +756 -0
  531. package/dist/src/shaders/water.js.map +1 -0
  532. package/dist/src/shadow/esm.js +237 -0
  533. package/dist/src/shadow/esm.js.map +1 -0
  534. package/dist/src/shadow/pcf_opt.js +181 -0
  535. package/dist/src/shadow/pcf_opt.js.map +1 -0
  536. package/dist/src/shadow/pcf_pd.js +189 -0
  537. package/dist/src/shadow/pcf_pd.js.map +1 -0
  538. package/dist/src/shadow/shader.js +37 -0
  539. package/dist/src/shadow/shader.js.map +1 -0
  540. package/dist/src/shadow/shadow_impl.js +15 -0
  541. package/dist/src/shadow/shadow_impl.js.map +1 -0
  542. package/dist/src/shadow/shadowmapper.js +790 -0
  543. package/dist/src/shadow/shadowmapper.js.map +1 -0
  544. package/dist/src/shadow/ssm.js +159 -0
  545. package/dist/src/shadow/ssm.js.map +1 -0
  546. package/dist/src/shadow/vsm.js +297 -0
  547. package/dist/src/shadow/vsm.js.map +1 -0
  548. package/dist/src/shapes/box.js +386 -0
  549. package/dist/src/shapes/box.js.map +1 -0
  550. package/dist/src/shapes/cylinder.js +125 -0
  551. package/dist/src/shapes/cylinder.js.map +1 -0
  552. package/dist/src/shapes/plane.js +88 -0
  553. package/dist/src/shapes/plane.js.map +1 -0
  554. package/dist/src/shapes/shape.js +87 -0
  555. package/dist/src/shapes/shape.js.map +1 -0
  556. package/dist/src/shapes/sphere.js +114 -0
  557. package/dist/src/shapes/sphere.js.map +1 -0
  558. package/dist/src/shapes/tetrahedron.js +188 -0
  559. package/dist/src/shapes/tetrahedron.js.map +1 -0
  560. package/dist/src/shapes/torus.js +111 -0
  561. package/dist/src/shapes/torus.js.map +1 -0
  562. package/dist/src/utility/aabbtree.js +400 -0
  563. package/dist/src/utility/aabbtree.js.map +1 -0
  564. package/dist/src/utility/bounding_volume.js +29 -0
  565. package/dist/src/utility/bounding_volume.js.map +1 -0
  566. package/dist/src/utility/debug.js +28 -0
  567. package/dist/src/utility/debug.js.map +1 -0
  568. package/dist/src/utility/draco/decoder.js +116 -0
  569. package/dist/src/utility/draco/decoder.js.map +1 -0
  570. package/dist/src/utility/misc.js +105 -0
  571. package/dist/src/utility/misc.js.map +1 -0
  572. package/dist/src/utility/panorama.js +163 -0
  573. package/dist/src/utility/panorama.js.map +1 -0
  574. package/dist/src/utility/pmrem.js +354 -0
  575. package/dist/src/utility/pmrem.js.map +1 -0
  576. package/dist/src/utility/rendermipmap.js +115 -0
  577. package/dist/src/utility/rendermipmap.js.map +1 -0
  578. package/dist/src/utility/serialization/json.js +402 -0
  579. package/dist/src/utility/serialization/json.js.map +1 -0
  580. package/dist/src/utility/serialization/manager.js +623 -0
  581. package/dist/src/utility/serialization/manager.js.map +1 -0
  582. package/dist/src/utility/serialization/scene/animation.js +248 -0
  583. package/dist/src/utility/serialization/scene/animation.js.map +1 -0
  584. package/dist/src/utility/serialization/scene/batch.js +59 -0
  585. package/dist/src/utility/serialization/scene/batch.js.map +1 -0
  586. package/dist/src/utility/serialization/scene/camera.js +790 -0
  587. package/dist/src/utility/serialization/scene/camera.js.map +1 -0
  588. package/dist/src/utility/serialization/scene/common.js +222 -0
  589. package/dist/src/utility/serialization/scene/common.js.map +1 -0
  590. package/dist/src/utility/serialization/scene/light.js +575 -0
  591. package/dist/src/utility/serialization/scene/light.js.map +1 -0
  592. package/dist/src/utility/serialization/scene/material.js +1111 -0
  593. package/dist/src/utility/serialization/scene/material.js.map +1 -0
  594. package/dist/src/utility/serialization/scene/mesh.js +148 -0
  595. package/dist/src/utility/serialization/scene/mesh.js.map +1 -0
  596. package/dist/src/utility/serialization/scene/misc.js +39 -0
  597. package/dist/src/utility/serialization/scene/misc.js.map +1 -0
  598. package/dist/src/utility/serialization/scene/node.js +451 -0
  599. package/dist/src/utility/serialization/scene/node.js.map +1 -0
  600. package/dist/src/utility/serialization/scene/particle.js +425 -0
  601. package/dist/src/utility/serialization/scene/particle.js.map +1 -0
  602. package/dist/src/utility/serialization/scene/primitive.js +692 -0
  603. package/dist/src/utility/serialization/scene/primitive.js.map +1 -0
  604. package/dist/src/utility/serialization/scene/scene.js +704 -0
  605. package/dist/src/utility/serialization/scene/scene.js.map +1 -0
  606. package/dist/src/utility/serialization/scene/terrain.js +488 -0
  607. package/dist/src/utility/serialization/scene/terrain.js.map +1 -0
  608. package/dist/src/utility/serialization/scene/water.js +465 -0
  609. package/dist/src/utility/serialization/scene/water.js.map +1 -0
  610. package/dist/src/utility/shprojector.js +297 -0
  611. package/dist/src/utility/shprojector.js.map +1 -0
  612. package/dist/{material/mixins → src/utility/textures}/ggxlut.js +1 -1
  613. package/dist/src/utility/textures/ggxlut.js.map +1 -0
  614. package/dist/src/utility/textures/gradientnoise.js +62 -0
  615. package/dist/src/utility/textures/gradientnoise.js.map +1 -0
  616. package/dist/src/utility/textures/randomnoise.js +41 -0
  617. package/dist/src/utility/textures/randomnoise.js.map +1 -0
  618. package/dist/src/values.js +162 -0
  619. package/dist/src/values.js.map +1 -0
  620. package/dist/utility/aabbtree.js +15 -5
  621. package/dist/utility/aabbtree.js.map +1 -1
  622. package/dist/utility/blueprint/common/constants.js +851 -0
  623. package/dist/utility/blueprint/common/constants.js.map +1 -0
  624. package/dist/utility/blueprint/common/math.js +2045 -0
  625. package/dist/utility/blueprint/common/math.js.map +1 -0
  626. package/dist/utility/blueprint/common.js +7 -0
  627. package/dist/utility/blueprint/common.js.map +1 -0
  628. package/dist/utility/blueprint/material/common.js +7 -0
  629. package/dist/utility/blueprint/material/common.js.map +1 -0
  630. package/dist/utility/blueprint/material/func.js +521 -0
  631. package/dist/utility/blueprint/material/func.js.map +1 -0
  632. package/dist/utility/blueprint/material/inputs.js +1659 -0
  633. package/dist/utility/blueprint/material/inputs.js.map +1 -0
  634. package/dist/utility/blueprint/material/ir.js +1311 -0
  635. package/dist/utility/blueprint/material/ir.js.map +1 -0
  636. package/dist/utility/blueprint/material/pbr.js +362 -0
  637. package/dist/utility/blueprint/material/pbr.js.map +1 -0
  638. package/dist/utility/blueprint/material/texture.js +1099 -0
  639. package/dist/utility/blueprint/material/texture.js.map +1 -0
  640. package/dist/utility/blueprint/node.js +187 -0
  641. package/dist/utility/blueprint/node.js.map +1 -0
  642. package/dist/utility/bounding_volume.js +0 -1
  643. package/dist/utility/bounding_volume.js.map +1 -1
  644. package/dist/utility/debug.js +26 -0
  645. package/dist/utility/debug.js.map +1 -0
  646. package/dist/utility/draco/decoder.js +1 -1
  647. package/dist/utility/draco/decoder.js.map +1 -1
  648. package/dist/utility/misc.js +18 -6
  649. package/dist/utility/misc.js.map +1 -1
  650. package/dist/utility/panorama.js +8 -6
  651. package/dist/utility/panorama.js.map +1 -1
  652. package/dist/utility/pmrem.js +30 -18
  653. package/dist/utility/pmrem.js.map +1 -1
  654. package/dist/utility/rendermipmap.js +116 -0
  655. package/dist/utility/rendermipmap.js.map +1 -0
  656. package/dist/utility/serialization/blueprint/constants.js +255 -0
  657. package/dist/utility/serialization/blueprint/constants.js.map +1 -0
  658. package/dist/utility/serialization/blueprint/material/constants.js +203 -0
  659. package/dist/utility/serialization/blueprint/material/constants.js.map +1 -0
  660. package/dist/utility/serialization/blueprint/material/texture.js +165 -0
  661. package/dist/utility/serialization/blueprint/material/texture.js.map +1 -0
  662. package/dist/utility/serialization/json.js +402 -0
  663. package/dist/utility/serialization/json.js.map +1 -0
  664. package/dist/utility/serialization/manager.js +1176 -0
  665. package/dist/utility/serialization/manager.js.map +1 -0
  666. package/dist/utility/serialization/scene/animation.js +699 -0
  667. package/dist/utility/serialization/scene/animation.js.map +1 -0
  668. package/dist/utility/serialization/scene/batch.js +53 -0
  669. package/dist/utility/serialization/scene/batch.js.map +1 -0
  670. package/dist/utility/serialization/scene/camera.js +808 -0
  671. package/dist/utility/serialization/scene/camera.js.map +1 -0
  672. package/dist/utility/serialization/scene/common.js +224 -0
  673. package/dist/utility/serialization/scene/common.js.map +1 -0
  674. package/dist/utility/serialization/scene/light.js +589 -0
  675. package/dist/utility/serialization/scene/light.js.map +1 -0
  676. package/dist/utility/serialization/scene/material.js +942 -0
  677. package/dist/utility/serialization/scene/material.js.map +1 -0
  678. package/dist/utility/serialization/scene/mesh.js +374 -0
  679. package/dist/utility/serialization/scene/mesh.js.map +1 -0
  680. package/dist/utility/serialization/scene/misc.js +39 -0
  681. package/dist/utility/serialization/scene/misc.js.map +1 -0
  682. package/dist/utility/serialization/scene/node.js +391 -0
  683. package/dist/utility/serialization/scene/node.js.map +1 -0
  684. package/dist/utility/serialization/scene/particle.js +425 -0
  685. package/dist/utility/serialization/scene/particle.js.map +1 -0
  686. package/dist/utility/serialization/scene/primitive.js +582 -0
  687. package/dist/utility/serialization/scene/primitive.js.map +1 -0
  688. package/dist/utility/serialization/scene/scene.js +763 -0
  689. package/dist/utility/serialization/scene/scene.js.map +1 -0
  690. package/dist/utility/serialization/scene/terrain.js +495 -0
  691. package/dist/utility/serialization/scene/terrain.js.map +1 -0
  692. package/dist/utility/serialization/scene/water.js +465 -0
  693. package/dist/utility/serialization/scene/water.js.map +1 -0
  694. package/dist/utility/shprojector.js +313 -0
  695. package/dist/utility/shprojector.js.map +1 -0
  696. package/dist/utility/textures/ggxlut.js +4 -5
  697. package/dist/utility/textures/ggxlut.js.map +1 -1
  698. package/dist/utility/textures/gradientnoise.js +2 -1
  699. package/dist/utility/textures/gradientnoise.js.map +1 -1
  700. package/dist/utility/textures/randomnoise.js +1 -0
  701. package/dist/utility/textures/randomnoise.js.map +1 -1
  702. package/dist/values.js +91 -4
  703. package/dist/values.js.map +1 -1
  704. package/package.json +29 -15
  705. package/dist/app.js.map +0 -1
  706. package/dist/blitter/depthlimitedgaussion.js.map +0 -1
  707. package/dist/input/inputmgr.js.map +0 -1
  708. package/dist/material/mixins/ggxlut.js.map +0 -1
  709. package/dist/posteffect/water.js +0 -508
  710. package/dist/posteffect/water.js.map +0 -1
  711. package/dist/render/oit.js +0 -16
  712. package/dist/render/oit.js.map +0 -1
  713. package/dist/render/scatteringlut.js +0 -634
  714. package/dist/render/scatteringlut.js.map +0 -1
  715. package/dist/render/watermesh.js +0 -193
  716. package/dist/render/watermesh.js.map +0 -1
  717. package/dist/render/wavegenerator.js +0 -8
  718. package/dist/render/wavegenerator.js.map +0 -1
  719. package/dist/scene/xform.js +0 -247
  720. package/dist/scene/xform.js.map +0 -1
  721. package/dist/utility/shprojection.js +0 -442
  722. package/dist/utility/shprojection.js.map +0 -1
@@ -0,0 +1,1005 @@
1
+ import { halton23, Matrix4x4, DRef, Vector4, Vector2, Plane, Vector3, Ray, Frustum } from '@zephyr3d/base';
2
+ import { SceneNode } from '../scene/scene_node.js';
3
+ import { Application } from '../app/app.js';
4
+ import { Compositor } from '../posteffect/compositor.js';
5
+ import { TAA } from '../posteffect/taa.js';
6
+ import { SSR } from '../posteffect/ssr.js';
7
+ import { Tonemap } from '../posteffect/tonemap.js';
8
+ import { FXAA } from '../posteffect/fxaa.js';
9
+ import { Bloom } from '../posteffect/bloom.js';
10
+ import { SAO } from '../posteffect/sao.js';
11
+ import { MotionBlur } from '../posteffect/motionblur.js';
12
+
13
+ /**
14
+ * The camera node class
15
+ * @public
16
+ */ class Camera extends SceneNode {
17
+ /** @internal */ static _halton23 = halton23(16);
18
+ /** @internal */ static _historyData = new WeakMap();
19
+ /** @internal */ _projMatrix;
20
+ /** @internal */ _invProjMatrix;
21
+ /** @internal */ _viewMatrix;
22
+ /** @internal */ _viewProjMatrix;
23
+ /** @internal */ _rotationMatrix;
24
+ /** @internal */ _invViewProjMatrix;
25
+ /** @internal */ _clipPlane;
26
+ /** @internal */ _controller;
27
+ /** @internal */ _frustum;
28
+ /** @internal */ _frustumV;
29
+ /** @internal */ _dirty;
30
+ /** @internal */ _viewport;
31
+ /** @internal */ _scissor;
32
+ /** @internal */ _clipMask;
33
+ /** @internal */ _oit;
34
+ /** @internal */ _depthPrePass;
35
+ /** @internal */ _commandBufferReuse;
36
+ /** @internal */ _HiZ;
37
+ /** @internal */ _toneMap;
38
+ /** @internal */ _postEffectTonemap;
39
+ /** @internal */ _tonemapExposure;
40
+ /** @internal */ _motionBlur;
41
+ /** @internal */ _postEffectMotionBlur;
42
+ /** @internal */ _motionBlurStrength;
43
+ /** @internal */ _bloom;
44
+ /** @internal */ _postEffectBloom;
45
+ /** @internal */ _bloomMaxDownsampleLevels;
46
+ /** @internal */ _bloomDownsampleLimit;
47
+ /** @internal */ _bloomThreshold;
48
+ /** @internal */ _bloomThresholdKnee;
49
+ /** @internal */ _bloomIntensity;
50
+ /** @internal */ _FXAA;
51
+ /** @internal */ _postEffectFXAA;
52
+ /** @internal */ _TAA;
53
+ /** @internal */ _postEffectTAA;
54
+ /** @internal */ _TAADebug;
55
+ /** @internal */ _SSR;
56
+ /** @internal */ _postEffectSSR;
57
+ /** @internal */ _ssrParams;
58
+ /** @internal */ _ssrMaxRoughness;
59
+ /** @internal */ _ssrRoughnessFactor;
60
+ /** @internal */ _ssrStride;
61
+ /** @internal */ _ssrCalcThickness;
62
+ /** @internal */ _ssrBlurriness;
63
+ /** @internal */ _ssrBlurDepthCutoff;
64
+ /** @internal */ _ssrBlurKernelSize;
65
+ /** @internal */ _ssrBlurStdDev;
66
+ /** @internal */ _SSAO;
67
+ /** @internal */ _postEffectSSAO;
68
+ /** @internal */ _SSAOScale;
69
+ /** @internal */ _SSAOBias;
70
+ /** @internal */ _SSAORadius;
71
+ /** @internal */ _SSAOIntensity;
72
+ /** @internal */ _SSAOBlurDepthCutoff;
73
+ /** @internal */ _pickResultPromise;
74
+ /** @internal */ _pickResultResolve;
75
+ /** @internal */ _pickPosX;
76
+ /** @internal */ _pickPosY;
77
+ /** @internal */ _pickResult;
78
+ /** @internal */ _jitterValue;
79
+ /** @internal */ _prevJitterValue;
80
+ /** @internal */ _jitteredVPMatrix;
81
+ /** @internal */ _jitteredInvVPMatrix;
82
+ /** @internal */ _prevVPMatrix;
83
+ /** @internal */ _prevPosition;
84
+ /** @internal */ _prevJitteredVPMatrix;
85
+ /** @internal */ _compositor;
86
+ /**
87
+ * Creates a new camera node
88
+ *
89
+ * @param scene - The scene that the camera belongs to
90
+ * @param projectionMatrix - Projection matrix for this camera
91
+ */ constructor(scene, projectionMatrix){
92
+ super(scene);
93
+ this._projMatrix = projectionMatrix || Matrix4x4.identity();
94
+ this._invProjMatrix = Matrix4x4.invert(this._projMatrix);
95
+ this._viewMatrix = Matrix4x4.identity();
96
+ this._viewProjMatrix = Matrix4x4.identity();
97
+ this._invViewProjMatrix = Matrix4x4.identity();
98
+ this._clipPlane = null;
99
+ this._dirty = true;
100
+ this._controller = null;
101
+ this._viewport = null;
102
+ this._scissor = null;
103
+ this._clipMask = 0;
104
+ this._frustum = null;
105
+ this._frustumV = null;
106
+ this._oit = new DRef();
107
+ this._depthPrePass = false;
108
+ this._HiZ = false;
109
+ this._toneMap = true;
110
+ this._postEffectTonemap = new DRef();
111
+ this._tonemapExposure = 1;
112
+ this._motionBlur = false;
113
+ this._postEffectMotionBlur = new DRef();
114
+ this._motionBlurStrength = 1;
115
+ this._bloom = false;
116
+ this._postEffectBloom = new DRef();
117
+ this._bloomMaxDownsampleLevels = 4;
118
+ this._bloomDownsampleLimit = 32;
119
+ this._bloomThreshold = 0.8;
120
+ this._bloomThresholdKnee = 0;
121
+ this._bloomIntensity = 1;
122
+ this._FXAA = false;
123
+ this._postEffectFXAA = new DRef();
124
+ this._TAA = false;
125
+ this._postEffectTAA = new DRef();
126
+ this._TAADebug = 0;
127
+ this._SSR = false;
128
+ this._postEffectSSR = new DRef();
129
+ this._ssrParams = new Vector4(100, 120, 0.5, 0);
130
+ this._ssrMaxRoughness = 0.8;
131
+ this._ssrRoughnessFactor = 1;
132
+ this._ssrStride = 2;
133
+ this._ssrCalcThickness = false;
134
+ this._ssrBlurriness = 0.05;
135
+ this._ssrBlurDepthCutoff = 2;
136
+ this._ssrBlurKernelSize = 17;
137
+ this._ssrBlurStdDev = 10;
138
+ this._SSAO = false;
139
+ this._postEffectSSAO = new DRef();
140
+ this._SSAOScale = 10;
141
+ this._SSAOBias = 1;
142
+ this._SSAOIntensity = 0.025;
143
+ this._SSAORadius = 100;
144
+ this._SSAOBlurDepthCutoff = 2;
145
+ this._pickResult = null;
146
+ this._commandBufferReuse = true;
147
+ this._jitteredVPMatrix = new Matrix4x4();
148
+ this._jitteredInvVPMatrix = new Matrix4x4();
149
+ this._jitterValue = new Vector2(0, 0);
150
+ this._prevVPMatrix = null;
151
+ this._prevPosition = null;
152
+ this._prevJitteredVPMatrix = null;
153
+ this._prevJitterValue = null;
154
+ this._pickResultPromise = null;
155
+ this._pickResultResolve = null;
156
+ this._pickPosX = 0;
157
+ this._pickPosY = 0;
158
+ this._compositor = new Compositor();
159
+ this.updatePostProcessing();
160
+ }
161
+ clone(method, recursive) {
162
+ const other = new Camera(this.scene);
163
+ other.copyFrom(this, method, recursive);
164
+ other.parent = this.parent;
165
+ return other;
166
+ }
167
+ copyFrom(other, method, recursive) {
168
+ super.copyFrom(other, method, recursive);
169
+ this.clipPlane = other.clipPlane ? new Plane(other.clipPlane) : null;
170
+ this.HiZ = other.HiZ;
171
+ this.toneMap = other.toneMap;
172
+ this.toneMapExposure = other.toneMapExposure;
173
+ this.bloom = other.bloom;
174
+ this.FXAA = other.FXAA;
175
+ this.TAA = other.TAA;
176
+ this.TAADebug = other.TAADebug;
177
+ this.SSR = other.SSR;
178
+ this.ssrMaxRoughness = other.ssrMaxRoughness;
179
+ this.ssrRoughnessFactor = other.ssrRoughnessFactor;
180
+ this.ssrStride = other.ssrStride;
181
+ this.ssrMaxDistance = other.ssrMaxDistance;
182
+ this.ssrIterations = other.ssrIterations;
183
+ this.ssrThickness = other.ssrThickness;
184
+ this.ssrCalcThickness = other.ssrCalcThickness;
185
+ this.ssrBlurScale = other.ssrBlurScale;
186
+ this.ssrBlurDepthCutoff = other.ssrBlurDepthCutoff;
187
+ this.ssrBlurKernelSize = other.ssrBlurKernelSize;
188
+ this.depthPrePass = other.depthPrePass;
189
+ this.commandBufferReuse = other.commandBufferReuse;
190
+ this.oit = other.oit;
191
+ this.clipMask = other.clipMask;
192
+ this.viewport = other.viewport?.slice() ?? null;
193
+ this.scissor = other.scissor?.slice() ?? null;
194
+ this.setProjectionMatrix(other.getProjectionMatrix());
195
+ }
196
+ /** Compositor */ get compositor() {
197
+ return this._compositor;
198
+ }
199
+ /** Clip plane in camera space */ get clipPlane() {
200
+ return this._clipPlane;
201
+ }
202
+ set clipPlane(plane) {
203
+ this._clipPlane = plane;
204
+ this._invalidate(false);
205
+ }
206
+ /**
207
+ * Gets whether Hi-Z acceleration is enabled.
208
+ * When enabled, it can significantly improve SSR performance with minimal quality impact.
209
+ */ get HiZ() {
210
+ return this._HiZ;
211
+ }
212
+ set HiZ(val) {
213
+ this._HiZ = !!val;
214
+ }
215
+ /**
216
+ * Gets whether Tonemap is enabled.
217
+ */ get toneMap() {
218
+ return this._postEffectTonemap.get().enabled;
219
+ }
220
+ set toneMap(val) {
221
+ this._postEffectTonemap.get().enabled = !!val;
222
+ }
223
+ /**
224
+ * Gets whether motion blur is enabled
225
+ */ get motionBlur() {
226
+ return this._postEffectMotionBlur.get().enabled;
227
+ }
228
+ set motionBlur(val) {
229
+ this._postEffectMotionBlur.get().enabled = !!val;
230
+ }
231
+ /** Motion blur strength */ get motionBlurStrength() {
232
+ return this._motionBlurStrength;
233
+ }
234
+ set motionBlurStrength(val) {
235
+ this._motionBlurStrength = val;
236
+ if (this._postEffectMotionBlur.get()) {
237
+ this._postEffectMotionBlur.get().strength = this._motionBlurStrength;
238
+ }
239
+ }
240
+ /**
241
+ * Gets whether Bloom is enabled.
242
+ */ get bloom() {
243
+ return this._postEffectBloom.get().enabled;
244
+ }
245
+ set bloom(val) {
246
+ this._postEffectBloom.get().enabled = !!val;
247
+ }
248
+ /**
249
+ * Maximum bloom downsample levels
250
+ */ get bloomMaxDownsampleLevels() {
251
+ return this._bloomMaxDownsampleLevels;
252
+ }
253
+ set bloomMaxDownsampleLevels(val) {
254
+ this._bloomMaxDownsampleLevels = val;
255
+ if (this._postEffectBloom.get()) {
256
+ this._postEffectBloom.get().maxDownsampleLevel = val;
257
+ }
258
+ }
259
+ /**
260
+ * Bloom downsample limit
261
+ */ get bloomDownsampleLimit() {
262
+ return this._bloomDownsampleLimit;
263
+ }
264
+ set bloomDownsampleLimit(val) {
265
+ this._bloomDownsampleLimit = val;
266
+ if (this._postEffectBloom.get()) {
267
+ this._postEffectBloom.get().downsampleLimit = val;
268
+ }
269
+ }
270
+ /**
271
+ * Bloom threshold
272
+ */ get bloomThreshold() {
273
+ return this._bloomThreshold;
274
+ }
275
+ set bloomThreshold(val) {
276
+ this._bloomThreshold = val;
277
+ if (this._postEffectBloom.get()) {
278
+ this._postEffectBloom.get().threshold = val;
279
+ }
280
+ }
281
+ /**
282
+ * Bloom threshold knee
283
+ */ get bloomThresholdKnee() {
284
+ return this._bloomThresholdKnee;
285
+ }
286
+ set bloomThresholdKnee(val) {
287
+ this._bloomThresholdKnee = val;
288
+ if (this._postEffectBloom.get()) {
289
+ this._postEffectBloom.get().thresholdKnee = val;
290
+ }
291
+ }
292
+ /**
293
+ * Bloom intensity
294
+ */ get bloomIntensity() {
295
+ return this._bloomIntensity;
296
+ }
297
+ set bloomIntensity(val) {
298
+ this._bloomIntensity = val;
299
+ if (this._postEffectBloom.get()) {
300
+ this._postEffectBloom.get().intensity = val;
301
+ }
302
+ }
303
+ /**
304
+ * Gets whether FXAA is enabled.
305
+ */ get FXAA() {
306
+ return this._postEffectFXAA.get().enabled;
307
+ }
308
+ set FXAA(val) {
309
+ this._postEffectFXAA.get().enabled = !!val;
310
+ }
311
+ /**
312
+ * Tonemap exposure
313
+ */ get toneMapExposure() {
314
+ return this._tonemapExposure;
315
+ }
316
+ set toneMapExposure(val) {
317
+ this._tonemapExposure = val;
318
+ if (this._postEffectTonemap.get()) {
319
+ this._postEffectTonemap.get().exposure = val;
320
+ }
321
+ }
322
+ /**
323
+ * Gets whether TAA is enabled.
324
+ */ get TAA() {
325
+ return this._postEffectTAA.get().enabled;
326
+ }
327
+ set TAA(val) {
328
+ this._postEffectTAA.get().enabled = !!val;
329
+ }
330
+ /**
331
+ * Gets the debug flag for TAA
332
+ */ get TAADebug() {
333
+ return this._TAADebug;
334
+ }
335
+ set TAADebug(val) {
336
+ this._TAADebug = val;
337
+ }
338
+ /**
339
+ * Gets whether Screen Space Reflections (SSR) is enabled.
340
+ */ get SSR() {
341
+ return this._postEffectSSR.get().enabled;
342
+ }
343
+ set SSR(val) {
344
+ this._postEffectSSR.get().enabled = !!val;
345
+ }
346
+ /**
347
+ * Gets the maximum roughness value for screen space reflections.
348
+ * Controls the cutoff point where surfaces are considered too rough for SSR.
349
+ */ get ssrMaxRoughness() {
350
+ return this._ssrMaxRoughness;
351
+ }
352
+ set ssrMaxRoughness(val) {
353
+ this._ssrMaxRoughness = val;
354
+ }
355
+ /**
356
+ * Gets the roughness factor for SSR calculations.
357
+ * Affects how surface roughness influences reflection clarity.
358
+ */ get ssrRoughnessFactor() {
359
+ return this._ssrRoughnessFactor;
360
+ }
361
+ set ssrRoughnessFactor(val) {
362
+ this._ssrRoughnessFactor = val;
363
+ }
364
+ /**
365
+ * Gets the stride value for SSR ray marching.
366
+ * Controls the step size during ray marching. Larger values improve performance but may miss details.
367
+ */ get ssrStride() {
368
+ return this._ssrStride;
369
+ }
370
+ set ssrStride(val) {
371
+ this._ssrStride = val;
372
+ }
373
+ /**
374
+ * Gets the maximum distance for SSR ray marching.
375
+ * Defines how far rays will travel when searching for reflection intersections.
376
+ */ get ssrMaxDistance() {
377
+ return this._ssrParams.x;
378
+ }
379
+ set ssrMaxDistance(val) {
380
+ this._ssrParams.x = val;
381
+ }
382
+ /**
383
+ * Gets the number of iterations for SSR ray marching.
384
+ * Higher values provide more accurate reflections but impact performance.
385
+ */ get ssrIterations() {
386
+ return this._ssrParams.y;
387
+ }
388
+ set ssrIterations(val) {
389
+ this._ssrParams.y = val;
390
+ }
391
+ /**
392
+ * Gets the thickness value for SSR calculations.
393
+ * Determines the thickness threshold for surfaces when calculating reflections.
394
+ */ get ssrThickness() {
395
+ return this._ssrParams.z;
396
+ }
397
+ set ssrThickness(val) {
398
+ this._ssrParams.z = val;
399
+ }
400
+ /**
401
+ * Gets whether SSR should calculate thickness automatically.
402
+ * When enabled, the system will dynamically compute surface thickness for reflections.
403
+ */ get ssrCalcThickness() {
404
+ return this._ssrCalcThickness;
405
+ }
406
+ set ssrCalcThickness(val) {
407
+ this._ssrCalcThickness = !!val;
408
+ }
409
+ /**
410
+ * Gets the blur scale factor for SSR.
411
+ * Controls the overall intensity of the blur effect applied to reflections.
412
+ */ get ssrBlurScale() {
413
+ return this._ssrBlurriness;
414
+ }
415
+ set ssrBlurScale(val) {
416
+ this._ssrBlurriness = val;
417
+ }
418
+ /**
419
+ * Gets the depth cutoff value for SSR blur.
420
+ * Determines at what depth difference the blur effect should be reduced or eliminated.
421
+ */ get ssrBlurDepthCutoff() {
422
+ return this._ssrBlurDepthCutoff;
423
+ }
424
+ set ssrBlurDepthCutoff(val) {
425
+ this._ssrBlurDepthCutoff = val;
426
+ }
427
+ /**
428
+ * Gets the kernel size for the SSR blur effect.
429
+ * Defines the size of the blur kernel. Larger values create softer, more spread-out blur.
430
+ */ get ssrBlurKernelSize() {
431
+ return this._ssrBlurKernelSize;
432
+ }
433
+ set ssrBlurKernelSize(val) {
434
+ this._ssrBlurKernelSize = val;
435
+ }
436
+ /**
437
+ * Gets the standard deviation for the SSR Gaussian blur.
438
+ * Controls the distribution of the blur effect. Higher values create more pronounced blur.
439
+ */ get ssrBlurStdDev() {
440
+ return this._ssrBlurStdDev;
441
+ }
442
+ set ssrBlurStdDev(val) {
443
+ this._ssrBlurStdDev = val;
444
+ }
445
+ /** @internal */ get ssrParams() {
446
+ return this._ssrParams;
447
+ }
448
+ /**
449
+ * Gets whether SSAO is enabled.
450
+ */ get SSAO() {
451
+ return this._postEffectSSAO.get().enabled;
452
+ }
453
+ set SSAO(val) {
454
+ this._postEffectSSAO.get().enabled = !!val;
455
+ }
456
+ /** SSAO scale */ get SSAOScale() {
457
+ return this._SSAOScale;
458
+ }
459
+ set SSAOScale(val) {
460
+ this._SSAOScale = val;
461
+ if (this._postEffectSSAO.get()) {
462
+ this._postEffectSSAO.get().scale = val;
463
+ }
464
+ }
465
+ /** SSAO bias */ get SSAOBias() {
466
+ return this._SSAOBias;
467
+ }
468
+ set SSAOBias(val) {
469
+ this._SSAOBias = val;
470
+ if (this._postEffectSSAO.get()) {
471
+ this._postEffectSSAO.get().bias = val;
472
+ }
473
+ }
474
+ /** SSAO radius */ get SSAORadius() {
475
+ return this._SSAORadius;
476
+ }
477
+ set SSAORadius(val) {
478
+ this._SSAORadius = val;
479
+ if (this._postEffectSSAO.get()) {
480
+ this._postEffectSSAO.get().radius = val;
481
+ }
482
+ }
483
+ /** SSAO intensity */ get SSAOIntensity() {
484
+ return this._SSAOIntensity;
485
+ }
486
+ set SSAOIntensity(val) {
487
+ this._SSAOIntensity = val;
488
+ if (this._postEffectSSAO.get()) {
489
+ this._postEffectSSAO.get().intensity = val;
490
+ }
491
+ }
492
+ /** SSAO depth cutoff */ get SSAOBlurDepthCutoff() {
493
+ return this._SSAOBlurDepthCutoff;
494
+ }
495
+ set SSAOBlurDepthCutoff(val) {
496
+ this._SSAOBlurDepthCutoff = val;
497
+ if (this._postEffectSSAO.get()) {
498
+ this._postEffectSSAO.get().blurDepthCutoff = val;
499
+ }
500
+ }
501
+ /** Whether to perform a depth pass */ get depthPrePass() {
502
+ return this._depthPrePass;
503
+ }
504
+ set depthPrePass(val) {
505
+ this._depthPrePass = !!val;
506
+ }
507
+ /** Whether to allow command buffer reuse optimization */ get commandBufferReuse() {
508
+ return this._commandBufferReuse;
509
+ }
510
+ set commandBufferReuse(val) {
511
+ this._commandBufferReuse = !!val;
512
+ }
513
+ /** OIT */ get oit() {
514
+ return this._oit.get();
515
+ }
516
+ set oit(val) {
517
+ this._oit.set(val);
518
+ }
519
+ /** Clip plane mask */ get clipMask() {
520
+ return this._clipMask;
521
+ }
522
+ set clipMask(val) {
523
+ this._clipMask = val;
524
+ }
525
+ /** Viewport used for rendering, if null, use full framebuffer size */ get viewport() {
526
+ return this._viewport ? [
527
+ ...this._viewport
528
+ ] : null;
529
+ }
530
+ set viewport(rect) {
531
+ this._viewport = rect?.slice() ?? null;
532
+ }
533
+ /** Scissor rectangle used for rendering, if null, use viewport value */ get scissor() {
534
+ return this._scissor ? [
535
+ ...this._scissor
536
+ ] : null;
537
+ }
538
+ set scissor(rect) {
539
+ this._scissor = rect?.slice() ?? null;
540
+ }
541
+ /**
542
+ * Handle input events
543
+ * @param ev - input event object
544
+ * @param type - event type, default to ev.type
545
+ * @returns Boolean value indicates whether the event was handled.
546
+ */ handleEvent(ev, type) {
547
+ let handled = false;
548
+ if (this._controller) {
549
+ type = type ?? ev.type;
550
+ if (type === 'pointerdown') {
551
+ handled = this._controller.onMouseDown(ev);
552
+ } else if (type === 'pointerup') {
553
+ handled = this._controller.onMouseUp(ev);
554
+ } else if (type === 'pointermove') {
555
+ handled = this._controller.onMouseMove(ev);
556
+ } else if (type === 'wheel') {
557
+ handled = this._controller.onMouseWheel(ev);
558
+ } else if (type === 'keydown') {
559
+ handled = this._controller.onKeyDown(ev);
560
+ } else if (type === 'keyup') {
561
+ handled = this._controller.onKeyUp(ev);
562
+ }
563
+ if (handled) {
564
+ ev.preventDefault();
565
+ }
566
+ }
567
+ return handled;
568
+ }
569
+ /**
570
+ * Constructs a ray based on the given screen coordinates.
571
+ *
572
+ * @param x - The x-component of the screen coordinates, relative to the top-left corner of the viewport.
573
+ * @param y - The y-component of the screen coordinates, relative to the top-left corner of the viewport.
574
+ * @returns The ray originating from the camera position and passing through the given screen coordinates.
575
+ */ constructRay(x, y) {
576
+ const width = this.viewport ? this.viewport[2] : Application.instance.device.getViewport().width;
577
+ const height = this.viewport ? this.viewport[3] : Application.instance.device.getViewport().height;
578
+ const ndcX = 2 * x / width - 1;
579
+ const ndcY = 1 - 2 * y / height;
580
+ const nearClip = new Vector4(ndcX, ndcY, 0, 1);
581
+ const farClip = new Vector4(ndcX, ndcY, 1, 1);
582
+ const nearWorld = this.invViewProjectionMatrix.transform(nearClip);
583
+ const farWorld = this.invViewProjectionMatrix.transform(farClip);
584
+ if (this.isPerspective()) {
585
+ nearWorld.scaleBy(1 / nearWorld.w);
586
+ farWorld.scaleBy(1 / farWorld.w);
587
+ }
588
+ const vEye = this.isPerspective() ? this.getWorldPosition() : nearWorld.xyz();
589
+ const vDir = Vector3.sub(farWorld.xyz(), vEye).inplaceNormalize();
590
+ return new Ray(vEye, vDir);
591
+ }
592
+ /**
593
+ * Place the camera by specifying the camera position and the target point
594
+ * @param eye - The camera position
595
+ * @param target - The target point to look at
596
+ * @param up - The up vector
597
+ * @returns self
598
+ */ lookAt(eye, target, up) {
599
+ return this.setLocalTransform(Matrix4x4.lookAt(eye, target, up));
600
+ }
601
+ /**
602
+ * Place the camera to look at a given cube face at a given camera position
603
+ * @param face - The cube face to look at
604
+ * @param position - The camera position
605
+ * @returns self
606
+ */ lookAtCubeFace(face, position) {
607
+ return this.setLocalTransform(Matrix4x4.lookAtCubeFace(face, position ?? this.position));
608
+ }
609
+ /**
610
+ * Setup a perspective projection matrix for the camera
611
+ * @param fovY - The vertical field of view in radians.
612
+ * @param aspect - The aspect ratio
613
+ * @param zNear - The near clip plane
614
+ * @param zFar - The far clip plane
615
+ * @returns self
616
+ */ setPerspective(fovY, aspect, zNear, zFar) {
617
+ this._projMatrix.perspective(fovY, aspect, zNear, zFar);
618
+ Matrix4x4.invert(this._projMatrix, this._invProjMatrix);
619
+ this._invalidate(true);
620
+ return this;
621
+ }
622
+ /**
623
+ * Setup a orthogonal projection matrix for the camera
624
+ * @param left - Left bound of the frustum
625
+ * @param right - Right bound of the frustum
626
+ * @param bottom - Bottom bound of the frustum
627
+ * @param top - Top bound of the frustum
628
+ * @param near - Near bound of the frustum.
629
+ * @param far - Far bound of the frustum.
630
+ * @returns self
631
+ */ setOrtho(left, right, bottom, top, near, far) {
632
+ this._projMatrix.ortho(left, right, bottom, top, near, far);
633
+ Matrix4x4.invert(this._projMatrix, this._invProjMatrix);
634
+ this._invalidate(true);
635
+ return this;
636
+ }
637
+ /**
638
+ * Setup a projection matrix for the camera
639
+ * @param matrix - The projection matrix
640
+ */ setProjectionMatrix(matrix) {
641
+ if (matrix && matrix !== this._projMatrix) {
642
+ this._projMatrix = matrix;
643
+ Matrix4x4.invert(this._projMatrix, this._invProjMatrix);
644
+ this._invalidate(true);
645
+ }
646
+ }
647
+ /**
648
+ * Gets the projection matrix of the camera
649
+ * @returns The projection matrix
650
+ */ getProjectionMatrix() {
651
+ if (this._dirty) {
652
+ this._dirty = false;
653
+ this._compute();
654
+ }
655
+ return this._projMatrix;
656
+ }
657
+ /**
658
+ * Gets the inverse projection matrix of the camera
659
+ * @returns The projection matrix
660
+ */ getInvProjectionMatrix() {
661
+ if (this._dirty) {
662
+ this._dirty = false;
663
+ this._compute();
664
+ }
665
+ return this._invProjMatrix;
666
+ }
667
+ getRotationMatrix() {
668
+ const rotationMatrix = new Matrix4x4();
669
+ this.worldMatrix.decompose(null, rotationMatrix, null);
670
+ const xAxis = rotationMatrix.getRow(0).xyz().scaleBy(-1);
671
+ const yAxis = rotationMatrix.getRow(1).xyz();
672
+ const zAxis = rotationMatrix.getRow(2).xyz().scaleBy(-1);
673
+ rotationMatrix.setRow(0, new Vector4(xAxis.x, xAxis.y, xAxis.z, 0));
674
+ rotationMatrix.setRow(1, new Vector4(yAxis.x, yAxis.y, yAxis.z, 0));
675
+ rotationMatrix.setRow(2, new Vector4(zAxis.x, zAxis.y, zAxis.z, 0));
676
+ return rotationMatrix;
677
+ }
678
+ /**
679
+ * View matrix of the camera
680
+ *
681
+ * @remarks
682
+ * Camera's view matrix will transform a point from the world space to the camera space
683
+ */ get viewMatrix() {
684
+ if (this._dirty) {
685
+ this._dirty = false;
686
+ this._compute();
687
+ }
688
+ return this._viewMatrix;
689
+ }
690
+ get viewProjectionMatrix() {
691
+ if (this._dirty) {
692
+ this._dirty = false;
693
+ this._compute();
694
+ }
695
+ return this._viewProjMatrix;
696
+ }
697
+ /**
698
+ * The inverse-view-projection matrix of the camera
699
+ *
700
+ * @remarks
701
+ * The inverse-view-projection matrix transforms a point from the clip space to the camera space
702
+ */ get invViewProjectionMatrix() {
703
+ if (this._dirty) {
704
+ this._dirty = false;
705
+ this._compute();
706
+ }
707
+ return this._invViewProjMatrix;
708
+ }
709
+ /** Gets the frustum of the camera */ get frustum() {
710
+ if (this._dirty) {
711
+ this._dirty = false;
712
+ this._compute();
713
+ }
714
+ return this._frustum;
715
+ }
716
+ get frustumViewSpace() {
717
+ if (this._dirty) {
718
+ this._dirty = false;
719
+ this._compute();
720
+ }
721
+ if (!this._frustumV) {
722
+ this._frustumV = new Frustum(this._projMatrix);
723
+ }
724
+ return this._frustumV;
725
+ }
726
+ /** The camera controller */ get controller() {
727
+ return this._controller || null;
728
+ }
729
+ set controller(controller) {
730
+ this.setController(controller);
731
+ }
732
+ /** {@inheritDoc SceneNode.isCamera} */ isCamera() {
733
+ return true;
734
+ }
735
+ /** Gets the near clip plane of the camera */ getNearPlane() {
736
+ return this.getProjectionMatrix().getNearPlane();
737
+ }
738
+ /** Gets the far clip plane of the camera */ getFarPlane() {
739
+ return this.getProjectionMatrix().getFarPlane();
740
+ }
741
+ /** Gets the vertical field of view of the camera */ getFOV() {
742
+ return this.getProjectionMatrix().getFov();
743
+ }
744
+ /** Gets the tangent of half of the vertical field of view */ getTanHalfFovy() {
745
+ return this.getProjectionMatrix().getTanHalfFov();
746
+ }
747
+ /** Gets the aspect ratio */ getAspect() {
748
+ return this.getProjectionMatrix().getAspect();
749
+ }
750
+ /** Returns true if the camera is perspective */ isPerspective() {
751
+ return this.getProjectionMatrix().isPerspective();
752
+ }
753
+ /** Returns true if the camera is orthographic */ isOrtho() {
754
+ return this.getProjectionMatrix().isOrtho();
755
+ }
756
+ /**
757
+ * Gets the camera history data which is used in temporal reprojection
758
+ * @returns Camera history data
759
+ */ getHistoryData() {
760
+ let data = Camera._historyData.get(this);
761
+ if (!data) {
762
+ data = {
763
+ prevColorTex: null,
764
+ prevMotionVectorTex: null
765
+ };
766
+ Camera._historyData.set(this, data);
767
+ }
768
+ return data;
769
+ }
770
+ /**
771
+ * Clears the camera history data which is used in temporal reprojection
772
+ */ clearHistoryData() {
773
+ const data = Camera._historyData.get(this);
774
+ if (data) {
775
+ if (data.prevColorTex) {
776
+ Application.instance.device.pool.releaseTexture(data.prevColorTex);
777
+ }
778
+ if (data.prevMotionVectorTex) {
779
+ Application.instance.device.pool.releaseTexture(data.prevMotionVectorTex);
780
+ }
781
+ Camera._historyData.delete(this);
782
+ }
783
+ this._prevVPMatrix = null;
784
+ this._prevPosition = null;
785
+ this._prevJitteredVPMatrix = null;
786
+ this._prevJitterValue = null;
787
+ }
788
+ /** @internal */ updatePostProcessing() {
789
+ this._compositor.clear();
790
+ if (!this._postEffectSSR.get()) {
791
+ const ssr = new SSR();
792
+ ssr.enabled = false;
793
+ this._postEffectSSR.set(ssr);
794
+ this._compositor.appendPostEffect(ssr);
795
+ }
796
+ if (!this._postEffectSSAO.get()) {
797
+ const ssao = new SAO();
798
+ ssao.enabled = false;
799
+ ssao.scale = this._SSAOScale;
800
+ ssao.bias = this._SSAOBias;
801
+ ssao.radius = this._SSAORadius;
802
+ ssao.intensity = this._SSAOIntensity;
803
+ ssao.blurDepthCutoff = this._SSAOBlurDepthCutoff;
804
+ this._postEffectSSAO.set(ssao);
805
+ this._compositor.appendPostEffect(ssao);
806
+ }
807
+ if (!this._postEffectTAA.get()) {
808
+ const taa = new TAA();
809
+ taa.enabled = false;
810
+ this._postEffectTAA.set(taa);
811
+ this._compositor.appendPostEffect(taa);
812
+ }
813
+ if (!this._postEffectMotionBlur.get()) {
814
+ const motionBlur = new MotionBlur();
815
+ motionBlur.enabled = false;
816
+ motionBlur.strength = this._motionBlurStrength;
817
+ this._postEffectMotionBlur.set(motionBlur);
818
+ this._compositor.appendPostEffect(motionBlur);
819
+ }
820
+ if (!this._postEffectTonemap.get()) {
821
+ const tonemap = new Tonemap();
822
+ tonemap.enabled = true;
823
+ tonemap.exposure = this._tonemapExposure;
824
+ this._postEffectTonemap.set(tonemap);
825
+ this._compositor.appendPostEffect(tonemap);
826
+ }
827
+ if (!this._postEffectFXAA.get()) {
828
+ const fxaa = new FXAA();
829
+ fxaa.enabled = false;
830
+ this._postEffectFXAA.set(fxaa);
831
+ this._compositor.appendPostEffect(fxaa);
832
+ }
833
+ if (!this._postEffectBloom.get()) {
834
+ const bloom = new Bloom();
835
+ bloom.enabled = false;
836
+ bloom.maxDownsampleLevel = this._bloomMaxDownsampleLevels;
837
+ bloom.downsampleLimit = this._bloomDownsampleLimit;
838
+ bloom.threshold = this._bloomThreshold;
839
+ bloom.thresholdKnee = this._bloomThresholdKnee;
840
+ bloom.intensity = this._bloomIntensity;
841
+ this._postEffectBloom.set(bloom);
842
+ this._compositor.appendPostEffect(bloom);
843
+ }
844
+ }
845
+ /**
846
+ * Renders a scene
847
+ * @param scene - The scene to be rendered
848
+ * @param compositor - Compositor instance that will be used to apply postprocess effects
849
+ */ render(scene) {
850
+ const device = Application.instance.device;
851
+ //this.updatePostProcessing(device);
852
+ const useMotionVector = (this.TAA || this.motionBlur) && device.type !== 'webgl';
853
+ const useTAA = useMotionVector && this.TAA;
854
+ scene.dispatchEvent('startrender', scene, this, this._compositor);
855
+ if (useMotionVector) {
856
+ const width = device.getDrawingBufferWidth();
857
+ const height = device.getDrawingBufferHeight();
858
+ if (useTAA) {
859
+ const halton = Camera._halton23[device.frameInfo.frameCounter % Camera._halton23.length];
860
+ this._jitterValue.setXY(halton[0] * 2 / width, halton[1] * 2 / height);
861
+ } else {
862
+ this._jitterValue.setXY(0, 0);
863
+ }
864
+ this._jitteredVPMatrix.set(this.getProjectionMatrix());
865
+ this._jitteredVPMatrix[8] += this._jitterValue.x;
866
+ this._jitteredVPMatrix[9] += this._jitterValue.y;
867
+ this._jitteredVPMatrix.multiplyRight(this.viewMatrix);
868
+ Matrix4x4.invert(this._jitteredVPMatrix, this._jitteredInvVPMatrix);
869
+ if (!this._prevJitteredVPMatrix) {
870
+ this._prevJitteredVPMatrix = new Matrix4x4();
871
+ this._prevJitteredVPMatrix.set(this._jitteredVPMatrix);
872
+ this._prevJitterValue = new Vector2(this._jitterValue);
873
+ }
874
+ if (!this._prevVPMatrix) {
875
+ this._prevVPMatrix = new Matrix4x4();
876
+ this._prevVPMatrix.set(this.viewProjectionMatrix);
877
+ this._prevPosition = this.getWorldPosition();
878
+ }
879
+ } else {
880
+ this._jitterValue.setXY(0, 0);
881
+ this._prevVPMatrix = null;
882
+ this._prevPosition = null;
883
+ this._prevJitteredVPMatrix = null;
884
+ this._prevJitterValue = null;
885
+ this._jitteredInvVPMatrix.set(this.invViewProjectionMatrix);
886
+ }
887
+ device.pushDeviceStates();
888
+ device.reverseVertexWindingOrder(false);
889
+ scene.getRenderer().renderScene(scene, this);
890
+ device.popDeviceStates();
891
+ if (useMotionVector) {
892
+ this._prevJitteredVPMatrix.set(this._jitteredVPMatrix);
893
+ this._prevJitterValue.set(this._jitterValue);
894
+ this._prevVPMatrix.set(this.viewProjectionMatrix);
895
+ this._prevPosition = this.getWorldPosition();
896
+ }
897
+ scene.dispatchEvent('endrender', scene, this, this._compositor);
898
+ }
899
+ async pickAsync(posX, posY) {
900
+ this._pickPosX = posX;
901
+ this._pickPosY = posY;
902
+ if (!this._pickResultPromise) {
903
+ this._pickResultPromise = new Promise((resolve)=>{
904
+ this._pickResultResolve = (result)=>{
905
+ resolve(result);
906
+ this._pickResultPromise = null;
907
+ this._pickResultResolve = null;
908
+ };
909
+ });
910
+ }
911
+ return this._pickResultPromise;
912
+ }
913
+ /** @internal */ getPickResultResolveFunc() {
914
+ return this._pickResultResolve;
915
+ }
916
+ /** @internal */ getPickPosX() {
917
+ return this._pickPosX;
918
+ }
919
+ /** @internal */ getPickPosY() {
920
+ return this._pickPosY;
921
+ }
922
+ /**
923
+ * Updates the controller state
924
+ */ updateController() {
925
+ this._controller?.update();
926
+ }
927
+ /**
928
+ * Reset the controller
929
+ */ resetController() {
930
+ this._controller?.reset();
931
+ }
932
+ /** @internal */ get jitteredVPMatrix() {
933
+ return this._jitteredVPMatrix;
934
+ }
935
+ /** @internal */ get jitteredInvVPMatrix() {
936
+ return this._jitteredInvVPMatrix;
937
+ }
938
+ /** @internal */ get jitterValue() {
939
+ return this._jitterValue;
940
+ }
941
+ /** @internal */ get prevJitteredVPMatrix() {
942
+ return this._prevJitteredVPMatrix;
943
+ }
944
+ /** @internal */ get prevJitterValue() {
945
+ return this._prevJitterValue;
946
+ }
947
+ /** @internal */ get prevVPMatrix() {
948
+ return this._prevVPMatrix;
949
+ }
950
+ /** @internal */ get prevPosition() {
951
+ return this._prevPosition;
952
+ }
953
+ /** @internal */ setController(controller) {
954
+ if (this._controller !== controller) {
955
+ if (controller && controller._getCamera() && controller._getCamera() !== this) {
956
+ throw new Error('Camera.setController failed: one camera controller object cannot be assigned to multiple camera');
957
+ }
958
+ this._controller?._setCamera(null);
959
+ this._controller = controller;
960
+ this._controller?._setCamera(this);
961
+ }
962
+ return this;
963
+ }
964
+ /** @internal */ _invalidate(projectMatrixChanged) {
965
+ this._dirty = true;
966
+ if (projectMatrixChanged) {
967
+ this._frustumV = null;
968
+ }
969
+ }
970
+ /** @internal */ _compute() {
971
+ this._computeProj();
972
+ Matrix4x4.invertAffine(this.worldMatrix, this._viewMatrix);
973
+ Matrix4x4.multiply(this._projMatrix, this._viewMatrix, this._viewProjMatrix);
974
+ Matrix4x4.invert(this._viewProjMatrix, this._invViewProjMatrix);
975
+ if (!this._frustum) {
976
+ this._frustum = new Frustum(this._viewProjMatrix);
977
+ } else {
978
+ this._frustum.initWithMatrix(this._viewProjMatrix);
979
+ }
980
+ }
981
+ /** @internal */ _computeProj() {}
982
+ /** @internal */ _onTransformChanged(invalidateLocal) {
983
+ super._onTransformChanged(invalidateLocal);
984
+ this._invalidate(false);
985
+ }
986
+ /** {@inheritdoc SceneNode.dispose} */ dispose() {
987
+ this.setController(null);
988
+ this.clearHistoryData();
989
+ this._projMatrix = null;
990
+ this._viewMatrix = null;
991
+ this._viewProjMatrix = null;
992
+ this._postEffectBloom.dispose();
993
+ this._postEffectFXAA.dispose();
994
+ this._postEffectMotionBlur.dispose();
995
+ this._postEffectSSAO.dispose();
996
+ this._postEffectSSR.dispose();
997
+ this._postEffectTAA.dispose();
998
+ this._postEffectTonemap.dispose();
999
+ this._oit.dispose();
1000
+ super.dispose();
1001
+ }
1002
+ }
1003
+
1004
+ export { Camera };
1005
+ //# sourceMappingURL=camera.js.map