@zephyr3d/scene 0.9.5 → 0.9.7

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 (621) hide show
  1. package/dist/animation/joint_dynamics/controller.js +92 -32
  2. package/dist/animation/joint_dynamics/controller.js.map +1 -1
  3. package/dist/animation/joint_dynamics/convex_collider.js +320 -0
  4. package/dist/animation/joint_dynamics/convex_collider.js.map +1 -0
  5. package/dist/animation/joint_dynamics/joint_dynamics_system.js +57 -19
  6. package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
  7. package/dist/animation/joint_dynamics/solver.js +71 -27
  8. package/dist/animation/joint_dynamics/solver.js.map +1 -1
  9. package/dist/animation/joint_dynamics_modifier.js +21 -20
  10. package/dist/animation/joint_dynamics_modifier.js.map +1 -1
  11. package/dist/animation/skeleton.js +7 -10
  12. package/dist/animation/skeleton.js.map +1 -1
  13. package/dist/app/engine.js +134 -140
  14. package/dist/app/engine.js.map +1 -1
  15. package/dist/app/scriptregistry.js +47 -16
  16. package/dist/app/scriptregistry.js.map +1 -1
  17. package/dist/asset/assetmanager.js +3 -1
  18. package/dist/asset/assetmanager.js.map +1 -1
  19. package/dist/asset/model.js +346 -7
  20. package/dist/asset/model.js.map +1 -1
  21. package/dist/avatar/wardrobe.js +20 -16
  22. package/dist/avatar/wardrobe.js.map +1 -1
  23. package/dist/camera/camera.js +416 -210
  24. package/dist/camera/camera.js.map +1 -1
  25. package/dist/index.d.ts +1350 -621
  26. package/dist/index.js +6 -11
  27. package/dist/index.js.map +1 -1
  28. package/dist/material/blinn.js +1 -1
  29. package/dist/material/blinn.js.map +1 -1
  30. package/dist/material/lambert.js +1 -1
  31. package/dist/material/lambert.js.map +1 -1
  32. package/dist/material/material.js +23 -1
  33. package/dist/material/material.js.map +1 -1
  34. package/dist/material/meshmaterial.js +178 -23
  35. package/dist/material/meshmaterial.js.map +1 -1
  36. package/dist/material/mixins/albedocolor.js +4 -4
  37. package/dist/material/mixins/albedocolor.js.map +1 -1
  38. package/dist/material/mixins/lightmodel/blinnphong.js +2 -1
  39. package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
  40. package/dist/material/mixins/lightmodel/lambert.js +2 -1
  41. package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
  42. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +63 -16
  43. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
  44. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +105 -32
  45. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  46. package/dist/material/mixins/lightmodel/pbrspecularglossness.js +16 -6
  47. package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
  48. package/dist/material/mixins/lit.js +1 -1
  49. package/dist/material/mixins/lit.js.map +1 -1
  50. package/dist/material/mixins/pbr/common.js +276 -65
  51. package/dist/material/mixins/pbr/common.js.map +1 -1
  52. package/dist/material/mixins/texture.js +3 -3
  53. package/dist/material/mixins/texture.js.map +1 -1
  54. package/dist/material/mixins/vertexcolor.js +2 -2
  55. package/dist/material/mixins/vertexcolor.js.map +1 -1
  56. package/dist/material/msdf_text.js +3 -3
  57. package/dist/material/msdf_text.js.map +1 -1
  58. package/dist/material/mtoon.js +574 -0
  59. package/dist/material/mtoon.js.map +1 -0
  60. package/dist/material/pbrblueprint.js +499 -336
  61. package/dist/material/pbrblueprint.js.map +1 -1
  62. package/dist/material/pbrmr.js +118 -100
  63. package/dist/material/pbrmr.js.map +1 -1
  64. package/dist/material/pbrsg.js +1 -1
  65. package/dist/material/pbrsg.js.map +1 -1
  66. package/dist/material/shader/helper.js +324 -294
  67. package/dist/material/shader/helper.js.map +1 -1
  68. package/dist/material/subsurfaceprofile.js +812 -0
  69. package/dist/material/subsurfaceprofile.js.map +1 -0
  70. package/dist/material/unlit.js +1 -1
  71. package/dist/material/unlit.js.map +1 -1
  72. package/dist/posteffect/compositor.js +46 -11
  73. package/dist/posteffect/compositor.js.map +1 -1
  74. package/dist/posteffect/ssr.js +422 -96
  75. package/dist/posteffect/ssr.js.map +1 -1
  76. package/dist/posteffect/sss.js +1053 -0
  77. package/dist/posteffect/sss.js.map +1 -0
  78. package/dist/posteffect/taa.js +61 -60
  79. package/dist/posteffect/taa.js.map +1 -1
  80. package/dist/render/abuffer_oit.js +63 -12
  81. package/dist/render/abuffer_oit.js.map +1 -1
  82. package/dist/render/cluster_light.js +6 -5
  83. package/dist/render/cluster_light.js.map +1 -1
  84. package/dist/render/drawable.js +1 -5
  85. package/dist/render/drawable.js.map +1 -1
  86. package/dist/render/drawable_mixin.js +2 -1
  87. package/dist/render/drawable_mixin.js.map +1 -1
  88. package/dist/render/fbm_wavegenerator.js +2 -1
  89. package/dist/render/fbm_wavegenerator.js.map +1 -1
  90. package/dist/render/gerstner_wavegenerator.js +2 -1
  91. package/dist/render/gerstner_wavegenerator.js.map +1 -1
  92. package/dist/render/globalbindgroup_allocator.js +2 -1
  93. package/dist/render/globalbindgroup_allocator.js.map +1 -1
  94. package/dist/render/lightpass.js +110 -23
  95. package/dist/render/lightpass.js.map +1 -1
  96. package/dist/render/render_queue.js +51 -8
  97. package/dist/render/render_queue.js.map +1 -1
  98. package/dist/render/renderer.js +80 -66
  99. package/dist/render/renderer.js.map +1 -1
  100. package/dist/render/rendergraph/device_pool_allocator.js +8 -0
  101. package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
  102. package/dist/render/rendergraph/forward_plus_builder.js +481 -95
  103. package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
  104. package/dist/render/rendergraph/history_resource_manager.js +55 -0
  105. package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
  106. package/dist/render/rendergraph/history_resources.js +3 -1
  107. package/dist/render/rendergraph/history_resources.js.map +1 -1
  108. package/dist/render/rendergraph/types.js.map +1 -1
  109. package/dist/render/renderpass.js +10 -4
  110. package/dist/render/renderpass.js.map +1 -1
  111. package/dist/render/sky.js +31 -1
  112. package/dist/render/sky.js.map +1 -1
  113. package/dist/render/weightedblended_oit.js +23 -5
  114. package/dist/render/weightedblended_oit.js.map +1 -1
  115. package/dist/scene/basesprite.js +4 -2
  116. package/dist/scene/basesprite.js.map +1 -1
  117. package/dist/scene/batchgroup.js +3 -1
  118. package/dist/scene/batchgroup.js.map +1 -1
  119. package/dist/scene/environment.js +11 -1
  120. package/dist/scene/environment.js.map +1 -1
  121. package/dist/scene/light.js +21 -3
  122. package/dist/scene/light.js.map +1 -1
  123. package/dist/scene/mesh.js +29 -14
  124. package/dist/scene/mesh.js.map +1 -1
  125. package/dist/scene/meshdrawable.js +6 -0
  126. package/dist/scene/meshdrawable.js.map +1 -1
  127. package/dist/scene/msdftext.js +5 -2
  128. package/dist/scene/msdftext.js.map +1 -1
  129. package/dist/scene/msdftextsprite.js +5 -3
  130. package/dist/scene/msdftextsprite.js.map +1 -1
  131. package/dist/scene/particlesys.js +3 -1
  132. package/dist/scene/particlesys.js.map +1 -1
  133. package/dist/scene/scene.js +6 -5
  134. package/dist/scene/scene.js.map +1 -1
  135. package/dist/scene/terrain-cm/grass.js +4 -2
  136. package/dist/scene/terrain-cm/grass.js.map +1 -1
  137. package/dist/scene/terrain-cm/grassmaterial.js +2 -1
  138. package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
  139. package/dist/scene/terrain-cm/terrain-cm.js +4 -2
  140. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
  141. package/dist/scene/water.js +4 -2
  142. package/dist/scene/water.js.map +1 -1
  143. package/dist/shaders/shadow.js +26 -393
  144. package/dist/shaders/shadow.js.map +1 -1
  145. package/dist/shadow/esm.js +112 -12
  146. package/dist/shadow/esm.js.map +1 -1
  147. package/dist/shadow/pcf_opt.js +2 -2
  148. package/dist/shadow/pcf_opt.js.map +1 -1
  149. package/dist/shadow/pcf_pd.js +19 -10
  150. package/dist/shadow/pcf_pd.js.map +1 -1
  151. package/dist/shadow/shader.js +58 -7
  152. package/dist/shadow/shader.js.map +1 -1
  153. package/dist/shadow/shadow_impl.js +6 -0
  154. package/dist/shadow/shadow_impl.js.map +1 -1
  155. package/dist/shadow/shadow_region.js +229 -0
  156. package/dist/shadow/shadow_region.js.map +1 -0
  157. package/dist/shadow/shadowmapper.js +67 -59
  158. package/dist/shadow/shadowmapper.js.map +1 -1
  159. package/dist/shadow/vsm.js +45 -19
  160. package/dist/shadow/vsm.js.map +1 -1
  161. package/dist/text/font/cff_font.js +890 -0
  162. package/dist/text/font/cff_font.js.map +1 -0
  163. package/dist/text/font/font_asset.js +17 -3
  164. package/dist/text/font/font_asset.js.map +1 -1
  165. package/dist/utility/blueprint/common/constants.js +8 -8
  166. package/dist/utility/blueprint/common/constants.js.map +1 -1
  167. package/dist/utility/blueprint/material/pbr.js +31 -4
  168. package/dist/utility/blueprint/material/pbr.js.map +1 -1
  169. package/dist/utility/blueprint/material/texture.js +1 -17
  170. package/dist/utility/blueprint/material/texture.js.map +1 -1
  171. package/dist/utility/serialization/manager.js +327 -359
  172. package/dist/utility/serialization/manager.js.map +1 -1
  173. package/dist/utility/serialization/scene/animation.js +5 -2
  174. package/dist/utility/serialization/scene/animation.js.map +1 -1
  175. package/dist/utility/serialization/scene/batch.js +4 -1
  176. package/dist/utility/serialization/scene/batch.js.map +1 -1
  177. package/dist/utility/serialization/scene/camera.js +249 -54
  178. package/dist/utility/serialization/scene/camera.js.map +1 -1
  179. package/dist/utility/serialization/scene/common.js +37 -1
  180. package/dist/utility/serialization/scene/common.js.map +1 -1
  181. package/dist/utility/serialization/scene/light.js +42 -3
  182. package/dist/utility/serialization/scene/light.js.map +1 -1
  183. package/dist/utility/serialization/scene/material.js +1112 -646
  184. package/dist/utility/serialization/scene/material.js.map +1 -1
  185. package/dist/utility/serialization/scene/mesh.js +7 -4
  186. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  187. package/dist/utility/serialization/scene/node.js +31 -12
  188. package/dist/utility/serialization/scene/node.js.map +1 -1
  189. package/dist/utility/serialization/scene/particle.js +4 -1
  190. package/dist/utility/serialization/scene/particle.js.map +1 -1
  191. package/dist/utility/serialization/scene/primitive.js +3 -1
  192. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  193. package/dist/utility/serialization/scene/scene.js +18 -0
  194. package/dist/utility/serialization/scene/scene.js.map +1 -1
  195. package/dist/utility/serialization/scene/sprite.js +6 -3
  196. package/dist/utility/serialization/scene/sprite.js.map +1 -1
  197. package/dist/utility/serialization/scene/terrain.js +5 -2
  198. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  199. package/dist/utility/serialization/scene/text.js +3 -1
  200. package/dist/utility/serialization/scene/text.js.map +1 -1
  201. package/dist/utility/serialization/scene/water.js +4 -1
  202. package/dist/utility/serialization/scene/water.js.map +1 -1
  203. package/dist/utility/textures/ltcdata.js +6 -0
  204. package/dist/utility/textures/ltcdata.js.map +1 -0
  205. package/dist/utility/textures/ltclut.js +61 -0
  206. package/dist/utility/textures/ltclut.js.map +1 -0
  207. package/dist/values.js +9 -1
  208. package/dist/values.js.map +1 -1
  209. package/package.json +3 -3
  210. package/dist/animation/ik/ik_chain_builder.js +0 -68
  211. package/dist/animation/ik/ik_chain_builder.js.map +0 -1
  212. package/dist/animation/ik/ik_pole_constraint.js +0 -123
  213. package/dist/animation/ik/ik_pole_constraint.js.map +0 -1
  214. package/dist/animation/ik/ik_track.js +0 -96
  215. package/dist/animation/ik/ik_track.js.map +0 -1
  216. package/dist/animation/ik_postprocessor.js +0 -71
  217. package/dist/animation/ik_postprocessor.js.map +0 -1
  218. package/dist/animation/joint_dynamics/math.js +0 -16
  219. package/dist/animation/joint_dynamics/math.js.map +0 -1
  220. package/dist/animation/manual_transform_processor.js +0 -156
  221. package/dist/animation/manual_transform_processor.js.map +0 -1
  222. package/dist/animation/skeleton_postprocessor.js +0 -50
  223. package/dist/animation/skeleton_postprocessor.js.map +0 -1
  224. package/dist/animation/spring2/collision.js +0 -469
  225. package/dist/animation/spring2/collision.js.map +0 -1
  226. package/dist/animation/spring2/constraints.js +0 -329
  227. package/dist/animation/spring2/constraints.js.map +0 -1
  228. package/dist/animation/spring2/controller.js +0 -434
  229. package/dist/animation/spring2/controller.js.map +0 -1
  230. package/dist/animation/spring2/math.js +0 -16
  231. package/dist/animation/spring2/math.js.map +0 -1
  232. package/dist/animation/spring2/solver.js +0 -624
  233. package/dist/animation/spring2/solver.js.map +0 -1
  234. package/dist/animation/spring2/spring_system.js +0 -118
  235. package/dist/animation/spring2/spring_system.js.map +0 -1
  236. package/dist/animation/spring2/types.js +0 -19
  237. package/dist/animation/spring2/types.js.map +0 -1
  238. package/dist/animation/spring_postprocessor.js +0 -54
  239. package/dist/animation/spring_postprocessor.js.map +0 -1
  240. package/dist/asset/loaders/gltf/gltf_loader.js +0 -1276
  241. package/dist/asset/loaders/gltf/gltf_loader.js.map +0 -1
  242. package/dist/asset/loaders/gltf/helpers.js +0 -331
  243. package/dist/asset/loaders/gltf/helpers.js.map +0 -1
  244. package/dist/material/sprite3d.js +0 -301
  245. package/dist/material/sprite3d.js.map +0 -1
  246. package/dist/material/sprite3d_std.js +0 -116
  247. package/dist/material/sprite3d_std.js.map +0 -1
  248. package/dist/material/sprite3dblueprint.js +0 -235
  249. package/dist/material/sprite3dblueprint.js.map +0 -1
  250. package/dist/material/sprite_sdf.js +0 -106
  251. package/dist/material/sprite_sdf.js.map +0 -1
  252. package/dist/material/terrainmaterial.js +0 -368
  253. package/dist/material/terrainmaterial.js.map +0 -1
  254. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +0 -38
  255. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +0 -1
  256. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +0 -10
  257. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +0 -1
  258. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +0 -127
  259. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +0 -1
  260. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +0 -263
  261. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +0 -1
  262. package/dist/render/deferredlightpass.js +0 -510
  263. package/dist/render/deferredlightpass.js.map +0 -1
  264. package/dist/render/deferredshadowlightpass.js +0 -428
  265. package/dist/render/deferredshadowlightpass.js.map +0 -1
  266. package/dist/render/gbufferpass.js +0 -50
  267. package/dist/render/gbufferpass.js.map +0 -1
  268. package/dist/scene/sdftextsprite.js +0 -322
  269. package/dist/scene/sdftextsprite.js.map +0 -1
  270. package/dist/scene/sprite3d.js +0 -18
  271. package/dist/scene/sprite3d.js.map +0 -1
  272. package/dist/scene/terrain/grass.js +0 -280
  273. package/dist/scene/terrain/grass.js.map +0 -1
  274. package/dist/scene/terrain/heightfield.js +0 -475
  275. package/dist/scene/terrain/heightfield.js.map +0 -1
  276. package/dist/scene/terrain/patch.js +0 -532
  277. package/dist/scene/terrain/patch.js.map +0 -1
  278. package/dist/scene/terrain/quadtree.js +0 -461
  279. package/dist/scene/terrain/quadtree.js.map +0 -1
  280. package/dist/scene/terrain/terrain.js +0 -231
  281. package/dist/scene/terrain/terrain.js.map +0 -1
  282. package/dist/src/animation/animation.js +0 -127
  283. package/dist/src/animation/animation.js.map +0 -1
  284. package/dist/src/animation/animationset.js +0 -255
  285. package/dist/src/animation/animationset.js.map +0 -1
  286. package/dist/src/animation/animationtrack.js +0 -34
  287. package/dist/src/animation/animationtrack.js.map +0 -1
  288. package/dist/src/animation/eulerrotationtrack.js +0 -52
  289. package/dist/src/animation/eulerrotationtrack.js.map +0 -1
  290. package/dist/src/animation/morphtarget.js +0 -93
  291. package/dist/src/animation/morphtarget.js.map +0 -1
  292. package/dist/src/animation/morphtrack.js +0 -70
  293. package/dist/src/animation/morphtrack.js.map +0 -1
  294. package/dist/src/animation/proptrack.js +0 -161
  295. package/dist/src/animation/proptrack.js.map +0 -1
  296. package/dist/src/animation/rotationtrack.js +0 -51
  297. package/dist/src/animation/rotationtrack.js.map +0 -1
  298. package/dist/src/animation/scaletrack.js +0 -50
  299. package/dist/src/animation/scaletrack.js.map +0 -1
  300. package/dist/src/animation/skeleton.js +0 -204
  301. package/dist/src/animation/skeleton.js.map +0 -1
  302. package/dist/src/animation/translationtrack.js +0 -50
  303. package/dist/src/animation/translationtrack.js.map +0 -1
  304. package/dist/src/app/app.js +0 -129
  305. package/dist/src/app/app.js.map +0 -1
  306. package/dist/src/app/inputmgr.js +0 -267
  307. package/dist/src/app/inputmgr.js.map +0 -1
  308. package/dist/src/asset/assetmanager.js +0 -404
  309. package/dist/src/asset/assetmanager.js.map +0 -1
  310. package/dist/src/asset/builtin.js +0 -337
  311. package/dist/src/asset/builtin.js.map +0 -1
  312. package/dist/src/asset/loaders/dds/dds.js +0 -470
  313. package/dist/src/asset/loaders/dds/dds.js.map +0 -1
  314. package/dist/src/asset/loaders/dds/dds_loader.js +0 -28
  315. package/dist/src/asset/loaders/dds/dds_loader.js.map +0 -1
  316. package/dist/src/asset/loaders/gltf/gltf_loader.js +0 -1265
  317. package/dist/src/asset/loaders/gltf/gltf_loader.js.map +0 -1
  318. package/dist/src/asset/loaders/gltf/helpers.js +0 -327
  319. package/dist/src/asset/loaders/gltf/helpers.js.map +0 -1
  320. package/dist/src/asset/loaders/hdr/hdr.js +0 -180
  321. package/dist/src/asset/loaders/hdr/hdr.js.map +0 -1
  322. package/dist/src/asset/loaders/image/tga_Loader.js +0 -116
  323. package/dist/src/asset/loaders/image/tga_Loader.js.map +0 -1
  324. package/dist/src/asset/loaders/image/webimage_loader.js +0 -63
  325. package/dist/src/asset/loaders/image/webimage_loader.js.map +0 -1
  326. package/dist/src/asset/loaders/loader.js +0 -45
  327. package/dist/src/asset/loaders/loader.js.map +0 -1
  328. package/dist/src/asset/model.js +0 -414
  329. package/dist/src/asset/model.js.map +0 -1
  330. package/dist/src/blitter/bilateralblur.js +0 -221
  331. package/dist/src/blitter/bilateralblur.js.map +0 -1
  332. package/dist/src/blitter/blitter.js +0 -390
  333. package/dist/src/blitter/blitter.js.map +0 -1
  334. package/dist/src/blitter/box.js +0 -118
  335. package/dist/src/blitter/box.js.map +0 -1
  336. package/dist/src/blitter/copy.js +0 -22
  337. package/dist/src/blitter/copy.js.map +0 -1
  338. package/dist/src/blitter/gaussianblur.js +0 -228
  339. package/dist/src/blitter/gaussianblur.js.map +0 -1
  340. package/dist/src/camera/base.js +0 -92
  341. package/dist/src/camera/base.js.map +0 -1
  342. package/dist/src/camera/camera.js +0 -1005
  343. package/dist/src/camera/camera.js.map +0 -1
  344. package/dist/src/camera/fps.js +0 -238
  345. package/dist/src/camera/fps.js.map +0 -1
  346. package/dist/src/camera/orbit.js +0 -245
  347. package/dist/src/camera/orbit.js.map +0 -1
  348. package/dist/src/camera/orthocamera.js +0 -167
  349. package/dist/src/camera/orthocamera.js.map +0 -1
  350. package/dist/src/camera/perspectivecamera.js +0 -141
  351. package/dist/src/camera/perspectivecamera.js.map +0 -1
  352. package/dist/src/index.js +0 -120
  353. package/dist/src/index.js.map +0 -1
  354. package/dist/src/material/blinn.js +0 -81
  355. package/dist/src/material/blinn.js.map +0 -1
  356. package/dist/src/material/grassmaterial.js +0 -113
  357. package/dist/src/material/grassmaterial.js.map +0 -1
  358. package/dist/src/material/lambert.js +0 -92
  359. package/dist/src/material/lambert.js.map +0 -1
  360. package/dist/src/material/material.js +0 -301
  361. package/dist/src/material/material.js.map +0 -1
  362. package/dist/src/material/meshmaterial.js +0 -704
  363. package/dist/src/material/meshmaterial.js.map +0 -1
  364. package/dist/src/material/mixins/albedocolor.js +0 -76
  365. package/dist/src/material/mixins/albedocolor.js.map +0 -1
  366. package/dist/src/material/mixins/foliage.js +0 -47
  367. package/dist/src/material/mixins/foliage.js.map +0 -1
  368. package/dist/src/material/mixins/lightmodel/blinnphong.js +0 -112
  369. package/dist/src/material/mixins/lightmodel/blinnphong.js.map +0 -1
  370. package/dist/src/material/mixins/lightmodel/lambert.js +0 -58
  371. package/dist/src/material/mixins/lightmodel/lambert.js.map +0 -1
  372. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +0 -178
  373. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +0 -1
  374. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +0 -139
  375. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +0 -1
  376. package/dist/src/material/mixins/lit.js +0 -476
  377. package/dist/src/material/mixins/lit.js.map +0 -1
  378. package/dist/src/material/mixins/pbr/common.js +0 -918
  379. package/dist/src/material/mixins/pbr/common.js.map +0 -1
  380. package/dist/src/material/mixins/texture.js +0 -172
  381. package/dist/src/material/mixins/texture.js.map +0 -1
  382. package/dist/src/material/mixins/vertexcolor.js +0 -56
  383. package/dist/src/material/mixins/vertexcolor.js.map +0 -1
  384. package/dist/src/material/particle.js +0 -178
  385. package/dist/src/material/particle.js.map +0 -1
  386. package/dist/src/material/pbrmr.js +0 -97
  387. package/dist/src/material/pbrmr.js.map +0 -1
  388. package/dist/src/material/pbrsg.js +0 -97
  389. package/dist/src/material/pbrsg.js.map +0 -1
  390. package/dist/src/material/shader/helper.js +0 -1209
  391. package/dist/src/material/shader/helper.js.map +0 -1
  392. package/dist/src/material/terrain-cm.js +0 -606
  393. package/dist/src/material/terrain-cm.js.map +0 -1
  394. package/dist/src/material/terrainmaterial.js +0 -375
  395. package/dist/src/material/terrainmaterial.js.map +0 -1
  396. package/dist/src/material/unlit.js +0 -41
  397. package/dist/src/material/unlit.js.map +0 -1
  398. package/dist/src/material/water.js +0 -417
  399. package/dist/src/material/water.js.map +0 -1
  400. package/dist/src/posteffect/bloom.js +0 -361
  401. package/dist/src/posteffect/bloom.js.map +0 -1
  402. package/dist/src/posteffect/compositor.js +0 -226
  403. package/dist/src/posteffect/compositor.js.map +0 -1
  404. package/dist/src/posteffect/fxaa.js +0 -273
  405. package/dist/src/posteffect/fxaa.js.map +0 -1
  406. package/dist/src/posteffect/grayscale.js +0 -69
  407. package/dist/src/posteffect/grayscale.js.map +0 -1
  408. package/dist/src/posteffect/motionblur.js +0 -96
  409. package/dist/src/posteffect/motionblur.js.map +0 -1
  410. package/dist/src/posteffect/posteffect.js +0 -126
  411. package/dist/src/posteffect/posteffect.js.map +0 -1
  412. package/dist/src/posteffect/sao.js +0 -324
  413. package/dist/src/posteffect/sao.js.map +0 -1
  414. package/dist/src/posteffect/ssr.js +0 -489
  415. package/dist/src/posteffect/ssr.js.map +0 -1
  416. package/dist/src/posteffect/taa.js +0 -172
  417. package/dist/src/posteffect/taa.js.map +0 -1
  418. package/dist/src/posteffect/tonemap.js +0 -94
  419. package/dist/src/posteffect/tonemap.js.map +0 -1
  420. package/dist/src/render/abuffer_oit.js +0 -361
  421. package/dist/src/render/abuffer_oit.js.map +0 -1
  422. package/dist/src/render/clipmap.js +0 -851
  423. package/dist/src/render/clipmap.js.map +0 -1
  424. package/dist/src/render/cluster_light.js +0 -333
  425. package/dist/src/render/cluster_light.js.map +0 -1
  426. package/dist/src/render/cull_visitor.js +0 -187
  427. package/dist/src/render/cull_visitor.js.map +0 -1
  428. package/dist/src/render/depthpass.js +0 -68
  429. package/dist/src/render/depthpass.js.map +0 -1
  430. package/dist/src/render/drawable_mixin.js +0 -227
  431. package/dist/src/render/drawable_mixin.js.map +0 -1
  432. package/dist/src/render/envlight.js +0 -463
  433. package/dist/src/render/envlight.js.map +0 -1
  434. package/dist/src/render/fbm_wavegenerator.js +0 -251
  435. package/dist/src/render/fbm_wavegenerator.js.map +0 -1
  436. package/dist/src/render/fft_wavegenerator.js +0 -1006
  437. package/dist/src/render/fft_wavegenerator.js.map +0 -1
  438. package/dist/src/render/fullscreenquad.js +0 -38
  439. package/dist/src/render/fullscreenquad.js.map +0 -1
  440. package/dist/src/render/gerstner_wavegenerator.js +0 -314
  441. package/dist/src/render/gerstner_wavegenerator.js.map +0 -1
  442. package/dist/src/render/globalbindgroup_allocator.js +0 -60
  443. package/dist/src/render/globalbindgroup_allocator.js.map +0 -1
  444. package/dist/src/render/hzb.js +0 -273
  445. package/dist/src/render/hzb.js.map +0 -1
  446. package/dist/src/render/lightpass.js +0 -172
  447. package/dist/src/render/lightpass.js.map +0 -1
  448. package/dist/src/render/objectcolorpass.js +0 -51
  449. package/dist/src/render/objectcolorpass.js.map +0 -1
  450. package/dist/src/render/primitive.js +0 -364
  451. package/dist/src/render/primitive.js.map +0 -1
  452. package/dist/src/render/render_queue.js +0 -467
  453. package/dist/src/render/render_queue.js.map +0 -1
  454. package/dist/src/render/renderbundle_wrapper.js +0 -152
  455. package/dist/src/render/renderbundle_wrapper.js.map +0 -1
  456. package/dist/src/render/renderer.js +0 -455
  457. package/dist/src/render/renderer.js.map +0 -1
  458. package/dist/src/render/renderpass.js +0 -200
  459. package/dist/src/render/renderpass.js.map +0 -1
  460. package/dist/src/render/shadowmap_pass.js +0 -56
  461. package/dist/src/render/shadowmap_pass.js.map +0 -1
  462. package/dist/src/render/sky.js +0 -1103
  463. package/dist/src/render/sky.js.map +0 -1
  464. package/dist/src/render/weightedblended_oit.js +0 -168
  465. package/dist/src/render/weightedblended_oit.js.map +0 -1
  466. package/dist/src/scene/batchgroup.js +0 -162
  467. package/dist/src/scene/batchgroup.js.map +0 -1
  468. package/dist/src/scene/environment.js +0 -209
  469. package/dist/src/scene/environment.js.map +0 -1
  470. package/dist/src/scene/graph_node.js +0 -72
  471. package/dist/src/scene/graph_node.js.map +0 -1
  472. package/dist/src/scene/light.js +0 -416
  473. package/dist/src/scene/light.js.map +0 -1
  474. package/dist/src/scene/mesh.js +0 -341
  475. package/dist/src/scene/mesh.js.map +0 -1
  476. package/dist/src/scene/octree.js +0 -649
  477. package/dist/src/scene/octree.js.map +0 -1
  478. package/dist/src/scene/particlesys.js +0 -738
  479. package/dist/src/scene/particlesys.js.map +0 -1
  480. package/dist/src/scene/raycast_visitor.js +0 -103
  481. package/dist/src/scene/raycast_visitor.js.map +0 -1
  482. package/dist/src/scene/scene.js +0 -284
  483. package/dist/src/scene/scene.js.map +0 -1
  484. package/dist/src/scene/scene_node.js +0 -732
  485. package/dist/src/scene/scene_node.js.map +0 -1
  486. package/dist/src/scene/terrain/grass.js +0 -278
  487. package/dist/src/scene/terrain/grass.js.map +0 -1
  488. package/dist/src/scene/terrain/heightfield.js +0 -475
  489. package/dist/src/scene/terrain/heightfield.js.map +0 -1
  490. package/dist/src/scene/terrain/patch.js +0 -530
  491. package/dist/src/scene/terrain/patch.js.map +0 -1
  492. package/dist/src/scene/terrain/quadtree.js +0 -461
  493. package/dist/src/scene/terrain/quadtree.js.map +0 -1
  494. package/dist/src/scene/terrain/terrain.js +0 -246
  495. package/dist/src/scene/terrain/terrain.js.map +0 -1
  496. package/dist/src/scene/terrain-cm/grass.js +0 -594
  497. package/dist/src/scene/terrain-cm/grass.js.map +0 -1
  498. package/dist/src/scene/terrain-cm/grassmaterial.js +0 -159
  499. package/dist/src/scene/terrain-cm/grassmaterial.js.map +0 -1
  500. package/dist/src/scene/terrain-cm/terrain-cm.js +0 -538
  501. package/dist/src/scene/terrain-cm/terrain-cm.js.map +0 -1
  502. package/dist/src/scene/water.js +0 -374
  503. package/dist/src/scene/water.js.map +0 -1
  504. package/dist/src/shaders/atmosphere.js +0 -957
  505. package/dist/src/shaders/atmosphere.js.map +0 -1
  506. package/dist/src/shaders/fog.js +0 -112
  507. package/dist/src/shaders/fog.js.map +0 -1
  508. package/dist/src/shaders/misc.js +0 -266
  509. package/dist/src/shaders/misc.js.map +0 -1
  510. package/dist/src/shaders/noise.js +0 -222
  511. package/dist/src/shaders/noise.js.map +0 -1
  512. package/dist/src/shaders/pbr.js +0 -51
  513. package/dist/src/shaders/pbr.js.map +0 -1
  514. package/dist/src/shaders/shadow.js +0 -636
  515. package/dist/src/shaders/shadow.js.map +0 -1
  516. package/dist/src/shaders/ssr.js +0 -490
  517. package/dist/src/shaders/ssr.js.map +0 -1
  518. package/dist/src/shaders/temporal.js +0 -215
  519. package/dist/src/shaders/temporal.js.map +0 -1
  520. package/dist/src/shaders/water.js +0 -756
  521. package/dist/src/shaders/water.js.map +0 -1
  522. package/dist/src/shadow/esm.js +0 -237
  523. package/dist/src/shadow/esm.js.map +0 -1
  524. package/dist/src/shadow/pcf_opt.js +0 -181
  525. package/dist/src/shadow/pcf_opt.js.map +0 -1
  526. package/dist/src/shadow/pcf_pd.js +0 -189
  527. package/dist/src/shadow/pcf_pd.js.map +0 -1
  528. package/dist/src/shadow/shader.js +0 -37
  529. package/dist/src/shadow/shader.js.map +0 -1
  530. package/dist/src/shadow/shadow_impl.js +0 -15
  531. package/dist/src/shadow/shadow_impl.js.map +0 -1
  532. package/dist/src/shadow/shadowmapper.js +0 -790
  533. package/dist/src/shadow/shadowmapper.js.map +0 -1
  534. package/dist/src/shadow/ssm.js +0 -159
  535. package/dist/src/shadow/ssm.js.map +0 -1
  536. package/dist/src/shadow/vsm.js +0 -297
  537. package/dist/src/shadow/vsm.js.map +0 -1
  538. package/dist/src/shapes/box.js +0 -386
  539. package/dist/src/shapes/box.js.map +0 -1
  540. package/dist/src/shapes/cylinder.js +0 -125
  541. package/dist/src/shapes/cylinder.js.map +0 -1
  542. package/dist/src/shapes/plane.js +0 -88
  543. package/dist/src/shapes/plane.js.map +0 -1
  544. package/dist/src/shapes/shape.js +0 -87
  545. package/dist/src/shapes/shape.js.map +0 -1
  546. package/dist/src/shapes/sphere.js +0 -114
  547. package/dist/src/shapes/sphere.js.map +0 -1
  548. package/dist/src/shapes/tetrahedron.js +0 -188
  549. package/dist/src/shapes/tetrahedron.js.map +0 -1
  550. package/dist/src/shapes/torus.js +0 -111
  551. package/dist/src/shapes/torus.js.map +0 -1
  552. package/dist/src/utility/aabbtree.js +0 -400
  553. package/dist/src/utility/aabbtree.js.map +0 -1
  554. package/dist/src/utility/bounding_volume.js +0 -29
  555. package/dist/src/utility/bounding_volume.js.map +0 -1
  556. package/dist/src/utility/debug.js +0 -28
  557. package/dist/src/utility/debug.js.map +0 -1
  558. package/dist/src/utility/draco/decoder.js +0 -116
  559. package/dist/src/utility/draco/decoder.js.map +0 -1
  560. package/dist/src/utility/misc.js +0 -105
  561. package/dist/src/utility/misc.js.map +0 -1
  562. package/dist/src/utility/panorama.js +0 -163
  563. package/dist/src/utility/panorama.js.map +0 -1
  564. package/dist/src/utility/pmrem.js +0 -354
  565. package/dist/src/utility/pmrem.js.map +0 -1
  566. package/dist/src/utility/rendermipmap.js +0 -115
  567. package/dist/src/utility/rendermipmap.js.map +0 -1
  568. package/dist/src/utility/serialization/json.js +0 -402
  569. package/dist/src/utility/serialization/json.js.map +0 -1
  570. package/dist/src/utility/serialization/manager.js +0 -623
  571. package/dist/src/utility/serialization/manager.js.map +0 -1
  572. package/dist/src/utility/serialization/scene/animation.js +0 -248
  573. package/dist/src/utility/serialization/scene/animation.js.map +0 -1
  574. package/dist/src/utility/serialization/scene/batch.js +0 -59
  575. package/dist/src/utility/serialization/scene/batch.js.map +0 -1
  576. package/dist/src/utility/serialization/scene/camera.js +0 -790
  577. package/dist/src/utility/serialization/scene/camera.js.map +0 -1
  578. package/dist/src/utility/serialization/scene/common.js +0 -222
  579. package/dist/src/utility/serialization/scene/common.js.map +0 -1
  580. package/dist/src/utility/serialization/scene/light.js +0 -575
  581. package/dist/src/utility/serialization/scene/light.js.map +0 -1
  582. package/dist/src/utility/serialization/scene/material.js +0 -1111
  583. package/dist/src/utility/serialization/scene/material.js.map +0 -1
  584. package/dist/src/utility/serialization/scene/mesh.js +0 -148
  585. package/dist/src/utility/serialization/scene/mesh.js.map +0 -1
  586. package/dist/src/utility/serialization/scene/misc.js +0 -39
  587. package/dist/src/utility/serialization/scene/misc.js.map +0 -1
  588. package/dist/src/utility/serialization/scene/node.js +0 -451
  589. package/dist/src/utility/serialization/scene/node.js.map +0 -1
  590. package/dist/src/utility/serialization/scene/particle.js +0 -425
  591. package/dist/src/utility/serialization/scene/particle.js.map +0 -1
  592. package/dist/src/utility/serialization/scene/primitive.js +0 -692
  593. package/dist/src/utility/serialization/scene/primitive.js.map +0 -1
  594. package/dist/src/utility/serialization/scene/scene.js +0 -704
  595. package/dist/src/utility/serialization/scene/scene.js.map +0 -1
  596. package/dist/src/utility/serialization/scene/terrain.js +0 -488
  597. package/dist/src/utility/serialization/scene/terrain.js.map +0 -1
  598. package/dist/src/utility/serialization/scene/water.js +0 -465
  599. package/dist/src/utility/serialization/scene/water.js.map +0 -1
  600. package/dist/src/utility/shprojector.js +0 -297
  601. package/dist/src/utility/shprojector.js.map +0 -1
  602. package/dist/src/utility/textures/ggxlut.js +0 -213
  603. package/dist/src/utility/textures/ggxlut.js.map +0 -1
  604. package/dist/src/utility/textures/gradientnoise.js +0 -62
  605. package/dist/src/utility/textures/gradientnoise.js.map +0 -1
  606. package/dist/src/utility/textures/randomnoise.js +0 -41
  607. package/dist/src/utility/textures/randomnoise.js.map +0 -1
  608. package/dist/src/values.js +0 -162
  609. package/dist/src/values.js.map +0 -1
  610. package/dist/utility/blueprint/material/common.js +0 -7
  611. package/dist/utility/blueprint/material/common.js.map +0 -1
  612. package/dist/utility/serialization/blueprint/constants.js +0 -255
  613. package/dist/utility/serialization/blueprint/constants.js.map +0 -1
  614. package/dist/utility/serialization/blueprint/material/constants.js +0 -203
  615. package/dist/utility/serialization/blueprint/material/constants.js.map +0 -1
  616. package/dist/utility/serialization/blueprint/material/texture.js +0 -165
  617. package/dist/utility/serialization/blueprint/material/texture.js.map +0 -1
  618. package/dist/utility/serialization/scene/cloth_script.js +0 -834
  619. package/dist/utility/serialization/scene/cloth_script.js.map +0 -1
  620. package/dist/utility/serialization/scene/spring_script.js +0 -596
  621. package/dist/utility/serialization/scene/spring_script.js.map +0 -1
