@babylonjs/lite 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/{_mat4-storage-f64-WeexU-hd.js → _mat4-storage-f64-BqqOLkos.js} +2 -2
  2. package/{_mat4-storage-f64-WeexU-hd.js.map → _mat4-storage-f64-BqqOLkos.js.map} +1 -1
  3. package/{alpha-test-fragment-x2mnjLgC.js → alpha-test-fragment-D8oeUpvv.js} +2 -2
  4. package/{alpha-test-fragment-x2mnjLgC.js.map → alpha-test-fragment-D8oeUpvv.js.map} +1 -1
  5. package/{background-dds-skybox-BpcDr-9c.js → background-dds-skybox-Cv92mmdC.js} +3 -4
  6. package/{background-dds-skybox-BpcDr-9c.js.map → background-dds-skybox-Cv92mmdC.js.map} +1 -1
  7. package/{background-ground-Bm6gjWqx.js → background-ground-ClcWiDuF.js} +2 -3
  8. package/{background-ground-Bm6gjWqx.js.map → background-ground-ClcWiDuF.js.map} +1 -1
  9. package/{background-hdr-skybox-CSFo8RX6.js → background-hdr-skybox-MfAwLhVx.js} +3 -3
  10. package/{background-hdr-skybox-CSFo8RX6.js.map → background-hdr-skybox-MfAwLhVx.js.map} +1 -1
  11. package/{background-solid-skybox-DOOBeDIz.js → background-solid-skybox-CkmGuOn5.js} +2 -3
  12. package/{background-solid-skybox-DOOBeDIz.js.map → background-solid-skybox-CkmGuOn5.js.map} +1 -1
  13. package/{billboard-renderable-IJfCpeDS.js → billboard-renderable-CmIfD7IP.js} +2 -2
  14. package/{billboard-renderable-IJfCpeDS.js.map → billboard-renderable-CmIfD7IP.js.map} +1 -1
  15. package/{clamp-block-BD_t8I89.js → clamp-block-Bupvx5sX.js} +2 -2
  16. package/{clamp-block-BD_t8I89.js.map → clamp-block-Bupvx5sX.js.map} +1 -1
  17. package/{clearcoat-fragment-Dj7vGX2u.js → clearcoat-fragment-wfkXOHHZ.js} +2 -2
  18. package/{clearcoat-fragment-Dj7vGX2u.js.map → clearcoat-fragment-wfkXOHHZ.js.map} +1 -1
  19. package/{create-skeleton-s0hjrC3A.js → create-skeleton-41NqPV9u.js} +2 -2
  20. package/{create-skeleton-s0hjrC3A.js.map → create-skeleton-41NqPV9u.js.map} +1 -1
  21. package/{cubemap-skybox-material-8lzbgi7K.js → cubemap-skybox-material-BWGdKMLi.js} +2 -2
  22. package/{cubemap-skybox-material-8lzbgi7K.js.map → cubemap-skybox-material-BWGdKMLi.js.map} +1 -1
  23. package/{curve-block-Ditr4R7V.js → curve-block-CeLMJE2N.js} +2 -2
  24. package/{curve-block-Ditr4R7V.js.map → curve-block-CeLMJE2N.js.map} +1 -1
  25. package/{emissive-fragment-BOAezkfk.js → emissive-fragment-CDJhX8ad.js} +2 -2
  26. package/{emissive-fragment-BOAezkfk.js.map → emissive-fragment-CDJhX8ad.js.map} +1 -1
  27. package/{esm-shadow-view-JCPaOOi7.js → esm-shadow-view-CcX1jdrL.js} +2 -2
  28. package/{esm-shadow-view-JCPaOOi7.js.map → esm-shadow-view-CcX1jdrL.js.map} +1 -1
  29. package/{esm-shadow-view-DRpyRAfa.js → esm-shadow-view-Cf2PwVNs.js} +2 -2
  30. package/{esm-shadow-view-DRpyRAfa.js.map → esm-shadow-view-Cf2PwVNs.js.map} +1 -1
  31. package/{esm-shadow-view-DmIORQGZ.js → esm-shadow-view-KyVyZnKZ.js} +2 -2
  32. package/{esm-shadow-view-DmIORQGZ.js.map → esm-shadow-view-KyVyZnKZ.js.map} +1 -1
  33. package/{gaussian-splatting-pipeline-sh-B30Mu56i.js → gaussian-splatting-pipeline-sh-lM48JDca.js} +2 -2
  34. package/{gaussian-splatting-pipeline-sh-B30Mu56i.js.map → gaussian-splatting-pipeline-sh-lM48JDca.js.map} +1 -1
  35. package/{geometry-texture-output-DURiaJ_n.js → geometry-texture-output-DSeH_3G_.js} +2 -2
  36. package/{geometry-texture-output-DURiaJ_n.js.map → geometry-texture-output-DSeH_3G_.js.map} +1 -1
  37. package/{geometry-view-DRrscyWU.js → geometry-view-L27hzPQF.js} +3 -4
  38. package/{geometry-view-DRrscyWU.js.map → geometry-view-L27hzPQF.js.map} +1 -1
  39. package/{gltf-animation-BjnXkop6.js → gltf-animation-Db8PwXmY.js} +6 -5
  40. package/gltf-animation-Db8PwXmY.js.map +1 -0
  41. package/{gltf-ext-basisu-DtzVV1Xx.js → gltf-ext-basisu-BARpgeiU.js} +2 -2
  42. package/{gltf-ext-basisu-DtzVV1Xx.js.map → gltf-ext-basisu-BARpgeiU.js.map} +1 -1
  43. package/{gltf-ext-node-visibility-BhX0DmiP.js → gltf-ext-node-visibility-Cv7HyWR_.js} +2 -2
  44. package/{gltf-ext-node-visibility-BhX0DmiP.js.map → gltf-ext-node-visibility-Cv7HyWR_.js.map} +1 -1
  45. package/{gltf-ext-quantization-DaymajCR.js → gltf-ext-quantization-DIYKR7_3.js} +2 -2
  46. package/{gltf-ext-quantization-DaymajCR.js.map → gltf-ext-quantization-DIYKR7_3.js.map} +1 -1
  47. package/{gltf-ext-uv-transform-DFmNJ8kA.js → gltf-ext-uv-transform-qU-LScDy.js} +2 -2
  48. package/{gltf-ext-uv-transform-DFmNJ8kA.js.map → gltf-ext-uv-transform-qU-LScDy.js.map} +1 -1
  49. package/gltf-feature-animation-pointer-nDf6dGpL.js +161 -0
  50. package/gltf-feature-animation-pointer-nDf6dGpL.js.map +1 -0
  51. package/{gltf-feature-animations-v0S_yb4T.js → gltf-feature-animations-Dr9AsgIN.js} +3 -3
  52. package/{gltf-feature-animations-v0S_yb4T.js.map → gltf-feature-animations-Dr9AsgIN.js.map} +1 -1
  53. package/gltf-feature-draco-CRgxNaK1.js +33 -0
  54. package/gltf-feature-draco-CRgxNaK1.js.map +1 -0
  55. package/{gltf-feature-gpu-instancing-BoeSm6Tn.js → gltf-feature-gpu-instancing-QfJNFW1R.js} +2 -2
  56. package/{gltf-feature-gpu-instancing-BoeSm6Tn.js.map → gltf-feature-gpu-instancing-QfJNFW1R.js.map} +1 -1
  57. package/{gltf-feature-lights-punctual-BCTwgyi_.js → gltf-feature-lights-punctual-B3xbCshn.js} +5 -5
  58. package/{gltf-feature-lights-punctual-BCTwgyi_.js.map → gltf-feature-lights-punctual-B3xbCshn.js.map} +1 -1
  59. package/{gltf-feature-meshopt-DItMkOMt.js → gltf-feature-meshopt-DBvtC2n2.js} +2 -34
  60. package/gltf-feature-meshopt-DBvtC2n2.js.map +1 -0
  61. package/{gltf-feature-morph-Cv0mEYIq.js → gltf-feature-morph-DE63vfIE.js} +3 -3
  62. package/{gltf-feature-morph-Cv0mEYIq.js.map → gltf-feature-morph-DE63vfIE.js.map} +1 -1
  63. package/{gltf-feature-registry-wNbt6UC-.js → gltf-feature-registry-DfOiNmhR.js} +15 -15
  64. package/{gltf-feature-registry-wNbt6UC-.js.map → gltf-feature-registry-DfOiNmhR.js.map} +1 -1
  65. package/{gltf-feature-skeleton-Deh2UBAn.js → gltf-feature-skeleton-IHj-DuKx.js} +12 -3
  66. package/gltf-feature-skeleton-IHj-DuKx.js.map +1 -0
  67. package/{gltf-feature-variants-DGSdFNJq.js → gltf-feature-variants-C-eyBru5.js} +2 -2
  68. package/{gltf-feature-variants-DGSdFNJq.js.map → gltf-feature-variants-C-eyBru5.js.map} +1 -1
  69. package/{gltf-glb-parser-DSQWsT4r.js → gltf-glb-parser-DXMAJA8e.js} +2 -2
  70. package/{gltf-glb-parser-DSQWsT4r.js.map → gltf-glb-parser-DXMAJA8e.js.map} +1 -1
  71. package/{gltf-interleave-OBqmlu-h.js → gltf-interleave-BdKrRH3j.js} +4 -4
  72. package/gltf-interleave-BdKrRH3j.js.map +1 -0
  73. package/{gltf-pbr-builder-ext-3imk8Tev.js → gltf-pbr-builder-ext-DJ8Jm7jo.js} +2 -2
  74. package/{gltf-pbr-builder-ext-3imk8Tev.js.map → gltf-pbr-builder-ext-DJ8Jm7jo.js.map} +1 -1
  75. package/{gltf-variants-Dyr54wwg.js → gltf-variants-C0HetOre.js} +4 -4
  76. package/{gltf-variants-Dyr54wwg.js.map → gltf-variants-C0HetOre.js.map} +1 -1
  77. package/{gpu-task-timer-DVBNZfq5.js → gpu-task-timer-C-3sLTxO.js} +2 -2
  78. package/{gpu-task-timer-DVBNZfq5.js.map → gpu-task-timer-C-3sLTxO.js.map} +1 -1
  79. package/{gs-picking-pipeline-CERN-Trj.js → gs-picking-pipeline-DlogO8fI.js} +2 -2
  80. package/{gs-picking-pipeline-CERN-Trj.js.map → gs-picking-pipeline-DlogO8fI.js.map} +1 -1
  81. package/{havok-floating-origin-VVdJRUYc.js → havok-floating-origin-CQ7yE-XD.js} +2 -2
  82. package/{havok-floating-origin-VVdJRUYc.js.map → havok-floating-origin-CQ7yE-XD.js.map} +1 -1
  83. package/{index-BgY3QEzL.js → index-C2sM8ERH.js} +2697 -932
  84. package/index-C2sM8ERH.js.map +1 -0
  85. package/index.d.ts +443 -12
  86. package/index.js +525 -507
  87. package/{input-block-DjdlndCL.js → input-block-DfFVJB-8.js} +2 -2
  88. package/{input-block-DjdlndCL.js.map → input-block-DfFVJB-8.js.map} +1 -1
  89. package/{iridescence-fragment-kfsCs8lN.js → iridescence-fragment-CQwzyZ3W.js} +2 -2
  90. package/{iridescence-fragment-kfsCs8lN.js.map → iridescence-fragment-CQwzyZ3W.js.map} +1 -1
  91. package/{light-block-qjCrz3de.js → light-block-othUHIHC.js} +2 -2
  92. package/{light-block-qjCrz3de.js.map → light-block-othUHIHC.js.map} +1 -1
  93. package/{loop-block-C8vkQ2bz.js → loop-block-DgHyTx97.js} +2 -2
  94. package/{loop-block-C8vkQ2bz.js.map → loop-block-DgHyTx97.js.map} +1 -1
  95. package/{morph-fragment-NpZYyIIU.js → morph-fragment-D_rgysrc.js} +2 -2
  96. package/{morph-fragment-NpZYyIIU.js.map → morph-fragment-D_rgysrc.js.map} +1 -1
  97. package/{multilight-wgsl-I5SncF0q.js → multilight-wgsl-DRmyM3cC.js} +2 -2
  98. package/{multilight-wgsl-I5SncF0q.js.map → multilight-wgsl-DRmyM3cC.js.map} +1 -1
  99. package/{node-env-D7Aee08u.js → node-env-B-Ca2DL0.js} +2 -2
  100. package/{node-env-D7Aee08u.js.map → node-env-B-Ca2DL0.js.map} +1 -1
  101. package/{node-geometry-view-DfKXWNfV.js → node-geometry-view-BJDB-lrf.js} +3 -3
  102. package/{node-geometry-view-DfKXWNfV.js.map → node-geometry-view-BJDB-lrf.js.map} +1 -1
  103. package/{node-registry-extra-compat-CDLeBR1P.js → node-registry-extra-compat-SwS962Ax.js} +2 -2
  104. package/{node-registry-extra-compat-CDLeBR1P.js.map → node-registry-extra-compat-SwS962Ax.js.map} +1 -1
  105. package/{node-registry-extra-math-BA8_l4lB.js → node-registry-extra-math-Bsj4UAE5.js} +2 -2
  106. package/{node-registry-extra-math-BA8_l4lB.js.map → node-registry-extra-math-Bsj4UAE5.js.map} +1 -1
  107. package/{node-renderable-EwLLnaL1.js → node-renderable-BOIc3hM1.js} +2 -2
  108. package/{node-renderable-EwLLnaL1.js.map → node-renderable-BOIc3hM1.js.map} +1 -1
  109. package/{node-shadow-CeTmT6g4.js → node-shadow-DE--Q2V1.js} +2 -2
  110. package/{node-shadow-CeTmT6g4.js.map → node-shadow-DE--Q2V1.js.map} +1 -1
  111. package/{normal-map-fragment-BHImLyM-.js → normal-map-fragment-Cjm-v9uq.js} +2 -3
  112. package/{normal-map-fragment-BHImLyM-.js.map → normal-map-fragment-Cjm-v9uq.js.map} +1 -1
  113. package/package.json +3 -3
  114. package/{parse-camera-5IGdctAS.js → parse-camera-uQ8oKgeH.js} +2 -2
  115. package/{parse-camera-5IGdctAS.js.map → parse-camera-uQ8oKgeH.js.map} +1 -1
  116. package/{pbr-fog-wgsl-BqdCid6r.js → pbr-fog-wgsl-B5LrMToX.js} +2 -2
  117. package/{pbr-fog-wgsl-BqdCid6r.js.map → pbr-fog-wgsl-B5LrMToX.js.map} +1 -1
  118. package/{pbr-geometry-view-Dthf9Aut.js → pbr-geometry-view-BI52zgUI.js} +9 -11
  119. package/pbr-geometry-view-BI52zgUI.js.map +1 -0
  120. package/{pbr-metallic-roughness-block-g7wjzwN_.js → pbr-metallic-roughness-block-C7s1jL4q.js} +2 -2
  121. package/{pbr-metallic-roughness-block-g7wjzwN_.js.map → pbr-metallic-roughness-block-C7s1jL4q.js.map} +1 -1
  122. package/{pbr-metallic-roughness-block-full-DD6zI_Lx.js → pbr-metallic-roughness-block-full-BuhhVBFO.js} +2 -2
  123. package/{pbr-metallic-roughness-block-full-DD6zI_Lx.js.map → pbr-metallic-roughness-block-full-BuhhVBFO.js.map} +1 -1
  124. package/{pbr-mr-helper-core-CWROQ7OA.js → pbr-mr-helper-core-XeyKg-g6.js} +2 -2
  125. package/{pbr-mr-helper-core-CWROQ7OA.js.map → pbr-mr-helper-core-XeyKg-g6.js.map} +1 -1
  126. package/{pbr-refraction-Dxsm_gii.js → pbr-refraction-Bxz4GDeh.js} +2 -2
  127. package/{pbr-refraction-Dxsm_gii.js.map → pbr-refraction-Bxz4GDeh.js.map} +1 -1
  128. package/{pbr-renderable-CuKWalEM.js → pbr-renderable-B0elfRlX.js} +41 -189
  129. package/pbr-renderable-B0elfRlX.js.map +1 -0
  130. package/{pbr-shadow-fragment-waeIBQUq.js → pbr-shadow-fragment-QHbgqVlc.js} +2 -2
  131. package/{pbr-shadow-fragment-waeIBQUq.js.map → pbr-shadow-fragment-QHbgqVlc.js.map} +1 -1
  132. package/{pbr-tracking-CdeqbBrh.js → pbr-tracking-BWWSjls_.js} +2 -2
  133. package/{pbr-tracking-CdeqbBrh.js.map → pbr-tracking-BWWSjls_.js.map} +1 -1
  134. package/{pbr-transmission-ext-BNiXngZc.js → pbr-transmission-ext-DiEBLim-.js} +2 -2
  135. package/{pbr-transmission-ext-BNiXngZc.js.map → pbr-transmission-ext-DiEBLim-.js.map} +1 -1
  136. package/{reflectance-fragment-BQFZ_pgy.js → reflectance-fragment-wBk8UtBP.js} +2 -2
  137. package/{reflectance-fragment-BQFZ_pgy.js.map → reflectance-fragment-wBk8UtBP.js.map} +1 -1
  138. package/{rgbd-decode-duTlXMWd.js → rgbd-decode-CAQ7XSwl.js} +2 -2
  139. package/{rgbd-decode-duTlXMWd.js.map → rgbd-decode-CAQ7XSwl.js.map} +1 -1
  140. package/{screenshot-readback-DnxR4rhp.js → screenshot-readback-NxsFpnE4.js} +2 -2
  141. package/{screenshot-readback-DnxR4rhp.js.map → screenshot-readback-NxsFpnE4.js.map} +1 -1
  142. package/{shader-renderable-DVMVD6zP.js → shader-renderable-CUlJSove.js} +4 -196
  143. package/shader-renderable-CUlJSove.js.map +1 -0
  144. package/{shader-thin-instance-CsDo3ULk.js → shader-thin-instance-BjIbuYdv.js} +2 -2
  145. package/{shader-thin-instance-CsDo3ULk.js.map → shader-thin-instance-BjIbuYdv.js.map} +1 -1
  146. package/{sheen-fragment-B_Jd7wrr.js → sheen-fragment-ef8myYaq.js} +2 -2
  147. package/{sheen-fragment-B_Jd7wrr.js.map → sheen-fragment-ef8myYaq.js.map} +1 -1
  148. package/{singlelight-directional-wgsl-Bw84txva.js → singlelight-directional-wgsl-BvFBA1MO.js} +2 -2
  149. package/{singlelight-directional-wgsl-Bw84txva.js.map → singlelight-directional-wgsl-BvFBA1MO.js.map} +1 -1
  150. package/{singlelight-hemispheric-wgsl-DjxhgI8r.js → singlelight-hemispheric-wgsl-BEsGCqSN.js} +2 -2
  151. package/{singlelight-hemispheric-wgsl-DjxhgI8r.js.map → singlelight-hemispheric-wgsl-BEsGCqSN.js.map} +1 -1
  152. package/{singlelight-point-wgsl-iA1aRkXA.js → singlelight-point-wgsl-CvMr18Zf.js} +2 -2
  153. package/{singlelight-point-wgsl-iA1aRkXA.js.map → singlelight-point-wgsl-CvMr18Zf.js.map} +1 -1
  154. package/{singlelight-spot-wgsl-MDdTdstF.js → singlelight-spot-wgsl-jYIr13wU.js} +2 -2
  155. package/{singlelight-spot-wgsl-MDdTdstF.js.map → singlelight-spot-wgsl-jYIr13wU.js.map} +1 -1
  156. package/{skeleton-fragment-COdHWFcK.js → skeleton-fragment-B9M_ddNC.js} +2 -2
  157. package/{skeleton-fragment-COdHWFcK.js.map → skeleton-fragment-B9M_ddNC.js.map} +1 -1
  158. package/{skybox-renderable-DJYkfw32.js → skybox-renderable-lbMC32aI.js} +2 -3
  159. package/{skybox-renderable-DJYkfw32.js.map → skybox-renderable-lbMC32aI.js.map} +1 -1
  160. package/{splat-ply-compressed-SxMlsKNK.js → splat-ply-compressed-B_w2N_V7.js} +2 -2
  161. package/{splat-ply-compressed-SxMlsKNK.js.map → splat-ply-compressed-B_w2N_V7.js.map} +1 -1
  162. package/{standard-renderable-BAc-i-ig.js → standard-renderable-AYZ-Pdcm.js} +3 -4
  163. package/standard-renderable-AYZ-Pdcm.js.map +1 -0
  164. package/{std-ambient-fragment-P8dHZ4An.js → std-ambient-fragment-BXl-88sn.js} +2 -2
  165. package/{std-ambient-fragment-P8dHZ4An.js.map → std-ambient-fragment-BXl-88sn.js.map} +1 -1
  166. package/{std-cube-reflection-fragment-CF03MuQt.js → std-cube-reflection-fragment-Dn34WuMa.js} +2 -2
  167. package/{std-cube-reflection-fragment-CF03MuQt.js.map → std-cube-reflection-fragment-Dn34WuMa.js.map} +1 -1
  168. package/{std-emissive-fragment-P8yJGclx.js → std-emissive-fragment-CK7TwRAt.js} +2 -2
  169. package/{std-emissive-fragment-P8yJGclx.js.map → std-emissive-fragment-CK7TwRAt.js.map} +1 -1
  170. package/{std-lightmap-fragment-CymEG79z.js → std-lightmap-fragment-BSeS8K-4.js} +2 -2
  171. package/{std-lightmap-fragment-CymEG79z.js.map → std-lightmap-fragment-BSeS8K-4.js.map} +1 -1
  172. package/{std-opacity-fragment-DLa1zV06.js → std-opacity-fragment-DnLaWH9w.js} +2 -2
  173. package/{std-opacity-fragment-DLa1zV06.js.map → std-opacity-fragment-DnLaWH9w.js.map} +1 -1
  174. package/{std-reflection-fragment-BLySsYos.js → std-reflection-fragment-BToYPemd.js} +2 -2
  175. package/{std-reflection-fragment-BLySsYos.js.map → std-reflection-fragment-BToYPemd.js.map} +1 -1
  176. package/{std-shadow-fragment-C_q27Mdi.js → std-shadow-fragment-9b0rFY7F.js} +2 -2
  177. package/{std-shadow-fragment-C_q27Mdi.js.map → std-shadow-fragment-9b0rFY7F.js.map} +1 -1
  178. package/{std-specular-fragment-CaBXyAWY.js → std-specular-fragment-OBO-zxGh.js} +2 -2
  179. package/{std-specular-fragment-CaBXyAWY.js.map → std-specular-fragment-OBO-zxGh.js.map} +1 -1
  180. package/{std-tracking-Bw61Dv98.js → std-tracking-4SHTntWt.js} +2 -2
  181. package/{std-tracking-Bw61Dv98.js.map → std-tracking-4SHTntWt.js.map} +1 -1
  182. package/{subsurface-fragment-BNQoG9gr.js → subsurface-fragment-D7QRWN_d.js} +2 -2
  183. package/{subsurface-fragment-BNQoG9gr.js.map → subsurface-fragment-D7QRWN_d.js.map} +1 -1
  184. package/{thin-instance-cull-binding-BNC5JiGw.js → thin-instance-cull-binding-D-p2Yxfg.js} +3 -3
  185. package/{thin-instance-cull-binding-BNC5JiGw.js.map → thin-instance-cull-binding-D-p2Yxfg.js.map} +1 -1
  186. package/{thin-instance-gpu-C1DGstap.js → thin-instance-gpu-QETC_NyQ.js} +2 -2
  187. package/{thin-instance-gpu-C1DGstap.js.map → thin-instance-gpu-QETC_NyQ.js.map} +1 -1
  188. package/{tracking-primitives-CMBWLxGr.js → tracking-primitives-CqIIi7Ej.js} +2 -2
  189. package/{tracking-primitives-CMBWLxGr.js.map → tracking-primitives-CqIIi7Ej.js.map} +1 -1
  190. package/{unlit-fragment-BsHrS9XX.js → unlit-fragment-DPWDQLxo.js} +2 -2
  191. package/{unlit-fragment-BsHrS9XX.js.map → unlit-fragment-DPWDQLxo.js.map} +1 -1
  192. package/gltf-animation-BjnXkop6.js.map +0 -1
  193. package/gltf-feature-animation-pointer-C40tqOhL.js +0 -88
  194. package/gltf-feature-animation-pointer-C40tqOhL.js.map +0 -1
  195. package/gltf-feature-draco-CljWrsna.js +0 -125
  196. package/gltf-feature-draco-CljWrsna.js.map +0 -1
  197. package/gltf-feature-meshopt-DItMkOMt.js.map +0 -1
  198. package/gltf-feature-skeleton-Deh2UBAn.js.map +0 -1
  199. package/gltf-interleave-OBqmlu-h.js.map +0 -1
  200. package/index-BgY3QEzL.js.map +0 -1
  201. package/pbr-geometry-view-Dthf9Aut.js.map +0 -1
  202. package/pbr-renderable-CuKWalEM.js.map +0 -1
  203. package/shader-composer-CBy2i8nU.js +0 -293
  204. package/shader-composer-CBy2i8nU.js.map +0 -1
  205. package/shader-renderable-DVMVD6zP.js.map +0 -1
  206. package/standard-pipeline-DXFOUqU_.js +0 -391
  207. package/standard-pipeline-DXFOUqU_.js.map +0 -1
  208. package/standard-renderable-BAc-i-ig.js.map +0 -1
  209. package/wgsl-helpers-D8sl1VVA.js +0 -48
  210. package/wgsl-helpers-D8sl1VVA.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"pbr-geometry-view-Dthf9Aut.js","sources":["../src/material/pbr/pbr-geometry-output-shader.ts","../src/material/pbr/pbr-geometry-renderable.ts","../src/material/pbr/pbr-geometry-view.ts"],"sourcesContent":["/** PBR geometry-output shader composer.\n *\n * Builds the WGSL for a {@link createPbrGeometryMaterialView}-wrapped PBR\n * material that targets the geometry-renderer MRT pass.\n *\n * Design — *zero bundle impact* on PBR scenes that never load the\n * geometry-renderer task:\n *\n * 1. Reuse the per-scene {@link composePbr} captured on the scene context.\n * The composer already wires every PBR feature (IBL, shadows, lights,\n * clearcoat, sheen, iridescence, anisotropy, subsurface, alpha-test,\n * emissive, tonemap, …); none of it needs re-implementing for the\n * real-colour attachment.\n * 2. Register a PBR extension that, only when `PBR2_GEOMETRY_OUTPUT` is on,\n * contributes a small `geometry-params` ShaderFragment carrying the\n * `gp` UBO + per-attachment varyings (vCurrentClip / vPreviousClip /\n * vLocalPos). Off otherwise — no impact on regular PBR composes.\n * 3. Post-process the composed fragment WGSL: change the entry signature\n * to return a `FragmentOutput` MRT struct, inject the struct\n * declaration, and replace the alpha-block `return …` with code that\n * writes each requested geometry attachment from the in-scope PBR\n * intermediates (`N`, `surfaceAlbedo`, `colorF0`, `roughness`,\n * `microSurface`, `finalIrradiance`, `input.worldPos`, …).\n *\n * The lighting / tonemap / gamma pipeline still runs in full, producing\n * the lit `color` written to the optional real-colour attachment. */\n\nimport type { ComposedShader, ShaderFragment, Varying } from \"../../shader/fragment-types.js\";\nimport { GeometryTextureType } from \"../../frame-graph/geometry-types.js\";\nimport { PBR_HAS_ALPHA_BLEND, PBR_HAS_ENV, PBR2_GEOMETRY_OUTPUT, _registerPbrExt, type _PbrBindCtx, type _PbrFragCtx, type PbrExt } from \"./pbr-flags.js\";\nimport type { createPbrComposer, PbrLightMode } from \"./pbr-compose.js\";\nimport type { MeshVbLayout } from \"../../mesh/mesh.js\";\n\nconst STAGE_FRAGMENT = 0x2;\nconst STAGE_VERTEX = 0x1;\n\n// ─── PBR extension contributing the geometry-params fragment ──────────\n\nfunction needsGpUbo(attachments: readonly GeometryTextureType[]): boolean {\n for (const t of attachments) {\n if (t === GeometryTextureType.NORMALIZED_VIEW_DEPTH || t === GeometryTextureType.LINEAR_VELOCITY) {\n return true;\n }\n }\n return false;\n}\n\nfunction needsVelocity(attachments: readonly GeometryTextureType[]): boolean {\n return attachments.includes(GeometryTextureType.LINEAR_VELOCITY);\n}\n\nfunction needsLocalPos(attachments: readonly GeometryTextureType[]): boolean {\n return attachments.includes(GeometryTextureType.LOCAL_POSITION);\n}\n\n/** ShaderFragment contributing the `gp` UBO + (optionally) velocity / local-pos varyings.\n * PBR-specific: world-position varying is `out.worldPos`. */\nfunction createPbrGeometryParamsFragment(needsParamsUbo: boolean, needsVelocityVaryings: boolean, needsLocalPosVarying: boolean): ShaderFragment {\n const bindings = needsParamsUbo ? [{ _name: \"gp\", _type: { _kind: \"uniform-buffer\" as const }, _visibility: STAGE_FRAGMENT | STAGE_VERTEX }] : [];\n const helpers = needsParamsUbo ? `struct gpUniforms { previousViewProjection: mat4x4<f32>, cameraNearFar: vec4<f32>, };` : \"\";\n const varyings: Varying[] = [];\n if (needsVelocityVaryings) {\n varyings.push({ _name: \"vCurrentClip\", _type: \"vec4<f32>\" }, { _name: \"vPreviousClip\", _type: \"vec4<f32>\" });\n }\n if (needsLocalPosVarying) {\n varyings.push({ _name: \"vLocalPos\", _type: \"vec3<f32>\" });\n }\n const vbParts: string[] = [];\n if (needsVelocityVaryings) {\n vbParts.push(`out.vCurrentClip = scene.viewProjection * vec4<f32>(out.worldPos, 1.0);`);\n vbParts.push(`out.vPreviousClip = gp.previousViewProjection * vec4<f32>(out.worldPos, 1.0);`);\n }\n if (needsLocalPosVarying) {\n vbParts.push(`out.vLocalPos = position;`);\n }\n const slots: ShaderFragment[\"_vertexSlots\"] = vbParts.length > 0 ? { VB: vbParts.join(\"\\n\") } : {};\n return {\n _id: \"pbr-geometry-params\",\n _bindings: bindings,\n _helperFunctions: helpers,\n _vertexHelperFunctions: helpers,\n _varyings: varyings,\n _vertexSlots: slots,\n };\n}\n\n/** PBR extension that wires the geometry-params fragment + gp UBO bind entry.\n * Off-path for any scene that doesn't request `PBR2_GEOMETRY_OUTPUT`. */\nlet _pbrGeomExtRegistered = false;\n\n/** @internal Registers (idempotent) the PBR extension that wires up the\n * geometry-output `gp` UBO and varyings. Called by the geometry view at\n * first use so non-geometry PBR scenes pay zero bytes. */\nexport function _ensurePbrGeometryExt(getAttachments: () => readonly GeometryTextureType[] | undefined): void {\n if (_pbrGeomExtRegistered) {\n return;\n }\n _pbrGeomExtRegistered = true;\n const ext: PbrExt = {\n id: \"pbr-geometry-params\",\n // Fragment-phase so bind entry is appended after all other PBR exts.\n phase: \"fragment\",\n frag(ctx: _PbrFragCtx): ShaderFragment | null {\n if ((ctx._features2 & PBR2_GEOMETRY_OUTPUT) === 0) {\n return null;\n }\n const att = getAttachments() ?? [];\n const wantsGp = needsGpUbo(att);\n const wantsVelocity = needsVelocity(att);\n const wantsLocalPos = needsLocalPos(att);\n if (!wantsGp && !wantsVelocity && !wantsLocalPos) {\n return null;\n }\n return createPbrGeometryParamsFragment(wantsGp, wantsVelocity, wantsLocalPos);\n },\n bind(ctx: _PbrBindCtx, entries: GPUBindGroupEntry[], b: number): number {\n if ((ctx._features2 & PBR2_GEOMETRY_OUTPUT) === 0) {\n return b;\n }\n const view = ctx._material as { _gpUBO?: GPUBuffer | null };\n if (view._gpUBO) {\n entries.push({ binding: b++, resource: { buffer: view._gpUBO } });\n }\n return b;\n },\n };\n _registerPbrExt(ext);\n}\n\n// ─── Per-attachment WGSL expressions ──────────────────────────────────\n\n/** Per-attachment WGSL output expression. Symbols are resolved against the\n * in-scope PBR fragment vars at the BC slot location (after tonemap +\n * gamma + contrast; same scope as the alpha-block).\n * @internal */\nfunction attachmentExpr(type: GeometryTextureType, wg: string, hasIbl: boolean): string {\n switch (type) {\n case GeometryTextureType.IRRADIANCE:\n // BJS PREPASS_IRRADIANCE (pbrBlockPrePass.fx): `finalDiffuse + finalIrradiance`\n // — direct-light diffuse plus the IBL diffuse contribution (already multiplied\n // by surfaceAlbedo / occlusion), NOT the raw SH irradiance. Lite's equivalents\n // are `directDiffuse` (direct) and `finalIrradiance` (= environmentIrradiance *\n // surfaceAlbedo * occlusion, ibl-fragment.ts). Both are pre-tonemap, matching BJS.\n return hasIbl ? `vec4<f32>(directDiffuse + finalIrradiance, ${wg})` : `vec4<f32>(directDiffuse, ${wg})`;\n case GeometryTextureType.WORLD_POSITION:\n return `vec4<f32>(input.worldPos, ${wg})`;\n case GeometryTextureType.LOCAL_POSITION:\n return `vec4<f32>(input.vLocalPos, ${wg})`;\n case GeometryTextureType.REFLECTIVITY:\n // BJS PREPASS_REFLECTIVITY (pbrBlockPrePass.fx): `vec4(specularEnvironmentR0, microSurface)`\n // — LINEAR F0 reflectance (no gamma) in RGB, microSurface (= 1 - roughness) in A,\n // the whole vec4 masked by writeGeometryInfo. Lite's `colorF0` is the F0 reflectance.\n return `vec4<f32>(colorF0, 1.0 - roughness) * ${wg}`;\n case GeometryTextureType.VIEW_DEPTH:\n return `vec4<f32>((scene.view * vec4<f32>(input.worldPos, 1.0)).z, 0.0, 0.0, ${wg})`;\n case GeometryTextureType.NORMALIZED_VIEW_DEPTH:\n return `vec4<f32>(((scene.view * vec4<f32>(input.worldPos, 1.0)).z - gp.cameraNearFar.x) / (gp.cameraNearFar.y - gp.cameraNearFar.x), 0.0, 0.0, ${wg})`;\n case GeometryTextureType.SCREENSPACE_DEPTH:\n return `vec4<f32>(input.clipPos.z, 0.0, 0.0, ${wg})`;\n case GeometryTextureType.VIEW_NORMAL:\n return `vec4<f32>(normalize((scene.view * vec4<f32>(N, 0.0)).xyz), ${wg})`;\n case GeometryTextureType.WORLD_NORMAL:\n return `vec4<f32>(N * 0.5 + vec3<f32>(0.5), ${wg})`;\n case GeometryTextureType.ALBEDO:\n // BJS uses `surfaceAlbedo` for PBR (post diffuse / metallic split).\n return `vec4<f32>(surfaceAlbedo, ${wg})`;\n case GeometryTextureType.LINEAR_VELOCITY: {\n const cur = `(input.vCurrentClip.xy / input.vCurrentClip.w)`;\n const prev = `(input.vPreviousClip.xy / input.vPreviousClip.w)`;\n return `vec4<f32>(0.5 * (${prev} - ${cur}), 0.0, ${wg})`;\n }\n }\n}\n\n// ─── Composer entry ────────────────────────────────────────────────────\n\n/** Compose a PBR geometry-output shader by reusing the per-scene composer\n * and post-patching the resulting WGSL into MRT form. */\nexport function composePbrGeometryShader(\n composePbr: ReturnType<typeof createPbrComposer>,\n features: number,\n features2: number,\n meshFeatures: number,\n sceneFeatures: number,\n lightMode: PbrLightMode,\n singleLightType: string,\n esmShadowDepthCode: string,\n vbStrides: MeshVbLayout | undefined,\n vbKey: string,\n attachments: readonly GeometryTextureType[],\n emitColor: boolean\n): ComposedShader {\n // Strip PBR_HAS_ALPHA_BLEND: the template's alpha-blend branch returns\n // `finalAlpha = saturate(alpha + luminanceOverAlpha²)` which we don't need\n // — we drive blending per attachment via the geometry pipeline state and\n // gate writes via the `writeGeometryInfo` mask. Stripping yields the\n // simple `return vec4<f32>(color,alpha*material.materialAlpha);` alpha\n // block which is easier to pattern-match for the replacement.\n const geomFeatures = features & ~PBR_HAS_ALPHA_BLEND;\n // Tag the cache key with PBR2_GEOMETRY_OUTPUT so the geometry composed\n // shader doesn't collide with the regular non-geometry one in composePbr's\n // internal cache.\n const geomFeatures2 = features2 | PBR2_GEOMETRY_OUTPUT;\n\n const base = composePbr(\n geomFeatures,\n geomFeatures2,\n meshFeatures,\n sceneFeatures,\n lightMode,\n singleLightType,\n esmShadowDepthCode,\n vbStrides,\n `${vbKey}:geom:${attachments.join(\",\")}:${emitColor ? \"c\" : \"\"}`\n );\n\n const hasIbl = (sceneFeatures & PBR_HAS_ENV) !== 0;\n\n // ── Post-process the fragment WGSL ────────────────────────────────────\n\n // 1) Swap the entry signature.\n const fragmentSignatureFrom = \"-> @location(0) vec4<f32>\";\n const fragmentSignatureTo = \"-> FragmentOutput\";\n if (!base._fragmentWGSL.includes(fragmentSignatureFrom)) {\n throw new Error(\"composePbrGeometryShader: PBR fragment signature mismatch — _noColorOutput/_esmShadowOutput should be off\");\n }\n let frag = base._fragmentWGSL.replace(fragmentSignatureFrom, fragmentSignatureTo);\n\n // 2) Inject FragmentOutput struct before `@fragment fn main`. When\n // `emitColor` is true, append an extra slot at @location(N) for the\n // real lit colour (matches BJS `targetTexture`).\n const colorSlot = attachments.length;\n const extraColorLine = emitColor ? `\\n@location(${colorSlot}) color: vec4<f32>,` : \"\";\n const outputStruct = `struct FragmentOutput {\n${attachments.map((_, i) => `@location(${i}) f${i}: vec4<f32>,`).join(\"\\n\")}${extraColorLine}\n};\n`;\n frag = frag.replace(\"@fragment fn main\", `${outputStruct}@fragment fn main`);\n\n // 3) Replace the alpha-block return with MRT writes. With ALPHA_BLEND\n // stripped, the template emits the simpler return form.\n const wg = `select(0.0, 1.0, alpha > 0.4)`;\n const writes = attachments.map((type, i) => `out.f${i} = ${attachmentExpr(type, wg, hasIbl)};`).join(\"\\n\");\n const extraColorWrite = emitColor ? `\\nout.color = vec4<f32>(color, alpha * material.materialAlpha);` : \"\";\n const replacement = `var out: FragmentOutput;\n${writes}${extraColorWrite}\nreturn out;`;\n const returnPattern = \"return vec4<f32>(color,alpha*material.materialAlpha);\";\n if (!frag.includes(returnPattern)) {\n throw new Error(\"composePbrGeometryShader: alpha-block return statement not found — template changed?\");\n }\n frag = frag.replace(returnPattern, replacement);\n\n return { ...base, _fragmentWGSL: frag };\n}\n","/** PBR geometry-MRT renderable factory.\n *\n * Builds a {@link Renderable} that draws a single mesh through a\n * {@link createPbrGeometryMaterialView} into the geometry renderer task's\n * multi-attachment render target. Mirrors the regular PBR per-mesh\n * rebuildSingle closure (mesh UBO, material UBO, mesh bind group with env +\n * shadows, draw closure) but swaps the single-target pipeline for a\n * multi-color-attachment one built from the geometry-output shader.\n *\n * Per-(view, mesh-feature-variant) shared state — composed shader, mesh\n * BGL, pipeline cache — is cached on `view._geometry` keyed by the\n * shader-relevant mesh-feature bits + (features, features2, sceneFeatures,\n * lightMode, singleLightType). Per-mesh state (UBOs, bind group, sort\n * centre) lives in the closure returned by {@link buildPbrGeometryRenderable}.\n *\n * This module is imported only by {@link createPbrGeometryMaterialView} —\n * PBR scenes that don't use the geometry renderer task pay zero bytes for\n * it. */\n\nimport { F32 } from \"../../engine/typed-arrays.js\";\nimport type { EngineContext } from \"../../engine/engine.js\";\nimport type { RenderTargetSignature } from \"../../engine/render-target.js\";\nimport type { Mesh } from \"../../mesh/mesh.js\";\nimport type { MeshGroupBuilder, Renderable } from \"../../render/renderable.js\";\nimport { writeMeshLightSelection } from \"../../render/lights-ubo.js\";\nimport type { SceneContext } from \"../../scene/scene-core.js\";\nimport { createUniformBuffer } from \"../../resource/gpu-buffers.js\";\nimport { acquireTexture, releaseTexture } from \"../../resource/gpu-pool.js\";\nimport type { ComposedShader } from \"../../shader/fragment-types.js\";\nimport { targetSignatureKey, REVERSE_DEPTH_COMPARE } from \"../../engine/render-target.js\";\nimport { packMat4IntoF32 } from \"../../math/pack-mat4-into-f32.js\";\nimport { _computeMeshFeatures, MSH_HAS_INSTANCE_COLOR, MSH_HAS_THIN_INSTANCES, MSH_HAS_TANGENTS, MSH_HAS_UV2, MSH_HAS_VERTEX_COLOR } from \"../mesh-features.js\";\nimport type { Material } from \"../material.js\";\nimport { getSceneBindGroupLayout } from \"../../render/scene-helpers.js\";\n\nimport type { PbrMaterialProps } from \"./pbr-material.js\";\nimport { collectPbrBoundTextures } from \"./pbr-material.js\";\nimport { _computePbrMaterialFeatures } from \"./pbr-material.js\";\nimport { PBR_HAS_ALPHA_BLEND, PBR_HAS_DOUBLE_SIDED, PBR_HAS_NORMAL_MAP, PBR2_HAS_UV2 } from \"./pbr-flags.js\";\nimport { createPbrMeshBindGroup } from \"./pbr-pipeline.js\";\nimport type { _PbrGeometryContext } from \"./pbr-renderable.js\";\nimport { _writeMaterialData } from \"./pbr-renderable.js\";\nimport type { PbrGeometryMaterialView } from \"./pbr-geometry-view.js\";\nimport { composePbrGeometryShader, _ensurePbrGeometryExt } from \"./pbr-geometry-output-shader.js\";\nimport { _setActivePbrGeometryAttachments } from \"./pbr-geometry-view.js\";\n\n/** Singleton {@link MeshGroupBuilder} that geometry views point at via their\n * overridden `_buildGroup`. The async builder body is unreachable —\n * geometry views are dispatched per-mesh via `_rebuildSingle` directly. */\nexport const pbrGeometryGroupBuilder: MeshGroupBuilder = (async () => {\n throw new Error(\"pbr-geometry view does not support scene group building\");\n}) as MeshGroupBuilder;\npbrGeometryGroupBuilder._rebuildSingle = (scene: SceneContext, mesh: Mesh, materialOverride?: Material): Renderable => {\n const view = (materialOverride ?? mesh.material) as PbrGeometryMaterialView;\n return buildPbrGeometryRenderable(scene, mesh, view);\n};\npbrGeometryGroupBuilder._materialFamily = \"pbr\";\n\ninterface PbrGeometryViewResources {\n _composed: ComposedShader;\n _features: number;\n _features2: number;\n _meshFeatures: number;\n _sceneFeatures: number;\n _meshBGL: GPUBindGroupLayout;\n _shadowBGL: GPUBindGroupLayout | null;\n _pipelineLayout: GPUPipelineLayout;\n _vertModule: GPUShaderModule;\n _fragModule: GPUShaderModule;\n _pipelines: Map<string, GPURenderPipeline>;\n _alphaBlend: boolean;\n}\n\nfunction _variantKey(meshFeatures: number, lightMode: number, singleLightType: string): string {\n return `${meshFeatures}:${lightMode}:${singleLightType}`;\n}\n\n/** Build a {@link Renderable} for one mesh drawn through a PBR geometry view. */\nexport function buildPbrGeometryRenderable(scene: SceneContext, mesh: Mesh, view: PbrGeometryMaterialView): Renderable {\n const engine = scene.surface.engine;\n const device = engine._device;\n\n const ctx = (scene as SceneContext & { _pbrGeomContext?: _PbrGeometryContext })._pbrGeomContext;\n if (!ctx) {\n throw new Error(\"buildPbrGeometryRenderable: scene has no PBR context. Ensure regular PBR meshes have been built before recording the geometry task.\");\n }\n\n const source = view.source as PbrMaterialProps;\n if (!source._renderFeatures) {\n source._renderFeatures = _computePbrMaterialFeatures(source);\n }\n\n // Light selection mirrors regular PBR rebuildSingle, gated by the same\n // shadow rules so the geometry-pass real-color attachment receives the\n // same lighting as the regular PBR pass would have produced.\n const lr = writeMeshLightSelection(mesh, scene.lights);\n const lightCount = lr > 0 ? 1 : -lr;\n const hasSomeShadows = ctx._shadowLights.length > 0;\n const receiveShadows = mesh.receiveShadows && hasSomeShadows;\n const lightMode: 0 | 1 | 2 = lightCount === 0 ? 0 : lightCount === 1 && !receiveShadows ? 1 : 2;\n const singleLightType = lightMode === 1 ? _getPackedSingleLightType(scene.lights, lr - 1) : \"\";\n const meshFeatures = _computeMeshFeatures(mesh, receiveShadows);\n\n const variantKey = _variantKey(meshFeatures, lightMode, singleLightType);\n const res = _ensureViewResources(view, engine, ctx, meshFeatures, lightMode, singleLightType, variantKey);\n\n const features = res._features;\n const features2 = res._features2;\n const composed = res._composed;\n\n // ── Mesh UBO ───────────────────────────────────────────────────────\n const meshUboData = new F32(composed._meshUboSpec._totalBytes / 4);\n const _packMeshWorld = engine._makePackMeshWorld?.(scene) ?? packMat4IntoF32;\n _packMeshWorld(meshUboData, mesh.worldMatrix, 0, 0);\n writeMeshLightSelection(mesh, scene.lights, meshUboData);\n const meshUBO = createUniformBuffer(engine, meshUboData);\n\n // ── Material UBO ───────────────────────────────────────────────────\n const materialSpec = composed._materialUboSpec!;\n const matInitData = new F32(materialSpec._totalBytes / 4);\n // Use the per-scene writer captured on the geometry context.\n _writePbrMaterialData(matInitData, source, materialSpec);\n const materialUBO = createUniformBuffer(engine, matInitData);\n\n // ── Mesh bind group (group 1). Pass the VIEW as the \"material\" so the\n // PBR geometry ext can read `view._gpUBO`. The view inherits all\n // source fields via its prototype chain, so other ext bind callbacks\n // that look at source.* still resolve correctly.\n //\n // Bind during a scope where `_activeAttachments` is set so that any\n // composePbr cache miss inside `createPbrMeshBindGroup` (none expected\n // here, but defensive) sees the right attachments.\n const prev = _setActivePbrGeometryAttachments(view._geometryAttachments);\n let materialBindGroupStatic: GPUBindGroup;\n try {\n materialBindGroupStatic = createPbrMeshBindGroup(engine, _wrapBindings(res), composed, meshUBO, materialUBO, view as unknown as PbrMaterialProps, ctx._envTextures, mesh);\n } finally {\n _setActivePbrGeometryAttachments(prev);\n }\n\n // ── Shadow bind group (group 2) ────────────────────────────────────\n let shadowBindGroup: GPUBindGroup | null = null;\n if (receiveShadows && res._shadowBGL) {\n const entries: GPUBindGroupEntry[] = [];\n let b = 0;\n for (const sl of ctx._shadowLights) {\n const sg = sl.gen;\n entries.push({ binding: b++, resource: sg._depthTexture.createView() });\n entries.push({ binding: b++, resource: sg._depthSampler });\n entries.push({ binding: b++, resource: { buffer: sg._shadowUBO } });\n }\n shadowBindGroup = device.createBindGroup({ layout: res._shadowBGL, entries });\n }\n\n // ── Texture acquire/release lifecycle ──────────────────────────────\n const boundTextures = collectPbrBoundTextures(source);\n for (const t of boundTextures) {\n acquireTexture(t);\n }\n const prevDisposables = scene._meshDisposables.get(mesh) ?? [];\n scene._meshDisposables.set(mesh, [\n ...prevDisposables,\n () => {\n meshUBO.destroy();\n materialUBO.destroy();\n },\n () => {\n for (const t of boundTextures) {\n releaseTexture(t);\n }\n },\n ]);\n\n const hasNormalMap = (features & PBR_HAS_NORMAL_MAP) !== 0 && (meshFeatures & MSH_HAS_TANGENTS) !== 0;\n const hasUV2 = (features2 & PBR2_HAS_UV2) !== 0 && (meshFeatures & MSH_HAS_UV2) !== 0;\n const hasVertexColor = (meshFeatures & MSH_HAS_VERTEX_COLOR) !== 0;\n const hasTI = (meshFeatures & MSH_HAS_THIN_INSTANCES) !== 0;\n const hasTIColor = (meshFeatures & MSH_HAS_INSTANCE_COLOR) !== 0;\n const syncThinInstanceBuffers = ctx._syncThinInstanceBuffers;\n const isAlphaBlend = res._alphaBlend;\n const sortCenter = [mesh.worldMatrix[12]!, mesh.worldMatrix[13]!, mesh.worldMatrix[14]!] as [number, number, number];\n\n let _lastWorldVersion = mesh.worldMatrixVersion;\n let _lastLightsCount = scene.lights.length;\n let _lastUboVersion = source._uboVersion;\n const matScratch = new F32(materialSpec._totalBytes / 4);\n\n const _baseUpdate = (): void => {\n if (mesh.worldMatrixVersion !== _lastWorldVersion || scene.lights.length !== _lastLightsCount) {\n sortCenter[0] = mesh.worldMatrix[12]!;\n sortCenter[1] = mesh.worldMatrix[13]!;\n sortCenter[2] = mesh.worldMatrix[14]!;\n _packMeshWorld(meshUboData, mesh.worldMatrix, 0, 0);\n writeMeshLightSelection(mesh, scene.lights, meshUboData);\n device.queue.writeBuffer(meshUBO, 0, meshUboData as Float32Array<ArrayBuffer>);\n _lastWorldVersion = mesh.worldMatrixVersion;\n _lastLightsCount = scene.lights.length;\n }\n if (source._uboVersion !== _lastUboVersion) {\n _lastUboVersion = source._uboVersion;\n matScratch.fill(0);\n _writePbrMaterialData(matScratch, source, materialSpec);\n device.queue.writeBuffer(materialUBO, 0, matScratch.buffer, 0, matScratch.byteLength);\n }\n };\n const _invalidate = (): void => {\n _lastWorldVersion = -1;\n };\n const update = engine._wrapRenderableForFO?.(_baseUpdate, scene, _invalidate) ?? _baseUpdate;\n\n const draw = (pass: GPURenderPassEncoder | GPURenderBundleEncoder): number => {\n if (mesh.visible === false) {\n return 0;\n }\n const gpu = mesh._gpu;\n pass.setBindGroup(1, materialBindGroupStatic);\n if (shadowBindGroup) {\n pass.setBindGroup(2, shadowBindGroup);\n }\n let slot = 0;\n const vb = gpu._vbLayout;\n pass.setVertexBuffer(slot++, gpu.positionBuffer, vb?._p?._offset);\n pass.setVertexBuffer(slot++, gpu.normalBuffer, vb?._n?._offset);\n if (hasNormalMap && gpu.tangentBuffer) {\n pass.setVertexBuffer(slot++, gpu.tangentBuffer, vb?._t?._offset);\n }\n pass.setVertexBuffer(slot++, gpu.uvBuffer, vb?._u?._offset);\n if (hasUV2 && gpu.uv2Buffer) {\n pass.setVertexBuffer(slot++, gpu.uv2Buffer, vb?._u2?._offset);\n }\n if (hasVertexColor && gpu.colorBuffer) {\n pass.setVertexBuffer(slot++, gpu.colorBuffer, vb?._c?._offset);\n }\n // Skinning vertex buffers: live skeleton OR baked VAT (same field names, mutually exclusive).\n // Mirrors the main PBR renderable — without the VAT branch, VAT-animated thin instances leave the\n // pipeline's joint/weight vertex slots unbound (invalid command buffer, black frame).\n const skin = mesh.skeleton ?? mesh.vat;\n if (skin) {\n pass.setVertexBuffer(slot++, skin.jointsBuffer);\n pass.setVertexBuffer(slot++, skin.weightsBuffer);\n if (skin.joints1Buffer && skin.weights1Buffer) {\n pass.setVertexBuffer(slot++, skin.joints1Buffer);\n pass.setVertexBuffer(slot++, skin.weights1Buffer);\n }\n }\n const ti = hasTI ? mesh.thinInstances : null;\n if (ti && syncThinInstanceBuffers) {\n slot = syncThinInstanceBuffers(engine, ti, pass, slot, hasTIColor);\n }\n pass.setIndexBuffer(gpu.indexBuffer, gpu.indexFormat);\n if (ti && ti.count > 0) {\n pass.drawIndexed(gpu.indexCount, ti.count);\n } else {\n pass.drawIndexed(gpu.indexCount);\n }\n return 1;\n };\n\n const r: Renderable = {\n order: mesh.renderOrder ?? (isAlphaBlend ? 200 : 100),\n isTransparent: isAlphaBlend,\n mesh,\n bind(eng: EngineContext, sig: RenderTargetSignature) {\n return {\n renderable: r,\n pipeline: _getOrCreateGeometryPipeline(eng as EngineContext, sig, view, res),\n update,\n draw,\n };\n },\n };\n r._worldCenter = sortCenter;\n return r;\n}\n\n// ─── Shared per-view resources ─────────────────────────────────────────\n\nfunction _ensureViewResources(\n view: PbrGeometryMaterialView,\n engine: EngineContext,\n ctx: _PbrGeometryContext,\n meshFeatures: number,\n lightMode: 0 | 1 | 2,\n singleLightType: string,\n variantKey: string\n): PbrGeometryViewResources {\n let cache = view._geometry as Map<string, PbrGeometryViewResources> | undefined;\n if (!cache) {\n cache = new Map();\n Object.defineProperty(view, \"_geometry\", { value: cache, enumerable: false, configurable: true });\n }\n const cached = cache.get(variantKey);\n if (cached) {\n return cached;\n }\n // Ensure the PBR geometry ext is registered (idempotent) before composePbr is called.\n _ensurePbrGeometryExt(() => view._geometryAttachments);\n\n const features = view._renderFeatures.features;\n const features2 = view._renderFeatures.features2 ?? 0;\n const sceneFeatures = ctx._sceneFeatures;\n const source = view.source as PbrMaterialProps;\n const vbLayout = (source as unknown as { _vbLayout?: import(\"../../mesh/mesh.js\").MeshVbLayout })._vbLayout;\n const vbKey = \"\";\n\n // Compose with the active-attachment scope set so the registered ext\n // sees the right list when contributing the geometry-params fragment.\n const prev = _setActivePbrGeometryAttachments(view._geometryAttachments);\n let composed: ComposedShader;\n try {\n composed = composePbrGeometryShader(\n ctx._composePbr,\n features,\n features2,\n meshFeatures,\n sceneFeatures,\n lightMode,\n singleLightType,\n \"\",\n vbLayout,\n vbKey,\n view._geometryAttachments,\n view._emitColor\n );\n } finally {\n _setActivePbrGeometryAttachments(prev);\n }\n\n const device = engine._device;\n const meshBGL = device.createBindGroupLayout(composed._meshBGLDescriptor);\n const shadowBGL = composed._shadowBGLDescriptor ? device.createBindGroupLayout(composed._shadowBGLDescriptor) : null;\n const sceneBGL = (engine as unknown as { _getSceneBGL: () => GPUBindGroupLayout })._getSceneBGL?.() ?? _getSceneBindGroupLayoutLocal(engine, composed);\n const bgls: GPUBindGroupLayout[] = shadowBGL ? [sceneBGL, meshBGL, shadowBGL] : [sceneBGL, meshBGL];\n const pipelineLayout = device.createPipelineLayout({ bindGroupLayouts: bgls });\n const vertModule = device.createShaderModule({ code: composed._vertexWGSL });\n const fragModule = device.createShaderModule({ code: composed._fragmentWGSL });\n\n // The view's features have PBR_HAS_ALPHA_BLEND already stripped. Detect\n // alpha-blend from the SOURCE so transparent meshes get the right blend\n // pipeline state below.\n const sourceFeatures = source._renderFeatures?.features ?? 0;\n const alphaBlend = (sourceFeatures & PBR_HAS_ALPHA_BLEND) !== 0;\n\n const res: PbrGeometryViewResources = {\n _composed: composed,\n _features: features,\n _features2: features2,\n _meshFeatures: meshFeatures,\n _sceneFeatures: sceneFeatures,\n _meshBGL: meshBGL,\n _shadowBGL: shadowBGL,\n _pipelineLayout: pipelineLayout,\n _vertModule: vertModule,\n _fragModule: fragModule,\n _pipelines: new Map(),\n _alphaBlend: alphaBlend,\n };\n cache.set(variantKey, res);\n return res;\n}\n\n/** Adapter so `createPbrMeshBindGroup` (which takes `_PbrShaderBindings`) can\n * consume our view resources. Only the fields it touches matter. */\nfunction _wrapBindings(res: PbrGeometryViewResources): Parameters<typeof createPbrMeshBindGroup>[1] {\n return {\n _features: res._features,\n _features2: res._features2,\n _meshFeatures: res._meshFeatures,\n _meshBGL: res._meshBGL,\n _shadowBGL: res._shadowBGL,\n _composed: res._composed,\n _pipelines: res._pipelines,\n } as Parameters<typeof createPbrMeshBindGroup>[1];\n}\n\n/** Local fallback used when the engine does not expose a centralised scene BGL\n * cache helper. Matches the layout produced by `getSceneBindGroupLayout`. */\nfunction _getSceneBindGroupLayoutLocal(engine: EngineContext, _composed: ComposedShader): GPUBindGroupLayout {\n return getSceneBindGroupLayout(engine);\n}\n\nfunction _getOrCreateGeometryPipeline(engine: EngineContext, sig: RenderTargetSignature, view: PbrGeometryMaterialView, res: PbrGeometryViewResources): GPURenderPipeline {\n const key = targetSignatureKey(sig);\n const cached = res._pipelines.get(key);\n if (cached) {\n return cached;\n }\n const device = engine._device;\n const formats = (sig as RenderTargetSignature & { _colorFormats?: readonly GPUTextureFormat[] })._colorFormats ?? (sig._colorFormat ? [sig._colorFormat] : []);\n if (formats.length === 0) {\n throw new Error(\"pbr-geometry: render target has no color attachments\");\n }\n const alphaBlend = res._alphaBlend;\n const blendState: GPUBlendState | undefined = alphaBlend\n ? {\n color: { srcFactor: \"src-alpha\", dstFactor: \"one-minus-src-alpha\", operation: \"add\" },\n alpha: { srcFactor: \"src-alpha\", dstFactor: \"one-minus-src-alpha\", operation: \"add\" },\n }\n : undefined;\n const colorTargets: GPUColorTargetState[] = formats.map((fmt) => (blendState ? { format: fmt, blend: blendState } : { format: fmt }));\n const sourceFeatures = (view.source as PbrMaterialProps)._renderFeatures?.features ?? 0;\n const hasDoubleSided = (sourceFeatures & PBR_HAS_DOUBLE_SIDED) !== 0;\n const cullMode = hasDoubleSided ? \"none\" : view._reverseCulling ? \"front\" : \"back\";\n const pipeline = device.createRenderPipeline({\n layout: res._pipelineLayout,\n vertex: { module: res._vertModule, entryPoint: \"main\", buffers: res._composed._vertexBufferLayouts },\n fragment: { module: res._fragModule, entryPoint: \"main\", targets: colorTargets },\n depthStencil: sig._depthStencilFormat\n ? {\n format: sig._depthStencilFormat,\n depthCompare: sig._depthCompare ?? REVERSE_DEPTH_COMPARE,\n // Disable depth-write for alpha-blended meshes so background\n // depth survives partially-transparent pixels. Matches the\n // Standard geometry-renderable behaviour.\n depthWriteEnabled: !alphaBlend,\n }\n : undefined,\n multisample: { count: sig._sampleCount },\n primitive: { topology: \"triangle-list\", cullMode, frontFace: \"ccw\" },\n });\n res._pipelines.set(key, pipeline);\n return pipeline;\n}\n\n// ─── Helpers cribbed from pbr-renderable (no static cycle) ─────────────\n\nfunction _getPackedSingleLightType(lights: SceneContext[\"lights\"], packedIndex: number): \"hemispheric\" | \"directional\" | \"spot\" | \"point\" {\n let packed = 0;\n for (const light of lights) {\n if (!light._writeLightUbo) {\n continue;\n }\n if (packed === packedIndex) {\n const t = light.lightType;\n return t === \"hemispheric\" || t === \"directional\" || t === \"spot\" ? t : \"point\";\n }\n packed++;\n }\n return \"point\";\n}\n\n/** Writes material UBO via the helper exported from pbr-renderable. */\nfunction _writePbrMaterialData(data: Float32Array, mat: PbrMaterialProps, spec: import(\"../../shader/fragment-types.js\").UboSpec): void {\n _writeMaterialData(data, mat, spec);\n}\n","/** PBR material view helper that targets geometry-rendering MRT output.\n *\n * The geometry renderer task wraps each PBR caster material in a\n * `PbrGeometryMaterialView`. The view carries the per-task attachment\n * list, target-texture intent, optional `gp` UBO (shared across the task's\n * materials), and reverse-culling flag. The view also shadows\n * {@link Material._buildGroup} with {@link pbrGeometryGroupBuilder} so that\n * the geometry renderer task materialises a {@link Renderable} through the\n * PBR geometry renderable infrastructure — no view-aware branching needed\n * in core render-task.\n *\n * The geometry-output WGSL itself is produced by post-processing the regular\n * per-scene composed PBR shader (reused via the `_pbrGeomContext` stash) in\n * `./pbr-geometry-output-shader.ts`. */\n\nimport { createMaterialView } from \"../material-view.js\";\nimport type { MaterialView } from \"../material.js\";\nimport type { GeometryTextureType } from \"../../frame-graph/geometry-types.js\";\nimport { PBR_HAS_ALPHA_BLEND, PBR2_GEOMETRY_OUTPUT } from \"./pbr-flags.js\";\nimport type { PbrMaterialProps } from \"./pbr-material.js\";\nimport { pbrGeometryGroupBuilder } from \"./pbr-geometry-renderable.js\";\nimport { _ensurePbrGeometryExt } from \"./pbr-geometry-output-shader.js\";\n\n/** Per-task ordered attachment list driving the geometry template. The array\n * index is the MRT color-attachment slot used in `@location(i)`. */\nexport type PbrGeometryAttachments = readonly GeometryTextureType[];\n\n/** Per-(task, material) PBR geometry view configuration. All fields are owned\n * by the geometry renderer task; the view captures them so per-mesh renderables\n * pick up the same pipeline state and bindings. */\nexport interface PbrGeometryViewConfig {\n /** Ordered MRT attachment list — index = `@location(i)`. */\n readonly attachments: PbrGeometryAttachments;\n /** When true, the composed fragment emits the real (lit) material color\n * at `@location(N)` (N = attachments.length). The target texture is\n * added to the pipeline color-target list at the same slot. */\n readonly emitColor: boolean;\n /** Per-task previous-VP + camera-near-far UBO. Required when\n * {@link attachments} contains `NORMALIZED_VIEW_DEPTH` or\n * `LINEAR_VELOCITY`; ignored otherwise. */\n readonly gpUBO?: GPUBuffer | null;\n /** Flip culling direction. */\n readonly reverseCulling?: boolean;\n}\n\n/** PBR material view that emits geometry textures instead of shaded colour. */\nexport interface PbrGeometryMaterialView extends MaterialView {\n /** @internal Ordered MRT attachment list — index = `@location(i)`. */\n readonly _geometryAttachments: PbrGeometryAttachments;\n /** @internal Geometry pipeline carries an extra `@location(N)` color attachment. */\n readonly _emitColor: boolean;\n /** @internal Optional per-task geometry-params UBO shared with the composer's\n * `geometry-params` fragment. */\n readonly _gpUBO: GPUBuffer | null;\n /** @internal */\n readonly _reverseCulling: boolean;\n /** @internal Shared per-view resources cache populated lazily by the renderable\n * factory. Opaque to callers. */\n _geometry?: unknown;\n}\n\n// Snapshot of the currently-building view's attachments so the registered\n// PBR geometry extension can read them from `frag(ctx)`. The extension is\n// invoked synchronously during composePbr inside `buildPbrGeometryRenderable`;\n// the snapshot is set right before that call and cleared after.\nlet _activeAttachments: readonly GeometryTextureType[] | undefined;\n\n/** @internal Used by the geometry renderable to scope attachment access for\n * the PBR ext during a composePbr call. Returns the previous value so the\n * caller can restore it (avoids global leakage in nested scenarios). */\nexport function _setActivePbrGeometryAttachments(att: readonly GeometryTextureType[] | undefined): readonly GeometryTextureType[] | undefined {\n const prev = _activeAttachments;\n _activeAttachments = att;\n return prev;\n}\n\n/** Wrap a PBR material as a geometry-output view.\n * - Sets the `PBR2_GEOMETRY_OUTPUT` features2 bit.\n * - Clears `PBR_HAS_ALPHA_BLEND`: the geometry pipeline drives blending per\n * attachment via the pipeline color-target state, not via the PBR\n * fragment's source-over color output.\n * - Shadows `_buildGroup` with {@link pbrGeometryGroupBuilder} so the\n * natural `material._buildGroup._rebuildSingle` dispatch in\n * `resolvePendingMeshes` builds a geometry-MRT renderable for this view.\n * - Registers the PBR geometry extension (idempotent) so subsequent\n * composePbr calls pick up the `gp` UBO + geometry varyings when\n * `PBR2_GEOMETRY_OUTPUT` is set. */\nexport function createPbrGeometryMaterialView(source: PbrMaterialProps, config: PbrGeometryViewConfig): PbrGeometryMaterialView {\n _ensurePbrGeometryExt(() => _activeAttachments);\n const baseFeatures = source._renderFeatures?.features ?? 0;\n const baseFeatures2 = source._renderFeatures?.features2 ?? 0;\n const view = createMaterialView(source, {\n features: baseFeatures & ~PBR_HAS_ALPHA_BLEND,\n features2: baseFeatures2 | PBR2_GEOMETRY_OUTPUT,\n }) as PbrGeometryMaterialView;\n Object.defineProperty(view, \"_geometryAttachments\", { value: config.attachments, enumerable: false });\n Object.defineProperty(view, \"_emitColor\", { value: config.emitColor, enumerable: false });\n Object.defineProperty(view, \"_gpUBO\", { value: config.gpUBO ?? null, enumerable: false });\n Object.defineProperty(view, \"_reverseCulling\", { value: config.reverseCulling ?? false, enumerable: false });\n Object.defineProperty(view, \"_buildGroup\", { value: pbrGeometryGroupBuilder, enumerable: false });\n return view;\n}\n"],"names":["_a","_b"],"mappings":";;AAiCA,MAAM,iBAAiB;AACvB,MAAM,eAAe;AAIrB,SAAS,WAAW,aAAsD;AACtE,aAAW,KAAK,aAAa;AACzB,QAAI,MAAM,oBAAoB,yBAAyB,MAAM,oBAAoB,iBAAiB;AAC9F,aAAO;AAAA,IACX;AAAA,EACJ;AACA,SAAO;AACX;AAEA,SAAS,cAAc,aAAsD;AACzE,SAAO,YAAY,SAAS,oBAAoB,eAAe;AACnE;AAEA,SAAS,cAAc,aAAsD;AACzE,SAAO,YAAY,SAAS,oBAAoB,cAAc;AAClE;AAIA,SAAS,gCAAgC,gBAAyB,uBAAgC,sBAA+C;AAC7I,QAAM,WAAW,iBAAiB,CAAC,EAAE,OAAO,MAAM,OAAO,EAAE,OAAO,iBAA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B,QAAI,CAAC,MAAM,gBAAgB;AACvB;AAAA,IACJ;AACA,QAAI,WAAW,aAAa;AACxB,YAAM,IAAI,MAAM;AAChB,aAAO,MAAM,iBAAiB,MAAM,iBAAiB,MAAM,SAAS,IAAI;AAAA,IAC5E;AACA;AAAA,EACJ;AACA,SAAO;AACX;AAGA,SAAS,sBAAsB,MAAoB,KAAuB,MAA8D;AACpI,qBAAmB,MAAM,KAAK,IAAI;AACtC;AC3XA,IAAI;AAKG,SAAS,iCAAiC,KAA6F;AAC1I,QAAM,OAAO;AACb,uBAAqB;AACrB,SAAO;AACX;AAaO,SAAS,8BAA8B,QAA0B,QAAwD;;AAC5H,wBAAsB,MAAM,kBAAkB;AAC9C,QAAM,iBAAe,YAAO,oBAAP,mBAAwB,aAAY;AACzD,QAAM,kBAAgB,YAAO,oBAAP,mBAAwB,cAAa;AAC3D,QAAM,OAAO,mBAAmB,QAAQ;AAAA,IACpC,UAAU,eAAe,CAAC;AAAA,IAC1B,WAAW,gBAAgB;AAAA,EAAA,CAC9B;AACD,SAAO,eAAe,MAAM,wBAAwB,EAAE,OAAO,OAAO,aAAa,YAAY,OAAO;AACpG,SAAO,eAAe,MAAM,cAAc,EAAE,OAAO,OAAO,WAAW,YAAY,OAAO;AACxF,SAAO,eAAe,MAAM,UAAU,EAAE,OAAO,OAAO,SAAS,MAAM,YAAY,MAAA,CAAO;AACxF,SAAO,eAAe,MAAM,mBAAmB,EAAE,OAAO,OAAO,kBAAkB,OAAO,YAAY,MAAA,CAAO;AAC3G,SAAO,eAAe,MAAM,eAAe,EAAE,OAAO,yBAAyB,YAAY,OAAO;AAChG,SAAO;AACX;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pbr-renderable-CuKWalEM.js","sources":["../src/material/pbr/pbr-pipeline.ts","../src/material/pbr/pbr-template.ts","../src/material/pbr/pbr-compose.ts","../src/material/pbr/pbr-renderable.ts"],"sourcesContent":["/** Dynamic PBR pipeline builder — creates and caches GPU render pipelines\n * based on per-mesh PBR feature flags + ComposedShader from the fragment system.\n *\n * Two-tier cache:\n * - Shader bindings (BGLs + composed shader + per-sig pipeline cache) keyed by\n * `(features, features2)`. Sig-independent.\n * - Pipelines live inside each `_PbrShaderBindings`, keyed by `targetSignatureKey(sig)`.\n */\n\nimport { CW } from \"../../engine/gpu-flags.js\";\nimport type { PbrMaterialProps } from \"./pbr-material.js\";\nimport type { EnvironmentTextures } from \"../../loader-env/load-env.js\";\nimport type { ComposedShader } from \"../../shader/fragment-types.js\";\nimport type { EngineContext } from \"../../engine/engine.js\";\nimport type { RenderTargetSignature } from \"../../engine/render-target.js\";\nimport type { Texture2D } from \"../../texture/texture-2d.js\";\nimport type { _PbrBindCtx, PbrExt } from \"./pbr-flags.js\";\nimport { _getPbrExtsSorted, PBR2_ESM_SHADOW_OUTPUT, PBR2_NO_COLOR_OUTPUT, PBR2_HAS_UV2 } from \"./pbr-flags.js\";\nimport { PBR_HAS_NORMAL_MAP, PBR_HAS_EMISSIVE, PBR_HAS_SPEC_GLOSS, PBR_HAS_DOUBLE_SIDED, PBR_HAS_ALPHA_BLEND } from \"./pbr-flags.js\";\nimport { MSH_HAS_TANGENTS, MSH_HAS_UV2 } from \"../mesh-features.js\";\nimport { REVERSE_DEPTH_COMPARE, targetSignatureKey } from \"../../engine/render-target.js\";\nimport { getSceneBindGroupLayout } from \"../../render/scene-helpers.js\";\n\n// ─── Shader Bindings (sig-independent) ──────────────────────────────\n\ninterface _PbrShaderBindings {\n _features: number;\n _features2: number;\n _meshFeatures: number;\n _meshBGL: GPUBindGroupLayout;\n _shadowBGL: GPUBindGroupLayout | null;\n _composed: ComposedShader;\n /** Per-sig pipeline cache. Key = `targetSignatureKey(sig)`. */\n _pipelines: Map<string, GPURenderPipeline>;\n}\n\n// ─── Caches ─────────────────────────────────────────────────────────\n\nconst _bindingsCache = new Map<string, _PbrShaderBindings>();\nlet _cachedDevice: GPUDevice | null = null;\n\nfunction ensureDevice(engine: EngineContext): void {\n if (_cachedDevice !== engine._device) {\n _bindingsCache.clear();\n _cachedDevice = engine._device;\n }\n}\n\n/** Clear the pipeline cache. Must be called when a GPU device is destroyed. */\nexport function clearPbrPipelineCache(): void {\n _bindingsCache.clear();\n _cachedDevice = null;\n}\n\n/** Get-or-build the sig-independent PBR shader bindings. Used at renderable build time\n * so per-mesh bind groups can be created BEFORE any sig is known. */\nexport function getOrCreatePbrBindings(\n engine: EngineContext,\n features: number,\n features2: number,\n meshFeatures: number,\n sceneFeatures: number,\n composed: ComposedShader,\n shaderKey = \"\"\n): _PbrShaderBindings {\n ensureDevice(engine);\n const key = `${features}:${features2}:${meshFeatures}:${sceneFeatures}:${shaderKey}`;\n const cached = _bindingsCache.get(key);\n if (cached) {\n return cached;\n }\n\n const device = engine._device;\n const meshBGL = device.createBindGroupLayout(composed._meshBGLDescriptor);\n let shadowBGL: GPUBindGroupLayout | null = null;\n if (composed._shadowBGLDescriptor) {\n shadowBGL = device.createBindGroupLayout(composed._shadowBGLDescriptor);\n }\n const bindings: _PbrShaderBindings = {\n _features: features,\n _features2: features2,\n _meshFeatures: meshFeatures,\n _meshBGL: meshBGL,\n _shadowBGL: shadowBGL,\n _composed: composed,\n _pipelines: new Map(),\n };\n _bindingsCache.set(key, bindings);\n return bindings;\n}\n\n/** Get-or-build the sig-specific pipeline on top of a PBR shader bindings. Called at bind() time. */\nexport function getOrCreatePbrPipeline(engine: EngineContext, sig: RenderTargetSignature, bindings: _PbrShaderBindings): GPURenderPipeline {\n ensureDevice(engine);\n const key = targetSignatureKey(sig);\n const cached = bindings._pipelines.get(key);\n if (cached) {\n return cached;\n }\n\n const device = engine._device;\n const { _features: features, _features2: features2, _composed: composed } = bindings;\n const esmShadowOutput = (features2 & PBR2_ESM_SHADOW_OUTPUT) !== 0;\n const hasAlpha = !esmShadowOutput && (features & PBR_HAS_ALPHA_BLEND) !== 0;\n const hasDoubleSided = (features & PBR_HAS_DOUBLE_SIDED) !== 0;\n\n const sceneBGL = getSceneBindGroupLayout(engine);\n const bgls: GPUBindGroupLayout[] = bindings._shadowBGL ? [sceneBGL, bindings._meshBGL, bindings._shadowBGL] : [sceneBGL, bindings._meshBGL];\n\n const vertModule = device.createShaderModule({ code: composed._vertexWGSL });\n const noColorOutput = (features2 & PBR2_NO_COLOR_OUTPUT) !== 0;\n const fragModule = !sig._colorFormat && !noColorOutput ? null : device.createShaderModule({ code: composed._fragmentWGSL });\n\n const fragTarget: GPUColorTargetState | null = noColorOutput ? null : { format: sig._colorFormat!, writeMask: CW.ALL };\n if (hasAlpha && fragTarget) {\n fragTarget.blend = {\n color: { srcFactor: \"src-alpha\", dstFactor: \"one-minus-src-alpha\", operation: \"add\" },\n alpha: { srcFactor: \"one\", dstFactor: \"one\", operation: \"add\" },\n };\n }\n\n const pipeline = device.createRenderPipeline({\n layout: device.createPipelineLayout({ bindGroupLayouts: bgls }),\n vertex: { module: vertModule, entryPoint: \"main\", buffers: composed._vertexBufferLayouts },\n ...(fragModule ? { fragment: { module: fragModule, entryPoint: \"main\", targets: fragTarget ? [fragTarget] : [] } } : {}),\n ...(sig._depthStencilFormat\n ? {\n depthStencil: {\n format: sig._depthStencilFormat,\n depthCompare: sig._depthCompare ?? REVERSE_DEPTH_COMPARE,\n depthWriteEnabled: noColorOutput || esmShadowOutput || !hasAlpha,\n },\n }\n : {}),\n multisample: { count: sig._sampleCount },\n primitive: { topology: \"triangle-list\", cullMode: hasDoubleSided ? (\"none\" as GPUCullMode) : \"back\", frontFace: \"ccw\" },\n });\n bindings._pipelines.set(key, pipeline);\n return pipeline;\n}\n\n// ─── Per-Mesh Bind Group ────────────────────────────────────────────\n\nexport function createPbrMeshBindGroup(\n engine: EngineContext,\n bindings: _PbrShaderBindings,\n composed: ComposedShader,\n meshUBO: GPUBuffer,\n materialUBO: GPUBuffer,\n material: PbrMaterialProps,\n env: EnvironmentTextures | null,\n meshCtx: { skeleton?: { boneTexture: GPUTexture } | null; morphTargets?: { texture: GPUTexture; weightsBuffer?: GPUBuffer } | null } | null,\n refractionTexture?: Texture2D | null\n): GPUBindGroup {\n const device = engine._device;\n const features = bindings._features;\n const features2 = bindings._features2;\n const meshFeatures = bindings._meshFeatures;\n const hasNormal = (features & PBR_HAS_NORMAL_MAP) !== 0 && (meshFeatures & MSH_HAS_TANGENTS) !== 0;\n const hasCotangentNormal = (features & PBR_HAS_NORMAL_MAP) !== 0 && (meshFeatures & MSH_HAS_TANGENTS) === 0;\n const hasAnyNormal = hasNormal || hasCotangentNormal;\n const hasEmissive = (features & PBR_HAS_EMISSIVE) !== 0;\n const hasSpecGloss = (features & PBR_HAS_SPEC_GLOSS) !== 0;\n const esmShadowOutput = (features2 & PBR2_ESM_SHADOW_OUTPUT) !== 0;\n\n const entries: GPUBindGroupEntry[] = [];\n let b = 0;\n const addTex = (t: { view: GPUTextureView; sampler: GPUSampler }) => {\n entries.push({ binding: b++, resource: t.view });\n entries.push({ binding: b++, resource: t.sampler });\n };\n\n const ctx: _PbrBindCtx = {\n _engine: engine,\n _features: features,\n _features2: features2,\n _meshFeatures: meshFeatures,\n _material: material,\n _mesh: meshCtx ?? undefined,\n _env: env,\n _refractionTexture: refractionTexture,\n };\n\n const sortedExts = _getPbrExtsSorted();\n\n const fragIds = composed._fragmentKey ? composed._fragmentKey.split(\"|\").filter((s) => s.length > 0) : [];\n\n entries.push({ binding: b++, resource: { buffer: meshUBO } });\n entries.push({ binding: b++, resource: { buffer: materialUBO } });\n for (const ext of sortedExts) {\n if (ext.phase === \"vertex\" && ext.bind) {\n b = ext.bind(ctx, entries, b);\n }\n }\n addTex(material.baseColorTexture!);\n if (hasAnyNormal) {\n addTex(material.normalTexture!);\n }\n addTex(material.ormTexture!);\n if ((features2 & PBR2_HAS_UV2) !== 0 && (meshFeatures & MSH_HAS_UV2) !== 0 && material.occlusionTexture) {\n addTex(material.occlusionTexture);\n }\n if (hasEmissive) {\n addTex(material.emissiveTexture!);\n }\n if (hasSpecGloss) {\n addTex(material.specGlossTexture!);\n }\n if (esmShadowOutput) {\n entries.push({\n binding: b++,\n resource: { buffer: (material as PbrMaterialProps & { readonly _esmShadowParamsUBO: GPUBuffer })._esmShadowParamsUBO },\n });\n }\n const seenExts: PbrExt[] = [];\n for (const fid of fragIds) {\n const ext = sortedExts.find((e) => e.id === fid || fid.startsWith(e.id + \"-\"));\n if (!ext || ext.phase === \"vertex\" || !ext.bind || seenExts.includes(ext)) {\n continue;\n }\n seenExts.push(ext);\n b = ext.bind(ctx, entries, b);\n }\n\n return device.createBindGroup({ layout: bindings._meshBGL, entries });\n}\n","/**\n * PBR Base Template\n *\n * Provides the base PBR shader structure with slot markers where\n * fragments inject their code. This is the PBR equivalent of\n * what composePbrVertex/composePbrFragment produce today.\n *\n * The template is parameterized by light type and feature flags\n * because these fundamentally change the shader structure.\n */\n\nimport type { ShaderTemplate, UboField, VertexAttribute, Varying, BindingDecl } from \"../../shader/fragment-types.js\";\nimport type { PbrTemplateExt } from \"./pbr-template-ext.js\";\nimport type { MeshVbLayout } from \"../../mesh/mesh.js\";\nimport { appendMeshLightUboFields, meshLightIndexWGSL } from \"../../render/lights-ubo.js\";\n\nconst STAGE_FRAGMENT = 0x2;\n\n// ── BRDF functions (always present in PBR) ──────────────────────\n\nconst BRDF_FUNCTIONS = `\nconst PI:f32=3.14159265358979323846;\nfn distributionGGX(NdotH:f32,alphaG:f32)->f32{\nlet a2=alphaG*alphaG;\nlet d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\nfn geometrySmithGGX(NdotL:f32,NdotV:f32,alphaG:f32)->f32{\nlet a2=alphaG*alphaG;\nlet gl=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);\nlet gv=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);\nreturn 0.5/(gl+gv);\n}\nfn fresnelSchlick(cosTheta:f32,F0:vec3<f32>,F90:vec3<f32>)->vec3<f32>{\nlet t=1.0-cosTheta;\nlet t2=t*t;\nreturn F0+(F90-F0)*(t2*t2*t);\n}\n`;\n\nexport interface PbrTemplateConfig {\n /** When true, generates a non-looping single-light direct block + lights UBO binding. */\n /** @internal */\n readonly _hasSingleLight?: boolean;\n /** When true, generates a multi-light loop + lights UBO binding.\n * Used for multiple lights or shadow receivers. */\n /** @internal */\n readonly _hasMultiLight?: boolean;\n /** Pre-built WGSL for the single-light UBO structs. */\n /** @internal */\n readonly _singleLightWGSL?: string;\n /** Pre-built WGSL for the single-light direct lighting block. */\n /** @internal */\n readonly _singleLightBlock?: string;\n /** Pre-built WGSL for multi-light (structs + computePbrLight). Passed from\n * dynamically imported fragments/multilight-wgsl.ts to keep it out of non-shadow bundles. */\n /** @internal */\n readonly _multiLightWGSL?: string;\n /** Pre-built WGSL for the multi-light direct lighting loop body. */\n /** @internal */\n readonly _multiLightLoop?: string;\n /** Normal map mode (default: \"none\") */\n /** @internal */\n readonly _normalMode?: \"tangent\" | \"cotangent\" | \"none\";\n /** Has emissive texture */\n /** @internal */\n readonly _hasEmissiveTexture?: boolean;\n /** Has specular-glossiness workflow */\n /** @internal */\n readonly _hasSpecGloss?: boolean;\n /** Has double-sided rendering */\n /** @internal */\n readonly _hasDoubleSided?: boolean;\n /** Has tonemap */\n /** @internal */\n readonly _hasTonemap?: boolean;\n /** Scene has fog (scene.fog != null). `calcFogFactor` helper WGSL, supplied by the dynamic\n * pbr-fog-wgsl import only for fog scenes; \"\" otherwise (zero bytes for non-fog scenes). */\n /** @internal */\n readonly _fogHelper?: string;\n /** Fog blend WGSL, emitted just before the tonemap block; \"\" for non-fog scenes. */\n /** @internal */\n readonly _fogBlock?: string;\n /** ACES WGSL: tonemap helper functions (dynamically imported). Empty string = standard exponential tonemap. */\n /** @internal */\n readonly _acesHelpers?: string;\n /** ACES WGSL: tonemap call block replacing the default exponential one. */\n /** @internal */\n readonly _acesTonemapCall?: string;\n /** Has alpha blending */\n /** @internal */\n readonly _hasAlphaBlend?: boolean;\n /** Has specular AA */\n /** @internal */\n readonly _hasSpecularAA?: boolean;\n /** Has gamma albedo (sRGB base color decode) */\n /** @internal */\n readonly _hasGammaAlbedo?: boolean;\n /** Has a non-default base-color factor multiplied over the base-color texture. */\n /** @internal */\n readonly _hasBaseColorFactor?: boolean;\n /** Has morph targets (changes position/normal variable names in vertex shader) */\n /** @internal */\n readonly _hasMorph?: boolean;\n /** Has occlusion in ORM texture (simple path, no reflectance ext) */\n /** @internal */\n readonly _hasOcclusion?: boolean;\n /** Has emissive color UBO field (fragment handles emissive computation) */\n /** @internal */\n readonly _hasEmissiveColor?: boolean;\n /** When true, the reflectance fragment handles F0 + occlusion computation */\n /** @internal */\n readonly _hasReflectanceExt?: boolean;\n /** When true, include IBL SH coefficients in scene UBO */\n /** @internal */\n readonly _hasIbl?: boolean;\n /** Has anisotropy layer */\n /** @internal */\n readonly _hasAnisotropy?: boolean;\n /** Anisotropy WGSL: BRDF helper functions (dynamically imported). */\n /** @internal */\n readonly _anisoBrdfFunctions?: string;\n /** Anisotropy WGSL: T/B computation block (dynamically imported). */\n /** @internal */\n readonly _anisoTBBlock?: string;\n /** Optional extension config for advanced features (UV transforms, UV2, vertex colors).\n * When undefined, base template defaults to master-like behavior (no feature strings). */\n /** @internal */\n readonly _ext?: PbrTemplateExt;\n /** Generate a fragment stage that runs discard/alpha-test logic and writes no color. */\n /** @internal */\n readonly _noColorOutput?: boolean;\n /** Generate a fragment stage that runs discard/alpha-test logic and writes ESM shadow color. */\n /** @internal */\n readonly _esmShadowOutput?: boolean;\n /** ESM shadow depth output code. Supplied by the ESM material view so normal PBR bundles don't retain it. */\n /** @internal */\n readonly _esmShadowDepthCode?: string;\n /** @internal Per-attribute vertex-buffer interleave layout. Undefined (or per-attribute\n * undefined) → canonical tight strides (12/12/16/8). Only set for meshes\n * sourcing attributes from a strided bufferView. */\n readonly _vbStrides?: MeshVbLayout;\n}\n\n/**\n * Create a PBR ShaderTemplate from the given configuration.\n * The template contains slot markers that the composer fills with fragment code.\n */\nexport function createPbrTemplate(config: PbrTemplateConfig): ShaderTemplate {\n const {\n _hasSingleLight = false,\n _hasMultiLight = false,\n _singleLightWGSL = \"\",\n _singleLightBlock = \"\",\n _multiLightWGSL = \"\",\n _multiLightLoop = \"\",\n _normalMode = \"none\",\n _hasEmissiveTexture = false,\n _hasSpecGloss = false,\n _hasDoubleSided = false,\n _hasTonemap = false,\n _fogHelper = \"\",\n _fogBlock = \"\",\n _acesHelpers = \"\",\n _acesTonemapCall = \"\",\n _hasAlphaBlend = false,\n _hasSpecularAA = false,\n _hasGammaAlbedo = false,\n _hasBaseColorFactor = false,\n _hasMorph = false,\n _hasOcclusion = false,\n _hasEmissiveColor = false,\n _hasReflectanceExt = false,\n _hasIbl = false,\n _hasAnisotropy = false,\n _anisoBrdfFunctions = \"\",\n _anisoTBBlock = \"\",\n _ext,\n _noColorOutput = false,\n _esmShadowOutput = false,\n _esmShadowDepthCode = \"\",\n _vbStrides,\n } = config;\n const hasNormal = _normalMode === \"tangent\";\n const hasCotangentNormal = _normalMode === \"cotangent\";\n const hasAnyNormal = hasNormal || hasCotangentNormal;\n\n // ── Base vertex attributes ──────────────────────────────────\n // arrayStride defaults to the canonical tight element size; interleaved meshes\n // override it (e.g. 24 for POSITION+NORMAL sharing one stride-24 bufferView).\n const _baseVertexAttributes: VertexAttribute[] = [\n { _name: \"position\", _type: \"vec3<f32>\", _gpuFormat: \"float32x3\", _arrayStride: _vbStrides?._p?._stride ?? 12 },\n { _name: \"normal\", _type: \"vec3<f32>\", _gpuFormat: \"float32x3\", _arrayStride: _vbStrides?._n?._stride ?? 12 },\n ];\n if (hasNormal) {\n _baseVertexAttributes.push({ _name: \"tangent\", _type: \"vec4<f32>\", _gpuFormat: \"float32x4\", _arrayStride: _vbStrides?._t?._stride ?? 16 });\n }\n _baseVertexAttributes.push({ _name: \"uv\", _type: \"vec2<f32>\", _gpuFormat: \"float32x2\", _arrayStride: _vbStrides?._u?._stride ?? 8 });\n if (_ext) {\n _baseVertexAttributes.push(..._ext.extraVertexAttributes);\n }\n\n // ── Base varyings ───────────────────────────────────────────\n const _baseVaryings: Varying[] = [\n { _name: \"worldPos\", _type: \"vec3<f32>\" },\n { _name: \"worldNormal\", _type: \"vec3<f32>\" },\n ];\n if (hasNormal) {\n _baseVaryings.push({ _name: \"worldTangent\", _type: \"vec3<f32>\" }, { _name: \"worldBitangent\", _type: \"vec3<f32>\" });\n }\n _baseVaryings.push({ _name: \"uv\", _type: \"vec2<f32>\" });\n if (_ext) {\n _baseVaryings.push(..._ext.extraVaryings);\n }\n\n // ── Base mesh UBO fields (world matrix + affected light indices — UV transforms are\n // per-texture now, emitted on the material UBO when hasUvTransform). ─\n const _baseMeshUboFields: UboField[] = [{ _name: \"world\", _type: \"mat4x4<f32>\" }];\n appendMeshLightUboFields(_baseMeshUboFields);\n\n // ── Base material UBO fields ────────────────────────────────────\n const _baseMaterialUboFields: UboField[] = [\n { _name: \"environmentIntensity\", _type: \"f32\" },\n { _name: \"directIntensity\", _type: \"f32\" },\n { _name: \"reflectance\", _type: \"f32\" },\n { _name: \"materialAlpha\", _type: \"f32\" },\n ...(_hasBaseColorFactor ? [{ _name: \"baseColorFactor\", _type: \"vec4<f32>\" as const }] : []),\n // glTF metallicFactor / roughnessFactor (default 1.0) — applied over MR texture channels.\n { _name: \"metallicFactor\", _type: \"f32\" },\n { _name: \"roughnessFactor\", _type: \"f32\" },\n { _name: \"normalScale\", _type: \"f32\" },\n { _name: \"lightFalloffMode\", _type: \"f32\" },\n // Anisotropy UBO field stays on the base template because anisotropy is\n // template-only (no ShaderFragment) — the anisotropyExt just writes its\n // slice through the unified ext.writeUbo hook.\n ...(_hasAnisotropy ? [{ _name: \"anisotropyParams\", _type: \"vec4<f32>\" as const }] : []),\n // ── Extension fields (per-texture UV transforms, etc.) ─\n ...(_ext ? _ext.extraMaterialUboFields : []),\n ];\n\n // ── Helper: texture + sampler binding pair ────────────────────\n const tex2d = (name: string, sampler: string): BindingDecl[] => [\n { _name: name, _type: { _kind: \"texture\", _textureType: \"texture_2d<f32>\" }, _visibility: STAGE_FRAGMENT },\n { _name: sampler, _type: { _kind: \"sampler\", _samplerType: \"sampler\" }, _visibility: STAGE_FRAGMENT },\n ];\n\n // ── Base bindings (always-present textures) ─────────────────\n const _baseBindings: BindingDecl[] = tex2d(\"baseColorTexture\", \"baseColorSampler\");\n if (hasAnyNormal) {\n _baseBindings.push(...tex2d(\"normalTexture\", \"normalSampler_\"));\n }\n _baseBindings.push(...tex2d(\"ormTexture\", \"ormSampler\"));\n if (_ext) {\n _baseBindings.push(..._ext.extraBindings);\n }\n if (_hasEmissiveTexture) {\n _baseBindings.push(...tex2d(\"emissiveTexture\", \"emissiveSampler\"));\n }\n if (_hasSpecGloss) {\n _baseBindings.push(...tex2d(\"specGlossTexture\", \"specGlossSampler\"));\n }\n if (_esmShadowOutput) {\n _baseBindings.push({ _name: \"shadowParams\", _type: { _kind: \"uniform-buffer\" }, _visibility: STAGE_FRAGMENT });\n }\n // ── Vertex template ─────────────────────────────────────────\n // When morph targets are active, the morph fragment's VR\n // defines morphedPos/morphedNorm. The base template uses those instead\n // of the raw vertex attributes.\n const posVar = _hasMorph ? \"morphedPos\" : \"position\";\n const normVar = _hasMorph ? \"morphedNorm\" : \"normal\";\n\n // The vertex template uses morphedPos/morphedNorm when morph fragment is present,\n // falling back to position/normal. The morph fragment's VR defines these vars.\n const tangentBlock = hasNormal\n ? `let N_local=normalize(${normVar});\nlet T_local=normalize(tangent.xyz);\nlet B_local=cross(N_local,T_local)*tangent.w;\nout.worldTangent=(finalWorld*vec4<f32>(T_local,0.0)).xyz;\nout.worldBitangent=(finalWorld*vec4<f32>(B_local,0.0)).xyz;`\n : \"\";\n\n const _vertexTemplate = `/*SU*/\n/*MU*/\n@group(1) @binding(0) var<uniform> mesh: MeshUniforms;\n/*VH*/\n/*VD*/\n/*VO*/\n@vertex fn main(\n/*VP*/\n) -> VertexOutput {\nvar out: VertexOutput;\n/*VR*/\nvar finalWorld = mesh.world;\n/*VW*/\nlet worldPos4 = finalWorld * vec4<f32>(${posVar}, 1.0);\nout.worldPos = worldPos4.xyz;\nout.clipPos = scene.viewProjection * worldPos4;\nout.worldNormal = (finalWorld * vec4<f32>(normalize(${normVar}), 0.0)).xyz;\n${tangentBlock}\nout.uv = uv;\n ${_ext ? _ext.vertexBodyExtra : \"\"}/*VB*/\nreturn out;\n}`;\n\n // ── Fragment template ────────────────────────────────────────\n\n // Normal handling block\n const normalUV = _ext?.uvForNormal ?? \"input.uv\";\n const normalScaleMod = _ext?.normalScaleMod ?? \"\";\n const normalRef = _ext?.normalScaleMod ? \"scaledNormal\" : \"normalMapRaw\";\n const normalRefCt = _ext?.normalScaleMod ? \"scaledNormalCT\" : \"normalMapSample\";\n let normalBlock: string;\n if (hasNormal) {\n normalBlock = `let normalMapRaw=textureSample(normalTexture,normalSampler_,${normalUV}).rgb*2.0-1.0;\n${normalScaleMod}let normalMapNorm=normalize(${normalRef});\nlet N_geom=normalize(input.worldNormal);\nlet TBN=mat3x3<f32>(input.worldTangent,input.worldBitangent,input.worldNormal);\nvar N=normalize(TBN*normalMapNorm);`;\n } else if (hasCotangentNormal) {\n normalBlock = `let normalMapSample=textureSample(normalTexture,normalSampler_,${normalUV}).rgb*2.0-1.0;\n${normalScaleMod.replace(/normalMapRaw/g, \"normalMapSample\").replace(/scaledNormal/g, \"scaledNormalCT\")}let N_geom=normalize(input.worldNormal);\nlet dp1=dpdx(input.worldPos);\nlet dp2=dpdy(input.worldPos);\nlet duv1=dpdx(${normalUV});\nlet duv2=dpdy(${normalUV});\nlet dp2perp=cross(dp2,N_geom);\nlet dp1perp=cross(N_geom,dp1);\nlet tangent_ct=dp2perp*duv1.x+dp1perp*duv2.x;\nlet bitangent_ct=-(dp2perp*duv1.y+dp1perp*duv2.y);\nlet det=max(dot(tangent_ct,tangent_ct),dot(bitangent_ct,bitangent_ct));\nlet invmax=select(inverseSqrt(det),0.0,det==0.0);\nlet cotangentFrame=mat3x3<f32>(tangent_ct*invmax,bitangent_ct*invmax,N_geom);\nvar N=normalize(cotangentFrame*normalize(${normalRefCt}));`;\n } else {\n normalBlock = `let N_geom=normalize(input.worldNormal);\nvar N=N_geom;`;\n }\n\n // Anisotropy: tangent/bitangent frame (passed in from dynamic import, empty if not used)\n const anisotropyTBBlock = _hasAnisotropy ? _anisoTBBlock : \"\";\n\n // Base color decoding\n const vertexColorMod = _ext?.baseColorMod ?? \"\";\n const baseColorFactorRgb = _hasBaseColorFactor ? \"*material.baseColorFactor.rgb\" : \"\";\n const baseColorFactorAlpha = _hasBaseColorFactor ? \"*material.baseColorFactor.a\" : \"\";\n const baseColorDecode = _hasGammaAlbedo\n ? `var baseColor=pow(baseColorSample.rgb,vec3<f32>(2.2))${baseColorFactorRgb};\nvar alpha=baseColorSample.a${baseColorFactorAlpha};${vertexColorMod}`\n : `var baseColor=baseColorSample.rgb${baseColorFactorRgb};\nvar alpha=baseColorSample.a${baseColorFactorAlpha};${vertexColorMod}`;\n\n // Roughness / metallic\n const specGlossUV = _ext?.uvForSpecGloss ?? \"input.uv\";\n const roughnessMetallic = _hasSpecGloss\n ? `let specGloss=textureSample(specGlossTexture,specGlossSampler,${specGlossUV});\nlet roughness=clamp(1.0-specGloss.a,0.0,1.0);\nlet metallic=0.0;`\n : `let roughness=clamp(orm.g*material.roughnessFactor,0.0,1.0);\nlet metallic=orm.b*material.metallicFactor;`;\n\n // Material-view / pass variants can skip extension slots while still compiling the colour path.\n const emissiveUV = _ext?.uvForEmissive ?? \"input.uv\";\n const emissiveDefault = _hasEmissiveColor || !_hasEmissiveTexture ? `var emissive:vec3f;` : `let emissive=textureSample(emissiveTexture,emissiveSampler,${emissiveUV}).rgb;`;\n\n // Occlusion default (overridden by reflectance fragment's AT slot or ext occlusion override)\n const occlusionDefault = _hasReflectanceExt ? `` : _ext?.occlusionOverride ? _ext.occlusionOverride : _hasOcclusion ? `let occlusion=orm.r;` : `let occlusion=1.0;`;\n // F0 computation (overridden by reflectance fragment's MF slot)\n const f0Default = _hasReflectanceExt\n ? ``\n : _hasSpecGloss\n ? `var colorF0=specGloss.rgb;\nlet colorF90=vec3<f32>(1.0);\nlet maxSpecular=max(colorF0.r,max(colorF0.g,colorF0.b));\nlet surfaceAlbedo=baseColor*(1.0-maxSpecular);`\n : `let dielectricF0=material.reflectance;\nvar colorF0=mix(vec3<f32>(dielectricF0),baseColor,metallic);\nlet colorF90=vec3<f32>(1.0);\nlet surfaceAlbedo=baseColor*(1.0-dielectricF0)*(1.0-metallic);`;\n\n // Specular AA + geometric-curvature roughness factors (BJS getAARoughnessFactors).\n // AA_factor_x is the direct-light roughness floor (matches BJS `computeSheenLighting`\n // which clamps info.roughness upward). AA_factor_y is the IBL/alphaG additive bump.\n // Emitted unconditionally as var so sheen/other fragments can reference them\n // without needing a define; zero on the no-curvature path makes them a no-op.\n const specularAABlock =\n _hasSpecularAA || hasAnyNormal\n ? `var AA_factor_x=0.0;\nvar AA_factor_y=0.0;\n{let nDfdx_AA=dpdx(N);\nlet nDfdy_AA=dpdy(N);\nlet slopeSquare_AA=max(dot(nDfdx_AA,nDfdx_AA),dot(nDfdy_AA,nDfdy_AA));\nAA_factor_x=pow(saturate(slopeSquare_AA),0.333);\nAA_factor_y=sqrt(slopeSquare_AA)*0.75;\nalphaG+=AA_factor_y;}`\n : `var AA_factor_x=0.0;\nvar AA_factor_y=0.0;`;\n\n // Direct lighting block — use the compact non-looping shader for one non-shadow light,\n // and the generic multi-light loop for multiple lights or shadow receivers.\n const directLightBlock: string = _hasMultiLight\n ? _multiLightLoop\n : _hasSingleLight\n ? _singleLightBlock\n : `var directDiffuse=vec3<f32>(0.0);\nvar directSpecular=vec3<f32>(0.0);\n/*BL*/`;\n\n // Tonemap: BJS TONEMAPPING_STANDARD (exponential) by default; caller-supplied\n // ACES WGSL (from pbr-aces-wgsl.ts) is used when provided.\n const useAces = _hasTonemap && _acesTonemapCall !== \"\";\n const acesBlock = useAces ? _acesHelpers : \"\";\n const tonemapBlock = _hasTonemap\n ? useAces\n ? _acesTonemapCall\n : `color*=scene.vImageInfos.x;\ncolor=1.0-exp2(-1.590579*color);`\n : `color*=scene.vImageInfos.x;`;\n\n // Fog (opt-in via scene.fog). The fog WGSL — `_fogHelper` (calcFogFactor) and `_fogBlock`\n // (the blend, emitted just before the tonemap block) — is supplied by pbr-renderable, which\n // dynamically imports pbr-fog-wgsl.ts only when scene.fog is set. Both are \"\" for non-fog\n // scenes, so those bundles carry zero fog bytes (see pbr-fog-wgsl.ts for the parity details).\n const fogHelper = _fogHelper;\n const fogBlock = _fogBlock;\n\n // Alpha output\n const alphaBlock = _noColorOutput\n ? \"\"\n : _hasAlphaBlend\n ? `var finalAlpha=alpha*material.materialAlpha;\nvar luminanceOverAlpha=0.0;\n/*BA*/\nluminanceOverAlpha+=dot(${_hasIbl ? `finalSpecularScaled` : `directSpecular`},vec3<f32>(0.2126,0.7152,0.0722));\nfinalAlpha=saturate(finalAlpha+luminanceOverAlpha*luminanceOverAlpha);\nreturn vec4<f32>(color,finalAlpha);`\n : `return vec4<f32>(color,alpha*material.materialAlpha);`;\n\n const doubleSidedEntry = _hasDoubleSided\n ? `@fragment fn main(input: FragmentInput, @builtin(front_facing) frontFacing: bool)${_noColorOutput ? \"\" : \" -> @location(0) vec4<f32>\"} {`\n : `@fragment fn main(input: FragmentInput)${_noColorOutput ? \"\" : \" -> @location(0) vec4<f32>\"} {`;\n const doubleSidedFlip = _hasDoubleSided ? `if (!frontFacing) { N = -N; }` : \"\";\n\n const lightDecls = _hasMultiLight ? _multiLightWGSL : _hasSingleLight ? _singleLightWGSL : \"\";\n const lightBindingDecl = _hasSingleLight || _hasMultiLight ? `@group(0) @binding(1) var<uniform> lights: lightsUniforms;` : \"\";\n const meshLightIndexHelper = _hasSingleLight || _hasMultiLight ? meshLightIndexWGSL(\"mesh\") : \"\";\n\n const anisoBrdfBlock = _hasAnisotropy ? _anisoBrdfFunctions : \"\";\n\n const fragmentHelpers = _ext?.fragmentHelpers ?? \"\";\n const fragmentPrelude = _ext?.fragmentPrelude ?? \"\";\n const baseColorUV = _ext?.uvForBaseColor ?? \"input.uv\";\n const ormUV = _ext?.uvForOrm ?? \"input.uv\";\n\n const _fragmentTemplate = `/*SU*/\n${_esmShadowOutput ? \"struct shadowParamsUniforms { biasAndScale: vec4<f32>, depthValues: vec4<f32>, }\" : \"\"}\n/*MU*/\n@group(1) @binding(0) var<uniform> mesh: MeshUniforms;\n/*HF*/\n/*FB*/\n/*FI*/\n${BRDF_FUNCTIONS}\n${acesBlock}\n${fogHelper}\n${anisoBrdfBlock}\n${lightDecls}\n${lightBindingDecl}\n${meshLightIndexHelper}\n${fragmentHelpers}\n${doubleSidedEntry}\n${fragmentPrelude}/*SV*/\nlet baseColorSample=textureSample(baseColorTexture,baseColorSampler,${baseColorUV});\n${baseColorDecode}\nlet orm=textureSample(ormTexture,ormSampler,${ormUV}).rgb;\n${occlusionDefault}\n${roughnessMetallic}\n${emissiveDefault}\n/*AT*/\n${\n // When the fragment terminates early (no color output, or ESM shadow\n // depth output), emit only the terminating return. Appending the\n // color-path body after the return would make it unreachable and\n // trigger a \"code is unreachable\" shader compilation warning.\n _noColorOutput\n ? \"return;\"\n : _esmShadowOutput\n ? _esmShadowDepthCode\n : `${normalBlock}\n${doubleSidedFlip}\n${anisotropyTBBlock}\n/*AC*/\nlet V=normalize(scene.vEyePosition.xyz-input.worldPos);\nlet NdotVUnclamped=dot(N,V);\nlet NdotV=abs(NdotVUnclamped)+0.0000001;\n${f0Default}\n/*MF*/\nvar alphaG=roughness*roughness+0.0005;\n${specularAABlock}\n${directLightBlock}\nvar color=directDiffuse+directSpecular+emissive;\n/*AI*/\n/*NI*/\n${fogBlock}\n${tonemapBlock}\ncolor=pow(color,vec3<f32>(1.0/2.2));\ncolor=clamp(color,vec3<f32>(0.0),vec3<f32>(1.0));\nlet highContrast=color*color*(3.0-2.0*color);\nif(scene.vImageInfos.y<1.0){color=mix(vec3<f32>(0.5),color,scene.vImageInfos.y);}\nelse{color=mix(color,highContrast,scene.vImageInfos.y-1.0);}\ncolor=max(color,vec3<f32>(0.0));\n/*BC*/\n${alphaBlock}`\n}\n}`;\n\n return {\n _vertexTemplate,\n _fragmentTemplate,\n _baseMeshUboFields,\n _baseMaterialUboFields,\n _baseVertexAttributes,\n _baseVaryings,\n _baseBindings,\n };\n}\n","/** PBR shader composer factory — extracts the per-feature-set shader composition\n * from pbr-renderable.ts. All dynamic dependencies (ACES, anisotropy, shadow,\n * multi-light, template-ext, thin-instance) are passed in via a deps object,\n * already resolved by the caller. Nothing is snapshotted at module load. */\n\nimport type { ShaderFragment, ComposedShader } from \"../../shader/fragment-types.js\";\nimport type { PbrShadowLightSlot } from \"./fragments/pbr-shadow-fragment.js\";\nimport { composeShader } from \"../../shader/shader-composer.js\";\nimport { createPbrTemplate } from \"./pbr-template.js\";\nimport type { MeshVbLayout } from \"../../mesh/mesh.js\";\nimport {\n PBR_HAS_NORMAL_MAP,\n PBR_HAS_ALPHA_BLEND,\n PBR2_HAS_UV_TRANSFORM,\n PBR2_HAS_REFLECTANCE_FACTORS,\n PBR2_HAS_UV2,\n PBR2_HAS_BASE_COLOR_FACTOR,\n PBR_HAS_METALLIC_REFLECTANCE_MAP,\n PBR_HAS_REFLECTANCE_MAP,\n PBR_HAS_SPECULAR_AA,\n PBR_HAS_EMISSIVE_COLOR,\n PBR_HAS_GAMMA_ALBEDO,\n PBR_HAS_ANISOTROPY,\n PBR_HAS_DOUBLE_SIDED,\n PBR_HAS_EMISSIVE,\n PBR_HAS_ENV,\n PBR_HAS_TONEMAP,\n PBR_HAS_FOG,\n PBR_HAS_SPEC_GLOSS,\n PBR_HAS_OCCLUSION,\n PBR_HAS_SKYBOX,\n PBR2_ESM_SHADOW_OUTPUT,\n PBR2_NO_COLOR_OUTPUT,\n} from \"./pbr-flag-bits.js\";\nimport { _getPbrExts, type _PbrFragCtx } from \"./pbr-flags.js\";\nimport {\n MSH_HAS_TANGENTS,\n MSH_HAS_MORPH_TARGETS,\n MSH_RECEIVE_SHADOWS,\n MSH_HAS_THIN_INSTANCES,\n MSH_HAS_INSTANCE_COLOR,\n MSH_HAS_VERTEX_COLOR,\n MSH_HAS_UV2,\n} from \"../mesh-features.js\";\n\ninterface PbrComposerDeps {\n readonly _singleLightWGSL: string;\n readonly _getSingleLightBlock: ((type: string) => string) | null;\n readonly _multiLightWGSL: string;\n readonly _multiLightLoop: string;\n readonly _acesHelpers: string;\n readonly _acesTonemapCall: string;\n /** Fog WGSL (calcFogFactor helper + blend block), dynamically loaded by pbr-renderable only\n * when scene.fog is set; \"\" otherwise so non-fog scenes bundle zero fog bytes. */\n readonly _fogHelper: string;\n readonly _fogBlock: string;\n readonly _createPbrTemplateExt: typeof import(\"./pbr-template-ext.js\").createPbrTemplateExt | null;\n readonly _anisoExt: typeof import(\"./fragments/anisotropy-fragment.js\") | null;\n readonly _iblSkyboxCalc: string;\n readonly _createPbrShadowFragment: ((slots: PbrShadowLightSlot[]) => ShaderFragment) | null;\n readonly _shadowLights: readonly { readonly lightIndex: number; readonly shadowType: import(\"./fragments/pbr-shadow-fragment.js\").PbrShadowLightSlot[\"shadowType\"] }[];\n readonly _createThinInstanceFragment: ((hasColor: boolean) => ShaderFragment) | null;\n}\n\nexport type PbrLightMode = 0 | 1 | 2;\ntype PbrComposeFn = (\n _features: number,\n _features2?: number,\n _meshFeatures?: number,\n _sceneFeatures?: number,\n _lightMode?: PbrLightMode,\n _singleLightType?: string,\n _esmShadowDepthCode?: string,\n _vbStrides?: MeshVbLayout,\n _vbKey?: string\n) => ComposedShader;\n\n/** Create a memoized shader composer for a given scene's resolved PBR deps. */\nexport function createPbrComposer(deps: PbrComposerDeps): PbrComposeFn {\n const cache = new Map<string, ComposedShader>();\n const {\n _singleLightWGSL,\n _getSingleLightBlock,\n _multiLightWGSL,\n _multiLightLoop,\n _acesHelpers,\n _acesTonemapCall,\n _fogHelper,\n _fogBlock,\n _createPbrTemplateExt,\n _anisoExt,\n _iblSkyboxCalc,\n _createPbrShadowFragment,\n _shadowLights,\n _createThinInstanceFragment,\n } = deps;\n\n return function composePbr(\n features: number,\n features2: number = 0,\n meshFeatures = 0,\n sceneFeatures = 0,\n lightMode: PbrLightMode = 0,\n singleLightType = \"\",\n _esmShadowDepthCode = \"\",\n vbStrides?: MeshVbLayout,\n vbKey = \"\"\n ): ComposedShader {\n const ckey = `${features}:${features2}:${meshFeatures}:${sceneFeatures}:${lightMode}:${singleLightType}${vbKey}`;\n const cached = cache.get(ckey);\n if (cached) {\n return cached;\n }\n\n const has = (bit: number) => (features & bit) !== 0;\n const hasMesh = (bit: number) => (meshFeatures & bit) !== 0;\n const hasScene = (bit: number) => (sceneFeatures & bit) !== 0;\n const hasNormal = has(PBR_HAS_NORMAL_MAP) && hasMesh(MSH_HAS_TANGENTS);\n const hasCotangent = has(PBR_HAS_NORMAL_MAP) && !hasMesh(MSH_HAS_TANGENTS);\n const _hasAnyNormal = hasNormal || hasCotangent;\n const _hasReflectanceExt = has(PBR_HAS_METALLIC_REFLECTANCE_MAP | PBR_HAS_REFLECTANCE_MAP) || (features2 & PBR2_HAS_REFLECTANCE_FACTORS) !== 0;\n const _hasIbl = hasScene(PBR_HAS_ENV);\n const _hasMorph = hasMesh(MSH_HAS_MORPH_TARGETS);\n const hasShadow = hasMesh(MSH_RECEIVE_SHADOWS);\n const _hasAnisotropy = has(PBR_HAS_ANISOTROPY);\n const _hasEmissiveColor = has(PBR_HAS_EMISSIVE_COLOR);\n const _hasEmissiveTexture = has(PBR_HAS_EMISSIVE);\n const hasTI = hasMesh(MSH_HAS_THIN_INSTANCES);\n\n const _hasUvTransform = (features2 & PBR2_HAS_UV_TRANSFORM) !== 0;\n const _hasVertexColor = hasMesh(MSH_HAS_VERTEX_COLOR);\n const _hasUv2 = (features2 & PBR2_HAS_UV2) !== 0 && hasMesh(MSH_HAS_UV2);\n const needsExt = _hasUvTransform || _hasVertexColor || _hasUv2;\n const _hasSpecularAA = has(PBR_HAS_SPECULAR_AA);\n const _ext =\n needsExt && _createPbrTemplateExt\n ? _createPbrTemplateExt({\n _hasUvTransform,\n _hasVertexColor,\n _hasUv2,\n _hasOcclusionUv2: _hasUv2,\n _hasAnyNormal,\n _hasEmissiveTexture,\n _hasSpecGloss: has(PBR_HAS_SPEC_GLOSS),\n })\n : undefined;\n\n const template = createPbrTemplate({\n _hasSingleLight: lightMode === 1,\n _hasMultiLight: lightMode === 2,\n _singleLightWGSL,\n _singleLightBlock: lightMode === 1 && _getSingleLightBlock ? _getSingleLightBlock(singleLightType) : \"\",\n _multiLightWGSL,\n _multiLightLoop,\n _normalMode: hasNormal ? \"tangent\" : hasCotangent ? \"cotangent\" : \"none\",\n _hasEmissiveTexture,\n _hasSpecGloss: has(PBR_HAS_SPEC_GLOSS),\n _hasDoubleSided: has(PBR_HAS_DOUBLE_SIDED),\n _hasTonemap: hasScene(PBR_HAS_TONEMAP),\n _fogHelper: hasScene(PBR_HAS_FOG) ? _fogHelper : \"\",\n _fogBlock: hasScene(PBR_HAS_FOG) ? _fogBlock : \"\",\n _acesHelpers: _acesHelpers,\n _acesTonemapCall: _acesTonemapCall,\n _hasAlphaBlend: has(PBR_HAS_ALPHA_BLEND),\n _hasSpecularAA,\n _hasGammaAlbedo: has(PBR_HAS_GAMMA_ALBEDO),\n _hasBaseColorFactor: (features2 & PBR2_HAS_BASE_COLOR_FACTOR) !== 0,\n _hasMorph,\n _hasOcclusion: has(PBR_HAS_OCCLUSION) && !_hasReflectanceExt,\n _hasEmissiveColor,\n _hasReflectanceExt,\n _hasIbl,\n _hasAnisotropy,\n _anisoBrdfFunctions: _hasAnisotropy && _anisoExt ? _anisoExt.ANISO_BRDF_FUNCTIONS : \"\",\n _anisoTBBlock: _hasAnisotropy && _anisoExt ? _anisoExt.makeAnisotropyTBBlock(hasNormal) : \"\",\n _ext,\n _noColorOutput: (features2 & PBR2_NO_COLOR_OUTPUT) !== 0,\n _esmShadowOutput: (features2 & PBR2_ESM_SHADOW_OUTPUT) !== 0,\n _esmShadowDepthCode,\n _vbStrides: vbStrides,\n });\n\n const frags: ShaderFragment[] = [];\n const fragCtx: _PbrFragCtx = {\n _features: features,\n _features2: features2,\n _meshFeatures: meshFeatures,\n _hasIbl: _hasIbl,\n _hasAnyNormal,\n _hasSpecularAA,\n _anisoBentNormalCode: _hasAnisotropy && _anisoExt ? _anisoExt.ANISO_BENT_NORMAL : \"\",\n _iblSkyboxCalc: has(PBR_HAS_SKYBOX) ? _iblSkyboxCalc : \"\",\n };\n // Registration order defines iteration order; callers register in composer-matching order.\n for (const regExt of _getPbrExts().values()) {\n if (regExt.frag) {\n const fr = regExt.frag(fragCtx);\n if (fr) {\n frags.push(fr);\n }\n }\n }\n if (hasShadow && _createPbrShadowFragment) {\n const slots = _shadowLights.map((sl) => ({ lightIndex: sl.lightIndex, shadowType: sl.shadowType }));\n frags.push(_createPbrShadowFragment(slots));\n }\n if (hasTI && _createThinInstanceFragment) {\n frags.push(_createThinInstanceFragment(hasMesh(MSH_HAS_INSTANCE_COLOR)));\n }\n\n const composed = composeShader(template, frags);\n cache.set(ckey, composed);\n return composed;\n };\n}\n","/** PBR mesh renderable — builds Renderables from glTF PBR meshes + environment.\n *\n * `buildPbrRenderables` does shared per-scene setup (extension/fragment imports,\n * shader composer, scene bind group, multi-light UBO), then delegates per-mesh\n * work to `buildSinglePbrRenderable`. Both initial build and material-swap\n * rebuilds go through the same single-mesh function. */\n\nimport { F32 } from \"../../engine/typed-arrays.js\";\nimport type { EngineContext } from \"../../engine/engine.js\";\nimport type { SceneContext } from \"../../scene/scene.js\";\nimport type { Mesh } from \"../../mesh/mesh.js\";\nimport type { PbrMaterialProps } from \"./pbr-material.js\";\nimport { collectPbrBoundTextures } from \"./pbr-material.js\";\nimport type { EnvironmentTextures } from \"../../loader-env/load-env.js\";\n\nimport type { Renderable, MeshGroupBuildResult } from \"../../render/renderable.js\";\nimport type { ShaderFragment } from \"../../shader/fragment-types.js\";\nimport { acquireTexture, releaseTexture, clearSamplerCache } from \"../../resource/gpu-pool.js\";\nimport { createUniformBuffer } from \"../../resource/gpu-buffers.js\";\nimport { getOrCreatePbrBindings, getOrCreatePbrPipeline, createPbrMeshBindGroup, clearPbrPipelineCache } from \"./pbr-pipeline.js\";\nimport {\n _registerPbrExt,\n _getPbrExts,\n PBR_HAS_NORMAL_MAP,\n PBR_HAS_ALPHA_BLEND,\n PBR2_NO_COLOR_OUTPUT,\n PBR2_HAS_REFRACTION,\n PBR2_HAS_UV2,\n PBR_HAS_ENV,\n PBR_HAS_TONEMAP,\n PBR_HAS_FOG,\n PBR2_ESM_SHADOW_OUTPUT,\n} from \"./pbr-flags.js\";\nimport type { PbrExt } from \"./pbr-flags.js\";\nimport { createPbrComposer } from \"./pbr-compose.js\";\nimport { _computePbrMaterialFeatures } from \"./pbr-material.js\";\nimport type { ShadowGenerator } from \"../../shadow/shadow-generator.js\";\nimport type { ThinInstanceData } from \"../../mesh/thin-instance.js\";\nimport type { PbrShadowLightSlot } from \"./fragments/pbr-shadow-fragment.js\";\nimport { writeMeshLightSelection } from \"../../render/lights-ubo.js\";\nimport type { PbrLightMode } from \"./pbr-compose.js\";\nimport type { Material, MaterialRenderFeatures } from \"../material.js\";\nimport { _computeMeshFeatures, MSH_HAS_INSTANCE_COLOR, MSH_HAS_THIN_INSTANCES, MSH_HAS_UV2, MSH_HAS_VERTEX_COLOR } from \"../mesh-features.js\";\nimport { packMat4IntoF32 } from \"../../math/pack-mat4-into-f32.js\";\n\ntype SingleLightType = \"hemispheric\" | \"directional\" | \"spot\" | \"point\";\ninterface SingleLightWgslModule {\n SINGLE_LIGHT_STRUCTS: string;\n getSingleLightBlock(): string;\n}\n\n/** Build PBR Renderable(s) + a SceneUniformUpdater from PBR meshes. */\nexport async function buildPbrRenderables(scene: SceneContext, meshes: Mesh[], envTextures: EnvironmentTextures | undefined): Promise<MeshGroupBuildResult> {\n const engine = scene.surface.engine;\n const device = engine._device;\n // Per-size scratch buffers for material UBO re-writes (zero allocation per frame).\n const materialScratch = new Map<number, Float32Array>();\n const hasEnv = !!envTextures;\n const shadowLights: { lightIndex: number; shadowType: \"esm\" | \"pcf\" | \"csm\"; gen: ShadowGenerator }[] = [];\n for (let i = 0; i < scene.lights.length; i++) {\n const sg = scene.lights[i]!.shadowGenerator;\n if (sg) {\n shadowLights.push({ lightIndex: i, shadowType: sg._shadowType, gen: sg });\n }\n }\n const hasSomeShadows = shadowLights.length > 0;\n let hasAnyAffectedLight = false;\n let needsSingleLightPath = false;\n let needsMultiLightPath = false;\n const singleLightTypes: SingleLightType[] = [];\n for (const mesh of meshes) {\n const lr = writeMeshLightSelection(mesh, scene.lights);\n const affectedCount = lr > 0 ? 1 : -lr;\n hasAnyAffectedLight ||= affectedCount > 0;\n if (affectedCount === 1 && !(mesh.receiveShadows && hasSomeShadows)) {\n needsSingleLightPath = true;\n const type = getPackedSingleLightType(scene.lights, lr - 1);\n if (!singleLightTypes.includes(type)) {\n singleLightTypes.push(type);\n }\n } else if (affectedCount > 0) {\n needsMultiLightPath = true;\n }\n }\n\n // ── Single O(N) scan over meshes for all scene-wide feature flags ──\n // Flags are plain locals (not an object return) so terser can mangle their names.\n // Replaces ~11 sequential meshes.some() loops (was O(11N)).\n let hasSkybox = false;\n let hasMetallicReflectance = false;\n let hasClearcoat = false;\n let hasSheen = false;\n let hasIridescence = false;\n let hasAnyAnisotropy = false;\n let hasAnySubsurface = false;\n let hasAlphaTest = false;\n let hasTransmissionRefraction = false;\n let needsEmissiveColor = false;\n let hasSomeSkeletons = false;\n let hasSomeMorphs = false;\n let hasSomeThinInstances = false;\n let hasCullingTI = false;\n let hasAnyUnlit = false;\n let hasAnyUvTransform = false;\n let hasAnyUv2 = false;\n let hasAnyVertexColor = false;\n for (let i = 0; i < meshes.length; i++) {\n const m = meshes[i]!;\n const mat = m.material as PbrMaterialProps & { _hasReflExt?: boolean; _hasUvTx?: boolean };\n const refractionIntensity = mat.subsurface?.refraction?.intensity ?? 0;\n hasSkybox ||= !!mat.skyboxMode;\n hasMetallicReflectance ||= !!(mat.metallicReflectanceTexture || mat.reflectanceTexture || mat._hasReflExt);\n hasClearcoat ||= !!mat.clearCoat?.isEnabled;\n hasSheen ||= !!mat.sheen?.isEnabled;\n hasIridescence ||= !!mat.iridescence?.isEnabled;\n hasAnyAnisotropy ||= !!mat.anisotropy?.isEnabled;\n hasAnySubsurface ||= !!mat.subsurface?.translucency;\n hasAlphaTest ||= mat.alphaCutOff! > 0;\n hasTransmissionRefraction ||= refractionIntensity > 0 && !!mat.transmissive;\n needsEmissiveColor ||= !!mat.emissiveColor;\n hasSomeSkeletons ||= !!m.skeleton;\n hasSomeMorphs ||= !!m.morphTargets;\n hasSomeThinInstances ||= !!m.thinInstances;\n hasCullingTI ||= !!m.thinInstances?._gpuCullingEnabled;\n hasAnyUnlit ||= !!mat.unlit;\n hasAnyUvTransform ||= !!mat._hasUvTx;\n // UV2 only counts when occlusion samples texcoord 1.\n hasAnyUv2 ||= !!m._gpu.uv2Buffer && mat.occlusionTexCoord === 1;\n hasAnyVertexColor ||= !!m._gpu.colorBuffer;\n }\n\n // ── Dynamically import fragment creators based on scene capabilities ──\n\n // IBL fragment.\n let _iblSkyboxCalc = \"\";\n if (hasEnv) {\n const mod = await import(\"./fragments/ibl-fragment.js\");\n _registerPbrExt(mod.pbrExt);\n if (hasSkybox) {\n // Skybox-mode WGSL is only loaded when at least one mesh in the scene needs it.\n const sky = await import(\"./fragments/ibl-skybox-wgsl.js\");\n _iblSkyboxCalc = sky.IBL_SKYBOX_CALCULATION;\n }\n }\n\n // Light/shadow helpers stay dynamic so single-light and non-shadow bundles stay lean.\n let _createPbrShadowFragment: ((slots: PbrShadowLightSlot[]) => ShaderFragment) | null = null;\n let _singleLightWGSL = \"\";\n let _getSingleLightBlock: ((type: string) => string) | null = null;\n const singleLightBlocks: Partial<Record<SingleLightType, () => string>> = {};\n let _multiLightWGSL = \"\";\n let _multiLightLoop = \"\";\n if (needsSingleLightPath) {\n for (const type of singleLightTypes) {\n const single = await importSingleLightWgsl(type);\n _singleLightWGSL = single.SINGLE_LIGHT_STRUCTS;\n singleLightBlocks[type] = single.getSingleLightBlock;\n }\n _getSingleLightBlock = (type) => singleLightBlocks[toSingleLightType(type)]?.() ?? \"\";\n }\n if (needsMultiLightPath) {\n const wgslMod = await import(\"./fragments/multilight-wgsl.js\");\n _multiLightWGSL = wgslMod.MULTI_LIGHT_STRUCTS() + wgslMod.COMPUTE_PBR_LIGHT;\n _multiLightLoop = wgslMod.getMultiLightLoop();\n }\n if (hasAnyAffectedLight && hasSomeShadows) {\n const shadowMod = await import(\"./fragments/pbr-shadow-fragment.js\");\n _createPbrShadowFragment = shadowMod.createPbrShadowFragment;\n }\n\n // ── Per-mesh fragment creators (imported if any mesh needs them) ──\n // Each optional PBR fragment module exports a uniform `pbrExt`, so registration\n // collapses to a single data-driven loop over [flag, loader] pairs. The `import()`\n // specifiers stay literal (required for Vite code-splitting) and the shared\n // `_registerPbrExt((await load()).pbrExt)` glue is emitted once instead of per\n // feature, keeping this management layer small as features are added.\n // Registration order is the iteration order consumed by `_getPbrExts().values()`\n // on the hot paths (composePbr, writeMaterialData, collectPbrBoundTextures).\n type PbrExtLoad = () => Promise<{ pbrExt: PbrExt }>;\n const _drainPbrExts = async (loaders: Array<readonly [boolean, PbrExtLoad]>) => {\n for (const [flag, load] of loaders) {\n if (flag) {\n _registerPbrExt((await load()).pbrExt);\n }\n }\n };\n\n await _drainPbrExts([\n [hasAlphaTest, () => import(\"./fragments/alpha-test-fragment.js\")],\n [hasMetallicReflectance, () => import(\"./fragments/reflectance-fragment.js\")],\n [hasClearcoat, () => import(\"./fragments/clearcoat-fragment.js\")],\n [hasSheen, () => import(\"./fragments/sheen-fragment.js\")],\n [hasIridescence, () => import(\"./fragments/iridescence-fragment.js\")],\n [hasAnySubsurface, () => import(\"./fragments/subsurface-fragment.js\")],\n ]);\n if (hasTransmissionRefraction) {\n const mod = await import(\"./pbr-refraction.js\");\n await mod.registerPbrRefraction(scene as SceneContext, engine, _registerPbrExt);\n }\n await _drainPbrExts([\n [needsEmissiveColor, () => import(\"./fragments/emissive-fragment.js\")],\n [hasAnyUnlit, () => import(\"./fragments/unlit-fragment.js\")],\n [hasSomeSkeletons, () => import(\"./fragments/skeleton-fragment.js\")],\n [hasSomeMorphs, () => import(\"./fragments/morph-fragment.js\")],\n [hasAnyUvTransform, () => import(\"./fragments/uv-transform-fragment.js\")],\n ]);\n\n // Anisotropy needs its module reference retained (for ANISO_BRDF_FUNCTIONS /\n // makeAnisotropyTBBlock / ANISO_DIRECT_DG / ANISO_BENT_NORMAL strings consumed\n // by the template below), so it keeps the full module binding.\n let _anisoExt: typeof import(\"./fragments/anisotropy-fragment.js\") | null = null;\n if (hasAnyAnisotropy) {\n _anisoExt = await import(\"./fragments/anisotropy-fragment.js\");\n _registerPbrExt(_anisoExt.pbrExt);\n }\n\n // Lazy-load pbr-template-ext when any advanced features are present.\n // Scene1 has none of these, so it won't pay the ~1.5KB cost.\n let _createPbrTemplateExt: typeof import(\"./pbr-template-ext.js\").createPbrTemplateExt | null = null;\n if (hasAnyUvTransform || hasAnyVertexColor || hasAnyUv2) {\n const extMod = await import(\"./pbr-template-ext.js\");\n _createPbrTemplateExt = extMod.createPbrTemplateExt;\n }\n\n let _createThinInstanceFragment: ((hasColor: boolean) => ShaderFragment) | null = null;\n let _syncThinInstanceBuffers:\n | ((\n engine: EngineContext,\n ti: ThinInstanceData,\n pass: GPURenderPassEncoder | GPURenderBundleEncoder,\n slot: number,\n hasColor: boolean,\n drawBuffers?: import(\"../../mesh/thin-instance-gpu.js\").ThinInstanceDrawBuffers | null\n ) => number)\n | null = null;\n let _cull: typeof import(\"../../mesh/thin-instance-cull-binding.js\") | undefined;\n // Per-frame thin-instance matrix/color UPLOAD (no pass — just writeBuffer of the dirty range).\n // The bundle-recorded draw only re-binds the buffer; animated instances (e.g. wind-swayed flora)\n // mutate their matrices every frame, but the cached opaque bundle is NOT re-recorded each frame,\n // so the draw-time sync never runs on a steady frame. We therefore upload dirty thin-instance data\n // from the per-frame update() below (which always runs). It is version-gated, so static instances\n // cost nothing, and it never recreates the buffer for a same-capacity update — keeping the cached\n // bundle's setVertexBuffer reference valid.\n let _syncThinInstanceGpuData: ((engine: EngineContext, ti: ThinInstanceData, hasColor: boolean) => void) | null = null;\n if (hasSomeThinInstances) {\n const mod = await import(\"../../shader/fragments/thin-instance-fragment.js\");\n _createThinInstanceFragment = mod.createThinInstanceFragment;\n const gpuMod = await import(\"../../mesh/thin-instance-gpu.js\");\n _syncThinInstanceBuffers = gpuMod.syncThinInstanceBuffers;\n if (hasCullingTI) {\n _cull = await import(\"../../mesh/thin-instance-cull-binding.js\");\n }\n _syncThinInstanceGpuData = gpuMod.syncThinInstanceGpuData;\n }\n\n // ACES tonemap WGSL is dynamically imported only when requested (keeps standard-tonemap bundles lean).\n // Must be loaded before the composer is created so deps are fully resolved.\n let _acesHelpers = \"\";\n let _acesTonemapCall = \"\";\n const hasTonemap = scene.imageProcessing.toneMappingEnabled;\n if (hasTonemap && scene.imageProcessing.toneMappingType === \"aces\") {\n const acesMod = await import(\"./pbr-aces-wgsl.js\");\n _acesHelpers = acesMod.ACES_HELPERS_WGSL;\n _acesTonemapCall = acesMod.ACES_TONEMAP_CALL_WGSL;\n }\n\n // Fog WGSL is dynamically imported only when the scene has fog, so non-fog PBR scenes\n // bundle zero fog bytes (a static import would defeat tree-shaking — see pbr-fog-wgsl.ts).\n let _fogHelper = \"\";\n let _fogBlock = \"\";\n if (scene.fog) {\n const fogMod = await import(\"./pbr-fog-wgsl.js\");\n _fogHelper = fogMod.PBR_FOG_HELPER;\n _fogBlock = fogMod.PBR_FOG_BLOCK;\n }\n\n const composePbr = createPbrComposer({\n _singleLightWGSL,\n _getSingleLightBlock,\n _multiLightWGSL,\n _multiLightLoop,\n _acesHelpers,\n _acesTonemapCall,\n _fogHelper,\n _fogBlock,\n _createPbrTemplateExt,\n _anisoExt,\n _iblSkyboxCalc,\n _createPbrShadowFragment,\n _shadowLights: shadowLights,\n _createThinInstanceFragment,\n });\n\n const sceneFeatures = (hasEnv ? PBR_HAS_ENV : 0) | (hasTonemap ? PBR_HAS_TONEMAP : 0) | (scene.fog ? PBR_HAS_FOG : 0);\n // Shadow bind group cache — within one scene build, all receiving meshes share the\n // same shadowLights array, so a BG keyed by shadowBGL alone is correct.\n const shadowBGCache = new Map<GPUBindGroupLayout, GPUBindGroup>();\n const syncThinInstanceBuffers = _syncThinInstanceBuffers;\n const syncThinInstanceGpuData = _syncThinInstanceGpuData;\n\n // Closure used both for the initial per-mesh build below AND for later\n // material-swap / per-pass-override rebuilds (set on pbrGroupBuilder._rebuildSingle).\n // Captures the per-scene context — no separate WeakMap needed.\n const rebuildSingle = (s: SceneContext, mesh: Mesh, materialOverride?: Material): Renderable => {\n const materialInput = (materialOverride ?? mesh.material) as PbrMaterialProps;\n const mat = materialInput;\n const renderFeatures = (mat._renderFeatures ??= _computePbrMaterialFeatures(mat)) as MaterialRenderFeatures;\n const isOverride = materialOverride != null;\n const mi = mesh;\n\n const lr = writeMeshLightSelection(mesh, s.lights);\n const lightCount = lr > 0 ? 1 : -lr;\n const features = renderFeatures.features;\n const features2 = renderFeatures.features2 ?? 0;\n const shadowOutput = (features2 & (PBR2_NO_COLOR_OUTPUT | PBR2_ESM_SHADOW_OUTPUT)) !== 0;\n const receiveShadows = !shadowOutput && mesh.receiveShadows && hasSomeShadows;\n const lightMode: PbrLightMode = lightCount === 0 ? 0 : lightCount === 1 && !receiveShadows ? 1 : 2;\n const singleLightType = lightMode === 1 ? getPackedSingleLightType(s.lights, lr - 1) : \"\";\n const meshFeatures = _computeMeshFeatures(mesh, receiveShadows);\n const esmShadowDepthCode = (features2 & PBR2_ESM_SHADOW_OUTPUT) !== 0 ? (mat as PbrMaterialProps & { readonly _esmShadowDepthCode: string })._esmShadowDepthCode : \"\";\n\n // Genuine GPU interleaving. Tight meshes have `_vbLayout` undefined → vbKey \"\"\n // → composed shader, bindings, and pipeline cache keys are byte-identical to\n // today. Interleaved meshes carry a precomputed vbKey from the loader module.\n const vbLayout = mi._gpu._vbLayout;\n const vbKey = mi._gpu._vbKey ?? \"\";\n\n const composed = composePbr(features, features2, meshFeatures, sceneFeatures, lightMode, singleLightType, esmShadowDepthCode, vbLayout, vbKey);\n const bindings = getOrCreatePbrBindings(engine, features, features2, meshFeatures, sceneFeatures, composed, `${lightMode}:${singleLightType}${vbKey}`);\n\n // Mesh UBO (world matrix at offset 0; spec.totalBytes covers any extra fields).\n const meshUboData = new F32(composed._meshUboSpec._totalBytes / 4);\n const _packMeshWorld = engine._makePackMeshWorld?.(s as SceneContext) ?? packMat4IntoF32;\n _packMeshWorld(meshUboData, mesh.worldMatrix, 0, 0);\n writeMeshLightSelection(mesh, s.lights, meshUboData);\n const meshUBO = createUniformBuffer(engine, meshUboData);\n\n // Material UBO.\n const materialSpec = composed._materialUboSpec!;\n const matInitData = new F32(materialSpec._totalBytes / 4);\n _writeMaterialData(matInitData, mat, materialSpec);\n const materialUBO = createUniformBuffer(engine, matInitData);\n\n const needsTaskRefraction = !!mat.transmissive && (features2 & PBR2_HAS_REFRACTION) !== 0;\n const materialBindGroupStatic = needsTaskRefraction ? null : createPbrMeshBindGroup(engine, bindings, composed, meshUBO, materialUBO, mat, envTextures ?? null, mesh);\n\n // Shadow bind group (group 2) — shared across receiving meshes via shadowBGCache.\n let shadowBindGroup: GPUBindGroup | null = null;\n const meshShadowLights = receiveShadows ? shadowLights : [];\n if (meshShadowLights.length > 0 && bindings._shadowBGL) {\n let cached = shadowBGCache.get(bindings._shadowBGL);\n if (!cached) {\n const entries: GPUBindGroupEntry[] = [];\n let b = 0;\n for (const sl of meshShadowLights) {\n const sg = sl.gen;\n entries.push({ binding: b++, resource: sg._depthTexture.createView() });\n entries.push({ binding: b++, resource: sg._depthSampler });\n entries.push({ binding: b++, resource: { buffer: sg._shadowUBO } });\n }\n cached = device.createBindGroup({ layout: bindings._shadowBGL, entries });\n shadowBGCache.set(bindings._shadowBGL, cached);\n }\n shadowBindGroup = cached;\n }\n\n const boundTextures = collectPbrBoundTextures(mat);\n for (const t of boundTextures) {\n acquireTexture(t);\n }\n s._meshDisposables.set(mesh, [\n () => {\n meshUBO.destroy();\n materialUBO.destroy();\n },\n () => {\n for (const t of boundTextures) {\n releaseTexture(t);\n }\n },\n ]);\n\n const isTransparent = (features2 & (PBR2_NO_COLOR_OUTPUT | PBR2_ESM_SHADOW_OUTPUT)) === 0 && (features & PBR_HAS_ALPHA_BLEND) !== 0;\n const order = mesh.renderOrder ?? (isTransparent || needsTaskRefraction ? 150 : 100);\n\n const hasNormalMap = (features & PBR_HAS_NORMAL_MAP) !== 0;\n const hasUV2 = (features2 & PBR2_HAS_UV2) !== 0 && (meshFeatures & MSH_HAS_UV2) !== 0;\n const hasVertexColor = (meshFeatures & MSH_HAS_VERTEX_COLOR) !== 0;\n const hasTI = (meshFeatures & MSH_HAS_THIN_INSTANCES) !== 0;\n const hasTIColor = (meshFeatures & MSH_HAS_INSTANCE_COLOR) !== 0;\n\n let _lastWorldVersion = mesh.worldMatrixVersion;\n let _lastLightsCount = s.lights.length;\n const sortCenter = isTransparent || needsTaskRefraction ? ([mesh.worldMatrix[12]!, mesh.worldMatrix[13]!, mesh.worldMatrix[14]!] as [number, number, number]) : null;\n const _baseUpdate = (): void => {\n const worldVersion = mesh.worldMatrixVersion;\n if (worldVersion !== _lastWorldVersion || s.lights.length !== _lastLightsCount) {\n if (sortCenter) {\n sortCenter[0] = mesh.worldMatrix[12]!;\n sortCenter[1] = mesh.worldMatrix[13]!;\n sortCenter[2] = mesh.worldMatrix[14]!;\n }\n _packMeshWorld(meshUboData, mesh.worldMatrix, 0, 0);\n writeMeshLightSelection(mesh, s.lights, meshUboData);\n device.queue.writeBuffer(meshUBO, 0, meshUboData as Float32Array<ArrayBuffer>);\n _lastWorldVersion = worldVersion;\n _lastLightsCount = s.lights.length;\n }\n const uboVersion = mat._uboVersion;\n if (uboVersion !== _lastUboVersion) {\n _lastUboVersion = uboVersion;\n let data = materialScratch.get(materialSpec._totalBytes);\n if (!data) {\n data = new F32(materialSpec._totalBytes / 4);\n materialScratch.set(materialSpec._totalBytes, data);\n } else {\n data.fill(0);\n }\n _writeMaterialData(data, mat, materialSpec);\n device.queue.writeBuffer(materialUBO, 0, data.buffer, 0, data.byteLength);\n }\n // Upload any dirty thin-instance matrices/colors every frame (version-gated; see the\n // _syncThinInstanceGpuData declaration above). This is what makes per-frame animated\n // instance transforms (wind sway) actually reach the GPU despite the cached draw bundle.\n if (hasTI && syncThinInstanceGpuData) {\n const ti = mesh.thinInstances;\n if (ti) {\n syncThinInstanceGpuData(engine, ti, hasTIColor);\n }\n }\n };\n // FO-version wrapper applied only when the engine has floating-origin\n // on (see standard-renderable for the rationale).\n const _invalidate = (): void => {\n _lastWorldVersion = -1;\n };\n const update = engine._wrapRenderableForFO?.(_baseUpdate, s as SceneContext, _invalidate) ?? _baseUpdate;\n\n const drawWith = (\n pass: GPURenderPassEncoder | GPURenderBundleEncoder,\n materialBindGroup: GPUBindGroup,\n cullBinding?: import(\"../../mesh/thin-instance-cull-binding.js\").TiCullBinding\n ): number => {\n if (!isOverride && mesh.material !== materialInput) {\n return 0;\n }\n const gpu = mi._gpu;\n pass.setBindGroup(1, materialBindGroup);\n if (shadowBindGroup) {\n pass.setBindGroup(2, shadowBindGroup);\n }\n let slot = 0;\n const vb = gpu._vbLayout;\n pass.setVertexBuffer(slot++, gpu.positionBuffer, vb?._p?._offset);\n pass.setVertexBuffer(slot++, gpu.normalBuffer, vb?._n?._offset);\n if (hasNormalMap && gpu.tangentBuffer) {\n pass.setVertexBuffer(slot++, gpu.tangentBuffer, vb?._t?._offset);\n }\n pass.setVertexBuffer(slot++, gpu.uvBuffer, vb?._u?._offset);\n if (hasUV2 && gpu.uv2Buffer) {\n pass.setVertexBuffer(slot++, gpu.uv2Buffer, vb?._u2?._offset);\n }\n if (hasVertexColor && gpu.colorBuffer) {\n pass.setVertexBuffer(slot++, gpu.colorBuffer, vb?._c?._offset);\n }\n // Skinning vertex buffers: live skeleton OR baked VAT (same field names, mutually exclusive).\n const skin = mesh.skeleton ?? mesh.vat;\n if (skin) {\n pass.setVertexBuffer(slot++, skin.jointsBuffer);\n pass.setVertexBuffer(slot++, skin.weightsBuffer);\n if (skin.joints1Buffer && skin.weights1Buffer) {\n pass.setVertexBuffer(slot++, skin.joints1Buffer);\n pass.setVertexBuffer(slot++, skin.weights1Buffer);\n }\n }\n\n const ti = hasTI ? mesh.thinInstances : null;\n if (ti && syncThinInstanceBuffers) {\n slot = syncThinInstanceBuffers(engine, ti, pass, slot, hasTIColor, cullBinding?.cullDrawBufs);\n }\n\n pass.setIndexBuffer(gpu.indexBuffer, gpu.indexFormat);\n if (cullBinding) {\n cullBinding.draw(pass, gpu.indexCount, ti!.count);\n } else if (ti && ti.count > 0) {\n pass.drawIndexed(gpu.indexCount, ti.count);\n } else {\n pass.drawIndexed(gpu.indexCount);\n }\n return 1;\n };\n\n const r: Renderable = {\n order,\n isTransparent,\n _transmissive: needsTaskRefraction,\n mesh,\n bind(eng, sig) {\n const pipeline = getOrCreatePbrPipeline(eng as EngineContext, sig, bindings);\n const materialBindGroup = needsTaskRefraction\n ? createPbrMeshBindGroup(engine, bindings, composed, meshUBO, materialUBO, mat, envTextures ?? null, mesh, sig._transmissionTexture)\n : materialBindGroupStatic!;\n // Opaque-only GPU culling (opt-in): tryBind returns a per-binding lifecycle or undefined.\n const cb = _cull?.tryBind(r, s, mesh, engine, hasTIColor, isTransparent || needsTaskRefraction, update);\n return {\n renderable: r,\n pipeline,\n update: cb ? cb.update : update,\n draw: (pass) => drawWith(pass, materialBindGroup, cb),\n };\n },\n };\n if (sortCenter) {\n r._worldCenter = sortCenter;\n }\n let _lastUboVersion = mat._uboVersion;\n return r;\n };\n\n const renderables = meshes.map((m) => rebuildSingle(scene, m));\n\n // Stash the per-scene PBR context on the scene so the PBR geometry-renderer\n // path can reuse the same composer / env / shadow setup without re-running\n // the scene-wide scan above. Stored on the scene (not on pbrGroupBuilder)\n // to avoid a static cycle: pbrGroupBuilder lives in pbr-material.ts which\n // already dynamic-imports this module.\n (scene as SceneContext & { _pbrGeomContext?: _PbrGeometryContext })._pbrGeomContext = {\n _composePbr: composePbr,\n _sceneFeatures: sceneFeatures,\n _envTextures: envTextures ?? null,\n _shadowLights: shadowLights,\n _syncThinInstanceBuffers: _syncThinInstanceBuffers,\n };\n\n scene._disposables.push(\n () => clearPbrPipelineCache(),\n () => clearSamplerCache(engine)\n );\n\n return { renderables, rebuildSingle };\n}\n\n/** @internal Per-scene PBR context stashed on the singleton `pbrGroupBuilder`\n * after `buildPbrRenderables` runs. Consumed by the PBR geometry-renderer\n * module — the only way to reuse the per-scene `composePbr` closure (env,\n * shadows, lights, anisotropy, sub-features) without duplicating the heavy\n * scene-wide dep-gathering scan. Overwritten on each scene build, matching\n * the same pattern used for `_rebuildSingle`. */\nexport interface _PbrGeometryContext {\n /** @internal */\n readonly _composePbr: ReturnType<typeof createPbrComposer>;\n /** @internal */\n readonly _sceneFeatures: number;\n /** @internal */\n readonly _envTextures: EnvironmentTextures | null;\n /** @internal */\n readonly _shadowLights: readonly { readonly lightIndex: number; readonly shadowType: \"esm\" | \"pcf\" | \"csm\"; readonly gen: ShadowGenerator }[];\n /** @internal */\n readonly _syncThinInstanceBuffers:\n | ((engine: EngineContext, ti: ThinInstanceData, pass: GPURenderPassEncoder | GPURenderBundleEncoder, slot: number, hasColor: boolean) => number)\n | null;\n}\n\nfunction toSingleLightType(type: string): SingleLightType {\n return type === \"hemispheric\" || type === \"directional\" || type === \"spot\" ? type : \"point\";\n}\n\nfunction getPackedSingleLightType(lights: SceneContext[\"lights\"], packedIndex: number): SingleLightType {\n let packed = 0;\n for (const light of lights) {\n if (!light._writeLightUbo) {\n continue;\n }\n if (packed === packedIndex) {\n return toSingleLightType(light.lightType);\n }\n packed++;\n }\n return \"point\";\n}\n\nasync function importSingleLightWgsl(type: SingleLightType): Promise<SingleLightWgslModule> {\n if (type === \"hemispheric\") {\n return import(\"./fragments/singlelight-hemispheric-wgsl.js\");\n }\n if (type === \"directional\") {\n return import(\"./fragments/singlelight-directional-wgsl.js\");\n }\n if (type === \"spot\") {\n return import(\"./fragments/singlelight-spot-wgsl.js\");\n }\n return import(\"./fragments/singlelight-point-wgsl.js\");\n}\n\n/** @internal Write material properties into a pre-allocated Float32Array.\n * Core fields only; per-extension slices are contributed by registered\n * writers. Exported for the PBR geometry-renderer path. */\nexport function _writeMaterialData(data: Float32Array, material: PbrMaterialProps, spec: import(\"../../shader/fragment-types.js\").UboSpec): void {\n data[0] = material.environmentIntensity ?? 1.0;\n data[1] = material.directIntensity ?? 1.0;\n data[2] = material.reflectance ?? 0.04;\n data[3] = material.alpha ?? 1.0;\n const baseColorFactorOffset = spec._offsets.get(\"baseColorFactor\");\n if (baseColorFactorOffset !== undefined) {\n const off = baseColorFactorOffset / 4;\n const factor = material.baseColorFactor;\n data[off] = factor ? factor[0]! : 1.0;\n data[off + 1] = factor ? factor[1]! : 1.0;\n data[off + 2] = factor ? factor[2]! : 1.0;\n data[off + 3] = factor ? factor[3]! : 1.0;\n }\n if (spec._offsets.has(\"metallicFactor\")) {\n const off = spec._offsets.get(\"metallicFactor\")! / 4;\n data[off] = material.metallicFactor ?? 1.0;\n data[off + 1] = material.roughnessFactor ?? 1.0;\n data[off + 2] = material.normalTextureScale ?? 1.0;\n data[off + 3] = material.usePhysicalLightFalloff === false ? 0 : 1;\n }\n for (const ext of _getPbrExts().values()) {\n if (ext.writeUbo) {\n ext.writeUbo(data, material, spec._offsets);\n }\n }\n}\n"],"names":["_a","_b","_c","_d","_e","_f"],"mappings":";;AAsCA,MAAM,qCAAqB,IAAA;AAC3B,IAAI,gBAAkC;AAEtC,SAAS,aAAa,QAA6B;AAC/C,MAAI,kBAAkB,OAAO,SAAS;AAClC,mBAAe,MAAA;AACf,oBAAgB,OAAO;AAAA,EAC3B;AACJ;AAGO,SAAS,wBAA8B;AAC1C,iBAAe,MAAA;AACf,kBAAgB;AACpB;AAIO,SAAS,uBACZ,QACA,UACA,WACA,cACA,eACA,UACA,YAAY,IACM;AACl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