@aura3d/rendering 1.0.6

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 (1433) hide show
  1. package/README.md +18 -0
  2. package/dist/ArchitecturalLightingFixtures.d.ts +40 -0
  3. package/dist/ArchitecturalLightingFixtures.d.ts.map +1 -0
  4. package/dist/ArchitecturalLightingFixtures.js +171 -0
  5. package/dist/ArchitecturalLightingFixtures.js.map +1 -0
  6. package/dist/ArchitecturalMaterialCatalog.d.ts +30 -0
  7. package/dist/ArchitecturalMaterialCatalog.d.ts.map +1 -0
  8. package/dist/ArchitecturalMaterialCatalog.js +90 -0
  9. package/dist/ArchitecturalMaterialCatalog.js.map +1 -0
  10. package/dist/ArchitecturalMeasurementFixtures.d.ts +30 -0
  11. package/dist/ArchitecturalMeasurementFixtures.d.ts.map +1 -0
  12. package/dist/ArchitecturalMeasurementFixtures.js +115 -0
  13. package/dist/ArchitecturalMeasurementFixtures.js.map +1 -0
  14. package/dist/BRDFLut.d.ts +13 -0
  15. package/dist/BRDFLut.d.ts.map +1 -0
  16. package/dist/BRDFLut.js +34 -0
  17. package/dist/BRDFLut.js.map +1 -0
  18. package/dist/CameraFraming.d.ts +31 -0
  19. package/dist/CameraFraming.d.ts.map +1 -0
  20. package/dist/CameraFraming.js +143 -0
  21. package/dist/CameraFraming.js.map +1 -0
  22. package/dist/CanonicalSceneFixtures.d.ts +13 -0
  23. package/dist/CanonicalSceneFixtures.d.ts.map +1 -0
  24. package/dist/CanonicalSceneFixtures.js +78 -0
  25. package/dist/CanonicalSceneFixtures.js.map +1 -0
  26. package/dist/CascadedShadowMaps.d.ts +121 -0
  27. package/dist/CascadedShadowMaps.d.ts.map +1 -0
  28. package/dist/CascadedShadowMaps.js +315 -0
  29. package/dist/CascadedShadowMaps.js.map +1 -0
  30. package/dist/ColorManagement.d.ts +33 -0
  31. package/dist/ColorManagement.d.ts.map +1 -0
  32. package/dist/ColorManagement.js +71 -0
  33. package/dist/ColorManagement.js.map +1 -0
  34. package/dist/CullingFixtures.d.ts +70 -0
  35. package/dist/CullingFixtures.d.ts.map +1 -0
  36. package/dist/CullingFixtures.js +191 -0
  37. package/dist/CullingFixtures.js.map +1 -0
  38. package/dist/DecalGeometry.d.ts +3 -0
  39. package/dist/DecalGeometry.d.ts.map +1 -0
  40. package/dist/DecalGeometry.js +2 -0
  41. package/dist/DecalGeometry.js.map +1 -0
  42. package/dist/DepthPass.d.ts +23 -0
  43. package/dist/DepthPass.d.ts.map +1 -0
  44. package/dist/DepthPass.js +99 -0
  45. package/dist/DepthPass.js.map +1 -0
  46. package/dist/EnvironmentBackgroundPass.d.ts +27 -0
  47. package/dist/EnvironmentBackgroundPass.d.ts.map +1 -0
  48. package/dist/EnvironmentBackgroundPass.js +167 -0
  49. package/dist/EnvironmentBackgroundPass.js.map +1 -0
  50. package/dist/EnvironmentBackgroundResources.d.ts +31 -0
  51. package/dist/EnvironmentBackgroundResources.d.ts.map +1 -0
  52. package/dist/EnvironmentBackgroundResources.js +237 -0
  53. package/dist/EnvironmentBackgroundResources.js.map +1 -0
  54. package/dist/EnvironmentLighting.d.ts +10 -0
  55. package/dist/EnvironmentLighting.d.ts.map +1 -0
  56. package/dist/EnvironmentLighting.js +64 -0
  57. package/dist/EnvironmentLighting.js.map +1 -0
  58. package/dist/EnvironmentMapResources.d.ts +98 -0
  59. package/dist/EnvironmentMapResources.d.ts.map +1 -0
  60. package/dist/EnvironmentMapResources.js +794 -0
  61. package/dist/EnvironmentMapResources.js.map +1 -0
  62. package/dist/EnvironmentPipeline.d.ts +21 -0
  63. package/dist/EnvironmentPipeline.d.ts.map +1 -0
  64. package/dist/EnvironmentPipeline.js +43 -0
  65. package/dist/EnvironmentPipeline.js.map +1 -0
  66. package/dist/EnvironmentPlatform.d.ts +185 -0
  67. package/dist/EnvironmentPlatform.d.ts.map +1 -0
  68. package/dist/EnvironmentPlatform.js +922 -0
  69. package/dist/EnvironmentPlatform.js.map +1 -0
  70. package/dist/EnvironmentPreset.d.ts +35 -0
  71. package/dist/EnvironmentPreset.d.ts.map +1 -0
  72. package/dist/EnvironmentPreset.js +96 -0
  73. package/dist/EnvironmentPreset.js.map +1 -0
  74. package/dist/Exposure.d.ts +19 -0
  75. package/dist/Exposure.d.ts.map +1 -0
  76. package/dist/Exposure.js +34 -0
  77. package/dist/Exposure.js.map +1 -0
  78. package/dist/ExternalParityRenderPreset.d.ts +149 -0
  79. package/dist/ExternalParityRenderPreset.d.ts.map +1 -0
  80. package/dist/ExternalParityRenderPreset.js +519 -0
  81. package/dist/ExternalParityRenderPreset.js.map +1 -0
  82. package/dist/ForwardPass.d.ts +122 -0
  83. package/dist/ForwardPass.d.ts.map +1 -0
  84. package/dist/ForwardPass.js +1352 -0
  85. package/dist/ForwardPass.js.map +1 -0
  86. package/dist/FrameVisualMetrics.d.ts +60 -0
  87. package/dist/FrameVisualMetrics.d.ts.map +1 -0
  88. package/dist/FrameVisualMetrics.js +146 -0
  89. package/dist/FrameVisualMetrics.js.map +1 -0
  90. package/dist/Geometry.d.ts +50 -0
  91. package/dist/Geometry.d.ts.map +1 -0
  92. package/dist/Geometry.js +385 -0
  93. package/dist/Geometry.js.map +1 -0
  94. package/dist/GeometryPrimitives.d.ts +3 -0
  95. package/dist/GeometryPrimitives.d.ts.map +1 -0
  96. package/dist/GeometryPrimitives.js +2 -0
  97. package/dist/GeometryPrimitives.js.map +1 -0
  98. package/dist/HDRRenderPipeline.d.ts +27 -0
  99. package/dist/HDRRenderPipeline.d.ts.map +1 -0
  100. package/dist/HDRRenderPipeline.js +67 -0
  101. package/dist/HDRRenderPipeline.js.map +1 -0
  102. package/dist/IBL.d.ts +37 -0
  103. package/dist/IBL.d.ts.map +1 -0
  104. package/dist/IBL.js +48 -0
  105. package/dist/IBL.js.map +1 -0
  106. package/dist/IndexBuffer.d.ts +15 -0
  107. package/dist/IndexBuffer.d.ts.map +1 -0
  108. package/dist/IndexBuffer.js +51 -0
  109. package/dist/IndexBuffer.js.map +1 -0
  110. package/dist/InstancedPBRMaterial.d.ts +33 -0
  111. package/dist/InstancedPBRMaterial.d.ts.map +1 -0
  112. package/dist/InstancedPBRMaterial.js +147 -0
  113. package/dist/InstancedPBRMaterial.js.map +1 -0
  114. package/dist/InstancedUnlitMaterial.d.ts +11 -0
  115. package/dist/InstancedUnlitMaterial.d.ts.map +1 -0
  116. package/dist/InstancedUnlitMaterial.js +50 -0
  117. package/dist/InstancedUnlitMaterial.js.map +1 -0
  118. package/dist/Instancing.d.ts +7 -0
  119. package/dist/Instancing.d.ts.map +1 -0
  120. package/dist/Instancing.js +14 -0
  121. package/dist/Instancing.js.map +1 -0
  122. package/dist/LightCollector.d.ts +24 -0
  123. package/dist/LightCollector.d.ts.map +1 -0
  124. package/dist/LightCollector.js +56 -0
  125. package/dist/LightCollector.js.map +1 -0
  126. package/dist/LightUniforms.d.ts +14 -0
  127. package/dist/LightUniforms.d.ts.map +1 -0
  128. package/dist/LightUniforms.js +37 -0
  129. package/dist/LightUniforms.js.map +1 -0
  130. package/dist/LightingDebug.d.ts +13 -0
  131. package/dist/LightingDebug.d.ts.map +1 -0
  132. package/dist/LightingDebug.js +69 -0
  133. package/dist/LightingDebug.js.map +1 -0
  134. package/dist/LightingDefaults.d.ts +13 -0
  135. package/dist/LightingDefaults.d.ts.map +1 -0
  136. package/dist/LightingDefaults.js +64 -0
  137. package/dist/LightingDefaults.js.map +1 -0
  138. package/dist/LightingRig.d.ts +53 -0
  139. package/dist/LightingRig.d.ts.map +1 -0
  140. package/dist/LightingRig.js +197 -0
  141. package/dist/LightingRig.js.map +1 -0
  142. package/dist/LineGeometry.d.ts +3 -0
  143. package/dist/LineGeometry.d.ts.map +1 -0
  144. package/dist/LineGeometry.js +2 -0
  145. package/dist/LineGeometry.js.map +1 -0
  146. package/dist/Material.d.ts +77 -0
  147. package/dist/Material.d.ts.map +1 -0
  148. package/dist/Material.js +137 -0
  149. package/dist/Material.js.map +1 -0
  150. package/dist/MaterialBinding.d.ts +17 -0
  151. package/dist/MaterialBinding.d.ts.map +1 -0
  152. package/dist/MaterialBinding.js +119 -0
  153. package/dist/MaterialBinding.js.map +1 -0
  154. package/dist/MaterialInstance.d.ts +16 -0
  155. package/dist/MaterialInstance.d.ts.map +1 -0
  156. package/dist/MaterialInstance.js +53 -0
  157. package/dist/MaterialInstance.js.map +1 -0
  158. package/dist/MaterialPresets.d.ts +31 -0
  159. package/dist/MaterialPresets.d.ts.map +1 -0
  160. package/dist/MaterialPresets.js +219 -0
  161. package/dist/MaterialPresets.js.map +1 -0
  162. package/dist/MorphTarget.d.ts +10 -0
  163. package/dist/MorphTarget.d.ts.map +1 -0
  164. package/dist/MorphTarget.js +101 -0
  165. package/dist/MorphTarget.js.map +1 -0
  166. package/dist/MorphUnlitMaterial.d.ts +11 -0
  167. package/dist/MorphUnlitMaterial.d.ts.map +1 -0
  168. package/dist/MorphUnlitMaterial.js +45 -0
  169. package/dist/MorphUnlitMaterial.js.map +1 -0
  170. package/dist/NormalMappedPBRMaterial.d.ts +37 -0
  171. package/dist/NormalMappedPBRMaterial.d.ts.map +1 -0
  172. package/dist/NormalMappedPBRMaterial.js +148 -0
  173. package/dist/NormalMappedPBRMaterial.js.map +1 -0
  174. package/dist/OceanFixtures.d.ts +62 -0
  175. package/dist/OceanFixtures.d.ts.map +1 -0
  176. package/dist/OceanFixtures.js +240 -0
  177. package/dist/OceanFixtures.js.map +1 -0
  178. package/dist/PBRLightingDefaults.d.ts +4 -0
  179. package/dist/PBRLightingDefaults.d.ts.map +1 -0
  180. package/dist/PBRLightingDefaults.js +10 -0
  181. package/dist/PBRLightingDefaults.js.map +1 -0
  182. package/dist/PBRMaterial.d.ts +84 -0
  183. package/dist/PBRMaterial.d.ts.map +1 -0
  184. package/dist/PBRMaterial.js +349 -0
  185. package/dist/PBRMaterial.js.map +1 -0
  186. package/dist/PMREM.d.ts +26 -0
  187. package/dist/PMREM.d.ts.map +1 -0
  188. package/dist/PMREM.js +26 -0
  189. package/dist/PMREM.js.map +1 -0
  190. package/dist/PbrReference.d.ts +153 -0
  191. package/dist/PbrReference.d.ts.map +1 -0
  192. package/dist/PbrReference.js +500 -0
  193. package/dist/PbrReference.js.map +1 -0
  194. package/dist/PostProcessPass.d.ts +439 -0
  195. package/dist/PostProcessPass.d.ts.map +1 -0
  196. package/dist/PostProcessPass.js +1834 -0
  197. package/dist/PostProcessPass.js.map +1 -0
  198. package/dist/ProceduralTextureFixtures.d.ts +27 -0
  199. package/dist/ProceduralTextureFixtures.d.ts.map +1 -0
  200. package/dist/ProceduralTextureFixtures.js +336 -0
  201. package/dist/ProceduralTextureFixtures.js.map +1 -0
  202. package/dist/ProductTurntableFixtures.d.ts +96 -0
  203. package/dist/ProductTurntableFixtures.d.ts.map +1 -0
  204. package/dist/ProductTurntableFixtures.js +559 -0
  205. package/dist/ProductTurntableFixtures.js.map +1 -0
  206. package/dist/Raycaster.d.ts +14 -0
  207. package/dist/Raycaster.d.ts.map +1 -0
  208. package/dist/Raycaster.js +10 -0
  209. package/dist/Raycaster.js.map +1 -0
  210. package/dist/ReflectionProbe.d.ts +8 -0
  211. package/dist/ReflectionProbe.d.ts.map +1 -0
  212. package/dist/ReflectionProbe.js +10 -0
  213. package/dist/ReflectionProbe.js.map +1 -0
  214. package/dist/ReflectionSurfaces.d.ts +35 -0
  215. package/dist/ReflectionSurfaces.d.ts.map +1 -0
  216. package/dist/ReflectionSurfaces.js +155 -0
  217. package/dist/ReflectionSurfaces.js.map +1 -0
  218. package/dist/RenderBackend.d.ts +14 -0
  219. package/dist/RenderBackend.d.ts.map +1 -0
  220. package/dist/RenderBackend.js +33 -0
  221. package/dist/RenderBackend.js.map +1 -0
  222. package/dist/RenderDebugViews.d.ts +26 -0
  223. package/dist/RenderDebugViews.d.ts.map +1 -0
  224. package/dist/RenderDebugViews.js +97 -0
  225. package/dist/RenderDebugViews.js.map +1 -0
  226. package/dist/RenderDevice.d.ts +280 -0
  227. package/dist/RenderDevice.d.ts.map +1 -0
  228. package/dist/RenderDevice.js +561 -0
  229. package/dist/RenderDevice.js.map +1 -0
  230. package/dist/RenderGraph.d.ts +22 -0
  231. package/dist/RenderGraph.d.ts.map +1 -0
  232. package/dist/RenderGraph.js +159 -0
  233. package/dist/RenderGraph.js.map +1 -0
  234. package/dist/RenderPass.d.ts +23 -0
  235. package/dist/RenderPass.d.ts.map +1 -0
  236. package/dist/RenderPass.js +14 -0
  237. package/dist/RenderPass.js.map +1 -0
  238. package/dist/RenderPipeline.d.ts +39 -0
  239. package/dist/RenderPipeline.d.ts.map +1 -0
  240. package/dist/RenderPipeline.js +67 -0
  241. package/dist/RenderPipeline.js.map +1 -0
  242. package/dist/RenderQueue.d.ts +3 -0
  243. package/dist/RenderQueue.d.ts.map +1 -0
  244. package/dist/RenderQueue.js +2 -0
  245. package/dist/RenderQueue.js.map +1 -0
  246. package/dist/RenderState.d.ts +3 -0
  247. package/dist/RenderState.d.ts.map +1 -0
  248. package/dist/RenderState.js +2 -0
  249. package/dist/RenderState.js.map +1 -0
  250. package/dist/Renderer.d.ts +265 -0
  251. package/dist/Renderer.d.ts.map +1 -0
  252. package/dist/Renderer.js +2094 -0
  253. package/dist/Renderer.js.map +1 -0
  254. package/dist/RendererDebugOverlay.d.ts +20 -0
  255. package/dist/RendererDebugOverlay.d.ts.map +1 -0
  256. package/dist/RendererDebugOverlay.js +54 -0
  257. package/dist/RendererDebugOverlay.js.map +1 -0
  258. package/dist/RendererFeatureGates.d.ts +17 -0
  259. package/dist/RendererFeatureGates.d.ts.map +1 -0
  260. package/dist/RendererFeatureGates.js +92 -0
  261. package/dist/RendererFeatureGates.js.map +1 -0
  262. package/dist/RendererPostprocessPlan.d.ts +59 -0
  263. package/dist/RendererPostprocessPlan.d.ts.map +1 -0
  264. package/dist/RendererPostprocessPlan.js +155 -0
  265. package/dist/RendererPostprocessPlan.js.map +1 -0
  266. package/dist/RendererTiming.d.ts +53 -0
  267. package/dist/RendererTiming.d.ts.map +1 -0
  268. package/dist/RendererTiming.js +186 -0
  269. package/dist/RendererTiming.js.map +1 -0
  270. package/dist/RendererVisualPipelineReport.d.ts +224 -0
  271. package/dist/RendererVisualPipelineReport.d.ts.map +1 -0
  272. package/dist/RendererVisualPipelineReport.js +499 -0
  273. package/dist/RendererVisualPipelineReport.js.map +1 -0
  274. package/dist/ResourceLifecycle.d.ts +8 -0
  275. package/dist/ResourceLifecycle.d.ts.map +1 -0
  276. package/dist/ResourceLifecycle.js +18 -0
  277. package/dist/ResourceLifecycle.js.map +1 -0
  278. package/dist/Sampler.d.ts +20 -0
  279. package/dist/Sampler.d.ts.map +1 -0
  280. package/dist/Sampler.js +19 -0
  281. package/dist/Sampler.js.map +1 -0
  282. package/dist/SceneOptimization.d.ts +127 -0
  283. package/dist/SceneOptimization.d.ts.map +1 -0
  284. package/dist/SceneOptimization.js +342 -0
  285. package/dist/SceneOptimization.js.map +1 -0
  286. package/dist/ShaderChunks.d.ts +8 -0
  287. package/dist/ShaderChunks.d.ts.map +1 -0
  288. package/dist/ShaderChunks.js +386 -0
  289. package/dist/ShaderChunks.js.map +1 -0
  290. package/dist/ShaderLibrary.d.ts +63 -0
  291. package/dist/ShaderLibrary.d.ts.map +1 -0
  292. package/dist/ShaderLibrary.js +2707 -0
  293. package/dist/ShaderLibrary.js.map +1 -0
  294. package/dist/ShaderModule.d.ts +14 -0
  295. package/dist/ShaderModule.d.ts.map +1 -0
  296. package/dist/ShaderModule.js +33 -0
  297. package/dist/ShaderModule.js.map +1 -0
  298. package/dist/ShaderPreprocessor.d.ts +19 -0
  299. package/dist/ShaderPreprocessor.d.ts.map +1 -0
  300. package/dist/ShaderPreprocessor.js +212 -0
  301. package/dist/ShaderPreprocessor.js.map +1 -0
  302. package/dist/ShaderReflection.d.ts +23 -0
  303. package/dist/ShaderReflection.d.ts.map +1 -0
  304. package/dist/ShaderReflection.js +134 -0
  305. package/dist/ShaderReflection.js.map +1 -0
  306. package/dist/ShadowMap.d.ts +58 -0
  307. package/dist/ShadowMap.d.ts.map +1 -0
  308. package/dist/ShadowMap.js +183 -0
  309. package/dist/ShadowMap.js.map +1 -0
  310. package/dist/ShadowPass.d.ts +44 -0
  311. package/dist/ShadowPass.d.ts.map +1 -0
  312. package/dist/ShadowPass.js +162 -0
  313. package/dist/ShadowPass.js.map +1 -0
  314. package/dist/ShadowProjection.d.ts +15 -0
  315. package/dist/ShadowProjection.d.ts.map +1 -0
  316. package/dist/ShadowProjection.js +90 -0
  317. package/dist/ShadowProjection.js.map +1 -0
  318. package/dist/SkinnedLitMaterial.d.ts +63 -0
  319. package/dist/SkinnedLitMaterial.d.ts.map +1 -0
  320. package/dist/SkinnedLitMaterial.js +296 -0
  321. package/dist/SkinnedLitMaterial.js.map +1 -0
  322. package/dist/SkinnedUnlitMaterial.d.ts +13 -0
  323. package/dist/SkinnedUnlitMaterial.d.ts.map +1 -0
  324. package/dist/SkinnedUnlitMaterial.js +52 -0
  325. package/dist/SkinnedUnlitMaterial.js.map +1 -0
  326. package/dist/SkinningBounds.d.ts +10 -0
  327. package/dist/SkinningBounds.d.ts.map +1 -0
  328. package/dist/SkinningBounds.js +107 -0
  329. package/dist/SkinningBounds.js.map +1 -0
  330. package/dist/SpaceEnvironmentFixtures.d.ts +59 -0
  331. package/dist/SpaceEnvironmentFixtures.d.ts.map +1 -0
  332. package/dist/SpaceEnvironmentFixtures.js +132 -0
  333. package/dist/SpaceEnvironmentFixtures.js.map +1 -0
  334. package/dist/SpriteGeometry.d.ts +3 -0
  335. package/dist/SpriteGeometry.d.ts.map +1 -0
  336. package/dist/SpriteGeometry.js +21 -0
  337. package/dist/SpriteGeometry.js.map +1 -0
  338. package/dist/StereoCameraRig.d.ts +34 -0
  339. package/dist/StereoCameraRig.d.ts.map +1 -0
  340. package/dist/StereoCameraRig.js +79 -0
  341. package/dist/StereoCameraRig.js.map +1 -0
  342. package/dist/StereoEffects.d.ts +90 -0
  343. package/dist/StereoEffects.d.ts.map +1 -0
  344. package/dist/StereoEffects.js +171 -0
  345. package/dist/StereoEffects.js.map +1 -0
  346. package/dist/TerrainFixtures.d.ts +36 -0
  347. package/dist/TerrainFixtures.d.ts.map +1 -0
  348. package/dist/TerrainFixtures.js +143 -0
  349. package/dist/TerrainFixtures.js.map +1 -0
  350. package/dist/Texture.d.ts +64 -0
  351. package/dist/Texture.d.ts.map +1 -0
  352. package/dist/Texture.js +257 -0
  353. package/dist/Texture.js.map +1 -0
  354. package/dist/TextureBinding.d.ts +38 -0
  355. package/dist/TextureBinding.d.ts.map +1 -0
  356. package/dist/TextureBinding.js +66 -0
  357. package/dist/TextureBinding.js.map +1 -0
  358. package/dist/TexturedPBRMaterial.d.ts +206 -0
  359. package/dist/TexturedPBRMaterial.d.ts.map +1 -0
  360. package/dist/TexturedPBRMaterial.js +842 -0
  361. package/dist/TexturedPBRMaterial.js.map +1 -0
  362. package/dist/TexturedUnlitMaterial.d.ts +19 -0
  363. package/dist/TexturedUnlitMaterial.d.ts.map +1 -0
  364. package/dist/TexturedUnlitMaterial.js +52 -0
  365. package/dist/TexturedUnlitMaterial.js.map +1 -0
  366. package/dist/ToneMapping.d.ts +19 -0
  367. package/dist/ToneMapping.d.ts.map +1 -0
  368. package/dist/ToneMapping.js +53 -0
  369. package/dist/ToneMapping.js.map +1 -0
  370. package/dist/UniformBinder.d.ts +7 -0
  371. package/dist/UniformBinder.d.ts.map +1 -0
  372. package/dist/UniformBinder.js +14 -0
  373. package/dist/UniformBinder.js.map +1 -0
  374. package/dist/UniformLayout.d.ts +19 -0
  375. package/dist/UniformLayout.d.ts.map +1 -0
  376. package/dist/UniformLayout.js +107 -0
  377. package/dist/UniformLayout.js.map +1 -0
  378. package/dist/UnlitMaterial.d.ts +16 -0
  379. package/dist/UnlitMaterial.d.ts.map +1 -0
  380. package/dist/UnlitMaterial.js +60 -0
  381. package/dist/UnlitMaterial.js.map +1 -0
  382. package/dist/VegetationFixtures.d.ts +68 -0
  383. package/dist/VegetationFixtures.d.ts.map +1 -0
  384. package/dist/VegetationFixtures.js +241 -0
  385. package/dist/VegetationFixtures.js.map +1 -0
  386. package/dist/VertexBuffer.d.ts +29 -0
  387. package/dist/VertexBuffer.d.ts.map +1 -0
  388. package/dist/VertexBuffer.js +106 -0
  389. package/dist/VertexBuffer.js.map +1 -0
  390. package/dist/VertexFormat.d.ts +36 -0
  391. package/dist/VertexFormat.d.ts.map +1 -0
  392. package/dist/VertexFormat.js +127 -0
  393. package/dist/VertexFormat.js.map +1 -0
  394. package/dist/VoxelWorldFixtures.d.ts +54 -0
  395. package/dist/VoxelWorldFixtures.d.ts.map +1 -0
  396. package/dist/VoxelWorldFixtures.js +186 -0
  397. package/dist/VoxelWorldFixtures.js.map +1 -0
  398. package/dist/WeatherFixtures.d.ts +46 -0
  399. package/dist/WeatherFixtures.d.ts.map +1 -0
  400. package/dist/WeatherFixtures.js +142 -0
  401. package/dist/WeatherFixtures.js.map +1 -0
  402. package/dist/WebGL2Device.d.ts +137 -0
  403. package/dist/WebGL2Device.d.ts.map +1 -0
  404. package/dist/WebGL2Device.js +2107 -0
  405. package/dist/WebGL2Device.js.map +1 -0
  406. package/dist/WebGL2StateCache.d.ts +89 -0
  407. package/dist/WebGL2StateCache.d.ts.map +1 -0
  408. package/dist/WebGL2StateCache.js +265 -0
  409. package/dist/WebGL2StateCache.js.map +1 -0
  410. package/dist/WebGPUDevice.d.ts +287 -0
  411. package/dist/WebGPUDevice.d.ts.map +1 -0
  412. package/dist/WebGPUDevice.js +2403 -0
  413. package/dist/WebGPUDevice.js.map +1 -0
  414. package/dist/WebGPURenderToTextureProof.d.ts +29 -0
  415. package/dist/WebGPURenderToTextureProof.d.ts.map +1 -0
  416. package/dist/WebGPURenderToTextureProof.js +96 -0
  417. package/dist/WebGPURenderToTextureProof.js.map +1 -0
  418. package/dist/advanced-runtime/AdvancedRenderer.d.ts +23 -0
  419. package/dist/advanced-runtime/AdvancedRenderer.d.ts.map +1 -0
  420. package/dist/advanced-runtime/AdvancedRenderer.js +45 -0
  421. package/dist/advanced-runtime/AdvancedRenderer.js.map +1 -0
  422. package/dist/advanced-runtime/index.d.ts +10 -0
  423. package/dist/advanced-runtime/index.d.ts.map +1 -0
  424. package/dist/advanced-runtime/index.js +9 -0
  425. package/dist/advanced-runtime/index.js.map +1 -0
  426. package/dist/cinematic/BloomPass.d.ts +10 -0
  427. package/dist/cinematic/BloomPass.d.ts.map +1 -0
  428. package/dist/cinematic/BloomPass.js +18 -0
  429. package/dist/cinematic/BloomPass.js.map +1 -0
  430. package/dist/cinematic/CinematicDepthComposition.d.ts +12 -0
  431. package/dist/cinematic/CinematicDepthComposition.d.ts.map +1 -0
  432. package/dist/cinematic/CinematicDepthComposition.js +22 -0
  433. package/dist/cinematic/CinematicDepthComposition.js.map +1 -0
  434. package/dist/cinematic/CinematicEvidence.d.ts +43 -0
  435. package/dist/cinematic/CinematicEvidence.d.ts.map +1 -0
  436. package/dist/cinematic/CinematicEvidence.js +55 -0
  437. package/dist/cinematic/CinematicEvidence.js.map +1 -0
  438. package/dist/cinematic/CinematicLightingRig.d.ts +32 -0
  439. package/dist/cinematic/CinematicLightingRig.d.ts.map +1 -0
  440. package/dist/cinematic/CinematicLightingRig.js +90 -0
  441. package/dist/cinematic/CinematicLightingRig.js.map +1 -0
  442. package/dist/cinematic/CinematicMaterialPresets.d.ts +16 -0
  443. package/dist/cinematic/CinematicMaterialPresets.d.ts.map +1 -0
  444. package/dist/cinematic/CinematicMaterialPresets.js +114 -0
  445. package/dist/cinematic/CinematicMaterialPresets.js.map +1 -0
  446. package/dist/cinematic/CinematicPostProcess.d.ts +25 -0
  447. package/dist/cinematic/CinematicPostProcess.d.ts.map +1 -0
  448. package/dist/cinematic/CinematicPostProcess.js +64 -0
  449. package/dist/cinematic/CinematicPostProcess.js.map +1 -0
  450. package/dist/cinematic/DepthHazePass.d.ts +12 -0
  451. package/dist/cinematic/DepthHazePass.d.ts.map +1 -0
  452. package/dist/cinematic/DepthHazePass.js +20 -0
  453. package/dist/cinematic/DepthHazePass.js.map +1 -0
  454. package/dist/cinematic/EmissivePracticalLightSystem.d.ts +18 -0
  455. package/dist/cinematic/EmissivePracticalLightSystem.d.ts.map +1 -0
  456. package/dist/cinematic/EmissivePracticalLightSystem.js +25 -0
  457. package/dist/cinematic/EmissivePracticalLightSystem.js.map +1 -0
  458. package/dist/cinematic/FilmGrainPass.d.ts +9 -0
  459. package/dist/cinematic/FilmGrainPass.d.ts.map +1 -0
  460. package/dist/cinematic/FilmGrainPass.js +17 -0
  461. package/dist/cinematic/FilmGrainPass.js.map +1 -0
  462. package/dist/cinematic/FogVolumeSystem.d.ts +12 -0
  463. package/dist/cinematic/FogVolumeSystem.d.ts.map +1 -0
  464. package/dist/cinematic/FogVolumeSystem.js +20 -0
  465. package/dist/cinematic/FogVolumeSystem.js.map +1 -0
  466. package/dist/cinematic/GlowCardSystem.d.ts +17 -0
  467. package/dist/cinematic/GlowCardSystem.d.ts.map +1 -0
  468. package/dist/cinematic/GlowCardSystem.js +28 -0
  469. package/dist/cinematic/GlowCardSystem.js.map +1 -0
  470. package/dist/cinematic/RainParticleSystem.d.ts +22 -0
  471. package/dist/cinematic/RainParticleSystem.d.ts.map +1 -0
  472. package/dist/cinematic/RainParticleSystem.js +114 -0
  473. package/dist/cinematic/RainParticleSystem.js.map +1 -0
  474. package/dist/cinematic/VignettePass.d.ts +10 -0
  475. package/dist/cinematic/VignettePass.d.ts.map +1 -0
  476. package/dist/cinematic/VignettePass.js +17 -0
  477. package/dist/cinematic/VignettePass.js.map +1 -0
  478. package/dist/cinematic/WetReflectionApproximation.d.ts +13 -0
  479. package/dist/cinematic/WetReflectionApproximation.d.ts.map +1 -0
  480. package/dist/cinematic/WetReflectionApproximation.js +18 -0
  481. package/dist/cinematic/WetReflectionApproximation.js.map +1 -0
  482. package/dist/cinematic/index.d.ts +15 -0
  483. package/dist/cinematic/index.d.ts.map +1 -0
  484. package/dist/cinematic/index.js +15 -0
  485. package/dist/cinematic/index.js.map +1 -0
  486. package/dist/effects/CollisionModule.d.ts +15 -0
  487. package/dist/effects/CollisionModule.d.ts.map +1 -0
  488. package/dist/effects/CollisionModule.js +46 -0
  489. package/dist/effects/CollisionModule.js.map +1 -0
  490. package/dist/effects/ColorModule.d.ts +15 -0
  491. package/dist/effects/ColorModule.d.ts.map +1 -0
  492. package/dist/effects/ColorModule.js +45 -0
  493. package/dist/effects/ColorModule.js.map +1 -0
  494. package/dist/effects/ForceModule.d.ts +11 -0
  495. package/dist/effects/ForceModule.d.ts.map +1 -0
  496. package/dist/effects/ForceModule.js +17 -0
  497. package/dist/effects/ForceModule.js.map +1 -0
  498. package/dist/effects/GPUParticleBackend.d.ts +153 -0
  499. package/dist/effects/GPUParticleBackend.d.ts.map +1 -0
  500. package/dist/effects/GPUParticleBackend.js +397 -0
  501. package/dist/effects/GPUParticleBackend.js.map +1 -0
  502. package/dist/effects/Particle.d.ts +49 -0
  503. package/dist/effects/Particle.d.ts.map +1 -0
  504. package/dist/effects/Particle.js +56 -0
  505. package/dist/effects/Particle.js.map +1 -0
  506. package/dist/effects/ParticleDiagnostics.d.ts +58 -0
  507. package/dist/effects/ParticleDiagnostics.d.ts.map +1 -0
  508. package/dist/effects/ParticleDiagnostics.js +145 -0
  509. package/dist/effects/ParticleDiagnostics.js.map +1 -0
  510. package/dist/effects/ParticleEffectPresets.d.ts +8 -0
  511. package/dist/effects/ParticleEffectPresets.d.ts.map +1 -0
  512. package/dist/effects/ParticleEffectPresets.js +137 -0
  513. package/dist/effects/ParticleEffectPresets.js.map +1 -0
  514. package/dist/effects/ParticleEmitter.d.ts +87 -0
  515. package/dist/effects/ParticleEmitter.d.ts.map +1 -0
  516. package/dist/effects/ParticleEmitter.js +254 -0
  517. package/dist/effects/ParticleEmitter.js.map +1 -0
  518. package/dist/effects/ParticleModule.d.ts +15 -0
  519. package/dist/effects/ParticleModule.d.ts.map +1 -0
  520. package/dist/effects/ParticleModule.js +6 -0
  521. package/dist/effects/ParticleModule.js.map +1 -0
  522. package/dist/effects/ParticleRenderPass.d.ts +35 -0
  523. package/dist/effects/ParticleRenderPass.d.ts.map +1 -0
  524. package/dist/effects/ParticleRenderPass.js +91 -0
  525. package/dist/effects/ParticleRenderPass.js.map +1 -0
  526. package/dist/effects/ParticleRenderer.d.ts +34 -0
  527. package/dist/effects/ParticleRenderer.d.ts.map +1 -0
  528. package/dist/effects/ParticleRenderer.js +93 -0
  529. package/dist/effects/ParticleRenderer.js.map +1 -0
  530. package/dist/effects/ParticleSystem.d.ts +51 -0
  531. package/dist/effects/ParticleSystem.d.ts.map +1 -0
  532. package/dist/effects/ParticleSystem.js +261 -0
  533. package/dist/effects/ParticleSystem.js.map +1 -0
  534. package/dist/effects/SizeModule.d.ts +14 -0
  535. package/dist/effects/SizeModule.d.ts.map +1 -0
  536. package/dist/effects/SizeModule.js +42 -0
  537. package/dist/effects/SizeModule.js.map +1 -0
  538. package/dist/effects/TrailModule.d.ts +22 -0
  539. package/dist/effects/TrailModule.d.ts.map +1 -0
  540. package/dist/effects/TrailModule.js +50 -0
  541. package/dist/effects/TrailModule.js.map +1 -0
  542. package/dist/effects/VelocityModule.d.ts +15 -0
  543. package/dist/effects/VelocityModule.d.ts.map +1 -0
  544. package/dist/effects/VelocityModule.js +57 -0
  545. package/dist/effects/VelocityModule.js.map +1 -0
  546. package/dist/effects/index.d.ts +16 -0
  547. package/dist/effects/index.d.ts.map +1 -0
  548. package/dist/effects/index.js +16 -0
  549. package/dist/effects/index.js.map +1 -0
  550. package/dist/index.d.ts +260 -0
  551. package/dist/index.d.ts.map +1 -0
  552. package/dist/index.js +155 -0
  553. package/dist/index.js.map +1 -0
  554. package/dist/materials/AlphaSorting.d.ts +8 -0
  555. package/dist/materials/AlphaSorting.d.ts.map +1 -0
  556. package/dist/materials/AlphaSorting.js +26 -0
  557. package/dist/materials/AlphaSorting.js.map +1 -0
  558. package/dist/materials/MaterialExtensions.d.ts +10 -0
  559. package/dist/materials/MaterialExtensions.d.ts.map +1 -0
  560. package/dist/materials/MaterialExtensions.js +20 -0
  561. package/dist/materials/MaterialExtensions.js.map +1 -0
  562. package/dist/materials/PhysicalMaterial.d.ts +36 -0
  563. package/dist/materials/PhysicalMaterial.d.ts.map +1 -0
  564. package/dist/materials/PhysicalMaterial.js +79 -0
  565. package/dist/materials/PhysicalMaterial.js.map +1 -0
  566. package/dist/materials/TransmissionPass.d.ts +16 -0
  567. package/dist/materials/TransmissionPass.d.ts.map +1 -0
  568. package/dist/materials/TransmissionPass.js +30 -0
  569. package/dist/materials/TransmissionPass.js.map +1 -0
  570. package/dist/performance/BVH.d.ts +3 -0
  571. package/dist/performance/BVH.d.ts.map +1 -0
  572. package/dist/performance/BVH.js +2 -0
  573. package/dist/performance/BVH.js.map +1 -0
  574. package/dist/performance/Batcher.d.ts +3 -0
  575. package/dist/performance/Batcher.d.ts.map +1 -0
  576. package/dist/performance/Batcher.js +2 -0
  577. package/dist/performance/Batcher.js.map +1 -0
  578. package/dist/performance/FrustumCuller.d.ts +3 -0
  579. package/dist/performance/FrustumCuller.d.ts.map +1 -0
  580. package/dist/performance/FrustumCuller.js +5 -0
  581. package/dist/performance/FrustumCuller.js.map +1 -0
  582. package/dist/performance/LOD.d.ts +8 -0
  583. package/dist/performance/LOD.d.ts.map +1 -0
  584. package/dist/performance/LOD.js +15 -0
  585. package/dist/performance/LOD.js.map +1 -0
  586. package/dist/performance/Octree.d.ts +7 -0
  587. package/dist/performance/Octree.d.ts.map +1 -0
  588. package/dist/performance/Octree.js +4 -0
  589. package/dist/performance/Octree.js.map +1 -0
  590. package/dist/performance/RenderItemSorting.d.ts +43 -0
  591. package/dist/performance/RenderItemSorting.d.ts.map +1 -0
  592. package/dist/performance/RenderItemSorting.js +111 -0
  593. package/dist/performance/RenderItemSorting.js.map +1 -0
  594. package/dist/performance/RendererStats.d.ts +23 -0
  595. package/dist/performance/RendererStats.d.ts.map +1 -0
  596. package/dist/performance/RendererStats.js +23 -0
  597. package/dist/performance/RendererStats.js.map +1 -0
  598. package/dist/performance/ResourceBudget.d.ts +19 -0
  599. package/dist/performance/ResourceBudget.d.ts.map +1 -0
  600. package/dist/performance/ResourceBudget.js +21 -0
  601. package/dist/performance/ResourceBudget.js.map +1 -0
  602. package/dist/postprocess/BloomPass.d.ts +11 -0
  603. package/dist/postprocess/BloomPass.d.ts.map +1 -0
  604. package/dist/postprocess/BloomPass.js +14 -0
  605. package/dist/postprocess/BloomPass.js.map +1 -0
  606. package/dist/postprocess/CinematicDiagnostics.d.ts +112 -0
  607. package/dist/postprocess/CinematicDiagnostics.d.ts.map +1 -0
  608. package/dist/postprocess/CinematicDiagnostics.js +492 -0
  609. package/dist/postprocess/CinematicDiagnostics.js.map +1 -0
  610. package/dist/postprocess/ColorGradingPass.d.ts +4 -0
  611. package/dist/postprocess/ColorGradingPass.d.ts.map +1 -0
  612. package/dist/postprocess/ColorGradingPass.js +15 -0
  613. package/dist/postprocess/ColorGradingPass.js.map +1 -0
  614. package/dist/postprocess/DepthOfFieldPass.d.ts +3 -0
  615. package/dist/postprocess/DepthOfFieldPass.d.ts.map +1 -0
  616. package/dist/postprocess/DepthOfFieldPass.js +7 -0
  617. package/dist/postprocess/DepthOfFieldPass.js.map +1 -0
  618. package/dist/postprocess/EffectComposer.d.ts +110 -0
  619. package/dist/postprocess/EffectComposer.d.ts.map +1 -0
  620. package/dist/postprocess/EffectComposer.js +249 -0
  621. package/dist/postprocess/EffectComposer.js.map +1 -0
  622. package/dist/postprocess/SSAOPass.d.ts +6 -0
  623. package/dist/postprocess/SSAOPass.d.ts.map +1 -0
  624. package/dist/postprocess/SSAOPass.js +18 -0
  625. package/dist/postprocess/SSAOPass.js.map +1 -0
  626. package/dist/postprocess/index.d.ts +11 -0
  627. package/dist/postprocess/index.d.ts.map +1 -0
  628. package/dist/postprocess/index.js +7 -0
  629. package/dist/postprocess/index.js.map +1 -0
  630. package/dist/production-runtime/AnimationControlsPipeline.d.ts +37 -0
  631. package/dist/production-runtime/AnimationControlsPipeline.d.ts.map +1 -0
  632. package/dist/production-runtime/AnimationControlsPipeline.js +41 -0
  633. package/dist/production-runtime/AnimationControlsPipeline.js.map +1 -0
  634. package/dist/production-runtime/PBRHDRPipeline.d.ts +81 -0
  635. package/dist/production-runtime/PBRHDRPipeline.d.ts.map +1 -0
  636. package/dist/production-runtime/PBRHDRPipeline.js +279 -0
  637. package/dist/production-runtime/PBRHDRPipeline.js.map +1 -0
  638. package/dist/production-runtime/ProductionEffectsPipeline.d.ts +20 -0
  639. package/dist/production-runtime/ProductionEffectsPipeline.d.ts.map +1 -0
  640. package/dist/production-runtime/ProductionEffectsPipeline.js +65 -0
  641. package/dist/production-runtime/ProductionEffectsPipeline.js.map +1 -0
  642. package/dist/production-runtime/ProductionRendererTypes.d.ts +97 -0
  643. package/dist/production-runtime/ProductionRendererTypes.d.ts.map +1 -0
  644. package/dist/production-runtime/ProductionRendererTypes.js +29 -0
  645. package/dist/production-runtime/ProductionRendererTypes.js.map +1 -0
  646. package/dist/production-runtime/ProductionRuntimeRenderer.d.ts +36 -0
  647. package/dist/production-runtime/ProductionRuntimeRenderer.d.ts.map +1 -0
  648. package/dist/production-runtime/ProductionRuntimeRenderer.js +124 -0
  649. package/dist/production-runtime/ProductionRuntimeRenderer.js.map +1 -0
  650. package/dist/production-runtime/ProductionWebGL2Renderer.d.ts +51 -0
  651. package/dist/production-runtime/ProductionWebGL2Renderer.d.ts.map +1 -0
  652. package/dist/production-runtime/ProductionWebGL2Renderer.js +269 -0
  653. package/dist/production-runtime/ProductionWebGL2Renderer.js.map +1 -0
  654. package/dist/production-runtime/ProductionWebGPURenderer.d.ts +69 -0
  655. package/dist/production-runtime/ProductionWebGPURenderer.d.ts.map +1 -0
  656. package/dist/production-runtime/ProductionWebGPURenderer.js +313 -0
  657. package/dist/production-runtime/ProductionWebGPURenderer.js.map +1 -0
  658. package/dist/production-runtime/TransmissionBackdropCapture.d.ts +11 -0
  659. package/dist/production-runtime/TransmissionBackdropCapture.d.ts.map +1 -0
  660. package/dist/production-runtime/TransmissionBackdropCapture.js +119 -0
  661. package/dist/production-runtime/TransmissionBackdropCapture.js.map +1 -0
  662. package/dist/production-runtime/animation/MorphTargetRenderer.d.ts +7 -0
  663. package/dist/production-runtime/animation/MorphTargetRenderer.d.ts.map +1 -0
  664. package/dist/production-runtime/animation/MorphTargetRenderer.js +2 -0
  665. package/dist/production-runtime/animation/MorphTargetRenderer.js.map +1 -0
  666. package/dist/production-runtime/animation/SkinningRenderer.d.ts +7 -0
  667. package/dist/production-runtime/animation/SkinningRenderer.d.ts.map +1 -0
  668. package/dist/production-runtime/animation/SkinningRenderer.js +2 -0
  669. package/dist/production-runtime/animation/SkinningRenderer.js.map +1 -0
  670. package/dist/production-runtime/backends/RendererBackend.d.ts +16 -0
  671. package/dist/production-runtime/backends/RendererBackend.d.ts.map +1 -0
  672. package/dist/production-runtime/backends/RendererBackend.js +2 -0
  673. package/dist/production-runtime/backends/RendererBackend.js.map +1 -0
  674. package/dist/production-runtime/backends/WebGL2RendererBackend.d.ts +15 -0
  675. package/dist/production-runtime/backends/WebGL2RendererBackend.d.ts.map +1 -0
  676. package/dist/production-runtime/backends/WebGL2RendererBackend.js +25 -0
  677. package/dist/production-runtime/backends/WebGL2RendererBackend.js.map +1 -0
  678. package/dist/production-runtime/backends/WebGPURendererBackend.d.ts +20 -0
  679. package/dist/production-runtime/backends/WebGPURendererBackend.d.ts.map +1 -0
  680. package/dist/production-runtime/backends/WebGPURendererBackend.js +19 -0
  681. package/dist/production-runtime/backends/WebGPURendererBackend.js.map +1 -0
  682. package/dist/production-runtime/backends/webgl2/WebGL2Buffer.d.ts +11 -0
  683. package/dist/production-runtime/backends/webgl2/WebGL2Buffer.d.ts.map +1 -0
  684. package/dist/production-runtime/backends/webgl2/WebGL2Buffer.js +8 -0
  685. package/dist/production-runtime/backends/webgl2/WebGL2Buffer.js.map +1 -0
  686. package/dist/production-runtime/backends/webgl2/WebGL2Capabilities.d.ts +11 -0
  687. package/dist/production-runtime/backends/webgl2/WebGL2Capabilities.d.ts.map +1 -0
  688. package/dist/production-runtime/backends/webgl2/WebGL2Capabilities.js +8 -0
  689. package/dist/production-runtime/backends/webgl2/WebGL2Capabilities.js.map +1 -0
  690. package/dist/production-runtime/backends/webgl2/WebGL2RenderTarget.d.ts +11 -0
  691. package/dist/production-runtime/backends/webgl2/WebGL2RenderTarget.d.ts.map +1 -0
  692. package/dist/production-runtime/backends/webgl2/WebGL2RenderTarget.js +8 -0
  693. package/dist/production-runtime/backends/webgl2/WebGL2RenderTarget.js.map +1 -0
  694. package/dist/production-runtime/backends/webgl2/WebGL2Shader.d.ts +11 -0
  695. package/dist/production-runtime/backends/webgl2/WebGL2Shader.d.ts.map +1 -0
  696. package/dist/production-runtime/backends/webgl2/WebGL2Shader.js +8 -0
  697. package/dist/production-runtime/backends/webgl2/WebGL2Shader.js.map +1 -0
  698. package/dist/production-runtime/backends/webgl2/WebGL2StateCache.d.ts +2 -0
  699. package/dist/production-runtime/backends/webgl2/WebGL2StateCache.d.ts.map +1 -0
  700. package/dist/production-runtime/backends/webgl2/WebGL2StateCache.js +2 -0
  701. package/dist/production-runtime/backends/webgl2/WebGL2StateCache.js.map +1 -0
  702. package/dist/production-runtime/backends/webgl2/WebGL2Texture.d.ts +11 -0
  703. package/dist/production-runtime/backends/webgl2/WebGL2Texture.d.ts.map +1 -0
  704. package/dist/production-runtime/backends/webgl2/WebGL2Texture.js +8 -0
  705. package/dist/production-runtime/backends/webgl2/WebGL2Texture.js.map +1 -0
  706. package/dist/production-runtime/backends/webgpu/WebGPUBuffer.d.ts +11 -0
  707. package/dist/production-runtime/backends/webgpu/WebGPUBuffer.d.ts.map +1 -0
  708. package/dist/production-runtime/backends/webgpu/WebGPUBuffer.js +8 -0
  709. package/dist/production-runtime/backends/webgpu/WebGPUBuffer.js.map +1 -0
  710. package/dist/production-runtime/backends/webgpu/WebGPUCapabilities.d.ts +11 -0
  711. package/dist/production-runtime/backends/webgpu/WebGPUCapabilities.d.ts.map +1 -0
  712. package/dist/production-runtime/backends/webgpu/WebGPUCapabilities.js +8 -0
  713. package/dist/production-runtime/backends/webgpu/WebGPUCapabilities.js.map +1 -0
  714. package/dist/production-runtime/backends/webgpu/WebGPURenderTarget.d.ts +11 -0
  715. package/dist/production-runtime/backends/webgpu/WebGPURenderTarget.d.ts.map +1 -0
  716. package/dist/production-runtime/backends/webgpu/WebGPURenderTarget.js +8 -0
  717. package/dist/production-runtime/backends/webgpu/WebGPURenderTarget.js.map +1 -0
  718. package/dist/production-runtime/backends/webgpu/WebGPUShader.d.ts +11 -0
  719. package/dist/production-runtime/backends/webgpu/WebGPUShader.d.ts.map +1 -0
  720. package/dist/production-runtime/backends/webgpu/WebGPUShader.js +8 -0
  721. package/dist/production-runtime/backends/webgpu/WebGPUShader.js.map +1 -0
  722. package/dist/production-runtime/backends/webgpu/WebGPUTexture.d.ts +11 -0
  723. package/dist/production-runtime/backends/webgpu/WebGPUTexture.d.ts.map +1 -0
  724. package/dist/production-runtime/backends/webgpu/WebGPUTexture.js +8 -0
  725. package/dist/production-runtime/backends/webgpu/WebGPUTexture.js.map +1 -0
  726. package/dist/production-runtime/color/ColorManagement.d.ts +4 -0
  727. package/dist/production-runtime/color/ColorManagement.d.ts.map +1 -0
  728. package/dist/production-runtime/color/ColorManagement.js +3 -0
  729. package/dist/production-runtime/color/ColorManagement.js.map +1 -0
  730. package/dist/production-runtime/color/ToneMapping.d.ts +3 -0
  731. package/dist/production-runtime/color/ToneMapping.d.ts.map +1 -0
  732. package/dist/production-runtime/color/ToneMapping.js +9 -0
  733. package/dist/production-runtime/color/ToneMapping.js.map +1 -0
  734. package/dist/production-runtime/diagnostics/FrameCapture.d.ts +7 -0
  735. package/dist/production-runtime/diagnostics/FrameCapture.d.ts.map +1 -0
  736. package/dist/production-runtime/diagnostics/FrameCapture.js +2 -0
  737. package/dist/production-runtime/diagnostics/FrameCapture.js.map +1 -0
  738. package/dist/production-runtime/diagnostics/GPUCapabilities.d.ts +9 -0
  739. package/dist/production-runtime/diagnostics/GPUCapabilities.d.ts.map +1 -0
  740. package/dist/production-runtime/diagnostics/GPUCapabilities.js +2 -0
  741. package/dist/production-runtime/diagnostics/GPUCapabilities.js.map +1 -0
  742. package/dist/production-runtime/diagnostics/RendererStats.d.ts +9 -0
  743. package/dist/production-runtime/diagnostics/RendererStats.d.ts.map +1 -0
  744. package/dist/production-runtime/diagnostics/RendererStats.js +2 -0
  745. package/dist/production-runtime/diagnostics/RendererStats.js.map +1 -0
  746. package/dist/production-runtime/environment/EnvironmentMap.d.ts +8 -0
  747. package/dist/production-runtime/environment/EnvironmentMap.d.ts.map +1 -0
  748. package/dist/production-runtime/environment/EnvironmentMap.js +2 -0
  749. package/dist/production-runtime/environment/EnvironmentMap.js.map +1 -0
  750. package/dist/production-runtime/environment/HDRLoader.d.ts +19 -0
  751. package/dist/production-runtime/environment/HDRLoader.d.ts.map +1 -0
  752. package/dist/production-runtime/environment/HDRLoader.js +22 -0
  753. package/dist/production-runtime/environment/HDRLoader.js.map +1 -0
  754. package/dist/production-runtime/environment/PMREMGenerator.d.ts +99 -0
  755. package/dist/production-runtime/environment/PMREMGenerator.d.ts.map +1 -0
  756. package/dist/production-runtime/environment/PMREMGenerator.js +534 -0
  757. package/dist/production-runtime/environment/PMREMGenerator.js.map +1 -0
  758. package/dist/production-runtime/framegraph/FrameGraph.d.ts +8 -0
  759. package/dist/production-runtime/framegraph/FrameGraph.d.ts.map +1 -0
  760. package/dist/production-runtime/framegraph/FrameGraph.js +14 -0
  761. package/dist/production-runtime/framegraph/FrameGraph.js.map +1 -0
  762. package/dist/production-runtime/framegraph/RenderPass.d.ts +14 -0
  763. package/dist/production-runtime/framegraph/RenderPass.d.ts.map +1 -0
  764. package/dist/production-runtime/framegraph/RenderPass.js +2 -0
  765. package/dist/production-runtime/framegraph/RenderPass.js.map +1 -0
  766. package/dist/production-runtime/geometry/ProjectedDecalGeometry.d.ts +53 -0
  767. package/dist/production-runtime/geometry/ProjectedDecalGeometry.d.ts.map +1 -0
  768. package/dist/production-runtime/geometry/ProjectedDecalGeometry.js +340 -0
  769. package/dist/production-runtime/geometry/ProjectedDecalGeometry.js.map +1 -0
  770. package/dist/production-runtime/index.d.ts +73 -0
  771. package/dist/production-runtime/index.d.ts.map +1 -0
  772. package/dist/production-runtime/index.js +67 -0
  773. package/dist/production-runtime/index.js.map +1 -0
  774. package/dist/production-runtime/lights/LightManager.d.ts +8 -0
  775. package/dist/production-runtime/lights/LightManager.d.ts.map +1 -0
  776. package/dist/production-runtime/lights/LightManager.js +7 -0
  777. package/dist/production-runtime/lights/LightManager.js.map +1 -0
  778. package/dist/production-runtime/lights/ShadowMapRenderer.d.ts +8 -0
  779. package/dist/production-runtime/lights/ShadowMapRenderer.d.ts.map +1 -0
  780. package/dist/production-runtime/lights/ShadowMapRenderer.js +4 -0
  781. package/dist/production-runtime/lights/ShadowMapRenderer.js.map +1 -0
  782. package/dist/production-runtime/materials/GLTFMaterialAdapter.d.ts +14 -0
  783. package/dist/production-runtime/materials/GLTFMaterialAdapter.d.ts.map +1 -0
  784. package/dist/production-runtime/materials/GLTFMaterialAdapter.js +5 -0
  785. package/dist/production-runtime/materials/GLTFMaterialAdapter.js.map +1 -0
  786. package/dist/production-runtime/materials/GLTFPBRMaterialAdapter.d.ts +3 -0
  787. package/dist/production-runtime/materials/GLTFPBRMaterialAdapter.d.ts.map +1 -0
  788. package/dist/production-runtime/materials/GLTFPBRMaterialAdapter.js +2 -0
  789. package/dist/production-runtime/materials/GLTFPBRMaterialAdapter.js.map +1 -0
  790. package/dist/production-runtime/materials/MaterialCompiler.d.ts +9 -0
  791. package/dist/production-runtime/materials/MaterialCompiler.d.ts.map +1 -0
  792. package/dist/production-runtime/materials/MaterialCompiler.js +5 -0
  793. package/dist/production-runtime/materials/MaterialCompiler.js.map +1 -0
  794. package/dist/production-runtime/materials/MaterialTextureBindings.d.ts +8 -0
  795. package/dist/production-runtime/materials/MaterialTextureBindings.d.ts.map +1 -0
  796. package/dist/production-runtime/materials/MaterialTextureBindings.js +4 -0
  797. package/dist/production-runtime/materials/MaterialTextureBindings.js.map +1 -0
  798. package/dist/production-runtime/materials/PBRMaterial.d.ts +23 -0
  799. package/dist/production-runtime/materials/PBRMaterial.d.ts.map +1 -0
  800. package/dist/production-runtime/materials/PBRMaterial.js +2 -0
  801. package/dist/production-runtime/materials/PBRMaterial.js.map +1 -0
  802. package/dist/production-runtime/materials/PBRShaderFeatures.d.ts +13 -0
  803. package/dist/production-runtime/materials/PBRShaderFeatures.d.ts.map +1 -0
  804. package/dist/production-runtime/materials/PBRShaderFeatures.js +2 -0
  805. package/dist/production-runtime/materials/PBRShaderFeatures.js.map +1 -0
  806. package/dist/production-runtime/passes/ContactShadowPass.d.ts +40 -0
  807. package/dist/production-runtime/passes/ContactShadowPass.d.ts.map +1 -0
  808. package/dist/production-runtime/passes/ContactShadowPass.js +126 -0
  809. package/dist/production-runtime/passes/ContactShadowPass.js.map +1 -0
  810. package/dist/production-runtime/passes/DepthPrepass.d.ts +8 -0
  811. package/dist/production-runtime/passes/DepthPrepass.d.ts.map +1 -0
  812. package/dist/production-runtime/passes/DepthPrepass.js +7 -0
  813. package/dist/production-runtime/passes/DepthPrepass.js.map +1 -0
  814. package/dist/production-runtime/passes/OpaquePass.d.ts +8 -0
  815. package/dist/production-runtime/passes/OpaquePass.d.ts.map +1 -0
  816. package/dist/production-runtime/passes/OpaquePass.js +7 -0
  817. package/dist/production-runtime/passes/OpaquePass.js.map +1 -0
  818. package/dist/production-runtime/passes/ShadowPass.d.ts +8 -0
  819. package/dist/production-runtime/passes/ShadowPass.d.ts.map +1 -0
  820. package/dist/production-runtime/passes/ShadowPass.js +7 -0
  821. package/dist/production-runtime/passes/ShadowPass.js.map +1 -0
  822. package/dist/production-runtime/passes/SkyboxPass.d.ts +8 -0
  823. package/dist/production-runtime/passes/SkyboxPass.d.ts.map +1 -0
  824. package/dist/production-runtime/passes/SkyboxPass.js +7 -0
  825. package/dist/production-runtime/passes/SkyboxPass.js.map +1 -0
  826. package/dist/production-runtime/passes/ToneMappingPass.d.ts +8 -0
  827. package/dist/production-runtime/passes/ToneMappingPass.d.ts.map +1 -0
  828. package/dist/production-runtime/passes/ToneMappingPass.js +7 -0
  829. package/dist/production-runtime/passes/ToneMappingPass.js.map +1 -0
  830. package/dist/production-runtime/passes/TransparentPass.d.ts +8 -0
  831. package/dist/production-runtime/passes/TransparentPass.d.ts.map +1 -0
  832. package/dist/production-runtime/passes/TransparentPass.js +7 -0
  833. package/dist/production-runtime/passes/TransparentPass.js.map +1 -0
  834. package/dist/production-runtime/postprocess/BloomPass.d.ts +15 -0
  835. package/dist/production-runtime/postprocess/BloomPass.d.ts.map +1 -0
  836. package/dist/production-runtime/postprocess/BloomPass.js +37 -0
  837. package/dist/production-runtime/postprocess/BloomPass.js.map +1 -0
  838. package/dist/production-runtime/postprocess/ColorGradingPass.d.ts +16 -0
  839. package/dist/production-runtime/postprocess/ColorGradingPass.d.ts.map +1 -0
  840. package/dist/production-runtime/postprocess/ColorGradingPass.js +34 -0
  841. package/dist/production-runtime/postprocess/ColorGradingPass.js.map +1 -0
  842. package/dist/production-runtime/postprocess/DOFPass.d.ts +16 -0
  843. package/dist/production-runtime/postprocess/DOFPass.d.ts.map +1 -0
  844. package/dist/production-runtime/postprocess/DOFPass.js +31 -0
  845. package/dist/production-runtime/postprocess/DOFPass.js.map +1 -0
  846. package/dist/production-runtime/postprocess/FXAAPass.d.ts +16 -0
  847. package/dist/production-runtime/postprocess/FXAAPass.d.ts.map +1 -0
  848. package/dist/production-runtime/postprocess/FXAAPass.js +39 -0
  849. package/dist/production-runtime/postprocess/FXAAPass.js.map +1 -0
  850. package/dist/production-runtime/postprocess/ProductionEffectComposer.d.ts +21 -0
  851. package/dist/production-runtime/postprocess/ProductionEffectComposer.d.ts.map +1 -0
  852. package/dist/production-runtime/postprocess/ProductionEffectComposer.js +53 -0
  853. package/dist/production-runtime/postprocess/ProductionEffectComposer.js.map +1 -0
  854. package/dist/production-runtime/postprocess/ProductionPostProcessTypes.d.ts +37 -0
  855. package/dist/production-runtime/postprocess/ProductionPostProcessTypes.d.ts.map +1 -0
  856. package/dist/production-runtime/postprocess/ProductionPostProcessTypes.js +124 -0
  857. package/dist/production-runtime/postprocess/ProductionPostProcessTypes.js.map +1 -0
  858. package/dist/production-runtime/postprocess/SSAOPass.d.ts +15 -0
  859. package/dist/production-runtime/postprocess/SSAOPass.d.ts.map +1 -0
  860. package/dist/production-runtime/postprocess/SSAOPass.js +30 -0
  861. package/dist/production-runtime/postprocess/SSAOPass.js.map +1 -0
  862. package/dist/production-runtime/resources/GPUBuffer.d.ts +10 -0
  863. package/dist/production-runtime/resources/GPUBuffer.d.ts.map +1 -0
  864. package/dist/production-runtime/resources/GPUBuffer.js +7 -0
  865. package/dist/production-runtime/resources/GPUBuffer.js.map +1 -0
  866. package/dist/production-runtime/resources/GPUTexture.d.ts +12 -0
  867. package/dist/production-runtime/resources/GPUTexture.d.ts.map +1 -0
  868. package/dist/production-runtime/resources/GPUTexture.js +7 -0
  869. package/dist/production-runtime/resources/GPUTexture.js.map +1 -0
  870. package/dist/production-runtime/resources/RenderTarget.d.ts +11 -0
  871. package/dist/production-runtime/resources/RenderTarget.d.ts.map +1 -0
  872. package/dist/production-runtime/resources/RenderTarget.js +7 -0
  873. package/dist/production-runtime/resources/RenderTarget.js.map +1 -0
  874. package/dist/production-runtime/resources/ResourceCache.d.ts +8 -0
  875. package/dist/production-runtime/resources/ResourceCache.d.ts.map +1 -0
  876. package/dist/production-runtime/resources/ResourceCache.js +8 -0
  877. package/dist/production-runtime/resources/ResourceCache.js.map +1 -0
  878. package/dist/production-runtime/scene/Camera.d.ts +8 -0
  879. package/dist/production-runtime/scene/Camera.d.ts.map +1 -0
  880. package/dist/production-runtime/scene/Camera.js +2 -0
  881. package/dist/production-runtime/scene/Camera.js.map +1 -0
  882. package/dist/production-runtime/scene/Lights.d.ts +9 -0
  883. package/dist/production-runtime/scene/Lights.d.ts.map +1 -0
  884. package/dist/production-runtime/scene/Lights.js +2 -0
  885. package/dist/production-runtime/scene/Lights.js.map +1 -0
  886. package/dist/production-runtime/scene/RenderableMesh.d.ts +8 -0
  887. package/dist/production-runtime/scene/RenderableMesh.d.ts.map +1 -0
  888. package/dist/production-runtime/scene/RenderableMesh.js +2 -0
  889. package/dist/production-runtime/scene/RenderableMesh.js.map +1 -0
  890. package/dist/production-runtime/scene/RenderablePrimitive.d.ts +8 -0
  891. package/dist/production-runtime/scene/RenderablePrimitive.d.ts.map +1 -0
  892. package/dist/production-runtime/scene/RenderablePrimitive.js +2 -0
  893. package/dist/production-runtime/scene/RenderablePrimitive.js.map +1 -0
  894. package/dist/production-runtime/scene/RenderableScene.d.ts +11 -0
  895. package/dist/production-runtime/scene/RenderableScene.d.ts.map +1 -0
  896. package/dist/production-runtime/scene/RenderableScene.js +2 -0
  897. package/dist/production-runtime/scene/RenderableScene.js.map +1 -0
  898. package/dist/production-runtime/shaders/ShaderProgramLibrary.d.ts +12 -0
  899. package/dist/production-runtime/shaders/ShaderProgramLibrary.d.ts.map +1 -0
  900. package/dist/production-runtime/shaders/ShaderProgramLibrary.js +7 -0
  901. package/dist/production-runtime/shaders/ShaderProgramLibrary.js.map +1 -0
  902. package/dist/shadows/CascadedShadowPipeline.d.ts +25 -0
  903. package/dist/shadows/CascadedShadowPipeline.d.ts.map +1 -0
  904. package/dist/shadows/CascadedShadowPipeline.js +31 -0
  905. package/dist/shadows/CascadedShadowPipeline.js.map +1 -0
  906. package/dist/shadows/ContactShadows.d.ts +37 -0
  907. package/dist/shadows/ContactShadows.d.ts.map +1 -0
  908. package/dist/shadows/ContactShadows.js +68 -0
  909. package/dist/shadows/ContactShadows.js.map +1 -0
  910. package/dist/shadows/ShadowDebugViews.d.ts +12 -0
  911. package/dist/shadows/ShadowDebugViews.d.ts.map +1 -0
  912. package/dist/shadows/ShadowDebugViews.js +35 -0
  913. package/dist/shadows/ShadowDebugViews.js.map +1 -0
  914. package/dist/threejs-compatibility/InstancingSystem.d.ts +10 -0
  915. package/dist/threejs-compatibility/InstancingSystem.d.ts.map +1 -0
  916. package/dist/threejs-compatibility/InstancingSystem.js +11 -0
  917. package/dist/threejs-compatibility/InstancingSystem.js.map +1 -0
  918. package/dist/threejs-compatibility/LightingSystem.d.ts +11 -0
  919. package/dist/threejs-compatibility/LightingSystem.d.ts.map +1 -0
  920. package/dist/threejs-compatibility/LightingSystem.js +14 -0
  921. package/dist/threejs-compatibility/LightingSystem.js.map +1 -0
  922. package/dist/threejs-compatibility/MaterialSystem.d.ts +6 -0
  923. package/dist/threejs-compatibility/MaterialSystem.d.ts.map +1 -0
  924. package/dist/threejs-compatibility/MaterialSystem.js +7 -0
  925. package/dist/threejs-compatibility/MaterialSystem.js.map +1 -0
  926. package/dist/threejs-compatibility/RenderTargetSystem.d.ts +16 -0
  927. package/dist/threejs-compatibility/RenderTargetSystem.d.ts.map +1 -0
  928. package/dist/threejs-compatibility/RenderTargetSystem.js +23 -0
  929. package/dist/threejs-compatibility/RenderTargetSystem.js.map +1 -0
  930. package/dist/threejs-compatibility/RendererDiagnostics.d.ts +27 -0
  931. package/dist/threejs-compatibility/RendererDiagnostics.d.ts.map +1 -0
  932. package/dist/threejs-compatibility/RendererDiagnostics.js +41 -0
  933. package/dist/threejs-compatibility/RendererDiagnostics.js.map +1 -0
  934. package/dist/threejs-compatibility/SceneRenderer.d.ts +19 -0
  935. package/dist/threejs-compatibility/SceneRenderer.d.ts.map +1 -0
  936. package/dist/threejs-compatibility/SceneRenderer.js +18 -0
  937. package/dist/threejs-compatibility/SceneRenderer.js.map +1 -0
  938. package/dist/threejs-compatibility/ShadowSystem.d.ts +11 -0
  939. package/dist/threejs-compatibility/ShadowSystem.d.ts.map +1 -0
  940. package/dist/threejs-compatibility/ShadowSystem.js +12 -0
  941. package/dist/threejs-compatibility/ShadowSystem.js.map +1 -0
  942. package/dist/threejs-compatibility/TextureSystem.d.ts +9 -0
  943. package/dist/threejs-compatibility/TextureSystem.d.ts.map +1 -0
  944. package/dist/threejs-compatibility/TextureSystem.js +14 -0
  945. package/dist/threejs-compatibility/TextureSystem.js.map +1 -0
  946. package/dist/threejs-compatibility/ThreeCompatRenderer.d.ts +37 -0
  947. package/dist/threejs-compatibility/ThreeCompatRenderer.d.ts.map +1 -0
  948. package/dist/threejs-compatibility/ThreeCompatRenderer.js +77 -0
  949. package/dist/threejs-compatibility/ThreeCompatRenderer.js.map +1 -0
  950. package/dist/threejs-compatibility/TransparencySystem.d.ts +11 -0
  951. package/dist/threejs-compatibility/TransparencySystem.d.ts.map +1 -0
  952. package/dist/threejs-compatibility/TransparencySystem.js +12 -0
  953. package/dist/threejs-compatibility/TransparencySystem.js.map +1 -0
  954. package/dist/threejs-compatibility/index.d.ts +25 -0
  955. package/dist/threejs-compatibility/index.d.ts.map +1 -0
  956. package/dist/threejs-compatibility/index.js +15 -0
  957. package/dist/threejs-compatibility/index.js.map +1 -0
  958. package/dist/threejs-compatibility/performance/BVH.d.ts +11 -0
  959. package/dist/threejs-compatibility/performance/BVH.d.ts.map +1 -0
  960. package/dist/threejs-compatibility/performance/BVH.js +10 -0
  961. package/dist/threejs-compatibility/performance/BVH.js.map +1 -0
  962. package/dist/threejs-compatibility/performance/FrustumCulling.d.ts +7 -0
  963. package/dist/threejs-compatibility/performance/FrustumCulling.d.ts.map +1 -0
  964. package/dist/threejs-compatibility/performance/FrustumCulling.js +5 -0
  965. package/dist/threejs-compatibility/performance/FrustumCulling.js.map +1 -0
  966. package/dist/threejs-compatibility/performance/Instancing.d.ts +7 -0
  967. package/dist/threejs-compatibility/performance/Instancing.d.ts.map +1 -0
  968. package/dist/threejs-compatibility/performance/Instancing.js +10 -0
  969. package/dist/threejs-compatibility/performance/Instancing.js.map +1 -0
  970. package/dist/threejs-compatibility/performance/LODSystem.d.ts +9 -0
  971. package/dist/threejs-compatibility/performance/LODSystem.d.ts.map +1 -0
  972. package/dist/threejs-compatibility/performance/LODSystem.js +11 -0
  973. package/dist/threejs-compatibility/performance/LODSystem.js.map +1 -0
  974. package/dist/threejs-compatibility/performance/OcclusionCulling.d.ts +3 -0
  975. package/dist/threejs-compatibility/performance/OcclusionCulling.d.ts.map +1 -0
  976. package/dist/threejs-compatibility/performance/OcclusionCulling.js +5 -0
  977. package/dist/threejs-compatibility/performance/OcclusionCulling.js.map +1 -0
  978. package/dist/threejs-compatibility/performance/RaycastAcceleration.d.ts +8 -0
  979. package/dist/threejs-compatibility/performance/RaycastAcceleration.d.ts.map +1 -0
  980. package/dist/threejs-compatibility/performance/RaycastAcceleration.js +11 -0
  981. package/dist/threejs-compatibility/performance/RaycastAcceleration.js.map +1 -0
  982. package/dist/threejs-compatibility/performance/RendererProfiler.d.ts +11 -0
  983. package/dist/threejs-compatibility/performance/RendererProfiler.d.ts.map +1 -0
  984. package/dist/threejs-compatibility/performance/RendererProfiler.js +10 -0
  985. package/dist/threejs-compatibility/performance/RendererProfiler.js.map +1 -0
  986. package/dist/threejs-compatibility/performance/TextureStreaming.d.ts +7 -0
  987. package/dist/threejs-compatibility/performance/TextureStreaming.d.ts.map +1 -0
  988. package/dist/threejs-compatibility/performance/TextureStreaming.js +10 -0
  989. package/dist/threejs-compatibility/performance/TextureStreaming.js.map +1 -0
  990. package/dist/threejs-compatibility/performance/index.d.ts +13 -0
  991. package/dist/threejs-compatibility/performance/index.d.ts.map +1 -0
  992. package/dist/threejs-compatibility/performance/index.js +9 -0
  993. package/dist/threejs-compatibility/performance/index.js.map +1 -0
  994. package/dist/threejs-compatibility/postprocess/BloomPass.d.ts +9 -0
  995. package/dist/threejs-compatibility/postprocess/BloomPass.d.ts.map +1 -0
  996. package/dist/threejs-compatibility/postprocess/BloomPass.js +14 -0
  997. package/dist/threejs-compatibility/postprocess/BloomPass.js.map +1 -0
  998. package/dist/threejs-compatibility/postprocess/ColorGradingPass.d.ts +10 -0
  999. package/dist/threejs-compatibility/postprocess/ColorGradingPass.d.ts.map +1 -0
  1000. package/dist/threejs-compatibility/postprocess/ColorGradingPass.js +16 -0
  1001. package/dist/threejs-compatibility/postprocess/ColorGradingPass.js.map +1 -0
  1002. package/dist/threejs-compatibility/postprocess/DepthOfFieldPass.d.ts +9 -0
  1003. package/dist/threejs-compatibility/postprocess/DepthOfFieldPass.d.ts.map +1 -0
  1004. package/dist/threejs-compatibility/postprocess/DepthOfFieldPass.js +19 -0
  1005. package/dist/threejs-compatibility/postprocess/DepthOfFieldPass.js.map +1 -0
  1006. package/dist/threejs-compatibility/postprocess/EffectComposer.d.ts +7 -0
  1007. package/dist/threejs-compatibility/postprocess/EffectComposer.d.ts.map +1 -0
  1008. package/dist/threejs-compatibility/postprocess/EffectComposer.js +11 -0
  1009. package/dist/threejs-compatibility/postprocess/EffectComposer.js.map +1 -0
  1010. package/dist/threejs-compatibility/postprocess/FXAAPass.d.ts +7 -0
  1011. package/dist/threejs-compatibility/postprocess/FXAAPass.d.ts.map +1 -0
  1012. package/dist/threejs-compatibility/postprocess/FXAAPass.js +10 -0
  1013. package/dist/threejs-compatibility/postprocess/FXAAPass.js.map +1 -0
  1014. package/dist/threejs-compatibility/postprocess/MotionBlurPass.d.ts +9 -0
  1015. package/dist/threejs-compatibility/postprocess/MotionBlurPass.d.ts.map +1 -0
  1016. package/dist/threejs-compatibility/postprocess/MotionBlurPass.js +18 -0
  1017. package/dist/threejs-compatibility/postprocess/MotionBlurPass.js.map +1 -0
  1018. package/dist/threejs-compatibility/postprocess/OutlinePass.d.ts +9 -0
  1019. package/dist/threejs-compatibility/postprocess/OutlinePass.d.ts.map +1 -0
  1020. package/dist/threejs-compatibility/postprocess/OutlinePass.js +19 -0
  1021. package/dist/threejs-compatibility/postprocess/OutlinePass.js.map +1 -0
  1022. package/dist/threejs-compatibility/postprocess/PostProcessTypes.d.ts +42 -0
  1023. package/dist/threejs-compatibility/postprocess/PostProcessTypes.d.ts.map +1 -0
  1024. package/dist/threejs-compatibility/postprocess/PostProcessTypes.js +123 -0
  1025. package/dist/threejs-compatibility/postprocess/PostProcessTypes.js.map +1 -0
  1026. package/dist/threejs-compatibility/postprocess/RenderPass.d.ts +7 -0
  1027. package/dist/threejs-compatibility/postprocess/RenderPass.d.ts.map +1 -0
  1028. package/dist/threejs-compatibility/postprocess/RenderPass.js +8 -0
  1029. package/dist/threejs-compatibility/postprocess/RenderPass.js.map +1 -0
  1030. package/dist/threejs-compatibility/postprocess/SMAAPass.d.ts +7 -0
  1031. package/dist/threejs-compatibility/postprocess/SMAAPass.d.ts.map +1 -0
  1032. package/dist/threejs-compatibility/postprocess/SMAAPass.js +10 -0
  1033. package/dist/threejs-compatibility/postprocess/SMAAPass.js.map +1 -0
  1034. package/dist/threejs-compatibility/postprocess/SSAOPass.d.ts +9 -0
  1035. package/dist/threejs-compatibility/postprocess/SSAOPass.d.ts.map +1 -0
  1036. package/dist/threejs-compatibility/postprocess/SSAOPass.js +19 -0
  1037. package/dist/threejs-compatibility/postprocess/SSAOPass.js.map +1 -0
  1038. package/dist/threejs-compatibility/postprocess/ShaderPass.d.ts +9 -0
  1039. package/dist/threejs-compatibility/postprocess/ShaderPass.d.ts.map +1 -0
  1040. package/dist/threejs-compatibility/postprocess/ShaderPass.js +11 -0
  1041. package/dist/threejs-compatibility/postprocess/ShaderPass.js.map +1 -0
  1042. package/dist/threejs-compatibility/postprocess/TAAPass.d.ts +7 -0
  1043. package/dist/threejs-compatibility/postprocess/TAAPass.d.ts.map +1 -0
  1044. package/dist/threejs-compatibility/postprocess/TAAPass.js +10 -0
  1045. package/dist/threejs-compatibility/postprocess/TAAPass.js.map +1 -0
  1046. package/dist/threejs-compatibility/postprocess/VignettePass.d.ts +9 -0
  1047. package/dist/threejs-compatibility/postprocess/VignettePass.d.ts.map +1 -0
  1048. package/dist/threejs-compatibility/postprocess/VignettePass.js +14 -0
  1049. package/dist/threejs-compatibility/postprocess/VignettePass.js.map +1 -0
  1050. package/dist/threejs-compatibility/postprocess/index.d.ts +16 -0
  1051. package/dist/threejs-compatibility/postprocess/index.d.ts.map +1 -0
  1052. package/dist/threejs-compatibility/postprocess/index.js +15 -0
  1053. package/dist/threejs-compatibility/postprocess/index.js.map +1 -0
  1054. package/dist/threejs-compatibility/shaders/NodeMaterial.d.ts +14 -0
  1055. package/dist/threejs-compatibility/shaders/NodeMaterial.d.ts.map +1 -0
  1056. package/dist/threejs-compatibility/shaders/NodeMaterial.js +15 -0
  1057. package/dist/threejs-compatibility/shaders/NodeMaterial.js.map +1 -0
  1058. package/dist/threejs-compatibility/shaders/RawShaderMaterial.d.ts +6 -0
  1059. package/dist/threejs-compatibility/shaders/RawShaderMaterial.d.ts.map +1 -0
  1060. package/dist/threejs-compatibility/shaders/RawShaderMaterial.js +6 -0
  1061. package/dist/threejs-compatibility/shaders/RawShaderMaterial.js.map +1 -0
  1062. package/dist/threejs-compatibility/shaders/ShaderDiagnostics.d.ts +7 -0
  1063. package/dist/threejs-compatibility/shaders/ShaderDiagnostics.d.ts.map +1 -0
  1064. package/dist/threejs-compatibility/shaders/ShaderDiagnostics.js +12 -0
  1065. package/dist/threejs-compatibility/shaders/ShaderDiagnostics.js.map +1 -0
  1066. package/dist/threejs-compatibility/shaders/ShaderMaterial.d.ts +12 -0
  1067. package/dist/threejs-compatibility/shaders/ShaderMaterial.d.ts.map +1 -0
  1068. package/dist/threejs-compatibility/shaders/ShaderMaterial.js +20 -0
  1069. package/dist/threejs-compatibility/shaders/ShaderMaterial.js.map +1 -0
  1070. package/dist/threejs-compatibility/shaders/ThreeCompatShaderChunks.d.ts +7 -0
  1071. package/dist/threejs-compatibility/shaders/ThreeCompatShaderChunks.d.ts.map +1 -0
  1072. package/dist/threejs-compatibility/shaders/ThreeCompatShaderChunks.js +7 -0
  1073. package/dist/threejs-compatibility/shaders/ThreeCompatShaderChunks.js.map +1 -0
  1074. package/dist/threejs-compatibility/shaders/Uniforms.d.ts +8 -0
  1075. package/dist/threejs-compatibility/shaders/Uniforms.d.ts.map +1 -0
  1076. package/dist/threejs-compatibility/shaders/Uniforms.js +14 -0
  1077. package/dist/threejs-compatibility/shaders/Uniforms.js.map +1 -0
  1078. package/dist/threejs-compatibility/shaders/index.d.ts +10 -0
  1079. package/dist/threejs-compatibility/shaders/index.d.ts.map +1 -0
  1080. package/dist/threejs-compatibility/shaders/index.js +7 -0
  1081. package/dist/threejs-compatibility/shaders/index.js.map +1 -0
  1082. package/dist/threejs-compatibility/vfx/GPUPointCloud.d.ts +7 -0
  1083. package/dist/threejs-compatibility/vfx/GPUPointCloud.d.ts.map +1 -0
  1084. package/dist/threejs-compatibility/vfx/GPUPointCloud.js +12 -0
  1085. package/dist/threejs-compatibility/vfx/GPUPointCloud.js.map +1 -0
  1086. package/dist/threejs-compatibility/vfx/LineRenderer.d.ts +10 -0
  1087. package/dist/threejs-compatibility/vfx/LineRenderer.d.ts.map +1 -0
  1088. package/dist/threejs-compatibility/vfx/LineRenderer.js +7 -0
  1089. package/dist/threejs-compatibility/vfx/LineRenderer.js.map +1 -0
  1090. package/dist/threejs-compatibility/vfx/ParticleSystem.d.ts +12 -0
  1091. package/dist/threejs-compatibility/vfx/ParticleSystem.d.ts.map +1 -0
  1092. package/dist/threejs-compatibility/vfx/ParticleSystem.js +15 -0
  1093. package/dist/threejs-compatibility/vfx/ParticleSystem.js.map +1 -0
  1094. package/dist/threejs-compatibility/vfx/SpriteSystem.d.ts +11 -0
  1095. package/dist/threejs-compatibility/vfx/SpriteSystem.d.ts.map +1 -0
  1096. package/dist/threejs-compatibility/vfx/SpriteSystem.js +7 -0
  1097. package/dist/threejs-compatibility/vfx/SpriteSystem.js.map +1 -0
  1098. package/dist/threejs-compatibility/vfx/TrailRenderer.d.ts +5 -0
  1099. package/dist/threejs-compatibility/vfx/TrailRenderer.d.ts.map +1 -0
  1100. package/dist/threejs-compatibility/vfx/TrailRenderer.js +9 -0
  1101. package/dist/threejs-compatibility/vfx/TrailRenderer.js.map +1 -0
  1102. package/dist/threejs-compatibility/vfx/VFXDiagnostics.d.ts +21 -0
  1103. package/dist/threejs-compatibility/vfx/VFXDiagnostics.d.ts.map +1 -0
  1104. package/dist/threejs-compatibility/vfx/VFXDiagnostics.js +12 -0
  1105. package/dist/threejs-compatibility/vfx/VFXDiagnostics.js.map +1 -0
  1106. package/dist/threejs-compatibility/vfx/index.d.ts +10 -0
  1107. package/dist/threejs-compatibility/vfx/index.d.ts.map +1 -0
  1108. package/dist/threejs-compatibility/vfx/index.js +7 -0
  1109. package/dist/threejs-compatibility/vfx/index.js.map +1 -0
  1110. package/dist/threejs-example-parity/index.d.ts +57 -0
  1111. package/dist/threejs-example-parity/index.d.ts.map +1 -0
  1112. package/dist/threejs-example-parity/index.js +139 -0
  1113. package/dist/threejs-example-parity/index.js.map +1 -0
  1114. package/dist/webgpu/WebGPUBuffer.d.ts +2 -0
  1115. package/dist/webgpu/WebGPUBuffer.d.ts.map +1 -0
  1116. package/dist/webgpu/WebGPUBuffer.js +2 -0
  1117. package/dist/webgpu/WebGPUBuffer.js.map +1 -0
  1118. package/dist/webgpu/WebGPUCompute.d.ts +3 -0
  1119. package/dist/webgpu/WebGPUCompute.d.ts.map +1 -0
  1120. package/dist/webgpu/WebGPUCompute.js +2 -0
  1121. package/dist/webgpu/WebGPUCompute.js.map +1 -0
  1122. package/dist/webgpu/WebGPUPipelineCache.d.ts +6 -0
  1123. package/dist/webgpu/WebGPUPipelineCache.d.ts.map +1 -0
  1124. package/dist/webgpu/WebGPUPipelineCache.js +15 -0
  1125. package/dist/webgpu/WebGPUPipelineCache.js.map +1 -0
  1126. package/dist/webgpu/WebGPUPostProcess.d.ts +3 -0
  1127. package/dist/webgpu/WebGPUPostProcess.d.ts.map +1 -0
  1128. package/dist/webgpu/WebGPUPostProcess.js +2 -0
  1129. package/dist/webgpu/WebGPUPostProcess.js.map +1 -0
  1130. package/dist/webgpu/WebGPUTexture.d.ts +3 -0
  1131. package/dist/webgpu/WebGPUTexture.d.ts.map +1 -0
  1132. package/dist/webgpu/WebGPUTexture.js +2 -0
  1133. package/dist/webgpu/WebGPUTexture.js.map +1 -0
  1134. package/package.json +18 -0
  1135. package/src/ArchitecturalLightingFixtures.ts +241 -0
  1136. package/src/ArchitecturalMaterialCatalog.ts +130 -0
  1137. package/src/ArchitecturalMeasurementFixtures.ts +155 -0
  1138. package/src/BRDFLut.ts +47 -0
  1139. package/src/CameraFraming.ts +200 -0
  1140. package/src/CanonicalSceneFixtures.ts +95 -0
  1141. package/src/CascadedShadowMaps.ts +449 -0
  1142. package/src/ColorManagement.ts +127 -0
  1143. package/src/CullingFixtures.ts +280 -0
  1144. package/src/DecalGeometry.ts +26 -0
  1145. package/src/DepthPass.ts +110 -0
  1146. package/src/EnvironmentBackgroundPass.ts +194 -0
  1147. package/src/EnvironmentBackgroundResources.ts +309 -0
  1148. package/src/EnvironmentLighting.ts +96 -0
  1149. package/src/EnvironmentMapResources.ts +1026 -0
  1150. package/src/EnvironmentPipeline.ts +69 -0
  1151. package/src/EnvironmentPlatform.ts +1306 -0
  1152. package/src/EnvironmentPreset.ts +155 -0
  1153. package/src/Exposure.ts +66 -0
  1154. package/src/ExternalParityRenderPreset.ts +725 -0
  1155. package/src/ForwardPass.ts +1639 -0
  1156. package/src/FrameVisualMetrics.ts +218 -0
  1157. package/src/Geometry.ts +461 -0
  1158. package/src/GeometryPrimitives.ts +2 -0
  1159. package/src/HDRRenderPipeline.ts +94 -0
  1160. package/src/IBL.ts +86 -0
  1161. package/src/IndexBuffer.ts +57 -0
  1162. package/src/InstancedPBRMaterial.ts +186 -0
  1163. package/src/InstancedUnlitMaterial.ts +60 -0
  1164. package/src/Instancing.ts +19 -0
  1165. package/src/LightCollector.ts +82 -0
  1166. package/src/LightUniforms.ts +47 -0
  1167. package/src/LightingDebug.ts +80 -0
  1168. package/src/LightingDefaults.ts +79 -0
  1169. package/src/LightingRig.ts +301 -0
  1170. package/src/LineGeometry.ts +2 -0
  1171. package/src/Material.ts +209 -0
  1172. package/src/MaterialBinding.ts +131 -0
  1173. package/src/MaterialInstance.ts +59 -0
  1174. package/src/MaterialPresets.ts +272 -0
  1175. package/src/MorphTarget.ts +123 -0
  1176. package/src/MorphUnlitMaterial.ts +54 -0
  1177. package/src/NormalMappedPBRMaterial.ts +188 -0
  1178. package/src/OceanFixtures.ts +318 -0
  1179. package/src/PBRLightingDefaults.ts +12 -0
  1180. package/src/PBRMaterial.ts +442 -0
  1181. package/src/PMREM.ts +53 -0
  1182. package/src/PbrReference.ts +681 -0
  1183. package/src/PostProcessPass.ts +2507 -0
  1184. package/src/ProceduralTextureFixtures.ts +393 -0
  1185. package/src/ProductTurntableFixtures.ts +815 -0
  1186. package/src/Raycaster.ts +21 -0
  1187. package/src/ReflectionProbe.ts +13 -0
  1188. package/src/ReflectionSurfaces.ts +219 -0
  1189. package/src/RenderBackend.ts +43 -0
  1190. package/src/RenderDebugViews.ts +138 -0
  1191. package/src/RenderDevice.ts +836 -0
  1192. package/src/RenderGraph.ts +194 -0
  1193. package/src/RenderPass.ts +27 -0
  1194. package/src/RenderPipeline.ts +101 -0
  1195. package/src/RenderQueue.ts +12 -0
  1196. package/src/RenderState.ts +12 -0
  1197. package/src/Renderer.ts +2626 -0
  1198. package/src/RendererDebugOverlay.ts +80 -0
  1199. package/src/RendererFeatureGates.ts +150 -0
  1200. package/src/RendererPostprocessPlan.ts +279 -0
  1201. package/src/RendererTiming.ts +251 -0
  1202. package/src/RendererVisualPipelineReport.ts +836 -0
  1203. package/src/ResourceLifecycle.ts +21 -0
  1204. package/src/Sampler.ts +37 -0
  1205. package/src/SceneOptimization.ts +518 -0
  1206. package/src/ShaderChunks.ts +393 -0
  1207. package/src/ShaderLibrary.ts +2738 -0
  1208. package/src/ShaderModule.ts +36 -0
  1209. package/src/ShaderPreprocessor.ts +260 -0
  1210. package/src/ShaderReflection.ts +201 -0
  1211. package/src/ShadowMap.ts +237 -0
  1212. package/src/ShadowPass.ts +198 -0
  1213. package/src/ShadowProjection.ts +115 -0
  1214. package/src/SkinnedLitMaterial.ts +366 -0
  1215. package/src/SkinnedUnlitMaterial.ts +63 -0
  1216. package/src/SkinningBounds.ts +131 -0
  1217. package/src/SpaceEnvironmentFixtures.ts +200 -0
  1218. package/src/SpriteGeometry.ts +21 -0
  1219. package/src/StereoCameraRig.ts +127 -0
  1220. package/src/StereoEffects.ts +274 -0
  1221. package/src/TerrainFixtures.ts +180 -0
  1222. package/src/Texture.ts +307 -0
  1223. package/src/TextureBinding.ts +91 -0
  1224. package/src/TexturedPBRMaterial.ts +1112 -0
  1225. package/src/TexturedUnlitMaterial.ts +67 -0
  1226. package/src/ToneMapping.ts +105 -0
  1227. package/src/UniformBinder.ts +16 -0
  1228. package/src/UniformLayout.ts +129 -0
  1229. package/src/UnlitMaterial.ts +75 -0
  1230. package/src/VegetationFixtures.ts +314 -0
  1231. package/src/VertexBuffer.ts +120 -0
  1232. package/src/VertexFormat.ts +171 -0
  1233. package/src/VoxelWorldFixtures.ts +280 -0
  1234. package/src/WeatherFixtures.ts +223 -0
  1235. package/src/WebGL2Device.ts +2280 -0
  1236. package/src/WebGL2StateCache.ts +330 -0
  1237. package/src/WebGPUDevice.ts +2806 -0
  1238. package/src/WebGPURenderToTextureProof.ts +139 -0
  1239. package/src/advanced-runtime/AdvancedRenderer.ts +73 -0
  1240. package/src/advanced-runtime/index.ts +9 -0
  1241. package/src/cinematic/BloomPass.ts +26 -0
  1242. package/src/cinematic/CinematicDepthComposition.ts +30 -0
  1243. package/src/cinematic/CinematicEvidence.ts +123 -0
  1244. package/src/cinematic/CinematicLightingRig.ts +144 -0
  1245. package/src/cinematic/CinematicMaterialPresets.ts +130 -0
  1246. package/src/cinematic/CinematicPostProcess.ts +83 -0
  1247. package/src/cinematic/DepthHazePass.ts +30 -0
  1248. package/src/cinematic/EmissivePracticalLightSystem.ts +45 -0
  1249. package/src/cinematic/FilmGrainPass.ts +24 -0
  1250. package/src/cinematic/FogVolumeSystem.ts +30 -0
  1251. package/src/cinematic/GlowCardSystem.ts +44 -0
  1252. package/src/cinematic/RainParticleSystem.ts +151 -0
  1253. package/src/cinematic/VignettePass.ts +25 -0
  1254. package/src/cinematic/WetReflectionApproximation.ts +27 -0
  1255. package/src/cinematic/index.ts +14 -0
  1256. package/src/effects/CollisionModule.ts +64 -0
  1257. package/src/effects/ColorModule.ts +60 -0
  1258. package/src/effects/ForceModule.ts +25 -0
  1259. package/src/effects/GPUParticleBackend.ts +569 -0
  1260. package/src/effects/Particle.ts +108 -0
  1261. package/src/effects/ParticleDiagnostics.ts +224 -0
  1262. package/src/effects/ParticleEffectPresets.ts +147 -0
  1263. package/src/effects/ParticleEmitter.ts +326 -0
  1264. package/src/effects/ParticleModule.ts +26 -0
  1265. package/src/effects/ParticleRenderPass.ts +117 -0
  1266. package/src/effects/ParticleRenderer.ts +132 -0
  1267. package/src/effects/ParticleSystem.ts +333 -0
  1268. package/src/effects/SizeModule.ts +56 -0
  1269. package/src/effects/TrailModule.ts +72 -0
  1270. package/src/effects/VelocityModule.ts +75 -0
  1271. package/src/effects/index.ts +15 -0
  1272. package/src/index.ts +914 -0
  1273. package/src/materials/AlphaSorting.ts +30 -0
  1274. package/src/materials/MaterialExtensions.ts +42 -0
  1275. package/src/materials/PhysicalMaterial.ts +133 -0
  1276. package/src/materials/TransmissionPass.ts +51 -0
  1277. package/src/performance/BVH.ts +18 -0
  1278. package/src/performance/Batcher.ts +2 -0
  1279. package/src/performance/FrustumCuller.ts +9 -0
  1280. package/src/performance/LOD.ts +20 -0
  1281. package/src/performance/Octree.ts +10 -0
  1282. package/src/performance/RenderItemSorting.ts +167 -0
  1283. package/src/performance/RendererStats.ts +43 -0
  1284. package/src/performance/ResourceBudget.ts +44 -0
  1285. package/src/postprocess/BloomPass.ts +28 -0
  1286. package/src/postprocess/CinematicDiagnostics.ts +642 -0
  1287. package/src/postprocess/ColorGradingPass.ts +24 -0
  1288. package/src/postprocess/DepthOfFieldPass.ts +12 -0
  1289. package/src/postprocess/EffectComposer.ts +349 -0
  1290. package/src/postprocess/SSAOPass.ts +20 -0
  1291. package/src/postprocess/index.ts +34 -0
  1292. package/src/production-runtime/AnimationControlsPipeline.ts +77 -0
  1293. package/src/production-runtime/PBRHDRPipeline.ts +381 -0
  1294. package/src/production-runtime/ProductionEffectsPipeline.ts +85 -0
  1295. package/src/production-runtime/ProductionRendererTypes.ts +136 -0
  1296. package/src/production-runtime/ProductionRuntimeRenderer.ts +172 -0
  1297. package/src/production-runtime/ProductionWebGL2Renderer.ts +313 -0
  1298. package/src/production-runtime/ProductionWebGPURenderer.ts +396 -0
  1299. package/src/production-runtime/TransmissionBackdropCapture.ts +130 -0
  1300. package/src/production-runtime/animation/MorphTargetRenderer.ts +2 -0
  1301. package/src/production-runtime/animation/SkinningRenderer.ts +2 -0
  1302. package/src/production-runtime/backends/RendererBackend.ts +17 -0
  1303. package/src/production-runtime/backends/WebGL2RendererBackend.ts +30 -0
  1304. package/src/production-runtime/backends/WebGPURendererBackend.ts +24 -0
  1305. package/src/production-runtime/backends/webgl2/WebGL2Buffer.ts +2 -0
  1306. package/src/production-runtime/backends/webgl2/WebGL2Capabilities.ts +2 -0
  1307. package/src/production-runtime/backends/webgl2/WebGL2RenderTarget.ts +2 -0
  1308. package/src/production-runtime/backends/webgl2/WebGL2Shader.ts +2 -0
  1309. package/src/production-runtime/backends/webgl2/WebGL2StateCache.ts +1 -0
  1310. package/src/production-runtime/backends/webgl2/WebGL2Texture.ts +2 -0
  1311. package/src/production-runtime/backends/webgpu/WebGPUBuffer.ts +2 -0
  1312. package/src/production-runtime/backends/webgpu/WebGPUCapabilities.ts +2 -0
  1313. package/src/production-runtime/backends/webgpu/WebGPURenderTarget.ts +2 -0
  1314. package/src/production-runtime/backends/webgpu/WebGPUShader.ts +2 -0
  1315. package/src/production-runtime/backends/webgpu/WebGPUTexture.ts +2 -0
  1316. package/src/production-runtime/color/ColorManagement.ts +3 -0
  1317. package/src/production-runtime/color/ToneMapping.ts +7 -0
  1318. package/src/production-runtime/diagnostics/FrameCapture.ts +2 -0
  1319. package/src/production-runtime/diagnostics/GPUCapabilities.ts +2 -0
  1320. package/src/production-runtime/diagnostics/RendererStats.ts +2 -0
  1321. package/src/production-runtime/environment/EnvironmentMap.ts +1 -0
  1322. package/src/production-runtime/environment/HDRLoader.ts +57 -0
  1323. package/src/production-runtime/environment/PMREMGenerator.ts +713 -0
  1324. package/src/production-runtime/framegraph/FrameGraph.ts +18 -0
  1325. package/src/production-runtime/framegraph/RenderPass.ts +15 -0
  1326. package/src/production-runtime/geometry/ProjectedDecalGeometry.ts +439 -0
  1327. package/src/production-runtime/index.ts +127 -0
  1328. package/src/production-runtime/lights/LightManager.ts +7 -0
  1329. package/src/production-runtime/lights/ShadowMapRenderer.ts +5 -0
  1330. package/src/production-runtime/materials/GLTFMaterialAdapter.ts +6 -0
  1331. package/src/production-runtime/materials/GLTFPBRMaterialAdapter.ts +2 -0
  1332. package/src/production-runtime/materials/MaterialCompiler.ts +7 -0
  1333. package/src/production-runtime/materials/MaterialTextureBindings.ts +5 -0
  1334. package/src/production-runtime/materials/PBRMaterial.ts +2 -0
  1335. package/src/production-runtime/materials/PBRShaderFeatures.ts +2 -0
  1336. package/src/production-runtime/passes/ContactShadowPass.ts +184 -0
  1337. package/src/production-runtime/passes/DepthPrepass.ts +7 -0
  1338. package/src/production-runtime/passes/OpaquePass.ts +7 -0
  1339. package/src/production-runtime/passes/ShadowPass.ts +7 -0
  1340. package/src/production-runtime/passes/SkyboxPass.ts +7 -0
  1341. package/src/production-runtime/passes/ToneMappingPass.ts +7 -0
  1342. package/src/production-runtime/passes/TransparentPass.ts +7 -0
  1343. package/src/production-runtime/postprocess/BloomPass.ts +51 -0
  1344. package/src/production-runtime/postprocess/ColorGradingPass.ts +49 -0
  1345. package/src/production-runtime/postprocess/DOFPass.ts +47 -0
  1346. package/src/production-runtime/postprocess/FXAAPass.ts +53 -0
  1347. package/src/production-runtime/postprocess/ProductionEffectComposer.ts +78 -0
  1348. package/src/production-runtime/postprocess/ProductionPostProcessTypes.ts +174 -0
  1349. package/src/production-runtime/postprocess/SSAOPass.ts +45 -0
  1350. package/src/production-runtime/resources/GPUBuffer.ts +2 -0
  1351. package/src/production-runtime/resources/GPUTexture.ts +2 -0
  1352. package/src/production-runtime/resources/RenderTarget.ts +3 -0
  1353. package/src/production-runtime/resources/ResourceCache.ts +7 -0
  1354. package/src/production-runtime/scene/Camera.ts +1 -0
  1355. package/src/production-runtime/scene/Lights.ts +2 -0
  1356. package/src/production-runtime/scene/RenderableMesh.ts +2 -0
  1357. package/src/production-runtime/scene/RenderablePrimitive.ts +1 -0
  1358. package/src/production-runtime/scene/RenderableScene.ts +4 -0
  1359. package/src/production-runtime/shaders/ShaderProgramLibrary.ts +7 -0
  1360. package/src/production-runtime/shaders/chunks/brdf.glsl +2 -0
  1361. package/src/production-runtime/shaders/chunks/ibl.glsl +3 -0
  1362. package/src/production-runtime/shaders/chunks/pbr.frag.glsl +47 -0
  1363. package/src/production-runtime/shaders/chunks/pbr.vert.glsl +8 -0
  1364. package/src/production-runtime/shaders/chunks/shadows.glsl +2 -0
  1365. package/src/production-runtime/shaders/wgsl/pbr.wgsl +3 -0
  1366. package/src/production-runtime/shaders/wgsl/postprocess.wgsl +2 -0
  1367. package/src/production-runtime/shaders/wgsl/skybox.wgsl +2 -0
  1368. package/src/shaders/depth.frag.glsl +5 -0
  1369. package/src/shaders/depth.vert.glsl +8 -0
  1370. package/src/shaders/pbr-direct.frag.glsl +687 -0
  1371. package/src/shaders/pbr-direct.vert.glsl +18 -0
  1372. package/src/shaders/unlit.frag.glsl +18 -0
  1373. package/src/shaders/unlit.vert.glsl +13 -0
  1374. package/src/shadows/CascadedShadowPipeline.ts +53 -0
  1375. package/src/shadows/ContactShadows.ts +106 -0
  1376. package/src/shadows/ShadowDebugViews.ts +46 -0
  1377. package/src/threejs-compatibility/InstancingSystem.ts +17 -0
  1378. package/src/threejs-compatibility/LightingSystem.ts +22 -0
  1379. package/src/threejs-compatibility/MaterialSystem.ts +9 -0
  1380. package/src/threejs-compatibility/RenderTargetSystem.ts +35 -0
  1381. package/src/threejs-compatibility/RendererDiagnostics.ts +61 -0
  1382. package/src/threejs-compatibility/SceneRenderer.ts +34 -0
  1383. package/src/threejs-compatibility/ShadowSystem.ts +19 -0
  1384. package/src/threejs-compatibility/TextureSystem.ts +19 -0
  1385. package/src/threejs-compatibility/ThreeCompatRenderer.ts +90 -0
  1386. package/src/threejs-compatibility/TransparencySystem.ts +19 -0
  1387. package/src/threejs-compatibility/index.ts +29 -0
  1388. package/src/threejs-compatibility/performance/BVH.ts +14 -0
  1389. package/src/threejs-compatibility/performance/FrustumCulling.ts +10 -0
  1390. package/src/threejs-compatibility/performance/Instancing.ts +4 -0
  1391. package/src/threejs-compatibility/performance/LODSystem.ts +16 -0
  1392. package/src/threejs-compatibility/performance/OcclusionCulling.ts +6 -0
  1393. package/src/threejs-compatibility/performance/RaycastAcceleration.ts +12 -0
  1394. package/src/threejs-compatibility/performance/RendererProfiler.ts +19 -0
  1395. package/src/threejs-compatibility/performance/TextureStreaming.ts +4 -0
  1396. package/src/threejs-compatibility/performance/index.ts +12 -0
  1397. package/src/threejs-compatibility/postprocess/BloomPass.ts +16 -0
  1398. package/src/threejs-compatibility/postprocess/ColorGradingPass.ts +16 -0
  1399. package/src/threejs-compatibility/postprocess/DepthOfFieldPass.ts +21 -0
  1400. package/src/threejs-compatibility/postprocess/EffectComposer.ts +14 -0
  1401. package/src/threejs-compatibility/postprocess/FXAAPass.ts +15 -0
  1402. package/src/threejs-compatibility/postprocess/MotionBlurPass.ts +20 -0
  1403. package/src/threejs-compatibility/postprocess/OutlinePass.ts +21 -0
  1404. package/src/threejs-compatibility/postprocess/PostProcessTypes.ts +169 -0
  1405. package/src/threejs-compatibility/postprocess/RenderPass.ts +9 -0
  1406. package/src/threejs-compatibility/postprocess/SMAAPass.ts +15 -0
  1407. package/src/threejs-compatibility/postprocess/SSAOPass.ts +21 -0
  1408. package/src/threejs-compatibility/postprocess/ShaderPass.ts +7 -0
  1409. package/src/threejs-compatibility/postprocess/TAAPass.ts +15 -0
  1410. package/src/threejs-compatibility/postprocess/VignettePass.ts +16 -0
  1411. package/src/threejs-compatibility/postprocess/index.ts +15 -0
  1412. package/src/threejs-compatibility/shaders/NodeMaterial.ts +21 -0
  1413. package/src/threejs-compatibility/shaders/RawShaderMaterial.ts +6 -0
  1414. package/src/threejs-compatibility/shaders/ShaderDiagnostics.ts +17 -0
  1415. package/src/threejs-compatibility/shaders/ShaderMaterial.ts +18 -0
  1416. package/src/threejs-compatibility/shaders/ThreeCompatShaderChunks.ts +6 -0
  1417. package/src/threejs-compatibility/shaders/Uniforms.ts +18 -0
  1418. package/src/threejs-compatibility/shaders/index.ts +9 -0
  1419. package/src/threejs-compatibility/vfx/GPUPointCloud.ts +7 -0
  1420. package/src/threejs-compatibility/vfx/LineRenderer.ts +13 -0
  1421. package/src/threejs-compatibility/vfx/ParticleSystem.ts +23 -0
  1422. package/src/threejs-compatibility/vfx/SpriteSystem.ts +14 -0
  1423. package/src/threejs-compatibility/vfx/TrailRenderer.ts +8 -0
  1424. package/src/threejs-compatibility/vfx/VFXDiagnostics.ts +23 -0
  1425. package/src/threejs-compatibility/vfx/index.ts +9 -0
  1426. package/src/threejs-example-parity/index.ts +205 -0
  1427. package/src/webgpu/WebGPUBuffer.ts +1 -0
  1428. package/src/webgpu/WebGPUCompute.ts +2 -0
  1429. package/src/webgpu/WebGPUPipelineCache.ts +15 -0
  1430. package/src/webgpu/WebGPUPostProcess.ts +2 -0
  1431. package/src/webgpu/WebGPUTexture.ts +2 -0
  1432. package/tsconfig.json +26 -0
  1433. package/vitest.config.ts +20 -0