@@ -1,649 +0,0 @@
1
- import { ASSERT, AABB, Vector3, nextPowerOf2 } from '@zephyr3d/base';
2
-
3
- /**
4
- * Octree placement
5
- * @public
6
- */ /* eslint-disable no-unused-vars */ var OctreePlacement = /*#__PURE__*/ function(OctreePlacement) {
7
- OctreePlacement[OctreePlacement["PPP"] = 0] = "PPP";
8
- OctreePlacement[OctreePlacement["PPN"] = 1] = "PPN";
9
- OctreePlacement[OctreePlacement["PNP"] = 2] = "PNP";
10
- OctreePlacement[OctreePlacement["PNN"] = 3] = "PNN";
11
- OctreePlacement[OctreePlacement["NPP"] = 4] = "NPP";
12
- OctreePlacement[OctreePlacement["NPN"] = 5] = "NPN";
13
- OctreePlacement[OctreePlacement["NNP"] = 6] = "NNP";
14
- OctreePlacement[OctreePlacement["NNN"] = 7] = "NNN";
15
- return OctreePlacement;
16
- }({});
17
- /**
18
- * Octree node
19
- * @public
20
- */ class OctreeNode {
21
- /** @internal */ _chunk;
22
- /** @internal */ _position;
23
- /** @internal */ _nodes;
24
- /** @internal */ _box;
25
- /** @internal */ _boxLoosed;
26
- /**
27
- * Creates an instance of octree node
28
- */ constructor(){
29
- this._chunk = null;
30
- this._position = 0;
31
- this._nodes = [];
32
- this._box = null;
33
- this._boxLoosed = null;
34
- }
35
- /**
36
- * Get all the scene nodes that this octree node contains
37
- * @returns An array of the scene nodes
38
- */ getNodes() {
39
- return this._nodes;
40
- }
41
- /**
42
- * Gets the level index of the octree node
43
- * @returns The level index
44
- */ getLevel() {
45
- return this._chunk.getLevel();
46
- }
47
- /**
48
- * Adds a scene node to this node
49
- * @param node - The scene node to be added
50
- */ addNode(node) {
51
- if (node && this._nodes.indexOf(node) < 0) {
52
- this._nodes.push(node);
53
- node.octreeNode = this;
54
- }
55
- }
56
- /**
57
- * Removes a scene node from this node
58
- * @param node - The scene node to be removed
59
- */ removeNode(node) {
60
- const index = this._nodes.indexOf(node);
61
- if (index >= 0) {
62
- this._nodes.splice(index, 1);
63
- node.octreeNode = null;
64
- }
65
- }
66
- /** Removes all the scene nodes that this octree node contains */ clearNodes() {
67
- for (const node of this._nodes){
68
- node.octreeNode = null;
69
- }
70
- this._nodes = [];
71
- }
72
- /**
73
- * Sets the octree chunk
74
- * @param chunk - The octree chunk to be set
75
- */ setChunk(chunk) {
76
- ASSERT(!!chunk, 'Invalid chunk');
77
- this._chunk = chunk;
78
- }
79
- /**
80
- * Gets the octree chunk
81
- * @returns The octree chunk
82
- */ getChunk() {
83
- return this._chunk;
84
- }
85
- /**
86
- * Sets the position of the node
87
- * @param index - Position of the node
88
- */ setPosition(index) {
89
- this._position = index;
90
- }
91
- /**
92
- * Gets the position of the octree node
93
- * @returns Position of the octree node
94
- */ getPosition() {
95
- return this._position;
96
- }
97
- /**
98
- * Get the bounding box of the octree node
99
- * @returns The bounding box of the octree node
100
- */ getBox() {
101
- if (this._box === null) {
102
- const box = new AABB();
103
- box.beginExtend();
104
- for(let i = 0; i < 8; i++){
105
- const child = this.getChild(i);
106
- if (child) {
107
- const childBox = child.getBox();
108
- if (childBox) {
109
- box.extend(childBox.minPoint);
110
- box.extend(childBox.maxPoint);
111
- }
112
- }
113
- }
114
- if (box.isValid()) {
115
- this._box = box;
116
- }
117
- }
118
- return this._box;
119
- }
120
- /**
121
- * Gets the loosed bounding box of the node
122
- * @returns The loosed bounding box of the node
123
- */ getBoxLoosed() {
124
- if (this._boxLoosed === null) {
125
- ASSERT(!!this._chunk, 'Invalid chunk');
126
- const d = this._chunk.getDimension();
127
- const nodeSize = this._chunk.getNodeSize();
128
- const halfWorldSize = this._chunk.getWorldSize() * 0.5;
129
- const px = this._position % d;
130
- const py = Math.floor(this._position / d) % d;
131
- const pz = Math.floor(Math.floor(this._position / d) / d);
132
- const minPoint = new Vector3(px - 0.5, py - 0.5, pz - 0.5).scaleBy(nodeSize).subBy(new Vector3(halfWorldSize, halfWorldSize, halfWorldSize));
133
- const maxPoint = new Vector3(minPoint.x + nodeSize * 2, minPoint.y + nodeSize * 2, minPoint.z + nodeSize * 2);
134
- this._boxLoosed = new AABB(minPoint, maxPoint);
135
- }
136
- return this._boxLoosed;
137
- }
138
- /**
139
- * Gets min point of the node
140
- * @returns Min point of the node
141
- */ getMinPoint() {
142
- ASSERT(!!this._chunk, 'Invalid chunk');
143
- const d = this._chunk.getDimension();
144
- const nodeSize = this._chunk.getNodeSize();
145
- const halfWorldSize = this._chunk.getWorldSize() * 0.5;
146
- const px = this._position % d;
147
- const py = Math.floor(this._position / d) % d;
148
- const pz = Math.floor(Math.floor(this._position / d) / d);
149
- return new Vector3(px, py, pz).scaleBy(nodeSize).subBy(new Vector3(halfWorldSize, halfWorldSize, halfWorldSize));
150
- }
151
- /**
152
- * Gets max point of the node
153
- * @returns Max point of the node
154
- */ getMaxPoint() {
155
- ASSERT(!!this._chunk, 'Invalid chunk');
156
- const d = this._chunk.getDimension();
157
- const nodeSize = this._chunk.getNodeSize();
158
- const halfWorldSize = this._chunk.getWorldSize() * 0.5;
159
- const px = this._position % d + 1;
160
- const py = Math.floor(this._position / d) % d + 1;
161
- const pz = Math.floor(Math.floor(this._position / d) / d) + 1;
162
- return new Vector3(px, py, pz).scaleBy(nodeSize).subBy(new Vector3(halfWorldSize, halfWorldSize, halfWorldSize));
163
- }
164
- /**
165
- * Gets the loosed min point of the node
166
- * @returns Loosed min point of the node
167
- */ getMinPointLoosed() {
168
- const halfNodeSize = this._chunk.getNodeSize() * 0.5;
169
- return this.getMinPoint().subBy(new Vector3(halfNodeSize, halfNodeSize, halfNodeSize));
170
- }
171
- /**
172
- * Gets the loosed max point of the node
173
- * @returns Loosed max point of the node
174
- */ getMaxPointLoosed() {
175
- const halfNodeSize = this._chunk.getNodeSize() * 0.5;
176
- return this.getMaxPoint().addBy(new Vector3(halfNodeSize, halfNodeSize, halfNodeSize));
177
- }
178
- /**
179
- * Gets the child node by a given placement
180
- * @param placement - The placement
181
- * @returns Child node at the given placement
182
- */ getChild(placement) {
183
- ASSERT(!!this._chunk, 'Invalid chunk');
184
- const next = this._chunk.getNext();
185
- return next ? next.getNode(this._chunk.getChildIndex(this._position, placement)) : null;
186
- }
187
- /**
188
- * Gets or creates a child node by a given placement
189
- * @param placement - The placement
190
- * @returns The child node fetched
191
- */ getOrCreateChild(placement) {
192
- ASSERT(!!this._chunk, 'Invalid chunk');
193
- const next = this._chunk.getNext();
194
- return next ? next.getOrCreateNode(this._chunk.getChildIndex(this._position, placement)) : null;
195
- }
196
- /**
197
- * Gets parent of the node
198
- * @returns Parent of the node
199
- */ getParent() {
200
- ASSERT(!!this._chunk, 'Invalid chunk');
201
- const prev = this._chunk.getPrev();
202
- return prev ? prev.getNode(this._chunk.getParentIndex(this._position)) : null;
203
- }
204
- /**
205
- * Gets or creates the parent node
206
- * @returns The parent node
207
- */ getOrCreateParent() {
208
- ASSERT(!!this._chunk, 'Invalid chunk');
209
- const prev = this._chunk.getPrev();
210
- return prev ? prev.getOrCreateNode(this._chunk.getParentIndex(this._position)) : null;
211
- }
212
- /**
213
- * Creates all children of this node
214
- */ createChildren() {
215
- this.getOrCreateChild(0);
216
- this.getOrCreateChild(1);
217
- this.getOrCreateChild(2);
218
- this.getOrCreateChild(3);
219
- this.getOrCreateChild(4);
220
- this.getOrCreateChild(5);
221
- this.getOrCreateChild(6);
222
- this.getOrCreateChild(7);
223
- }
224
- /**
225
- * Traverse this node by a visitor
226
- * @param v - The visitor
227
- */ traverse(v) {
228
- if (v.visit(this)) {
229
- for(let i = 0; i < 8; i++){
230
- const child = this.getChild(i);
231
- if (child) {
232
- child.traverse(v);
233
- }
234
- }
235
- }
236
- }
237
- }
238
- /**
239
- * Octree node chunk
240
- * @public
241
- */ class OctreeNodeChunk {
242
- /** @internal */ _level;
243
- /** @internal */ _dimension;
244
- /** @internal */ _nodeSize;
245
- /** @internal */ _prev;
246
- /** @internal */ _next;
247
- /** @internal */ _octree;
248
- /** @internal */ _nodeMap;
249
- /**
250
- * Creates an instance of octree chunk
251
- * @param octree - Octree to which the chunk belongs
252
- */ constructor(octree){
253
- this._octree = octree;
254
- this._level = 0;
255
- this._dimension = 0;
256
- this._nodeSize = 0;
257
- this._next = null;
258
- this._prev = null;
259
- this._nodeMap = new Map();
260
- }
261
- /** @internal */ get nodeMap() {
262
- return this._nodeMap;
263
- }
264
- /**
265
- * Gets an octree node at a given index
266
- * @param index - Index of the node
267
- * @returns The octree node
268
- */ getNode(index) {
269
- return this._nodeMap.get(index) || null;
270
- }
271
- /**
272
- * Gets or creates an octree node at a given index
273
- * @param index - Index of the node
274
- * @returns The octree node
275
- */ getOrCreateNode(index) {
276
- let node = this.getNode(index);
277
- if (!node) {
278
- node = new OctreeNode();
279
- node.setChunk(this);
280
- node.setPosition(index);
281
- this._nodeMap.set(index, node);
282
- }
283
- return node;
284
- }
285
- /**
286
- * Gets or creates an octree node chain at a given index
287
- * @param index - Index of the head node
288
- * @returns The head node of the chain
289
- */ getOrCreateNodeChain(index) {
290
- const node = this.getOrCreateNode(index);
291
- if (this._prev) {
292
- this._prev.getOrCreateNodeChain(this.getParentIndex(index));
293
- }
294
- return node;
295
- }
296
- /**
297
- * Removes all octree nodes of this chunk
298
- */ clearNodes() {
299
- for (const key of this._nodeMap.keys()){
300
- this._nodeMap.get(key).clearNodes();
301
- this._nodeMap.delete(key);
302
- }
303
- }
304
- /**
305
- * Gets the index of a child node at given placement
306
- * @param index - Index of the parent node
307
- * @param placement - The placement
308
- * @returns Index of the child
309
- */ getChildIndex(index, placement) {
310
- const dim = this._dimension;
311
- let px = 2 * (index % dim);
312
- let py = 2 * (Math.floor(index / dim) % dim);
313
- let pz = 2 * Math.floor(Math.floor(index / dim) / dim);
314
- switch(placement){
315
- case 0:
316
- ++px;
317
- ++py;
318
- ++pz;
319
- break;
320
- case 1:
321
- ++px;
322
- ++py;
323
- break;
324
- case 2:
325
- ++px;
326
- ++pz;
327
- break;
328
- case 3:
329
- ++px;
330
- break;
331
- case 4:
332
- ++py;
333
- ++pz;
334
- break;
335
- case 5:
336
- ++py;
337
- break;
338
- case 6:
339
- ++pz;
340
- break;
341
- case 7:
342
- break;
343
- default:
344
- ASSERT(false, 'getChildIndex: Got invalid index');
345
- return 0;
346
- }
347
- const dimension2 = 2 * dim;
348
- return pz * dimension2 * dimension2 + py * dimension2 + px;
349
- }
350
- /**
351
- * Gets the index of the parent node
352
- * @param index - Index of the child node
353
- * @returns Index of the parent node
354
- */ getParentIndex(index) {
355
- const dim = this._dimension;
356
- const px = index % dim >> 1;
357
- const py = Math.floor(index / dim) % dim >> 1;
358
- const pz = Math.floor(Math.floor(index / dim) / dim) >> 1;
359
- const d = dim >> 1;
360
- return px + py * d + pz * d * d;
361
- }
362
- /**
363
- * Gets the size of the node in this chunk
364
- * @returns The size of the node in this chunk
365
- */ getNodeSize() {
366
- return this._nodeSize;
367
- }
368
- /**
369
- * Gets the root size of the octree
370
- * @returns The root size of the octree
371
- */ getWorldSize() {
372
- return this._octree.getRootSize();
373
- }
374
- /**
375
- * Gets the dimension of this chunk
376
- * @returns Dimension of this chunk
377
- */ getDimension() {
378
- return this._dimension;
379
- }
380
- /**
381
- * Gets the level index of this chunk
382
- * @returns Level index of this chunk
383
- */ getLevel() {
384
- return this._level;
385
- }
386
- /**
387
- * Check if this chunk is empty
388
- * @returns true if this chunk is empty, otherwise false
389
- */ empty() {
390
- return this._nodeMap.size === 0;
391
- }
392
- /**
393
- * Gets the chunk next to this chunk
394
- * @returns The next chunk
395
- */ getNext() {
396
- return this._next;
397
- }
398
- /**
399
- * Gets the chunk previous to this chunk
400
- * @returns The previous chunk
401
- */ getPrev() {
402
- return this._prev;
403
- }
404
- /**
405
- * Gets the octree that the chunk belongs to
406
- * @returns The octree
407
- */ getOctree() {
408
- return this._octree;
409
- }
410
- /**
411
- * Sets the level index of this chunk
412
- * @param level - The level index to set
413
- */ setLevel(level) {
414
- this._level = level;
415
- }
416
- /**
417
- * Sets the dimension of this chunk
418
- * @param dimension - The dimension to set
419
- */ setDimension(dimension) {
420
- this._dimension = dimension;
421
- }
422
- /**
423
- * Sets the size of octree node in this chunk
424
- * @param size - The node size to set
425
- */ setNodeSize(size) {
426
- this._nodeSize = size;
427
- }
428
- /**
429
- * Sets the next chunk
430
- * @param chunk - The chunk to set
431
- */ setNext(chunk) {
432
- this._next = chunk;
433
- }
434
- /**
435
- * Sets the previous chunk
436
- * @param chunk - The chunk to set
437
- */ setPrev(chunk) {
438
- this._prev = chunk;
439
- }
440
- }
441
- /**
442
- * Octree class
443
- * @public
444
- */ class Octree {
445
- /** @internal */ _scene;
446
- /** @internal */ _chunks;
447
- /** @internal */ _rootSize;
448
- /** @internal */ _maxRootSize;
449
- /** @internal */ _leafSize;
450
- /** @internal */ _rootNode;
451
- /** @internal */ _nodeMap;
452
- /** @internal */ _nodes;
453
- /**
454
- * Creates an instance of octree
455
- * @param scene - The scene to which the octree belongs
456
- * @param rootSize - Root size of the octre
457
- * @param leafSize - Leaf size of the octree
458
- */ constructor(scene, rootSize = 8, leafSize = 8, maxRootSize = 65536){
459
- this._scene = scene;
460
- this._chunks = [];
461
- this._rootSize = 0;
462
- this._leafSize = 0;
463
- this._rootNode = null;
464
- this._nodeMap = new WeakMap();
465
- this._nodes = new Set();
466
- this.initialize(rootSize, leafSize);
467
- this._maxRootSize = Math.max(maxRootSize, this._rootSize);
468
- }
469
- /**
470
- * Initialize the octree with specified root size and leaf size
471
- * @param rootSize - Root size of the octree
472
- * @param leafSize - Leaf size of the octree
473
- */ initialize(rootSize, leafSize) {
474
- this.finalize();
475
- this._leafSize = leafSize;
476
- this._rootSize = Math.max(leafSize, rootSize);
477
- let n = 1;
478
- for(; rootSize >= leafSize * 2; leafSize *= 2, ++n){}
479
- for(let i = 0; i < n; ++i, rootSize *= 0.5){
480
- const chunk = new OctreeNodeChunk(this);
481
- chunk.setLevel(i);
482
- chunk.setNodeSize(rootSize);
483
- chunk.setDimension(1 << i);
484
- this._chunks.push(chunk);
485
- if (i > 0) {
486
- this._chunks[i - 1].setNext(chunk);
487
- chunk.setPrev(this._chunks[i - 1]);
488
- }
489
- }
490
- }
491
- /** Free up the octree */ finalize() {
492
- this._chunks.forEach((chunk)=>chunk.clearNodes());
493
- this._chunks = [];
494
- this._rootSize = 0;
495
- this._leafSize = 0;
496
- this._rootNode = null;
497
- this._nodeMap = new WeakMap();
498
- }
499
- /**
500
- * Gets the scene to which the octree belongs
501
- * @returns The scene
502
- */ getScene() {
503
- return this._scene;
504
- }
505
- /**
506
- * Gets the root size of the octree
507
- * @returns The root size of the octree
508
- */ getRootSize() {
509
- return this._rootSize;
510
- }
511
- /**
512
- * Gets the leaf size of the octree
513
- * @returns The leaf size of the octree
514
- */ getLeafSize() {
515
- return this._leafSize;
516
- }
517
- /**
518
- * Locates a node chain in the octree by a sphere
519
- * @param candidate - The candidate node
520
- * @param center - center of the sphere
521
- * @param radius - radius of the sphere
522
- * @returns Head node of the located node chain
523
- */ locateNodeChain(candidate, center, radius) {
524
- let level = this._chunks.length - 1;
525
- while(level >= 0 && this._chunks[level].getNodeSize() < 4 * radius){
526
- --level;
527
- }
528
- if (level < 0) {
529
- return null;
530
- }
531
- const dim = this._chunks[level].getDimension();
532
- const inv_node_size = 1 / this._chunks[level].getNodeSize();
533
- const px = Math.floor((center.x + this._rootSize * 0.5) * inv_node_size);
534
- const py = Math.floor((center.y + this._rootSize * 0.5) * inv_node_size);
535
- const pz = Math.floor((center.z + this._rootSize * 0.5) * inv_node_size);
536
- if (px >= dim || px < 0 || py >= dim || py < 0 || pz >= dim || pz < 0) {
537
- return null;
538
- }
539
- const index = px + py * dim + pz * dim * dim;
540
- if (candidate && candidate.getChunk().getLevel() === level && candidate.getPosition() === index) {
541
- return candidate;
542
- }
543
- return this._chunks[level].getOrCreateNodeChain(index);
544
- }
545
- /**
546
- * Gets the root node of the octree
547
- * @returns Root node of the octree
548
- */ getRootNode() {
549
- if (!this._rootNode) {
550
- this._rootNode = this._chunks[0].getOrCreateNode(0);
551
- }
552
- return this._rootNode;
553
- }
554
- /**
555
- * Gets the number of chunks in the octree
556
- * @returns The number of chunks in the octree
557
- */ getNumChunks() {
558
- return this._chunks.length;
559
- }
560
- /**
561
- * Gets the chunk by a given index
562
- * @param level - The chunk index
563
- * @returns The chunk at given index
564
- */ getChunk(level) {
565
- return this._chunks[level];
566
- }
567
- /**
568
- * Place a scene node into the octree
569
- * @param node - The scene node to be placed
570
- */ placeNode(node) {
571
- const curNode = this._nodeMap.get(node) || null;
572
- let locatedNode = this.getRootNode();
573
- if (node.clipTestEnabled) {
574
- const bbox = node.getWorldBoundingVolume()?.toAABB();
575
- if (bbox && bbox.isValid()) {
576
- const center = bbox.center;
577
- const extents = bbox.extents;
578
- let size = Math.min(Math.max(Math.max(extents.x, extents.y), extents.z), this._maxRootSize);
579
- if (Number.isNaN(size)) {
580
- size = this._maxRootSize;
581
- }
582
- locatedNode = this.locateNodeChain(curNode, center, size);
583
- if (!locatedNode) {
584
- let d = Math.min(Math.max(...Vector3.abs(bbox.minPoint), ...Vector3.abs(bbox.maxPoint)), this._maxRootSize);
585
- if (Number.isNaN(d)) {
586
- d = this._maxRootSize;
587
- }
588
- const newSize = nextPowerOf2(Math.ceil(Math.max(d * 2, 4 * size)));
589
- if (newSize <= this._maxRootSize) {
590
- this.resize(newSize);
591
- this.placeNode(node);
592
- return;
593
- } else {
594
- locatedNode = this.getRootNode();
595
- }
596
- }
597
- }
598
- }
599
- if (curNode !== locatedNode) {
600
- curNode?.removeNode(node);
601
- locatedNode?.addNode(node);
602
- this._nodeMap.set(node, locatedNode);
603
- }
604
- this._nodes.add(node);
605
- }
606
- /**
607
- * Removes a scene node from the octree
608
- * @param node - The scene node to be removed
609
- */ removeNode(node) {
610
- if (node.isGraphNode()) {
611
- const curNode = this._nodeMap.get(node) || null;
612
- if (curNode) {
613
- curNode.removeNode(node);
614
- this._nodeMap.delete(node);
615
- }
616
- this._nodes.delete(node);
617
- }
618
- }
619
- prune() {
620
- if (this._chunks.length === 1) {
621
- return;
622
- }
623
- for (const entry of this._chunks[1].nodeMap){
624
- if (entry[1].getNodes().length > 0) {
625
- return;
626
- }
627
- }
628
- this.resize(this._leafSize);
629
- }
630
- resize(size) {
631
- size = Math.max(nextPowerOf2(Math.ceil(size)), this._leafSize);
632
- if (size === this._rootSize) {
633
- return;
634
- }
635
- const nodes = [];
636
- for (const chunk of this._chunks){
637
- chunk.nodeMap.forEach((node)=>{
638
- nodes.push(...node.getNodes());
639
- });
640
- }
641
- this.initialize(size, this._leafSize);
642
- for (const node of nodes){
643
- this.placeNode(node);
644
- }
645
- }
646
- }
647
-
648
- export { Octree, OctreeNode, OctreeNodeChunk, OctreePlacement };
649
- //# sourceMappingURL=octree.js.map