@driftengine/core 3.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (955) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +9 -0
  3. package/README.md +9 -0
  4. package/dist/behavior/behaviorTree.d.ts +140 -0
  5. package/dist/behavior/behaviorTree.js +289 -0
  6. package/dist/build/shaderComments.d.ts +64 -0
  7. package/dist/build/shaderComments.js +0 -0
  8. package/dist/cinematic/player.d.ts +80 -0
  9. package/dist/cinematic/player.js +184 -0
  10. package/dist/cinematic/script.d.ts +63 -0
  11. package/dist/cinematic/script.js +141 -0
  12. package/dist/core/bootGate.d.ts +37 -0
  13. package/dist/core/bootGate.js +47 -0
  14. package/dist/core/loadTracker.d.ts +78 -0
  15. package/dist/core/loadTracker.js +106 -0
  16. package/dist/core/loop.d.ts +118 -0
  17. package/dist/core/loop.js +84 -0
  18. package/dist/core/messageQueue.d.ts +61 -0
  19. package/dist/core/messageQueue.js +104 -0
  20. package/dist/core/onceSet.d.ts +27 -0
  21. package/dist/core/onceSet.js +62 -0
  22. package/dist/core/preferences.d.ts +47 -0
  23. package/dist/core/preferences.js +140 -0
  24. package/dist/core/remoteSave.d.ts +154 -0
  25. package/dist/core/remoteSave.js +249 -0
  26. package/dist/core/rng.d.ts +64 -0
  27. package/dist/core/rng.js +72 -0
  28. package/dist/core/stepBudget.d.ts +91 -0
  29. package/dist/core/stepBudget.js +105 -0
  30. package/dist/core/storage.d.ts +52 -0
  31. package/dist/core/storage.js +85 -0
  32. package/dist/core/tickTrace.d.ts +72 -0
  33. package/dist/core/tickTrace.js +102 -0
  34. package/dist/core/timeCurve.d.ts +83 -0
  35. package/dist/core/timeCurve.js +107 -0
  36. package/dist/core/withDefaults.d.ts +21 -0
  37. package/dist/core/withDefaults.js +29 -0
  38. package/dist/dev/contactProbe.d.ts +41 -0
  39. package/dist/dev/contactProbe.js +58 -0
  40. package/dist/dev/fpsMeter.d.ts +45 -0
  41. package/dist/dev/fpsMeter.js +86 -0
  42. package/dist/environment/celestialClock.d.ts +141 -0
  43. package/dist/environment/celestialClock.js +262 -0
  44. package/dist/geometry/decal.d.ts +61 -0
  45. package/dist/geometry/decal.js +178 -0
  46. package/dist/geometry/filmPatch.d.ts +35 -0
  47. package/dist/geometry/filmPatch.js +112 -0
  48. package/dist/geometry/growable.d.ts +70 -0
  49. package/dist/geometry/growable.js +167 -0
  50. package/dist/geometry/lightVolume.d.ts +76 -0
  51. package/dist/geometry/lightVolume.js +65 -0
  52. package/dist/geometry/meshBuilder.d.ts +426 -0
  53. package/dist/geometry/meshBuilder.js +1184 -0
  54. package/dist/geometry/pixelFont.d.ts +59 -0
  55. package/dist/geometry/pixelFont.js +179 -0
  56. package/dist/geometry/ribbon.d.ts +101 -0
  57. package/dist/geometry/ribbon.js +546 -0
  58. package/dist/geometry/shellFill.d.ts +101 -0
  59. package/dist/geometry/shellFill.js +203 -0
  60. package/dist/geometry/spline.d.ts +162 -0
  61. package/dist/geometry/spline.js +527 -0
  62. package/dist/geometry/tangents.d.ts +30 -0
  63. package/dist/geometry/tangents.js +142 -0
  64. package/dist/geometry/textMesh.d.ts +51 -0
  65. package/dist/geometry/textMesh.js +57 -0
  66. package/dist/geometry/treeBuilder.d.ts +37 -0
  67. package/dist/geometry/treeBuilder.js +56 -0
  68. package/dist/host/display.d.ts +135 -0
  69. package/dist/host/display.js +114 -0
  70. package/dist/host/files.d.ts +25 -0
  71. package/dist/host/files.js +44 -0
  72. package/dist/host/lifecycle.d.ts +45 -0
  73. package/dist/host/lifecycle.js +28 -0
  74. package/dist/host/platformServices.d.ts +23 -0
  75. package/dist/host/platformServices.js +1 -0
  76. package/dist/host/screen.d.ts +49 -0
  77. package/dist/host/screen.js +90 -0
  78. package/dist/index.d.ts +289 -0
  79. package/dist/index.js +320 -0
  80. package/dist/input/actionMap.d.ts +181 -0
  81. package/dist/input/actionMap.js +314 -0
  82. package/dist/input/activeDevice.d.ts +55 -0
  83. package/dist/input/activeDevice.js +83 -0
  84. package/dist/input/gamepadIdentity.d.ts +43 -0
  85. package/dist/input/gamepadIdentity.js +108 -0
  86. package/dist/input/gamepadMapping.d.ts +56 -0
  87. package/dist/input/gamepadMapping.js +91 -0
  88. package/dist/input/input.d.ts +281 -0
  89. package/dist/input/input.js +703 -0
  90. package/dist/input/inputHarness.d.ts +42 -0
  91. package/dist/input/inputHarness.js +193 -0
  92. package/dist/input/rightGesture.d.ts +57 -0
  93. package/dist/input/rightGesture.js +49 -0
  94. package/dist/input/rumble.d.ts +71 -0
  95. package/dist/input/rumble.js +119 -0
  96. package/dist/input/touchControls.d.ts +138 -0
  97. package/dist/input/touchControls.js +352 -0
  98. package/dist/input/typingTarget.d.ts +6 -0
  99. package/dist/input/typingTarget.js +27 -0
  100. package/dist/math/bounds.d.ts +61 -0
  101. package/dist/math/bounds.js +121 -0
  102. package/dist/math/color.d.ts +8 -0
  103. package/dist/math/color.js +35 -0
  104. package/dist/math/exact.d.ts +66 -0
  105. package/dist/math/exact.js +262 -0
  106. package/dist/math/frustum.d.ts +44 -0
  107. package/dist/math/frustum.js +90 -0
  108. package/dist/math/intersect.d.ts +76 -0
  109. package/dist/math/intersect.js +185 -0
  110. package/dist/math/scalar.d.ts +51 -0
  111. package/dist/math/scalar.js +99 -0
  112. package/dist/math/spring.d.ts +59 -0
  113. package/dist/math/spring.js +88 -0
  114. package/dist/nav/navGraph.d.ts +71 -0
  115. package/dist/nav/navGraph.js +111 -0
  116. package/dist/nav/navPath.d.ts +93 -0
  117. package/dist/nav/navPath.js +162 -0
  118. package/dist/nav/navSearch.d.ts +74 -0
  119. package/dist/nav/navSearch.js +198 -0
  120. package/dist/physics/boxSurface.d.ts +48 -0
  121. package/dist/physics/boxSurface.js +73 -0
  122. package/dist/physics/colliderSurface.d.ts +46 -0
  123. package/dist/physics/colliderSurface.js +146 -0
  124. package/dist/physics/compositeSurface.d.ts +33 -0
  125. package/dist/physics/compositeSurface.js +108 -0
  126. package/dist/physics/heightSurface.d.ts +103 -0
  127. package/dist/physics/heightSurface.js +153 -0
  128. package/dist/physics/ribbonSurface.d.ts +239 -0
  129. package/dist/physics/ribbonSurface.js +522 -0
  130. package/dist/render/ambientOcclusionPass.d.ts +53 -0
  131. package/dist/render/ambientOcclusionPass.js +179 -0
  132. package/dist/render/areaLights.d.ts +116 -0
  133. package/dist/render/areaLights.js +91 -0
  134. package/dist/render/areaShadowSet.d.ts +184 -0
  135. package/dist/render/areaShadowSet.js +277 -0
  136. package/dist/render/atmosphere.d.ts +94 -0
  137. package/dist/render/atmosphere.js +91 -0
  138. package/dist/render/backend/api.d.ts +496 -0
  139. package/dist/render/backend/api.js +1 -0
  140. package/dist/render/backend/budget.d.ts +82 -0
  141. package/dist/render/backend/budget.js +99 -0
  142. package/dist/render/backend/createRenderer.d.ts +135 -0
  143. package/dist/render/backend/createRenderer.js +201 -0
  144. package/dist/render/backend/deadline.d.ts +24 -0
  145. package/dist/render/backend/deadline.js +38 -0
  146. package/dist/render/backend/probe.d.ts +30 -0
  147. package/dist/render/backend/probe.js +129 -0
  148. package/dist/render/backend/select.d.ts +70 -0
  149. package/dist/render/backend/select.js +249 -0
  150. package/dist/render/backend/timer.d.ts +50 -0
  151. package/dist/render/backend/timer.js +1 -0
  152. package/dist/render/backend/webgl2/instanced.d.ts +21 -0
  153. package/dist/render/backend/webgl2/instanced.js +42 -0
  154. package/dist/render/backend/webgl2/morphTexture.d.ts +21 -0
  155. package/dist/render/backend/webgl2/morphTexture.js +55 -0
  156. package/dist/render/backend/webgl2/renderer.d.ts +3027 -0
  157. package/dist/render/backend/webgl2/renderer.js +6041 -0
  158. package/dist/render/backend/webgl2/skinPaletteTexture.d.ts +32 -0
  159. package/dist/render/backend/webgl2/skinPaletteTexture.js +68 -0
  160. package/dist/render/backend/webgpu/boltPass.d.ts +42 -0
  161. package/dist/render/backend/webgpu/boltPass.js +160 -0
  162. package/dist/render/backend/webgpu/buffers.d.ts +159 -0
  163. package/dist/render/backend/webgpu/buffers.js +402 -0
  164. package/dist/render/backend/webgpu/causticsPass.d.ts +36 -0
  165. package/dist/render/backend/webgpu/causticsPass.js +138 -0
  166. package/dist/render/backend/webgpu/clusterBinner.d.ts +51 -0
  167. package/dist/render/backend/webgpu/clusterBinner.js +206 -0
  168. package/dist/render/backend/webgpu/depthPass.d.ts +114 -0
  169. package/dist/render/backend/webgpu/depthPass.js +228 -0
  170. package/dist/render/backend/webgpu/device.d.ts +52 -0
  171. package/dist/render/backend/webgpu/device.js +121 -0
  172. package/dist/render/backend/webgpu/drawCommand.d.ts +43 -0
  173. package/dist/render/backend/webgpu/drawCommand.js +54 -0
  174. package/dist/render/backend/webgpu/environmentTexels.d.ts +28 -0
  175. package/dist/render/backend/webgpu/environmentTexels.js +79 -0
  176. package/dist/render/backend/webgpu/filmPass.d.ts +29 -0
  177. package/dist/render/backend/webgpu/filmPass.js +97 -0
  178. package/dist/render/backend/webgpu/flatPass.d.ts +213 -0
  179. package/dist/render/backend/webgpu/flatPass.js +482 -0
  180. package/dist/render/backend/webgpu/flockPass.d.ts +34 -0
  181. package/dist/render/backend/webgpu/flockPass.js +129 -0
  182. package/dist/render/backend/webgpu/gpuTimestamps.d.ts +94 -0
  183. package/dist/render/backend/webgpu/gpuTimestamps.js +213 -0
  184. package/dist/render/backend/webgpu/insetPass.d.ts +19 -0
  185. package/dist/render/backend/webgpu/insetPass.js +108 -0
  186. package/dist/render/backend/webgpu/instanced.d.ts +27 -0
  187. package/dist/render/backend/webgpu/instanced.js +49 -0
  188. package/dist/render/backend/webgpu/lightVolumePass.d.ts +75 -0
  189. package/dist/render/backend/webgpu/lightVolumePass.js +154 -0
  190. package/dist/render/backend/webgpu/linePass.d.ts +90 -0
  191. package/dist/render/backend/webgpu/linePass.js +220 -0
  192. package/dist/render/backend/webgpu/morphTexture.d.ts +18 -0
  193. package/dist/render/backend/webgpu/morphTexture.js +51 -0
  194. package/dist/render/backend/webgpu/panelPass.d.ts +37 -0
  195. package/dist/render/backend/webgpu/panelPass.js +114 -0
  196. package/dist/render/backend/webgpu/particlePass.d.ts +89 -0
  197. package/dist/render/backend/webgpu/particlePass.js +280 -0
  198. package/dist/render/backend/webgpu/pipelineCache.d.ts +93 -0
  199. package/dist/render/backend/webgpu/pipelineCache.js +140 -0
  200. package/dist/render/backend/webgpu/plumePass.d.ts +69 -0
  201. package/dist/render/backend/webgpu/plumePass.js +213 -0
  202. package/dist/render/backend/webgpu/pointShadowPass.d.ts +88 -0
  203. package/dist/render/backend/webgpu/pointShadowPass.js +280 -0
  204. package/dist/render/backend/webgpu/postPass.d.ts +342 -0
  205. package/dist/render/backend/webgpu/postPass.js +366 -0
  206. package/dist/render/backend/webgpu/probePass.d.ts +108 -0
  207. package/dist/render/backend/webgpu/probePass.js +188 -0
  208. package/dist/render/backend/webgpu/reflectionPass.d.ts +29 -0
  209. package/dist/render/backend/webgpu/reflectionPass.js +87 -0
  210. package/dist/render/backend/webgpu/renderer.d.ts +3082 -0
  211. package/dist/render/backend/webgpu/renderer.js +10911 -0
  212. package/dist/render/backend/webgpu/scatterPass.d.ts +95 -0
  213. package/dist/render/backend/webgpu/scatterPass.js +266 -0
  214. package/dist/render/backend/webgpu/sdfTextPass.d.ts +86 -0
  215. package/dist/render/backend/webgpu/sdfTextPass.js +190 -0
  216. package/dist/render/backend/webgpu/shaderModules.d.ts +9 -0
  217. package/dist/render/backend/webgpu/shaderModules.js +45 -0
  218. package/dist/render/backend/webgpu/shaders/clusterBin.wgsl.d.ts +23 -0
  219. package/dist/render/backend/webgpu/shaders/clusterBin.wgsl.js +208 -0
  220. package/dist/render/backend/webgpu/skinPaletteRing.d.ts +67 -0
  221. package/dist/render/backend/webgpu/skinPaletteRing.js +97 -0
  222. package/dist/render/backend/webgpu/skinPaletteTexture.d.ts +17 -0
  223. package/dist/render/backend/webgpu/skinPaletteTexture.js +68 -0
  224. package/dist/render/backend/webgpu/skyPass.d.ts +102 -0
  225. package/dist/render/backend/webgpu/skyPass.js +70 -0
  226. package/dist/render/backend/webgpu/surfaceTexturePass.d.ts +41 -0
  227. package/dist/render/backend/webgpu/surfaceTexturePass.js +228 -0
  228. package/dist/render/backend/webgpu/textPass.d.ts +73 -0
  229. package/dist/render/backend/webgpu/textPass.js +190 -0
  230. package/dist/render/backend/webgpu/uniformRing.d.ts +133 -0
  231. package/dist/render/backend/webgpu/uniformRing.js +208 -0
  232. package/dist/render/backend/webgpu/waterPass.d.ts +73 -0
  233. package/dist/render/backend/webgpu/waterPass.js +160 -0
  234. package/dist/render/backend/webgpu/windStreakPass.d.ts +46 -0
  235. package/dist/render/backend/webgpu/windStreakPass.js +153 -0
  236. package/dist/render/billboard.d.ts +27 -0
  237. package/dist/render/billboard.js +79 -0
  238. package/dist/render/bloomChain.d.ts +66 -0
  239. package/dist/render/bloomChain.js +83 -0
  240. package/dist/render/bloomPass.d.ts +54 -0
  241. package/dist/render/bloomPass.js +219 -0
  242. package/dist/render/boltBatch.d.ts +39 -0
  243. package/dist/render/boltBatch.js +121 -0
  244. package/dist/render/boltPool.d.ts +135 -0
  245. package/dist/render/boltPool.js +259 -0
  246. package/dist/render/boom.d.ts +46 -0
  247. package/dist/render/boom.js +81 -0
  248. package/dist/render/camera.d.ts +119 -0
  249. package/dist/render/camera.js +304 -0
  250. package/dist/render/causticsRenderer.d.ts +63 -0
  251. package/dist/render/causticsRenderer.js +119 -0
  252. package/dist/render/cinematicCamera.d.ts +102 -0
  253. package/dist/render/cinematicCamera.js +227 -0
  254. package/dist/render/clusteredLights.d.ts +260 -0
  255. package/dist/render/clusteredLights.js +479 -0
  256. package/dist/render/colourGrade.d.ts +62 -0
  257. package/dist/render/colourGrade.js +91 -0
  258. package/dist/render/compute.d.ts +74 -0
  259. package/dist/render/compute.js +8 -0
  260. package/dist/render/contextLoss.d.ts +32 -0
  261. package/dist/render/contextLoss.js +46 -0
  262. package/dist/render/debugLines.d.ts +75 -0
  263. package/dist/render/debugLines.js +281 -0
  264. package/dist/render/decalPass.d.ts +34 -0
  265. package/dist/render/decalPass.js +103 -0
  266. package/dist/render/decalProjector.d.ts +140 -0
  267. package/dist/render/decalProjector.js +282 -0
  268. package/dist/render/decalQueue.d.ts +53 -0
  269. package/dist/render/decalQueue.js +87 -0
  270. package/dist/render/depthConvention.d.ts +314 -0
  271. package/dist/render/depthConvention.js +346 -0
  272. package/dist/render/drawingBuffer.d.ts +52 -0
  273. package/dist/render/drawingBuffer.js +67 -0
  274. package/dist/render/emptyTexture.d.ts +60 -0
  275. package/dist/render/emptyTexture.js +103 -0
  276. package/dist/render/envProbeArray.d.ts +85 -0
  277. package/dist/render/envProbeArray.js +164 -0
  278. package/dist/render/equirectToCube.d.ts +54 -0
  279. package/dist/render/equirectToCube.js +123 -0
  280. package/dist/render/flockGeometry.d.ts +23 -0
  281. package/dist/render/flockGeometry.js +43 -0
  282. package/dist/render/flockRenderer.d.ts +37 -0
  283. package/dist/render/flockRenderer.js +70 -0
  284. package/dist/render/frame/arena.d.ts +32 -0
  285. package/dist/render/frame/arena.js +65 -0
  286. package/dist/render/frame/index.d.ts +18 -0
  287. package/dist/render/frame/index.js +4 -0
  288. package/dist/render/frame/replay.d.ts +34 -0
  289. package/dist/render/frame/replay.js +48 -0
  290. package/dist/render/frame/resources.d.ts +25 -0
  291. package/dist/render/frame/resources.js +55 -0
  292. package/dist/render/frame/schedule.d.ts +37 -0
  293. package/dist/render/frame/schedule.js +61 -0
  294. package/dist/render/frameView.d.ts +19 -0
  295. package/dist/render/frameView.js +1 -0
  296. package/dist/render/gizmo.d.ts +236 -0
  297. package/dist/render/gizmo.js +727 -0
  298. package/dist/render/globalMedium.d.ts +124 -0
  299. package/dist/render/globalMedium.js +100 -0
  300. package/dist/render/globalMediumPass.d.ts +101 -0
  301. package/dist/render/globalMediumPass.js +250 -0
  302. package/dist/render/gpuCapability.d.ts +111 -0
  303. package/dist/render/gpuCapability.js +194 -0
  304. package/dist/render/gpuTimer.d.ts +87 -0
  305. package/dist/render/gpuTimer.js +145 -0
  306. package/dist/render/halfFloat.d.ts +4 -0
  307. package/dist/render/halfFloat.js +38 -0
  308. package/dist/render/handleRegistry.d.ts +54 -0
  309. package/dist/render/handleRegistry.js +84 -0
  310. package/dist/render/iesProfile.d.ts +64 -0
  311. package/dist/render/iesProfile.js +179 -0
  312. package/dist/render/imageTexels.d.ts +50 -0
  313. package/dist/render/imageTexels.js +91 -0
  314. package/dist/render/instancedMesh.d.ts +48 -0
  315. package/dist/render/instancedMesh.js +127 -0
  316. package/dist/render/instances.d.ts +69 -0
  317. package/dist/render/instances.js +52 -0
  318. package/dist/render/lightBudget.d.ts +397 -0
  319. package/dist/render/lightBudget.js +524 -0
  320. package/dist/render/lightMatrix.d.ts +3 -0
  321. package/dist/render/lightMatrix.js +45 -0
  322. package/dist/render/lightVolumeDraw.d.ts +132 -0
  323. package/dist/render/lightVolumeDraw.js +181 -0
  324. package/dist/render/lineBatch.d.ts +60 -0
  325. package/dist/render/lineBatch.js +160 -0
  326. package/dist/render/linePoints.d.ts +33 -0
  327. package/dist/render/linePoints.js +46 -0
  328. package/dist/render/livePointShadowSet.d.ts +72 -0
  329. package/dist/render/livePointShadowSet.js +258 -0
  330. package/dist/render/lod.d.ts +35 -0
  331. package/dist/render/lod.js +65 -0
  332. package/dist/render/mesh.d.ts +177 -0
  333. package/dist/render/mesh.js +466 -0
  334. package/dist/render/occlusion.d.ts +81 -0
  335. package/dist/render/occlusion.js +378 -0
  336. package/dist/render/oitPass.d.ts +67 -0
  337. package/dist/render/oitPass.js +213 -0
  338. package/dist/render/orderIndependent.d.ts +92 -0
  339. package/dist/render/orderIndependent.js +108 -0
  340. package/dist/render/particleBatch.d.ts +140 -0
  341. package/dist/render/particleBatch.js +186 -0
  342. package/dist/render/particleMaterial.d.ts +54 -0
  343. package/dist/render/particleMaterial.js +42 -0
  344. package/dist/render/particlePool.d.ts +124 -0
  345. package/dist/render/particlePool.js +182 -0
  346. package/dist/render/pass.d.ts +195 -0
  347. package/dist/render/pass.js +9 -0
  348. package/dist/render/passTarget.d.ts +86 -0
  349. package/dist/render/passTarget.js +121 -0
  350. package/dist/render/pickable.d.ts +31 -0
  351. package/dist/render/pickable.js +172 -0
  352. package/dist/render/planarReflection.d.ts +59 -0
  353. package/dist/render/planarReflection.js +194 -0
  354. package/dist/render/planarReflectionDraw.d.ts +31 -0
  355. package/dist/render/planarReflectionDraw.js +65 -0
  356. package/dist/render/plumeGeometry.d.ts +25 -0
  357. package/dist/render/plumeGeometry.js +61 -0
  358. package/dist/render/plumeMaterial.d.ts +31 -0
  359. package/dist/render/plumeMaterial.js +64 -0
  360. package/dist/render/plumeRenderer.d.ts +96 -0
  361. package/dist/render/plumeRenderer.js +185 -0
  362. package/dist/render/pointLightSelection.d.ts +175 -0
  363. package/dist/render/pointLightSelection.js +301 -0
  364. package/dist/render/pointShadowArray.d.ts +95 -0
  365. package/dist/render/pointShadowArray.js +219 -0
  366. package/dist/render/pointShadowBudget.d.ts +118 -0
  367. package/dist/render/pointShadowBudget.js +221 -0
  368. package/dist/render/pointShadowImage.d.ts +265 -0
  369. package/dist/render/pointShadowImage.js +339 -0
  370. package/dist/render/pointShadowMap.d.ts +93 -0
  371. package/dist/render/pointShadowMap.js +167 -0
  372. package/dist/render/pointShadowSystem.d.ts +195 -0
  373. package/dist/render/pointShadowSystem.js +336 -0
  374. package/dist/render/prefilterEnvMap.d.ts +124 -0
  375. package/dist/render/prefilterEnvMap.js +146 -0
  376. package/dist/render/prefilterPass.d.ts +44 -0
  377. package/dist/render/prefilterPass.js +98 -0
  378. package/dist/render/probeGrid.d.ts +122 -0
  379. package/dist/render/probeGrid.js +174 -0
  380. package/dist/render/rainField.d.ts +99 -0
  381. package/dist/render/rainField.js +168 -0
  382. package/dist/render/reflectionProbe.d.ts +188 -0
  383. package/dist/render/reflectionProbe.js +437 -0
  384. package/dist/render/renderQuality.d.ts +699 -0
  385. package/dist/render/renderQuality.js +293 -0
  386. package/dist/render/rendererHarness.d.ts +39 -0
  387. package/dist/render/rendererHarness.js +185 -0
  388. package/dist/render/resolutionGovernor.d.ts +107 -0
  389. package/dist/render/resolutionGovernor.js +144 -0
  390. package/dist/render/scatterDeform.d.ts +17 -0
  391. package/dist/render/scatterDeform.js +46 -0
  392. package/dist/render/sceneTarget.d.ts +288 -0
  393. package/dist/render/sceneTarget.js +856 -0
  394. package/dist/render/screenSpaceReflection.d.ts +233 -0
  395. package/dist/render/screenSpaceReflection.js +415 -0
  396. package/dist/render/sdfFont.d.ts +77 -0
  397. package/dist/render/sdfFont.js +86 -0
  398. package/dist/render/sdfTextLayout.d.ts +46 -0
  399. package/dist/render/sdfTextLayout.js +145 -0
  400. package/dist/render/sdfTextRenderer.d.ts +75 -0
  401. package/dist/render/sdfTextRenderer.js +194 -0
  402. package/dist/render/seaState.d.ts +25 -0
  403. package/dist/render/seaState.js +34 -0
  404. package/dist/render/segmentQuads.d.ts +29 -0
  405. package/dist/render/segmentQuads.js +75 -0
  406. package/dist/render/shader.d.ts +5 -0
  407. package/dist/render/shader.js +172 -0
  408. package/dist/render/shaders/ambientOcclusion.d.ts +45 -0
  409. package/dist/render/shaders/ambientOcclusion.js +352 -0
  410. package/dist/render/shaders/arcane.d.ts +19 -0
  411. package/dist/render/shaders/arcane.js +102 -0
  412. package/dist/render/shaders/bloom.d.ts +70 -0
  413. package/dist/render/shaders/bloom.js +227 -0
  414. package/dist/render/shaders/bolt.d.ts +17 -0
  415. package/dist/render/shaders/bolt.js +161 -0
  416. package/dist/render/shaders/caustics.d.ts +38 -0
  417. package/dist/render/shaders/caustics.js +167 -0
  418. package/dist/render/shaders/conditionals.d.ts +21 -0
  419. package/dist/render/shaders/conditionals.js +55 -0
  420. package/dist/render/shaders/decalProject.d.ts +25 -0
  421. package/dist/render/shaders/decalProject.js +125 -0
  422. package/dist/render/shaders/depth.d.ts +14 -0
  423. package/dist/render/shaders/depth.js +114 -0
  424. package/dist/render/shaders/depthOfField.d.ts +41 -0
  425. package/dist/render/shaders/depthOfField.js +139 -0
  426. package/dist/render/shaders/film.d.ts +15 -0
  427. package/dist/render/shaders/film.js +283 -0
  428. package/dist/render/shaders/fire.d.ts +12 -0
  429. package/dist/render/shaders/fire.js +178 -0
  430. package/dist/render/shaders/flat/directionalShadow.d.ts +1 -0
  431. package/dist/render/shaders/flat/directionalShadow.js +195 -0
  432. package/dist/render/shaders/flat/index.d.ts +135 -0
  433. package/dist/render/shaders/flat/index.js +387 -0
  434. package/dist/render/shaders/flat/lobes.d.ts +1 -0
  435. package/dist/render/shaders/flat/lobes.js +398 -0
  436. package/dist/render/shaders/flat/main.d.ts +2 -0
  437. package/dist/render/shaders/flat/main.js +1630 -0
  438. package/dist/render/shaders/flat/pointShadow.d.ts +1 -0
  439. package/dist/render/shaders/flat/pointShadow.js +322 -0
  440. package/dist/render/shaders/flat/preamble.d.ts +15 -0
  441. package/dist/render/shaders/flat/preamble.js +864 -0
  442. package/dist/render/shaders/flat/probeGrid.d.ts +21 -0
  443. package/dist/render/shaders/flat/probeGrid.js +151 -0
  444. package/dist/render/shaders/flat/surface.d.ts +2 -0
  445. package/dist/render/shaders/flat/surface.js +40 -0
  446. package/dist/render/shaders/flock.d.ts +11 -0
  447. package/dist/render/shaders/flock.js +102 -0
  448. package/dist/render/shaders/fog.d.ts +37 -0
  449. package/dist/render/shaders/fog.js +98 -0
  450. package/dist/render/shaders/fullscreen.d.ts +16 -0
  451. package/dist/render/shaders/fullscreen.js +27 -0
  452. package/dist/render/shaders/generated/ambientOcclusion.wgsl.d.ts +65 -0
  453. package/dist/render/shaders/generated/ambientOcclusion.wgsl.js +71 -0
  454. package/dist/render/shaders/generated/arcane.wgsl.d.ts +90 -0
  455. package/dist/render/shaders/generated/arcane.wgsl.js +96 -0
  456. package/dist/render/shaders/generated/bloom.wgsl.d.ts +69 -0
  457. package/dist/render/shaders/generated/bloom.wgsl.js +75 -0
  458. package/dist/render/shaders/generated/bolt.wgsl.d.ts +118 -0
  459. package/dist/render/shaders/generated/bolt.wgsl.js +124 -0
  460. package/dist/render/shaders/generated/caustics.wgsl.d.ts +118 -0
  461. package/dist/render/shaders/generated/caustics.wgsl.js +124 -0
  462. package/dist/render/shaders/generated/decalProject.wgsl.d.ts +61 -0
  463. package/dist/render/shaders/generated/decalProject.wgsl.js +67 -0
  464. package/dist/render/shaders/generated/depth.wgsl.d.ts +131 -0
  465. package/dist/render/shaders/generated/depth.wgsl.js +137 -0
  466. package/dist/render/shaders/generated/film.wgsl.d.ts +134 -0
  467. package/dist/render/shaders/generated/film.wgsl.js +140 -0
  468. package/dist/render/shaders/generated/fire.wgsl.d.ts +128 -0
  469. package/dist/render/shaders/generated/fire.wgsl.js +134 -0
  470. package/dist/render/shaders/generated/flat.wgsl.d.ts +9163 -0
  471. package/dist/render/shaders/generated/flat.wgsl.js +9192 -0
  472. package/dist/render/shaders/generated/flock.wgsl.d.ts +73 -0
  473. package/dist/render/shaders/generated/flock.wgsl.js +79 -0
  474. package/dist/render/shaders/generated/fullscreen.wgsl.d.ts +12 -0
  475. package/dist/render/shaders/generated/fullscreen.wgsl.js +18 -0
  476. package/dist/render/shaders/generated/globalMedium.wgsl.d.ts +130 -0
  477. package/dist/render/shaders/generated/globalMedium.wgsl.js +136 -0
  478. package/dist/render/shaders/generated/lightVolume.wgsl.d.ts +230 -0
  479. package/dist/render/shaders/generated/lightVolume.wgsl.js +239 -0
  480. package/dist/render/shaders/generated/line.wgsl.d.ts +128 -0
  481. package/dist/render/shaders/generated/line.wgsl.js +134 -0
  482. package/dist/render/shaders/generated/octahedralResolve.wgsl.d.ts +51 -0
  483. package/dist/render/shaders/generated/octahedralResolve.wgsl.js +57 -0
  484. package/dist/render/shaders/generated/oitResolve.wgsl.d.ts +23 -0
  485. package/dist/render/shaders/generated/oitResolve.wgsl.js +29 -0
  486. package/dist/render/shaders/generated/panel.wgsl.d.ts +48 -0
  487. package/dist/render/shaders/generated/panel.wgsl.js +54 -0
  488. package/dist/render/shaders/generated/particle.wgsl.d.ts +332 -0
  489. package/dist/render/shaders/generated/particle.wgsl.js +338 -0
  490. package/dist/render/shaders/generated/prefilter.wgsl.d.ts +61 -0
  491. package/dist/render/shaders/generated/prefilter.wgsl.js +67 -0
  492. package/dist/render/shaders/generated/rush.wgsl.d.ts +131 -0
  493. package/dist/render/shaders/generated/rush.wgsl.js +137 -0
  494. package/dist/render/shaders/generated/scatter.wgsl.d.ts +195 -0
  495. package/dist/render/shaders/generated/scatter.wgsl.js +201 -0
  496. package/dist/render/shaders/generated/sdfText.wgsl.d.ts +69 -0
  497. package/dist/render/shaders/generated/sdfText.wgsl.js +75 -0
  498. package/dist/render/shaders/generated/sky.wgsl.d.ts +100 -0
  499. package/dist/render/shaders/generated/sky.wgsl.js +106 -0
  500. package/dist/render/shaders/generated/smoke.wgsl.d.ts +85 -0
  501. package/dist/render/shaders/generated/smoke.wgsl.js +91 -0
  502. package/dist/render/shaders/generated/ssrResolve.wgsl.d.ts +18 -0
  503. package/dist/render/shaders/generated/ssrResolve.wgsl.js +24 -0
  504. package/dist/render/shaders/generated/ssrTrace.wgsl.d.ts +86 -0
  505. package/dist/render/shaders/generated/ssrTrace.wgsl.js +92 -0
  506. package/dist/render/shaders/generated/temporalResolve.wgsl.d.ts +46 -0
  507. package/dist/render/shaders/generated/temporalResolve.wgsl.js +52 -0
  508. package/dist/render/shaders/generated/text.wgsl.d.ts +98 -0
  509. package/dist/render/shaders/generated/text.wgsl.js +104 -0
  510. package/dist/render/shaders/generated/water.wgsl.d.ts +247 -0
  511. package/dist/render/shaders/generated/water.wgsl.js +253 -0
  512. package/dist/render/shaders/generated/windStreaks.wgsl.d.ts +73 -0
  513. package/dist/render/shaders/generated/windStreaks.wgsl.js +79 -0
  514. package/dist/render/shaders/gerstner.d.ts +21 -0
  515. package/dist/render/shaders/gerstner.js +110 -0
  516. package/dist/render/shaders/globalMedium.d.ts +56 -0
  517. package/dist/render/shaders/globalMedium.js +393 -0
  518. package/dist/render/shaders/lightVolume.d.ts +61 -0
  519. package/dist/render/shaders/lightVolume.js +527 -0
  520. package/dist/render/shaders/line.d.ts +18 -0
  521. package/dist/render/shaders/line.js +122 -0
  522. package/dist/render/shaders/morph.d.ts +26 -0
  523. package/dist/render/shaders/morph.js +61 -0
  524. package/dist/render/shaders/octahedral.d.ts +76 -0
  525. package/dist/render/shaders/octahedral.js +161 -0
  526. package/dist/render/shaders/octahedralResolve.d.ts +25 -0
  527. package/dist/render/shaders/octahedralResolve.js +81 -0
  528. package/dist/render/shaders/oitResolve.d.ts +17 -0
  529. package/dist/render/shaders/oitResolve.js +42 -0
  530. package/dist/render/shaders/outputTransform.d.ts +37 -0
  531. package/dist/render/shaders/outputTransform.js +106 -0
  532. package/dist/render/shaders/panel.d.ts +17 -0
  533. package/dist/render/shaders/panel.js +50 -0
  534. package/dist/render/shaders/particle.d.ts +82 -0
  535. package/dist/render/shaders/particle.js +431 -0
  536. package/dist/render/shaders/prefilter.d.ts +37 -0
  537. package/dist/render/shaders/prefilter.js +276 -0
  538. package/dist/render/shaders/rush.d.ts +21 -0
  539. package/dist/render/shaders/rush.js +355 -0
  540. package/dist/render/shaders/scatter.d.ts +14 -0
  541. package/dist/render/shaders/scatter.js +206 -0
  542. package/dist/render/shaders/sdfText.d.ts +9 -0
  543. package/dist/render/shaders/sdfText.js +65 -0
  544. package/dist/render/shaders/skinning.d.ts +17 -0
  545. package/dist/render/shaders/skinning.js +59 -0
  546. package/dist/render/shaders/sky.d.ts +10 -0
  547. package/dist/render/shaders/sky.js +242 -0
  548. package/dist/render/shaders/smoke.d.ts +8 -0
  549. package/dist/render/shaders/smoke.js +88 -0
  550. package/dist/render/shaders/ssrResolve.d.ts +15 -0
  551. package/dist/render/shaders/ssrResolve.js +28 -0
  552. package/dist/render/shaders/ssrTrace.d.ts +22 -0
  553. package/dist/render/shaders/ssrTrace.js +230 -0
  554. package/dist/render/shaders/tangentFrame.d.ts +17 -0
  555. package/dist/render/shaders/tangentFrame.js +70 -0
  556. package/dist/render/shaders/temporalResolve.d.ts +1 -0
  557. package/dist/render/shaders/temporalResolve.js +150 -0
  558. package/dist/render/shaders/text.d.ts +17 -0
  559. package/dist/render/shaders/text.js +155 -0
  560. package/dist/render/shaders/vertexChannel.d.ts +39 -0
  561. package/dist/render/shaders/vertexChannel.js +69 -0
  562. package/dist/render/shaders/water.d.ts +18 -0
  563. package/dist/render/shaders/water.js +354 -0
  564. package/dist/render/shaders/windStreaks.d.ts +14 -0
  565. package/dist/render/shaders/windStreaks.js +129 -0
  566. package/dist/render/shadowCasters.d.ts +107 -0
  567. package/dist/render/shadowCasters.js +1 -0
  568. package/dist/render/shadowMap.d.ts +10 -0
  569. package/dist/render/shadowMap.js +80 -0
  570. package/dist/render/shotPlacement.d.ts +80 -0
  571. package/dist/render/shotPlacement.js +183 -0
  572. package/dist/render/skinPalette.d.ts +90 -0
  573. package/dist/render/skinPalette.js +136 -0
  574. package/dist/render/ssrPass.d.ts +59 -0
  575. package/dist/render/ssrPass.js +196 -0
  576. package/dist/render/surfaceSheet.d.ts +52 -0
  577. package/dist/render/surfaceSheet.js +99 -0
  578. package/dist/render/surfaceTexture.d.ts +197 -0
  579. package/dist/render/surfaceTexture.js +116 -0
  580. package/dist/render/temporalAa.d.ts +104 -0
  581. package/dist/render/temporalAa.js +194 -0
  582. package/dist/render/temporalPass.d.ts +54 -0
  583. package/dist/render/temporalPass.js +135 -0
  584. package/dist/render/textLayout.d.ts +88 -0
  585. package/dist/render/textLayout.js +201 -0
  586. package/dist/render/textRenderer.d.ts +32 -0
  587. package/dist/render/textRenderer.js +176 -0
  588. package/dist/render/thirdPersonCamera.d.ts +272 -0
  589. package/dist/render/thirdPersonCamera.js +479 -0
  590. package/dist/render/trample.d.ts +57 -0
  591. package/dist/render/trample.js +134 -0
  592. package/dist/render/translucentQueue.d.ts +76 -0
  593. package/dist/render/translucentQueue.js +90 -0
  594. package/dist/render/uniformVectorBudget.d.ts +105 -0
  595. package/dist/render/uniformVectorBudget.js +201 -0
  596. package/dist/render/uploadStep.d.ts +14 -0
  597. package/dist/render/uploadStep.js +14 -0
  598. package/dist/render/vertexDefaults.d.ts +48 -0
  599. package/dist/render/vertexDefaults.js +111 -0
  600. package/dist/render/visibility.d.ts +22 -0
  601. package/dist/render/visibility.js +47 -0
  602. package/dist/render/waterDraw.d.ts +57 -0
  603. package/dist/render/waterDraw.js +102 -0
  604. package/dist/render/waterGrid.d.ts +62 -0
  605. package/dist/render/waterGrid.js +151 -0
  606. package/dist/render/waterRenderer.d.ts +163 -0
  607. package/dist/render/waterRenderer.js +165 -0
  608. package/dist/render/wind.d.ts +45 -0
  609. package/dist/render/wind.js +32 -0
  610. package/dist/render/windField.d.ts +34 -0
  611. package/dist/render/windField.js +13 -0
  612. package/dist/render/windStreakDraw.d.ts +73 -0
  613. package/dist/render/windStreakDraw.js +86 -0
  614. package/dist/render/windStreakRenderer.d.ts +37 -0
  615. package/dist/render/windStreakRenderer.js +86 -0
  616. package/dist/scene/node.d.ts +128 -0
  617. package/dist/scene/node.js +319 -0
  618. package/dist/scene/visit.d.ts +38 -0
  619. package/dist/scene/visit.js +43 -0
  620. package/dist/ui/clipMime.d.ts +46 -0
  621. package/dist/ui/clipMime.js +88 -0
  622. package/dist/ui/exportTarget.d.ts +305 -0
  623. package/dist/ui/exportTarget.js +368 -0
  624. package/dist/ui/frameOverlay.d.ts +59 -0
  625. package/dist/ui/frameOverlay.js +76 -0
  626. package/dist/ui/framePacer.d.ts +142 -0
  627. package/dist/ui/framePacer.js +284 -0
  628. package/dist/ui/frameRecorder.d.ts +188 -0
  629. package/dist/ui/frameRecorder.js +221 -0
  630. package/dist/ui/fullscreen.d.ts +72 -0
  631. package/dist/ui/fullscreen.js +92 -0
  632. package/dist/ui/pixelCursor.d.ts +28 -0
  633. package/dist/ui/pixelCursor.js +66 -0
  634. package/dist/ui/splash.d.ts +86 -0
  635. package/dist/ui/splash.js +300 -0
  636. package/dist/ui/stillFrame.d.ts +22 -0
  637. package/dist/ui/stillFrame.js +40 -0
  638. package/package.json +60 -0
  639. package/src/behavior/behaviorTree.ts +346 -0
  640. package/src/build/shaderComments.ts +0 -0
  641. package/src/cinematic/player.ts +209 -0
  642. package/src/cinematic/script.ts +231 -0
  643. package/src/core/bootGate.ts +49 -0
  644. package/src/core/loadTracker.ts +144 -0
  645. package/src/core/loop.ts +211 -0
  646. package/src/core/messageQueue.ts +145 -0
  647. package/src/core/onceSet.ts +65 -0
  648. package/src/core/preferences.ts +177 -0
  649. package/src/core/remoteSave.ts +347 -0
  650. package/src/core/rng.ts +101 -0
  651. package/src/core/stepBudget.ts +136 -0
  652. package/src/core/storage.ts +114 -0
  653. package/src/core/tickTrace.ts +129 -0
  654. package/src/core/timeCurve.ts +175 -0
  655. package/src/core/withDefaults.ts +28 -0
  656. package/src/dev/contactProbe.ts +115 -0
  657. package/src/dev/fpsMeter.ts +101 -0
  658. package/src/environment/celestialClock.ts +385 -0
  659. package/src/geometry/decal.ts +260 -0
  660. package/src/geometry/filmPatch.ts +158 -0
  661. package/src/geometry/growable.ts +165 -0
  662. package/src/geometry/lightVolume.ts +161 -0
  663. package/src/geometry/meshBuilder.ts +1397 -0
  664. package/src/geometry/pixelFont.ts +189 -0
  665. package/src/geometry/ribbon.ts +790 -0
  666. package/src/geometry/shellFill.ts +265 -0
  667. package/src/geometry/spline.ts +659 -0
  668. package/src/geometry/tangents.ts +173 -0
  669. package/src/geometry/textMesh.ts +96 -0
  670. package/src/geometry/treeBuilder.ts +114 -0
  671. package/src/host/display.ts +180 -0
  672. package/src/host/files.ts +77 -0
  673. package/src/host/lifecycle.ts +63 -0
  674. package/src/host/platformServices.ts +23 -0
  675. package/src/host/screen.ts +134 -0
  676. package/src/index.ts +730 -0
  677. package/src/input/actionMap.ts +377 -0
  678. package/src/input/activeDevice.ts +86 -0
  679. package/src/input/gamepadIdentity.ts +131 -0
  680. package/src/input/gamepadMapping.ts +121 -0
  681. package/src/input/input.ts +872 -0
  682. package/src/input/inputHarness.ts +226 -0
  683. package/src/input/rightGesture.ts +76 -0
  684. package/src/input/rumble.ts +138 -0
  685. package/src/input/touchControls.ts +451 -0
  686. package/src/input/typingTarget.ts +26 -0
  687. package/src/math/bounds.ts +153 -0
  688. package/src/math/color.ts +37 -0
  689. package/src/math/exact.ts +274 -0
  690. package/src/math/frustum.ts +115 -0
  691. package/src/math/intersect.ts +228 -0
  692. package/src/math/scalar.ts +109 -0
  693. package/src/math/spring.ts +106 -0
  694. package/src/nav/navGraph.ts +168 -0
  695. package/src/nav/navPath.ts +217 -0
  696. package/src/nav/navSearch.ts +200 -0
  697. package/src/physics/boxSurface.ts +96 -0
  698. package/src/physics/colliderSurface.ts +213 -0
  699. package/src/physics/compositeSurface.ts +111 -0
  700. package/src/physics/heightSurface.ts +234 -0
  701. package/src/physics/ribbonSurface.ts +642 -0
  702. package/src/render/ambientOcclusionPass.ts +200 -0
  703. package/src/render/areaLights.ts +194 -0
  704. package/src/render/areaShadowSet.ts +405 -0
  705. package/src/render/atmosphere.ts +186 -0
  706. package/src/render/backend/api.ts +802 -0
  707. package/src/render/backend/budget.ts +139 -0
  708. package/src/render/backend/createRenderer.ts +343 -0
  709. package/src/render/backend/deadline.ts +37 -0
  710. package/src/render/backend/probe.ts +152 -0
  711. package/src/render/backend/select.ts +288 -0
  712. package/src/render/backend/timer.ts +59 -0
  713. package/src/render/backend/webgl2/instanced.ts +46 -0
  714. package/src/render/backend/webgl2/morphTexture.ts +58 -0
  715. package/src/render/backend/webgl2/renderer.ts +7484 -0
  716. package/src/render/backend/webgl2/skinPaletteTexture.ts +70 -0
  717. package/src/render/backend/webgpu/boltPass.ts +205 -0
  718. package/src/render/backend/webgpu/buffers.ts +553 -0
  719. package/src/render/backend/webgpu/causticsPass.ts +174 -0
  720. package/src/render/backend/webgpu/clusterBinner.ts +259 -0
  721. package/src/render/backend/webgpu/depthPass.ts +261 -0
  722. package/src/render/backend/webgpu/device.ts +148 -0
  723. package/src/render/backend/webgpu/drawCommand.ts +79 -0
  724. package/src/render/backend/webgpu/environmentTexels.ts +96 -0
  725. package/src/render/backend/webgpu/filmPass.ts +123 -0
  726. package/src/render/backend/webgpu/flatPass.ts +635 -0
  727. package/src/render/backend/webgpu/flockPass.ts +163 -0
  728. package/src/render/backend/webgpu/gpuTimestamps.ts +255 -0
  729. package/src/render/backend/webgpu/insetPass.ts +123 -0
  730. package/src/render/backend/webgpu/instanced.ts +55 -0
  731. package/src/render/backend/webgpu/lightVolumePass.ts +203 -0
  732. package/src/render/backend/webgpu/linePass.ts +270 -0
  733. package/src/render/backend/webgpu/morphTexture.ts +61 -0
  734. package/src/render/backend/webgpu/panelPass.ts +138 -0
  735. package/src/render/backend/webgpu/particlePass.ts +370 -0
  736. package/src/render/backend/webgpu/pipelineCache.ts +152 -0
  737. package/src/render/backend/webgpu/plumePass.ts +292 -0
  738. package/src/render/backend/webgpu/pointShadowPass.ts +368 -0
  739. package/src/render/backend/webgpu/postPass.ts +470 -0
  740. package/src/render/backend/webgpu/probePass.ts +218 -0
  741. package/src/render/backend/webgpu/reflectionPass.ts +137 -0
  742. package/src/render/backend/webgpu/renderer.ts +13004 -0
  743. package/src/render/backend/webgpu/scatterPass.ts +354 -0
  744. package/src/render/backend/webgpu/sdfTextPass.ts +220 -0
  745. package/src/render/backend/webgpu/shaderModules.ts +49 -0
  746. package/src/render/backend/webgpu/shaders/clusterBin.wgsl.ts +219 -0
  747. package/src/render/backend/webgpu/skinPaletteRing.ts +105 -0
  748. package/src/render/backend/webgpu/skinPaletteTexture.ts +79 -0
  749. package/src/render/backend/webgpu/skyPass.ts +85 -0
  750. package/src/render/backend/webgpu/surfaceTexturePass.ts +257 -0
  751. package/src/render/backend/webgpu/textPass.ts +224 -0
  752. package/src/render/backend/webgpu/uniformRing.ts +228 -0
  753. package/src/render/backend/webgpu/waterPass.ts +211 -0
  754. package/src/render/backend/webgpu/windStreakPass.ts +196 -0
  755. package/src/render/billboard.ts +108 -0
  756. package/src/render/bloomChain.ts +101 -0
  757. package/src/render/bloomPass.ts +256 -0
  758. package/src/render/boltBatch.ts +141 -0
  759. package/src/render/boltPool.ts +360 -0
  760. package/src/render/boom.ts +123 -0
  761. package/src/render/camera.ts +348 -0
  762. package/src/render/causticsRenderer.ts +171 -0
  763. package/src/render/cinematicCamera.ts +278 -0
  764. package/src/render/clusteredLights.ts +598 -0
  765. package/src/render/colourGrade.ts +109 -0
  766. package/src/render/compute.ts +83 -0
  767. package/src/render/contextLoss.ts +50 -0
  768. package/src/render/debugLines.ts +411 -0
  769. package/src/render/decalPass.ts +124 -0
  770. package/src/render/decalProjector.ts +390 -0
  771. package/src/render/decalQueue.ts +110 -0
  772. package/src/render/depthConvention.ts +383 -0
  773. package/src/render/drawingBuffer.ts +89 -0
  774. package/src/render/emptyTexture.ts +130 -0
  775. package/src/render/envProbeArray.ts +201 -0
  776. package/src/render/equirectToCube.ts +160 -0
  777. package/src/render/flockGeometry.ts +53 -0
  778. package/src/render/flockRenderer.ts +111 -0
  779. package/src/render/frame/arena.ts +93 -0
  780. package/src/render/frame/index.ts +29 -0
  781. package/src/render/frame/replay.ts +50 -0
  782. package/src/render/frame/resources.ts +61 -0
  783. package/src/render/frame/schedule.ts +85 -0
  784. package/src/render/frameView.ts +20 -0
  785. package/src/render/gizmo.ts +923 -0
  786. package/src/render/globalMedium.ts +154 -0
  787. package/src/render/globalMediumPass.ts +323 -0
  788. package/src/render/gpuCapability.ts +244 -0
  789. package/src/render/gpuTimer.ts +182 -0
  790. package/src/render/halfFloat.ts +39 -0
  791. package/src/render/handleRegistry.ts +96 -0
  792. package/src/render/iesProfile.ts +215 -0
  793. package/src/render/imageTexels.ts +109 -0
  794. package/src/render/instancedMesh.ts +187 -0
  795. package/src/render/instances.ts +92 -0
  796. package/src/render/lightBudget.ts +655 -0
  797. package/src/render/lightMatrix.ts +69 -0
  798. package/src/render/lightVolumeDraw.ts +216 -0
  799. package/src/render/lineBatch.ts +180 -0
  800. package/src/render/linePoints.ts +61 -0
  801. package/src/render/livePointShadowSet.ts +285 -0
  802. package/src/render/lod.ts +86 -0
  803. package/src/render/mesh.ts +536 -0
  804. package/src/render/occlusion.ts +406 -0
  805. package/src/render/oitPass.ts +230 -0
  806. package/src/render/orderIndependent.ts +136 -0
  807. package/src/render/particleBatch.ts +299 -0
  808. package/src/render/particleMaterial.ts +84 -0
  809. package/src/render/particlePool.ts +291 -0
  810. package/src/render/pass.ts +203 -0
  811. package/src/render/passTarget.ts +225 -0
  812. package/src/render/pickable.ts +222 -0
  813. package/src/render/planarReflection.ts +233 -0
  814. package/src/render/planarReflectionDraw.ts +87 -0
  815. package/src/render/plumeGeometry.ts +75 -0
  816. package/src/render/plumeMaterial.ts +99 -0
  817. package/src/render/plumeRenderer.ts +272 -0
  818. package/src/render/pointLightSelection.ts +447 -0
  819. package/src/render/pointShadowArray.ts +276 -0
  820. package/src/render/pointShadowBudget.ts +305 -0
  821. package/src/render/pointShadowImage.ts +470 -0
  822. package/src/render/pointShadowMap.ts +228 -0
  823. package/src/render/pointShadowSystem.ts +408 -0
  824. package/src/render/prefilterEnvMap.ts +162 -0
  825. package/src/render/prefilterPass.ts +115 -0
  826. package/src/render/probeGrid.ts +248 -0
  827. package/src/render/rainField.ts +240 -0
  828. package/src/render/reflectionProbe.ts +530 -0
  829. package/src/render/renderQuality.ts +1054 -0
  830. package/src/render/rendererHarness.ts +214 -0
  831. package/src/render/resolutionGovernor.ts +189 -0
  832. package/src/render/scatterDeform.ts +72 -0
  833. package/src/render/sceneTarget.ts +1032 -0
  834. package/src/render/screenSpaceReflection.ts +524 -0
  835. package/src/render/sdfFont.ts +157 -0
  836. package/src/render/sdfTextLayout.ts +206 -0
  837. package/src/render/sdfTextRenderer.ts +233 -0
  838. package/src/render/seaState.ts +55 -0
  839. package/src/render/segmentQuads.ts +92 -0
  840. package/src/render/shader.ts +190 -0
  841. package/src/render/shaders/ambientOcclusion.ts +354 -0
  842. package/src/render/shaders/arcane.ts +103 -0
  843. package/src/render/shaders/bloom.ts +232 -0
  844. package/src/render/shaders/bolt.ts +164 -0
  845. package/src/render/shaders/caustics.ts +169 -0
  846. package/src/render/shaders/conditionals.ts +58 -0
  847. package/src/render/shaders/decalProject.ts +127 -0
  848. package/src/render/shaders/depth.ts +131 -0
  849. package/src/render/shaders/depthOfField.ts +141 -0
  850. package/src/render/shaders/film.ts +285 -0
  851. package/src/render/shaders/fire.ts +180 -0
  852. package/src/render/shaders/flat/directionalShadow.ts +196 -0
  853. package/src/render/shaders/flat/index.ts +502 -0
  854. package/src/render/shaders/flat/lobes.ts +399 -0
  855. package/src/render/shaders/flat/main.ts +1631 -0
  856. package/src/render/shaders/flat/pointShadow.ts +323 -0
  857. package/src/render/shaders/flat/preamble.ts +875 -0
  858. package/src/render/shaders/flat/probeGrid.ts +152 -0
  859. package/src/render/shaders/flat/surface.ts +41 -0
  860. package/src/render/shaders/flock.ts +103 -0
  861. package/src/render/shaders/fog.ts +99 -0
  862. package/src/render/shaders/fullscreen.ts +28 -0
  863. package/src/render/shaders/generated/ambientOcclusion.wgsl.ts +74 -0
  864. package/src/render/shaders/generated/arcane.wgsl.ts +98 -0
  865. package/src/render/shaders/generated/bloom.wgsl.ts +79 -0
  866. package/src/render/shaders/generated/bolt.wgsl.ts +127 -0
  867. package/src/render/shaders/generated/caustics.wgsl.ts +127 -0
  868. package/src/render/shaders/generated/decalProject.wgsl.ts +69 -0
  869. package/src/render/shaders/generated/depth.wgsl.ts +142 -0
  870. package/src/render/shaders/generated/film.wgsl.ts +143 -0
  871. package/src/render/shaders/generated/fire.wgsl.ts +137 -0
  872. package/src/render/shaders/generated/flat.wgsl.ts +9195 -0
  873. package/src/render/shaders/generated/flock.wgsl.ts +82 -0
  874. package/src/render/shaders/generated/fullscreen.wgsl.ts +20 -0
  875. package/src/render/shaders/generated/globalMedium.wgsl.ts +139 -0
  876. package/src/render/shaders/generated/lightVolume.wgsl.ts +242 -0
  877. package/src/render/shaders/generated/line.wgsl.ts +137 -0
  878. package/src/render/shaders/generated/octahedralResolve.wgsl.ts +60 -0
  879. package/src/render/shaders/generated/oitResolve.wgsl.ts +31 -0
  880. package/src/render/shaders/generated/panel.wgsl.ts +57 -0
  881. package/src/render/shaders/generated/particle.wgsl.ts +343 -0
  882. package/src/render/shaders/generated/prefilter.wgsl.ts +69 -0
  883. package/src/render/shaders/generated/rush.wgsl.ts +139 -0
  884. package/src/render/shaders/generated/scatter.wgsl.ts +205 -0
  885. package/src/render/shaders/generated/sdfText.wgsl.ts +78 -0
  886. package/src/render/shaders/generated/sky.wgsl.ts +109 -0
  887. package/src/render/shaders/generated/smoke.wgsl.ts +93 -0
  888. package/src/render/shaders/generated/ssrResolve.wgsl.ts +26 -0
  889. package/src/render/shaders/generated/ssrTrace.wgsl.ts +94 -0
  890. package/src/render/shaders/generated/temporalResolve.wgsl.ts +54 -0
  891. package/src/render/shaders/generated/text.wgsl.ts +107 -0
  892. package/src/render/shaders/generated/water.wgsl.ts +256 -0
  893. package/src/render/shaders/generated/windStreaks.wgsl.ts +82 -0
  894. package/src/render/shaders/gerstner.ts +110 -0
  895. package/src/render/shaders/globalMedium.ts +396 -0
  896. package/src/render/shaders/lightVolume.ts +546 -0
  897. package/src/render/shaders/line.ts +125 -0
  898. package/src/render/shaders/morph.ts +62 -0
  899. package/src/render/shaders/octahedral.ts +170 -0
  900. package/src/render/shaders/octahedralResolve.ts +83 -0
  901. package/src/render/shaders/oitResolve.ts +42 -0
  902. package/src/render/shaders/outputTransform.ts +107 -0
  903. package/src/render/shaders/panel.ts +51 -0
  904. package/src/render/shaders/particle.ts +438 -0
  905. package/src/render/shaders/prefilter.ts +278 -0
  906. package/src/render/shaders/rush.ts +357 -0
  907. package/src/render/shaders/scatter.ts +211 -0
  908. package/src/render/shaders/sdfText.ts +68 -0
  909. package/src/render/shaders/skinning.ts +59 -0
  910. package/src/render/shaders/sky.ts +243 -0
  911. package/src/render/shaders/smoke.ts +89 -0
  912. package/src/render/shaders/ssrResolve.ts +28 -0
  913. package/src/render/shaders/ssrTrace.ts +233 -0
  914. package/src/render/shaders/tangentFrame.ts +70 -0
  915. package/src/render/shaders/temporalResolve.ts +151 -0
  916. package/src/render/shaders/text.ts +156 -0
  917. package/src/render/shaders/vertexChannel.ts +71 -0
  918. package/src/render/shaders/water.ts +356 -0
  919. package/src/render/shaders/windStreaks.ts +130 -0
  920. package/src/render/shadowCasters.ts +124 -0
  921. package/src/render/shadowMap.ts +89 -0
  922. package/src/render/shotPlacement.ts +266 -0
  923. package/src/render/skinPalette.ts +157 -0
  924. package/src/render/ssrPass.ts +241 -0
  925. package/src/render/surfaceSheet.ts +158 -0
  926. package/src/render/surfaceTexture.ts +310 -0
  927. package/src/render/temporalAa.ts +221 -0
  928. package/src/render/temporalPass.ts +153 -0
  929. package/src/render/textLayout.ts +239 -0
  930. package/src/render/textRenderer.ts +201 -0
  931. package/src/render/thirdPersonCamera.ts +578 -0
  932. package/src/render/trample.ts +140 -0
  933. package/src/render/translucentQueue.ts +161 -0
  934. package/src/render/uniformVectorBudget.ts +246 -0
  935. package/src/render/uploadStep.ts +14 -0
  936. package/src/render/vertexDefaults.ts +115 -0
  937. package/src/render/visibility.ts +56 -0
  938. package/src/render/waterDraw.ts +167 -0
  939. package/src/render/waterGrid.ts +180 -0
  940. package/src/render/waterRenderer.ts +352 -0
  941. package/src/render/wind.ts +79 -0
  942. package/src/render/windField.ts +50 -0
  943. package/src/render/windStreakDraw.ts +131 -0
  944. package/src/render/windStreakRenderer.ts +130 -0
  945. package/src/scene/node.ts +336 -0
  946. package/src/scene/visit.ts +82 -0
  947. package/src/ui/clipMime.ts +109 -0
  948. package/src/ui/exportTarget.ts +491 -0
  949. package/src/ui/frameOverlay.ts +159 -0
  950. package/src/ui/framePacer.ts +351 -0
  951. package/src/ui/frameRecorder.ts +333 -0
  952. package/src/ui/fullscreen.ts +113 -0
  953. package/src/ui/pixelCursor.ts +99 -0
  954. package/src/ui/splash.ts +347 -0
  955. package/src/ui/stillFrame.ts +44 -0