@@ -0,0 +1,2403 @@
1
+ import { RenderDeviceError, viewBytes } from "./RenderDevice.js";
2
+ import { reflectShaderSources } from "./ShaderReflection.js";
3
+ import { Texture, bytesPerPixel, isCompressedTextureFormat } from "./Texture.js";
4
+ import { TextureBinding } from "./TextureBinding.js";
5
+ import {} from "./VertexFormat.js";
6
+ const BUFFER_USAGE = {
7
+ MAP_READ: 0x0001,
8
+ COPY_SRC: 0x0004,
9
+ COPY_DST: 0x0008,
10
+ INDEX: 0x0010,
11
+ VERTEX: 0x0020,
12
+ UNIFORM: 0x0040
13
+ };
14
+ const MAP_MODE = {
15
+ READ: 0x0001
16
+ };
17
+ const TEXTURE_USAGE = {
18
+ RENDER_ATTACHMENT: 0x0010,
19
+ COPY_SRC: 0x0001,
20
+ COPY_DST: 0x0002,
21
+ TEXTURE_BINDING: 0x0004
22
+ };
23
+ const DEPTH_TEXTURE_FORMAT = "depth24plus";
24
+ class WebGPURenderBuffer {
25
+ id;
26
+ usage;
27
+ byteLength;
28
+ nativeByteLength;
29
+ handle;
30
+ disposed = false;
31
+ bytes;
32
+ constructor(id, usage, byteLength, nativeByteLength, handle, initialData) {
33
+ this.id = id;
34
+ this.usage = usage;
35
+ this.byteLength = byteLength;
36
+ this.nativeByteLength = nativeByteLength;
37
+ this.handle = handle;
38
+ this.bytes = new Uint8Array(byteLength);
39
+ if (initialData)
40
+ this.bytes.set(viewBytes(initialData), 0);
41
+ }
42
+ dispose() {
43
+ if (!this.disposed) {
44
+ this.handle.destroy();
45
+ this.disposed = true;
46
+ }
47
+ }
48
+ }
49
+ class WebGPUShaderProgram {
50
+ id;
51
+ label;
52
+ marker;
53
+ reflection;
54
+ modules;
55
+ entryPoints;
56
+ nativeUniformLayout;
57
+ disposed = false;
58
+ renderPipelines = new Map();
59
+ constructor(id, label, marker, reflection, modules, entryPoints, nativeUniformLayout) {
60
+ this.id = id;
61
+ this.label = label;
62
+ this.marker = marker;
63
+ this.reflection = reflection;
64
+ this.modules = modules;
65
+ this.entryPoints = entryPoints;
66
+ this.nativeUniformLayout = nativeUniformLayout;
67
+ }
68
+ dispose() {
69
+ this.disposed = true;
70
+ }
71
+ }
72
+ class WebGPURenderTarget {
73
+ id;
74
+ width;
75
+ height;
76
+ label;
77
+ colorTexture;
78
+ depthTexture;
79
+ nativeTexture;
80
+ nativeView;
81
+ nativeDepthTexture;
82
+ nativeDepthView;
83
+ hasDepth;
84
+ disposed = false;
85
+ nativeNeedsClear = true;
86
+ nativeClearColor = [0, 0, 0, 1];
87
+ colorPixels;
88
+ colorFloatPixels;
89
+ depthPixels;
90
+ constructor(id, width, height, label, colorTexture, depthTexture, nativeTexture, nativeView, nativeDepthTexture, nativeDepthView, hasDepth) {
91
+ this.id = id;
92
+ this.width = width;
93
+ this.height = height;
94
+ this.label = label;
95
+ this.colorTexture = colorTexture;
96
+ this.depthTexture = depthTexture;
97
+ this.nativeTexture = nativeTexture;
98
+ this.nativeView = nativeView;
99
+ this.nativeDepthTexture = nativeDepthTexture;
100
+ this.nativeDepthView = nativeDepthView;
101
+ this.hasDepth = hasDepth;
102
+ this.colorPixels = new Uint8Array(width * height * 4);
103
+ this.colorFloatPixels = colorTexture.format === "rgba16f" || colorTexture.format === "rgba32f"
104
+ ? new Float32Array(width * height * 4)
105
+ : null;
106
+ this.depthPixels = hasDepth ? new Float32Array(width * height).fill(1) : null;
107
+ }
108
+ dispose() {
109
+ if (!this.disposed) {
110
+ this.nativeTexture?.destroy();
111
+ this.nativeDepthTexture?.destroy();
112
+ this.colorTexture.dispose();
113
+ this.depthTexture?.dispose();
114
+ this.disposed = true;
115
+ }
116
+ }
117
+ }
118
+ export class WebGPUDevice {
119
+ adapter;
120
+ device;
121
+ canvasContext;
122
+ presentationFormat;
123
+ kind = "webgpu";
124
+ info;
125
+ disposed = false;
126
+ contextLost = false;
127
+ nextId = 1;
128
+ frameActive = false;
129
+ drawCalls = 0;
130
+ viewportWidth = 0;
131
+ viewportHeight = 0;
132
+ clearColor = [0, 0, 0, 1];
133
+ lastError = null;
134
+ nativeSubmissions = 0;
135
+ nativeTextureBindings = 0;
136
+ nativeGeneratedBasicSubmissions = 0;
137
+ nativeGeneratedTextureSubmissions = 0;
138
+ nativePassthroughSubmissions = 0;
139
+ nativePbrSubmissions = 0;
140
+ nativeInstancedSubmissions = 0;
141
+ nativeSkinnedSubmissions = 0;
142
+ nativeMorphSubmissions = 0;
143
+ nativeEnvironmentBindings = 0;
144
+ nativeShadowMapBindings = 0;
145
+ canvasSubmissions = 0;
146
+ buffers = new Set();
147
+ shaders = new Set();
148
+ renderTargets = new Set();
149
+ nativeSampledTextures = new Map();
150
+ activeRenderTarget = null;
151
+ backbufferPixels = null;
152
+ backbufferWidth = 0;
153
+ backbufferHeight = 0;
154
+ canvasDepthTexture = null;
155
+ canvasDepthView = null;
156
+ canvasDepthWidth = 0;
157
+ canvasDepthHeight = 0;
158
+ static async create(options = {}) {
159
+ const gpu = options.gpu ?? readWebGPU(globalThis);
160
+ const adapter = options.adapter ?? (await requestAdapter(gpu));
161
+ if (!adapter) {
162
+ throw new RenderDeviceError("WebGPU adapter request did not return a device owner", "WEBGPU_ADAPTER_MISSING");
163
+ }
164
+ const device = validateWebGPUDevice(await requestDevice(adapter, options.device));
165
+ const canvasContext = options.canvas ? acquireWebGPUCanvasContext(options.canvas) : null;
166
+ const presentationFormat = options.presentationFormat ?? gpu?.getPreferredCanvasFormat?.() ?? "bgra8unorm";
167
+ if (canvasContext) {
168
+ canvasContext.configure({
169
+ device,
170
+ format: presentationFormat,
171
+ alphaMode: "opaque"
172
+ });
173
+ }
174
+ return new WebGPUDevice(adapter, device, canvasContext, presentationFormat);
175
+ }
176
+ constructor(adapter, device, canvasContext, presentationFormat) {
177
+ this.adapter = adapter;
178
+ this.device = device;
179
+ this.canvasContext = canvasContext;
180
+ this.presentationFormat = presentationFormat;
181
+ const supportsNativeRenderPipeline = hasNativeRenderPipeline(device);
182
+ const supportsNativeTextureReadback = hasNativeTextureReadback(device);
183
+ const supportsCanvasSurface = supportsNativeRenderPipeline && canvasContext !== null;
184
+ this.info = {
185
+ backend: "webgpu",
186
+ vendor: adapter.info?.vendor ?? "webgpu",
187
+ renderer: describeAdapter(adapter) ?? "webgpu-render-device",
188
+ capabilities: [
189
+ "buffers",
190
+ "buffer-readback",
191
+ "shader-validation",
192
+ "render-targets",
193
+ "pixel-readback",
194
+ "postprocess-presentation",
195
+ "hdr-render-targets",
196
+ "float-readback",
197
+ "draw-validation",
198
+ "rasterization",
199
+ "depth-render-targets",
200
+ "spot-shadow-maps",
201
+ "point-shadow-maps",
202
+ "hdr-image-based-lighting",
203
+ ...(supportsNativeRenderPipeline ? ["native-render-pipeline"] : []),
204
+ ...(hasNativeSampledTextureBinding(device) ? ["native-sampled-textures"] : []),
205
+ ...(supportsNativeTextureReadback ? ["native-texture-readback"] : []),
206
+ ...(supportsCanvasSurface ? ["canvas-surface"] : [])
207
+ ],
208
+ limitations: [
209
+ "Synchronous readPixels remains CPU-shadowed for deterministic tests; use readPixelsAsync for native WebGPU texture-to-buffer readback when available.",
210
+ "Renderer.render() stays synchronous and uses CPU-shadowed readback for deterministic compatibility; use Renderer.renderAsync() when renderer-owned WebGPU postprocess must read native render targets.",
211
+ "Sampleable WebGPU depth render-target textures are not advertised until native texture binding and depth readback evidence exists.",
212
+ ...(supportsNativeRenderPipeline ? [] : ["native WebGPU render-pipeline submission requires createRenderPipeline, createTexture, and createCommandEncoder."]),
213
+ ...(hasNativeSampledTextureBinding(device) ? [] : ["native WebGPU sampled texture binding requires createSampler, createTexture, and queue.writeTexture."]),
214
+ ...(supportsNativeTextureReadback ? [] : ["native WebGPU texture readback requires copyTextureToBuffer plus mappable readback buffers."]),
215
+ ...(canvasContext ? [] : ["Canvas presentation requires a canvas that exposes a webgpu context."])
216
+ ]
217
+ };
218
+ this.observeDeviceLost();
219
+ }
220
+ createBuffer(usage, byteLength, initialData) {
221
+ this.assertAlive();
222
+ if (byteLength <= 0 || !Number.isInteger(byteLength)) {
223
+ throw new RenderDeviceError("Buffer byteLength must be a positive integer", "INVALID_BUFFER_SIZE", { byteLength });
224
+ }
225
+ if (initialData && initialData.byteLength > byteLength) {
226
+ throw new RenderDeviceError("Initial data exceeds buffer size", "BUFFER_OVERFLOW", {
227
+ byteLength,
228
+ dataByteLength: initialData.byteLength
229
+ });
230
+ }
231
+ const handle = this.device.createBuffer({
232
+ label: `aura3d-${usage}-${this.nextId}`,
233
+ size: alignTo(byteLength, 4),
234
+ usage: bufferUsageFlags(usage)
235
+ });
236
+ const buffer = new WebGPURenderBuffer(this.nextId++, usage, byteLength, alignTo(byteLength, 4), handle, initialData);
237
+ this.buffers.add(buffer);
238
+ if (initialData)
239
+ writeAlignedQueueBuffer(this.device.queue, handle, 0, initialData, buffer.nativeByteLength);
240
+ return buffer;
241
+ }
242
+ updateBuffer(buffer, byteOffset, data) {
243
+ this.assertAlive();
244
+ const webgpuBuffer = this.requireBuffer(buffer);
245
+ if (byteOffset < 0 || byteOffset + data.byteLength > webgpuBuffer.byteLength) {
246
+ throw new RenderDeviceError("Buffer update range is out of bounds", "BUFFER_RANGE_OUT_OF_BOUNDS", {
247
+ byteOffset,
248
+ dataByteLength: data.byteLength,
249
+ byteLength: webgpuBuffer.byteLength
250
+ });
251
+ }
252
+ webgpuBuffer.bytes.set(viewBytes(data), byteOffset);
253
+ writeAlignedQueueBuffer(this.device.queue, webgpuBuffer.handle, byteOffset, webgpuBuffer.bytes.subarray(byteOffset, byteOffset + data.byteLength), webgpuBuffer.nativeByteLength);
254
+ }
255
+ readBuffer(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
256
+ this.assertAlive();
257
+ const webgpuBuffer = this.requireBuffer(buffer);
258
+ if (byteOffset < 0 || byteLength < 0 || byteOffset + byteLength > webgpuBuffer.byteLength) {
259
+ throw new RenderDeviceError("Buffer read range is out of bounds", "BUFFER_RANGE_OUT_OF_BOUNDS", {
260
+ byteOffset,
261
+ byteLength,
262
+ bufferByteLength: webgpuBuffer.byteLength
263
+ });
264
+ }
265
+ return webgpuBuffer.bytes.slice(byteOffset, byteOffset + byteLength);
266
+ }
267
+ createShaderProgram(sources) {
268
+ this.assertAlive();
269
+ if (!sources.vertex.includes(sources.marker) || !sources.fragment.includes(sources.marker)) {
270
+ throw new RenderDeviceError("Shader source marker is missing from compiled sources", "SHADER_MARKER_MISSING", {
271
+ label: sources.label,
272
+ marker: sources.marker
273
+ });
274
+ }
275
+ const nativeSources = createNativeShaderSources(sources);
276
+ const modules = this.device.createShaderModule
277
+ ? [
278
+ this.device.createShaderModule({ label: `${sources.label}-vertex`, code: nativeSources.vertex }),
279
+ this.device.createShaderModule({ label: `${sources.label}-fragment`, code: nativeSources.fragment })
280
+ ]
281
+ : [];
282
+ const shader = new WebGPUShaderProgram(this.nextId++, sources.label, sources.marker, reflectShaderSources(sources), modules, nativeSources.entryPoints, nativeSources.uniformLayout);
283
+ this.shaders.add(shader);
284
+ return shader;
285
+ }
286
+ createRenderTarget(descriptor) {
287
+ this.assertAlive();
288
+ if (!Number.isInteger(descriptor.width) ||
289
+ descriptor.width <= 0 ||
290
+ !Number.isInteger(descriptor.height) ||
291
+ descriptor.height <= 0) {
292
+ throw new RenderDeviceError("Render target dimensions must be positive integers", "INVALID_RENDER_TARGET_SIZE", {
293
+ width: descriptor.width,
294
+ height: descriptor.height,
295
+ label: descriptor.label
296
+ });
297
+ }
298
+ const nativeTexture = this.device.createTexture?.({
299
+ label: descriptor.label ?? "aura3d-webgpu-render-target",
300
+ size: [descriptor.width, descriptor.height],
301
+ format: webgpuTextureFormat(descriptor.format ?? "rgba8"),
302
+ usage: TEXTURE_USAGE.RENDER_ATTACHMENT | TEXTURE_USAGE.COPY_SRC | TEXTURE_USAGE.COPY_DST | TEXTURE_USAGE.TEXTURE_BINDING
303
+ }) ?? null;
304
+ const hasDepth = descriptor.depth !== false;
305
+ const hasSampleableDepth = descriptor.depth === "texture";
306
+ const nativeDepthTexture = hasDepth
307
+ ? this.device.createTexture?.({
308
+ label: `${descriptor.label ?? "aura3d-webgpu-render-target"}-depth`,
309
+ size: [descriptor.width, descriptor.height],
310
+ format: DEPTH_TEXTURE_FORMAT,
311
+ usage: TEXTURE_USAGE.RENDER_ATTACHMENT | (hasSampleableDepth ? TEXTURE_USAGE.TEXTURE_BINDING : 0)
312
+ }) ?? null
313
+ : null;
314
+ const depthTexture = hasSampleableDepth
315
+ ? new Texture({ width: descriptor.width, height: descriptor.height, format: "depth24", label: `${descriptor.label ?? "render-target"}-depth` })
316
+ : undefined;
317
+ const target = new WebGPURenderTarget(this.nextId++, descriptor.width, descriptor.height, descriptor.label ?? "render-target", new Texture({ width: descriptor.width, height: descriptor.height, format: descriptor.format ?? "rgba8", label: descriptor.label ?? "render-target-color" }), depthTexture, nativeTexture, nativeTexture?.createView() ?? null, nativeDepthTexture, nativeDepthTexture?.createView() ?? null, hasDepth);
318
+ this.renderTargets.add(target);
319
+ return target;
320
+ }
321
+ setRenderTarget(target) {
322
+ this.assertAlive();
323
+ if (target === null) {
324
+ this.activeRenderTarget = null;
325
+ return;
326
+ }
327
+ if (!(target instanceof WebGPURenderTarget) || !this.renderTargets.has(target) || target.disposed) {
328
+ throw new RenderDeviceError("Render target is not a live WebGPU resource owned by this device", "INVALID_RESOURCE", {
329
+ targetId: target.id
330
+ });
331
+ }
332
+ this.activeRenderTarget = target;
333
+ }
334
+ writeRenderTargetPixels(target, pixels) {
335
+ this.assertAlive();
336
+ const webgpuTarget = this.requireRenderTarget(target);
337
+ const expectedLength = webgpuTarget.width * webgpuTarget.height * 4;
338
+ if (pixels.length !== expectedLength) {
339
+ throw new RenderDeviceError("Render target pixel upload length does not match target dimensions", "INVALID_RENDER_TARGET_PIXELS", {
340
+ targetId: target.id,
341
+ expectedLength,
342
+ actualLength: pixels.length
343
+ });
344
+ }
345
+ webgpuTarget.colorPixels.set(pixels);
346
+ if (webgpuTarget.colorFloatPixels) {
347
+ for (let index = 0; index < pixels.length; index += 1) {
348
+ webgpuTarget.colorFloatPixels[index] = pixels[index] / 255;
349
+ }
350
+ }
351
+ if (webgpuTarget.nativeTexture && webgpuTarget.colorTexture.format === "rgba8" && hasNativeTextureUpload(this.device)) {
352
+ this.device.queue.writeTexture({ texture: webgpuTarget.nativeTexture }, pixels, { bytesPerRow: webgpuTarget.width * 4, rowsPerImage: webgpuTarget.height }, { width: webgpuTarget.width, height: webgpuTarget.height, depthOrArrayLayers: 1 });
353
+ webgpuTarget.nativeNeedsClear = false;
354
+ }
355
+ }
356
+ presentRenderTarget(source) {
357
+ this.assertAlive();
358
+ const target = this.requireRenderTarget(source);
359
+ if (target.colorTexture.format !== "rgba8") {
360
+ throw new RenderDeviceError("WebGPU backbuffer presentation currently requires rgba8 source pixels", "PRESENT_FORMAT_UNSUPPORTED", {
361
+ source: source.label,
362
+ format: target.colorTexture.format
363
+ });
364
+ }
365
+ this.backbufferPixels = target.colorPixels.slice();
366
+ this.backbufferWidth = target.width;
367
+ this.backbufferHeight = target.height;
368
+ this.activeRenderTarget = null;
369
+ this.canvasSubmissions += 1;
370
+ }
371
+ readPixels(x, y, width, height) {
372
+ this.assertAlive();
373
+ if (![x, y, width, height].every(Number.isInteger) || x < 0 || y < 0 || width <= 0 || height <= 0) {
374
+ throw new RenderDeviceError("Readback rectangle must be positive and in bounds", "INVALID_READBACK_RECT", { x, y, width, height });
375
+ }
376
+ const boundsWidth = this.activeRenderTarget?.width ?? (this.backbufferPixels ? this.backbufferWidth : this.viewportWidth);
377
+ const boundsHeight = this.activeRenderTarget?.height ?? (this.backbufferPixels ? this.backbufferHeight : this.viewportHeight);
378
+ if (x + width > boundsWidth || y + height > boundsHeight) {
379
+ throw new RenderDeviceError("Readback rectangle exceeds framebuffer bounds", "READBACK_OUT_OF_BOUNDS", {
380
+ x,
381
+ y,
382
+ width,
383
+ height,
384
+ boundsWidth,
385
+ boundsHeight
386
+ });
387
+ }
388
+ const output = new Uint8Array(width * height * 4);
389
+ const target = this.activeRenderTarget;
390
+ if (!target) {
391
+ if (this.backbufferPixels) {
392
+ for (let row = 0; row < height; row += 1) {
393
+ const sourceOffset = ((y + row) * this.backbufferWidth + x) * 4;
394
+ const destOffset = row * width * 4;
395
+ output.set(this.backbufferPixels.subarray(sourceOffset, sourceOffset + width * 4), destOffset);
396
+ }
397
+ return output;
398
+ }
399
+ const bytes = rgbaBytes(this.clearColor);
400
+ for (let index = 0; index < output.length; index += 4)
401
+ output.set(bytes, index);
402
+ return output;
403
+ }
404
+ for (let row = 0; row < height; row += 1) {
405
+ const sourceOffset = ((y + row) * target.width + x) * 4;
406
+ const destOffset = row * width * 4;
407
+ output.set(target.colorPixels.subarray(sourceOffset, sourceOffset + width * 4), destOffset);
408
+ }
409
+ return output;
410
+ }
411
+ async readPixelsAsync(x, y, width, height) {
412
+ this.assertAlive();
413
+ if (![x, y, width, height].every(Number.isInteger) || x < 0 || y < 0 || width <= 0 || height <= 0) {
414
+ throw new RenderDeviceError("Readback rectangle must be positive and in bounds", "INVALID_READBACK_RECT", { x, y, width, height });
415
+ }
416
+ const target = this.activeRenderTarget;
417
+ if (!target || !target.nativeTexture) {
418
+ throw new RenderDeviceError("Native WebGPU readback requires an active native render target", "NATIVE_READBACK_TARGET_MISSING", {
419
+ x,
420
+ y,
421
+ width,
422
+ height,
423
+ renderTarget: target?.label ?? null
424
+ });
425
+ }
426
+ if (target.colorTexture.format !== "rgba8") {
427
+ throw new RenderDeviceError("Native WebGPU readback currently supports rgba8 render targets", "NATIVE_READBACK_FORMAT_UNSUPPORTED", {
428
+ format: target.colorTexture.format,
429
+ renderTarget: target.label
430
+ });
431
+ }
432
+ if (x + width > target.width || y + height > target.height) {
433
+ throw new RenderDeviceError("Readback rectangle exceeds framebuffer bounds", "READBACK_OUT_OF_BOUNDS", {
434
+ x,
435
+ y,
436
+ width,
437
+ height,
438
+ boundsWidth: target.width,
439
+ boundsHeight: target.height
440
+ });
441
+ }
442
+ if (!hasNativeTextureReadback(this.device)) {
443
+ throw new RenderDeviceError("WebGPU device does not expose native texture-to-buffer readback", "NATIVE_READBACK_UNSUPPORTED");
444
+ }
445
+ this.flushNativeRenderTargetClear(target);
446
+ const bytesPerPixel = 4;
447
+ const unpaddedBytesPerRow = width * bytesPerPixel;
448
+ const bytesPerRow = alignTo(unpaddedBytesPerRow, 256);
449
+ const bufferSize = bytesPerRow * height;
450
+ const readback = this.device.createBuffer({
451
+ label: `${target.label}-native-readback`,
452
+ size: bufferSize,
453
+ usage: BUFFER_USAGE.MAP_READ | BUFFER_USAGE.COPY_DST
454
+ });
455
+ const encoder = this.device.createCommandEncoder({ label: `${target.label}-native-readback-encoder` });
456
+ const copyTextureToBuffer = encoder.copyTextureToBuffer;
457
+ if (!copyTextureToBuffer) {
458
+ readback.destroy();
459
+ throw new RenderDeviceError("WebGPU command encoder does not expose texture-to-buffer copy", "NATIVE_READBACK_UNSUPPORTED");
460
+ }
461
+ copyTextureToBuffer.call(encoder, { texture: target.nativeTexture, origin: { x, y, z: 0 } }, { buffer: readback, bytesPerRow, rowsPerImage: height }, { width, height, depthOrArrayLayers: 1 });
462
+ this.device.queue.submit([encoder.finish()]);
463
+ try {
464
+ const mapAsync = readback.mapAsync;
465
+ const getMappedRange = readback.getMappedRange;
466
+ const unmap = readback.unmap;
467
+ if (!mapAsync || !getMappedRange || !unmap) {
468
+ throw new RenderDeviceError("WebGPU readback buffer does not expose mapped readback APIs", "NATIVE_READBACK_UNSUPPORTED");
469
+ }
470
+ await mapAsync.call(readback, MAP_MODE.READ);
471
+ const mapped = new Uint8Array(getMappedRange.call(readback));
472
+ const output = new Uint8Array(width * height * bytesPerPixel);
473
+ for (let row = 0; row < height; row += 1) {
474
+ const sourceOffset = row * bytesPerRow;
475
+ const destOffset = (height - 1 - row) * unpaddedBytesPerRow;
476
+ output.set(mapped.subarray(sourceOffset, sourceOffset + unpaddedBytesPerRow), destOffset);
477
+ }
478
+ unmap.call(readback);
479
+ return output;
480
+ }
481
+ finally {
482
+ readback.destroy();
483
+ }
484
+ }
485
+ async readFloatPixelsAsync(x, y, width, height) {
486
+ this.assertAlive();
487
+ if (![x, y, width, height].every(Number.isInteger) || x < 0 || y < 0 || width <= 0 || height <= 0) {
488
+ throw new RenderDeviceError("Float readback rectangle must be positive and in bounds", "INVALID_READBACK_RECT", { x, y, width, height });
489
+ }
490
+ const target = this.activeRenderTarget;
491
+ if (!target || !target.nativeTexture) {
492
+ throw new RenderDeviceError("Native WebGPU float readback requires an active native render target", "NATIVE_READBACK_TARGET_MISSING", {
493
+ x,
494
+ y,
495
+ width,
496
+ height,
497
+ renderTarget: target?.label ?? null
498
+ });
499
+ }
500
+ if (x + width > target.width || y + height > target.height) {
501
+ throw new RenderDeviceError("Float readback rectangle exceeds framebuffer bounds", "READBACK_OUT_OF_BOUNDS", {
502
+ x,
503
+ y,
504
+ width,
505
+ height,
506
+ boundsWidth: target.width,
507
+ boundsHeight: target.height
508
+ });
509
+ }
510
+ if (!hasNativeTextureReadback(this.device)) {
511
+ throw new RenderDeviceError("WebGPU device does not expose native texture-to-buffer readback", "NATIVE_READBACK_UNSUPPORTED");
512
+ }
513
+ this.flushNativeRenderTargetClear(target);
514
+ const format = target.colorTexture.format;
515
+ const bytesPerPixel = format === "rgba32f" ? 16 : format === "rgba16f" ? 8 : 4;
516
+ const unpaddedBytesPerRow = width * bytesPerPixel;
517
+ const bytesPerRow = alignTo(unpaddedBytesPerRow, 256);
518
+ const bufferSize = bytesPerRow * height;
519
+ const readback = this.device.createBuffer({
520
+ label: `${target.label}-native-float-readback`,
521
+ size: bufferSize,
522
+ usage: BUFFER_USAGE.MAP_READ | BUFFER_USAGE.COPY_DST
523
+ });
524
+ const encoder = this.device.createCommandEncoder({ label: `${target.label}-native-float-readback-encoder` });
525
+ const copyTextureToBuffer = encoder.copyTextureToBuffer;
526
+ if (!copyTextureToBuffer) {
527
+ readback.destroy();
528
+ throw new RenderDeviceError("WebGPU command encoder does not expose texture-to-buffer copy", "NATIVE_READBACK_UNSUPPORTED");
529
+ }
530
+ copyTextureToBuffer.call(encoder, { texture: target.nativeTexture, origin: { x, y, z: 0 } }, { buffer: readback, bytesPerRow, rowsPerImage: height }, { width, height, depthOrArrayLayers: 1 });
531
+ this.device.queue.submit([encoder.finish()]);
532
+ try {
533
+ const mapAsync = readback.mapAsync;
534
+ const getMappedRange = readback.getMappedRange;
535
+ const unmap = readback.unmap;
536
+ if (!mapAsync || !getMappedRange || !unmap) {
537
+ throw new RenderDeviceError("WebGPU readback buffer does not expose mapped readback APIs", "NATIVE_READBACK_UNSUPPORTED");
538
+ }
539
+ await mapAsync.call(readback, MAP_MODE.READ);
540
+ const mapped = new Uint8Array(getMappedRange.call(readback));
541
+ const view = new DataView(mapped.buffer, mapped.byteOffset, mapped.byteLength);
542
+ const output = new Float32Array(width * height * 4);
543
+ for (let row = 0; row < height; row += 1) {
544
+ const destRow = height - 1 - row;
545
+ for (let column = 0; column < width; column += 1) {
546
+ const sourceOffset = row * bytesPerRow + column * bytesPerPixel;
547
+ const destOffset = (destRow * width + column) * 4;
548
+ if (format === "rgba32f") {
549
+ output[destOffset] = view.getFloat32(sourceOffset, true);
550
+ output[destOffset + 1] = view.getFloat32(sourceOffset + 4, true);
551
+ output[destOffset + 2] = view.getFloat32(sourceOffset + 8, true);
552
+ output[destOffset + 3] = view.getFloat32(sourceOffset + 12, true);
553
+ }
554
+ else if (format === "rgba16f") {
555
+ output[destOffset] = halfFloatToNumber(view.getUint16(sourceOffset, true));
556
+ output[destOffset + 1] = halfFloatToNumber(view.getUint16(sourceOffset + 2, true));
557
+ output[destOffset + 2] = halfFloatToNumber(view.getUint16(sourceOffset + 4, true));
558
+ output[destOffset + 3] = halfFloatToNumber(view.getUint16(sourceOffset + 6, true));
559
+ }
560
+ else {
561
+ output[destOffset] = (mapped[sourceOffset] ?? 0) / 255;
562
+ output[destOffset + 1] = (mapped[sourceOffset + 1] ?? 0) / 255;
563
+ output[destOffset + 2] = (mapped[sourceOffset + 2] ?? 0) / 255;
564
+ output[destOffset + 3] = (mapped[sourceOffset + 3] ?? 0) / 255;
565
+ }
566
+ }
567
+ }
568
+ unmap.call(readback);
569
+ return output;
570
+ }
571
+ finally {
572
+ readback.destroy();
573
+ }
574
+ }
575
+ readFloatPixels(x, y, width, height) {
576
+ this.assertAlive();
577
+ if (![x, y, width, height].every(Number.isInteger) || x < 0 || y < 0 || width <= 0 || height <= 0) {
578
+ throw new RenderDeviceError("Float readback rectangle must be positive and in bounds", "INVALID_READBACK_RECT", { x, y, width, height });
579
+ }
580
+ const boundsWidth = this.activeRenderTarget?.width ?? (this.backbufferPixels ? this.backbufferWidth : this.viewportWidth);
581
+ const boundsHeight = this.activeRenderTarget?.height ?? (this.backbufferPixels ? this.backbufferHeight : this.viewportHeight);
582
+ if (x + width > boundsWidth || y + height > boundsHeight) {
583
+ throw new RenderDeviceError("Float readback rectangle exceeds framebuffer bounds", "READBACK_OUT_OF_BOUNDS", {
584
+ x,
585
+ y,
586
+ width,
587
+ height,
588
+ boundsWidth,
589
+ boundsHeight
590
+ });
591
+ }
592
+ const output = new Float32Array(width * height * 4);
593
+ const target = this.activeRenderTarget;
594
+ if (!target) {
595
+ if (this.backbufferPixels) {
596
+ const bytes = this.readPixels(x, y, width, height);
597
+ for (let index = 0; index < bytes.length; index += 1)
598
+ output[index] = bytes[index] / 255;
599
+ return output;
600
+ }
601
+ for (let index = 0; index < output.length; index += 4) {
602
+ output[index] = this.clearColor[0];
603
+ output[index + 1] = this.clearColor[1];
604
+ output[index + 2] = this.clearColor[2];
605
+ output[index + 3] = this.clearColor[3];
606
+ }
607
+ return output;
608
+ }
609
+ if (target.colorFloatPixels) {
610
+ for (let row = 0; row < height; row += 1) {
611
+ const sourceOffset = ((y + row) * target.width + x) * 4;
612
+ const destOffset = row * width * 4;
613
+ output.set(target.colorFloatPixels.subarray(sourceOffset, sourceOffset + width * 4), destOffset);
614
+ }
615
+ return output;
616
+ }
617
+ const bytes = this.readPixels(x, y, width, height);
618
+ for (let index = 0; index < bytes.length; index += 1)
619
+ output[index] = bytes[index] / 255;
620
+ return output;
621
+ }
622
+ beginFrame(width, height) {
623
+ this.assertAlive();
624
+ if (this.frameActive) {
625
+ throw new RenderDeviceError("Frame is already active", "FRAME_ALREADY_ACTIVE");
626
+ }
627
+ if (width <= 0 || height <= 0) {
628
+ throw new RenderDeviceError("Frame dimensions must be positive", "INVALID_FRAME_SIZE", { width, height });
629
+ }
630
+ this.frameActive = true;
631
+ this.drawCalls = 0;
632
+ this.lastError = null;
633
+ this.viewportWidth = width;
634
+ this.viewportHeight = height;
635
+ this.ensureCanvasDepthAttachment(width, height);
636
+ }
637
+ clear(color) {
638
+ this.assertFrame();
639
+ this.clearColor = color;
640
+ if (this.activeRenderTarget) {
641
+ this.clearActiveRenderTarget(color);
642
+ }
643
+ }
644
+ clearRenderTarget(color) {
645
+ this.assertFrame();
646
+ if (!this.activeRenderTarget) {
647
+ this.clearColor = color;
648
+ return;
649
+ }
650
+ this.clearActiveRenderTarget(color);
651
+ }
652
+ draw(command) {
653
+ this.assertFrame();
654
+ const vertexBuffer = this.requireBuffer(command.vertexBuffer);
655
+ if (vertexBuffer.disposed) {
656
+ throw new RenderDeviceError("Cannot draw with a disposed vertex buffer", "DISPOSED_RESOURCE", {
657
+ bufferId: command.vertexBuffer.id
658
+ });
659
+ }
660
+ if (command.indexBuffer) {
661
+ const indexBuffer = this.requireBuffer(command.indexBuffer);
662
+ if (indexBuffer.disposed) {
663
+ throw new RenderDeviceError("Cannot draw with a disposed index buffer", "DISPOSED_RESOURCE", {
664
+ bufferId: command.indexBuffer.id
665
+ });
666
+ }
667
+ }
668
+ if (command.shader)
669
+ this.requireShader(command.shader);
670
+ if (command.vertexCount <= 0) {
671
+ throw new RenderDeviceError("Draw command must have a positive vertex count", "INVALID_DRAW_COMMAND", {
672
+ vertexCount: command.vertexCount,
673
+ label: command.label
674
+ });
675
+ }
676
+ if (command.firstVertex !== undefined && (!Number.isInteger(command.firstVertex) || command.firstVertex < 0)) {
677
+ throw new RenderDeviceError("Draw command firstVertex must be a non-negative integer", "INVALID_DRAW_COMMAND", {
678
+ firstVertex: command.firstVertex,
679
+ label: command.label
680
+ });
681
+ }
682
+ if (command.indexBuffer && (command.indexCount === undefined || command.indexCount <= 0)) {
683
+ throw new RenderDeviceError("Indexed draw command must have a positive index count", "INVALID_DRAW_COMMAND", {
684
+ indexCount: command.indexCount,
685
+ label: command.label
686
+ });
687
+ }
688
+ if (command.firstIndex !== undefined && (!Number.isInteger(command.firstIndex) || command.firstIndex < 0)) {
689
+ throw new RenderDeviceError("Draw command firstIndex must be a non-negative integer", "INVALID_DRAW_COMMAND", {
690
+ firstIndex: command.firstIndex,
691
+ label: command.label
692
+ });
693
+ }
694
+ if (command.instanceCount !== undefined && (!Number.isInteger(command.instanceCount) || command.instanceCount <= 0)) {
695
+ throw new RenderDeviceError("Draw command instanceCount must be a positive integer", "INVALID_DRAW_COMMAND", {
696
+ instanceCount: command.instanceCount,
697
+ label: command.label
698
+ });
699
+ }
700
+ this.submitNativeRenderPass(command, vertexBuffer);
701
+ this.rasterizeDraw(command, vertexBuffer);
702
+ this.drawCalls += 1;
703
+ }
704
+ endFrame() {
705
+ this.assertFrame();
706
+ this.frameActive = false;
707
+ this.device.queue.submit([]);
708
+ }
709
+ captureState() {
710
+ return new Map([
711
+ ["backend", this.kind],
712
+ ["disposed", this.disposed],
713
+ ["contextLost", this.contextLost],
714
+ ["frameActive", this.frameActive],
715
+ ["viewportWidth", this.viewportWidth],
716
+ ["viewportHeight", this.viewportHeight],
717
+ ["renderTarget", this.activeRenderTarget?.label ?? null],
718
+ ["presentationFormat", this.presentationFormat],
719
+ ["drawCalls", this.drawCalls],
720
+ ["nativeSubmissions", this.nativeSubmissions],
721
+ ["nativeTextureBindings", this.nativeTextureBindings],
722
+ ["nativeGeneratedBasicSubmissions", this.nativeGeneratedBasicSubmissions],
723
+ ["nativeGeneratedTextureSubmissions", this.nativeGeneratedTextureSubmissions],
724
+ ["nativePassthroughSubmissions", this.nativePassthroughSubmissions],
725
+ ["nativePbrSubmissions", this.nativePbrSubmissions],
726
+ ["nativeInstancedSubmissions", this.nativeInstancedSubmissions],
727
+ ["nativeSkinnedSubmissions", this.nativeSkinnedSubmissions],
728
+ ["nativeMorphSubmissions", this.nativeMorphSubmissions],
729
+ ["nativeEnvironmentBindings", this.nativeEnvironmentBindings],
730
+ ["nativeShadowMapBindings", this.nativeShadowMapBindings],
731
+ ["canvasSubmissions", this.canvasSubmissions]
732
+ ]);
733
+ }
734
+ getDiagnostics() {
735
+ const liveRenderTargets = [...this.renderTargets].filter((target) => !target.disposed);
736
+ const bufferBytes = [...this.buffers].filter((buffer) => !buffer.disposed).reduce((total, buffer) => total + buffer.byteLength, 0);
737
+ const textureBytes = liveRenderTargets.reduce((total, target) => total + target.colorTexture.byteLength + (target.depthTexture?.byteLength ?? 0), 0);
738
+ return {
739
+ drawCalls: this.drawCalls,
740
+ buffers: [...this.buffers].filter((buffer) => !buffer.disposed).length,
741
+ shaders: [...this.shaders].filter((shader) => !shader.disposed).length,
742
+ renderTargets: liveRenderTargets.length,
743
+ textures: liveRenderTargets.length,
744
+ bufferBytes,
745
+ textureBytes,
746
+ approximateGpuMemoryBytes: bufferBytes + textureBytes,
747
+ compressedTextures: 0,
748
+ compressedTextureBytes: 0,
749
+ textureFallbacks: 0,
750
+ textureFallbackBytes: 0,
751
+ disposedBuffers: [...this.buffers].filter((buffer) => buffer.disposed).length,
752
+ disposedShaders: [...this.shaders].filter((shader) => shader.disposed).length,
753
+ disposedRenderTargets: [...this.renderTargets].filter((target) => target.disposed).length,
754
+ disposedTextures: [...this.renderTargets].reduce((total, target) => total + (target.colorTexture.disposed ? 1 : 0) + (target.depthTexture?.disposed ? 1 : 0), 0),
755
+ nativeSubmissions: this.nativeSubmissions,
756
+ nativeTextureBindings: this.nativeTextureBindings,
757
+ nativeGeneratedBasicSubmissions: this.nativeGeneratedBasicSubmissions,
758
+ nativeGeneratedTextureSubmissions: this.nativeGeneratedTextureSubmissions,
759
+ nativePassthroughSubmissions: this.nativePassthroughSubmissions,
760
+ nativePbrSubmissions: this.nativePbrSubmissions,
761
+ nativeInstancedSubmissions: this.nativeInstancedSubmissions,
762
+ nativeSkinnedSubmissions: this.nativeSkinnedSubmissions,
763
+ nativeMorphSubmissions: this.nativeMorphSubmissions,
764
+ nativeEnvironmentBindings: this.nativeEnvironmentBindings,
765
+ nativeShadowMapBindings: this.nativeShadowMapBindings,
766
+ lastError: this.lastError,
767
+ contextLost: this.contextLost
768
+ };
769
+ }
770
+ dispose() {
771
+ if (this.disposed)
772
+ return;
773
+ for (const buffer of this.buffers)
774
+ buffer.dispose();
775
+ for (const shader of this.shaders)
776
+ shader.dispose();
777
+ for (const target of this.renderTargets)
778
+ target.dispose();
779
+ for (const resource of this.nativeSampledTextures.values())
780
+ resource.texture.destroy();
781
+ this.nativeSampledTextures.clear();
782
+ this.canvasDepthTexture?.destroy();
783
+ this.canvasDepthTexture = null;
784
+ this.canvasDepthView = null;
785
+ this.canvasContext?.unconfigure?.();
786
+ this.device.destroy?.();
787
+ this.frameActive = false;
788
+ this.disposed = true;
789
+ }
790
+ assertAlive() {
791
+ if (this.disposed) {
792
+ throw new RenderDeviceError("Render device is disposed", "DISPOSED_DEVICE");
793
+ }
794
+ if (this.contextLost) {
795
+ throw new RenderDeviceError("Render context is lost", "CONTEXT_LOST");
796
+ }
797
+ }
798
+ assertFrame() {
799
+ this.assertAlive();
800
+ if (!this.frameActive) {
801
+ throw new RenderDeviceError("No active frame", "NO_ACTIVE_FRAME");
802
+ }
803
+ }
804
+ observeDeviceLost() {
805
+ const lost = this.device.lost;
806
+ if (!lost || typeof lost.then !== "function")
807
+ return;
808
+ void lost.then((info) => {
809
+ if (this.disposed)
810
+ return;
811
+ this.contextLost = true;
812
+ const detail = [info.reason, info.message].filter(Boolean).join(": ");
813
+ this.lastError = detail ? `WebGPU device lost: ${detail}` : "WebGPU device lost";
814
+ }).catch((error) => {
815
+ if (this.disposed)
816
+ return;
817
+ this.contextLost = true;
818
+ this.lastError = `WebGPU device lost promise rejected: ${error instanceof Error ? error.message : String(error)}`;
819
+ });
820
+ }
821
+ requireBuffer(buffer) {
822
+ if (!(buffer instanceof WebGPURenderBuffer) || !this.buffers.has(buffer)) {
823
+ throw new RenderDeviceError("Buffer was not created by this WebGPU device", "FOREIGN_RESOURCE", {
824
+ bufferId: buffer.id
825
+ });
826
+ }
827
+ if (buffer.disposed) {
828
+ throw new RenderDeviceError("Cannot use a disposed buffer", "DISPOSED_RESOURCE", { bufferId: buffer.id });
829
+ }
830
+ return buffer;
831
+ }
832
+ requireShader(shader) {
833
+ if (!(shader instanceof WebGPUShaderProgram) || !this.shaders.has(shader)) {
834
+ throw new RenderDeviceError("Shader was not created by this WebGPU device", "FOREIGN_RESOURCE", {
835
+ shaderId: shader.id
836
+ });
837
+ }
838
+ if (shader.disposed) {
839
+ throw new RenderDeviceError("Cannot use a disposed shader", "DISPOSED_RESOURCE", { shaderId: shader.id });
840
+ }
841
+ return shader;
842
+ }
843
+ requireRenderTarget(target) {
844
+ if (!(target instanceof WebGPURenderTarget) || !this.renderTargets.has(target)) {
845
+ throw new RenderDeviceError("Render target was not created by this WebGPU device", "FOREIGN_RESOURCE", {
846
+ targetId: target.id
847
+ });
848
+ }
849
+ if (target.disposed) {
850
+ throw new RenderDeviceError("Cannot use a disposed render target", "DISPOSED_RESOURCE", { targetId: target.id });
851
+ }
852
+ return target;
853
+ }
854
+ rasterizeDraw(command, vertexBuffer) {
855
+ if (!this.activeRenderTarget || !command.vertexFormat?.hasAttribute("position"))
856
+ return;
857
+ const position = command.vertexFormat.getAttribute("position");
858
+ const colorAttribute = command.vertexFormat.hasAttribute("color") ? command.vertexFormat.getAttribute("color") : null;
859
+ const uvAttribute = command.vertexFormat.hasAttribute("uv") ? command.vertexFormat.getAttribute("uv") : null;
860
+ if (position.components < 2)
861
+ return;
862
+ const indices = this.indicesFor(command);
863
+ const color = uniformColor(command.uniforms);
864
+ const texture = uniformBaseColorTextureBinding(command.uniforms);
865
+ const shadow = uniformForwardShadow(command.uniforms);
866
+ const instanceMatrices = uniformRasterMatrices(command.uniforms, command.instanceCount ?? 1);
867
+ const modelMatrices = uniformRasterModelMatrices(command.uniforms, command.instanceCount ?? 1);
868
+ const depthTest = command.renderState?.depthTest !== false && this.activeRenderTarget.depthPixels !== null;
869
+ const depthWrite = command.renderState?.depthWrite !== false;
870
+ for (let instanceIndex = 0; instanceIndex < instanceMatrices.length; instanceIndex += 1) {
871
+ const matrix = instanceMatrices[instanceIndex] ?? identityMatrix();
872
+ const modelMatrix = modelMatrices[instanceIndex] ?? identityMatrix();
873
+ if (command.topology === "triangles") {
874
+ for (let offset = 0; offset + 2 < indices.length; offset += 3) {
875
+ const indexA = indices[offset];
876
+ const indexB = indices[offset + 1];
877
+ const indexC = indices[offset + 2];
878
+ const localA = readMorphedPosition(vertexBuffer.bytes, command.vertexFormat.stride, position.offset, indexA, command.uniforms);
879
+ const localB = readMorphedPosition(vertexBuffer.bytes, command.vertexFormat.stride, position.offset, indexB, command.uniforms);
880
+ const localC = readMorphedPosition(vertexBuffer.bytes, command.vertexFormat.stride, position.offset, indexC, command.uniforms);
881
+ const a = transformPosition(localA, matrix);
882
+ const b = transformPosition(localB, matrix);
883
+ const c = transformPosition(localC, matrix);
884
+ const worldA = transformPosition(localA, modelMatrix);
885
+ const worldB = transformPosition(localB, modelMatrix);
886
+ const worldC = transformPosition(localC, modelMatrix);
887
+ const colorA = readVertexColor(vertexBuffer.bytes, command.vertexFormat.stride, colorAttribute?.offset, indexA);
888
+ const colorB = readVertexColor(vertexBuffer.bytes, command.vertexFormat.stride, colorAttribute?.offset, indexB);
889
+ const colorC = readVertexColor(vertexBuffer.bytes, command.vertexFormat.stride, colorAttribute?.offset, indexC);
890
+ const uvA = readVertexUv(vertexBuffer.bytes, command.vertexFormat.stride, uvAttribute?.offset, indexA);
891
+ const uvB = readVertexUv(vertexBuffer.bytes, command.vertexFormat.stride, uvAttribute?.offset, indexB);
892
+ const uvC = readVertexUv(vertexBuffer.bytes, command.vertexFormat.stride, uvAttribute?.offset, indexC);
893
+ rasterizeTriangle(this.activeRenderTarget, a, b, c, worldA, worldB, worldC, color, colorA, colorB, colorC, uvA, uvB, uvC, texture, shadow, depthTest, depthWrite);
894
+ }
895
+ }
896
+ else if (command.topology === "lines") {
897
+ for (let offset = 0; offset + 1 < indices.length; offset += 2) {
898
+ const indexA = indices[offset];
899
+ const indexB = indices[offset + 1];
900
+ const a = transformPosition(readMorphedPosition(vertexBuffer.bytes, command.vertexFormat.stride, position.offset, indexA, command.uniforms), matrix);
901
+ const b = transformPosition(readMorphedPosition(vertexBuffer.bytes, command.vertexFormat.stride, position.offset, indexB, command.uniforms), matrix);
902
+ const colorA = readVertexColor(vertexBuffer.bytes, command.vertexFormat.stride, colorAttribute?.offset, indexA);
903
+ const colorB = readVertexColor(vertexBuffer.bytes, command.vertexFormat.stride, colorAttribute?.offset, indexB);
904
+ rasterizeLine(this.activeRenderTarget, a, b, color, colorA, colorB, depthTest, depthWrite);
905
+ }
906
+ }
907
+ else {
908
+ for (const index of indices) {
909
+ const point = transformPosition(readMorphedPosition(vertexBuffer.bytes, command.vertexFormat.stride, position.offset, index, command.uniforms), matrix);
910
+ const vertexColor = readVertexColor(vertexBuffer.bytes, command.vertexFormat.stride, colorAttribute?.offset, index);
911
+ rasterizePoint(this.activeRenderTarget, point, multiplyColor(color, vertexColor), depthTest, depthWrite);
912
+ }
913
+ }
914
+ }
915
+ }
916
+ submitNativeRenderPass(command, vertexBuffer) {
917
+ const nativeView = this.activeRenderTarget?.nativeView ?? this.currentCanvasView();
918
+ if (!nativeView || !command.shader)
919
+ return;
920
+ if (!hasNativeRenderPipeline(this.device))
921
+ return;
922
+ const shader = this.requireShader(command.shader);
923
+ const vertexModule = shader.modules[0];
924
+ const fragmentModule = shader.modules[1] ?? vertexModule;
925
+ if (!vertexModule || !fragmentModule)
926
+ return;
927
+ const topology = command.topology === "lines" ? "line-list" : command.topology === "points" ? "point-list" : "triangle-list";
928
+ const targetFormat = this.activeRenderTarget ? webgpuTextureFormat(this.activeRenderTarget.colorTexture.format) : this.presentationFormat;
929
+ const vertexBuffers = command.vertexFormat ? [vertexBufferLayout(command.vertexFormat)] : undefined;
930
+ const shouldClear = this.activeRenderTarget ? this.activeRenderTarget.nativeNeedsClear : this.drawCalls === 0;
931
+ const depthView = this.activeRenderTarget?.nativeDepthView ?? this.canvasDepthView;
932
+ const depthEnabled = depthView !== null &&
933
+ depthView !== undefined &&
934
+ command.renderState?.depthTest !== false;
935
+ const depthWriteEnabled = command.renderState?.depthWrite ?? true;
936
+ const depthCompare = command.renderState?.depthCompare ?? "less-equal";
937
+ const blendEnabled = command.renderState?.blend === true;
938
+ const pipelineKey = `${shader.nativeUniformLayout}:${topology}:${targetFormat}:${blendEnabled ? "blend" : "opaque"}:${depthEnabled ? `${depthWriteEnabled}:${depthCompare}` : "nodepth"}:${command.vertexFormat?.stride ?? 0}:${command.vertexFormat?.attributes.map((attribute) => `${attribute.shaderLocation}/${attribute.offset}/${attribute.components}`).join(",") ?? "none"}`;
939
+ let pipeline = shader.renderPipelines.get(pipelineKey);
940
+ if (!pipeline) {
941
+ pipeline = this.device.createRenderPipeline({
942
+ label: `${shader.label}-pipeline`,
943
+ layout: "auto",
944
+ vertex: { module: vertexModule, entryPoint: shader.entryPoints[0], ...(vertexBuffers ? { buffers: vertexBuffers } : {}) },
945
+ fragment: {
946
+ module: fragmentModule,
947
+ entryPoint: shader.entryPoints[1],
948
+ targets: [{
949
+ format: targetFormat,
950
+ ...(blendEnabled
951
+ ? {
952
+ blend: {
953
+ color: { srcFactor: "src-alpha", dstFactor: "one-minus-src-alpha", operation: "add" },
954
+ alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
955
+ }
956
+ }
957
+ : {})
958
+ }]
959
+ },
960
+ primitive: { topology },
961
+ ...(depthEnabled
962
+ ? {
963
+ depthStencil: {
964
+ format: DEPTH_TEXTURE_FORMAT,
965
+ depthWriteEnabled,
966
+ depthCompare
967
+ }
968
+ }
969
+ : {})
970
+ });
971
+ shader.renderPipelines.set(pipelineKey, pipeline);
972
+ }
973
+ const encoder = this.device.createCommandEncoder({ label: `${command.label ?? "draw"}-encoder` });
974
+ const uniformBuffer = usesNativeDrawUniforms(shader.nativeUniformLayout) ? this.createNativeDrawUniformBuffer(command) : null;
975
+ const sampledTexture = shader.nativeUniformLayout === "generated-texture" ? this.createNativeSampledTextureBinding(uniformBaseColorTextureBinding(command.uniforms)) : null;
976
+ const materialTextures = usesNativePbrTextureBindings(shader.nativeUniformLayout) ? this.createNativePbrTextureBindings(command) : null;
977
+ if (shader.nativeUniformLayout === "generated-texture" && !sampledTexture) {
978
+ uniformBuffer?.destroy();
979
+ return;
980
+ }
981
+ if (usesNativePbrTextureBindings(shader.nativeUniformLayout) && !materialTextures) {
982
+ uniformBuffer?.destroy();
983
+ return;
984
+ }
985
+ const bindGroup = uniformBuffer && pipeline.getBindGroupLayout && this.device.createBindGroup
986
+ ? this.device.createBindGroup({
987
+ label: `${command.label ?? "draw"}-draw-bind-group`,
988
+ layout: pipeline.getBindGroupLayout(0),
989
+ entries: [
990
+ { binding: 0, resource: { buffer: uniformBuffer } },
991
+ ...(sampledTexture ? [
992
+ { binding: 1, resource: sampledTexture.sampler },
993
+ { binding: 2, resource: sampledTexture.view }
994
+ ] : []),
995
+ ...(materialTextures ? [
996
+ { binding: 1, resource: materialTextures.base.sampler },
997
+ { binding: 2, resource: materialTextures.base.view },
998
+ { binding: 3, resource: materialTextures.environment.sampler },
999
+ { binding: 4, resource: materialTextures.environment.view },
1000
+ { binding: 5, resource: materialTextures.brdf.sampler },
1001
+ { binding: 6, resource: materialTextures.brdf.view },
1002
+ { binding: 7, resource: materialTextures.shadow.sampler },
1003
+ { binding: 8, resource: materialTextures.shadow.view },
1004
+ { binding: 9, resource: materialTextures.normal.sampler },
1005
+ { binding: 10, resource: materialTextures.normal.view },
1006
+ { binding: 11, resource: materialTextures.metallicRoughness.sampler },
1007
+ { binding: 12, resource: materialTextures.metallicRoughness.view },
1008
+ { binding: 13, resource: materialTextures.occlusion.sampler },
1009
+ { binding: 14, resource: materialTextures.occlusion.view }
1010
+ ] : [])
1011
+ ]
1012
+ })
1013
+ : null;
1014
+ const pass = encoder.beginRenderPass({
1015
+ label: `${command.label ?? "draw"}-pass`,
1016
+ colorAttachments: [{
1017
+ view: nativeView,
1018
+ clearValue: this.activeRenderTarget?.nativeClearColor ?? this.clearColor,
1019
+ loadOp: shouldClear ? "clear" : "load",
1020
+ storeOp: "store"
1021
+ }],
1022
+ ...(depthEnabled
1023
+ ? {
1024
+ depthStencilAttachment: {
1025
+ view: depthView,
1026
+ depthClearValue: 1,
1027
+ depthLoadOp: shouldClear ? "clear" : "load",
1028
+ depthStoreOp: "store"
1029
+ }
1030
+ }
1031
+ : {})
1032
+ });
1033
+ pass.setPipeline(pipeline);
1034
+ pass.setVertexBuffer(0, vertexBuffer.handle);
1035
+ if (bindGroup)
1036
+ pass.setBindGroup?.(0, bindGroup);
1037
+ if (command.indexBuffer) {
1038
+ if (!pass.setIndexBuffer || !pass.drawIndexed) {
1039
+ pass.end();
1040
+ uniformBuffer?.destroy();
1041
+ this.lastError = "Native WebGPU indexed draw skipped because the render-pass encoder does not expose indexed draw APIs.";
1042
+ return;
1043
+ }
1044
+ const indexBuffer = this.requireBuffer(command.indexBuffer);
1045
+ pass.setIndexBuffer(indexBuffer.handle, command.indexType ?? "uint16");
1046
+ pass.drawIndexed(command.indexCount ?? this.indicesFor(command).length, command.instanceCount ?? 1, command.firstIndex ?? 0);
1047
+ }
1048
+ else {
1049
+ pass.draw(command.vertexCount, command.instanceCount ?? 1, command.firstVertex ?? 0);
1050
+ }
1051
+ pass.end();
1052
+ this.device.queue.submit([encoder.finish()]);
1053
+ if (this.activeRenderTarget)
1054
+ this.activeRenderTarget.nativeNeedsClear = false;
1055
+ uniformBuffer?.destroy();
1056
+ this.nativeSubmissions += 1;
1057
+ if (sampledTexture)
1058
+ this.nativeTextureBindings += 1;
1059
+ if (shader.nativeUniformLayout === "generated-basic")
1060
+ this.nativeGeneratedBasicSubmissions += 1;
1061
+ if (shader.nativeUniformLayout === "generated-texture")
1062
+ this.nativeGeneratedTextureSubmissions += 1;
1063
+ if (shader.nativeUniformLayout === "passthrough")
1064
+ this.nativePassthroughSubmissions += 1;
1065
+ if (shader.nativeUniformLayout === "generated-pbr" || shader.nativeUniformLayout === "generated-textured-pbr" || shader.nativeUniformLayout === "generated-instanced-pbr")
1066
+ this.nativePbrSubmissions += 1;
1067
+ if (shader.nativeUniformLayout === "generated-instanced-pbr")
1068
+ this.nativeInstancedSubmissions += 1;
1069
+ if (shader.nativeUniformLayout === "generated-skinned-unlit")
1070
+ this.nativeSkinnedSubmissions += 1;
1071
+ if (shader.nativeUniformLayout === "generated-morph-unlit")
1072
+ this.nativeMorphSubmissions += 1;
1073
+ if (materialTextures?.actualBaseColor)
1074
+ this.nativeTextureBindings += 1;
1075
+ if (materialTextures?.actualNormal)
1076
+ this.nativeTextureBindings += 1;
1077
+ if (materialTextures?.actualMetallicRoughness)
1078
+ this.nativeTextureBindings += 1;
1079
+ if (materialTextures?.actualOcclusion)
1080
+ this.nativeTextureBindings += 1;
1081
+ if (materialTextures?.actualEnvironment)
1082
+ this.nativeEnvironmentBindings += 1;
1083
+ if (materialTextures?.actualBrdf)
1084
+ this.nativeEnvironmentBindings += 1;
1085
+ if (materialTextures?.actualShadow)
1086
+ this.nativeShadowMapBindings += 1;
1087
+ if (!this.activeRenderTarget)
1088
+ this.canvasSubmissions += 1;
1089
+ }
1090
+ flushNativeRenderTargetClear(target) {
1091
+ if (!target.nativeNeedsClear || !target.nativeView || !this.device.createCommandEncoder)
1092
+ return;
1093
+ const encoder = this.device.createCommandEncoder({ label: `${target.label}-native-clear` });
1094
+ const pass = encoder.beginRenderPass({
1095
+ label: `${target.label}-native-clear-pass`,
1096
+ colorAttachments: [{
1097
+ view: target.nativeView,
1098
+ clearValue: target.nativeClearColor,
1099
+ loadOp: "clear",
1100
+ storeOp: "store"
1101
+ }],
1102
+ ...(target.nativeDepthView
1103
+ ? {
1104
+ depthStencilAttachment: {
1105
+ view: target.nativeDepthView,
1106
+ depthClearValue: 1,
1107
+ depthLoadOp: "clear",
1108
+ depthStoreOp: "store"
1109
+ }
1110
+ }
1111
+ : {})
1112
+ });
1113
+ pass.end();
1114
+ this.device.queue.submit([encoder.finish()]);
1115
+ target.nativeNeedsClear = false;
1116
+ }
1117
+ createNativeSampledTextureBinding(binding) {
1118
+ if (!binding?.texture || binding.texture.disposed || !binding.validate().ok || !hasNativeSampledTextureBinding(this.device))
1119
+ return null;
1120
+ const texture = binding.texture;
1121
+ let resource = this.nativeSampledTextures.get(texture);
1122
+ if (!resource) {
1123
+ if (texture.source) {
1124
+ const sourceLevels = nativeTextureSourceLevels(texture);
1125
+ if (sourceLevels.length === 0)
1126
+ return null;
1127
+ const nativeTexture = this.device.createTexture({
1128
+ label: texture.label,
1129
+ size: { width: texture.width, height: texture.height, depthOrArrayLayers: 1 },
1130
+ format: webgpuSampledTextureFormat(texture, "rgba8"),
1131
+ usage: TEXTURE_USAGE.TEXTURE_BINDING | TEXTURE_USAGE.COPY_DST,
1132
+ mipLevelCount: sourceLevels.length
1133
+ });
1134
+ const writeTexture = this.device.queue.writeTexture;
1135
+ if (!writeTexture)
1136
+ return null;
1137
+ sourceLevels.forEach((level, mipLevel) => {
1138
+ writeTexture.call(this.device.queue, { texture: nativeTexture, mipLevel }, level.data, { bytesPerRow: level.bytesPerRow, rowsPerImage: level.height }, { width: level.width, height: level.height, depthOrArrayLayers: 1 });
1139
+ });
1140
+ resource = { texture: nativeTexture, view: nativeTexture.createView() };
1141
+ }
1142
+ else {
1143
+ const sampledTexture = nativeSampledTextureLevels(texture);
1144
+ if (!sampledTexture)
1145
+ return null;
1146
+ const { levels, format } = sampledTexture;
1147
+ const baseLevel = levels[0];
1148
+ if (!baseLevel)
1149
+ return null;
1150
+ const levelBytesPerPixel = bytesPerPixel(format);
1151
+ if (levels.some((level) => level.data.byteLength < level.width * level.height * levelBytesPerPixel))
1152
+ return null;
1153
+ const nativeTexture = this.device.createTexture({
1154
+ label: texture.label,
1155
+ size: { width: baseLevel.width, height: baseLevel.height, depthOrArrayLayers: 1 },
1156
+ format: webgpuSampledTextureFormat(texture, format),
1157
+ usage: TEXTURE_USAGE.TEXTURE_BINDING | TEXTURE_USAGE.COPY_DST,
1158
+ mipLevelCount: levels.length
1159
+ });
1160
+ for (const [mipLevel, level] of levels.entries()) {
1161
+ this.device.queue.writeTexture({ texture: nativeTexture, mipLevel }, level.data, { bytesPerRow: level.width * levelBytesPerPixel, rowsPerImage: level.height }, { width: level.width, height: level.height, depthOrArrayLayers: 1 });
1162
+ }
1163
+ resource = { texture: nativeTexture, view: nativeTexture.createView() };
1164
+ }
1165
+ this.nativeSampledTextures.set(texture, resource);
1166
+ }
1167
+ return {
1168
+ view: resource.view,
1169
+ sampler: this.device.createSampler(webgpuSamplerDescriptor(binding.sampler)),
1170
+ actual: true
1171
+ };
1172
+ }
1173
+ createNativePbrTextureBindings(command) {
1174
+ if (!hasNativeSampledTextureBinding(this.device))
1175
+ return null;
1176
+ const baseBinding = uniformBaseColorTextureBinding(command.uniforms);
1177
+ const environmentBinding = uniformTextureBinding(command.uniforms, "u_environmentMapTexture");
1178
+ const brdfBinding = uniformTextureBinding(command.uniforms, "u_environmentBrdfLutTexture");
1179
+ const shadowBinding = uniformTextureBinding(command.uniforms, "u_shadowMapTexture");
1180
+ const normalBinding = uniformTextureBinding(command.uniforms, "u_normalTexture");
1181
+ const metallicRoughnessBinding = uniformTextureBinding(command.uniforms, "u_metallicRoughnessTexture");
1182
+ const occlusionBinding = uniformTextureBinding(command.uniforms, "u_occlusionTexture");
1183
+ const base = this.createNativeSampledTextureBinding(baseBinding) ?? this.createNativeFallbackSampledTextureBinding("white-srgb", [255, 255, 255, 255], "srgb");
1184
+ const environment = this.createNativeSampledTextureBinding(environmentBinding) ?? this.createNativeFallbackSampledTextureBinding("environment-srgb", [92, 116, 156, 255], "srgb");
1185
+ const brdf = this.createNativeSampledTextureBinding(brdfBinding) ?? this.createNativeFallbackSampledTextureBinding("brdf-linear", [180, 180, 255, 255], "linear");
1186
+ const shadow = this.createNativeSampledTextureBinding(shadowBinding) ?? this.createNativeFallbackSampledTextureBinding("shadow-lit-linear", [255, 255, 255, 255], "linear");
1187
+ const normal = this.createNativeSampledTextureBinding(normalBinding) ?? this.createNativeFallbackSampledTextureBinding("flat-normal-linear", [128, 128, 255, 255], "linear");
1188
+ const metallicRoughness = this.createNativeSampledTextureBinding(metallicRoughnessBinding) ?? this.createNativeFallbackSampledTextureBinding("metallic-roughness-linear", [255, 255, 255, 255], "linear");
1189
+ const occlusion = this.createNativeSampledTextureBinding(occlusionBinding) ?? this.createNativeFallbackSampledTextureBinding("occlusion-linear", [255, 255, 255, 255], "linear");
1190
+ if (!base || !environment || !brdf || !shadow || !normal || !metallicRoughness || !occlusion)
1191
+ return null;
1192
+ return {
1193
+ base,
1194
+ environment,
1195
+ brdf,
1196
+ shadow,
1197
+ normal,
1198
+ metallicRoughness,
1199
+ occlusion,
1200
+ actualBaseColor: baseBinding !== null && base.actual,
1201
+ actualEnvironment: environmentBinding !== null && environment.actual,
1202
+ actualBrdf: brdfBinding !== null && brdf.actual,
1203
+ actualShadow: shadowBinding !== null && shadow.actual,
1204
+ actualNormal: normalBinding !== null && normal.actual,
1205
+ actualMetallicRoughness: metallicRoughnessBinding !== null && metallicRoughness.actual,
1206
+ actualOcclusion: occlusionBinding !== null && occlusion.actual
1207
+ };
1208
+ }
1209
+ createNativeFallbackSampledTextureBinding(key, rgba, colorSpace) {
1210
+ if (!hasNativeSampledTextureBinding(this.device))
1211
+ return null;
1212
+ let resource = this.nativeSampledTextures.get(`fallback:${key}`);
1213
+ if (!resource) {
1214
+ const nativeTexture = this.device.createTexture({
1215
+ label: `aura3d-native-${key}`,
1216
+ size: { width: 1, height: 1, depthOrArrayLayers: 1 },
1217
+ format: colorSpace === "srgb" ? "rgba8unorm-srgb" : "rgba8unorm",
1218
+ usage: TEXTURE_USAGE.TEXTURE_BINDING | TEXTURE_USAGE.COPY_DST
1219
+ });
1220
+ this.device.queue.writeTexture({ texture: nativeTexture }, new Uint8Array(rgba), { bytesPerRow: 4, rowsPerImage: 1 }, { width: 1, height: 1, depthOrArrayLayers: 1 });
1221
+ resource = { texture: nativeTexture, view: nativeTexture.createView() };
1222
+ this.nativeSampledTextures.set(`fallback:${key}`, resource);
1223
+ }
1224
+ return {
1225
+ view: resource.view,
1226
+ sampler: this.device.createSampler({
1227
+ minFilter: "nearest",
1228
+ magFilter: "nearest",
1229
+ addressModeU: "clamp-to-edge",
1230
+ addressModeV: "clamp-to-edge"
1231
+ }),
1232
+ actual: false
1233
+ };
1234
+ }
1235
+ createNativeDrawUniformBuffer(command) {
1236
+ if (!this.device.createBindGroup)
1237
+ return null;
1238
+ const data = new Float32Array(188);
1239
+ const baseColorBinding = uniformBaseColorTextureBinding(command.uniforms);
1240
+ const environmentBinding = uniformTextureBinding(command.uniforms, "u_environmentMapTexture");
1241
+ const normalBinding = uniformTextureBinding(command.uniforms, "u_normalTexture");
1242
+ const metallicRoughnessBinding = uniformTextureBinding(command.uniforms, "u_metallicRoughnessTexture");
1243
+ const occlusionBinding = uniformTextureBinding(command.uniforms, "u_occlusionTexture");
1244
+ data.set(uniformMat4(command.uniforms?.get("u_modelViewProjection")) ?? identityMatrix(), 0);
1245
+ data.set(uniformColor(command.uniforms), 16);
1246
+ data[20] = uniformNumber(command.uniforms?.get("u_metallic"), 0);
1247
+ data[21] = uniformNumber(command.uniforms?.get("u_roughness"), 0.5);
1248
+ data[22] = uniformNumber(command.uniforms?.get("u_environmentIntensity"), 0);
1249
+ data[23] = uniformNumber(command.uniforms?.get("u_environmentMapTextureIntensity"), 0);
1250
+ data[24] = uniformNumber(command.uniforms?.get("u_baseColorTextureEnabled"), baseColorBinding ? 1 : 0);
1251
+ data[25] = uniformNumber(command.uniforms?.get("u_shadowMapEnabled"), 0);
1252
+ data[26] = uniformNumber(command.uniforms?.get("u_shadowMapStrength"), 0.65);
1253
+ data[27] = uniformNumber(command.uniforms?.get("u_environmentMapTextureEnabled"), environmentBinding ? 1 : 0);
1254
+ const morphWeights = command.uniforms?.get("u_morphWeights");
1255
+ data[28] = morphWeights instanceof Float32Array || Array.isArray(morphWeights) ? Number(morphWeights[0] ?? 0) : 0;
1256
+ data[29] = uniformNumber(command.uniforms?.get("u_morphTargetCount"), 0);
1257
+ data[30] = uniformNumber(command.uniforms?.get("u_environmentMapTextureMipCount"), 1);
1258
+ data[31] = uniformNumber(command.uniforms?.get("u_environmentMapTextureSpecularIntensity"), 0)
1259
+ * uniformNumber(command.uniforms?.get("u_materialEnvironmentSpecularScale"), 1);
1260
+ data[128] = uniformNumber(command.uniforms?.get("u_normalTextureEnabled"), normalBinding ? 1 : 0);
1261
+ data[129] = uniformNumber(command.uniforms?.get("u_normalScale"), 1);
1262
+ data[130] = uniformNumber(command.uniforms?.get("u_occlusionStrength"), 1);
1263
+ data[160] = uniformNumber(command.uniforms?.get("u_alphaCutoff"), 0);
1264
+ data[161] = uniformNumber(command.uniforms?.get("u_transmissionFactor"), 0);
1265
+ data[162] = uniformNumber(command.uniforms?.get("u_diffuseTransmissionFactor"), 0);
1266
+ data.set(uniformVec3(command.uniforms?.get("u_cameraPosition")) ?? [0, 0, 1], 164);
1267
+ data[167] = 1;
1268
+ data[168] = uniformNumber(command.uniforms?.get("u_metallicRoughnessTextureEnabled"), metallicRoughnessBinding ? 1 : 0);
1269
+ data[169] = uniformNumber(command.uniforms?.get("u_occlusionTextureEnabled"), occlusionBinding ? 1 : 0);
1270
+ data[170] = uniformNumber(command.uniforms?.get("u_productColorSmoothing"), 0);
1271
+ data.set(uniformMat4(command.uniforms?.get("u_normalMatrix")) ?? identityMatrix(), 172);
1272
+ const modelMatrix = uniformMat4(command.uniforms?.get("u_modelMatrix")) ?? identityMatrix();
1273
+ const instanceMatrixValue = command.uniforms?.get("u_instanceMatrices");
1274
+ const instanceMatrixNumbers = instanceMatrixValue instanceof Float32Array || Array.isArray(instanceMatrixValue) ? Array.from(instanceMatrixValue) : [];
1275
+ const hasInstanceMatrices = instanceMatrixNumbers.length >= 16 && instanceMatrixNumbers.slice(0, 16).every(Number.isFinite);
1276
+ const instanceMatrices = hasInstanceMatrices ? uniformMat4Array(instanceMatrixValue, 4) : [];
1277
+ for (let index = 0; index < 4; index += 1) {
1278
+ data.set(instanceMatrices[index] ?? (index === 0 ? modelMatrix : identityMatrix()), 32 + index * 16);
1279
+ }
1280
+ const jointMatrices = uniformMat4Array(command.uniforms?.get("u_jointMatrices"), 2);
1281
+ for (let index = 0; index < 2; index += 1) {
1282
+ data.set(jointMatrices[index] ?? identityMatrix(), 96 + index * 16);
1283
+ }
1284
+ const morphDeltas = command.uniforms?.get("u_morphPositionDeltas");
1285
+ const morphNumbers = morphDeltas instanceof Float32Array || Array.isArray(morphDeltas) ? Array.from(morphDeltas).slice(0, 32) : [];
1286
+ if (morphNumbers.length > 0)
1287
+ data.set(morphNumbers, 128);
1288
+ const buffer = this.device.createBuffer({
1289
+ label: `${command.label ?? "draw"}-draw-uniforms`,
1290
+ size: data.byteLength,
1291
+ usage: BUFFER_USAGE.UNIFORM | BUFFER_USAGE.COPY_DST
1292
+ });
1293
+ this.device.queue.writeBuffer(buffer, 0, data);
1294
+ return buffer;
1295
+ }
1296
+ currentCanvasView() {
1297
+ if (!this.canvasContext)
1298
+ return null;
1299
+ return this.canvasContext.getCurrentTexture().createView();
1300
+ }
1301
+ ensureCanvasDepthAttachment(width, height) {
1302
+ if (!this.canvasContext || !this.device.createTexture)
1303
+ return;
1304
+ if (this.canvasDepthTexture &&
1305
+ this.canvasDepthView &&
1306
+ this.canvasDepthWidth === width &&
1307
+ this.canvasDepthHeight === height) {
1308
+ return;
1309
+ }
1310
+ this.canvasDepthTexture?.destroy();
1311
+ this.canvasDepthTexture = this.device.createTexture({
1312
+ label: "aura3d-webgpu-canvas-depth",
1313
+ size: [width, height],
1314
+ format: DEPTH_TEXTURE_FORMAT,
1315
+ usage: TEXTURE_USAGE.RENDER_ATTACHMENT
1316
+ });
1317
+ this.canvasDepthView = this.canvasDepthTexture.createView();
1318
+ this.canvasDepthWidth = width;
1319
+ this.canvasDepthHeight = height;
1320
+ }
1321
+ clearActiveRenderTarget(color) {
1322
+ if (!this.activeRenderTarget)
1323
+ return;
1324
+ const bytes = rgbaBytes(color);
1325
+ for (let index = 0; index < this.activeRenderTarget.colorPixels.length; index += 4) {
1326
+ this.activeRenderTarget.colorPixels.set(bytes, index);
1327
+ }
1328
+ this.activeRenderTarget.nativeNeedsClear = true;
1329
+ this.activeRenderTarget.nativeClearColor = color;
1330
+ this.activeRenderTarget.depthPixels?.fill(1);
1331
+ if (this.activeRenderTarget.colorFloatPixels) {
1332
+ for (let index = 0; index < this.activeRenderTarget.colorFloatPixels.length; index += 4) {
1333
+ this.activeRenderTarget.colorFloatPixels[index] = color[0];
1334
+ this.activeRenderTarget.colorFloatPixels[index + 1] = color[1];
1335
+ this.activeRenderTarget.colorFloatPixels[index + 2] = color[2];
1336
+ this.activeRenderTarget.colorFloatPixels[index + 3] = color[3];
1337
+ }
1338
+ }
1339
+ }
1340
+ indicesFor(command) {
1341
+ if (!command.indexBuffer) {
1342
+ const firstVertex = command.firstVertex ?? 0;
1343
+ return Array.from({ length: command.vertexCount }, (_, index) => firstVertex + index);
1344
+ }
1345
+ const indexBuffer = this.requireBuffer(command.indexBuffer);
1346
+ const indexCount = command.indexCount ?? Math.floor(indexBuffer.byteLength / (command.indexType === "uint32" ? 4 : 2));
1347
+ const indices = [];
1348
+ const view = new DataView(indexBuffer.bytes.buffer, indexBuffer.bytes.byteOffset, indexBuffer.bytes.byteLength);
1349
+ const firstIndex = command.firstIndex ?? 0;
1350
+ for (let index = 0; index < indexCount; index += 1) {
1351
+ const byteOffset = (firstIndex + index) * (command.indexType === "uint32" ? 4 : 2);
1352
+ indices.push(command.indexType === "uint32" ? view.getUint32(byteOffset, true) : view.getUint16(byteOffset, true));
1353
+ }
1354
+ return indices;
1355
+ }
1356
+ }
1357
+ async function requestAdapter(gpu) {
1358
+ if (!gpu) {
1359
+ throw new RenderDeviceError("WebGPU runtime is missing from the current environment", "WEBGPU_RUNTIME_MISSING");
1360
+ }
1361
+ return gpu.requestAdapter();
1362
+ }
1363
+ async function requestDevice(adapter, injectedDevice) {
1364
+ if (injectedDevice) {
1365
+ return injectedDevice;
1366
+ }
1367
+ try {
1368
+ return await adapter.requestDevice();
1369
+ }
1370
+ catch (error) {
1371
+ throw new RenderDeviceError("WebGPU adapter failed to create a device", "WEBGPU_DEVICE_REQUEST_FAILED", {
1372
+ adapter: describeAdapter(adapter),
1373
+ reason: error instanceof Error ? error.message : String(error)
1374
+ });
1375
+ }
1376
+ }
1377
+ function validateWebGPUDevice(device) {
1378
+ const missing = [];
1379
+ if (!device || typeof device !== "object")
1380
+ missing.push("device");
1381
+ if (typeof device?.createBuffer !== "function")
1382
+ missing.push("createBuffer");
1383
+ if (typeof device?.queue?.writeBuffer !== "function")
1384
+ missing.push("queue.writeBuffer");
1385
+ if (typeof device?.queue?.submit !== "function")
1386
+ missing.push("queue.submit");
1387
+ if (missing.length > 0) {
1388
+ throw new RenderDeviceError("WebGPU device is missing required render-device capabilities", "WEBGPU_DEVICE_INVALID", {
1389
+ missing
1390
+ });
1391
+ }
1392
+ return device;
1393
+ }
1394
+ function hasNativeRenderPipeline(device) {
1395
+ return typeof device.createCommandEncoder === "function" &&
1396
+ typeof device.createRenderPipeline === "function" &&
1397
+ typeof device.createBindGroup === "function" &&
1398
+ typeof device.createTexture === "function";
1399
+ }
1400
+ function hasNativeSampledTextureBinding(device) {
1401
+ return typeof device.createTexture === "function" &&
1402
+ typeof device.createSampler === "function" &&
1403
+ typeof device.queue.writeTexture === "function";
1404
+ }
1405
+ function hasNativeTextureUpload(device) {
1406
+ return typeof device.queue.writeTexture === "function";
1407
+ }
1408
+ function hasNativeTextureReadback(device) {
1409
+ if (typeof device.createCommandEncoder !== "function" || typeof device.createTexture !== "function")
1410
+ return false;
1411
+ const probe = device.createBuffer({
1412
+ label: "aura3d-native-readback-capability-probe",
1413
+ size: 4,
1414
+ usage: BUFFER_USAGE.MAP_READ | BUFFER_USAGE.COPY_DST
1415
+ });
1416
+ const supported = typeof probe.mapAsync === "function" &&
1417
+ typeof probe.getMappedRange === "function" &&
1418
+ typeof probe.unmap === "function" &&
1419
+ typeof device.createCommandEncoder({ label: "aura3d-native-readback-capability-probe" }).copyTextureToBuffer === "function";
1420
+ probe.destroy();
1421
+ return supported;
1422
+ }
1423
+ function alignTo(value, alignment) {
1424
+ return Math.ceil(value / alignment) * alignment;
1425
+ }
1426
+ function readWebGPU(globalScope) {
1427
+ return globalScope.navigator?.gpu;
1428
+ }
1429
+ function acquireWebGPUCanvasContext(canvas) {
1430
+ const getContext = canvas.getContext;
1431
+ if (typeof getContext !== "function") {
1432
+ throw new RenderDeviceError("WebGPU canvas presentation requires getContext(\"webgpu\")", "WEBGPU_CANVAS_CONTEXT_MISSING");
1433
+ }
1434
+ const context = getContext.call(canvas, "webgpu");
1435
+ if (!context || typeof context.configure !== "function" || typeof context.getCurrentTexture !== "function") {
1436
+ throw new RenderDeviceError("Canvas did not provide a usable WebGPU presentation context", "WEBGPU_CANVAS_CONTEXT_INVALID");
1437
+ }
1438
+ return context;
1439
+ }
1440
+ function describeAdapter(adapter) {
1441
+ if (adapter.name)
1442
+ return adapter.name;
1443
+ const parts = [adapter.info?.vendor, adapter.info?.architecture, adapter.info?.device, adapter.info?.description].filter(Boolean);
1444
+ return parts.length > 0 ? parts.join(" ") : undefined;
1445
+ }
1446
+ function bufferUsageFlags(usage) {
1447
+ if (usage === "vertex")
1448
+ return BUFFER_USAGE.VERTEX | BUFFER_USAGE.COPY_DST | BUFFER_USAGE.COPY_SRC;
1449
+ if (usage === "index")
1450
+ return BUFFER_USAGE.INDEX | BUFFER_USAGE.COPY_DST | BUFFER_USAGE.COPY_SRC;
1451
+ if (usage === "uniform")
1452
+ return BUFFER_USAGE.UNIFORM | BUFFER_USAGE.COPY_DST | BUFFER_USAGE.COPY_SRC;
1453
+ return BUFFER_USAGE.MAP_READ | BUFFER_USAGE.COPY_DST;
1454
+ }
1455
+ function webgpuTextureFormat(format) {
1456
+ if (format === "rgba16f")
1457
+ return "rgba16float";
1458
+ if (format === "rgba32f")
1459
+ return "rgba32float";
1460
+ return "rgba8unorm";
1461
+ }
1462
+ function nativeSampledTextureLevels(texture) {
1463
+ if (isCompressedTextureFormat(texture.format)) {
1464
+ const fallback = texture.fallbackTextureLevels;
1465
+ return fallback.length > 0 ? { levels: fallback, format: "rgba8" } : null;
1466
+ }
1467
+ if (texture.format === "depth24")
1468
+ return null;
1469
+ const levels = texture.textureLevels;
1470
+ return levels.length > 0 ? { levels, format: texture.format } : null;
1471
+ }
1472
+ function nativeTextureSourceLevels(texture) {
1473
+ const source = texture.source;
1474
+ if (!source || typeof globalThis === "undefined")
1475
+ return [];
1476
+ const width = Math.max(1, Math.round(texture.width));
1477
+ const height = Math.max(1, Math.round(texture.height));
1478
+ const mipCount = Math.max(1, Math.floor(Math.log2(Math.max(width, height))) + 1);
1479
+ const levels = [];
1480
+ for (let level = 0; level < mipCount; level += 1) {
1481
+ const levelWidth = Math.max(1, width >> level);
1482
+ const levelHeight = Math.max(1, height >> level);
1483
+ const canvas = createTextureReadbackCanvas(levelWidth, levelHeight);
1484
+ if (!canvas)
1485
+ return levels;
1486
+ const context = canvas.getContext("2d", { willReadFrequently: true });
1487
+ if (!context)
1488
+ return levels;
1489
+ context.clearRect(0, 0, levelWidth, levelHeight);
1490
+ context.drawImage(source, 0, 0, levelWidth, levelHeight);
1491
+ const pixels = context.getImageData(0, 0, levelWidth, levelHeight).data;
1492
+ const sourceBytesPerRow = levelWidth * 4;
1493
+ const bytesPerRow = alignTo(sourceBytesPerRow, 256);
1494
+ if (bytesPerRow === sourceBytesPerRow) {
1495
+ levels.push({ width: levelWidth, height: levelHeight, bytesPerRow, data: new Uint8Array(pixels.buffer.slice(pixels.byteOffset, pixels.byteOffset + pixels.byteLength)) });
1496
+ continue;
1497
+ }
1498
+ const data = new Uint8Array(bytesPerRow * levelHeight);
1499
+ for (let row = 0; row < levelHeight; row += 1) {
1500
+ data.set(pixels.subarray(row * sourceBytesPerRow, (row + 1) * sourceBytesPerRow), row * bytesPerRow);
1501
+ }
1502
+ levels.push({ width: levelWidth, height: levelHeight, bytesPerRow, data });
1503
+ }
1504
+ return levels;
1505
+ }
1506
+ function createTextureReadbackCanvas(width, height) {
1507
+ const offscreenCanvas = globalThis.OffscreenCanvas;
1508
+ if (offscreenCanvas)
1509
+ return new offscreenCanvas(width, height);
1510
+ if (typeof document === "undefined")
1511
+ return null;
1512
+ const canvas = document.createElement("canvas");
1513
+ canvas.width = width;
1514
+ canvas.height = height;
1515
+ return canvas;
1516
+ }
1517
+ function webgpuSampledTextureFormat(texture, format) {
1518
+ if (format === "rgba16f")
1519
+ return "rgba16float";
1520
+ if (format === "rgba32f")
1521
+ return "rgba32float";
1522
+ return texture.colorSpace === "srgb" ? "rgba8unorm-srgb" : "rgba8unorm";
1523
+ }
1524
+ function webgpuMinFilter(filter) {
1525
+ if (filter === "nearest" || filter === "nearest-mipmap-nearest" || filter === "nearest-mipmap-linear")
1526
+ return "nearest";
1527
+ return "linear";
1528
+ }
1529
+ function webgpuMagFilter(filter) {
1530
+ return filter;
1531
+ }
1532
+ function webgpuMipmapFilter(filter) {
1533
+ if (filter === "nearest-mipmap-nearest" || filter === "linear-mipmap-nearest")
1534
+ return "nearest";
1535
+ if (filter === "nearest-mipmap-linear" || filter === "linear-mipmap-linear")
1536
+ return "linear";
1537
+ return undefined;
1538
+ }
1539
+ function webgpuSamplerDescriptor(sampler) {
1540
+ const minFilter = webgpuMinFilter(sampler.minFilter);
1541
+ const magFilter = webgpuMagFilter(sampler.magFilter);
1542
+ const mipmapFilter = webgpuMipmapFilter(sampler.minFilter);
1543
+ const descriptor = {
1544
+ minFilter,
1545
+ magFilter,
1546
+ ...(mipmapFilter ? { mipmapFilter } : {}),
1547
+ addressModeU: sampler.addressU,
1548
+ addressModeV: sampler.addressV
1549
+ };
1550
+ const maxAnisotropy = webgpuMaxAnisotropy(sampler.maxAnisotropy, minFilter, magFilter, mipmapFilter);
1551
+ return maxAnisotropy === undefined ? descriptor : { ...descriptor, maxAnisotropy };
1552
+ }
1553
+ function webgpuMaxAnisotropy(maxAnisotropy, minFilter, magFilter, mipmapFilter) {
1554
+ if (maxAnisotropy <= 1)
1555
+ return undefined;
1556
+ if (minFilter !== "linear" || magFilter !== "linear" || mipmapFilter !== "linear")
1557
+ return undefined;
1558
+ return Math.min(16, Math.max(1, Math.floor(maxAnisotropy)));
1559
+ }
1560
+ function usesNativeDrawUniforms(layout) {
1561
+ return layout !== "passthrough";
1562
+ }
1563
+ function usesNativePbrTextureBindings(layout) {
1564
+ return layout === "generated-pbr" ||
1565
+ layout === "generated-textured-pbr" ||
1566
+ layout === "generated-instanced-pbr";
1567
+ }
1568
+ function writeAlignedQueueBuffer(queue, buffer, byteOffset, data, nativeByteLength) {
1569
+ const bytes = viewBytes(data);
1570
+ if (byteOffset % 4 === 0 && bytes.byteLength % 4 === 0) {
1571
+ queue.writeBuffer(buffer, byteOffset, bytes);
1572
+ return;
1573
+ }
1574
+ const alignedOffset = Math.floor(byteOffset / 4) * 4;
1575
+ const alignedEnd = alignTo(byteOffset + bytes.byteLength, 4);
1576
+ if (alignedEnd > nativeByteLength) {
1577
+ throw new RenderDeviceError("Aligned WebGPU buffer write exceeds native buffer allocation", "BUFFER_RANGE_OUT_OF_BOUNDS", {
1578
+ byteOffset,
1579
+ dataByteLength: bytes.byteLength,
1580
+ alignedOffset,
1581
+ alignedEnd,
1582
+ nativeByteLength
1583
+ });
1584
+ }
1585
+ const padded = new Uint8Array(alignedEnd - alignedOffset);
1586
+ padded.set(bytes, byteOffset - alignedOffset);
1587
+ queue.writeBuffer(buffer, alignedOffset, padded);
1588
+ }
1589
+ function rgbaBytes(color) {
1590
+ return new Uint8Array(color.map((channel) => Math.round(Math.max(0, Math.min(1, channel)) * 255)));
1591
+ }
1592
+ function halfFloatToNumber(bits) {
1593
+ const sign = (bits & 0x8000) ? -1 : 1;
1594
+ const exponent = (bits >> 10) & 0x1f;
1595
+ const fraction = bits & 0x03ff;
1596
+ if (exponent === 0) {
1597
+ return sign * 2 ** -14 * (fraction / 1024);
1598
+ }
1599
+ if (exponent === 0x1f) {
1600
+ return fraction === 0 ? sign * Infinity : Number.NaN;
1601
+ }
1602
+ return sign * 2 ** (exponent - 15) * (1 + fraction / 1024);
1603
+ }
1604
+ function uniformColor(uniforms) {
1605
+ const value = uniforms?.get("u_baseColor") ?? uniforms?.get("u_color") ?? uniforms?.get("color");
1606
+ const components = value instanceof Float32Array || Array.isArray(value) ? Array.from(value).slice(0, 4) : [];
1607
+ if (components.length >= 3 && components.every((component) => Number.isFinite(component))) {
1608
+ return [
1609
+ components[0] ?? 1,
1610
+ components[1] ?? 1,
1611
+ components[2] ?? 1,
1612
+ components[3] ?? 1
1613
+ ];
1614
+ }
1615
+ return [1, 1, 1, 1];
1616
+ }
1617
+ function uniformBaseColorTextureBinding(uniforms) {
1618
+ if (!uniforms)
1619
+ return null;
1620
+ const direct = uniforms.get("u_texture") ?? uniforms.get("u_baseColorTexture") ?? uniforms.get("baseColorTexture");
1621
+ if (direct instanceof TextureBinding && direct.texture && !direct.texture.disposed && direct.validate().ok) {
1622
+ return direct;
1623
+ }
1624
+ return null;
1625
+ }
1626
+ function uniformTextureBinding(uniforms, name) {
1627
+ const value = uniforms?.get(name);
1628
+ return value instanceof TextureBinding && value.texture && !value.texture.disposed && value.validate().ok ? value : null;
1629
+ }
1630
+ function uniformNumber(value, fallback) {
1631
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
1632
+ }
1633
+ function uniformVec3(value) {
1634
+ const components = value instanceof Float32Array || Array.isArray(value) ? Array.from(value).slice(0, 3) : [];
1635
+ return components.length === 3 && components.every(Number.isFinite)
1636
+ ? [components[0], components[1], components[2]]
1637
+ : null;
1638
+ }
1639
+ function uniformMat4Array(value, count) {
1640
+ const numbers = value instanceof Float32Array || Array.isArray(value) ? Array.from(value) : [];
1641
+ return Array.from({ length: count }, (_, index) => {
1642
+ const start = index * 16;
1643
+ const matrix = numbers.slice(start, start + 16);
1644
+ return matrix.length === 16 && matrix.every(Number.isFinite) ? matrix : identityMatrix();
1645
+ });
1646
+ }
1647
+ function uniformRasterMatrices(uniforms, instanceCount) {
1648
+ const modelViewProjection = uniformMat4(uniforms?.get("u_modelViewProjection")) ?? identityMatrix();
1649
+ const value = uniforms?.get("u_instanceMatrices");
1650
+ const numbers = value instanceof Float32Array || Array.isArray(value) ? Array.from(value) : [];
1651
+ if (numbers.length < instanceCount * 16 || !numbers.slice(0, instanceCount * 16).every(Number.isFinite)) {
1652
+ return Array.from({ length: instanceCount }, () => modelViewProjection);
1653
+ }
1654
+ return Array.from({ length: instanceCount }, (_, index) => multiplyMat4(modelViewProjection, numbers.slice(index * 16, index * 16 + 16)));
1655
+ }
1656
+ function uniformRasterModelMatrices(uniforms, instanceCount) {
1657
+ const modelMatrix = uniformMat4(uniforms?.get("u_modelMatrix")) ?? identityMatrix();
1658
+ const value = uniforms?.get("u_instanceMatrices");
1659
+ const numbers = value instanceof Float32Array || Array.isArray(value) ? Array.from(value) : [];
1660
+ if (numbers.length < instanceCount * 16 || !numbers.slice(0, instanceCount * 16).every(Number.isFinite)) {
1661
+ return Array.from({ length: instanceCount }, () => modelMatrix);
1662
+ }
1663
+ return Array.from({ length: instanceCount }, (_, index) => multiplyMat4(modelMatrix, numbers.slice(index * 16, index * 16 + 16)));
1664
+ }
1665
+ function uniformForwardShadow(uniforms) {
1666
+ if (!uniforms)
1667
+ return null;
1668
+ const enabled = uniforms.get("u_shadowMapEnabled");
1669
+ if (typeof enabled !== "number" || enabled < 0.5)
1670
+ return null;
1671
+ const texture = uniforms.get("u_shadowMapTexture");
1672
+ const matrix = uniformMat4(uniforms.get("u_shadowMapMatrix")) ?? identityMatrix();
1673
+ if (!(texture instanceof TextureBinding) || !texture.texture || texture.texture.disposed || !texture.validate().ok) {
1674
+ return null;
1675
+ }
1676
+ const strengthValue = uniforms.get("u_shadowMapStrength");
1677
+ const biasValue = uniforms.get("u_shadowMapBias");
1678
+ const strength = typeof strengthValue === "number" && Number.isFinite(strengthValue) ? Math.max(0, Math.min(1, strengthValue)) : 0.65;
1679
+ const bias = typeof biasValue === "number" && Number.isFinite(biasValue) ? Math.max(0, biasValue) : 0.001;
1680
+ return { texture, matrix, strength, bias };
1681
+ }
1682
+ function uniformMat4(value) {
1683
+ const numbers = value instanceof Float32Array || Array.isArray(value) ? Array.from(value) : [];
1684
+ return numbers.length === 16 && numbers.every(Number.isFinite) ? numbers : null;
1685
+ }
1686
+ function multiplyMat4(left, right) {
1687
+ const out = new Array(16);
1688
+ for (let row = 0; row < 4; row += 1) {
1689
+ for (let column = 0; column < 4; column += 1) {
1690
+ out[column * 4 + row] =
1691
+ (left[0 * 4 + row] ?? 0) * (right[column * 4 + 0] ?? 0) +
1692
+ (left[1 * 4 + row] ?? 0) * (right[column * 4 + 1] ?? 0) +
1693
+ (left[2 * 4 + row] ?? 0) * (right[column * 4 + 2] ?? 0) +
1694
+ (left[3 * 4 + row] ?? 0) * (right[column * 4 + 3] ?? 0);
1695
+ }
1696
+ }
1697
+ return out;
1698
+ }
1699
+ function transformPosition(position, matrix) {
1700
+ const x = (matrix[0] ?? 1) * position[0] + (matrix[4] ?? 0) * position[1] + (matrix[8] ?? 0) * position[2] + (matrix[12] ?? 0);
1701
+ const y = (matrix[1] ?? 0) * position[0] + (matrix[5] ?? 1) * position[1] + (matrix[9] ?? 0) * position[2] + (matrix[13] ?? 0);
1702
+ const z = (matrix[2] ?? 0) * position[0] + (matrix[6] ?? 0) * position[1] + (matrix[10] ?? 1) * position[2] + (matrix[14] ?? 0);
1703
+ const w = (matrix[3] ?? 0) * position[0] + (matrix[7] ?? 0) * position[1] + (matrix[11] ?? 0) * position[2] + (matrix[15] ?? 1);
1704
+ const inverseW = Math.abs(w) > 1e-8 ? 1 / w : 1;
1705
+ return [
1706
+ x * inverseW,
1707
+ y * inverseW,
1708
+ z * inverseW
1709
+ ];
1710
+ }
1711
+ function toDepth(ndcZ) {
1712
+ return Math.max(0, Math.min(1, ndcZ * 0.5 + 0.5));
1713
+ }
1714
+ function passesDepthTest(target, pixelIndex, depth, enabled, write) {
1715
+ if (!enabled || !target.depthPixels)
1716
+ return true;
1717
+ if (depth > (target.depthPixels[pixelIndex] ?? 1) + 1e-6)
1718
+ return false;
1719
+ if (write)
1720
+ target.depthPixels[pixelIndex] = depth;
1721
+ return true;
1722
+ }
1723
+ function readPosition(bytes, stride, offset, vertexIndex) {
1724
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
1725
+ const base = vertexIndex * stride + offset;
1726
+ return [
1727
+ view.getFloat32(base, true),
1728
+ view.getFloat32(base + 4, true),
1729
+ view.getFloat32(base + 8, true)
1730
+ ];
1731
+ }
1732
+ function readMorphedPosition(bytes, stride, offset, vertexIndex, uniforms) {
1733
+ const basePosition = readPosition(bytes, stride, offset, vertexIndex);
1734
+ const packed = uniforms?.get("u_morphPositionDeltas");
1735
+ const weights = uniforms?.get("u_morphWeights");
1736
+ const targetCountValue = uniforms?.get("u_morphTargetCount");
1737
+ if (!(packed instanceof Float32Array) || !(weights instanceof Float32Array) || typeof targetCountValue !== "number") {
1738
+ return basePosition;
1739
+ }
1740
+ const targetCount = Math.max(0, Math.min(weights.length, Math.floor(targetCountValue)));
1741
+ let x = basePosition[0];
1742
+ let y = basePosition[1];
1743
+ let z = basePosition[2];
1744
+ for (let target = 0; target < targetCount; target += 1) {
1745
+ const weight = weights[target] ?? 0;
1746
+ const deltaOffset = (target * 64 + vertexIndex) * 4;
1747
+ x += (packed[deltaOffset] ?? 0) * weight;
1748
+ y += (packed[deltaOffset + 1] ?? 0) * weight;
1749
+ z += (packed[deltaOffset + 2] ?? 0) * weight;
1750
+ }
1751
+ return [x, y, z];
1752
+ }
1753
+ function toPixel(position, width, height) {
1754
+ return [
1755
+ (position[0] * 0.5 + 0.5) * (width - 1),
1756
+ (1 - (position[1] * 0.5 + 0.5)) * (height - 1),
1757
+ toDepth(position[2])
1758
+ ];
1759
+ }
1760
+ function identityMatrix() {
1761
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
1762
+ }
1763
+ function readVertexColor(bytes, stride, offset, vertexIndex) {
1764
+ if (offset === undefined)
1765
+ return [1, 1, 1, 1];
1766
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
1767
+ const base = vertexIndex * stride + offset;
1768
+ return [
1769
+ view.getFloat32(base, true),
1770
+ view.getFloat32(base + 4, true),
1771
+ view.getFloat32(base + 8, true),
1772
+ view.getFloat32(base + 12, true)
1773
+ ];
1774
+ }
1775
+ function readVertexUv(bytes, stride, offset, vertexIndex) {
1776
+ if (offset === undefined)
1777
+ return [0, 0];
1778
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
1779
+ const base = vertexIndex * stride + offset;
1780
+ return [view.getFloat32(base, true), view.getFloat32(base + 4, true)];
1781
+ }
1782
+ function rasterizeTriangle(target, a, b, c, worldA, worldB, worldC, color, colorA, colorB, colorC, uvA, uvB, uvC, texture, shadow, depthTest, depthWrite) {
1783
+ const pa = toPixel(a, target.width, target.height);
1784
+ const pb = toPixel(b, target.width, target.height);
1785
+ const pc = toPixel(c, target.width, target.height);
1786
+ const minX = clampInt(Math.floor(Math.min(pa[0], pb[0], pc[0])), 0, target.width - 1);
1787
+ const maxX = clampInt(Math.ceil(Math.max(pa[0], pb[0], pc[0])), 0, target.width - 1);
1788
+ const minY = clampInt(Math.floor(Math.min(pa[1], pb[1], pc[1])), 0, target.height - 1);
1789
+ const maxY = clampInt(Math.ceil(Math.max(pa[1], pb[1], pc[1])), 0, target.height - 1);
1790
+ const area = edge(pa, pb, pc);
1791
+ if (Math.abs(area) < 1e-6)
1792
+ return;
1793
+ for (let y = minY; y <= maxY; y += 1) {
1794
+ for (let x = minX; x <= maxX; x += 1) {
1795
+ const p = [x + 0.5, y + 0.5];
1796
+ const w0 = edge(pb, pc, p);
1797
+ const w1 = edge(pc, pa, p);
1798
+ const w2 = edge(pa, pb, p);
1799
+ if ((w0 >= 0 && w1 >= 0 && w2 >= 0) || (w0 <= 0 && w1 <= 0 && w2 <= 0)) {
1800
+ const invArea = 1 / area;
1801
+ const wa = w0 * invArea;
1802
+ const wb = w1 * invArea;
1803
+ const wc = w2 * invArea;
1804
+ const uv = [
1805
+ uvA[0] * wa + uvB[0] * wb + uvC[0] * wc,
1806
+ uvA[1] * wa + uvB[1] * wb + uvC[1] * wc
1807
+ ];
1808
+ const worldPosition = [
1809
+ worldA[0] * wa + worldB[0] * wb + worldC[0] * wc,
1810
+ worldA[1] * wa + worldB[1] * wb + worldC[1] * wc,
1811
+ worldA[2] * wa + worldB[2] * wb + worldC[2] * wc
1812
+ ];
1813
+ const pixelIndex = y * target.width + x;
1814
+ const depth = pa[2] * wa + pb[2] * wb + pc[2] * wc;
1815
+ if (!passesDepthTest(target, pixelIndex, depth, depthTest, depthWrite))
1816
+ continue;
1817
+ const shadedColor = multiplyColor(multiplyColor(color, interpolateColor(colorA, colorB, colorC, wa, wb, wc)), texture ? sampleTextureBinding(texture, uv) : [1, 1, 1, 1]);
1818
+ target.colorPixels.set(rgbaBytes(multiplyColor(shadedColor, shadowFactor(shadow, worldPosition))), pixelIndex * 4);
1819
+ }
1820
+ }
1821
+ }
1822
+ }
1823
+ function rasterizeLine(target, a, b, color, colorA, colorB, depthTest, depthWrite) {
1824
+ const pa = toPixel(a, target.width, target.height);
1825
+ const pb = toPixel(b, target.width, target.height);
1826
+ const x0 = clampInt(Math.round(pa[0]), 0, target.width - 1);
1827
+ const y0 = clampInt(Math.round(pa[1]), 0, target.height - 1);
1828
+ const x1 = clampInt(Math.round(pb[0]), 0, target.width - 1);
1829
+ const y1 = clampInt(Math.round(pb[1]), 0, target.height - 1);
1830
+ const dx = Math.abs(x1 - x0);
1831
+ const dy = Math.abs(y1 - y0);
1832
+ const steps = Math.max(dx, dy, 1);
1833
+ const shadedA = multiplyColor(color, colorA);
1834
+ const shadedB = multiplyColor(color, colorB);
1835
+ for (let step = 0; step <= steps; step += 1) {
1836
+ const t = step / steps;
1837
+ const x = clampInt(Math.round(x0 + (x1 - x0) * t), 0, target.width - 1);
1838
+ const y = clampInt(Math.round(y0 + (y1 - y0) * t), 0, target.height - 1);
1839
+ const pixelIndex = y * target.width + x;
1840
+ const depth = pa[2] + (pb[2] - pa[2]) * t;
1841
+ if (!passesDepthTest(target, pixelIndex, depth, depthTest, depthWrite))
1842
+ continue;
1843
+ const shaded = lerpColor(shadedA, shadedB, t);
1844
+ target.colorPixels.set(rgbaBytes(shaded), pixelIndex * 4);
1845
+ }
1846
+ }
1847
+ function rasterizePoint(target, point, color, depthTest, depthWrite) {
1848
+ const pixel = toPixel(point, target.width, target.height);
1849
+ const centerX = clampInt(Math.round(pixel[0]), 0, target.width - 1);
1850
+ const centerY = clampInt(Math.round(pixel[1]), 0, target.height - 1);
1851
+ const bytes = rgbaBytes(color);
1852
+ for (let y = centerY - 2; y <= centerY + 2; y += 1) {
1853
+ if (y < 0 || y >= target.height)
1854
+ continue;
1855
+ for (let x = centerX - 2; x <= centerX + 2; x += 1) {
1856
+ if (x < 0 || x >= target.width)
1857
+ continue;
1858
+ const pixelIndex = y * target.width + x;
1859
+ if (!passesDepthTest(target, pixelIndex, pixel[2], depthTest, depthWrite))
1860
+ continue;
1861
+ target.colorPixels.set(bytes, pixelIndex * 4);
1862
+ }
1863
+ }
1864
+ }
1865
+ function sampleTextureBinding(binding, uv) {
1866
+ const texture = binding.texture;
1867
+ if (!texture || texture.disposed)
1868
+ return [1, 1, 1, 1];
1869
+ const level = texture.textureLevels[0] ?? texture.fallbackTextureLevels[0];
1870
+ if (!level || level.data.length < level.width * level.height * 4)
1871
+ return [1, 1, 1, 1];
1872
+ const transformed = binding.transformUV(uv);
1873
+ const u = addressCoordinate(transformed[0], binding.sampler.addressU);
1874
+ const v = addressCoordinate(transformed[1], binding.sampler.addressV);
1875
+ const x = clampInt(Math.round(u * (level.width - 1)), 0, level.width - 1);
1876
+ const y = clampInt(Math.round(v * (level.height - 1)), 0, level.height - 1);
1877
+ const offset = (y * level.width + x) * 4;
1878
+ const r = (level.data[offset] ?? 255) / 255;
1879
+ const g = (level.data[offset + 1] ?? 255) / 255;
1880
+ const b = (level.data[offset + 2] ?? 255) / 255;
1881
+ return [
1882
+ texture.colorSpace === "srgb" ? srgbToLinear(r) : r,
1883
+ texture.colorSpace === "srgb" ? srgbToLinear(g) : g,
1884
+ texture.colorSpace === "srgb" ? srgbToLinear(b) : b,
1885
+ (level.data[offset + 3] ?? 255) / 255
1886
+ ];
1887
+ }
1888
+ function srgbToLinear(value) {
1889
+ return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
1890
+ }
1891
+ function shadowFactor(shadow, worldPosition) {
1892
+ if (!shadow)
1893
+ return [1, 1, 1, 1];
1894
+ const projected = transformPosition(worldPosition, shadow.matrix);
1895
+ if (projected[0] < -1 || projected[0] > 1 || projected[1] < -1 || projected[1] > 1 || projected[2] < -1 || projected[2] > 1) {
1896
+ return [1, 1, 1, 1];
1897
+ }
1898
+ const uv = [projected[0] * 0.5 + 0.5, projected[1] * 0.5 + 0.5];
1899
+ const storedDepth = sampleTextureBinding(shadow.texture, uv)[0];
1900
+ const receiverDepth = projected[2] * 0.5 + 0.5 - shadow.bias;
1901
+ const visibility = receiverDepth > storedDepth ? 1 - shadow.strength : 1;
1902
+ return [visibility, visibility, visibility, 1];
1903
+ }
1904
+ function addressCoordinate(value, mode) {
1905
+ if (mode === "repeat")
1906
+ return value - Math.floor(value);
1907
+ if (mode === "mirror-repeat") {
1908
+ const repeated = value - Math.floor(value);
1909
+ return Math.floor(value) % 2 === 0 ? repeated : 1 - repeated;
1910
+ }
1911
+ return Math.min(1, Math.max(0, value));
1912
+ }
1913
+ function lerpColor(a, b, t) {
1914
+ return [
1915
+ a[0] + (b[0] - a[0]) * t,
1916
+ a[1] + (b[1] - a[1]) * t,
1917
+ a[2] + (b[2] - a[2]) * t,
1918
+ a[3] + (b[3] - a[3]) * t
1919
+ ];
1920
+ }
1921
+ function interpolateColor(a, b, c, wa, wb, wc) {
1922
+ return [
1923
+ a[0] * wa + b[0] * wb + c[0] * wc,
1924
+ a[1] * wa + b[1] * wb + c[1] * wc,
1925
+ a[2] * wa + b[2] * wb + c[2] * wc,
1926
+ a[3] * wa + b[3] * wb + c[3] * wc
1927
+ ];
1928
+ }
1929
+ function multiplyColor(a, b) {
1930
+ return [a[0] * b[0], a[1] * b[1], a[2] * b[2], a[3] * b[3]];
1931
+ }
1932
+ function edge(a, b, c) {
1933
+ return (c[0] - a[0]) * (b[1] - a[1]) - (c[1] - a[1]) * (b[0] - a[0]);
1934
+ }
1935
+ function clampInt(value, min, max) {
1936
+ return Math.min(max, Math.max(min, value));
1937
+ }
1938
+ function createNativeShaderSources(sources) {
1939
+ const vertexEntry = inferWGSLVertexEntryPoint(sources.vertex) ?? "vs_main";
1940
+ const fragmentEntry = inferWGSLFragmentEntryPoint(sources.fragment) ?? "fs_main";
1941
+ if (/\@(vertex|fragment|compute)\b/.test(sources.vertex) || /\@(vertex|fragment|compute)\b/.test(sources.fragment)) {
1942
+ return { vertex: sources.vertex, fragment: sources.fragment, entryPoints: [vertexEntry, fragmentEntry], uniformLayout: "passthrough" };
1943
+ }
1944
+ if (sources.marker.includes("instanced-pbr")) {
1945
+ return { ...nativeInstancedPbrShader(vertexEntry, fragmentEntry, sources.marker), entryPoints: [vertexEntry, fragmentEntry], uniformLayout: "generated-instanced-pbr" };
1946
+ }
1947
+ if (sources.marker.includes("pbr-textured")) {
1948
+ return { ...nativeTexturedPbrShader(vertexEntry, fragmentEntry, sources.marker, nativeShaderUsesTangent(sources.vertex)), entryPoints: [vertexEntry, fragmentEntry], uniformLayout: "generated-textured-pbr" };
1949
+ }
1950
+ if (sources.marker.includes("pbr-direct")) {
1951
+ return sources.fragment.includes("u_baseColorTexture")
1952
+ ? { ...nativeTexturedPbrShader(vertexEntry, fragmentEntry, sources.marker, nativeShaderUsesTangent(sources.vertex)), entryPoints: [vertexEntry, fragmentEntry], uniformLayout: "generated-textured-pbr" }
1953
+ : { ...nativePbrShader(vertexEntry, fragmentEntry, sources.marker), entryPoints: [vertexEntry, fragmentEntry], uniformLayout: "generated-pbr" };
1954
+ }
1955
+ if (sources.marker.includes("skinned-unlit")) {
1956
+ return { ...nativeSkinnedUnlitShader(vertexEntry, fragmentEntry, sources.marker), entryPoints: [vertexEntry, fragmentEntry], uniformLayout: "generated-skinned-unlit" };
1957
+ }
1958
+ if (sources.marker.includes("morph-unlit")) {
1959
+ return { ...nativeMorphUnlitShader(vertexEntry, fragmentEntry, sources.marker), entryPoints: [vertexEntry, fragmentEntry], uniformLayout: "generated-morph-unlit" };
1960
+ }
1961
+ if (/sampler2D/.test(sources.fragment) && /layout\s*\(\s*location\s*=\s*2\s*\)\s*in\s+vec2/.test(sources.vertex)) {
1962
+ return {
1963
+ vertex: `// ${sources.marker}\nstruct DrawUniforms {\n modelViewProjection: mat4x4<f32>,\n color: vec4<f32>,\n};\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv: vec2<f32>,\n};\n\n@group(0) @binding(0) var<uniform> u_draw: DrawUniforms;\n\n@vertex\nfn ${vertexEntry}(@location(0) position: vec3<f32>, @location(2) uv: vec2<f32>) -> VertexOutput {\n var output: VertexOutput;\n let clipPosition = u_draw.modelViewProjection * vec4<f32>(position, 1.0);
1964
+ output.position = vec4<f32>(clipPosition.x, clipPosition.y, clipPosition.z * 0.5 + clipPosition.w * 0.5, clipPosition.w);\n output.uv = uv;\n return output;\n}\n`,
1965
+ fragment: `// ${sources.marker}\nstruct DrawUniforms {\n modelViewProjection: mat4x4<f32>,\n color: vec4<f32>,\n};\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv: vec2<f32>,\n};\n\n@group(0) @binding(0) var<uniform> u_draw: DrawUniforms;\n@group(0) @binding(1) var u_textureSampler: sampler;\n@group(0) @binding(2) var u_texture: texture_2d<f32>;\n\n@fragment\nfn ${fragmentEntry}(input: VertexOutput) -> @location(0) vec4<f32> {\n return u_draw.color * textureSample(u_texture, u_textureSampler, input.uv);\n}\n`,
1966
+ entryPoints: [vertexEntry, fragmentEntry],
1967
+ uniformLayout: "generated-texture"
1968
+ };
1969
+ }
1970
+ return {
1971
+ vertex: `// ${sources.marker}\nstruct DrawUniforms {\n modelViewProjection: mat4x4<f32>,\n color: vec4<f32>,\n};\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> u_draw: DrawUniforms;\n\n@vertex\nfn ${vertexEntry}(@location(0) position: vec3<f32>) -> VertexOutput {\n var output: VertexOutput;\n let clipPosition = u_draw.modelViewProjection * vec4<f32>(position, 1.0);
1972
+ output.position = vec4<f32>(clipPosition.x, clipPosition.y, clipPosition.z * 0.5 + clipPosition.w * 0.5, clipPosition.w);\n return output;\n}\n`,
1973
+ fragment: `// ${sources.marker}\nstruct DrawUniforms {\n modelViewProjection: mat4x4<f32>,\n color: vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> u_draw: DrawUniforms;\n\n@fragment\nfn ${fragmentEntry}() -> @location(0) vec4<f32> {\n return u_draw.color;\n}\n`,
1974
+ entryPoints: [vertexEntry, fragmentEntry],
1975
+ uniformLayout: "generated-basic"
1976
+ };
1977
+ }
1978
+ function nativeUniformStruct() {
1979
+ return `struct DrawUniforms {
1980
+ modelViewProjection: mat4x4<f32>,
1981
+ color: vec4<f32>,
1982
+ params: vec4<f32>,
1983
+ flags: vec4<f32>,
1984
+ reserved0: vec4<f32>,
1985
+ instance0: mat4x4<f32>,
1986
+ instance1: mat4x4<f32>,
1987
+ instance2: mat4x4<f32>,
1988
+ instance3: mat4x4<f32>,
1989
+ joint0: mat4x4<f32>,
1990
+ joint1: mat4x4<f32>,
1991
+ morph0: vec4<f32>,
1992
+ morph1: vec4<f32>,
1993
+ morph2: vec4<f32>,
1994
+ morph3: vec4<f32>,
1995
+ morph4: vec4<f32>,
1996
+ morph5: vec4<f32>,
1997
+ morph6: vec4<f32>,
1998
+ morph7: vec4<f32>,
1999
+ material: vec4<f32>,
2000
+ camera: vec4<f32>,
2001
+ materialFlags: vec4<f32>,
2002
+ normalMatrix: mat4x4<f32>,
2003
+ };
2004
+
2005
+ @group(0) @binding(0) var<uniform> u_draw: DrawUniforms;
2006
+
2007
+ fn a3dWebGPUClipPosition(clipPosition: vec4<f32>) -> vec4<f32> {
2008
+ return vec4<f32>(clipPosition.x, clipPosition.y, clipPosition.z * 0.5 + clipPosition.w * 0.5, clipPosition.w);
2009
+ }
2010
+ `;
2011
+ }
2012
+ function nativeShaderUsesTangent(vertexSource) {
2013
+ return /\ba_tangent\b/.test(vertexSource) || /layout\s*\(\s*location\s*=\s*3\s*\)\s*in\s+vec4/.test(vertexSource);
2014
+ }
2015
+ function nativePbrFragmentPrelude(marker) {
2016
+ return `// ${marker}
2017
+ ${nativeUniformStruct()}
2018
+ @group(0) @binding(1) var u_baseSampler: sampler;
2019
+ @group(0) @binding(2) var u_baseTexture: texture_2d<f32>;
2020
+ @group(0) @binding(3) var u_environmentSampler: sampler;
2021
+ @group(0) @binding(4) var u_environmentTexture: texture_2d<f32>;
2022
+ @group(0) @binding(5) var u_brdfSampler: sampler;
2023
+ @group(0) @binding(6) var u_brdfTexture: texture_2d<f32>;
2024
+ @group(0) @binding(7) var u_shadowSampler: sampler;
2025
+ @group(0) @binding(8) var u_shadowTexture: texture_2d<f32>;
2026
+ @group(0) @binding(9) var u_normalSampler: sampler;
2027
+ @group(0) @binding(10) var u_normalTexture: texture_2d<f32>;
2028
+ @group(0) @binding(11) var u_metallicRoughnessSampler: sampler;
2029
+ @group(0) @binding(12) var u_metallicRoughnessTexture: texture_2d<f32>;
2030
+ @group(0) @binding(13) var u_occlusionSampler: sampler;
2031
+ @group(0) @binding(14) var u_occlusionTexture: texture_2d<f32>;
2032
+
2033
+ struct VertexOutput {
2034
+ @builtin(position) position: vec4<f32>,
2035
+ @location(0) normal: vec3<f32>,
2036
+ @location(1) uv: vec2<f32>,
2037
+ @location(2) worldPosition: vec3<f32>,
2038
+ @location(3) tangent: vec4<f32>,
2039
+ };
2040
+
2041
+ fn fresnelSchlick(cosTheta: f32, f0: vec3<f32>) -> vec3<f32> {
2042
+ return f0 + (vec3<f32>(1.0, 1.0, 1.0) - f0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
2043
+ }
2044
+
2045
+ fn fresnelSchlickRoughness(cosTheta: f32, f0: vec3<f32>, roughness: f32) -> vec3<f32> {
2046
+ let smoothness = 1.0 - clamp(roughness, 0.0, 1.0);
2047
+ return f0 + (max(vec3<f32>(smoothness, smoothness, smoothness), f0) - f0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
2048
+ }
2049
+
2050
+ fn ggxDistribution(nDotH: f32, roughness: f32) -> f32 {
2051
+ let a = max(roughness * roughness, 0.045);
2052
+ let a2 = a * a;
2053
+ let denom = max((nDotH * nDotH) * (a2 - 1.0) + 1.0, 0.001);
2054
+ return a2 / max(3.14159265 * denom * denom, 0.001);
2055
+ }
2056
+
2057
+ fn ggxVisibilitySmithCorrelated(nDotV: f32, nDotL: f32, roughness: f32) -> f32 {
2058
+ let a = max(roughness * roughness, 0.045);
2059
+ let a2 = a * a;
2060
+ let lambdaV = nDotL * sqrt(max((nDotV - a2 * nDotV) * nDotV + a2, 0.00001));
2061
+ let lambdaL = nDotV * sqrt(max((nDotL - a2 * nDotL) * nDotL + a2, 0.00001));
2062
+ return 0.5 / max(lambdaV + lambdaL, 0.00001);
2063
+ }
2064
+
2065
+ fn diffuseBurley(nDotV: f32, nDotL: f32, lDotH: f32, roughness: f32) -> f32 {
2066
+ let energyBias = mix(0.0, 0.5, roughness);
2067
+ let energyFactor = mix(1.0, 1.0 / 1.51, roughness);
2068
+ let fd90 = energyBias + 2.0 * lDotH * lDotH * roughness;
2069
+ let lightScatter = 1.0 + (fd90 - 1.0) * pow(clamp(1.0 - nDotL, 0.0, 1.0), 5.0);
2070
+ let viewScatter = 1.0 + (fd90 - 1.0) * pow(clamp(1.0 - nDotV, 0.0, 1.0), 5.0);
2071
+ return lightScatter * viewScatter * energyFactor;
2072
+ }
2073
+
2074
+ fn encodePbrOutput(linearColor: vec3<f32>) -> vec3<f32> {
2075
+ let color = max(linearColor, vec3<f32>(0.0, 0.0, 0.0));
2076
+ let filmic = clamp((color * (2.51 * color + vec3<f32>(0.03, 0.03, 0.03))) / (color * (2.43 * color + vec3<f32>(0.59, 0.59, 0.59)) + vec3<f32>(0.14, 0.14, 0.14)), vec3<f32>(0.0, 0.0, 0.0), vec3<f32>(1.0, 1.0, 1.0));
2077
+ return pow(filmic, vec3<f32>(1.0 / 2.2, 1.0 / 2.2, 1.0 / 2.2));
2078
+ }
2079
+
2080
+ fn productPropBodyGate(baseColor: vec3<f32>, strength: f32) -> f32 {
2081
+ let maxChannel = max(max(baseColor.r, baseColor.g), baseColor.b);
2082
+ let minChannel = min(min(baseColor.r, baseColor.g), baseColor.b);
2083
+ let normalized = baseColor / max(maxChannel, 0.001);
2084
+ let warm = clamp(strength, 0.0, 1.0)
2085
+ * smoothstep(0.18, 0.42, maxChannel)
2086
+ * smoothstep(0.04, 0.2, maxChannel - minChannel)
2087
+ * smoothstep(0.64, 0.84, normalized.r)
2088
+ * (1.0 - smoothstep(0.12, 0.32, normalized.b));
2089
+ return warm * smoothstep(0.46, 0.64, normalized.g) * (1.0 - smoothstep(0.74, 0.94, normalized.b));
2090
+ }
2091
+
2092
+ fn productPropOrangeGate(baseColor: vec3<f32>, strength: f32) -> f32 {
2093
+ let maxChannel = max(max(baseColor.r, baseColor.g), baseColor.b);
2094
+ let minChannel = min(min(baseColor.r, baseColor.g), baseColor.b);
2095
+ let normalized = baseColor / max(maxChannel, 0.001);
2096
+ let warm = clamp(strength, 0.0, 1.0)
2097
+ * smoothstep(0.32, 0.58, maxChannel)
2098
+ * smoothstep(0.05, 0.24, maxChannel - minChannel)
2099
+ * smoothstep(0.68, 0.88, normalized.r)
2100
+ * (1.0 - smoothstep(0.1, 0.28, normalized.b));
2101
+ return warm * (1.0 - smoothstep(0.34, 0.58, normalized.g)) * smoothstep(0.012, 0.08, baseColor.g);
2102
+ }
2103
+
2104
+ fn productPropAlbedo(baseColor: vec3<f32>, strength: f32) -> vec3<f32> {
2105
+ let orangeGate = productPropOrangeGate(baseColor, strength);
2106
+ let bodyGate = productPropBodyGate(baseColor, strength) * (1.0 - orangeGate * 0.92);
2107
+ let maxChannel = max(max(baseColor.r, baseColor.g), baseColor.b);
2108
+ let bodyLuma = mix(0.98, 1.03, smoothstep(0.24, 0.9, maxChannel));
2109
+ let beakLuma = mix(0.94, 1.02, smoothstep(0.2, 0.82, maxChannel));
2110
+ var color = mix(baseColor, vec3<f32>(1.0, 0.88, 0.012) * bodyLuma, clamp(bodyGate * 0.995, 0.0, 0.995));
2111
+ color = mix(color, vec3<f32>(1.0, 0.24, 0.018) * beakLuma, clamp(orangeGate * 0.99, 0.0, 0.99));
2112
+ return color;
2113
+ }
2114
+
2115
+ fn perturbNormal(normalInput: vec3<f32>, tangentFrame: vec4<f32>, normalSample: vec3<f32>, normalScale: f32) -> vec3<f32> {
2116
+ let n = normalize(normalInput);
2117
+ let tangent = normalize(tangentFrame.xyz);
2118
+ let bitangent = normalize(cross(n, tangent) * tangentFrame.w);
2119
+ let mapped = vec3<f32>((normalSample.xy * 2.0 - vec2<f32>(1.0, 1.0)) * max(normalScale, 0.0), normalSample.z * 2.0 - 1.0);
2120
+ return normalize(tangent * mapped.x + bitangent * mapped.y + n * max(mapped.z, 0.001));
2121
+ }
2122
+
2123
+ fn shadePbr(normalInput: vec3<f32>, tangentFrame: vec4<f32>, uv: vec2<f32>, worldPosition: vec3<f32>) -> vec4<f32> {
2124
+ var normal = normalize(normalInput);
2125
+ if (u_draw.morph0.x > 0.5) {
2126
+ normal = perturbNormal(normal, tangentFrame, textureSample(u_normalTexture, u_normalSampler, uv).rgb, u_draw.morph0.y);
2127
+ }
2128
+ let viewDirection = normalize(u_draw.camera.xyz - worldPosition);
2129
+ let lightDirection = normalize(vec3<f32>(0.36, 0.52, 0.78));
2130
+ let halfVector = normalize(lightDirection + viewDirection);
2131
+ var baseColor = u_draw.color.rgb;
2132
+ var materialAlpha = u_draw.color.a;
2133
+ if (u_draw.flags.x > 0.5) {
2134
+ let baseSample = textureSample(u_baseTexture, u_baseSampler, uv);
2135
+ baseColor = baseColor * baseSample.rgb;
2136
+ materialAlpha = materialAlpha * baseSample.a;
2137
+ }
2138
+ let sourceProductBaseColor = baseColor;
2139
+ let productOrangeGate = productPropOrangeGate(sourceProductBaseColor, u_draw.materialFlags.z);
2140
+ let productBodyGate = productPropBodyGate(sourceProductBaseColor, u_draw.materialFlags.z) * (1.0 - productOrangeGate * 0.92);
2141
+ let productSurfaceGate = clamp(productBodyGate + productOrangeGate * 0.72, 0.0, 1.0);
2142
+ baseColor = productPropAlbedo(sourceProductBaseColor, u_draw.materialFlags.z);
2143
+ if (materialAlpha < u_draw.material.x) {
2144
+ discard;
2145
+ }
2146
+ let transmission = clamp(max(u_draw.material.y, u_draw.material.z), 0.0, 1.0);
2147
+ let metallicRoughnessSample = textureSample(u_metallicRoughnessTexture, u_metallicRoughnessSampler, uv);
2148
+ let metallicRoughnessEnabled = step(0.5, u_draw.materialFlags.x);
2149
+ let occlusionEnabled = step(0.5, u_draw.materialFlags.y);
2150
+ let sampledMetallic = clamp(u_draw.params.x * metallicRoughnessSample.b, 0.0, 1.0);
2151
+ let sampledRoughness = clamp(u_draw.params.y * metallicRoughnessSample.g, 0.045, 1.0);
2152
+ let sampledOcclusion = mix(1.0, textureSample(u_occlusionTexture, u_occlusionSampler, uv).r, clamp(u_draw.morph0.z, 0.0, 1.0));
2153
+ let metallic = mix(clamp(u_draw.params.x, 0.0, 1.0), sampledMetallic, metallicRoughnessEnabled);
2154
+ let roughness = mix(clamp(u_draw.params.y, 0.045, 1.0), sampledRoughness, metallicRoughnessEnabled);
2155
+ let occlusion = mix(1.0, sampledOcclusion, occlusionEnabled);
2156
+ let smoothedProductNormal = normalize(vec3<f32>(normal.x * 0.42, max(normal.y, 0.28), normal.z * 0.42));
2157
+ normal = normalize(mix(normal, smoothedProductNormal, productBodyGate * 0.46 + productOrangeGate * 0.84));
2158
+ let nDotL = max(dot(normal, lightDirection), 0.0);
2159
+ let nDotV = max(dot(normal, viewDirection), 0.001);
2160
+ let nDotH = max(dot(normal, halfVector), 0.001);
2161
+ let vDotH = max(dot(viewDirection, halfVector), 0.001);
2162
+ let f0 = mix(vec3<f32>(0.04, 0.04, 0.04), baseColor, metallic);
2163
+ let fresnel = fresnelSchlick(vDotH, f0);
2164
+ let distribution = ggxDistribution(nDotH, roughness);
2165
+ let visibility = ggxVisibilitySmithCorrelated(nDotV, nDotL, roughness);
2166
+ let lDotH = max(dot(lightDirection, halfVector), 0.0);
2167
+ let kd = (vec3<f32>(1.0, 1.0, 1.0) - fresnel) * (1.0 - metallic);
2168
+ let specular = fresnel * distribution * visibility;
2169
+ let diffuse = kd * baseColor * diffuseBurley(nDotV, nDotL, lDotH, roughness) / 3.14159265;
2170
+ var environment = baseColor * u_draw.params.z * (0.28 + 0.72 * clamp(normal.y * 0.5 + 0.5, 0.0, 1.0)) * occlusion;
2171
+ var environmentSpecularContribution = vec3<f32>(0.0, 0.0, 0.0);
2172
+ if (u_draw.flags.w > 0.5) {
2173
+ let reflectionDirection = reflect(-viewDirection, normal);
2174
+ let diffuseUv = vec2<f32>(fract(atan2(normal.z, normal.x) / 6.2831853 + 0.5), acos(clamp(normal.y, -1.0, 1.0)) / 3.14159265);
2175
+ let specularUv = vec2<f32>(fract(atan2(reflectionDirection.z, reflectionDirection.x) / 6.2831853 + 0.5), acos(clamp(reflectionDirection.y, -1.0, 1.0)) / 3.14159265);
2176
+ let environmentMipCount = max(u_draw.reserved0.z, 1.0);
2177
+ let diffuseEnv = textureSampleLevel(u_environmentTexture, u_environmentSampler, diffuseUv, max(environmentMipCount - 1.0, 0.0)).rgb;
2178
+ let specularEnv = textureSampleLevel(u_environmentTexture, u_environmentSampler, specularUv, roughness * max(environmentMipCount - 1.0, 0.0)).rgb;
2179
+ let brdf = textureSampleLevel(u_brdfTexture, u_brdfSampler, vec2<f32>(nDotV, roughness), 0.0).rg;
2180
+ let environmentFresnel = fresnelSchlickRoughness(nDotV, f0, roughness);
2181
+ let environmentDiffuse = (vec3<f32>(1.0, 1.0, 1.0) - environmentFresnel) * (1.0 - metallic) * diffuseEnv * baseColor * u_draw.params.w * occlusion;
2182
+ let environmentSpecular = specularEnv * (f0 * brdf.x + vec3<f32>(brdf.y, brdf.y, brdf.y)) * max(u_draw.reserved0.w, 0.0);
2183
+ environmentSpecularContribution = environmentSpecular;
2184
+ environment = environment + environmentDiffuse + environmentSpecular;
2185
+ }
2186
+ var shadow = 1.0;
2187
+ if (u_draw.flags.y > 0.5) {
2188
+ let shadowDepth = textureSampleLevel(u_shadowTexture, u_shadowSampler, vec2<f32>(0.5, 0.5), 0.0).r;
2189
+ shadow = mix(1.0, shadowDepth, clamp(u_draw.flags.z, 0.0, 1.0));
2190
+ }
2191
+ let litOpaqueLinearColor = environment + (diffuse + specular) * nDotL * 2.25 * shadow;
2192
+ let smoothedBodyColor = mix(baseColor, vec3<f32>(1.0, 0.88, 0.012), productBodyGate * 0.32);
2193
+ let smoothedBeakColor = mix(baseColor, vec3<f32>(1.0, 0.24, 0.018), productOrangeGate * 0.82);
2194
+ let softBodyProduct = smoothedBodyColor * (1.5 + 0.06 * nDotL) + specular * nDotL * 0.018;
2195
+ let softBeakProduct = smoothedBeakColor * (1.08 + 0.05 * nDotL) + specular * nDotL * 0.018;
2196
+ var opaqueLinearColor = mix(litOpaqueLinearColor, softBodyProduct, productBodyGate * 0.78);
2197
+ opaqueLinearColor = mix(opaqueLinearColor, softBeakProduct, productOrangeGate * 0.95);
2198
+ let transmittedTint = baseColor * u_draw.params.w * (0.18 + 0.42 * clamp(1.0 - roughness, 0.0, 1.0)) + environmentSpecularContribution * 1.35;
2199
+ let linearColor = mix(opaqueLinearColor, opaqueLinearColor * 0.22 + transmittedTint, transmission);
2200
+ let outputAlpha = mix(materialAlpha, min(materialAlpha, 0.22), transmission);
2201
+ return vec4<f32>(encodePbrOutput(linearColor), outputAlpha);
2202
+ }
2203
+ `;
2204
+ }
2205
+ function nativePbrShader(vertexEntry, fragmentEntry, marker) {
2206
+ return {
2207
+ vertex: `// ${marker}
2208
+ ${nativeUniformStruct()}
2209
+ struct VertexOutput {
2210
+ @builtin(position) position: vec4<f32>,
2211
+ @location(0) normal: vec3<f32>,
2212
+ @location(1) uv: vec2<f32>,
2213
+ @location(2) worldPosition: vec3<f32>,
2214
+ @location(3) tangent: vec4<f32>,
2215
+ };
2216
+
2217
+ @vertex
2218
+ fn ${vertexEntry}(@location(0) position: vec3<f32>, @location(1) normal: vec3<f32>) -> VertexOutput {
2219
+ var output: VertexOutput;
2220
+ let worldPosition = (u_draw.instance0 * vec4<f32>(position, 1.0)).xyz;
2221
+ output.position = a3dWebGPUClipPosition(u_draw.modelViewProjection * vec4<f32>(position, 1.0));
2222
+ output.normal = normalize((u_draw.normalMatrix * vec4<f32>(normal, 0.0)).xyz);
2223
+ output.uv = vec2<f32>(0.5, 0.5);
2224
+ output.worldPosition = worldPosition;
2225
+ output.tangent = vec4<f32>(1.0, 0.0, 0.0, 1.0);
2226
+ return output;
2227
+ }
2228
+ `,
2229
+ fragment: `${nativePbrFragmentPrelude(marker)}
2230
+ @fragment
2231
+ fn ${fragmentEntry}(input: VertexOutput) -> @location(0) vec4<f32> {
2232
+ return shadePbr(input.normal, input.tangent, input.uv, input.worldPosition);
2233
+ }
2234
+ `
2235
+ };
2236
+ }
2237
+ function nativeTexturedPbrShader(vertexEntry, fragmentEntry, marker, usesTangent) {
2238
+ return {
2239
+ vertex: `// ${marker}
2240
+ ${nativeUniformStruct()}
2241
+ struct VertexOutput {
2242
+ @builtin(position) position: vec4<f32>,
2243
+ @location(0) normal: vec3<f32>,
2244
+ @location(1) uv: vec2<f32>,
2245
+ @location(2) worldPosition: vec3<f32>,
2246
+ @location(3) tangent: vec4<f32>,
2247
+ };
2248
+
2249
+ @vertex
2250
+ fn ${vertexEntry}(@location(0) position: vec3<f32>, @location(1) normal: vec3<f32>, @location(2) uv: vec2<f32>${usesTangent ? ", @location(3) tangent: vec4<f32>" : ""}) -> VertexOutput {
2251
+ var output: VertexOutput;
2252
+ let worldPosition = (u_draw.instance0 * vec4<f32>(position, 1.0)).xyz;
2253
+ output.position = a3dWebGPUClipPosition(u_draw.modelViewProjection * vec4<f32>(position, 1.0));
2254
+ output.normal = normalize((u_draw.normalMatrix * vec4<f32>(normal, 0.0)).xyz);
2255
+ output.uv = uv;
2256
+ output.worldPosition = worldPosition;
2257
+ ${usesTangent ? "output.tangent = vec4<f32>(normalize((u_draw.normalMatrix * vec4<f32>(tangent.xyz, 0.0)).xyz), tangent.w);" : "output.tangent = vec4<f32>(1.0, 0.0, 0.0, 1.0);"}
2258
+ return output;
2259
+ }
2260
+ `,
2261
+ fragment: `${nativePbrFragmentPrelude(marker)}
2262
+ @fragment
2263
+ fn ${fragmentEntry}(input: VertexOutput) -> @location(0) vec4<f32> {
2264
+ return shadePbr(input.normal, input.tangent, input.uv, input.worldPosition);
2265
+ }
2266
+ `
2267
+ };
2268
+ }
2269
+ function nativeInstancedPbrShader(vertexEntry, fragmentEntry, marker) {
2270
+ return {
2271
+ vertex: `// ${marker}
2272
+ ${nativeUniformStruct()}
2273
+ struct VertexOutput {
2274
+ @builtin(position) position: vec4<f32>,
2275
+ @location(0) normal: vec3<f32>,
2276
+ @location(1) uv: vec2<f32>,
2277
+ @location(2) worldPosition: vec3<f32>,
2278
+ @location(3) tangent: vec4<f32>,
2279
+ };
2280
+
2281
+ fn instanceMatrix(index: u32) -> mat4x4<f32> {
2282
+ if (index == 1u) { return u_draw.instance1; }
2283
+ if (index == 2u) { return u_draw.instance2; }
2284
+ if (index == 3u) { return u_draw.instance3; }
2285
+ return u_draw.instance0;
2286
+ }
2287
+
2288
+ @vertex
2289
+ fn ${vertexEntry}(@location(0) position: vec3<f32>, @location(1) normal: vec3<f32>, @builtin(instance_index) instanceIndex: u32) -> VertexOutput {
2290
+ var output: VertexOutput;
2291
+ let model = instanceMatrix(instanceIndex);
2292
+ let worldPosition = (model * vec4<f32>(position, 1.0)).xyz;
2293
+ output.position = a3dWebGPUClipPosition(u_draw.modelViewProjection * model * vec4<f32>(position, 1.0));
2294
+ output.normal = normalize((model * vec4<f32>(normal, 0.0)).xyz);
2295
+ output.uv = vec2<f32>(0.5, 0.5);
2296
+ output.worldPosition = worldPosition;
2297
+ output.tangent = vec4<f32>(1.0, 0.0, 0.0, 1.0);
2298
+ return output;
2299
+ }
2300
+ `,
2301
+ fragment: `${nativePbrFragmentPrelude(marker)}
2302
+ @fragment
2303
+ fn ${fragmentEntry}(input: VertexOutput) -> @location(0) vec4<f32> {
2304
+ return shadePbr(input.normal, input.tangent, input.uv, input.worldPosition);
2305
+ }
2306
+ `
2307
+ };
2308
+ }
2309
+ function nativeSkinnedUnlitShader(vertexEntry, fragmentEntry, marker) {
2310
+ return {
2311
+ vertex: `// ${marker}
2312
+ ${nativeUniformStruct()}
2313
+ struct VertexOutput {
2314
+ @builtin(position) position: vec4<f32>,
2315
+ };
2316
+
2317
+ fn jointMatrix(index: f32) -> mat4x4<f32> {
2318
+ if (index > 0.5) { return u_draw.joint1; }
2319
+ return u_draw.joint0;
2320
+ }
2321
+
2322
+ @vertex
2323
+ fn ${vertexEntry}(@location(0) position: vec3<f32>, @location(5) joints: vec4<f32>, @location(6) weights: vec4<f32>) -> VertexOutput {
2324
+ var output: VertexOutput;
2325
+ let skin = jointMatrix(joints.x) * weights.x + jointMatrix(joints.y) * weights.y + jointMatrix(joints.z) * weights.z + jointMatrix(joints.w) * weights.w;
2326
+ let weightSum = weights.x + weights.y + weights.z + weights.w;
2327
+ let skinned = select(vec4<f32>(position, 1.0), skin * vec4<f32>(position, 1.0), weightSum > 0.0001);
2328
+ output.position = a3dWebGPUClipPosition(u_draw.modelViewProjection * skinned);
2329
+ return output;
2330
+ }
2331
+ `,
2332
+ fragment: `// ${marker}
2333
+ ${nativeUniformStruct()}
2334
+ @fragment
2335
+ fn ${fragmentEntry}() -> @location(0) vec4<f32> {
2336
+ return u_draw.color;
2337
+ }
2338
+ `
2339
+ };
2340
+ }
2341
+ function nativeMorphUnlitShader(vertexEntry, fragmentEntry, marker) {
2342
+ return {
2343
+ vertex: `// ${marker}
2344
+ ${nativeUniformStruct()}
2345
+ struct VertexOutput {
2346
+ @builtin(position) position: vec4<f32>,
2347
+ };
2348
+
2349
+ fn morphDelta(index: u32) -> vec3<f32> {
2350
+ if (index == 0u) { return u_draw.morph0.xyz; }
2351
+ if (index == 1u) { return u_draw.morph1.xyz; }
2352
+ if (index == 2u) { return u_draw.morph2.xyz; }
2353
+ if (index == 3u) { return u_draw.morph3.xyz; }
2354
+ if (index == 4u) { return u_draw.morph4.xyz; }
2355
+ if (index == 5u) { return u_draw.morph5.xyz; }
2356
+ if (index == 6u) { return u_draw.morph6.xyz; }
2357
+ return u_draw.morph7.xyz;
2358
+ }
2359
+
2360
+ @vertex
2361
+ fn ${vertexEntry}(@location(0) position: vec3<f32>, @builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
2362
+ var output: VertexOutput;
2363
+ let enabled = min(u_draw.reserved0.y, 1.0);
2364
+ let morphed = position + morphDelta(min(vertexIndex, 7u)) * u_draw.reserved0.x * enabled;
2365
+ output.position = a3dWebGPUClipPosition(u_draw.modelViewProjection * vec4<f32>(morphed, 1.0));
2366
+ return output;
2367
+ }
2368
+ `,
2369
+ fragment: `// ${marker}
2370
+ ${nativeUniformStruct()}
2371
+ @fragment
2372
+ fn ${fragmentEntry}() -> @location(0) vec4<f32> {
2373
+ return u_draw.color;
2374
+ }
2375
+ `
2376
+ };
2377
+ }
2378
+ function inferWGSLVertexEntryPoint(source) {
2379
+ return /@vertex\s+fn\s+([A-Za-z_]\w*)/.exec(source)?.[1];
2380
+ }
2381
+ function inferWGSLFragmentEntryPoint(source) {
2382
+ return /@fragment\s+fn\s+([A-Za-z_]\w*)/.exec(source)?.[1];
2383
+ }
2384
+ function vertexBufferLayout(format) {
2385
+ return {
2386
+ arrayStride: format.stride,
2387
+ attributes: format.attributes.map((attribute) => ({
2388
+ shaderLocation: attribute.shaderLocation,
2389
+ offset: attribute.offset,
2390
+ format: vertexAttributeFormat(attribute.components)
2391
+ }))
2392
+ };
2393
+ }
2394
+ function vertexAttributeFormat(components) {
2395
+ if (components === 1)
2396
+ return "float32";
2397
+ if (components === 2)
2398
+ return "float32x2";
2399
+ if (components === 3)
2400
+ return "float32x3";
2401
+ return "float32x4";
2402
+ }
2403
+ //# sourceMappingURL=WebGPUDevice.js.map