@zephyr3d/scene 0.9.1 → 0.9.3

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 (522) hide show
  1. package/dist/animation/animationset.js +2 -0
  2. package/dist/animation/animationset.js.map +1 -1
  3. package/dist/animation/cloth/gpu_cloth_system.js +9 -1
  4. package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
  5. package/dist/animation/fixed_geometry_cache_track.js +5 -1
  6. package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
  7. package/dist/animation/geometry_cache_utils.js +20 -4
  8. package/dist/animation/geometry_cache_utils.js.map +1 -1
  9. package/dist/animation/ik/ik_angle_constraint.js +2 -6
  10. package/dist/animation/ik/ik_angle_constraint.js.map +1 -1
  11. package/dist/animation/ik/ik_chain_builder.js +68 -0
  12. package/dist/animation/ik/ik_chain_builder.js.map +1 -0
  13. package/dist/animation/ik/ik_pole_constraint.js +2 -7
  14. package/dist/animation/ik/ik_pole_constraint.js.map +1 -1
  15. package/dist/animation/ik/two_bone_ik_solver.js +2 -6
  16. package/dist/animation/ik/two_bone_ik_solver.js.map +1 -1
  17. package/dist/animation/joint_dynamics/collision.js +60 -12
  18. package/dist/animation/joint_dynamics/collision.js.map +1 -1
  19. package/dist/animation/joint_dynamics/constraints.js +20 -4
  20. package/dist/animation/joint_dynamics/constraints.js.map +1 -1
  21. package/dist/animation/joint_dynamics/controller.js +94 -46
  22. package/dist/animation/joint_dynamics/controller.js.map +1 -1
  23. package/dist/animation/joint_dynamics/math.js +16 -0
  24. package/dist/animation/joint_dynamics/math.js.map +1 -0
  25. package/dist/animation/joint_dynamics/solver.js +21 -11
  26. package/dist/animation/joint_dynamics/solver.js.map +1 -1
  27. package/dist/animation/joint_dynamics/types.js +15 -3
  28. package/dist/animation/joint_dynamics/types.js.map +1 -1
  29. package/dist/animation/pca_geometry_cache_track.js +5 -1
  30. package/dist/animation/pca_geometry_cache_track.js.map +1 -1
  31. package/dist/animation/skeleton.js +2 -2
  32. package/dist/animation/skeleton.js.map +1 -1
  33. package/dist/animation/skeleton_modifier.js +2 -6
  34. package/dist/animation/skeleton_modifier.js.map +1 -1
  35. package/dist/animation/spring/spring_particle.js +4 -4
  36. package/dist/animation/spring/spring_particle.js.map +1 -1
  37. package/dist/animation/spring/spring_system.js +13 -40
  38. package/dist/animation/spring/spring_system.js.map +1 -1
  39. package/dist/animation/spring2/constraints.js.map +1 -1
  40. package/dist/animation/spring2/controller.js +64 -64
  41. package/dist/animation/spring2/controller.js.map +1 -1
  42. package/dist/animation/spring2/math.js.map +1 -1
  43. package/dist/animation/spring2/spring_system.js +8 -8
  44. package/dist/animation/spring2/spring_system.js.map +1 -1
  45. package/dist/app/app.js.map +1 -1
  46. package/dist/app/engine.js +1 -1
  47. package/dist/app/engine.js.map +1 -1
  48. package/dist/app/screen.js +4 -4
  49. package/dist/app/screen.js.map +1 -1
  50. package/dist/app/scriptingsystem.js +24 -1
  51. package/dist/app/scriptingsystem.js.map +1 -1
  52. package/dist/app/scriptregistry.js +22 -1
  53. package/dist/app/scriptregistry.js.map +1 -1
  54. package/dist/asset/assetmanager.js +2 -2
  55. package/dist/asset/assetmanager.js.map +1 -1
  56. package/dist/asset/model.js +60 -60
  57. package/dist/asset/model.js.map +1 -1
  58. package/dist/camera/camera.js +1 -1
  59. package/dist/camera/camera.js.map +1 -1
  60. package/dist/camera/orbit.js.map +1 -1
  61. package/dist/index.d.ts +795 -266
  62. package/dist/index.js +3 -2
  63. package/dist/index.js.map +1 -1
  64. package/dist/material/material.js +3 -1
  65. package/dist/material/material.js.map +1 -1
  66. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  67. package/dist/material/shader/helper.js +281 -278
  68. package/dist/material/shader/helper.js.map +1 -1
  69. package/dist/material/sprite.js +6 -6
  70. package/dist/material/sprite.js.map +1 -1
  71. package/dist/material/terrain-cm.js +2 -2
  72. package/dist/material/terrain-cm.js.map +1 -1
  73. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +38 -0
  74. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +1 -0
  75. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +10 -0
  76. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +1 -0
  77. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +127 -0
  78. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +1 -0
  79. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +263 -0
  80. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +1 -0
  81. package/dist/posteffect/taa.js +31 -39
  82. package/dist/posteffect/taa.js.map +1 -1
  83. package/dist/render/cluster_light.js +3 -4
  84. package/dist/render/cluster_light.js.map +1 -1
  85. package/dist/render/drawable.js +5 -1
  86. package/dist/render/drawable.js.map +1 -1
  87. package/dist/render/rendergraph/device_pool_allocator.js +29 -3
  88. package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
  89. package/dist/render/rendergraph/executor.js +283 -33
  90. package/dist/render/rendergraph/executor.js.map +1 -1
  91. package/dist/render/rendergraph/forward_plus_builder.js +338 -108
  92. package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
  93. package/dist/render/rendergraph/history_resource_manager.js +195 -115
  94. package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
  95. package/dist/render/rendergraph/history_resources.js +10 -0
  96. package/dist/render/rendergraph/history_resources.js.map +1 -0
  97. package/dist/render/rendergraph/rendergraph.js +162 -35
  98. package/dist/render/rendergraph/rendergraph.js.map +1 -1
  99. package/dist/render/rendergraph/types.js +25 -5
  100. package/dist/render/rendergraph/types.js.map +1 -1
  101. package/dist/render/rendertarget.js +5 -1
  102. package/dist/render/rendertarget.js.map +1 -1
  103. package/dist/render/screenrendertarget.js +5 -1
  104. package/dist/render/screenrendertarget.js.map +1 -1
  105. package/dist/render/sky.js +4 -4
  106. package/dist/render/sky.js.map +1 -1
  107. package/dist/scene/basesprite.js +2 -2
  108. package/dist/scene/basesprite.js.map +1 -1
  109. package/dist/scene/graph_node.js +1 -1
  110. package/dist/scene/graph_node.js.map +1 -1
  111. package/dist/scene/mesh.js +81 -97
  112. package/dist/scene/mesh.js.map +1 -1
  113. package/dist/scene/particlesys.js +1 -1
  114. package/dist/scene/particlesys.js.map +1 -1
  115. package/dist/scene/scene_node.js +228 -228
  116. package/dist/scene/scene_node.js.map +1 -1
  117. package/dist/scene/script_attachment.js +15 -3
  118. package/dist/scene/script_attachment.js.map +1 -1
  119. package/dist/scene/terrain-cm/terrain-cm.js +3 -3
  120. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
  121. package/dist/shadow/shadowmapper.js.map +1 -1
  122. package/dist/shapes/box.js +1 -1
  123. package/dist/shapes/box.js.map +1 -1
  124. package/dist/shapes/capsule.js +0 -3
  125. package/dist/shapes/capsule.js.map +1 -1
  126. package/dist/shapes/cylinder.js +0 -3
  127. package/dist/shapes/cylinder.js.map +1 -1
  128. package/dist/shapes/plane.js +0 -3
  129. package/dist/shapes/plane.js.map +1 -1
  130. package/dist/shapes/tetrahedron.js +3 -9
  131. package/dist/shapes/tetrahedron.js.map +1 -1
  132. package/dist/shapes/torus.js +94 -66
  133. package/dist/shapes/torus.js.map +1 -1
  134. package/dist/src/animation/animation.js +127 -0
  135. package/dist/src/animation/animation.js.map +1 -0
  136. package/dist/src/animation/animationset.js +255 -0
  137. package/dist/src/animation/animationset.js.map +1 -0
  138. package/dist/src/animation/animationtrack.js +34 -0
  139. package/dist/src/animation/animationtrack.js.map +1 -0
  140. package/dist/src/animation/eulerrotationtrack.js +52 -0
  141. package/dist/src/animation/eulerrotationtrack.js.map +1 -0
  142. package/dist/src/animation/morphtarget.js +93 -0
  143. package/dist/src/animation/morphtarget.js.map +1 -0
  144. package/dist/src/animation/morphtrack.js +70 -0
  145. package/dist/src/animation/morphtrack.js.map +1 -0
  146. package/dist/src/animation/proptrack.js +161 -0
  147. package/dist/src/animation/proptrack.js.map +1 -0
  148. package/dist/src/animation/rotationtrack.js +51 -0
  149. package/dist/src/animation/rotationtrack.js.map +1 -0
  150. package/dist/src/animation/scaletrack.js +50 -0
  151. package/dist/src/animation/scaletrack.js.map +1 -0
  152. package/dist/src/animation/skeleton.js +204 -0
  153. package/dist/src/animation/skeleton.js.map +1 -0
  154. package/dist/src/animation/translationtrack.js +50 -0
  155. package/dist/src/animation/translationtrack.js.map +1 -0
  156. package/dist/src/app/app.js +129 -0
  157. package/dist/src/app/app.js.map +1 -0
  158. package/dist/src/app/inputmgr.js +267 -0
  159. package/dist/src/app/inputmgr.js.map +1 -0
  160. package/dist/src/asset/assetmanager.js +404 -0
  161. package/dist/src/asset/assetmanager.js.map +1 -0
  162. package/dist/src/asset/builtin.js +337 -0
  163. package/dist/src/asset/builtin.js.map +1 -0
  164. package/dist/src/asset/loaders/dds/dds.js +470 -0
  165. package/dist/src/asset/loaders/dds/dds.js.map +1 -0
  166. package/dist/src/asset/loaders/dds/dds_loader.js +28 -0
  167. package/dist/src/asset/loaders/dds/dds_loader.js.map +1 -0
  168. package/dist/src/asset/loaders/gltf/gltf_loader.js +1265 -0
  169. package/dist/src/asset/loaders/gltf/gltf_loader.js.map +1 -0
  170. package/dist/src/asset/loaders/gltf/helpers.js +327 -0
  171. package/dist/src/asset/loaders/gltf/helpers.js.map +1 -0
  172. package/dist/src/asset/loaders/hdr/hdr.js +180 -0
  173. package/dist/src/asset/loaders/hdr/hdr.js.map +1 -0
  174. package/dist/src/asset/loaders/image/tga_Loader.js +116 -0
  175. package/dist/src/asset/loaders/image/tga_Loader.js.map +1 -0
  176. package/dist/src/asset/loaders/image/webimage_loader.js +63 -0
  177. package/dist/src/asset/loaders/image/webimage_loader.js.map +1 -0
  178. package/dist/src/asset/loaders/loader.js +45 -0
  179. package/dist/src/asset/loaders/loader.js.map +1 -0
  180. package/dist/src/asset/model.js +414 -0
  181. package/dist/src/asset/model.js.map +1 -0
  182. package/dist/src/blitter/bilateralblur.js +221 -0
  183. package/dist/src/blitter/bilateralblur.js.map +1 -0
  184. package/dist/src/blitter/blitter.js +390 -0
  185. package/dist/src/blitter/blitter.js.map +1 -0
  186. package/dist/src/blitter/box.js +118 -0
  187. package/dist/src/blitter/box.js.map +1 -0
  188. package/dist/src/blitter/copy.js +22 -0
  189. package/dist/src/blitter/copy.js.map +1 -0
  190. package/dist/src/blitter/gaussianblur.js +228 -0
  191. package/dist/src/blitter/gaussianblur.js.map +1 -0
  192. package/dist/src/camera/base.js +92 -0
  193. package/dist/src/camera/base.js.map +1 -0
  194. package/dist/src/camera/camera.js +1005 -0
  195. package/dist/src/camera/camera.js.map +1 -0
  196. package/dist/src/camera/fps.js +238 -0
  197. package/dist/src/camera/fps.js.map +1 -0
  198. package/dist/src/camera/orbit.js +245 -0
  199. package/dist/src/camera/orbit.js.map +1 -0
  200. package/dist/src/camera/orthocamera.js +167 -0
  201. package/dist/src/camera/orthocamera.js.map +1 -0
  202. package/dist/src/camera/perspectivecamera.js +141 -0
  203. package/dist/src/camera/perspectivecamera.js.map +1 -0
  204. package/dist/src/index.js +120 -0
  205. package/dist/src/index.js.map +1 -0
  206. package/dist/src/material/blinn.js +81 -0
  207. package/dist/src/material/blinn.js.map +1 -0
  208. package/dist/src/material/grassmaterial.js +113 -0
  209. package/dist/src/material/grassmaterial.js.map +1 -0
  210. package/dist/src/material/lambert.js +92 -0
  211. package/dist/src/material/lambert.js.map +1 -0
  212. package/dist/src/material/material.js +301 -0
  213. package/dist/src/material/material.js.map +1 -0
  214. package/dist/src/material/meshmaterial.js +704 -0
  215. package/dist/src/material/meshmaterial.js.map +1 -0
  216. package/dist/src/material/mixins/albedocolor.js +76 -0
  217. package/dist/src/material/mixins/albedocolor.js.map +1 -0
  218. package/dist/src/material/mixins/foliage.js +47 -0
  219. package/dist/src/material/mixins/foliage.js.map +1 -0
  220. package/dist/src/material/mixins/lightmodel/blinnphong.js +112 -0
  221. package/dist/src/material/mixins/lightmodel/blinnphong.js.map +1 -0
  222. package/dist/src/material/mixins/lightmodel/lambert.js +58 -0
  223. package/dist/src/material/mixins/lightmodel/lambert.js.map +1 -0
  224. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +178 -0
  225. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -0
  226. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +139 -0
  227. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -0
  228. package/dist/src/material/mixins/lit.js +476 -0
  229. package/dist/src/material/mixins/lit.js.map +1 -0
  230. package/dist/src/material/mixins/pbr/common.js +918 -0
  231. package/dist/src/material/mixins/pbr/common.js.map +1 -0
  232. package/dist/src/material/mixins/texture.js +172 -0
  233. package/dist/src/material/mixins/texture.js.map +1 -0
  234. package/dist/src/material/mixins/vertexcolor.js +56 -0
  235. package/dist/src/material/mixins/vertexcolor.js.map +1 -0
  236. package/dist/src/material/particle.js +178 -0
  237. package/dist/src/material/particle.js.map +1 -0
  238. package/dist/src/material/pbrmr.js +97 -0
  239. package/dist/src/material/pbrmr.js.map +1 -0
  240. package/dist/src/material/pbrsg.js +97 -0
  241. package/dist/src/material/pbrsg.js.map +1 -0
  242. package/dist/src/material/shader/helper.js +1209 -0
  243. package/dist/src/material/shader/helper.js.map +1 -0
  244. package/dist/src/material/terrain-cm.js +606 -0
  245. package/dist/src/material/terrain-cm.js.map +1 -0
  246. package/dist/src/material/terrainmaterial.js +375 -0
  247. package/dist/src/material/terrainmaterial.js.map +1 -0
  248. package/dist/src/material/unlit.js +41 -0
  249. package/dist/src/material/unlit.js.map +1 -0
  250. package/dist/src/material/water.js +417 -0
  251. package/dist/src/material/water.js.map +1 -0
  252. package/dist/src/posteffect/bloom.js +361 -0
  253. package/dist/src/posteffect/bloom.js.map +1 -0
  254. package/dist/src/posteffect/compositor.js +226 -0
  255. package/dist/src/posteffect/compositor.js.map +1 -0
  256. package/dist/src/posteffect/fxaa.js +273 -0
  257. package/dist/src/posteffect/fxaa.js.map +1 -0
  258. package/dist/src/posteffect/grayscale.js +69 -0
  259. package/dist/src/posteffect/grayscale.js.map +1 -0
  260. package/dist/src/posteffect/motionblur.js +96 -0
  261. package/dist/src/posteffect/motionblur.js.map +1 -0
  262. package/dist/src/posteffect/posteffect.js +126 -0
  263. package/dist/src/posteffect/posteffect.js.map +1 -0
  264. package/dist/src/posteffect/sao.js +324 -0
  265. package/dist/src/posteffect/sao.js.map +1 -0
  266. package/dist/src/posteffect/ssr.js +489 -0
  267. package/dist/src/posteffect/ssr.js.map +1 -0
  268. package/dist/src/posteffect/taa.js +172 -0
  269. package/dist/src/posteffect/taa.js.map +1 -0
  270. package/dist/src/posteffect/tonemap.js +94 -0
  271. package/dist/src/posteffect/tonemap.js.map +1 -0
  272. package/dist/src/render/abuffer_oit.js +361 -0
  273. package/dist/src/render/abuffer_oit.js.map +1 -0
  274. package/dist/src/render/clipmap.js +851 -0
  275. package/dist/src/render/clipmap.js.map +1 -0
  276. package/dist/src/render/cluster_light.js +333 -0
  277. package/dist/src/render/cluster_light.js.map +1 -0
  278. package/dist/src/render/cull_visitor.js +187 -0
  279. package/dist/src/render/cull_visitor.js.map +1 -0
  280. package/dist/src/render/depthpass.js +68 -0
  281. package/dist/src/render/depthpass.js.map +1 -0
  282. package/dist/src/render/drawable_mixin.js +227 -0
  283. package/dist/src/render/drawable_mixin.js.map +1 -0
  284. package/dist/src/render/envlight.js +463 -0
  285. package/dist/src/render/envlight.js.map +1 -0
  286. package/dist/src/render/fbm_wavegenerator.js +251 -0
  287. package/dist/src/render/fbm_wavegenerator.js.map +1 -0
  288. package/dist/src/render/fft_wavegenerator.js +1006 -0
  289. package/dist/src/render/fft_wavegenerator.js.map +1 -0
  290. package/dist/src/render/fullscreenquad.js +38 -0
  291. package/dist/src/render/fullscreenquad.js.map +1 -0
  292. package/dist/src/render/gerstner_wavegenerator.js +314 -0
  293. package/dist/src/render/gerstner_wavegenerator.js.map +1 -0
  294. package/dist/src/render/globalbindgroup_allocator.js +60 -0
  295. package/dist/src/render/globalbindgroup_allocator.js.map +1 -0
  296. package/dist/src/render/hzb.js +273 -0
  297. package/dist/src/render/hzb.js.map +1 -0
  298. package/dist/src/render/lightpass.js +172 -0
  299. package/dist/src/render/lightpass.js.map +1 -0
  300. package/dist/src/render/objectcolorpass.js +51 -0
  301. package/dist/src/render/objectcolorpass.js.map +1 -0
  302. package/dist/src/render/primitive.js +364 -0
  303. package/dist/src/render/primitive.js.map +1 -0
  304. package/dist/src/render/render_queue.js +467 -0
  305. package/dist/src/render/render_queue.js.map +1 -0
  306. package/dist/src/render/renderbundle_wrapper.js +152 -0
  307. package/dist/src/render/renderbundle_wrapper.js.map +1 -0
  308. package/dist/src/render/renderer.js +455 -0
  309. package/dist/src/render/renderer.js.map +1 -0
  310. package/dist/src/render/renderpass.js +200 -0
  311. package/dist/src/render/renderpass.js.map +1 -0
  312. package/dist/src/render/shadowmap_pass.js +56 -0
  313. package/dist/src/render/shadowmap_pass.js.map +1 -0
  314. package/dist/src/render/sky.js +1103 -0
  315. package/dist/src/render/sky.js.map +1 -0
  316. package/dist/src/render/weightedblended_oit.js +168 -0
  317. package/dist/src/render/weightedblended_oit.js.map +1 -0
  318. package/dist/src/scene/batchgroup.js +162 -0
  319. package/dist/src/scene/batchgroup.js.map +1 -0
  320. package/dist/src/scene/environment.js +209 -0
  321. package/dist/src/scene/environment.js.map +1 -0
  322. package/dist/src/scene/graph_node.js +72 -0
  323. package/dist/src/scene/graph_node.js.map +1 -0
  324. package/dist/src/scene/light.js +416 -0
  325. package/dist/src/scene/light.js.map +1 -0
  326. package/dist/src/scene/mesh.js +341 -0
  327. package/dist/src/scene/mesh.js.map +1 -0
  328. package/dist/src/scene/octree.js +649 -0
  329. package/dist/src/scene/octree.js.map +1 -0
  330. package/dist/src/scene/particlesys.js +738 -0
  331. package/dist/src/scene/particlesys.js.map +1 -0
  332. package/dist/src/scene/raycast_visitor.js +103 -0
  333. package/dist/src/scene/raycast_visitor.js.map +1 -0
  334. package/dist/src/scene/scene.js +284 -0
  335. package/dist/src/scene/scene.js.map +1 -0
  336. package/dist/src/scene/scene_node.js +732 -0
  337. package/dist/src/scene/scene_node.js.map +1 -0
  338. package/dist/src/scene/terrain/grass.js +278 -0
  339. package/dist/src/scene/terrain/grass.js.map +1 -0
  340. package/dist/src/scene/terrain/heightfield.js +475 -0
  341. package/dist/src/scene/terrain/heightfield.js.map +1 -0
  342. package/dist/src/scene/terrain/patch.js +530 -0
  343. package/dist/src/scene/terrain/patch.js.map +1 -0
  344. package/dist/src/scene/terrain/quadtree.js +461 -0
  345. package/dist/src/scene/terrain/quadtree.js.map +1 -0
  346. package/dist/src/scene/terrain/terrain.js +246 -0
  347. package/dist/src/scene/terrain/terrain.js.map +1 -0
  348. package/dist/src/scene/terrain-cm/grass.js +594 -0
  349. package/dist/src/scene/terrain-cm/grass.js.map +1 -0
  350. package/dist/src/scene/terrain-cm/grassmaterial.js +159 -0
  351. package/dist/src/scene/terrain-cm/grassmaterial.js.map +1 -0
  352. package/dist/src/scene/terrain-cm/terrain-cm.js +538 -0
  353. package/dist/src/scene/terrain-cm/terrain-cm.js.map +1 -0
  354. package/dist/src/scene/water.js +374 -0
  355. package/dist/src/scene/water.js.map +1 -0
  356. package/dist/src/shaders/atmosphere.js +957 -0
  357. package/dist/src/shaders/atmosphere.js.map +1 -0
  358. package/dist/src/shaders/fog.js +112 -0
  359. package/dist/src/shaders/fog.js.map +1 -0
  360. package/dist/src/shaders/misc.js +266 -0
  361. package/dist/src/shaders/misc.js.map +1 -0
  362. package/dist/src/shaders/noise.js +222 -0
  363. package/dist/src/shaders/noise.js.map +1 -0
  364. package/dist/src/shaders/pbr.js +51 -0
  365. package/dist/src/shaders/pbr.js.map +1 -0
  366. package/dist/src/shaders/shadow.js +636 -0
  367. package/dist/src/shaders/shadow.js.map +1 -0
  368. package/dist/src/shaders/ssr.js +490 -0
  369. package/dist/src/shaders/ssr.js.map +1 -0
  370. package/dist/src/shaders/temporal.js +215 -0
  371. package/dist/src/shaders/temporal.js.map +1 -0
  372. package/dist/src/shaders/water.js +756 -0
  373. package/dist/src/shaders/water.js.map +1 -0
  374. package/dist/src/shadow/esm.js +237 -0
  375. package/dist/src/shadow/esm.js.map +1 -0
  376. package/dist/src/shadow/pcf_opt.js +181 -0
  377. package/dist/src/shadow/pcf_opt.js.map +1 -0
  378. package/dist/src/shadow/pcf_pd.js +189 -0
  379. package/dist/src/shadow/pcf_pd.js.map +1 -0
  380. package/dist/src/shadow/shader.js +37 -0
  381. package/dist/src/shadow/shader.js.map +1 -0
  382. package/dist/src/shadow/shadow_impl.js +15 -0
  383. package/dist/src/shadow/shadow_impl.js.map +1 -0
  384. package/dist/src/shadow/shadowmapper.js +790 -0
  385. package/dist/src/shadow/shadowmapper.js.map +1 -0
  386. package/dist/src/shadow/ssm.js +159 -0
  387. package/dist/src/shadow/ssm.js.map +1 -0
  388. package/dist/src/shadow/vsm.js +297 -0
  389. package/dist/src/shadow/vsm.js.map +1 -0
  390. package/dist/src/shapes/box.js +386 -0
  391. package/dist/src/shapes/box.js.map +1 -0
  392. package/dist/src/shapes/cylinder.js +125 -0
  393. package/dist/src/shapes/cylinder.js.map +1 -0
  394. package/dist/src/shapes/plane.js +88 -0
  395. package/dist/src/shapes/plane.js.map +1 -0
  396. package/dist/src/shapes/shape.js +87 -0
  397. package/dist/src/shapes/shape.js.map +1 -0
  398. package/dist/src/shapes/sphere.js +114 -0
  399. package/dist/src/shapes/sphere.js.map +1 -0
  400. package/dist/src/shapes/tetrahedron.js +188 -0
  401. package/dist/src/shapes/tetrahedron.js.map +1 -0
  402. package/dist/src/shapes/torus.js +111 -0
  403. package/dist/src/shapes/torus.js.map +1 -0
  404. package/dist/src/utility/aabbtree.js +400 -0
  405. package/dist/src/utility/aabbtree.js.map +1 -0
  406. package/dist/src/utility/bounding_volume.js +29 -0
  407. package/dist/src/utility/bounding_volume.js.map +1 -0
  408. package/dist/src/utility/debug.js +28 -0
  409. package/dist/src/utility/debug.js.map +1 -0
  410. package/dist/src/utility/draco/decoder.js +116 -0
  411. package/dist/src/utility/draco/decoder.js.map +1 -0
  412. package/dist/src/utility/misc.js +105 -0
  413. package/dist/src/utility/misc.js.map +1 -0
  414. package/dist/src/utility/panorama.js +163 -0
  415. package/dist/src/utility/panorama.js.map +1 -0
  416. package/dist/src/utility/pmrem.js +354 -0
  417. package/dist/src/utility/pmrem.js.map +1 -0
  418. package/dist/src/utility/rendermipmap.js +115 -0
  419. package/dist/src/utility/rendermipmap.js.map +1 -0
  420. package/dist/src/utility/serialization/json.js +402 -0
  421. package/dist/src/utility/serialization/json.js.map +1 -0
  422. package/dist/src/utility/serialization/manager.js +623 -0
  423. package/dist/src/utility/serialization/manager.js.map +1 -0
  424. package/dist/src/utility/serialization/scene/animation.js +248 -0
  425. package/dist/src/utility/serialization/scene/animation.js.map +1 -0
  426. package/dist/src/utility/serialization/scene/batch.js +59 -0
  427. package/dist/src/utility/serialization/scene/batch.js.map +1 -0
  428. package/dist/src/utility/serialization/scene/camera.js +790 -0
  429. package/dist/src/utility/serialization/scene/camera.js.map +1 -0
  430. package/dist/src/utility/serialization/scene/common.js +222 -0
  431. package/dist/src/utility/serialization/scene/common.js.map +1 -0
  432. package/dist/src/utility/serialization/scene/light.js +575 -0
  433. package/dist/src/utility/serialization/scene/light.js.map +1 -0
  434. package/dist/src/utility/serialization/scene/material.js +1111 -0
  435. package/dist/src/utility/serialization/scene/material.js.map +1 -0
  436. package/dist/src/utility/serialization/scene/mesh.js +148 -0
  437. package/dist/src/utility/serialization/scene/mesh.js.map +1 -0
  438. package/dist/src/utility/serialization/scene/misc.js +39 -0
  439. package/dist/src/utility/serialization/scene/misc.js.map +1 -0
  440. package/dist/src/utility/serialization/scene/node.js +451 -0
  441. package/dist/src/utility/serialization/scene/node.js.map +1 -0
  442. package/dist/src/utility/serialization/scene/particle.js +425 -0
  443. package/dist/src/utility/serialization/scene/particle.js.map +1 -0
  444. package/dist/src/utility/serialization/scene/primitive.js +692 -0
  445. package/dist/src/utility/serialization/scene/primitive.js.map +1 -0
  446. package/dist/src/utility/serialization/scene/scene.js +704 -0
  447. package/dist/src/utility/serialization/scene/scene.js.map +1 -0
  448. package/dist/src/utility/serialization/scene/terrain.js +488 -0
  449. package/dist/src/utility/serialization/scene/terrain.js.map +1 -0
  450. package/dist/src/utility/serialization/scene/water.js +465 -0
  451. package/dist/src/utility/serialization/scene/water.js.map +1 -0
  452. package/dist/src/utility/shprojector.js +297 -0
  453. package/dist/src/utility/shprojector.js.map +1 -0
  454. package/dist/src/utility/textures/ggxlut.js +213 -0
  455. package/dist/src/utility/textures/ggxlut.js.map +1 -0
  456. package/dist/src/utility/textures/gradientnoise.js +62 -0
  457. package/dist/src/utility/textures/gradientnoise.js.map +1 -0
  458. package/dist/src/utility/textures/randomnoise.js +41 -0
  459. package/dist/src/utility/textures/randomnoise.js.map +1 -0
  460. package/dist/src/values.js +162 -0
  461. package/dist/src/values.js.map +1 -0
  462. package/dist/utility/blueprint/material/common.js +7 -0
  463. package/dist/utility/blueprint/material/common.js.map +1 -0
  464. package/dist/utility/blueprint/material/inputs.js +3 -3
  465. package/dist/utility/blueprint/material/inputs.js.map +1 -1
  466. package/dist/utility/blueprint/material/ir.js +4 -4
  467. package/dist/utility/blueprint/material/ir.js.map +1 -1
  468. package/dist/utility/serialization/blueprint/constants.js +255 -0
  469. package/dist/utility/serialization/blueprint/constants.js.map +1 -0
  470. package/dist/utility/serialization/blueprint/material/constants.js +203 -0
  471. package/dist/utility/serialization/blueprint/material/constants.js.map +1 -0
  472. package/dist/utility/serialization/blueprint/material/texture.js +165 -0
  473. package/dist/utility/serialization/blueprint/material/texture.js.map +1 -0
  474. package/dist/utility/serialization/manager.js +299 -268
  475. package/dist/utility/serialization/manager.js.map +1 -1
  476. package/dist/utility/serialization/scene/animation.js +45 -0
  477. package/dist/utility/serialization/scene/animation.js.map +1 -1
  478. package/dist/utility/serialization/scene/camera.js +53 -0
  479. package/dist/utility/serialization/scene/camera.js.map +1 -1
  480. package/dist/utility/serialization/scene/common.js +10 -0
  481. package/dist/utility/serialization/scene/common.js.map +1 -1
  482. package/dist/utility/serialization/scene/light.js +30 -0
  483. package/dist/utility/serialization/scene/light.js.map +1 -1
  484. package/dist/utility/serialization/scene/material.js +63 -0
  485. package/dist/utility/serialization/scene/material.js.map +1 -1
  486. package/dist/utility/serialization/scene/mesh.js +11 -0
  487. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  488. package/dist/utility/serialization/scene/misc.js +2 -0
  489. package/dist/utility/serialization/scene/misc.js.map +1 -1
  490. package/dist/utility/serialization/scene/node.js +19 -0
  491. package/dist/utility/serialization/scene/node.js.map +1 -1
  492. package/dist/utility/serialization/scene/particle.js +22 -0
  493. package/dist/utility/serialization/scene/particle.js.map +1 -1
  494. package/dist/utility/serialization/scene/primitive.js +33 -0
  495. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  496. package/dist/utility/serialization/scene/scene.js +39 -0
  497. package/dist/utility/serialization/scene/scene.js.map +1 -1
  498. package/dist/utility/serialization/scene/script.js +2 -0
  499. package/dist/utility/serialization/scene/script.js.map +1 -1
  500. package/dist/utility/serialization/scene/sprite.js +6 -0
  501. package/dist/utility/serialization/scene/sprite.js.map +1 -1
  502. package/dist/utility/serialization/scene/terrain.js +9 -0
  503. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  504. package/dist/utility/serialization/scene/water.js +21 -0
  505. package/dist/utility/serialization/scene/water.js.map +1 -1
  506. package/dist/utility/serialization/types.js +5 -1
  507. package/dist/utility/serialization/types.js.map +1 -1
  508. package/dist/values.js +49 -53
  509. package/dist/values.js.map +1 -1
  510. package/package.json +2 -2
  511. package/dist/animation/joint_dynamics/vrm_spring_bone.js +0 -46
  512. package/dist/animation/joint_dynamics/vrm_spring_bone.js.map +0 -1
  513. package/dist/animation/spring/spring_bone.js +0 -240
  514. package/dist/animation/spring/spring_bone.js.map +0 -1
  515. package/dist/animation/spring/spring_bone_collider.js +0 -198
  516. package/dist/animation/spring/spring_bone_collider.js.map +0 -1
  517. package/dist/animation/spring/spring_bone_constraint.js +0 -170
  518. package/dist/animation/spring/spring_bone_constraint.js.map +0 -1
  519. package/dist/animation/spring/spring_bone_system.js +0 -328
  520. package/dist/animation/spring/spring_bone_system.js.map +0 -1
  521. package/dist/render/sky_motion_vector.js +0 -85
  522. package/dist/render/sky_motion_vector.js.map +0 -1