@@ -0,0 +1,206 @@
1
+ import { CLUSTER_COUNT, LIGHT_RECORD, LIGHT_TEXELS, NO_IES_PROFILE, POINT_LIGHT_COS_INNER, POINT_LIGHT_COS_OUTER, MAX_CLUSTERED_LIGHTS, TABLE_HEIGHT, TABLE_WIDTH, } from '../../clusteredLights.js';
2
+ import { MAX_POINT_LIGHTS } from '../../lightBudget.js';
3
+ import { CLUSTER_BIN_WGSL } from './shaders/clusterBin.wgsl.js';
4
+ /**
5
+ * The froxel binner on the GPU: the first thing in this engine to dispatch compute.
6
+ *
7
+ * **What it replaces is not a slow thing, it is a thing on the wrong processor.** The CPU binner
8
+ * in `clusteredLights.ts` is measured at 0.386 ms a frame for sixteen lights and 2.0 ms for 256,
9
+ * and 2 ms is 12% of a 60 fps frame spent on the main thread where a consumer's own game logic
10
+ * lives. On WebGL2 there is nowhere else to put it. Here there is.
11
+ *
12
+ * **It writes the same table, and that is asserted rather than assumed.** `scripts/cluster-check.mjs`
13
+ * runs both binners over one camera and one light set and compares the tables, because the
14
+ * 2026-08-17 rule says two implementations of one decision drift invisibly when their constants
15
+ * agree — which is exactly the situation this is.
16
+ */
17
+ /*
18
+ * WebGPU usage flags, named rather than read off the globals, for the reason `buffers.ts` gives:
19
+ * the values are normative in the specification and the globals do not exist outside a browser.
20
+ */
21
+ const BUFFER_USAGE = {
22
+ COPY_DST: 0x0008,
23
+ UNIFORM: 0x0040,
24
+ STORAGE: 0x0080,
25
+ };
26
+ const TEXTURE_USAGE = {
27
+ COPY_SRC: 0x01,
28
+ TEXTURE_BINDING: 0x04,
29
+ STORAGE_BINDING: 0x08,
30
+ };
31
+ /** `mat4` plus a `vec4` plus four `u32`, which is 96 bytes and already 16-byte aligned. */
32
+ const PARAMS_BYTES = 16 * 4 + 4 * 4 + 4 * 4;
33
+ /** Invocations a workgroup, matching `@workgroup_size` in the shader. */
34
+ const WORKGROUP = 64;
35
+ export class ClusterBinner {
36
+ /** The table the lit pass samples. Written by the dispatch, never by the CPU on this backend. */
37
+ texture = null;
38
+ view = null;
39
+ pipeline = null;
40
+ group = null;
41
+ params = null;
42
+ lightBuffer = null;
43
+ device = null;
44
+ /** Staging for the two uploads, allocated once: `dispatch` is a per-frame path. */
45
+ paramsStaging = new ArrayBuffer(PARAMS_BYTES);
46
+ paramsFloats = new Float32Array(this.paramsStaging);
47
+ paramsUints = new Uint32Array(this.paramsStaging);
48
+ lightStaging = new Float32Array(MAX_CLUSTERED_LIGHTS * LIGHT_TEXELS * 4);
49
+ frame = null;
50
+ /** The table's view, for whoever binds it into the lit pass. Null before `init`. */
51
+ get tableView() {
52
+ return this.view;
53
+ }
54
+ /** The table itself, which a readback needs and the lit pass does not. */
55
+ get tableTexture() {
56
+ return this.texture;
57
+ }
58
+ /**
59
+ * The device `init` was handed, for a caller that needs to encode a copy of its own.
60
+ *
61
+ * **Exposed rather than fetched from somewhere else**, because there is nowhere else: a
62
+ * `GPUTexture` does not name its device and `createRenderer` does not return one. The seam
63
+ * hands a definition the device precisely so it can do work of its own outside a dispatch, and
64
+ * a readback is that work.
65
+ */
66
+ get gpuDevice() {
67
+ return this.device;
68
+ }
69
+ /** What the next dispatch bins. Set per frame; nothing is copied until `dispatch`. */
70
+ setFrame(frame) {
71
+ this.frame = frame;
72
+ }
73
+ definition() {
74
+ return {
75
+ label: 'lights.bin',
76
+ init: (device) => this.build(device.device),
77
+ dispatch: (ctx) => this.run(ctx),
78
+ dispose: () => this.release(),
79
+ };
80
+ }
81
+ build(device) {
82
+ this.device = device;
83
+ this.texture = device.createTexture({
84
+ label: 'lights.clusterTable',
85
+ size: [TABLE_WIDTH, TABLE_HEIGHT],
86
+ /*
87
+ * `rgba32uint` because the indices are integers and an integer is what a texture carries
88
+ * exactly. It is also one of core WebGPU's storage-capable formats, which is what lets the
89
+ * dispatch write it at all — and `texelFetch` reads the same format on WebGL2, which is the
90
+ * whole reason the interface between binning and shading is a texture.
91
+ */
92
+ format: 'rgba32uint',
93
+ usage: TEXTURE_USAGE.STORAGE_BINDING | TEXTURE_USAGE.TEXTURE_BINDING | TEXTURE_USAGE.COPY_SRC,
94
+ });
95
+ this.view = this.texture.createView({ label: 'lights.clusterTable' });
96
+ this.params = device.createBuffer({
97
+ label: 'lights.bin.params',
98
+ size: PARAMS_BYTES,
99
+ usage: BUFFER_USAGE.UNIFORM | BUFFER_USAGE.COPY_DST,
100
+ });
101
+ this.lightBuffer = device.createBuffer({
102
+ label: 'lights.bin.lights',
103
+ size: this.lightStaging.byteLength,
104
+ usage: BUFFER_USAGE.STORAGE | BUFFER_USAGE.COPY_DST,
105
+ });
106
+ this.pipeline = device.createComputePipeline({
107
+ label: 'lights.bin',
108
+ layout: 'auto',
109
+ compute: {
110
+ module: device.createShaderModule({ label: 'lights.bin', code: CLUSTER_BIN_WGSL }),
111
+ entryPoint: 'main',
112
+ },
113
+ });
114
+ this.group = device.createBindGroup({
115
+ label: 'lights.bin',
116
+ layout: this.pipeline.getBindGroupLayout(0),
117
+ entries: [
118
+ { binding: 0, resource: { buffer: this.params } },
119
+ { binding: 1, resource: { buffer: this.lightBuffer } },
120
+ { binding: 2, resource: this.view },
121
+ ],
122
+ });
123
+ }
124
+ run(ctx) {
125
+ const frame = this.frame;
126
+ const { device, pipeline, group, params, lightBuffer } = this;
127
+ if (frame === null || device === null || pipeline === null || group === null)
128
+ return;
129
+ if (params === null || lightBuffer === null)
130
+ return;
131
+ const count = Math.min(frame.lights.count, MAX_CLUSTERED_LIGHTS);
132
+ /*
133
+ * The records, in exactly the order `buildLightClusters` writes them, because the shader
134
+ * copies them into the table verbatim and the lit pass reads one layout on both backends.
135
+ */
136
+ for (let light = 0; light < count; light++) {
137
+ const at = light * LIGHT_TEXELS * 4;
138
+ this.lightStaging[at] = frame.lights.positions[light * 3] ?? 0;
139
+ this.lightStaging[at + 1] = frame.lights.positions[light * 3 + 1] ?? 0;
140
+ this.lightStaging[at + 2] = frame.lights.positions[light * 3 + 2] ?? 0;
141
+ this.lightStaging[at + 3] = frame.lights.radii[light] ?? 0;
142
+ this.lightStaging[at + 4] = frame.lights.colors[light * 3] ?? 0;
143
+ this.lightStaging[at + 5] = frame.lights.colors[light * 3 + 1] ?? 0;
144
+ this.lightStaging[at + 6] = frame.lights.colors[light * 3 + 2] ?? 0;
145
+ this.lightStaging[at + 7] = frame.lights.sourceRadii[light] ?? 0;
146
+ this.lightStaging[at + LIGHT_RECORD.weight] = frame.lights.weights[light] ?? 1;
147
+ this.lightStaging[at + LIGHT_RECORD.shadowSlot] = light < frame.shadowSlots ? light : -1;
148
+ /*
149
+ * The cone, addressed through `LIGHT_RECORD` rather than by number. Two writers fill this
150
+ * record — the CPU binner in `clusteredLights.ts` and this — and the 2026-08-17 rule is that
151
+ * two implementations of one decision drift invisibly when the constants are identical. They
152
+ * now read the same table of offsets, so a field can only move in both at once.
153
+ *
154
+ * `POINT_LIGHT_COS_OUTER` and its inner twin are what make a light with no cone collapse to
155
+ * exactly the arithmetic a point light had. `scripts/cluster-check.mjs` compares the two
156
+ * tables byte for byte and is what would catch this being wrong anyway.
157
+ */
158
+ const directions = frame.lights.directions;
159
+ const cone = frame.lights.coneCos;
160
+ this.lightStaging[at + LIGHT_RECORD.directionX] = directions?.[light * 3] ?? 0;
161
+ this.lightStaging[at + LIGHT_RECORD.directionY] = directions?.[light * 3 + 1] ?? 0;
162
+ this.lightStaging[at + LIGHT_RECORD.directionZ] = directions?.[light * 3 + 2] ?? 0;
163
+ this.lightStaging[at + LIGHT_RECORD.cosInner] = cone?.[light * 2] ?? POINT_LIGHT_COS_INNER;
164
+ this.lightStaging[at + LIGHT_RECORD.cosOuter] =
165
+ cone?.[light * 2 + 1] ?? POINT_LIGHT_COS_OUTER;
166
+ this.lightStaging[at + LIGHT_RECORD.iesProfile] =
167
+ frame.lights.iesProfiles?.[light] ?? NO_IES_PROFILE;
168
+ /* The azimuth reference an asymmetric profile is oriented by; zero where a consumer gave
169
+ none, which the shader reads as no usable reference and leaves on the first plane. */
170
+ const axes = frame.lights.iesAxes;
171
+ this.lightStaging[at + LIGHT_RECORD.iesAxisX] = axes?.[light * 3] ?? 0;
172
+ this.lightStaging[at + LIGHT_RECORD.iesAxisY] = axes?.[light * 3 + 1] ?? 0;
173
+ this.lightStaging[at + LIGHT_RECORD.iesAxisZ] = axes?.[light * 3 + 2] ?? 0;
174
+ this.lightStaging[at + LIGHT_RECORD.cookie] = frame.lights.cookies?.[light] ?? NO_IES_PROFILE;
175
+ }
176
+ this.paramsFloats.set(frame.view, 0);
177
+ this.paramsFloats[16] = frame.near;
178
+ this.paramsFloats[17] = frame.far;
179
+ this.paramsFloats[18] = frame.tanHalfFovY;
180
+ this.paramsFloats[19] = frame.aspect;
181
+ this.paramsUints[20] = count;
182
+ device.queue.writeBuffer(params, 0, this.paramsStaging);
183
+ device.queue.writeBuffer(lightBuffer, 0, this.lightStaging.buffer, 0, count * LIGHT_TEXELS * 16);
184
+ ctx.pass.setPipeline(pipeline);
185
+ ctx.pass.setBindGroup(0, group);
186
+ /*
187
+ * Enough invocations for every cluster. The first `count` of them also write a light record,
188
+ * which they can because there are always far more clusters than lights.
189
+ */
190
+ ctx.pass.dispatchWorkgroups(Math.ceil(CLUSTER_COUNT / WORKGROUP));
191
+ }
192
+ release() {
193
+ this.texture?.destroy();
194
+ this.params?.destroy();
195
+ this.lightBuffer?.destroy();
196
+ this.texture = null;
197
+ this.view = null;
198
+ this.params = null;
199
+ this.lightBuffer = null;
200
+ this.pipeline = null;
201
+ this.group = null;
202
+ this.device = null;
203
+ }
204
+ }
205
+ /** The shadow slots a frame has, which is the fixed budget the pool is sized for. */
206
+ export const DEFAULT_SHADOW_SLOTS = MAX_POINT_LIGHTS;
@@ -0,0 +1,114 @@
1
+ import { DEPTH_FRAG_WGSL } from '../../shaders/generated/depth.wgsl.ts';
2
+ import type { PipelineCache } from './pipelineCache.ts';
3
+ /**
4
+ * The shadow pass: the world drawn from the light, into a depth map.
5
+ *
6
+ * **A pass of its own, before the frame.** `beginShadowPass` is called by a scene *before*
7
+ * `beginFrame`, so this owns its own encoder and its own render pass rather than sharing the
8
+ * frame's. That ordering is the scene's and is not this backend's to change.
9
+ */
10
+ export declare const DEPTH_VERT_FIELDS: {
11
+ readonly uLightViewProj: {
12
+ readonly offset: 0;
13
+ readonly size: 64;
14
+ readonly type: "mat4";
15
+ };
16
+ readonly uModel: {
17
+ readonly offset: 64;
18
+ readonly size: 64;
19
+ readonly type: "mat4";
20
+ };
21
+ readonly uWindDirection: {
22
+ readonly offset: 128;
23
+ readonly size: 8;
24
+ readonly type: "vec2";
25
+ };
26
+ readonly uWindSpeed: {
27
+ readonly offset: 136;
28
+ readonly size: 4;
29
+ readonly type: "float";
30
+ };
31
+ readonly uWindGust: {
32
+ readonly offset: 140;
33
+ readonly size: 4;
34
+ readonly type: "float";
35
+ };
36
+ readonly uWindTime: {
37
+ readonly offset: 144;
38
+ readonly size: 4;
39
+ readonly type: "float";
40
+ };
41
+ readonly uWindSpatialPhase: {
42
+ readonly offset: 152;
43
+ readonly size: 8;
44
+ readonly type: "vec2";
45
+ };
46
+ };
47
+ export declare const DEPTH_VERT_SIZE: 160;
48
+ export declare const DEPTH_FRAG_SIZE: 16;
49
+ /** Re-exported so the scatter depth pass can pair with the same fragment stage. */
50
+ export { DEPTH_FRAG_WGSL };
51
+ export declare const DEPTH_FRAG_BINDING: 1;
52
+ export declare const DEPTH_PREVIOUS_BINDING: {
53
+ readonly texture: 32;
54
+ readonly sampler: 33;
55
+ readonly type: "sampler2D";
56
+ };
57
+ /** Where the skinned vertex stage reads the joint palette. Generated, not chosen here. */
58
+ export declare const DEPTH_PALETTE_BINDING: {
59
+ readonly texture: 16;
60
+ readonly sampler: 17;
61
+ readonly type: "sampler2D";
62
+ };
63
+ /**
64
+ * The format the shadow map is stored in.
65
+ *
66
+ * `depth32float` rather than the frame's `depth24plus`, because this one is *sampled* as
67
+ * well as written and a comparison against a quantised depth is where shadow acne comes
68
+ * from. It is also the format `shadowMap.ts` asks WebGL2 for, so the two backends compare
69
+ * the same numbers.
70
+ */
71
+ export declare const SHADOW_FORMAT: GPUTextureFormat;
72
+ export declare function createDepthBindGroupLayout(device: GPUDevice,
73
+ /**
74
+ * Whether this layout carries the joint palette.
75
+ *
76
+ * A **separate layout** rather than the palette added to the one layout with a stand-in bound
77
+ * when nothing is skinned, which is the shape `flatLayoutFor` already uses. What it buys is that
78
+ * the rigid path is untouched: no extra binding, no one-pixel texture to keep alive, and a
79
+ * frame that skins nothing pays nothing at all.
80
+ */
81
+ skinned?: boolean): GPUBindGroupLayout;
82
+ export declare function createDepthBindGroup(device: GPUDevice, layout: GPUBindGroupLayout, perDraw: GPUBuffer, perPass: GPUBuffer, previous: GPUTextureView, sampler: GPUSampler,
83
+ /** The joint palette, for a layout built with `skinned`. Omit for the rigid layout. */
84
+ palette?: GPUTextureView | null): GPUBindGroup;
85
+ /**
86
+ * The depth pipeline.
87
+ *
88
+ * **No colour target at all.** The pass writes depth and nothing else, which is what makes
89
+ * it cheap; a colour attachment here would be a buffer written and never read.
90
+ *
91
+ * The vertex layout is the mesh's own, because the depth shader takes position from
92
+ * location 0 and the pipeline still has to describe every attribute the module declares.
93
+ */
94
+ export declare function depthPipeline(cache: PipelineCache, device: GPUDevice, layout: GPUBindGroupLayout, key: string, present: Readonly<Record<string, boolean>>,
95
+ /**
96
+ * **`none` for a cubemap face, and the directional pass's own comment says why not here.**
97
+ *
98
+ * That comment argues against culling front faces to cure acne, and it is about the
99
+ * *directional* map, which is rendered from far away over a whole world. A point light's
100
+ * cube is rendered from inside a room, and `pointShadowMap.ts` disables culling outright for
101
+ * a reason that is not about acne at all: rendering back faces only stores the far side of
102
+ * every caster, and for a character's limbs the near and far sides are centimetres apart, so
103
+ * the caster effectively vanishes from the map. Two passes, two answers, one parameter.
104
+ */
105
+ cullMode?: GPUCullMode,
106
+ /** Whether this pipeline's vertex stage reads a joint palette. See `DEPTH_SKINNED_VERT`. */
107
+ skinned?: boolean,
108
+ /**
109
+ * Whether placement arrives per instance. See `DEPTH_INSTANCED_VERT`.
110
+ *
111
+ * Excludes `skinned`, and the layout is why rather than the shader: an instanced pipeline
112
+ * reclaims the two attribute locations the joint indices and weights occupy.
113
+ */
114
+ instanced?: boolean): GPURenderPipeline;
@@ -0,0 +1,228 @@
1
+ import { DEPTH_BINDINGS, DEPTH_FRAG_WGSL, DEPTH_INSTANCED_VERT_WGSL, DEPTH_SKINNED_VERT_WGSL, DEPTH_VERT_WGSL, } from '../../shaders/generated/depth.wgsl.js';
2
+ import { vertexBufferLayouts } from './buffers.js';
3
+ import { shaderModule } from './shaderModules.js';
4
+ /**
5
+ * The shadow pass: the world drawn from the light, into a depth map.
6
+ *
7
+ * **A pass of its own, before the frame.** `beginShadowPass` is called by a scene *before*
8
+ * `beginFrame`, so this owns its own encoder and its own render pass rather than sharing the
9
+ * frame's. That ordering is the scene's and is not this backend's to change.
10
+ */
11
+ export const DEPTH_VERT_FIELDS = DEPTH_BINDINGS.DEPTH_VERT.fields;
12
+ export const DEPTH_VERT_SIZE = DEPTH_BINDINGS.DEPTH_VERT.uniformSize;
13
+ export const DEPTH_FRAG_SIZE = DEPTH_BINDINGS.DEPTH_FRAG.uniformSize;
14
+ /** Re-exported so the scatter depth pass can pair with the same fragment stage. */
15
+ export { DEPTH_FRAG_WGSL };
16
+ export const DEPTH_FRAG_BINDING = DEPTH_BINDINGS.DEPTH_FRAG.uniforms;
17
+ export const DEPTH_PREVIOUS_BINDING = DEPTH_BINDINGS.DEPTH_FRAG.textures.uPreviousShadowMap;
18
+ const VERT_BINDING = DEPTH_BINDINGS.DEPTH_VERT.uniforms;
19
+ const FRAG_BINDING = DEPTH_BINDINGS.DEPTH_FRAG.uniforms;
20
+ const PREVIOUS = DEPTH_BINDINGS.DEPTH_FRAG.textures.uPreviousShadowMap;
21
+ /** Where the skinned vertex stage reads the joint palette. Generated, not chosen here. */
22
+ export const DEPTH_PALETTE_BINDING = DEPTH_BINDINGS.DEPTH_SKINNED_VERT.textures.uJointPalette;
23
+ const VISIBILITY_VERTEX = 0x1;
24
+ const VISIBILITY_FRAGMENT = 0x2;
25
+ /**
26
+ * The format the shadow map is stored in.
27
+ *
28
+ * `depth32float` rather than the frame's `depth24plus`, because this one is *sampled* as
29
+ * well as written and a comparison against a quantised depth is where shadow acne comes
30
+ * from. It is also the format `shadowMap.ts` asks WebGL2 for, so the two backends compare
31
+ * the same numbers.
32
+ */
33
+ export const SHADOW_FORMAT = 'depth32float';
34
+ export function createDepthBindGroupLayout(device,
35
+ /**
36
+ * Whether this layout carries the joint palette.
37
+ *
38
+ * A **separate layout** rather than the palette added to the one layout with a stand-in bound
39
+ * when nothing is skinned, which is the shape `flatLayoutFor` already uses. What it buys is that
40
+ * the rigid path is untouched: no extra binding, no one-pixel texture to keep alive, and a
41
+ * frame that skins nothing pays nothing at all.
42
+ */
43
+ skinned = false) {
44
+ return device.createBindGroupLayout({
45
+ label: skinned ? 'depth.layout.skinned' : 'depth.layout',
46
+ entries: [
47
+ /* The texture and no sampler: the shader reads the palette with `textureLoad`, an integer
48
+ coordinate with nothing to filter, which is what `flatPass.ts` binds for the same
49
+ palette. naga declares a sampler for it and nothing ever reads one. */
50
+ ...(skinned
51
+ ? [
52
+ {
53
+ binding: DEPTH_PALETTE_BINDING.texture,
54
+ visibility: VISIBILITY_VERTEX,
55
+ texture: { sampleType: 'unfilterable-float' },
56
+ },
57
+ ]
58
+ : []),
59
+ {
60
+ binding: VERT_BINDING,
61
+ visibility: VISIBILITY_VERTEX,
62
+ buffer: { type: 'uniform', hasDynamicOffset: true, minBindingSize: DEPTH_VERT_SIZE },
63
+ },
64
+ {
65
+ binding: FRAG_BINDING,
66
+ visibility: VISIBILITY_FRAGMENT,
67
+ buffer: { type: 'uniform', minBindingSize: DEPTH_FRAG_SIZE },
68
+ },
69
+ /*
70
+ * **`unfilterable-float`, because the peel binds `SHADOW_FORMAT` here.**
71
+ *
72
+ * The defaults are `sampleType: 'float'` and `type: 'filtering'`, and a `depth32float`
73
+ * view satisfies neither. The device rejects the pair in as many words — *"None of the
74
+ * supported sample types (UnfilterableFloat|Depth) of [Texture "shadow.static"] match
75
+ * the expected sample types (Float)"* — and it rejects it by returning an **invalid
76
+ * bind group rather than throwing**. A peel pass built on one records nothing, so the
77
+ * peel map keeps the undefined contents it was created with and the frame still
78
+ * presents. Three ports of the peel were measured and reverted against that silence.
79
+ *
80
+ * The one-pixel `rgba8unorm` stand-in every non-peel frame binds here satisfies this
81
+ * too — measured, both ways — and the sampler beside it is all-`nearest` already, which
82
+ * is what `non-filtering` requires. `flatPass.ts` reaches the same declaration from the
83
+ * name, and `uPreviousShadowMap` is one of the names it would match.
84
+ */
85
+ {
86
+ binding: PREVIOUS.texture,
87
+ visibility: VISIBILITY_FRAGMENT,
88
+ texture: { sampleType: 'unfilterable-float' },
89
+ },
90
+ {
91
+ binding: PREVIOUS.sampler,
92
+ visibility: VISIBILITY_FRAGMENT,
93
+ sampler: { type: 'non-filtering' },
94
+ },
95
+ ],
96
+ });
97
+ }
98
+ export function createDepthBindGroup(device, layout, perDraw, perPass, previous, sampler,
99
+ /** The joint palette, for a layout built with `skinned`. Omit for the rigid layout. */
100
+ palette = null) {
101
+ return device.createBindGroup({
102
+ label: palette === null ? 'depth.bindGroup' : 'depth.bindGroup.skinned',
103
+ layout,
104
+ entries: [
105
+ { binding: VERT_BINDING, resource: { buffer: perDraw, size: DEPTH_VERT_SIZE } },
106
+ { binding: FRAG_BINDING, resource: { buffer: perPass, size: DEPTH_FRAG_SIZE } },
107
+ { binding: PREVIOUS.texture, resource: previous },
108
+ { binding: PREVIOUS.sampler, resource: sampler },
109
+ ...(palette !== null ? [{ binding: DEPTH_PALETTE_BINDING.texture, resource: palette }] : []),
110
+ ],
111
+ });
112
+ }
113
+ /**
114
+ * The depth pipeline.
115
+ *
116
+ * **No colour target at all.** The pass writes depth and nothing else, which is what makes
117
+ * it cheap; a colour attachment here would be a buffer written and never read.
118
+ *
119
+ * The vertex layout is the mesh's own, because the depth shader takes position from
120
+ * location 0 and the pipeline still has to describe every attribute the module declares.
121
+ */
122
+ export function depthPipeline(cache, device, layout, key, present,
123
+ /**
124
+ * **`none` for a cubemap face, and the directional pass's own comment says why not here.**
125
+ *
126
+ * That comment argues against culling front faces to cure acne, and it is about the
127
+ * *directional* map, which is rendered from far away over a whole world. A point light's
128
+ * cube is rendered from inside a room, and `pointShadowMap.ts` disables culling outright for
129
+ * a reason that is not about acne at all: rendering back faces only stores the far side of
130
+ * every caster, and for a character's limbs the near and far sides are centimetres apart, so
131
+ * the caster effectively vanishes from the map. Two passes, two answers, one parameter.
132
+ */
133
+ cullMode = 'back',
134
+ /** Whether this pipeline's vertex stage reads a joint palette. See `DEPTH_SKINNED_VERT`. */
135
+ skinned = false,
136
+ /**
137
+ * Whether placement arrives per instance. See `DEPTH_INSTANCED_VERT`.
138
+ *
139
+ * Excludes `skinned`, and the layout is why rather than the shader: an instanced pipeline
140
+ * reclaims the two attribute locations the joint indices and weights occupy.
141
+ */
142
+ instanced = false) {
143
+ return cache.get(key, () => ({
144
+ label: key,
145
+ layout: device.createPipelineLayout({ bindGroupLayouts: [layout] }),
146
+ vertex: {
147
+ module: shaderModule(device, instanced
148
+ ? { label: 'depth.instanced.vert', code: DEPTH_INSTANCED_VERT_WGSL }
149
+ : skinned
150
+ ? { label: 'depth.skinned.vert', code: DEPTH_SKINNED_VERT_WGSL }
151
+ : { label: 'depth.vert', code: DEPTH_VERT_WGSL }),
152
+ entryPoint: 'main',
153
+ buffers: vertexBufferLayouts(present, instanced),
154
+ },
155
+ fragment: {
156
+ module: shaderModule(device, { label: 'depth.frag', code: DEPTH_FRAG_WGSL }),
157
+ entryPoint: 'main',
158
+ targets: [],
159
+ },
160
+ /*
161
+ * **Back faces culled, matching the frame.** Culling front faces instead is the textbook
162
+ * answer to shadow acne, and it is the wrong answer here: `renderer.ts` keeps the
163
+ * frame's own back-face culling through the directional pass and handles acne with
164
+ * receiver-plane compensation instead, so a depth map built from the far side of every
165
+ * surface disagrees with what the shader expects to compare against.
166
+ *
167
+ * The symptom was unmistakable and worth recording: the whole scene came out uniformly
168
+ * in shadow — paving, pillars and all — because every fragment compared itself against a
169
+ * depth recorded behind it.
170
+ *
171
+ * **`frontFace: 'cw'`, and it is this pass's projection that asks for it rather than a
172
+ * preference.** Facing is decided in framebuffer coordinates, whose Y points down while
173
+ * clip space's points up, so a triangle wound counter-clockwise in clip space reaches the
174
+ * rasteriser clockwise. Every presented pass is projected through `CLIP_CORRECTION`, which
175
+ * negates Y and turns that back over, so the default `ccw` is right for all of them. This
176
+ * map is sampled rather than presented, so `SHADOW_CLIP_CORRECTION` leaves Y alone — and
177
+ * the default then culls precisely the faces this pass exists to record.
178
+ *
179
+ * That shipped and was invisible for a fortnight, because it takes geometry the light can
180
+ * see through to show: on a world of a vault over an arcade, the vault was missing from the
181
+ * map, so the arcade under it was lit here and in shadow on WebGL2. Read back texel for
182
+ * texel against that backend, 2,000,709 texels of 2,095,575 differed by more than 0.2 m and
183
+ * 805,117 by more than 2 m, this map holding surfaces 8.4 m further from the light on
184
+ * average; declaring the winding takes those to 6,972 and 0.
185
+ *
186
+ * **What would make it wrong** is giving this pass the Y flip after all — the winding has to
187
+ * move back with it, and neither half is inert on its own.
188
+ * `webgpu/renderer.test.ts` asserts the pair against the matrix rather than against the
189
+ * literal for that reason.
190
+ */
191
+ primitive: { topology: 'triangle-list', cullMode, frontFace: 'cw' },
192
+ /*
193
+ * **The raster offset the other backend has always had, and this one never did.**
194
+ *
195
+ * `shadowMap.ts` sets `gl.polygonOffset(1.1, 4)` for its directional pass and calls it
196
+ * load-bearing in its own comment: *"a small slope-aware raster offset separates the stored
197
+ * caster from its receiver"*. This pipeline declared a format, a write and a compare, and
198
+ * nothing else — so every WebGPU shadow was compared against a depth with no separation at
199
+ * all.
200
+ *
201
+ * **It was measured as minor and it was not.** Adding it moved 2,178 pixels when it was first
202
+ * tried, which read as a small thing worth taking on its own terms. What that measurement
203
+ * could not see is that the pass was, at the time, storing the *far* side of every caster
204
+ * because its winding was inverted — and a caster's own thickness is an enormous accidental
205
+ * bias. Correcting the winding removed the masking, and what it exposed is what a shadow pass
206
+ * with no offset does: acne on ground in shadow, and self-shadowing near geometry that reads
207
+ * as a shadow with nothing casting it.
208
+ *
209
+ * **`depthBias` is not the same quantity on the two backends and that is stated rather than
210
+ * hidden.** WebGL2's `units` are multiples of the smallest resolvable difference of a
211
+ * `DEPTH_COMPONENT24` map; WebGPU applies the constant against a `depth32float`, where the
212
+ * specification scales it by the exponent of the primitive's maximum depth. The slope term is
213
+ * the same quantity in both. So these are the other backend's numbers as a starting point and
214
+ * the constant is the half to distrust — which is why `shadows.html` exists.
215
+ *
216
+ * **What would make it wrong** is over-biasing, which detaches a shadow from its caster: the
217
+ * failure `shadowMap.ts` names as the reason it culls back faces rather than front. Too small
218
+ * shows as acne, too large as a floating shadow, and only one of them looks like a bug.
219
+ */
220
+ depthStencil: {
221
+ format: SHADOW_FORMAT,
222
+ depthWriteEnabled: true,
223
+ depthCompare: 'less',
224
+ depthBias: 4,
225
+ depthBiasSlopeScale: 1.1,
226
+ },
227
+ }));
228
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * A device, a configured canvas, and loss adapted to the shape the renderer already handles.
3
+ *
4
+ * Everything WebGPU-specific about *owning* a drawing surface lives here, so that
5
+ * `webgpu/renderer.ts` is about drawing and this is about the context it draws into. The
6
+ * split matters because these two fail for unrelated reasons: a device is lost by a driver
7
+ * reset the page did not cause, and a frame is wrong because of something the frame did.
8
+ */
9
+ /** What the renderer needs from the canvas it draws into, with the API's shape absorbed. */
10
+ export interface GpuSurface {
11
+ readonly device: GPUDevice;
12
+ readonly context: GPUCanvasContext;
13
+ /**
14
+ * The canvas being drawn into.
15
+ *
16
+ * Carried because the renderer's public measurements are questions about it and nothing
17
+ * else: `cssWidth` and `cssHeight` are its CSS box, `aspect` its drawing buffer. WebGL2
18
+ * answers them off `this.canvas` and a second backend has to answer the same questions
19
+ * from somewhere.
20
+ */
21
+ readonly canvas: HTMLCanvasElement;
22
+ /** The swap chain's format, which every render pipeline has to be built against. */
23
+ readonly format: GPUTextureFormat;
24
+ /** Whether the device has gone. Read per frame; never throws. */
25
+ readonly lost: boolean;
26
+ /** Called when the device is lost. Fires immediately if it already has been. */
27
+ onLost(listener: () => void): void;
28
+ /** Resize the drawing buffer and reconfigure the swap chain. */
29
+ configure(width: number, height: number): void;
30
+ /** Tear down on purpose. A disposed surface never reports a loss. */
31
+ dispose(): void;
32
+ }
33
+ /**
34
+ * Take a canvas and a device, and hand back the surface the renderer draws into.
35
+ *
36
+ * **Device loss is a promise, and that is a different shape from the event WebGL gives.**
37
+ * `webglcontextlost` fires once and is missed by anybody not already listening;
38
+ * `device.lost` is a promise that resolves once, never rejects, and stays resolved. A
39
+ * renderer constructed after the loss therefore gets no event at all from the WebGL-shaped
40
+ * mental model, and would draw into a dead device forever without ever being told.
41
+ *
42
+ * So the resolution is latched here and `onLost` fires immediately for a listener that
43
+ * arrives late. Adapting it once, at the boundary, is why no call site has to know that the
44
+ * two APIs disagree about what a failure looks like — the same argument `contextLoss.ts`
45
+ * makes for owning the WebGL half rather than letting a game listen for it.
46
+ *
47
+ * **Disposal is not loss.** Tearing a surface down calls `destroy()`, which resolves
48
+ * `device.lost` exactly as a driver reset would. Reporting that to listeners would tell a
49
+ * consumer its GPU had failed every time it unmounted a canvas on purpose, so a disposed
50
+ * surface stays silent.
51
+ */
52
+ export declare function createGpuSurface(canvas: HTMLCanvasElement, device: GPUDevice): GpuSurface;