@@ -0,0 +1,127 @@
1
+ import { ScriptRegistry } from './scriptregistry.js';
2
+ import { HttpFS } from '@zephyr3d/base';
3
+ import { RuntimeScript } from './runtimescript.js';
4
+
5
+ class ScriptingSystem {
6
+ _registry;
7
+ _hostScripts = new Map();
8
+ _onLoadError;
9
+ _importComment;
10
+ constructor(opts = {}){
11
+ this._registry = new ScriptRegistry(opts.VFS ?? new HttpFS('./'), opts.scriptsRoot ?? '/', opts.editorMode ?? false);
12
+ this._importComment = opts.importComment;
13
+ this._onLoadError = opts.onLoadError;
14
+ }
15
+ get registry() {
16
+ return this._registry;
17
+ }
18
+ // Attachs a script to object and returns the script instance
19
+ async attachScript(host, module) {
20
+ try {
21
+ const url = await this._registry.resolveRuntimeUrl(module);
22
+ if (!url) {
23
+ return null;
24
+ }
25
+ const mod = await import(url + (this._importComment ?? ''));
26
+ let instance;
27
+ if (typeof mod?.default === 'function') {
28
+ // default export
29
+ instance = new mod.default();
30
+ if (instance instanceof RuntimeScript) {
31
+ const P = instance.onCreated();
32
+ if (P instanceof Promise) {
33
+ await P;
34
+ }
35
+ }
36
+ } else {
37
+ console.warn(`Script '${module}' does not have RuntimeScript class exported as default`);
38
+ return null;
39
+ }
40
+ const attached = {
41
+ id: module,
42
+ url,
43
+ instance
44
+ };
45
+ let list = this._hostScripts.get(host);
46
+ if (!list) {
47
+ list = [];
48
+ this._hostScripts.set(host, list);
49
+ if (host) {
50
+ host.on('dispose', ()=>{
51
+ this.detachScript(host);
52
+ });
53
+ }
54
+ }
55
+ list.push(attached);
56
+ this.registerHost(host);
57
+ const P = instance.onAttached(host);
58
+ if (P instanceof Promise) {
59
+ await P;
60
+ }
61
+ return attached.instance;
62
+ } catch (e) {
63
+ this._onLoadError?.(e, module);
64
+ return null;
65
+ }
66
+ }
67
+ // Detach script from host object
68
+ detachScript(host, idOrInstance) {
69
+ const list = this._hostScripts.get(host);
70
+ if (!list || list.length === 0) {
71
+ return false;
72
+ }
73
+ let removed = false;
74
+ for(let i = list.length - 1; i >= 0; i--){
75
+ const it = list[i];
76
+ const hit = !idOrInstance || typeof idOrInstance === 'string' ? it.id === idOrInstance : it.instance === idOrInstance;
77
+ if (hit) {
78
+ try {
79
+ it.instance.onDetached();
80
+ } catch (err) {
81
+ console.error(`Error occured at onDetach() of module '${it.id}': ${err}`);
82
+ }
83
+ try {
84
+ it.instance.onDestroy();
85
+ } catch (err) {
86
+ console.error(`Error occured at onDestroy() of module '${it.id}': ${err}`);
87
+ }
88
+ list.splice(i, 1);
89
+ removed = true;
90
+ }
91
+ }
92
+ if (list.length === 0) {
93
+ this._hostScripts.delete(host);
94
+ this.unregisterHost(host);
95
+ }
96
+ return removed;
97
+ }
98
+ // Update script instances
99
+ update(deltaTime, elapsedTime) {
100
+ if (this._hostScripts.size === 0) {
101
+ return;
102
+ }
103
+ for (const list of this._hostScripts.values()){
104
+ for (const s of list){
105
+ try {
106
+ s.instance.onUpdate(deltaTime, elapsedTime);
107
+ } catch (err) {
108
+ console.error(`Error occured at onUpdate() of module '${s.id}': ${err}`);
109
+ }
110
+ }
111
+ }
112
+ }
113
+ // Detach all script instances
114
+ detachAllScripts() {
115
+ while(this._hostScripts.size > 0){
116
+ for (const entry of this._hostScripts){
117
+ this.detachScript(entry[0]);
118
+ }
119
+ }
120
+ }
121
+ // Preserved functions
122
+ registerHost(_host) {}
123
+ unregisterHost(_host) {}
124
+ }
125
+
126
+ export { ScriptingSystem };
127
+ //# sourceMappingURL=scriptingsystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scriptingsystem.js","sources":["../../../../../../node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js"],"sourcesContent":["import { ScriptRegistry } from './scriptregistry.js';\nimport { HttpFS } from '@zephyr3d/base';\nimport { RuntimeScript } from './runtimescript.js';\n\nclass ScriptingSystem {\n _registry;\n _hostScripts = new Map();\n _onLoadError;\n _importComment;\n constructor(opts = {}){\n this._registry = new ScriptRegistry(opts.VFS ?? new HttpFS('./'), opts.scriptsRoot ?? '/', opts.editorMode ?? false);\n this._importComment = opts.importComment;\n this._onLoadError = opts.onLoadError;\n }\n get registry() {\n return this._registry;\n }\n // Attachs a script to object and returns the script instance\n async attachScript(host, module) {\n try {\n const url = await this._registry.resolveRuntimeUrl(module);\n if (!url) {\n return null;\n }\n const mod = await import(url + (this._importComment ?? ''));\n let instance;\n if (typeof mod?.default === 'function') {\n // default export\n instance = new mod.default();\n if (instance instanceof RuntimeScript) {\n const P = instance.onCreated();\n if (P instanceof Promise) {\n await P;\n }\n }\n } else {\n console.warn(`Script '${module}' does not have RuntimeScript class exported as default`);\n return null;\n }\n const attached = {\n id: module,\n url,\n instance\n };\n let list = this._hostScripts.get(host);\n if (!list) {\n list = [];\n this._hostScripts.set(host, list);\n if (host) {\n host.on('dispose', ()=>{\n this.detachScript(host);\n });\n }\n }\n list.push(attached);\n this.registerHost(host);\n const P = instance.onAttached(host);\n if (P instanceof Promise) {\n await P;\n }\n return attached.instance;\n } catch (e) {\n this._onLoadError?.(e, module);\n return null;\n }\n }\n // Detach script from host object\n detachScript(host, idOrInstance) {\n const list = this._hostScripts.get(host);\n if (!list || list.length === 0) {\n return false;\n }\n let removed = false;\n for(let i = list.length - 1; i >= 0; i--){\n const it = list[i];\n const hit = !idOrInstance || typeof idOrInstance === 'string' ? it.id === idOrInstance : it.instance === idOrInstance;\n if (hit) {\n try {\n it.instance.onDetached();\n } catch (err) {\n console.error(`Error occured at onDetach() of module '${it.id}': ${err}`);\n }\n try {\n it.instance.onDestroy();\n } catch (err) {\n console.error(`Error occured at onDestroy() of module '${it.id}': ${err}`);\n }\n list.splice(i, 1);\n removed = true;\n }\n }\n if (list.length === 0) {\n this._hostScripts.delete(host);\n this.unregisterHost(host);\n }\n return removed;\n }\n // Update script instances\n update(deltaTime, elapsedTime) {\n if (this._hostScripts.size === 0) {\n return;\n }\n for (const list of this._hostScripts.values()){\n for (const s of list){\n try {\n s.instance.onUpdate(deltaTime, elapsedTime);\n } catch (err) {\n console.error(`Error occured at onUpdate() of module '${s.id}': ${err}`);\n }\n }\n }\n }\n // Detach all script instances\n detachAllScripts() {\n while(this._hostScripts.size > 0){\n for (const entry of this._hostScripts){\n this.detachScript(entry[0]);\n }\n }\n }\n // Preserved functions\n registerHost(_host) {}\n unregisterHost(_host) {}\n}\n\nexport { ScriptingSystem };\n//# sourceMappingURL=scriptingsystem.js.map\n"],"names":[],"mappings":";;;;AAIA,MAAM,eAAe,CAAC;AACtB,IAAI,SAAS;AACb,IAAI,YAAY,GAAG,IAAI,GAAG,EAAE;AAC5B,IAAI,YAAY;AAChB,IAAI,cAAc;AAClB,IAAI,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC;AAC1B,QAAQ,IAAI,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,WAAW,IAAI,GAAG,EAAE,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC;AAC5H,QAAQ,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,aAAa;AAChD,QAAQ,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW;AAC5C;AACA,IAAI,IAAI,QAAQ,GAAG;AACnB,QAAQ,OAAO,IAAI,CAAC,SAAS;AAC7B;AACA;AACA,IAAI,MAAM,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE;AACrC,QAAQ,IAAI;AACZ,YAAY,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAA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AC;AAClD,gBAAgB,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC3C;AACA;AACA;AACA;AACA,IAAI,YAAY,CAAC,KAAK,EAAE;AACxB,IAAI,cAAc,CAAC,KAAK,EAAE;AAC1B;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,263 @@
1
+ import { textToBase64 } from '@zephyr3d/base';
2
+
3
+ function toDataUrl(js, id) {
4
+ const b64 = textToBase64(js);
5
+ return `data:text/javascript;base64,${b64}#${encodeURIComponent(String(id))}`;
6
+ }
7
+ function isAbsoluteUrl(spec) {
8
+ return /^https?:\/\//i.test(spec);
9
+ }
10
+ function isSpecialUrl(spec) {
11
+ return /^(data|blob):/i.test(spec);
12
+ }
13
+ function isBareModule(spec) {
14
+ return !spec.startsWith('./') && !spec.startsWith('../') && !spec.startsWith('/') && !spec.startsWith('#/');
15
+ }
16
+ class ScriptRegistry {
17
+ _vfs;
18
+ _scriptsRoot;
19
+ _built = new Map();
20
+ _editorMode = false;
21
+ constructor(vfs, scriptsRoot, editorMode){
22
+ this._vfs = vfs;
23
+ this._scriptsRoot = scriptsRoot;
24
+ this._editorMode = editorMode;
25
+ }
26
+ get VFS() {
27
+ return this._vfs;
28
+ }
29
+ set VFS(vfs) {
30
+ this._vfs = vfs;
31
+ }
32
+ get editorMode() {
33
+ return this._editorMode;
34
+ }
35
+ set editorMode(val) {
36
+ this._editorMode = val;
37
+ }
38
+ get scriptsRoot() {
39
+ return this._scriptsRoot;
40
+ }
41
+ set scriptsRoot(path) {
42
+ this._scriptsRoot = path;
43
+ }
44
+ async fetchSource(_id) {
45
+ let type = null;
46
+ let pathWithExt = '';
47
+ if (_id.endsWith('.ts')) {
48
+ pathWithExt = _id;
49
+ type = 'ts';
50
+ } else if (_id.endsWith('.js')) {
51
+ pathWithExt = _id;
52
+ type = 'js';
53
+ }
54
+ if (type) {
55
+ const exists = await this._vfs.exists(pathWithExt);
56
+ if (!exists) {
57
+ type = null;
58
+ }
59
+ const stat = await this._vfs.stat(pathWithExt);
60
+ if (stat.isDirectory) {
61
+ type = null;
62
+ }
63
+ }
64
+ const types = [
65
+ 'ts',
66
+ 'js'
67
+ ];
68
+ if (!type) {
69
+ for (const t of types){
70
+ pathWithExt = `${_id}.${t}`;
71
+ const exists = await this._vfs.exists(pathWithExt);
72
+ if (exists) {
73
+ const stats = await this._vfs.stat(pathWithExt);
74
+ if (stats.isFile) {
75
+ type = t;
76
+ break;
77
+ }
78
+ }
79
+ }
80
+ }
81
+ if (type) {
82
+ const code = await this._vfs.readFile(pathWithExt, {
83
+ encoding: 'utf8'
84
+ });
85
+ return {
86
+ code,
87
+ type,
88
+ path: pathWithExt
89
+ };
90
+ }
91
+ }
92
+ async resolveRuntimeUrl(entryId) {
93
+ const id = this.resolveLogicalId(entryId);
94
+ return this._editorMode ? await this.build(String(id)) : id;
95
+ }
96
+ async getDependencies(entryId, fromId, dependencies) {
97
+ const reStatic = /\b(?:import|export)\s+[^"']*?from\s+(['"])([^'"]+)\1/g;
98
+ const reDynamic = /\bimport\s*\(\s*(['"])([^'"]+)\1\s*\)/g;
99
+ const normalizedId = this.resolveLogicalId(entryId, fromId);
100
+ const srcPath = await this.resolveSourcePath(normalizedId);
101
+ if (!srcPath || dependencies[srcPath.path] !== undefined) {
102
+ return;
103
+ }
104
+ const code = await this._vfs.readFile(srcPath.path, {
105
+ encoding: 'utf8'
106
+ });
107
+ dependencies[srcPath.path] = code;
108
+ const gather = async (input, re)=>{
109
+ for(;;){
110
+ const m = re.exec(input);
111
+ if (!m) {
112
+ break;
113
+ }
114
+ const spec = m[2];
115
+ if (spec.startsWith('./') || spec.startsWith('../')) {
116
+ await this.getDependencies(spec, normalizedId, dependencies);
117
+ }
118
+ }
119
+ };
120
+ await gather(code, reStatic);
121
+ await gather(code, reDynamic);
122
+ }
123
+ async build(id) {
124
+ const key = String(id);
125
+ const cached = this._built.get(key);
126
+ if (cached) {
127
+ return cached;
128
+ }
129
+ const srcPath = await this.resolveSourcePath(key);
130
+ if (!srcPath) {
131
+ return '';
132
+ }
133
+ const code = await this._vfs.readFile(srcPath.path, {
134
+ encoding: 'utf8'
135
+ });
136
+ const rewritten = await this.rewriteImports(code, key);
137
+ const js = await this.transpile(rewritten, key, srcPath.type);
138
+ const url = toDataUrl(js, key);
139
+ this._built.set(key, url);
140
+ return url;
141
+ }
142
+ async transpile(code, _id, type) {
143
+ const logicalId = String(_id);
144
+ if (type === 'js') {
145
+ return `${code}\n//# sourceURL=${logicalId}`;
146
+ }
147
+ const ts = window.ts;
148
+ if (!ts) {
149
+ throw new Error('TypeScript runtime (window.ts) not found. Load typescript.js first.');
150
+ }
151
+ const res = ts.transpileModule(code, {
152
+ compilerOptions: {
153
+ target: ts.ScriptTarget.ES2015,
154
+ module: ts.ModuleKind.ESNext,
155
+ sourceMap: true,
156
+ inlineSources: true,
157
+ experimentalDecorators: true,
158
+ useDefineForClassFields: false
159
+ },
160
+ fileName: logicalId
161
+ });
162
+ let out = res.outputText || '';
163
+ if (res.sourceMapText) {
164
+ const mapBase64 = btoa(unescape(encodeURIComponent(res.sourceMapText)));
165
+ out += `\n//# sourceMappingURL=data:application/json;base64,${mapBase64}`;
166
+ }
167
+ out += `\n//# sourceURL=${logicalId}`;
168
+ return out;
169
+ }
170
+ async rewriteImports(code, fromId) {
171
+ const reStatic = /\b(?:import|export)\s+[^"']*?from\s+(['"])([^'"]+)\1/g;
172
+ const reDynamic = /\bimport\s*\(\s*(['"])([^'"]+)\1\s*\)/g;
173
+ const replaceAsync = async (input, re)=>{
174
+ let out = '';
175
+ let last = 0;
176
+ for(;;){
177
+ const m = re.exec(input);
178
+ if (!m) {
179
+ break;
180
+ }
181
+ out += input.slice(last, m.index);
182
+ const quote = m[1];
183
+ const spec = m[2];
184
+ let replacement = spec;
185
+ if (isAbsoluteUrl(spec) || isSpecialUrl(spec) || isBareModule(spec)) {
186
+ replacement = spec;
187
+ } else {
188
+ const depId = this.resolveLogicalId(spec, String(fromId));
189
+ replacement = await this.build(depId); // 递归构建为 data URL
190
+ }
191
+ const replaced = m[0].replace(`${quote}${spec}${quote}`, `${quote}${replacement}${quote}`);
192
+ out += replaced;
193
+ last = m.index + m[0].length;
194
+ }
195
+ out += input.slice(last);
196
+ return out;
197
+ };
198
+ let out = await replaceAsync(code, reStatic);
199
+ out = await replaceAsync(out, reDynamic);
200
+ return out;
201
+ }
202
+ resolveLogicalId(spec, fromId) {
203
+ let path;
204
+ if (spec.startsWith('#/')) {
205
+ path = this._vfs.normalizePath(this._vfs.join(this._scriptsRoot, spec.slice(2)));
206
+ } else if (spec.startsWith('./') || spec.startsWith('../')) {
207
+ if (!fromId) {
208
+ throw new Error(`Relative import "${spec}" requires fromId`);
209
+ }
210
+ path = this._vfs.normalizePath(this._vfs.join(this._vfs.dirname(this._vfs.normalizePath(fromId)), spec));
211
+ } else if (spec.startsWith('/')) {
212
+ path = spec.replace(/^\/+/, '/');
213
+ } else {
214
+ return spec;
215
+ }
216
+ return path;
217
+ }
218
+ async resolveSourcePath(logicalId) {
219
+ let type = null;
220
+ let pathWithExt = '';
221
+ if (logicalId.endsWith('.ts')) {
222
+ pathWithExt = logicalId;
223
+ type = 'ts';
224
+ } else if (logicalId.endsWith('.js')) {
225
+ pathWithExt = logicalId;
226
+ type = 'js';
227
+ }
228
+ if (type) {
229
+ const exists = await this._vfs.exists(pathWithExt);
230
+ if (!exists) {
231
+ type = null;
232
+ }
233
+ const stat = await this._vfs.stat(pathWithExt);
234
+ if (stat.isDirectory) {
235
+ type = null;
236
+ }
237
+ }
238
+ const types = [
239
+ 'ts',
240
+ 'js'
241
+ ];
242
+ if (!type) {
243
+ for (const t of types){
244
+ pathWithExt = `${logicalId}.${t}`;
245
+ const exists = await this._vfs.exists(pathWithExt);
246
+ if (exists) {
247
+ const stats = await this._vfs.stat(pathWithExt);
248
+ if (stats.isFile) {
249
+ type = t;
250
+ break;
251
+ }
252
+ }
253
+ }
254
+ }
255
+ return type ? {
256
+ type,
257
+ path: pathWithExt
258
+ } : null;
259
+ }
260
+ }
261
+
262
+ export { ScriptRegistry };
263
+ //# sourceMappingURL=scriptregistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scriptregistry.js","sources":["../../../../../../node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js"],"sourcesContent":["import { textToBase64 } from '@zephyr3d/base';\n\nfunction toDataUrl(js, id) {\n const b64 = textToBase64(js);\n return `data:text/javascript;base64,${b64}#${encodeURIComponent(String(id))}`;\n}\nfunction isAbsoluteUrl(spec) {\n return /^https?:\\/\\//i.test(spec);\n}\nfunction isSpecialUrl(spec) {\n return /^(data|blob):/i.test(spec);\n}\nfunction isBareModule(spec) {\n return !spec.startsWith('./') && !spec.startsWith('../') && !spec.startsWith('/') && !spec.startsWith('#/');\n}\nclass ScriptRegistry {\n _vfs;\n _scriptsRoot;\n _built = new Map();\n _editorMode = false;\n constructor(vfs, scriptsRoot, editorMode){\n this._vfs = vfs;\n this._scriptsRoot = scriptsRoot;\n this._editorMode = editorMode;\n }\n get VFS() {\n return this._vfs;\n }\n set VFS(vfs) {\n this._vfs = vfs;\n }\n get editorMode() {\n return this._editorMode;\n }\n set editorMode(val) {\n this._editorMode = val;\n }\n get scriptsRoot() {\n return this._scriptsRoot;\n }\n set scriptsRoot(path) {\n this._scriptsRoot = path;\n }\n async fetchSource(_id) {\n let type = null;\n let pathWithExt = '';\n if (_id.endsWith('.ts')) {\n pathWithExt = _id;\n type = 'ts';\n } else if (_id.endsWith('.js')) {\n pathWithExt = _id;\n type = 'js';\n }\n if (type) {\n const exists = await this._vfs.exists(pathWithExt);\n if (!exists) {\n type = null;\n }\n const stat = await this._vfs.stat(pathWithExt);\n if (stat.isDirectory) {\n type = null;\n }\n }\n const types = [\n 'ts',\n 'js'\n ];\n if (!type) {\n for (const t of types){\n pathWithExt = `${_id}.${t}`;\n const exists = await this._vfs.exists(pathWithExt);\n if (exists) {\n const stats = await this._vfs.stat(pathWithExt);\n if (stats.isFile) {\n type = t;\n break;\n }\n }\n }\n }\n if (type) {\n const code = await this._vfs.readFile(pathWithExt, {\n encoding: 'utf8'\n });\n return {\n code,\n type,\n path: pathWithExt\n };\n }\n }\n async resolveRuntimeUrl(entryId) {\n const id = this.resolveLogicalId(entryId);\n return this._editorMode ? await this.build(String(id)) : id;\n }\n async getDependencies(entryId, fromId, dependencies) {\n const reStatic = /\\b(?:import|export)\\s+[^\"']*?from\\s+(['\"])([^'\"]+)\\1/g;\n const reDynamic = /\\bimport\\s*\\(\\s*(['\"])([^'\"]+)\\1\\s*\\)/g;\n const normalizedId = this.resolveLogicalId(entryId, fromId);\n const srcPath = await this.resolveSourcePath(normalizedId);\n if (!srcPath || dependencies[srcPath.path] !== undefined) {\n return;\n }\n const code = await this._vfs.readFile(srcPath.path, {\n encoding: 'utf8'\n });\n dependencies[srcPath.path] = code;\n const gather = async (input, re)=>{\n for(;;){\n const m = re.exec(input);\n if (!m) {\n break;\n }\n const spec = m[2];\n if (spec.startsWith('./') || spec.startsWith('../')) {\n await this.getDependencies(spec, normalizedId, dependencies);\n }\n }\n };\n await gather(code, reStatic);\n await gather(code, reDynamic);\n }\n async build(id) {\n const key = String(id);\n const cached = this._built.get(key);\n if (cached) {\n return cached;\n }\n const srcPath = await this.resolveSourcePath(key);\n if (!srcPath) {\n return '';\n }\n const code = await this._vfs.readFile(srcPath.path, {\n encoding: 'utf8'\n });\n const rewritten = await this.rewriteImports(code, key);\n const js = await this.transpile(rewritten, key, srcPath.type);\n const url = toDataUrl(js, key);\n this._built.set(key, url);\n return url;\n }\n async transpile(code, _id, type) {\n const logicalId = String(_id);\n if (type === 'js') {\n return `${code}\\n//# sourceURL=${logicalId}`;\n }\n const ts = window.ts;\n if (!ts) {\n throw new Error('TypeScript runtime (window.ts) not found. Load typescript.js first.');\n }\n const res = ts.transpileModule(code, {\n compilerOptions: {\n target: ts.ScriptTarget.ES2015,\n module: ts.ModuleKind.ESNext,\n sourceMap: true,\n inlineSources: true,\n experimentalDecorators: true,\n useDefineForClassFields: false\n },\n fileName: logicalId\n });\n let out = res.outputText || '';\n if (res.sourceMapText) {\n const mapBase64 = btoa(unescape(encodeURIComponent(res.sourceMapText)));\n out += `\\n//# sourceMappingURL=data:application/json;base64,${mapBase64}`;\n }\n out += `\\n//# sourceURL=${logicalId}`;\n return out;\n }\n async rewriteImports(code, fromId) {\n const reStatic = /\\b(?:import|export)\\s+[^\"']*?from\\s+(['\"])([^'\"]+)\\1/g;\n const reDynamic = /\\bimport\\s*\\(\\s*(['\"])([^'\"]+)\\1\\s*\\)/g;\n const replaceAsync = async (input, re)=>{\n let out = '';\n let last = 0;\n for(;;){\n const m = re.exec(input);\n if (!m) {\n break;\n }\n out += input.slice(last, m.index);\n const quote = m[1];\n const spec = m[2];\n let replacement = spec;\n if (isAbsoluteUrl(spec) || isSpecialUrl(spec) || isBareModule(spec)) {\n replacement = spec;\n } else {\n const depId = this.resolveLogicalId(spec, String(fromId));\n replacement = await this.build(depId); // 递归构建为 data URL\n }\n const replaced = m[0].replace(`${quote}${spec}${quote}`, `${quote}${replacement}${quote}`);\n out += replaced;\n last = m.index + m[0].length;\n }\n out += input.slice(last);\n return out;\n };\n let out = await replaceAsync(code, reStatic);\n out = await replaceAsync(out, reDynamic);\n return out;\n }\n resolveLogicalId(spec, fromId) {\n let path;\n if (spec.startsWith('#/')) {\n path = this._vfs.normalizePath(this._vfs.join(this._scriptsRoot, spec.slice(2)));\n } else if (spec.startsWith('./') || spec.startsWith('../')) {\n if (!fromId) {\n throw new Error(`Relative import \"${spec}\" requires fromId`);\n }\n path = this._vfs.normalizePath(this._vfs.join(this._vfs.dirname(this._vfs.normalizePath(fromId)), spec));\n } else if (spec.startsWith('/')) {\n path = spec.replace(/^\\/+/, '/');\n } else {\n return spec;\n }\n return path;\n }\n async resolveSourcePath(logicalId) {\n let type = null;\n let pathWithExt = '';\n if (logicalId.endsWith('.ts')) {\n pathWithExt = logicalId;\n type = 'ts';\n } else if (logicalId.endsWith('.js')) {\n pathWithExt = logicalId;\n type = 'js';\n }\n if (type) {\n const exists = await this._vfs.exists(pathWithExt);\n if (!exists) {\n type = null;\n }\n const stat = await this._vfs.stat(pathWithExt);\n if (stat.isDirectory) {\n type = null;\n }\n }\n const types = [\n 'ts',\n 'js'\n ];\n if (!type) {\n for (const t of types){\n pathWithExt = `${logicalId}.${t}`;\n const exists = await this._vfs.exists(pathWithExt);\n if (exists) {\n const stats = await this._vfs.stat(pathWithExt);\n if (stats.isFile) {\n type = t;\n break;\n }\n }\n }\n }\n return type ? {\n type,\n path: pathWithExt\n } : null;\n }\n}\n\nexport { ScriptRegistry };\n//# sourceMappingURL=scriptregistry.js.map\n"],"names":[],"mappings":";;AAEA,SAAS,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE;AAC3B,IAAI,MAAM,GAAG,GAAG,YAAY,CAAC,EAAE,CAAC;AAChC,IAAI,OAAO,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACjF;AACA,SAAS,aAAa,CAAC,IAAI,EAAE;AAC7B,IAAI,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;AACrC;AACA,SAAS,YAAY,CAAC,IAAI,EAAE;AAC5B,IAAI,OAAO,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;AACtC;AACA,SAAS,YAAY,CAAC,IAAI,EAAE;AAC5B,IAAI,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;AAC/G;AACA,MAAM,cAAc,CAAC;AACrB,IAAI,IAAI;AACR,IAAI,YAAY;AAChB,IAAI,MAAM,GAAG,IAAI,GAAG,EAAE;AACtB,IAAI,WAAW,GAAG,KAAK;AACv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AAE;AAC9C,YAAY,WAAW,GAAG,SAAS;AACnC,YAAY,IAAI,GAAG,IAAI;AACvB;AACA,QAAQ,IAAI,IAAI,EAAE;AAClB,YAAY,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;AAC9D,YAAY,IAAI,CAAC,MAAM,EAAE;AACzB,gBAAgB,IAAI,GAAG,IAAI;AAC3B;AACA,YAAY,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;AAC1D,YAAY,IAAI,IAAI,CAAC,WAAW,EAAE;AAClC,gBAAgB,IAAI,GAAG,IAAI;AAC3B;AACA;AACA,QAAQ,MAAM,KAAK,GAAG;AACtB,YAAY,IAAI;AAChB,YAAY;AACZ,SAAS;AACT,QAAQ,IAAI,CAAC,IAAI,EAAE;AACnB,YAAY,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC;AAClC,gBAAgB,WAAW,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACjD,gBAAgB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;AAClE,gBAAgB,IAAI,MAAM,EAAE;AAC5B,oBAAoB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;AACnE,oBAAoB,IAAI,KAAK,CAAC,MAAM,EAAE;AACtC,wBAAwB,IAAI,GAAG,CAAC;AAChC,wBAAwB;AACxB;AACA;AACA;AACA;AACA,QAAQ,OAAO,IAAI,GAAG;AACtB,YAAY,IAAI;AAChB,YAAY,IAAI,EAAE;AAClB,SAAS,GAAG,IAAI;AAChB;AACA;;;;","x_google_ignoreList":[0]}
@@ -11,11 +11,8 @@ import '../shapes/plane.js';
11
11
  import '../shapes/sphere.js';
12
12
  import '../shapes/tetrahedron.js';
13
13
  import { temporalResolve } from '../shaders/temporal.js';
14
+ import { RGHistoryResources } from '../render/rendergraph/history_resources.js';
14
15
 
15
- /** Resource names for TAA history buffers */ const TAA_RESOURCES = {
16
- COLOR: 'taaColor',
17
- MOTION_VECTOR: 'taaMotionVector'
18
- };
19
16
  /** @internal */ class TAA extends AbstractPostEffect {
20
17
  static _resolveProgram = [];
21
18
  static _skyMotionVectorProgram = null;
@@ -51,46 +48,41 @@ import { temporalResolve } from '../shaders/temporal.js';
51
48
  }
52
49
  apply(ctx, inputColorTexture, sceneDepthTexture, srgbOutput) {
53
50
  const historyMgr = ctx.camera.getHistoryResourceManager();
54
- // Check if this is the first frame (no history yet)
55
- const isFirstFrame = !historyMgr.has(TAA_RESOURCES.COLOR);
56
- if (isFirstFrame) {
51
+ const colorDesc = {
52
+ format: inputColorTexture.format,
53
+ sizeMode: 'absolute',
54
+ width: inputColorTexture.width,
55
+ height: inputColorTexture.height
56
+ };
57
+ const colorSize = {
58
+ width: inputColorTexture.width,
59
+ height: inputColorTexture.height
60
+ };
61
+ const motionVectorDesc = {
62
+ format: ctx.motionVectorTexture.format,
63
+ sizeMode: 'absolute',
64
+ width: ctx.motionVectorTexture.width,
65
+ height: ctx.motionVectorTexture.height
66
+ };
67
+ const motionVectorSize = {
68
+ width: ctx.motionVectorTexture.width,
69
+ height: ctx.motionVectorTexture.height
70
+ };
71
+ const hasHistory = historyMgr.isCompatible(RGHistoryResources.TAA_COLOR, colorDesc, colorSize) && historyMgr.isCompatible(RGHistoryResources.TAA_MOTION_VECTOR, motionVectorDesc, motionVectorSize);
72
+ if (!hasHistory) {
57
73
  // First frame: just pass through
58
74
  this.passThrough(ctx, inputColorTexture, srgbOutput);
59
- // Register and update history resources (zero-copy)
75
+ // Queue history resources only after retaining references from the pool.
60
76
  const currentColorTex = ctx.device.getFramebuffer().getColorAttachments()[0];
61
77
  ctx.device.pool.retainTexture(currentColorTex);
62
- historyMgr.registerWithTexture(TAA_RESOURCES.COLOR, {
63
- format: inputColorTexture.format,
64
- sizeMode: 'absolute',
65
- width: inputColorTexture.width,
66
- height: inputColorTexture.height
67
- }, {
68
- width: inputColorTexture.width,
69
- height: inputColorTexture.height
70
- }, currentColorTex);
78
+ historyMgr.queueCommit(RGHistoryResources.TAA_COLOR, colorDesc, colorSize, currentColorTex);
71
79
  ctx.device.pool.retainTexture(ctx.motionVectorTexture);
72
- historyMgr.registerWithTexture(TAA_RESOURCES.MOTION_VECTOR, {
73
- format: ctx.motionVectorTexture.format,
74
- sizeMode: 'absolute',
75
- width: ctx.motionVectorTexture.width,
76
- height: ctx.motionVectorTexture.height
77
- }, {
78
- width: ctx.motionVectorTexture.width,
79
- height: ctx.motionVectorTexture.height
80
- }, ctx.motionVectorTexture);
80
+ historyMgr.queueCommit(RGHistoryResources.TAA_MOTION_VECTOR, motionVectorDesc, motionVectorSize, ctx.motionVectorTexture);
81
81
  return;
82
82
  }
83
83
  // Get history textures
84
- const prevColorTex = historyMgr.getPrevious(TAA_RESOURCES.COLOR);
85
- // Check if resolution changed
86
- if (prevColorTex.width !== inputColorTexture.width || prevColorTex.height !== inputColorTexture.height) {
87
- // Resolution changed, unregister old resources and restart
88
- historyMgr.unregister(TAA_RESOURCES.COLOR);
89
- historyMgr.unregister(TAA_RESOURCES.MOTION_VECTOR);
90
- this.passThrough(ctx, inputColorTexture, srgbOutput);
91
- return;
92
- }
93
- const prevMotionVectorTex = historyMgr.getPrevious(TAA_RESOURCES.MOTION_VECTOR);
84
+ const prevColorTex = historyMgr.getPrevious(RGHistoryResources.TAA_COLOR);
85
+ const prevMotionVectorTex = historyMgr.getPrevious(RGHistoryResources.TAA_MOTION_VECTOR);
94
86
  // Render TAA
95
87
  let program = TAA._resolveProgram[ctx.camera.TAADebug];
96
88
  if (!program) {
@@ -115,10 +107,10 @@ import { temporalResolve } from '../shaders/temporal.js';
115
107
  // Update history with current framebuffer output (zero-copy)
116
108
  const currentColorTex = ctx.device.getFramebuffer().getColorAttachments()[0];
117
109
  ctx.device.pool.retainTexture(currentColorTex);
118
- historyMgr.updateCurrent(TAA_RESOURCES.COLOR, currentColorTex);
110
+ historyMgr.queueCommit(RGHistoryResources.TAA_COLOR, colorDesc, colorSize, currentColorTex);
119
111
  ctx.device.pool.retainTexture(ctx.motionVectorTexture);
120
- historyMgr.updateCurrent(TAA_RESOURCES.MOTION_VECTOR, ctx.motionVectorTexture);
121
- // Note: History swap happens automatically in executeForwardPlusGraph
112
+ historyMgr.queueCommit(RGHistoryResources.TAA_MOTION_VECTOR, motionVectorDesc, motionVectorSize, ctx.motionVectorTexture);
113
+ // History commits happen after the render graph completes successfully.
122
114
  }
123
115
  requireLinearDepthTexture(_ctx) {
124
116
  return true;