@xiping/react-components 1.0.29 → 1.0.31

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 (563) hide show
  1. package/dist/cjs/components/confetti-button/index.js +1 -1
  2. package/dist/cjs/components/qr-code/index.js +1 -1
  3. package/dist/cjs/components/txt-editor/TxtEditor.js +1 -1
  4. package/dist/cjs/components/video-dialog/VideoDialog.js +1 -1
  5. package/dist/cjs/hooks/useStayTimeReport.js +1 -1
  6. package/dist/cjs/index.js +1 -1
  7. package/dist/cjs/react-components.css +1 -1
  8. package/dist/es/components/confetti-button/index.js +6 -5
  9. package/dist/es/components/qr-code/index.js +1 -1
  10. package/dist/es/components/txt-editor/TxtEditor.js +10 -10
  11. package/dist/es/components/video-dialog/VideoDialog.js +11 -12
  12. package/dist/es/hooks/useStayTimeReport.js +1 -1
  13. package/dist/es/index.js +2 -2
  14. package/dist/es/react-components.css +1 -1
  15. package/package.json +16 -16
  16. package/dist/cjs/_virtual/_commonjsHelpers.js +0 -1
  17. package/dist/cjs/_virtual/alignment-pattern.js +0 -1
  18. package/dist/cjs/_virtual/browser.js +0 -1
  19. package/dist/cjs/_virtual/browser2.js +0 -1
  20. package/dist/cjs/_virtual/canvas.js +0 -1
  21. package/dist/cjs/_virtual/dijkstra.js +0 -1
  22. package/dist/cjs/_virtual/error-correction-code.js +0 -1
  23. package/dist/cjs/_virtual/error-correction-level.js +0 -1
  24. package/dist/cjs/_virtual/finder-pattern.js +0 -1
  25. package/dist/cjs/_virtual/format-info.js +0 -1
  26. package/dist/cjs/_virtual/galois-field.js +0 -1
  27. package/dist/cjs/_virtual/generateBounds.js +0 -1
  28. package/dist/cjs/_virtual/generateCreateBody.js +0 -1
  29. package/dist/cjs/_virtual/generateCreateDragForce.js +0 -1
  30. package/dist/cjs/_virtual/generateCreateSpringForce.js +0 -1
  31. package/dist/cjs/_virtual/generateIntegrator.js +0 -1
  32. package/dist/cjs/_virtual/generateQuadTree.js +0 -1
  33. package/dist/cjs/_virtual/index.js +0 -1
  34. package/dist/cjs/_virtual/index2.js +0 -1
  35. package/dist/cjs/_virtual/index3.js +0 -1
  36. package/dist/cjs/_virtual/index4.js +0 -1
  37. package/dist/cjs/_virtual/index5.js +0 -1
  38. package/dist/cjs/_virtual/index6.js +0 -1
  39. package/dist/cjs/_virtual/index7.js +0 -1
  40. package/dist/cjs/_virtual/mask-pattern.js +0 -1
  41. package/dist/cjs/_virtual/mode.js +0 -1
  42. package/dist/cjs/_virtual/polynomial.js +0 -1
  43. package/dist/cjs/_virtual/qrcode.js +0 -1
  44. package/dist/cjs/_virtual/react-is.development.js +0 -1
  45. package/dist/cjs/_virtual/react-is.production.min.js +0 -1
  46. package/dist/cjs/_virtual/regex.js +0 -1
  47. package/dist/cjs/_virtual/segments.js +0 -1
  48. package/dist/cjs/_virtual/svg-tag.js +0 -1
  49. package/dist/cjs/_virtual/utils.js +0 -1
  50. package/dist/cjs/_virtual/utils2.js +0 -1
  51. package/dist/cjs/_virtual/version-check.js +0 -1
  52. package/dist/cjs/_virtual/version.js +0 -1
  53. package/dist/cjs/node_modules/.pnpm/3d-force-graph@1.78.3/node_modules/3d-force-graph/dist/3d-force-graph.js +0 -28
  54. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js +0 -1
  55. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/construct.js +0 -1
  56. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/extends.js +0 -1
  57. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js +0 -1
  58. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +0 -1
  59. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/isNativeFunction.js +0 -1
  60. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js +0 -1
  61. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +0 -1
  62. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js +0 -1
  63. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/_virtual/_rollupPluginBabelHelpers.js +0 -2
  64. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/config/index.js +0 -1
  65. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/loader/index.js +0 -1
  66. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/compose.js +0 -1
  67. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/curry.js +0 -1
  68. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/deepMerge.js +0 -1
  69. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/isObject.js +0 -1
  70. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/makeCancelable.js +0 -1
  71. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/validators/index.js +0 -10
  72. package/dist/cjs/node_modules/.pnpm/@monaco-editor_react@4.7.0_monaco-editor@0.52.2_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/@monaco-editor/react/dist/index.js +0 -1
  73. package/dist/cjs/node_modules/.pnpm/@tweenjs_tween.js@25.0.0/node_modules/@tweenjs/tween.js/dist/tween.esm.js +0 -1
  74. package/dist/cjs/node_modules/.pnpm/accessor-fn@1.5.3/node_modules/accessor-fn/dist/accessor-fn.js +0 -1
  75. package/dist/cjs/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/bowser.js +0 -6
  76. package/dist/cjs/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/constants.js +0 -1
  77. package/dist/cjs/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser-browsers.js +0 -1
  78. package/dist/cjs/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser-engines.js +0 -1
  79. package/dist/cjs/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser-os.js +0 -1
  80. package/dist/cjs/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser-platforms.js +0 -1
  81. package/dist/cjs/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser.js +0 -1
  82. package/dist/cjs/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/utils.js +0 -1
  83. package/dist/cjs/node_modules/.pnpm/canvas-confetti@1.9.3/node_modules/canvas-confetti/dist/confetti.module.js +0 -2
  84. package/dist/cjs/node_modules/.pnpm/d3-array@3.2.4/node_modules/d3-array/src/max.js +0 -1
  85. package/dist/cjs/node_modules/.pnpm/d3-array@3.2.4/node_modules/d3-array/src/min.js +0 -1
  86. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/add.js +0 -1
  87. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/binarytree.js +0 -1
  88. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/cover.js +0 -1
  89. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/data.js +0 -1
  90. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/extent.js +0 -1
  91. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/find.js +0 -1
  92. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/half.js +0 -1
  93. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/remove.js +0 -1
  94. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/root.js +0 -1
  95. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/size.js +0 -1
  96. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/visit.js +0 -1
  97. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/visitAfter.js +0 -1
  98. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/x.js +0 -1
  99. package/dist/cjs/node_modules/.pnpm/d3-dispatch@3.0.1/node_modules/d3-dispatch/src/dispatch.js +0 -1
  100. package/dist/cjs/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/center.js +0 -1
  101. package/dist/cjs/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/constant.js +0 -1
  102. package/dist/cjs/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/jiggle.js +0 -1
  103. package/dist/cjs/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/lcg.js +0 -1
  104. package/dist/cjs/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/link.js +0 -1
  105. package/dist/cjs/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/manyBody.js +0 -1
  106. package/dist/cjs/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/radial.js +0 -1
  107. package/dist/cjs/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/simulation.js +0 -1
  108. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/add.js +0 -1
  109. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/cover.js +0 -1
  110. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/data.js +0 -1
  111. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/extent.js +0 -1
  112. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/find.js +0 -1
  113. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/findAll.js +0 -1
  114. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/octant.js +0 -1
  115. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/octree.js +0 -1
  116. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/remove.js +0 -1
  117. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/root.js +0 -1
  118. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/size.js +0 -1
  119. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/visit.js +0 -1
  120. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/visitAfter.js +0 -1
  121. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/x.js +0 -1
  122. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/y.js +0 -1
  123. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/z.js +0 -1
  124. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/add.js +0 -1
  125. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/cover.js +0 -1
  126. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/data.js +0 -1
  127. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/extent.js +0 -1
  128. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/find.js +0 -1
  129. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/quad.js +0 -1
  130. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/quadtree.js +0 -1
  131. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/remove.js +0 -1
  132. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/root.js +0 -1
  133. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/size.js +0 -1
  134. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/visit.js +0 -1
  135. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/visitAfter.js +0 -1
  136. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/x.js +0 -1
  137. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/y.js +0 -1
  138. package/dist/cjs/node_modules/.pnpm/d3-scale-chromatic@3.1.0/node_modules/d3-scale-chromatic/src/categorical/Paired.js +0 -1
  139. package/dist/cjs/node_modules/.pnpm/d3-scale-chromatic@3.1.0/node_modules/d3-scale-chromatic/src/colors.js +0 -1
  140. package/dist/cjs/node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/init.js +0 -1
  141. package/dist/cjs/node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/ordinal.js +0 -1
  142. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/array.js +0 -1
  143. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/constant.js +0 -1
  144. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/creator.js +0 -1
  145. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/matcher.js +0 -1
  146. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/namespace.js +0 -1
  147. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/namespaces.js +0 -1
  148. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/pointer.js +0 -1
  149. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/select.js +0 -1
  150. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/append.js +0 -1
  151. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/attr.js +0 -1
  152. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/call.js +0 -1
  153. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/classed.js +0 -1
  154. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/clone.js +0 -1
  155. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/data.js +0 -1
  156. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/datum.js +0 -1
  157. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/dispatch.js +0 -1
  158. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/each.js +0 -1
  159. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/empty.js +0 -1
  160. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/enter.js +0 -1
  161. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/exit.js +0 -1
  162. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/filter.js +0 -1
  163. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/html.js +0 -1
  164. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/index.js +0 -1
  165. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/insert.js +0 -1
  166. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/iterator.js +0 -1
  167. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/join.js +0 -1
  168. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/lower.js +0 -1
  169. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/merge.js +0 -1
  170. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/node.js +0 -1
  171. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/nodes.js +0 -1
  172. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/on.js +0 -1
  173. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/order.js +0 -1
  174. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/property.js +0 -1
  175. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/raise.js +0 -1
  176. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/remove.js +0 -1
  177. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/select.js +0 -1
  178. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/selectAll.js +0 -1
  179. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/selectChild.js +0 -1
  180. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/selectChildren.js +0 -1
  181. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/size.js +0 -1
  182. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/sort.js +0 -1
  183. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/sparse.js +0 -1
  184. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/style.js +0 -1
  185. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/text.js +0 -1
  186. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selector.js +0 -1
  187. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selectorAll.js +0 -1
  188. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/sourceEvent.js +0 -1
  189. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/window.js +0 -1
  190. package/dist/cjs/node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/timer.js +0 -1
  191. package/dist/cjs/node_modules/.pnpm/data-bind-mapper@1.0.3/node_modules/data-bind-mapper/dist/data-bind-mapper.js +0 -3
  192. package/dist/cjs/node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js +0 -1
  193. package/dist/cjs/node_modules/.pnpm/float-tooltip@1.7.5/node_modules/float-tooltip/dist/float-tooltip.js +0 -13
  194. package/dist/cjs/node_modules/.pnpm/internmap@2.0.3/node_modules/internmap/src/index.js +0 -1
  195. package/dist/cjs/node_modules/.pnpm/jerrypick@1.1.2/node_modules/jerrypick/dist/jerrypick.js +0 -3
  196. package/dist/cjs/node_modules/.pnpm/kapsule@1.16.3/node_modules/kapsule/dist/kapsule.js +0 -2
  197. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.js +0 -1
  198. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.js +0 -1
  199. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseTrim.js +0 -1
  200. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js +0 -1
  201. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.js +0 -1
  202. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.js +0 -1
  203. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.js +0 -1
  204. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_trimmedEndIndex.js +0 -1
  205. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/debounce.js +0 -1
  206. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.js +0 -1
  207. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObjectLike.js +0 -1
  208. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isSymbol.js +0 -1
  209. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/now.js +0 -1
  210. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/toNumber.js +0 -1
  211. package/dist/cjs/node_modules/.pnpm/lucide-react@0.525.0_react@19.1.0/node_modules/lucide-react/dist/esm/Icon.js +0 -6
  212. package/dist/cjs/node_modules/.pnpm/lucide-react@0.525.0_react@19.1.0/node_modules/lucide-react/dist/esm/createLucideIcon.js +0 -6
  213. package/dist/cjs/node_modules/.pnpm/lucide-react@0.525.0_react@19.1.0/node_modules/lucide-react/dist/esm/defaultAttributes.js +0 -6
  214. package/dist/cjs/node_modules/.pnpm/lucide-react@0.525.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/play.js +0 -6
  215. package/dist/cjs/node_modules/.pnpm/lucide-react@0.525.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/x.js +0 -6
  216. package/dist/cjs/node_modules/.pnpm/lucide-react@0.525.0_react@19.1.0/node_modules/lucide-react/dist/esm/shared/src/utils.js +0 -6
  217. package/dist/cjs/node_modules/.pnpm/ngraph.events@1.2.2/node_modules/ngraph.events/index.js +0 -1
  218. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/index.js +0 -1
  219. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/createPatternBuilder.js +0 -2
  220. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateBounds.js +0 -55
  221. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateCreateBody.js +0 -47
  222. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateCreateDragForce.js +0 -9
  223. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateCreateSpringForce.js +0 -33
  224. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateIntegrator.js +0 -35
  225. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateQuadTree.js +0 -325
  226. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/getVariableName.js +0 -1
  227. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/createPhysicsSimulator.js +0 -1
  228. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/spring.js +0 -1
  229. package/dist/cjs/node_modules/.pnpm/ngraph.graph@20.0.1/node_modules/ngraph.graph/index.js +0 -3
  230. package/dist/cjs/node_modules/.pnpm/ngraph.merge@1.0.0/node_modules/ngraph.merge/index.js +0 -1
  231. package/dist/cjs/node_modules/.pnpm/ngraph.random@1.2.0/node_modules/ngraph.random/index.js +0 -1
  232. package/dist/cjs/node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js +0 -5
  233. package/dist/cjs/node_modules/.pnpm/polished@4.3.1/node_modules/polished/dist/polished.esm.js +0 -149
  234. package/dist/cjs/node_modules/.pnpm/preact@10.26.9/node_modules/preact/dist/preact.module.js +0 -1
  235. package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/checkPropTypes.js +0 -1
  236. package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithThrowingShims.js +0 -1
  237. package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithTypeCheckers.js +0 -2
  238. package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +0 -1
  239. package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js +0 -1
  240. package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/has.js +0 -1
  241. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js +0 -1
  242. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js +0 -1
  243. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js +0 -1
  244. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js +0 -1
  245. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js +0 -1
  246. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js +0 -1
  247. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js +0 -1
  248. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js +0 -1
  249. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js +0 -1
  250. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js +0 -1
  251. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js +0 -1
  252. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js +0 -1
  253. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js +0 -2
  254. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js +0 -1
  255. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js +0 -1
  256. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js +0 -1
  257. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js +0 -1
  258. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js +0 -4
  259. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js +0 -1
  260. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js +0 -2
  261. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js +0 -2
  262. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js +0 -1
  263. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js +0 -1
  264. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js +0 -1
  265. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js +0 -1
  266. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js +0 -2
  267. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js +0 -1
  268. package/dist/cjs/node_modules/.pnpm/react-force-graph-3d@1.28.0_react@19.1.0/node_modules/react-force-graph-3d/dist/react-force-graph-3d.js +0 -1
  269. package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js +0 -8
  270. package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.production.min.js +0 -8
  271. package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js +0 -1
  272. package/dist/cjs/node_modules/.pnpm/react-kapsule@2.5.7_react@19.1.0/node_modules/react-kapsule/dist/react-kapsule.js +0 -3
  273. package/dist/cjs/node_modules/.pnpm/state-local@1.0.7/node_modules/state-local/lib/es/state-local.js +0 -1
  274. package/dist/cjs/node_modules/.pnpm/three-forcegraph@1.43.0_three@0.178.0/node_modules/three-forcegraph/dist/three-forcegraph.js +0 -3
  275. package/dist/cjs/node_modules/.pnpm/three-render-objects@1.40.4_three@0.178.0/node_modules/three-render-objects/dist/three-render-objects.js +0 -18
  276. package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/build/three.core.js +0 -44
  277. package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/build/three.module.js +0 -3784
  278. package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/build/three.webgpu.js +0 -392
  279. package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/controls/DragControls.js +0 -1
  280. package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/controls/FlyControls.js +0 -1
  281. package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/controls/OrbitControls.js +0 -1
  282. package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/controls/TrackballControls.js +0 -1
  283. package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/postprocessing/EffectComposer.js +0 -1
  284. package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/postprocessing/MaskPass.js +0 -1
  285. package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/postprocessing/Pass.js +0 -1
  286. package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/postprocessing/RenderPass.js +0 -1
  287. package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/postprocessing/ShaderPass.js +0 -1
  288. package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/shaders/CopyShader.js +0 -24
  289. package/dist/cjs/node_modules/.pnpm/tinycolor2@1.6.0/node_modules/tinycolor2/esm/tinycolor.js +0 -1
  290. package/dist/es/_virtual/_commonjsHelpers.js +0 -6
  291. package/dist/es/_virtual/alignment-pattern.js +0 -4
  292. package/dist/es/_virtual/browser.js +0 -7
  293. package/dist/es/_virtual/browser2.js +0 -4
  294. package/dist/es/_virtual/canvas.js +0 -4
  295. package/dist/es/_virtual/dijkstra.js +0 -4
  296. package/dist/es/_virtual/error-correction-code.js +0 -4
  297. package/dist/es/_virtual/error-correction-level.js +0 -4
  298. package/dist/es/_virtual/finder-pattern.js +0 -4
  299. package/dist/es/_virtual/format-info.js +0 -4
  300. package/dist/es/_virtual/galois-field.js +0 -4
  301. package/dist/es/_virtual/generateBounds.js +0 -4
  302. package/dist/es/_virtual/generateCreateBody.js +0 -4
  303. package/dist/es/_virtual/generateCreateDragForce.js +0 -4
  304. package/dist/es/_virtual/generateCreateSpringForce.js +0 -4
  305. package/dist/es/_virtual/generateIntegrator.js +0 -4
  306. package/dist/es/_virtual/generateQuadTree.js +0 -4
  307. package/dist/es/_virtual/index.js +0 -7
  308. package/dist/es/_virtual/index2.js +0 -4
  309. package/dist/es/_virtual/index3.js +0 -4
  310. package/dist/es/_virtual/index4.js +0 -7
  311. package/dist/es/_virtual/index5.js +0 -7
  312. package/dist/es/_virtual/index6.js +0 -4
  313. package/dist/es/_virtual/index7.js +0 -4
  314. package/dist/es/_virtual/mask-pattern.js +0 -4
  315. package/dist/es/_virtual/mode.js +0 -4
  316. package/dist/es/_virtual/polynomial.js +0 -4
  317. package/dist/es/_virtual/qrcode.js +0 -4
  318. package/dist/es/_virtual/react-is.development.js +0 -4
  319. package/dist/es/_virtual/react-is.production.min.js +0 -4
  320. package/dist/es/_virtual/regex.js +0 -4
  321. package/dist/es/_virtual/segments.js +0 -4
  322. package/dist/es/_virtual/svg-tag.js +0 -4
  323. package/dist/es/_virtual/utils.js +0 -4
  324. package/dist/es/_virtual/utils2.js +0 -4
  325. package/dist/es/_virtual/version-check.js +0 -4
  326. package/dist/es/_virtual/version.js +0 -4
  327. package/dist/es/node_modules/.pnpm/3d-force-graph@1.78.3/node_modules/3d-force-graph/dist/3d-force-graph.js +0 -398
  328. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js +0 -7
  329. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/construct.js +0 -12
  330. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/extends.js +0 -12
  331. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js +0 -8
  332. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +0 -7
  333. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/isNativeFunction.js +0 -10
  334. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js +0 -13
  335. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +0 -8
  336. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js +0 -29
  337. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/_virtual/_rollupPluginBabelHelpers.js +0 -99
  338. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/config/index.js +0 -8
  339. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/loader/index.js +0 -101
  340. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/compose.js +0 -12
  341. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/curry.js +0 -14
  342. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/deepMerge.js +0 -9
  343. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/isObject.js +0 -6
  344. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/makeCancelable.js +0 -18
  345. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/validators/index.js +0 -37
  346. package/dist/es/node_modules/.pnpm/@monaco-editor_react@4.7.0_monaco-editor@0.52.2_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/@monaco-editor/react/dist/index.js +0 -154
  347. package/dist/es/node_modules/.pnpm/@tweenjs_tween.js@25.0.0/node_modules/@tweenjs/tween.js/dist/tween.esm.js +0 -396
  348. package/dist/es/node_modules/.pnpm/accessor-fn@1.5.3/node_modules/accessor-fn/dist/accessor-fn.js +0 -10
  349. package/dist/es/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/bowser.js +0 -55
  350. package/dist/es/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/constants.js +0 -113
  351. package/dist/es/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser-browsers.js +0 -404
  352. package/dist/es/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser-engines.js +0 -78
  353. package/dist/es/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser-os.js +0 -159
  354. package/dist/es/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser-platforms.js +0 -238
  355. package/dist/es/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser.js +0 -303
  356. package/dist/es/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/utils.js +0 -280
  357. package/dist/es/node_modules/.pnpm/canvas-confetti@1.9.3/node_modules/canvas-confetti/dist/confetti.module.js +0 -409
  358. package/dist/es/node_modules/.pnpm/d3-array@3.2.4/node_modules/d3-array/src/max.js +0 -15
  359. package/dist/es/node_modules/.pnpm/d3-array@3.2.4/node_modules/d3-array/src/min.js +0 -15
  360. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/add.js +0 -32
  361. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/binarytree.js +0 -48
  362. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/cover.js +0 -22
  363. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/data.js +0 -11
  364. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/extent.js +0 -6
  365. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/find.js +0 -20
  366. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/half.js +0 -6
  367. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/remove.js +0 -20
  368. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/root.js +0 -6
  369. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/size.js +0 -11
  370. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/visit.js +0 -13
  371. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/visitAfter.js +0 -18
  372. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/x.js +0 -10
  373. package/dist/es/node_modules/.pnpm/d3-dispatch@3.0.1/node_modules/d3-dispatch/src/dispatch.js +0 -64
  374. package/dist/es/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/center.js +0 -25
  375. package/dist/es/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/constant.js +0 -8
  376. package/dist/es/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/jiggle.js +0 -6
  377. package/dist/es/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/lcg.js +0 -7
  378. package/dist/es/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/link.js +0 -58
  379. package/dist/es/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/manyBody.js +0 -58
  380. package/dist/es/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/radial.js +0 -34
  381. package/dist/es/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/simulation.js +0 -95
  382. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/add.js +0 -32
  383. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/cover.js +0 -40
  384. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/data.js +0 -11
  385. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/extent.js +0 -6
  386. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/find.js +0 -29
  387. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/findAll.js +0 -15
  388. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/octant.js +0 -6
  389. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/octree.js +0 -54
  390. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/remove.js +0 -20
  391. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/root.js +0 -6
  392. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/size.js +0 -11
  393. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/visit.js +0 -13
  394. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/visitAfter.js +0 -18
  395. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/x.js +0 -10
  396. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/y.js +0 -10
  397. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/z.js +0 -10
  398. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/add.js +0 -29
  399. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/cover.js +0 -28
  400. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/data.js +0 -11
  401. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/extent.js +0 -6
  402. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/find.js +0 -25
  403. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/quad.js +0 -6
  404. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/quadtree.js +0 -50
  405. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/remove.js +0 -20
  406. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/root.js +0 -6
  407. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/size.js +0 -11
  408. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/visit.js +0 -13
  409. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/visitAfter.js +0 -18
  410. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/x.js +0 -10
  411. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/y.js +0 -10
  412. package/dist/es/node_modules/.pnpm/d3-scale-chromatic@3.1.0/node_modules/d3-scale-chromatic/src/categorical/Paired.js +0 -5
  413. package/dist/es/node_modules/.pnpm/d3-scale-chromatic@3.1.0/node_modules/d3-scale-chromatic/src/colors.js +0 -7
  414. package/dist/es/node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/init.js +0 -16
  415. package/dist/es/node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/ordinal.js +0 -31
  416. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/array.js +0 -6
  417. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/constant.js +0 -8
  418. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/creator.js +0 -20
  419. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/matcher.js +0 -14
  420. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/namespace.js +0 -8
  421. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/namespaces.js +0 -12
  422. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/pointer.js +0 -18
  423. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/select.js +0 -7
  424. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/append.js +0 -10
  425. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/attr.js +0 -44
  426. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/call.js +0 -7
  427. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/classed.js +0 -54
  428. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/clone.js +0 -14
  429. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/data.js +0 -42
  430. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/datum.js +0 -6
  431. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/dispatch.js +0 -21
  432. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/each.js +0 -9
  433. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/empty.js +0 -6
  434. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/enter.js +0 -27
  435. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/exit.js +0 -8
  436. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/filter.js +0 -12
  437. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/html.js +0 -20
  438. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/index.js +0 -83
  439. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/insert.js +0 -14
  440. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/iterator.js +0 -8
  441. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/join.js +0 -7
  442. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/lower.js +0 -9
  443. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/merge.js +0 -12
  444. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/node.js +0 -11
  445. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/nodes.js +0 -6
  446. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/on.js +0 -52
  447. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/order.js +0 -9
  448. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/property.js +0 -22
  449. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/raise.js +0 -9
  450. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/remove.js +0 -10
  451. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/select.js +0 -12
  452. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/selectAll.js +0 -18
  453. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/selectChild.js +0 -16
  454. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/selectChildren.js +0 -16
  455. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/size.js +0 -8
  456. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/sort.js +0 -19
  457. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/sparse.js +0 -6
  458. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/style.js +0 -27
  459. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/text.js +0 -20
  460. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selector.js +0 -10
  461. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selectorAll.js +0 -11
  462. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/sourceEvent.js +0 -8
  463. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/window.js +0 -6
  464. package/dist/es/node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/timer.js +0 -62
  465. package/dist/es/node_modules/.pnpm/data-bind-mapper@1.0.3/node_modules/data-bind-mapper/dist/data-bind-mapper.js +0 -173
  466. package/dist/es/node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js +0 -72
  467. package/dist/es/node_modules/.pnpm/float-tooltip@1.7.5/node_modules/float-tooltip/dist/float-tooltip.js +0 -169
  468. package/dist/es/node_modules/.pnpm/internmap@2.0.3/node_modules/internmap/src/index.js +0 -35
  469. package/dist/es/node_modules/.pnpm/jerrypick@1.1.2/node_modules/jerrypick/dist/jerrypick.js +0 -92
  470. package/dist/es/node_modules/.pnpm/kapsule@1.16.3/node_modules/kapsule/dist/kapsule.js +0 -113
  471. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.js +0 -5
  472. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.js +0 -10
  473. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseTrim.js +0 -8
  474. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js +0 -4
  475. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.js +0 -15
  476. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.js +0 -7
  477. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.js +0 -5
  478. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_trimmedEndIndex.js +0 -9
  479. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/debounce.js +0 -54
  480. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.js +0 -7
  481. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObjectLike.js +0 -6
  482. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isSymbol.js +0 -9
  483. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/now.js +0 -7
  484. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/toNumber.js +0 -22
  485. package/dist/es/node_modules/.pnpm/lucide-react@0.525.0_react@19.1.0/node_modules/lucide-react/dist/esm/Icon.js +0 -41
  486. package/dist/es/node_modules/.pnpm/lucide-react@0.525.0_react@19.1.0/node_modules/lucide-react/dist/esm/createLucideIcon.js +0 -27
  487. package/dist/es/node_modules/.pnpm/lucide-react@0.525.0_react@19.1.0/node_modules/lucide-react/dist/esm/defaultAttributes.js +0 -20
  488. package/dist/es/node_modules/.pnpm/lucide-react@0.525.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/play.js +0 -12
  489. package/dist/es/node_modules/.pnpm/lucide-react@0.525.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/x.js +0 -15
  490. package/dist/es/node_modules/.pnpm/lucide-react@0.525.0_react@19.1.0/node_modules/lucide-react/dist/esm/shared/src/utils.js +0 -24
  491. package/dist/es/node_modules/.pnpm/ngraph.events@1.2.2/node_modules/ngraph.events/index.js +0 -57
  492. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/index.js +0 -239
  493. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/createPatternBuilder.js +0 -22
  494. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateBounds.js +0 -74
  495. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateCreateBody.js +0 -74
  496. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateCreateDragForce.js +0 -28
  497. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateCreateSpringForce.js +0 -53
  498. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateIntegrator.js +0 -55
  499. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateQuadTree.js +0 -403
  500. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/getVariableName.js +0 -9
  501. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/createPhysicsSimulator.js +0 -273
  502. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/spring.js +0 -12
  503. package/dist/es/node_modules/.pnpm/ngraph.graph@20.0.1/node_modules/ngraph.graph/index.js +0 -319
  504. package/dist/es/node_modules/.pnpm/ngraph.merge@1.0.0/node_modules/ngraph.merge/index.js +0 -20
  505. package/dist/es/node_modules/.pnpm/ngraph.random@1.2.0/node_modules/ngraph.random/index.js +0 -71
  506. package/dist/es/node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js +0 -54
  507. package/dist/es/node_modules/.pnpm/polished@4.3.1/node_modules/polished/dist/polished.esm.js +0 -717
  508. package/dist/es/node_modules/.pnpm/preact@10.26.9/node_modules/preact/dist/preact.module.js +0 -257
  509. package/dist/es/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/checkPropTypes.js +0 -54
  510. package/dist/es/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithThrowingShims.js +0 -52
  511. package/dist/es/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithTypeCheckers.js +0 -329
  512. package/dist/es/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +0 -17
  513. package/dist/es/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js +0 -10
  514. package/dist/es/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/has.js +0 -7
  515. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js +0 -44
  516. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js +0 -9
  517. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js +0 -26
  518. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js +0 -73
  519. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js +0 -28
  520. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js +0 -23
  521. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js +0 -23
  522. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js +0 -362
  523. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js +0 -41
  524. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js +0 -22
  525. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js +0 -18
  526. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js +0 -24
  527. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js +0 -36
  528. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js +0 -102
  529. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js +0 -68
  530. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js +0 -26
  531. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js +0 -34
  532. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js +0 -154
  533. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js +0 -27
  534. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js +0 -23
  535. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js +0 -146
  536. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js +0 -74
  537. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js +0 -10
  538. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js +0 -75
  539. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js +0 -32
  540. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js +0 -32
  541. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js +0 -58
  542. package/dist/es/node_modules/.pnpm/react-force-graph-3d@1.28.0_react@19.1.0/node_modules/react-force-graph-3d/dist/react-force-graph-3d.js +0 -148
  543. package/dist/es/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js +0 -95
  544. package/dist/es/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.production.min.js +0 -78
  545. package/dist/es/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js +0 -10
  546. package/dist/es/node_modules/.pnpm/react-kapsule@2.5.7_react@19.1.0/node_modules/react-kapsule/dist/react-kapsule.js +0 -113
  547. package/dist/es/node_modules/.pnpm/state-local@1.0.7/node_modules/state-local/lib/es/state-local.js +0 -131
  548. package/dist/es/node_modules/.pnpm/three-forcegraph@1.43.0_three@0.178.0/node_modules/three-forcegraph/dist/three-forcegraph.js +0 -1037
  549. package/dist/es/node_modules/.pnpm/three-render-objects@1.40.4_three@0.178.0/node_modules/three-render-objects/dist/three-render-objects.js +0 -453
  550. package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/build/three.core.js +0 -13236
  551. package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/build/three.module.js +0 -9725
  552. package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/build/three.webgpu.js +0 -24475
  553. package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/controls/DragControls.js +0 -116
  554. package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/controls/FlyControls.js +0 -188
  555. package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/controls/OrbitControls.js +0 -459
  556. package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/controls/TrackballControls.js +0 -223
  557. package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/postprocessing/EffectComposer.js +0 -139
  558. package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/postprocessing/MaskPass.js +0 -55
  559. package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/postprocessing/Pass.js +0 -89
  560. package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/postprocessing/RenderPass.js +0 -38
  561. package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/postprocessing/ShaderPass.js +0 -46
  562. package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/shaders/CopyShader.js +0 -41
  563. package/dist/es/node_modules/.pnpm/tinycolor2@1.6.0/node_modules/tinycolor2/esm/tinycolor.js +0 -711
@@ -1,392 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./three.core.js");/**
2
- * @license
3
- * Copyright 2010-2025 Three.js Authors
4
- * SPDX-License-Identifier: MIT
5
- */const Zl=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class Zo{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=Zl,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){const t=e.getMRT();return t!==null&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){const{geometry:s,material:r,object:n}=e;if(t={material:this.getMaterialData(r),geometry:{id:s.id,attributes:this.getAttributesData(s.attributes),indexVersion:s.index?s.index.version:null,drawRange:{start:s.drawRange.start,count:s.drawRange.count}},worldMatrix:n.matrixWorld.clone()},n.center&&(t.center=n.center.clone()),n.morphTargetInfluences&&(t.morphTargetInfluences=n.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){const{width:i,height:u}=e.context;t.bufferWidth=i,t.bufferHeight=u}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const s in e){const r=e[s];t[s]={version:r.version}}return t}containsNode(e){const t=e.material;for(const s in t)if(t[s]&&t[s].isNode)return!0;return e.renderer.overrideNodes.modelViewMatrix!==null||e.renderer.overrideNodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const s of this.refreshUniforms){const r=e[s];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[s]={id:r.id,version:r.version}:t[s]=r.clone():t[s]=r)}return t}equals(e){const{object:t,material:s,geometry:r}=e,n=this.getRenderObjectData(e);if(n.worldMatrix.equals(t.matrixWorld)!==!0)return n.worldMatrix.copy(t.matrixWorld),!1;const i=n.material;for(const m in i){const y=i[m],_=s[m];if(y.equals!==void 0){if(y.equals(_)===!1)return y.copy(_),!1}else if(_.isTexture===!0){if(y.id!==_.id||y.version!==_.version)return y.id=_.id,y.version=_.version,!1}else if(y!==_)return i[m]=_,!1}if(i.transmission>0){const{width:m,height:y}=e.context;if(n.bufferWidth!==m||n.bufferHeight!==y)return n.bufferWidth=m,n.bufferHeight=y,!1}const u=n.geometry,a=r.attributes,c=u.attributes,d=Object.keys(c),h=Object.keys(a);if(u.id!==r.id)return u.id=r.id,!1;if(d.length!==h.length)return n.geometry.attributes=this.getAttributesData(a),!1;for(const m of d){const y=c[m],_=a[m];if(_===void 0)return delete c[m],!1;if(y.version!==_.version)return y.version=_.version,!1}const p=r.index,f=u.indexVersion,g=p?p.version:null;if(f!==g)return u.indexVersion=g,!1;if(u.drawRange.start!==r.drawRange.start||u.drawRange.count!==r.drawRange.count)return u.drawRange.start=r.drawRange.start,u.drawRange.count=r.drawRange.count,!1;if(n.morphTargetInfluences){let m=!1;for(let y=0;y<n.morphTargetInfluences.length;y++)n.morphTargetInfluences[y]!==t.morphTargetInfluences[y]&&(m=!0);if(m)return!0}return n.center&&n.center.equals(t.center)===!1?(n.center.copy(t.center),!0):(e.bundle!==null&&(n.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;const{renderId:s}=t;if(this.renderId!==s)return this.renderId=s,!0;const r=e.object.static===!0,n=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;return r||n?!1:this.equals(e)!==!0}}function Cs(o,e=0){let t=3735928559^e,s=1103547991^e;if(o instanceof Array)for(let r=0,n;r<o.length;r++)n=o[r],t=Math.imul(t^n,2654435761),s=Math.imul(s^n,1597334677);else for(let r=0,n;r<o.length;r++)n=o.charCodeAt(r),t=Math.imul(t^n,2654435761),s=Math.imul(s^n,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&s)+(t>>>0)}const Jl=o=>Cs(o),Dn=o=>Cs(o),rr=(...o)=>Cs(o);function Jo(o,e=!1){const t=[];o.isNode===!0&&(t.push(o.id),o=o.getSelf());for(const{property:s,childNode:r}of nr(o))t.push(Cs(s.slice(0,-4)),r.getCacheKey(e));return Cs(t)}function*nr(o,e=!1){for(const t in o){if(t.startsWith("_")===!0)continue;const s=o[t];if(Array.isArray(s)===!0)for(let r=0;r<s.length;r++){const n=s[r];n&&(n.isNode===!0||e&&typeof n.toJSON=="function")&&(yield{property:t,index:r,childNode:n})}else if(s&&s.isNode===!0)yield{property:t,childNode:s};else if(typeof s=="object")for(const r in s){const n=s[r];n&&(n.isNode===!0||e&&typeof n.toJSON=="function")&&(yield{property:t,index:r,childNode:n})}}}const ec=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Ri=new WeakMap;function tc(o){return ec.get(o)}function ir(o){if(o==null)return null;const e=typeof o;return o.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":o.isVector2===!0?"vec2":o.isVector3===!0?"vec3":o.isVector4===!0?"vec4":o.isMatrix2===!0?"mat2":o.isMatrix3===!0?"mat3":o.isMatrix4===!0?"mat4":o.isColor===!0?"color":o instanceof ArrayBuffer?"ArrayBuffer":null}function ea(o,...e){const t=o?o.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),o==="color"?new l.Color(...e):t==="vec2"?new l.Vector2(...e):t==="vec3"?new l.Vector3(...e):t==="vec4"?new l.Vector4(...e):t==="mat2"?new l.Matrix2(...e):t==="mat3"?new l.Matrix3(...e):t==="mat4"?new l.Matrix4(...e):o==="bool"?e[0]||!1:o==="float"||o==="int"||o==="uint"?e[0]||0:o==="string"?e[0]||"":o==="ArrayBuffer"?rc(e[0]):null}function ta(o){let e=Ri.get(o);return e===void 0&&(e={},Ri.set(o,e)),e}function sc(o){let e="";const t=new Uint8Array(o);for(let s=0;s<t.length;s++)e+=String.fromCharCode(t[s]);return btoa(e)}function rc(o){return Uint8Array.from(atob(o),e=>e.charCodeAt(0)).buffer}const fs={VERTEX:"vertex"},z={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},He={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},sa=["fragment","vertex"],pn=["setup","analyze","generate"],fn=[...sa,"compute"],Bt=["x","y","z","w"],nc={analyze:"setup",generate:"analyze"};let ic=0;class V extends l.EventDispatcher{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=z.NONE,this.updateBeforeType=z.NONE,this.updateAfterType=z.NONE,this.uuid=l.MathUtils.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:ic++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,z.FRAME)}onRenderUpdate(e){return this.onUpdate(e,z.RENDER)}onObjectUpdate(e){return this.onUpdate(e,z.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of nr(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=rr(Jo(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let s=0;for(const r of this.getChildren())t["node"+s++]=r;return t.outputNode||null}analyze(e,t=null){const s=e.increaseUsage(this);if(this.parents===!0){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(s===1){const r=e.getNodeProperties(this);for(const n of Object.values(r))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){const{outputNode:s}=e.getNodeProperties(this);if(s&&s.isNode===!0)return s.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const s=this.getShared(e);if(this!==s)return s.build(e,t);const r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;const n=nc[e.buildStage];if(n&&r.buildStages[n]!==!0){const a=e.getBuildStage();e.setBuildStage(n),this.build(e),e.setBuildStage(a)}e.addNode(this),e.addChain(this);let i=null;const u=e.getBuildStage();if(u==="setup"){this.updateReference(e);const a=e.getNodeProperties(this);if(a.initialized!==!0){a.initialized=!0,a.outputNode=this.setup(e)||a.outputNode||null;for(const c of Object.values(a))if(c&&c.isNode===!0){if(c.parents===!0){const d=e.getNodeProperties(c);d.parents=d.parents||[],d.parents.push(this)}c.build(e)}}i=a.outputNode}else if(u==="analyze")this.analyze(e,t);else if(u==="generate")if(this.generate.length===1){const c=this.getNodeType(e),d=e.getDataFromNode(this);i=d.snippet,i===void 0?d.generated===void 0?(d.generated=!0,i=this.generate(e)||"",d.snippet=i):(console.warn("THREE.Node: Recursion detected.",this),i="/* Recursion detected. */"):d.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),i=e.format(i,c,t)}else i=this.generate(e,t)||"";return e.removeChain(this),e.addSequentialNode(this),i}getSerializeChildren(){return nr(this)}serialize(e){const t=this.getSerializeChildren(),s={};for(const{property:r,index:n,childNode:i}of t)n!==void 0?(s[r]===void 0&&(s[r]=Number.isInteger(n)?[]:{}),s[r][n]=i.toJSON(e.meta).uuid):s[r]=i.toJSON(e.meta).uuid;Object.keys(s).length>0&&(e.inputNodes=s)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const s in e.inputNodes)if(Array.isArray(e.inputNodes[s])){const r=[];for(const n of e.inputNodes[s])r.push(t[n]);this[s]=r}else if(typeof e.inputNodes[s]=="object"){const r={};for(const n in e.inputNodes[s]){const i=e.inputNodes[s][n];r[n]=t[i]}this[s]=r}else{const r=e.inputNodes[s];this[s]=t[r]}}}toJSON(e){const{uuid:t,type:s}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let n=e.nodes[t];n===void 0&&(n={uuid:t,type:s,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[n.uuid]=n),this.serialize(n),delete n.meta);function i(u){const a=[];for(const c in u){const d=u[c];delete d.metadata,a.push(d)}return a}if(r){const u=i(e.textures),a=i(e.images),c=i(e.nodes);u.length>0&&(n.textures=u),a.length>0&&(n.images=a),c.length>0&&(n.nodes=c)}return n}}class Zt extends V{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e),s=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${s}[ ${r} ]`}}class Ln extends V{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let s=null;for(const r of this.convertTo.split("|"))(s===null||e.getTypeLength(t)===e.getTypeLength(r))&&(s=r);return s}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const s=this.node,r=this.getNodeType(e),n=s.build(e,r);return e.format(n,r,t)}}class fe extends V{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const r=e.getVectorType(this.getNodeType(e,t)),n=e.getDataFromNode(this);if(n.propertyName!==void 0)return e.format(n.propertyName,r,t);if(r!=="void"&&t!=="void"&&this.hasDependencies(e)){const i=super.build(e,r),u=e.getVarFromNode(this,null,r),a=e.getPropertyName(u);return e.addLineFlowCode(`${a} = ${i}`,this),n.snippet=i,n.propertyName=a,e.format(n.propertyName,r,t)}}return super.build(e,t)}}class ra extends fe{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,s)=>t+e.getTypeLength(s.getNodeType(e)),0))}generate(e,t){const s=this.getNodeType(e),r=e.getTypeLength(s),n=this.nodes,i=e.getComponentType(s),u=[];let a=0;for(const d of n){if(a>=r){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${s}()' type.`);break}let h=d.getNodeType(e),p=e.getTypeLength(h),f;a+p>r&&(console.error(`THREE.TSL: Length of '${s}()' data exceeds maximum length of output type.`),p=r-a,h=e.getTypeFromLength(p)),a+=p,f=d.build(e,h);const g=e.getComponentType(h);g!==i&&(f=e.format(f,g,i)),u.push(f)}const c=`${e.getType(s)}( ${u.join(", ")} )`;return e.format(c,s,t)}}const oc=Bt.join("");class gn extends V{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(Bt.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const s=this.node,r=e.getTypeLength(s.getNodeType(e));let n=null;if(r>1){let i=null;this.getVectorLength()>=r&&(i=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const a=s.build(e,i);this.components.length===r&&this.components===oc.slice(0,this.components.length)?n=e.format(a,i,t):n=e.format(`${a}.${this.components}`,this.getNodeType(e),t)}else n=s.build(e,t);return n}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class na extends fe{static get type(){return"SetNode"}constructor(e,t,s){super(),this.sourceNode=e,this.components=t,this.targetNode=s}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:s,targetNode:r}=this,n=this.getNodeType(e),i=e.getComponentType(r.getNodeType(e)),u=e.getTypeFromLength(s.length,i),a=r.build(e,u),c=t.build(e,n),d=e.getTypeLength(n),h=[];for(let p=0;p<d;p++){const f=Bt[p];f===s[0]?(h.push(a),p+=s.length-1):h.push(c+"."+f)}return`${e.getType(n)}( ${h.join(", ")} )`}}class ac extends fe{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:s}=this,r=this.getNodeType(e),n=s.build(e),i=e.getVarFromNode(this),u=e.getPropertyName(i);e.addLineFlowCode(u+" = "+n,this);const a=e.getTypeLength(r),c=[];let d=0;for(let h=0;h<a;h++){const p=Bt[h];p===t[d]?(c.push("1.0 - "+(u+"."+p)),d++):c.push(u+"."+p)}return`${e.getType(r)}( ${c.join(", ")} )`}}class Un extends V{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?ir(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=ir(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=sc(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?ea(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}}const Ai=/float|u?int/;class Ke extends Un{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const s=this.getNodeType(e);return Ai.test(s)&&Ai.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),s,t)}}class ia extends V{static get type(){return"MemberNode"}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){return this.node.build(e)+"."+this.property}}let Xt=null;const Gt=new Map;function N(o,e){if(Gt.has(o)){console.warn(`THREE.TSL: Redefinition of method chaining '${o}'.`);return}if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${o} is not a function`);Gt.set(o,e)}const oa=o=>o.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Ci=o=>oa(o).split("").sort().join(""),aa={setup(o,e){const t=e.shift();return o(gr(t),...e)},get(o,e,t){if(typeof e=="string"&&o[e]===void 0){if(o.isStackNode!==!0&&e==="assign")return(...s)=>(Xt.assign(t,...s),t);if(Gt.has(e)){const s=Gt.get(e);return o.isStackNode?(...r)=>t.add(s(...r)):(...r)=>s(t,...r)}else{if(e==="self")return o;if(e.endsWith("Assign")&&Gt.has(e.slice(0,e.length-6))){const s=Gt.get(e.slice(0,e.length-6));return o.isStackNode?(...r)=>t.assign(r[0],s(...r)):(...r)=>t.assign(s(t,...r))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=oa(e),E(new gn(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=Ci(e.slice(3).toLowerCase()),s=>E(new na(o,e,E(s)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=Ci(e.slice(4).toLowerCase()),()=>E(new ac(E(o),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),E(new gn(o,e));if(/^\d+$/.test(e)===!0)return E(new Zt(t,new Ke(Number(e),"uint")));if(/^get$/.test(e)===!0)return s=>E(new ia(t,s))}}}return Reflect.get(o,e,t)},set(o,e,t,s){return typeof e=="string"&&o[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(s[e].assign(t),!0):Reflect.set(o,e,t,s)}},Br=new WeakMap,vi=new WeakMap,uc=function(o,e=null){const t=ir(o);if(t==="node"){let s=Br.get(o);return s===void 0&&(s=new Proxy(o,aa),Br.set(o,s),Br.set(s,s)),s}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return E(mn(o,e));if(t==="shader")return o.isFn?o:v(o)}return o},lc=function(o,e=null){for(const t in o)o[t]=E(o[t],e);return o},cc=function(o,e=null){const t=o.length;for(let s=0;s<t;s++)o[s]=E(o[s],e);return o},dc=function(o,e=null,t=null,s=null){const r=d=>E(s!==null?Object.assign(d,s):d);let n,i=e,u,a;function c(d){let h;return i?h=/[a-z]/i.test(i)?i+"()":i:h=o.type,u!==void 0&&d.length<u?(console.error(`THREE.TSL: "${h}" parameter length is less than minimum required.`),d.concat(new Array(u-d.length).fill(0))):a!==void 0&&d.length>a?(console.error(`THREE.TSL: "${h}" parameter length exceeds limit.`),d.slice(0,a)):d}return e===null?n=(...d)=>r(new o(...zt(c(d)))):t!==null?(t=E(t),n=(...d)=>r(new o(e,...zt(c(d)),t))):n=(...d)=>r(new o(e,...zt(c(d)))),n.setParameterLength=(...d)=>(d.length===1?u=a=d[0]:d.length===2&&([u,a]=d),n),n.setName=d=>(i=d,n),n},hc=function(o,...e){return E(new o(...zt(e)))};class pc extends V{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,inputNodes:s}=this,r=e.getNodeProperties(t),n=e.getClosestSubBuild(t.subBuilds)||"",i=n||"default";if(r[i])return r[i];const u=e.subBuildFn;e.subBuildFn=n;let a=null;if(t.layout){let c=vi.get(e.constructor);c===void 0&&(c=new WeakMap,vi.set(e.constructor,c));let d=c.get(t);d===void 0&&(d=E(e.buildFunctionNode(t)),c.set(t,d)),e.addInclude(d),a=E(d.call(s))}else{const c=t.jsFunc,d=s!==null||c.length>1?c(s||[],e):c(e);a=E(d)}return e.subBuildFn=u,t.once&&(r[i]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),s=e.getSubBuildOutput(this);return t[s]=t[s]||this.setupOutput(e),t[s].subBuild=e.getClosestSubBuild(this),t[s]}build(e,t=null){let s=null;const r=e.getBuildStage(),n=e.getNodeProperties(this),i=e.getSubBuildOutput(this),u=this.getOutputNode(e);if(r==="setup"){const a=e.getSubBuildProperty("initialized",this);if(n[a]!==!0&&(n[a]=!0,n[i]=this.getOutputNode(e),n[i].build(e),this.shaderNode.subBuilds))for(const c of e.chaining){const d=e.getDataFromNode(c,"any");d.subBuilds=d.subBuilds||new Set;for(const h of this.shaderNode.subBuilds)d.subBuilds.add(h)}s=n[i]}else r==="analyze"?u.build(e,t):r==="generate"&&(s=u.build(e,t)||"");return s}}class fc extends V{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return gr(e),E(new pc(this,e))}setup(){return this.call()}}const gc=[!1,!0],mc=[0,1,2,3],Tc=[-1,-2],ua=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],Gn=new Map;for(const o of gc)Gn.set(o,new Ke(o));const In=new Map;for(const o of mc)In.set(o,new Ke(o,"uint"));const On=new Map([...In].map(o=>new Ke(o.value,"int")));for(const o of Tc)On.set(o,new Ke(o,"int"));const pr=new Map([...On].map(o=>new Ke(o.value)));for(const o of ua)pr.set(o,new Ke(o));for(const o of ua)pr.set(-o,new Ke(-o));const fr={bool:Gn,uint:In,ints:On,float:pr},Ei=new Map([...Gn,...pr]),mn=(o,e)=>Ei.has(o)?Ei.get(o):o.isNode===!0?o:new Ke(o,e),pe=function(o,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(o)&&t.every(r=>typeof r!="object"))&&(t=[ea(o,...t)]),t.length===1&&e!==null&&e.has(t[0]))return E(e.get(t[0]));if(t.length===1){const r=mn(t[0],o);return r.nodeType===o?E(r):E(new Ln(r,o))}const s=t.map(r=>mn(r));return E(new ra(s,o))}},Bi=o=>typeof o=="object"&&o!==null?o.value:o,yc=o=>o!=null?o.nodeType||o.convertTo||(typeof o=="string"?o:null):null;function gs(o,e){return new Proxy(new fc(o,e),aa)}const E=(o,e=null)=>uc(o,e),gr=(o,e=null)=>new lc(o,e),zt=(o,e=null)=>new cc(o,e),B=(...o)=>new dc(...o),P=(...o)=>new hc(...o);let xc=0;const v=(o,e=null)=>{let t=null;e!==null&&(typeof e=="object"?t=e.return:(typeof e=="string"?t=e:console.error("THREE.TSL: Invalid layout type."),e=null));const s=new gs(o,t),r=(...n)=>{let i;gr(n),n[0]&&(n[0].isNode||Object.getPrototypeOf(n[0])!==Object.prototype)?i=[...n]:i=n[0];const a=s.call(i);return t==="void"&&a.toStack(),a};if(r.shaderNode=s,r.id=s.id,r.isFn=!0,r.getNodeType=(...n)=>s.getNodeType(...n),r.getCacheKey=(...n)=>s.getCacheKey(...n),r.setLayout=n=>(s.setLayout(n),r),r.once=(n=null)=>(s.once=!0,s.subBuilds=n,r),e!==null){if(typeof e.inputs!="object"){const n={name:"fn"+xc++,type:t,inputs:[]};for(const i in e)i!=="return"&&n.inputs.push({name:i,type:e[i]});e=n}r.setLayout(e)}return r},or=o=>{Xt=o},la=()=>Xt,le=(...o)=>Xt.If(...o);function ca(o){return Xt&&Xt.add(o),o}N("toStack",ca);const _c=new pe("color"),b=new pe("float",fr.float),se=new pe("int",fr.ints),Sc=new pe("uint",fr.uint),Vn=new pe("bool",fr.bool),w=new pe("vec2"),Ye=new pe("ivec2"),Nc=new pe("uvec2"),bc=new pe("bvec2"),A=new pe("vec3"),Rc=new pe("ivec3"),Ac=new pe("uvec3"),Cc=new pe("bvec3"),k=new pe("vec4"),vc=new pe("ivec4"),Ec=new pe("uvec4"),Bc=new pe("bvec4"),kn=new pe("mat2"),Re=new pe("mat3"),$t=new pe("mat4");N("toColor",_c);N("toFloat",b);N("toInt",se);N("toUint",Sc);N("toBool",Vn);N("toVec2",w);N("toIVec2",Ye);N("toUVec2",Nc);N("toBVec2",bc);N("toVec3",A);N("toIVec3",Rc);N("toUVec3",Ac);N("toBVec3",Cc);N("toVec4",k);N("toIVec4",vc);N("toUVec4",Ec);N("toBVec4",Bc);N("toMat2",kn);N("toMat3",Re);N("toMat4",$t);const Mc=B(Zt).setParameterLength(2),Fc=(o,e)=>E(new Ln(E(o),e));N("element",Mc);N("convert",Fc);N("append",o=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),ca(o)));class Y extends V{static get type(){return"PropertyNode"}constructor(e,t=null,s=!1){super(e),this.name=t,this.varying=s,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const ut=(o,e)=>E(new Y(o,e)),ar=(o,e)=>E(new Y(o,e,!0)),K=P(Y,"vec4","DiffuseColor"),Mi=P(Y,"vec3","EmissiveColor"),je=P(Y,"float","Roughness"),ur=P(Y,"float","Metalness"),Tn=P(Y,"float","Clearcoat"),lr=P(Y,"float","ClearcoatRoughness"),It=P(Y,"vec3","Sheen"),zn=P(Y,"float","SheenRoughness"),$n=P(Y,"float","Iridescence"),da=P(Y,"float","IridescenceIOR"),ha=P(Y,"float","IridescenceThickness"),yn=P(Y,"float","AlphaT"),St=P(Y,"float","Anisotropy"),Zs=P(Y,"vec3","AnisotropyT"),Wt=P(Y,"vec3","AnisotropyB"),Be=P(Y,"color","SpecularColor"),cr=P(Y,"float","SpecularF90"),xn=P(Y,"float","Shininess"),xs=P(Y,"vec4","Output"),Mr=P(Y,"float","dashSize"),Fi=P(Y,"float","gapSize"),Js=P(Y,"float","IOR"),_n=P(Y,"float","Transmission"),pa=P(Y,"float","Thickness"),fa=P(Y,"float","AttenuationDistance"),ga=P(Y,"color","AttenuationColor"),ma=P(Y,"float","Dispersion");class Wn extends V{static get type(){return"UniformGroupNode"}constructor(e,t=!1,s=1){super("string"),this.name=e,this.shared=t,this.order=s,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const wc=o=>new Wn(o),Hn=(o,e=0)=>new Wn(o,!0,e),Pc=Hn("frame"),I=Hn("render"),Ta=wc("object");class Jt extends Un{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Ta}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const s=this.getSelf();return e=e.bind(s),super.onUpdate(r=>{const n=e(r,s);n!==void 0&&(this.value=n)},t)}generate(e,t){const s=this.getNodeType(e),r=this.getUniformHash(e);let n=e.getNodeFromHash(r);n===void 0&&(e.setHashNode(this,r),n=this);const i=n.getInputType(e),u=e.getUniformFromNode(n,i,e.shaderStage,this.name||e.context.label),a=e.getPropertyName(u);return e.context.label!==void 0&&delete e.context.label,e.format(a,s,t)}}const O=(o,e)=>{const t=yc(e||o),s=o&&o.isNode===!0?o.node&&o.node.value||o.value:o;return E(new Jt(s,t))};class Sn extends fe{static get type(){return"ArrayNode"}constructor(e,t,s=null){super(e),this.count=t,this.values=s,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const Dc=(...o)=>{let e;if(o.length===1){const t=o[0];e=new Sn(null,t.length,t)}else{const t=o[0],s=o[1];e=new Sn(t,s)}return E(e)};N("toArray",(o,e)=>Dc(Array(e).fill(o)));class ya extends fe{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const s=e.getTypeLength(t.node.getNodeType(e));return Bt.join("").slice(0,s)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:s}=this,r=e.getNodeProperties(this);r.sourceNode=s,r.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:s,sourceNode:r}=e.getNodeProperties(this),n=this.needsSplitAssign(e),i=s.getNodeType(e),u=s.build(e),a=r.build(e,i),c=r.getNodeType(e),d=e.getDataFromNode(this);let h;if(d.initialized===!0)t!=="void"&&(h=u);else if(n){const p=e.getVarFromNode(this,null,i),f=e.getPropertyName(p);e.addLineFlowCode(`${f} = ${a}`,this);const g=s.node,y=g.node.context({assign:!0}).build(e);for(let _=0;_<g.components.length;_++){const C=g.components[_];e.addLineFlowCode(`${y}.${C} = ${f}[ ${_} ]`,this)}t!=="void"&&(h=u)}else h=`${u} = ${a}`,(t==="void"||c==="void")&&(e.addLineFlowCode(h,this),t!=="void"&&(h=u));return d.initialized=!0,e.format(h,i,t)}}const Lc=B(ya).setParameterLength(2);N("assign",Lc);class xa extends fe{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){const t=[],s=this.functionNode,r=s.getInputs(e),n=this.parameters,i=(a,c)=>{const d=c.type,h=d==="pointer";let p;return h?p="&"+a.build(e):p=a.build(e,d),p};if(Array.isArray(n)){if(n.length>r.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),n.length=r.length;else if(n.length<r.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");n.length<r.length;)n.push(b(0));for(let a=0;a<n.length;a++)t.push(i(n[a],r[a]))}else for(const a of r){const c=n[a.name];c!==void 0?t.push(i(c,a)):(console.error(`THREE.TSL: Input '${a.name}' not found in 'Fn()'.`),t.push(i(b(0),a)))}return`${s.build(e,"property")}( ${t.join(", ")} )`}}const Uc=(o,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?zt(e):gr(e[0]),E(new xa(E(o),e)));N("call",Uc);const Gc={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class ie extends fe{static get type(){return"OperatorNode"}constructor(e,t,s,...r){if(super(),r.length>0){let n=new ie(e,t,s);for(let i=0;i<r.length-1;i++)n=new ie(e,n,r[i]);t=n,s=r[r.length-1]}this.op=e,this.aNode=t,this.bNode=s,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(Gc[this.op],t)}getNodeType(e){const t=this.op,s=this.aNode,r=this.bNode,n=s.getNodeType(e),i=r?r.getNodeType(e):null;if(n==="void"||i==="void")return"void";if(t==="%")return n;if(t==="~"||t==="&"||t==="|"||t==="^"||t===">>"||t==="<<")return e.getIntegerType(n);if(t==="!"||t==="&&"||t==="||"||t==="^^")return"bool";if(t==="=="||t==="!="||t==="<"||t===">"||t==="<="||t===">="){const u=Math.max(e.getTypeLength(n),e.getTypeLength(i));return u>1?`bvec${u}`:"bool"}else{if(e.isMatrix(n)){if(i==="float")return n;if(e.isVector(i))return e.getVectorFromMatrix(n);if(e.isMatrix(i))return n}else if(e.isMatrix(i)){if(n==="float")return i;if(e.isVector(n))return e.getVectorFromMatrix(i)}return e.getTypeLength(i)>e.getTypeLength(n)?i:n}}generate(e,t){const s=this.op,{aNode:r,bNode:n}=this,i=this.getNodeType(e);let u=null,a=null;i!=="void"?(u=r.getNodeType(e),a=n?n.getNodeType(e):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="||s==="!="?e.isVector(u)?a=u:e.isVector(a)?u=a:u!==a&&(u=a="float"):s===">>"||s==="<<"?(u=i,a=e.changeComponentType(a,"uint")):s==="%"?(u=i,a=e.isInteger(u)&&e.isInteger(a)?a:u):e.isMatrix(u)?a==="float"?a="float":e.isVector(a)?a=e.getVectorFromMatrix(u):e.isMatrix(a)||(u=a=i):e.isMatrix(a)?u==="float"?u="float":e.isVector(u)?u=e.getVectorFromMatrix(a):u=a=i:u=a=i):u=a=i;const c=r.build(e,u),d=n?n.build(e,a):null,h=e.getFunctionOperator(s);if(t!=="void"){const p=e.renderer.coordinateSystem===l.WebGLCoordinateSystem;if(s==="=="||s==="!="||s==="<"||s===">"||s==="<="||s===">=")return p?e.isVector(u)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${d} )`,i,t):e.format(`( ${c} ${s} ${d} )`,i,t):e.format(`( ${c} ${s} ${d} )`,i,t);if(s==="%")return e.isInteger(a)?e.format(`( ${c} % ${d} )`,i,t):e.format(`${this.getOperatorMethod(e,i)}( ${c}, ${d} )`,i,t);if(s==="!"||s==="~")return e.format(`(${s}${c})`,u,t);if(h)return e.format(`${h}( ${c}, ${d} )`,i,t);if(e.isMatrix(u)&&a==="float")return e.format(`( ${d} ${s} ${c} )`,i,t);if(u==="float"&&e.isMatrix(a))return e.format(`${c} ${s} ${d}`,i,t);{let f=`( ${c} ${s} ${d} )`;return!p&&i==="bool"&&e.isVector(u)&&e.isVector(a)&&(f=`all${f}`),e.format(f,i,t)}}else if(u!=="void")return h?e.format(`${h}( ${c}, ${d} )`,i,t):e.isMatrix(u)&&a==="float"?e.format(`${d} ${s} ${c}`,i,t):e.format(`${c} ${s} ${d}`,i,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const Ce=B(ie,"+").setParameterLength(2,1/0).setName("add"),_e=B(ie,"-").setParameterLength(2,1/0).setName("sub"),$=B(ie,"*").setParameterLength(2,1/0).setName("mul"),qe=B(ie,"/").setParameterLength(2,1/0).setName("div"),qn=B(ie,"%").setParameterLength(2).setName("mod"),_a=B(ie,"==").setParameterLength(2).setName("equal"),Ic=B(ie,"!=").setParameterLength(2).setName("notEqual"),Oc=B(ie,"<").setParameterLength(2).setName("lessThan"),Vc=B(ie,">").setParameterLength(2).setName("greaterThan"),kc=B(ie,"<=").setParameterLength(2).setName("lessThanEqual"),zc=B(ie,">=").setParameterLength(2).setName("greaterThanEqual"),$c=B(ie,"&&").setParameterLength(2,1/0).setName("and"),Wc=B(ie,"||").setParameterLength(2,1/0).setName("or"),Hc=B(ie,"!").setParameterLength(1).setName("not"),qc=B(ie,"^^").setParameterLength(2).setName("xor"),Xc=B(ie,"&").setParameterLength(2).setName("bitAnd"),Kc=B(ie,"~").setParameterLength(2).setName("bitNot"),Qc=B(ie,"|").setParameterLength(2).setName("bitOr"),Yc=B(ie,"^").setParameterLength(2).setName("bitXor"),jc=B(ie,"<<").setParameterLength(2).setName("shiftLeft"),Zc=B(ie,">>").setParameterLength(2).setName("shiftRight"),Jc=v(([o])=>(o.addAssign(1),o)),ed=v(([o])=>(o.subAssign(1),o)),td=v(([o])=>{const e=se(o).toConst();return o.addAssign(1),e}),sd=v(([o])=>{const e=se(o).toConst();return o.subAssign(1),e});N("add",Ce);N("sub",_e);N("mul",$);N("div",qe);N("mod",qn);N("equal",_a);N("notEqual",Ic);N("lessThan",Oc);N("greaterThan",Vc);N("lessThanEqual",kc);N("greaterThanEqual",zc);N("and",$c);N("or",Wc);N("not",Hc);N("xor",qc);N("bitAnd",Xc);N("bitNot",Kc);N("bitOr",Qc);N("bitXor",Yc);N("shiftLeft",jc);N("shiftRight",Zc);N("incrementBefore",Jc);N("decrementBefore",ed);N("increment",td);N("decrement",sd);const rd=(o,e)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),qn(se(o),se(e)));N("modInt",rd);class x extends fe{static get type(){return"MathNode"}constructor(e,t,s=null,r=null){if(super(),(e===x.MAX||e===x.MIN)&&arguments.length>3){let n=new x(e,t,s);for(let i=2;i<arguments.length-1;i++)n=new x(e,n,arguments[i]);t=n,s=arguments[arguments.length-1],r=null}this.method=e,this.aNode=t,this.bNode=s,this.cNode=r,this.isMathNode=!0}getInputType(e){const t=this.aNode.getNodeType(e),s=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,n=e.isMatrix(t)?0:e.getTypeLength(t),i=e.isMatrix(s)?0:e.getTypeLength(s),u=e.isMatrix(r)?0:e.getTypeLength(r);return n>i&&n>u?t:i>u?s:u>n?r:t}getNodeType(e){const t=this.method;return t===x.LENGTH||t===x.DISTANCE||t===x.DOT?"float":t===x.CROSS?"vec3":t===x.ALL||t===x.ANY?"bool":t===x.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:s,method:r}=this;let n=null;if(r===x.ONE_MINUS)n=_e(1,t);else if(r===x.RECIPROCAL)n=qe(1,t);else if(r===x.DIFFERENCE)n=we(_e(t,s));else if(r===x.TRANSFORM_DIRECTION){let i=t,u=s;e.isMatrix(i.getNodeType(e))?u=k(A(u),0):i=k(A(i),0);const a=$(i,u).xyz;n=Es(a)}return n!==null?n:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const n=this.getNodeType(e),i=this.getInputType(e),u=this.aNode,a=this.bNode,c=this.cNode,d=e.renderer.coordinateSystem;if(r===x.NEGATE)return e.format("( - "+u.build(e,i)+" )",n,t);{const h=[];return r===x.CROSS?h.push(u.build(e,n),a.build(e,n)):d===l.WebGLCoordinateSystem&&r===x.STEP?h.push(u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":i),a.build(e,i)):d===l.WebGLCoordinateSystem&&(r===x.MIN||r===x.MAX)?h.push(u.build(e,i),a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":i)):r===x.REFRACT?h.push(u.build(e,i),a.build(e,i),c.build(e,"float")):r===x.MIX?h.push(u.build(e,i),a.build(e,i),c.build(e,e.getTypeLength(c.getNodeType(e))===1?"float":i)):(d===l.WebGPUCoordinateSystem&&r===x.ATAN&&a!==null&&(r="atan2"),e.shaderStage!=="fragment"&&(r===x.DFDX||r===x.DFDY)&&(console.warn(`THREE.TSL: '${r}' is not supported in the ${e.shaderStage} stage.`),r="/*"+r+"*/"),h.push(u.build(e,i)),a!==null&&h.push(a.build(e,i)),c!==null&&h.push(c.build(e,i))),e.format(`${e.getMethod(r,n)}( ${h.join(", ")} )`,n,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}x.ALL="all";x.ANY="any";x.RADIANS="radians";x.DEGREES="degrees";x.EXP="exp";x.EXP2="exp2";x.LOG="log";x.LOG2="log2";x.SQRT="sqrt";x.INVERSE_SQRT="inversesqrt";x.FLOOR="floor";x.CEIL="ceil";x.NORMALIZE="normalize";x.FRACT="fract";x.SIN="sin";x.COS="cos";x.TAN="tan";x.ASIN="asin";x.ACOS="acos";x.ATAN="atan";x.ABS="abs";x.SIGN="sign";x.LENGTH="length";x.NEGATE="negate";x.ONE_MINUS="oneMinus";x.DFDX="dFdx";x.DFDY="dFdy";x.ROUND="round";x.RECIPROCAL="reciprocal";x.TRUNC="trunc";x.FWIDTH="fwidth";x.TRANSPOSE="transpose";x.BITCAST="bitcast";x.EQUALS="equals";x.MIN="min";x.MAX="max";x.STEP="step";x.REFLECT="reflect";x.DISTANCE="distance";x.DIFFERENCE="difference";x.DOT="dot";x.CROSS="cross";x.POW="pow";x.TRANSFORM_DIRECTION="transformDirection";x.MIX="mix";x.CLAMP="clamp";x.REFRACT="refract";x.SMOOTHSTEP="smoothstep";x.FACEFORWARD="faceforward";const nd=b(1e-6),id=b(Math.PI),od=B(x,x.ALL).setParameterLength(1),ad=B(x,x.ANY).setParameterLength(1),ud=B(x,x.RADIANS).setParameterLength(1),ld=B(x,x.DEGREES).setParameterLength(1),Sa=B(x,x.EXP).setParameterLength(1),vs=B(x,x.EXP2).setParameterLength(1),Na=B(x,x.LOG).setParameterLength(1),Ze=B(x,x.LOG2).setParameterLength(1),Xn=B(x,x.SQRT).setParameterLength(1),cd=B(x,x.INVERSE_SQRT).setParameterLength(1),vt=B(x,x.FLOOR).setParameterLength(1),Kn=B(x,x.CEIL).setParameterLength(1),Es=B(x,x.NORMALIZE).setParameterLength(1),dt=B(x,x.FRACT).setParameterLength(1),Oe=B(x,x.SIN).setParameterLength(1),it=B(x,x.COS).setParameterLength(1),dd=B(x,x.TAN).setParameterLength(1),hd=B(x,x.ASIN).setParameterLength(1),ba=B(x,x.ACOS).setParameterLength(1),Ra=B(x,x.ATAN).setParameterLength(1,2),we=B(x,x.ABS).setParameterLength(1),dr=B(x,x.SIGN).setParameterLength(1),Je=B(x,x.LENGTH).setParameterLength(1),pd=B(x,x.NEGATE).setParameterLength(1),fd=B(x,x.ONE_MINUS).setParameterLength(1),Aa=B(x,x.DFDX).setParameterLength(1),Ca=B(x,x.DFDY).setParameterLength(1),gd=B(x,x.ROUND).setParameterLength(1),md=B(x,x.RECIPROCAL).setParameterLength(1),Td=B(x,x.TRUNC).setParameterLength(1),yd=B(x,x.FWIDTH).setParameterLength(1),xd=B(x,x.TRANSPOSE).setParameterLength(1),_d=(o,e)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),_a(o,e)),Kt=B(x,x.MIN).setParameterLength(2,1/0),ye=B(x,x.MAX).setParameterLength(2,1/0),va=B(x,x.STEP).setParameterLength(2),Sd=B(x,x.REFLECT).setParameterLength(2),Nd=B(x,x.DISTANCE).setParameterLength(2),bd=B(x,x.DIFFERENCE).setParameterLength(2),Qn=B(x,x.DOT).setParameterLength(2),Ea=B(x,x.CROSS).setParameterLength(2),mr=B(x,x.POW).setParameterLength(2),Ba=B(x,x.POW,2).setParameterLength(1),Rd=B(x,x.POW,3).setParameterLength(1),Ad=B(x,x.POW,4).setParameterLength(1),Cd=B(x,x.TRANSFORM_DIRECTION).setParameterLength(2),vd=o=>$(dr(o),mr(we(o),1/3)),Ma=o=>Qn(o,o),ne=B(x,x.MIX).setParameterLength(3),et=(o,e=0,t=1)=>E(new x(x.CLAMP,E(o),E(e),E(t))),Fa=o=>et(o),wa=B(x,x.REFRACT).setParameterLength(3),lt=B(x,x.SMOOTHSTEP).setParameterLength(3),Ed=B(x,x.FACEFORWARD).setParameterLength(3),Bd=v(([o])=>{const s=43758.5453,r=Qn(o.xy,w(12.9898,78.233)),n=qn(r,id);return dt(Oe(n).mul(s))}),Md=(o,e,t)=>ne(e,t,o),Fd=(o,e,t)=>lt(e,t,o),wd=(o,e)=>va(e,o),Pd=(o,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),Ra(o,e));N("all",od);N("any",ad);N("equals",_d);N("radians",ud);N("degrees",ld);N("exp",Sa);N("exp2",vs);N("log",Na);N("log2",Ze);N("sqrt",Xn);N("inverseSqrt",cd);N("floor",vt);N("ceil",Kn);N("normalize",Es);N("fract",dt);N("sin",Oe);N("cos",it);N("tan",dd);N("asin",hd);N("acos",ba);N("atan",Ra);N("abs",we);N("sign",dr);N("length",Je);N("lengthSq",Ma);N("negate",pd);N("oneMinus",fd);N("dFdx",Aa);N("dFdy",Ca);N("round",gd);N("reciprocal",md);N("trunc",Td);N("fwidth",yd);N("atan2",Pd);N("min",Kt);N("max",ye);N("step",wd);N("reflect",Sd);N("distance",Nd);N("dot",Qn);N("cross",Ea);N("pow",mr);N("pow2",Ba);N("pow3",Rd);N("pow4",Ad);N("transformDirection",Cd);N("mix",Md);N("clamp",et);N("refract",wa);N("smoothstep",Fd);N("faceForward",Ed);N("difference",bd);N("saturate",Fa);N("cbrt",vd);N("transpose",xd);N("rand",Bd);class Dd extends V{static get type(){return"ConditionalNode"}constructor(e,t,s=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=s}getNodeType(e){const{ifNode:t,elseNode:s}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);const r=t.getNodeType(e);if(s!==null){const n=s.getNodeType(e);if(e.getTypeLength(n)>e.getTypeLength(r))return n}return r}setup(e){const t=this.condNode.cache(),s=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,n=e.context.nodeBlock;e.getDataFromNode(s).parentNodeBlock=n,r!==null&&(e.getDataFromNode(r).parentNodeBlock=n);const i=e.getNodeProperties(this);i.condNode=t,i.ifNode=s.context({nodeBlock:s}),i.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){const s=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:n,ifNode:i,elseNode:u}=e.getNodeProperties(this),a=e.currentFunctionNode,c=t!=="void",d=c?ut(s).build(e):"";r.nodeProperty=d;const h=n.build(e,"bool");e.addFlowCode(`
6
- ${e.tab}if ( ${h} ) {
7
-
8
- `).addFlowTab();let p=i.build(e,s);if(p&&(c?p=d+" = "+p+";":(p="return "+p+";",a===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),p="// "+p))),e.removeFlowTab().addFlowCode(e.tab+" "+p+`
9
-
10
- `+e.tab+"}"),u!==null){e.addFlowCode(` else {
11
-
12
- `).addFlowTab();let f=u.build(e,s);f&&(c?f=d+" = "+f+";":(f="return "+f+";",a===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),f="// "+f))),e.removeFlowTab().addFlowCode(e.tab+" "+f+`
13
-
14
- `+e.tab+`}
15
-
16
- `)}else e.addFlowCode(`
17
-
18
- `);return e.format(d,s,t)}}const Se=B(Dd).setParameterLength(2,3);N("select",Se);class Yn extends V{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){const s=e.getContext();e.setContext({...e.context,...this.value});const r=this.node.build(e,t);return e.setContext(s),r}}const jn=B(Yn).setParameterLength(1,2),Ld=(o,e)=>jn(o,{label:e});N("context",jn);N("label",Ld);class _s extends V{static get type(){return"VarNode"}constructor(e,t=null,s=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=s,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:s,readOnly:r}=this,{renderer:n}=e,i=n.backend.isWebGPUBackend===!0;let u=!1,a=!1;r&&(u=e.isDeterministic(t),a=i?r:u);const c=e.getVectorType(this.getNodeType(e)),d=t.build(e,c),h=e.getVarFromNode(this,s,c,void 0,a),p=e.getPropertyName(h);let f=p;if(a)if(i)f=u?`const ${p}`:`let ${p}`;else{const g=e.getArrayCount(t);f=`const ${e.getVar(h.type,p,g)}`}return e.addLineFlowCode(`${f} = ${d}`,this),p}}const Zn=B(_s),Ud=(o,e=null)=>Zn(o,e).toStack(),Gd=(o,e=null)=>Zn(o,e,!0).toStack();N("toVar",Ud);N("toConst",Gd);const Id=o=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),Zn(o));N("temp",Id);class Pa extends V{static get type(){return"SubBuild"}constructor(e,t,s=null){super(s),this.node=e,this.name=t,this.isSubBuildNode=!0}getNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);const t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);const s=this.node.build(e,...t);return e.removeSubBuild(),s}}const Ss=(o,e,t=null)=>E(new Pa(E(o),e,t));class Da extends V{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let s=t.varying;if(s===void 0){const r=this.name,n=this.getNodeType(e),i=this.interpolationType,u=this.interpolationSampling;t.varying=s=e.getVaryingFromNode(this,r,n,i,u),t.node=Ss(this.node,"VERTEX")}return s.needsInterpolation||(s.needsInterpolation=e.shaderStage==="fragment"),s}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(fs.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(fs.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),s=e.getNodeProperties(this),r=this.setupVarying(e);if(s[t]===void 0){const n=this.getNodeType(e),i=e.getPropertyName(r,fs.VERTEX);e.flowNodeFromShaderStage(fs.VERTEX,s.node,n,i),s[t]=i}return e.getPropertyName(r)}}const ht=B(Da).setParameterLength(1,2),Od=o=>ht(o);N("toVarying",ht);N("toVertexStage",Od);N("varying",(...o)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),ht(...o)));N("vertexStage",(...o)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),ht(...o)));const Vd=v(([o])=>{const e=o.mul(.9478672986).add(.0521327014).pow(2.4),t=o.mul(.0773993808),s=o.lessThanEqual(.04045);return ne(e,t,s)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),kd=v(([o])=>{const e=o.pow(.41666).mul(1.055).sub(.055),t=o.mul(12.92),s=o.lessThanEqual(.0031308);return ne(e,t,s)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Jn="WorkingColorSpace",zd="OutputColorSpace";class ei extends fe{static get type(){return"ColorSpaceNode"}constructor(e,t,s){super("vec4"),this.colorNode=e,this.source=t,this.target=s}resolveColorSpace(e,t){return t===Jn?l.ColorManagement.workingColorSpace:t===zd?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,s=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target);let n=t;return l.ColorManagement.enabled===!1||s===r||!s||!r||(l.ColorManagement.getTransfer(s)===l.SRGBTransfer&&(n=k(Vd(n.rgb),n.a)),l.ColorManagement.getPrimaries(s)!==l.ColorManagement.getPrimaries(r)&&(n=k(Re(l.ColorManagement._getMatrix(new l.Matrix3,s,r)).mul(n.rgb),n.a)),l.ColorManagement.getTransfer(r)===l.SRGBTransfer&&(n=k(kd(n.rgb),n.a))),n}}const $d=(o,e)=>E(new ei(E(o),Jn,e)),ti=(o,e)=>E(new ei(E(o),e,Jn));N("workingToColorSpace",$d);N("colorSpaceToWorking",ti);let Wd=class extends Zt{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),s=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,s,r)}};class La extends V{static get type(){return"ReferenceBaseNode"}constructor(e,t,s=null,r=null){super(),this.property=e,this.uniformType=t,this.object=s,this.count=r,this.properties=e.split("."),this.reference=s,this.node=null,this.group=null,this.updateType=z.OBJECT}setGroup(e){return this.group=e,this}element(e){return E(new Wd(this,E(e)))}setNodeType(e){const t=O(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let s=e[t[0]];for(let r=1;r<t.length;r++)s=s[t[r]];return s}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const Hd=(o,e,t)=>E(new La(o,e,t));class Ua extends La{static get type(){return"RendererReferenceNode"}constructor(e,t,s=null){super(e,t,s),this.renderer=s,this.setGroup(I)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const qd=(o,e,t=null)=>E(new Ua(o,e,t));class Ga extends fe{static get type(){return"ToneMappingNode"}constructor(e,t=Kd,s=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=s}customCacheKey(){return rr(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,s=this.toneMapping;if(s===l.NoToneMapping)return t;let r=null;const n=e.renderer.library.getToneMappingFunction(s);return n!==null?r=k(n(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",s),r=t),r}}const Xd=(o,e,t)=>E(new Ga(o,E(e),E(t))),Kd=qd("toneMappingExposure","float");N("toneMapping",(o,e,t)=>Xd(e,t,o));class Ia extends Un{static get type(){return"BufferAttributeNode"}constructor(e,t=null,s=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=s,this.bufferOffset=r,this.usage=l.StaticDrawUsage,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),s=this.value,r=e.getTypeLength(t),n=this.bufferStride||r,i=this.bufferOffset,u=s.isInterleavedBuffer===!0?s:new l.InterleavedBuffer(s,n),a=new l.InterleavedBufferAttribute(u,r,i);u.setUsage(this.usage),this.attribute=a,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),s=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(s);let n=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,n=r):n=ht(this).build(e,t),n}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const si=(o,e=null,t=0,s=0)=>E(new Ia(o,e,t,s)),Qd=(o,e=null,t=0,s=0)=>si(o,e,t,s).setUsage(l.DynamicDrawUsage),wi=(o,e=null,t=0,s=0)=>si(o,e,t,s).setInstanced(!0),Pi=(o,e=null,t=0,s=0)=>Qd(o,e,t,s).setInstanced(!0);N("toAttribute",o=>si(o.value));class Oa extends V{static get type(){return"ComputeNode"}constructor(e,t,s=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=s,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=z.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let s=t[0];for(let r=1;r<t.length;r++)s*=t[r];this.dispatchCount=Math.ceil(e/s)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){const t=this.computeNode.build(e);if(t){const s=e.getNodeProperties(this);s.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:s}=e;if(s==="compute"){const r=this.computeNode.build(e,"void");r!==""&&e.addLineFlowCode(r,this)}else{const n=e.getNodeProperties(this).outputComputeNode;if(n)return n.build(e,t)}}}const Yd=(o,e,t)=>E(new Oa(E(o),e,t));N("compute",Yd);class Va extends V{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){const s=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const n=this.node.build(e,...t);return e.setCache(s),n}}const er=(o,e)=>E(new Va(E(o),e));N("cache",er);class ka extends V{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const jd=B(ka).setParameterLength(2);N("bypass",jd);class ri extends V{static get type(){return"RemapNode"}constructor(e,t,s,r=b(0),n=b(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=s,this.outLowNode=r,this.outHighNode=n,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:s,outLowNode:r,outHighNode:n,doClamp:i}=this;let u=e.sub(t).div(s.sub(t));return i===!0&&(u=u.clamp()),u.mul(n.sub(r)).add(r)}}const Zd=B(ri,null,null,{doClamp:!1}).setParameterLength(3,5),Jd=B(ri).setParameterLength(3,5);N("remap",Zd);N("remapClamp",Jd);class Ns extends V{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const s=this.getNodeType(e),r=this.snippet;if(s==="void")e.addLineFlowCode(r,this);else return e.format(r,s,t)}}const Qt=B(Ns).setParameterLength(1,2),eh=o=>(o?Se(o,Qt("discard")):Qt("discard")).toStack();N("discard",eh);class za extends fe{static get type(){return"RenderOutputNode"}constructor(e,t,s){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=s,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const s=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||l.NoToneMapping,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||l.NoColorSpace;return s!==l.NoToneMapping&&(t=t.toneMapping(s)),r!==l.NoColorSpace&&r!==l.ColorManagement.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const th=(o,e=null,t=null)=>E(new za(E(o),e,t));N("renderOutput",th);class $a extends fe{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,s=this.node.build(e),r="--- TSL debug - "+e.shaderStage+" shader ---",n="-".repeat(r.length);let i="";return i+="// #"+r+`#
19
- `,i+=e.flow.code.replace(/^\t/mg,"")+`
20
- `,i+="/* ... */ "+s+` /* ... */
21
- `,i+="// #"+n+`#
22
- `,t!==null?t(e,i):console.log(i),s}}const sh=(o,e=null)=>E(new $a(E(o),e));N("debug",sh);class ni extends V{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const s=this.getAttributeName(e);if(e.hasGeometryAttribute(s)){const r=e.geometry.getAttribute(s);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),s=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const n=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(n),u=e.getAttribute(t,i);return e.shaderStage==="vertex"?e.format(u.name,i,s):ht(this).build(e,s)}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(s)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const ct=(o,e=null)=>E(new ni(o,e)),Ps=(o=0)=>ct("uv"+(o>0?o:""),"vec2");class Wa extends V{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const s=this.textureNode.build(e,"property"),r=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${s}, ${r} )`,this.getNodeType(e),t)}}const Ht=B(Wa).setParameterLength(1,2);class Ha extends Jt{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=z.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,s=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(s&&s.width!==void 0){const{width:r,height:n}=s;this.value=Math.log2(Math.max(r,n))}}}const rh=B(Ha).setParameterLength(1),qa=new l.Texture;class Mt extends Jt{static get type(){return"TextureNode"}constructor(e=qa,t=null,s=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=s,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=z.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===l.UnsignedIntType?"uvec4":this.value.type===l.IntType?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Ps(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=O(this.value.matrix)),this._matrixUniform.mul(A(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?z.OBJECT:z.NONE,this}setupUV(e,t){const s=this.value;return e.isFlipY()&&(s.image instanceof ImageBitmap&&s.flipY===!0||s.isRenderTargetTexture===!0||s.isFramebufferTexture===!0||s.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(se(Ht(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const s=this.value;if(!s||s.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let r=this.uvNode;(r===null||e.context.forceUVContext===!0)&&e.context.getUV&&(r=e.context.getUV(this,e)),r||(r=this.getDefaultUV()),this.updateMatrix===!0&&(r=this.getTransformedUV(r)),r=this.setupUV(e,r);let n=this.levelNode;n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),t.uvNode=r,t.levelNode=n,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateSnippet(e,t,s,r,n,i,u,a){const c=this.value;let d;return r?d=e.generateTextureLevel(c,t,s,r,i):n?d=e.generateTextureBias(c,t,s,n,i):a?d=e.generateTextureGrad(c,t,s,a,i):u?d=e.generateTextureCompare(c,t,s,u,i):this.sampler===!1?d=e.generateTextureLoad(c,t,s,i):d=e.generateTexture(c,t,s,i),d}generate(e,t){const s=this.value,r=e.getNodeProperties(this),n=super.generate(e,"property");if(/^sampler/.test(t))return n+"_sampler";if(e.isReference(t))return n;{const i=e.getDataFromNode(this);let u=i.propertyName;if(u===void 0){const{uvNode:d,levelNode:h,biasNode:p,compareNode:f,depthNode:g,gradNode:m}=r,y=this.generateUV(e,d),_=h?h.build(e,"float"):null,C=p?p.build(e,"float"):null,R=g?g.build(e,"int"):null,U=f?f.build(e,"float"):null,M=m?[m[0].build(e,"vec2"),m[1].build(e,"vec2")]:null,D=e.getVarFromNode(this);u=e.getPropertyName(D);const F=this.generateSnippet(e,n,y,_,C,R,U,M);e.addLineFlowCode(`${u} = ${F}`,this),i.snippet=F,i.propertyName=u}let a=u;const c=this.getNodeType(e);return e.needsToWorkingColorSpace(s)&&(a=ti(Qt(a,c),s.colorSpace).setup(e).build(e,c)),e.format(a,c,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=E(e),t.referenceNode=this.getSelf(),E(t)}blur(e){const t=this.clone();t.biasNode=E(e).mul(rh(t)),t.referenceNode=this.getSelf();const s=t.value;return t.generateMipmaps===!1&&(s&&s.generateMipmaps===!1||s.minFilter===l.NearestFilter||s.magFilter===l.NearestFilter)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),E(t)}level(e){const t=this.clone();return t.levelNode=E(e),t.referenceNode=this.getSelf(),E(t)}size(e){return Ht(this,e)}bias(e){const t=this.clone();return t.biasNode=E(e),t.referenceNode=this.getSelf(),E(t)}compare(e){const t=this.clone();return t.compareNode=E(e),t.referenceNode=this.getSelf(),E(t)}grad(e,t){const s=this.clone();return s.gradNode=[E(e),E(t)],s.referenceNode=this.getSelf(),E(s)}depth(e){const t=this.clone();return t.depthNode=E(e),t.referenceNode=this.getSelf(),E(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}const nh=B(Mt).setParameterLength(1,4).setName("texture"),X=(o=qa,e=null,t=null,s=null)=>{let r;return o&&o.isTextureNode===!0?(r=E(o.clone()),r.referenceNode=o.getSelf(),e!==null&&(r.uvNode=E(e)),t!==null&&(r.levelNode=E(t)),s!==null&&(r.biasNode=E(s))):r=nh(o,e,t,s),r},Ie=(...o)=>X(...o).setSampler(!1);class ii extends Jt{static get type(){return"BufferNode"}constructor(e,t,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=s}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const Xa=(o,e,t)=>E(new ii(o,e,t));class ih extends Zt{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),s=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,s)}}class Ka extends ii{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?ir(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=z.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,s=this.elementType;if(s==="float"||s==="int"||s==="uint")for(let r=0;r<e.length;r++){const n=r*4;t[n]=e[r]}else if(s==="color")for(let r=0;r<e.length;r++){const n=r*4,i=e[r];t[n]=i.r,t[n+1]=i.g,t[n+2]=i.b||0}else if(s==="mat2")for(let r=0;r<e.length;r++){const n=r*4,i=e[r];t[n]=i.elements[0],t[n+1]=i.elements[1],t[n+2]=i.elements[2],t[n+3]=i.elements[3]}else if(s==="mat3")for(let r=0;r<e.length;r++){const n=r*16,i=e[r];t[n]=i.elements[0],t[n+1]=i.elements[1],t[n+2]=i.elements[2],t[n+4]=i.elements[3],t[n+5]=i.elements[4],t[n+6]=i.elements[5],t[n+8]=i.elements[6],t[n+9]=i.elements[7],t[n+10]=i.elements[8],t[n+15]=1}else if(s==="mat4")for(let r=0;r<e.length;r++){const n=r*16,i=e[r];for(let u=0;u<i.elements.length;u++)t[n+u]=i.elements[u]}else for(let r=0;r<e.length;r++){const n=r*4,i=e[r];t[n]=i.x,t[n+1]=i.y,t[n+2]=i.z||0,t[n+3]=i.w||0}}setup(e){const t=this.array.length,s=this.elementType;let r=Float32Array;const n=this.paddedType,i=e.getTypeLength(n);return s.charAt(0)==="i"&&(r=Int32Array),s.charAt(0)==="u"&&(r=Uint32Array),this.value=new r(t*i),this.bufferCount=t,this.bufferType=n,super.setup(e)}element(e){return E(new ih(this,E(e)))}}const We=(o,e)=>E(new Ka(o,e));class oh extends V{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const Tr=B(oh).setParameterLength(1),Qa=O(0,"uint").label("u_cameraIndex").setGroup(Hn("cameraIndex")).toVarying("v_cameraIndex"),bt=O("float").label("cameraNear").setGroup(I).onRenderUpdate(({camera:o})=>o.near),Rt=O("float").label("cameraFar").setGroup(I).onRenderUpdate(({camera:o})=>o.far),oi=v(({camera:o})=>{let e;if(o.isArrayCamera&&o.cameras.length>0){const t=[];for(const r of o.cameras)t.push(r.projectionMatrix);e=We(t).setGroup(I).label("cameraProjectionMatrices").element(o.isMultiViewCamera?Tr("gl_ViewID_OVR"):Qa).toVar("cameraProjectionMatrix")}else e=O("mat4").label("cameraProjectionMatrix").setGroup(I).onRenderUpdate(({camera:t})=>t.projectionMatrix);return e}).once()(),tt=v(({camera:o})=>{let e;if(o.isArrayCamera&&o.cameras.length>0){const t=[];for(const r of o.cameras)t.push(r.matrixWorldInverse);e=We(t).setGroup(I).label("cameraViewMatrices").element(o.isMultiViewCamera?Tr("gl_ViewID_OVR"):Qa).toVar("cameraViewMatrix")}else e=O("mat4").label("cameraViewMatrix").setGroup(I).onRenderUpdate(({camera:t})=>t.matrixWorldInverse);return e}).once()(),ah=O(new l.Vector3).label("cameraPosition").setGroup(I).onRenderUpdate(({camera:o},e)=>e.value.setFromMatrixPosition(o.matrixWorld)),Di=new l.Sphere;class j extends V{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=z.OBJECT,this.uniformNode=new Jt(null)}getNodeType(){const e=this.scope;if(e===j.WORLD_MATRIX)return"mat4";if(e===j.POSITION||e===j.VIEW_POSITION||e===j.DIRECTION||e===j.SCALE)return"vec3";if(e===j.RADIUS)return"float"}update(e){const t=this.object3d,s=this.uniformNode,r=this.scope;if(r===j.WORLD_MATRIX)s.value=t.matrixWorld;else if(r===j.POSITION)s.value=s.value||new l.Vector3,s.value.setFromMatrixPosition(t.matrixWorld);else if(r===j.SCALE)s.value=s.value||new l.Vector3,s.value.setFromMatrixScale(t.matrixWorld);else if(r===j.DIRECTION)s.value=s.value||new l.Vector3,t.getWorldDirection(s.value);else if(r===j.VIEW_POSITION){const n=e.camera;s.value=s.value||new l.Vector3,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(n.matrixWorldInverse)}else if(r===j.RADIUS){const n=e.object.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Di.copy(n.boundingSphere).applyMatrix4(t.matrixWorld),s.value=Di.radius}}generate(e){const t=this.scope;return t===j.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===j.POSITION||t===j.VIEW_POSITION||t===j.DIRECTION||t===j.SCALE?this.uniformNode.nodeType="vec3":t===j.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}j.WORLD_MATRIX="worldMatrix";j.POSITION="position";j.SCALE="scale";j.VIEW_POSITION="viewPosition";j.DIRECTION="direction";j.RADIUS="radius";const uh=B(j,j.POSITION).setParameterLength(1);class Me extends j{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}Me.DIRECTION;const Et=P(Me,Me.WORLD_MATRIX);Me.POSITION;Me.SCALE;Me.VIEW_POSITION;Me.RADIUS;const lh=O(new l.Matrix3).onObjectUpdate(({object:o},e)=>e.value.getNormalMatrix(o.matrixWorld)),yr=v(o=>o.renderer.overrideNodes.modelViewMatrix||ch).once()().toVar("modelViewMatrix"),ch=tt.mul(Et),Li=v(o=>(o.context.isHighPrecisionModelViewMatrix=!0,O("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),Ui=v(o=>{const e=o.context.isHighPrecisionModelViewMatrix;return O("mat3").onObjectUpdate(({object:t,camera:s})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),xr=ct("position","vec3"),Te=xr.toVarying("positionLocal"),Gi=xr.toVarying("positionPrevious"),Bs=v(o=>Et.mul(Te).xyz.toVarying(o.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),Ya=v(()=>Te.transformDirection(Et).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),ue=v(o=>o.context.setupPositionView().toVarying("v_positionView"),"vec3").once(["POSITION"])(),oe=ue.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class ja extends V{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!=="fragment")return"true";const{renderer:t,material:s}=e;return t.coordinateSystem===l.WebGLCoordinateSystem&&s.side===l.BackSide?"false":e.getFrontFacing()}}const dh=P(ja),Za=b(dh).mul(2).sub(1),Ds=v(([o],{material:e})=>{const t=e.side;return t===l.BackSide?o=o.mul(-1):t===l.DoubleSide&&(o=o.mul(Za)),o}),Ja=ct("normal","vec3"),Xe=v(o=>o.geometry.hasAttribute("normal")===!1?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),A(0,1,0)):Ja,"vec3").once()().toVar("normalLocal"),hh=ue.dFdx().cross(ue.dFdy()).normalize().toVar("normalFlat"),Ms=v(o=>{let e;return o.material.flatShading===!0?e=hh:e=eu(Xe).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),ph=v(o=>{let e=Ms.transformDirection(tt);return o.material.flatShading!==!0&&(e=e.toVarying("v_normalWorldGeometry")),e.normalize().toVar("normalWorldGeometry")},"vec3").once()(),Z=v(({subBuildFn:o,material:e,context:t})=>{let s;return o==="NORMAL"||o==="VERTEX"?(s=Ms,e.flatShading!==!0&&(s=Ds(s))):s=t.setupNormal().context({getUV:null}),s},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),es=Z.transformDirection(tt).toVar("normalWorld"),Ot=v(({subBuildFn:o,context:e})=>{let t;return o==="NORMAL"||o==="VERTEX"?t=Z:t=e.setupClearcoatNormal().context({getUV:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),fh=v(([o,e=Et])=>{const t=Re(e),s=o.div(A(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(s).xyz}),eu=v(([o],e)=>{const t=e.renderer.overrideNodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(o);const s=lh.mul(o);return tt.transformDirection(s)});v(()=>(console.warn('THREE.TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),Z)).once(["NORMAL","VERTEX"])();v(()=>(console.warn('THREE.TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),es)).once(["NORMAL","VERTEX"])();v(()=>(console.warn('THREE.TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),Ot)).once(["NORMAL","VERTEX"])();const Ii=new l.Euler,Fr=new l.Matrix4,gh=O(0).onReference(({material:o})=>o).onObjectUpdate(({material:o})=>o.refractionRatio),wr=O(1).onReference(({material:o})=>o).onObjectUpdate(function({material:o,scene:e}){return o.envMap?o.envMapIntensity:e.environmentIntensity}),tu=O(new l.Matrix4).onReference(function(o){return o.material}).onObjectUpdate(function({material:o,scene:e}){const t=e.environment!==null&&o.envMap===null?e.environmentRotation:o.envMapRotation;return t?(Ii.copy(t),Fr.makeRotationFromEuler(Ii)):Fr.identity(),Fr}),mh=oe.negate().reflect(Z),Th=oe.negate().refract(Z,gh),yh=mh.transformDirection(tt).toVar("reflectVector"),xh=Th.transformDirection(tt).toVar("reflectVector"),_h=new l.CubeTexture;class su extends Mt{static get type(){return"CubeTextureNode"}constructor(e,t=null,s=null,r=null){super(e,t,s,r),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===l.CubeReflectionMapping?yh:e.mapping===l.CubeRefractionMapping?xh:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),A(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const s=this.value;return(e.renderer.coordinateSystem===l.WebGPUCoordinateSystem||!s.isRenderTargetTexture)&&(t=A(t.x.negate(),t.yz)),tu.mul(t)}generateUV(e,t){return t.build(e,"vec3")}}const Sh=B(su).setParameterLength(1,4).setName("cubeTexture"),Fs=(o=_h,e=null,t=null,s=null)=>{let r;return o&&o.isCubeTextureNode===!0?(r=E(o.clone()),r.referenceNode=o.getSelf(),e!==null&&(r.uvNode=E(e)),t!==null&&(r.levelNode=E(t)),s!==null&&(r.biasNode=E(s))):r=Sh(o,e,t,s),r};class Nh extends Zt{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),s=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,s,r)}}class _r extends V{static get type(){return"ReferenceNode"}constructor(e,t,s=null,r=null){super(),this.property=e,this.uniformType=t,this.object=s,this.count=r,this.properties=e.split("."),this.reference=s,this.node=null,this.group=null,this.name=null,this.updateType=z.OBJECT}element(e){return E(new Nh(this,E(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;this.count!==null?t=Xa(null,e,this.count):Array.isArray(this.getValueFromReference())?t=We(null,e):e==="texture"?t=X(null):e==="cubeTexture"?t=Fs(null):t=O(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let s=e[t[0]];for(let r=1;r<t.length;r++)s=s[t[r]];return s}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const J=(o,e,t)=>E(new _r(o,e,t)),Oi=(o,e,t,s)=>E(new _r(o,e,s,t));class ru extends _r{static get type(){return"MaterialReferenceNode"}constructor(e,t,s=null){super(e,t,s),this.material=s,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const ot=(o,e,t=null)=>E(new ru(o,e,t)),nu=Ps(),bh=ue.dFdx(),Rh=ue.dFdy(),iu=nu.dFdx(),ou=nu.dFdy(),au=Z,uu=Rh.cross(au),lu=au.cross(bh),Nn=uu.mul(iu.x).add(lu.mul(ou.x)),bn=uu.mul(iu.y).add(lu.mul(ou.y)),Vi=Nn.dot(Nn).max(bn.dot(bn)),cu=Vi.equal(0).select(0,Vi.inverseSqrt()),Ah=Nn.mul(cu).toVar("tangentViewFrame"),Ch=bn.mul(cu).toVar("bitangentViewFrame"),du=v(o=>(o.geometry.hasAttribute("tangent")===!1&&o.geometry.computeTangents(),ct("tangent","vec4")))(),ai=du.xyz.toVar("tangentLocal"),hu=v(({subBuildFn:o,geometry:e,material:t})=>{let s;return o==="VERTEX"||e.hasAttribute("tangent")?s=yr.mul(k(ai,0)).xyz.toVarying("v_tangentView").normalize():s=Ah,t.flatShading!==!0&&(s=Ds(s)),s},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),vh=v(([o,e],{subBuildFn:t,material:s})=>{let r=o.mul(du.w).xyz;return t==="NORMAL"&&s.flatShading!==!0&&(r=r.toVarying(e)),r}).once(["NORMAL"]),Eh=v(({subBuildFn:o,geometry:e,material:t})=>{let s;return o==="VERTEX"||e.hasAttribute("tangent")?s=vh(Z.cross(hu),"v_bitangentView").normalize():s=Ch,t.flatShading!==!0&&(s=Ds(s)),s},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),ms=Re(hu,Eh,Z).toVar("TBNViewMatrix"),Bh=v(()=>{let o=Wt.cross(oe);return o=o.cross(Wt).normalize(),o=ne(o,Z,St.mul(je.oneMinus()).oneMinus().pow2().pow2()).normalize(),o}).once()();class pu extends fe{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=l.TangentSpaceNormalMap}setup({material:e}){const{normalMapType:t,scaleNode:s}=this;let r=this.node.mul(2).sub(1);if(s!==null){let i=s;e.flatShading===!0&&(i=Ds(i)),r=A(r.xy.mul(i),r.z)}let n=null;return t===l.ObjectSpaceNormalMap?n=eu(r):t===l.TangentSpaceNormalMap?n=ms.mul(r).normalize():(console.error(`THREE.NodeMaterial: Unsupported normal map type: ${t}`),n=Z),n}}const ki=B(pu).setParameterLength(1,2),Mh=v(({textureNode:o,bumpScale:e})=>{const t=r=>o.cache().context({getUV:n=>r(n.uvNode||Ps()),forceUVContext:!0}),s=b(t(r=>r));return w(b(t(r=>r.add(r.dFdx()))).sub(s),b(t(r=>r.add(r.dFdy()))).sub(s)).mul(e)}),Fh=v(o=>{const{surf_pos:e,surf_norm:t,dHdxy:s}=o,r=e.dFdx().normalize(),n=e.dFdy().normalize(),i=t,u=n.cross(i),a=i.cross(r),c=r.dot(u).mul(Za),d=c.sign().mul(s.x.mul(u).add(s.y.mul(a)));return c.abs().mul(t).sub(d).normalize()});class fu extends fe{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=Mh({textureNode:this.textureNode,bumpScale:e});return Fh({surf_pos:ue,surf_norm:Z,dHdxy:t})}}const wh=B(fu).setParameterLength(1,2),zi=new Map;class S extends V{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let s=zi.get(e);return s===void 0&&(s=ot(e,t),zi.set(e,s)),s}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,s=this.scope;let r=null;if(s===S.COLOR){const n=t.color!==void 0?this.getColor(s):A();t.map&&t.map.isTexture===!0?r=n.mul(this.getTexture("map")):r=n}else if(s===S.OPACITY){const n=this.getFloat(s);t.alphaMap&&t.alphaMap.isTexture===!0?r=n.mul(this.getTexture("alpha")):r=n}else if(s===S.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=b(1);else if(s===S.SPECULAR_INTENSITY){const n=this.getFloat(s);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?r=n.mul(this.getTexture(s).a):r=n}else if(s===S.SPECULAR_COLOR){const n=this.getColor(s);t.specularColorMap&&t.specularColorMap.isTexture===!0?r=n.mul(this.getTexture(s).rgb):r=n}else if(s===S.ROUGHNESS){const n=this.getFloat(s);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=n.mul(this.getTexture(s).g):r=n}else if(s===S.METALNESS){const n=this.getFloat(s);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=n.mul(this.getTexture(s).b):r=n}else if(s===S.EMISSIVE){const n=this.getFloat("emissiveIntensity"),i=this.getColor(s).mul(n);t.emissiveMap&&t.emissiveMap.isTexture===!0?r=i.mul(this.getTexture(s)):r=i}else if(s===S.NORMAL)t.normalMap?(r=ki(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType):t.bumpMap?r=wh(this.getTexture("bump").r,this.getFloat("bumpScale")):r=Z;else if(s===S.CLEARCOAT){const n=this.getFloat(s);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=n.mul(this.getTexture(s).r):r=n}else if(s===S.CLEARCOAT_ROUGHNESS){const n=this.getFloat(s);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?r=n.mul(this.getTexture(s).r):r=n}else if(s===S.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=ki(this.getTexture(s),this.getCache(s+"Scale","vec2")):r=Z;else if(s===S.SHEEN){const n=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?r=n.mul(this.getTexture("sheenColor").rgb):r=n}else if(s===S.SHEEN_ROUGHNESS){const n=this.getFloat(s);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?r=n.mul(this.getTexture(s).a):r=n,r=r.clamp(.07,1)}else if(s===S.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const n=this.getTexture(s);r=kn(ts.x,ts.y,ts.y.negate(),ts.x).mul(n.rg.mul(2).sub(w(1)).normalize().mul(n.b))}else r=ts;else if(s===S.IRIDESCENCE_THICKNESS){const n=J("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const i=J("0","float",t.iridescenceThicknessRange);r=n.sub(i).mul(this.getTexture(s).g).add(i)}else r=n}else if(s===S.TRANSMISSION){const n=this.getFloat(s);t.transmissionMap?r=n.mul(this.getTexture(s).r):r=n}else if(s===S.THICKNESS){const n=this.getFloat(s);t.thicknessMap?r=n.mul(this.getTexture(s).g):r=n}else if(s===S.IOR)r=this.getFloat(s);else if(s===S.LIGHT_MAP)r=this.getTexture(s).rgb.mul(this.getFloat("lightMapIntensity"));else if(s===S.AO)r=this.getTexture(s).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(s===S.LINE_DASH_OFFSET)r=t.dashOffset?this.getFloat(s):b(0);else{const n=this.getNodeType(e);r=this.getCache(s,n)}return r}}S.ALPHA_TEST="alphaTest";S.COLOR="color";S.OPACITY="opacity";S.SHININESS="shininess";S.SPECULAR="specular";S.SPECULAR_STRENGTH="specularStrength";S.SPECULAR_INTENSITY="specularIntensity";S.SPECULAR_COLOR="specularColor";S.REFLECTIVITY="reflectivity";S.ROUGHNESS="roughness";S.METALNESS="metalness";S.NORMAL="normal";S.CLEARCOAT="clearcoat";S.CLEARCOAT_ROUGHNESS="clearcoatRoughness";S.CLEARCOAT_NORMAL="clearcoatNormal";S.EMISSIVE="emissive";S.ROTATION="rotation";S.SHEEN="sheen";S.SHEEN_ROUGHNESS="sheenRoughness";S.ANISOTROPY="anisotropy";S.IRIDESCENCE="iridescence";S.IRIDESCENCE_IOR="iridescenceIOR";S.IRIDESCENCE_THICKNESS="iridescenceThickness";S.IOR="ior";S.TRANSMISSION="transmission";S.THICKNESS="thickness";S.ATTENUATION_DISTANCE="attenuationDistance";S.ATTENUATION_COLOR="attenuationColor";S.LINE_SCALE="scale";S.LINE_DASH_SIZE="dashSize";S.LINE_GAP_SIZE="gapSize";S.LINE_WIDTH="linewidth";S.LINE_DASH_OFFSET="dashOffset";S.POINT_SIZE="size";S.DISPERSION="dispersion";S.LIGHT_MAP="light";S.AO="ao";const Ph=P(S,S.ALPHA_TEST),Dh=P(S,S.COLOR),Lh=P(S,S.SHININESS),Uh=P(S,S.EMISSIVE),gu=P(S,S.OPACITY),Gh=P(S,S.SPECULAR),$i=P(S,S.SPECULAR_INTENSITY),Ih=P(S,S.SPECULAR_COLOR),tr=P(S,S.SPECULAR_STRENGTH),Pr=P(S,S.REFLECTIVITY),Oh=P(S,S.ROUGHNESS),Vh=P(S,S.METALNESS),kh=P(S,S.NORMAL),zh=P(S,S.CLEARCOAT),$h=P(S,S.CLEARCOAT_ROUGHNESS),Wh=P(S,S.CLEARCOAT_NORMAL),Hh=P(S,S.ROTATION),qh=P(S,S.SHEEN),Xh=P(S,S.SHEEN_ROUGHNESS),Kh=P(S,S.ANISOTROPY),Qh=P(S,S.IRIDESCENCE),Yh=P(S,S.IRIDESCENCE_IOR),jh=P(S,S.IRIDESCENCE_THICKNESS),Zh=P(S,S.TRANSMISSION),Jh=P(S,S.THICKNESS),ep=P(S,S.IOR),tp=P(S,S.ATTENUATION_DISTANCE),sp=P(S,S.ATTENUATION_COLOR),rp=P(S,S.LINE_SCALE),np=P(S,S.LINE_DASH_SIZE),ip=P(S,S.LINE_GAP_SIZE);S.LINE_WIDTH;const op=P(S,S.LINE_DASH_OFFSET),ap=P(S,S.POINT_SIZE),up=P(S,S.DISPERSION),mu=P(S,S.LIGHT_MAP),lp=P(S,S.AO),ts=O(new l.Vector2).onReference(function(o){return o.material}).onRenderUpdate(function({material:o}){this.value.set(o.anisotropy*Math.cos(o.anisotropyRotation),o.anisotropy*Math.sin(o.anisotropyRotation))}),Tu=v(o=>o.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class re extends V{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),s=this.scope;let r;if(s===re.VERTEX)r=e.getVertexIndex();else if(s===re.INSTANCE)r=e.getInstanceIndex();else if(s===re.DRAW)r=e.getDrawIndex();else if(s===re.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(s===re.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(s===re.SUBGROUP)r=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+s);let n;return e.shaderStage==="vertex"||e.shaderStage==="compute"?n=r:n=ht(this).build(e,t),n}}re.VERTEX="vertex";re.INSTANCE="instance";re.SUBGROUP="subgroup";re.INVOCATION_LOCAL="invocationLocal";re.INVOCATION_SUBGROUP="invocationSubgroup";re.DRAW="draw";const cp=P(re,re.VERTEX),ui=P(re,re.INSTANCE);re.SUBGROUP;re.INVOCATION_SUBGROUP;re.INVOCATION_LOCAL;const dp=P(re,re.DRAW);class yu extends V{static get type(){return"InstanceNode"}constructor(e,t,s=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=s,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=z.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:s,instanceColor:r}=this;let{instanceMatrixNode:n,instanceColorNode:i}=this;if(n===null){if(t<=1e3)n=Xa(s.array,"mat4",Math.max(t,1)).element(ui);else{const a=new l.InstancedInterleavedBuffer(s.array,16,1);this.buffer=a;const c=s.usage===l.DynamicDrawUsage?Pi:wi,d=[c(a,"vec4",16,0),c(a,"vec4",16,4),c(a,"vec4",16,8),c(a,"vec4",16,12)];n=$t(...d)}this.instanceMatrixNode=n}if(r&&i===null){const a=new l.InstancedBufferAttribute(r.array,3),c=r.usage===l.DynamicDrawUsage?Pi:wi;this.bufferColor=a,i=A(c(a,"vec3",3,0)),this.instanceColorNode=i}const u=n.mul(Te).xyz;if(Te.assign(u),e.hasGeometryAttribute("normal")){const a=fh(Xe,n);Xe.assign(a)}this.instanceColorNode!==null&&ar("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==l.DynamicDrawUsage&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==l.DynamicDrawUsage&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}class xu extends yu{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:s,instanceColor:r}=e;super(t,s,r),this.instancedMesh=e}}const hp=B(xu).setParameterLength(1);class _u extends V{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=ui:this.batchingIdNode=dp);const s=v(([g])=>{const m=se(Ht(Ie(this.batchMesh._indirectTexture),0).x),y=se(g).mod(m),_=se(g).div(m);return Ie(this.batchMesh._indirectTexture,Ye(y,_)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(se(this.batchingIdNode)),r=this.batchMesh._matricesTexture,n=se(Ht(Ie(r),0).x),i=b(s).mul(4).toInt().toVar(),u=i.mod(n),a=i.div(n),c=$t(Ie(r,Ye(u,a)),Ie(r,Ye(u.add(1),a)),Ie(r,Ye(u.add(2),a)),Ie(r,Ye(u.add(3),a))),d=this.batchMesh._colorsTexture;if(d!==null){const m=v(([y])=>{const _=se(Ht(Ie(d),0).x),C=y,R=C.mod(_),U=C.div(_);return Ie(d,Ye(R,U)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(s);ar("vec3","vBatchColor").assign(m)}const h=Re(c);Te.assign(c.mul(Te));const p=Xe.div(A(h[0].dot(h[0]),h[1].dot(h[1]),h[2].dot(h[2]))),f=h.mul(p).xyz;Xe.assign(f),e.hasGeometryAttribute("tangent")&&ai.mulAssign(h)}}const pp=B(_u).setParameterLength(1),Wi=new WeakMap;class Su extends V{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=z.OBJECT,this.skinIndexNode=ct("skinIndex","uvec4"),this.skinWeightNode=ct("skinWeight","vec4"),this.bindMatrixNode=J("bindMatrix","mat4"),this.bindMatrixInverseNode=J("bindMatrixInverse","mat4"),this.boneMatricesNode=Oi("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Te,this.toPositionNode=Te,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:s,skinWeightNode:r,bindMatrixNode:n,bindMatrixInverseNode:i}=this,u=e.element(s.x),a=e.element(s.y),c=e.element(s.z),d=e.element(s.w),h=n.mul(t),p=Ce(u.mul(r.x).mul(h),a.mul(r.y).mul(h),c.mul(r.z).mul(h),d.mul(r.w).mul(h));return i.mul(p).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=Xe){const{skinIndexNode:s,skinWeightNode:r,bindMatrixNode:n,bindMatrixInverseNode:i}=this,u=e.element(s.x),a=e.element(s.y),c=e.element(s.z),d=e.element(s.w);let h=Ce(r.x.mul(u),r.y.mul(a),r.z.mul(c),r.w.mul(d));return h=i.mul(h).mul(n),h.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Oi("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Gi)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||ta(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&Gi.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const s=this.getSkinnedNormal();Xe.assign(s),e.hasGeometryAttribute("tangent")&&ai.assign(s)}return t}generate(e,t){if(t!=="void")return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;Wi.get(t)!==e.frameId&&(Wi.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const fp=o=>E(new Su(o));class Nu extends V{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const s={};for(let i=0,u=this.params.length-1;i<u;i++){const a=this.params[i],c=a.isNode!==!0&&a.name||this.getVarName(i),d=a.isNode!==!0&&a.type||"int";s[c]=Qt(c,d)}const r=e.addStack();t.returnsNode=this.params[this.params.length-1](s,e),t.stackNode=r;const n=this.params[0];return n.isNode!==!0&&typeof n.update=="function"&&(t.updateNode=v(this.params[0].update)(s)),e.removeStack(),t}getNodeType(e){const{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):"void"}setup(e){this.getProperties(e)}generate(e){const t=this.getProperties(e),s=this.params,r=t.stackNode;for(let u=0,a=s.length-1;u<a;u++){const c=s[u];let d=!1,h=null,p=null,f=null,g=null,m=null,y=null;c.isNode?c.getNodeType(e)==="bool"?(d=!0,g="bool",p=c.build(e,g)):(g="int",f=this.getVarName(u),h="0",p=c.build(e,g),m="<"):(g=c.type||"int",f=c.name||this.getVarName(u),h=c.start,p=c.end,m=c.condition,y=c.update,typeof h=="number"?h=e.generateConst(g,h):h&&h.isNode&&(h=h.build(e,g)),typeof p=="number"?p=e.generateConst(g,p):p&&p.isNode&&(p=p.build(e,g)),h!==void 0&&p===void 0?(h=h+" - 1",p="0",m=">="):p!==void 0&&h===void 0&&(h="0",m="<"),m===void 0&&(Number(h)>Number(p)?m=">=":m="<"));let _;if(d)_=`while ( ${p} )`;else{const C={start:h,end:p},R=C.start,U=C.end;let M;const D=()=>m.includes("<")?"+=":"-=";if(y!=null)switch(typeof y){case"function":M=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":M=f+" "+D()+" "+e.generateConst(g,y);break;case"string":M=f+" "+y;break;default:y.isNode?M=f+" "+D()+" "+y.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),M="break /* invalid update */")}else g==="int"||g==="uint"?y=m.includes("<")?"++":"--":y=D()+" 1.",M=f+" "+y;const F=e.getVar(g,f)+" = "+R,L=f+" "+m+" "+U;_=`for ( ${F}; ${L}; ${M} )`}e.addFlowCode((u===0?`
23
- `:"")+e.tab+_+` {
24
-
25
- `).addFlowTab()}const n=r.build(e,"void"),i=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(`
26
- `+e.tab+n);for(let u=0,a=this.params.length-1;u<a;u++)e.addFlowCode((u===0?"":e.tab)+`}
27
-
28
- `).removeFlowTab();return e.addFlowTab(),i}}const Ve=(...o)=>E(new Nu(zt(o,"int"))).toStack(),gp=()=>Qt("break").toStack(),Dr=new WeakMap,Ee=new l.Vector4,Hi=v(({bufferMap:o,influence:e,stride:t,width:s,depth:r,offset:n})=>{const i=se(cp).mul(t).add(n),u=i.div(s),a=i.sub(u.mul(s));return Ie(o,Ye(a,u)).depth(r).xyz.mul(e)});function mp(o){const e=o.morphAttributes.position!==void 0,t=o.morphAttributes.normal!==void 0,s=o.morphAttributes.color!==void 0,r=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,n=r!==void 0?r.length:0;let i=Dr.get(o);if(i===void 0||i.count!==n){let _=function(){m.dispose(),Dr.delete(o),o.removeEventListener("dispose",_)};i!==void 0&&i.texture.dispose();const u=o.morphAttributes.position||[],a=o.morphAttributes.normal||[],c=o.morphAttributes.color||[];let d=0;e===!0&&(d=1),t===!0&&(d=2),s===!0&&(d=3);let h=o.attributes.position.count*d,p=1;const f=4096;h>f&&(p=Math.ceil(h/f),h=f);const g=new Float32Array(h*p*4*n),m=new l.DataArrayTexture(g,h,p,n);m.type=l.FloatType,m.needsUpdate=!0;const y=d*4;for(let C=0;C<n;C++){const R=u[C],U=a[C],M=c[C],D=h*p*4*C;for(let F=0;F<R.count;F++){const L=F*y;e===!0&&(Ee.fromBufferAttribute(R,F),g[D+L+0]=Ee.x,g[D+L+1]=Ee.y,g[D+L+2]=Ee.z,g[D+L+3]=0),t===!0&&(Ee.fromBufferAttribute(U,F),g[D+L+4]=Ee.x,g[D+L+5]=Ee.y,g[D+L+6]=Ee.z,g[D+L+7]=0),s===!0&&(Ee.fromBufferAttribute(M,F),g[D+L+8]=Ee.x,g[D+L+9]=Ee.y,g[D+L+10]=Ee.z,g[D+L+11]=M.itemSize===4?Ee.w:1)}}i={count:n,texture:m,stride:d,size:new l.Vector2(h,p)},Dr.set(o,i),o.addEventListener("dispose",_)}return i}class bu extends V{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=O(1),this.updateType=z.OBJECT}setup(e){const{geometry:t}=e,s=t.morphAttributes.position!==void 0,r=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,n=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,i=n!==void 0?n.length:0,{texture:u,stride:a,size:c}=mp(t);s===!0&&Te.mulAssign(this.morphBaseInfluence),r===!0&&Xe.mulAssign(this.morphBaseInfluence);const d=se(c.width);Ve(i,({i:h})=>{const p=b(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?p.assign(Ie(this.mesh.morphTexture,Ye(se(h).add(1),se(ui))).r):p.assign(J("morphTargetInfluences","float").element(h).toVar()),le(p.notEqual(0),()=>{s===!0&&Te.addAssign(Hi({bufferMap:u,influence:p,stride:a,width:d,depth:h,offset:se(0)})),r===!0&&Xe.addAssign(Hi({bufferMap:u,influence:p,stride:a,width:d,depth:h,offset:se(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,s)=>t+s,0)}}const Tp=B(bu).setParameterLength(1);class Ft extends V{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class Ru extends Ft{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Au extends Yn{static get type(){return"LightingContextNode"}constructor(e,t=null,s=null,r=null){super(e),this.lightingModel=t,this.backdropNode=s,this.backdropAlphaNode=r,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,s=A().toVar("directDiffuse"),r=A().toVar("directSpecular"),n=A().toVar("indirectDiffuse"),i=A().toVar("indirectSpecular"),u={directDiffuse:s,directSpecular:r,indirectDiffuse:n,indirectSpecular:i};return{radiance:A().toVar("radiance"),irradiance:A().toVar("irradiance"),iblIrradiance:A().toVar("iblIrradiance"),ambientOcclusion:b(1).toVar("ambientOcclusion"),reflectedLight:u,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const yp=B(Au);class Cu extends Ft{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let ss,rs;class ae extends V{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===ae.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=z.NONE;return(this.scope===ae.SIZE||this.scope===ae.VIEWPORT)&&(e=z.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===ae.VIEWPORT?t!==null?rs.copy(t.viewport):(e.getViewport(rs),rs.multiplyScalar(e.getPixelRatio())):t!==null?(ss.width=t.width,ss.height=t.height):e.getDrawingBufferSize(ss)}setup(){const e=this.scope;let t=null;return e===ae.SIZE?t=O(ss||(ss=new l.Vector2)):e===ae.VIEWPORT?t=O(rs||(rs=new l.Vector4)):t=w(Sr.div(Rn)),t}generate(e){if(this.scope===ae.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const s=e.getNodeProperties(Rn).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${s}.y - ${t}.y )`}return t}return super.generate(e)}}ae.COORDINATE="coordinate";ae.VIEWPORT="viewport";ae.SIZE="size";ae.UV="uv";const qt=P(ae,ae.UV),Rn=P(ae,ae.SIZE),Sr=P(ae,ae.COORDINATE),bs=P(ae,ae.VIEWPORT);bs.zw;bs.xy;const ns=new l.Vector2;class li extends Mt{static get type(){return"ViewportTextureNode"}constructor(e=qt,t=null,s=null){s===null&&(s=new l.FramebufferTexture,s.minFilter=l.LinearMipmapLinearFilter),super(s,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=z.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(ns);const s=this.value;(s.image.width!==ns.width||s.image.height!==ns.height)&&(s.image.width=ns.width,s.image.height=ns.height,s.needsUpdate=!0);const r=s.generateMipmaps;s.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(s),s.generateMipmaps=r}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const vu=B(li,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let Lr=null;class Eu extends li{static get type(){return"ViewportDepthTextureNode"}constructor(e=qt,t=null){Lr===null&&(Lr=new l.DepthTexture),super(e,t,Lr)}}const xp=B(Eu).setParameterLength(0,2);class Ne extends V{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Ne.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,s=this.valueNode;let r=null;if(t===Ne.DEPTH_BASE)s!==null&&(r=Fu().assign(s));else if(t===Ne.DEPTH)e.isPerspectiveCamera?r=_p(ue.z,bt,Rt):r=Rs(ue.z,bt,Rt);else if(t===Ne.LINEAR_DEPTH)if(s!==null)if(e.isPerspectiveCamera){const n=Bu(s,bt,Rt);r=Rs(n,bt,Rt)}else r=s;else r=Rs(ue.z,bt,Rt);return r}}Ne.DEPTH_BASE="depthBase";Ne.DEPTH="depth";Ne.LINEAR_DEPTH="linearDepth";const Rs=(o,e,t)=>o.add(e).div(e.sub(t)),_p=(o,e,t)=>e.add(o).mul(t).div(t.sub(e).mul(o)),Bu=(o,e,t)=>e.mul(t).div(t.sub(e).mul(o).sub(t)),Mu=(o,e,t)=>{e=e.max(1e-6).toVar();const s=Ze(o.negate().div(e)),r=Ze(t.div(e));return s.div(r)},Fu=B(Ne,Ne.DEPTH_BASE),wu=P(Ne,Ne.DEPTH),Sp=B(Ne,Ne.LINEAR_DEPTH).setParameterLength(0,1);xp();wu.assign=o=>Fu(o);class De extends V{static get type(){return"ClippingNode"}constructor(e=De.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:s,unionPlanes:r}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===De.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(s,r):this.scope===De.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(s,r)}setupAlphaToCoverage(e,t){return v(()=>{const s=b().toVar("distanceToPlane"),r=b().toVar("distanceToGradient"),n=b(1).toVar("clipOpacity"),i=t.length;if(this.hardwareClipping===!1&&i>0){const a=We(t);Ve(i,({i:c})=>{const d=a.element(c);s.assign(ue.dot(d.xyz).negate().add(d.w)),r.assign(s.fwidth().div(2)),n.mulAssign(lt(r.negate(),r,s))})}const u=e.length;if(u>0){const a=We(e),c=b(1).toVar("intersectionClipOpacity");Ve(u,({i:d})=>{const h=a.element(d);s.assign(ue.dot(h.xyz).negate().add(h.w)),r.assign(s.fwidth().div(2)),c.mulAssign(lt(r.negate(),r,s).oneMinus())}),n.mulAssign(c.oneMinus())}K.a.mulAssign(n),K.a.equal(0).discard()})()}setupDefault(e,t){return v(()=>{const s=t.length;if(this.hardwareClipping===!1&&s>0){const n=We(t);Ve(s,({i})=>{const u=n.element(i);ue.dot(u.xyz).greaterThan(u.w).discard()})}const r=e.length;if(r>0){const n=We(e),i=Vn(!0).toVar("clipped");Ve(r,({i:u})=>{const a=n.element(u);i.assign(ue.dot(a.xyz).greaterThan(a.w).and(i))}),i.discard()}})()}setupHardwareClipping(e,t){const s=e.length;return t.enableHardwareClipping(s),v(()=>{const r=We(e),n=Tr(t.getClipDistance());Ve(s,({i})=>{const u=r.element(i),a=ue.dot(u.xyz).sub(u.w).negate();n.element(i).assign(a)})})()}}De.ALPHA_TO_COVERAGE="alphaToCoverage";De.DEFAULT="default";De.HARDWARE="hardware";const Np=()=>E(new De),bp=()=>E(new De(De.ALPHA_TO_COVERAGE)),Rp=()=>E(new De(De.HARDWARE)),Ap=.05,qi=v(([o])=>dt($(1e4,Oe($(17,o.x).add($(.1,o.y)))).mul(Ce(.1,we(Oe($(13,o.y).add(o.x))))))),Xi=v(([o])=>qi(w(qi(o.xy),o.z))),Cp=v(([o])=>{const e=ye(Je(Aa(o.xyz)),Je(Ca(o.xyz))),t=b(1).div(b(Ap).mul(e)).toVar("pixScale"),s=w(vs(vt(Ze(t))),vs(Kn(Ze(t)))),r=w(Xi(vt(s.x.mul(o.xyz))),Xi(vt(s.y.mul(o.xyz)))),n=dt(Ze(t)),i=Ce($(n.oneMinus(),r.x),$(n,r.y)),u=Kt(n,n.oneMinus()),a=A(i.mul(i).div($(2,u).mul(_e(1,u))),i.sub($(.5,u)).div(_e(1,u)),_e(1,_e(1,i).mul(_e(1,i)).div($(2,u).mul(_e(1,u))))),c=i.lessThan(u.oneMinus()).select(i.lessThan(u).select(a.x,a.y),a.z);return et(c,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class Pu extends ni{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),s=e.hasGeometryAttribute(t);let r;return s===!0?r=super.generate(e):r=e.generateConst(this.nodeType,new l.Vector4(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const vp=(o=0)=>E(new Pu(o)),Ep=v(([o])=>k(o.rgb.mul(o.a),o.a),{color:"vec4",return:"vec4"});class ce extends l.Material{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+Jo(this)}build(e){this.setup(e)}setupObserver(e){return new Zo(e)}setup(e){e.context.setupNormal=()=>Ss(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,s=t.getRenderTarget();e.addStack();const r=Ss(this.setupVertex(e),"VERTEX"),n=this.vertexNode||r;e.stack.outputNode=n,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let i;const u=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(s!==null?s.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const a=this.setupLighting(e);u!==null&&e.stack.add(u);const c=k(a,K.a).max(0);i=this.setupOutput(e,c),xs.assign(i);const d=this.outputNode!==null;if(d&&(i=this.outputNode),s!==null){const h=t.getMRT(),p=this.mrtNode;h!==null?(d&&xs.assign(i),i=h,p!==null&&(i=h.merge(p))):p!==null&&(i=p)}}else{let a=this.fragmentNode;a.isOutputStructNode!==!0&&(a=k(a)),i=this.setupOutput(e,a)}e.stack.outputNode=i,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:s}=e.clippingContext;let r=null;if(t.length>0||s.length>0){const n=e.renderer.samples;this.alphaToCoverage&&n>1?r=bp():e.stack.add(Np())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(Rp()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:s}=e;let r=this.depthNode;if(r===null){const n=t.getMRT();n&&n.has("depth")?r=n.get("depth"):t.logarithmicDepthBuffer===!0&&(s.isPerspectiveCamera?r=Mu(ue.z,bt,Rt):r=Rs(ue.z,bt,Rt))}r!==null&&wu.assign(r).toStack()}setupPositionView(){return yr.mul(Te).xyz}setupModelViewProjection(){return oi.mul(ue)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),Tu}setupPosition(e){const{object:t,geometry:s}=e;if((s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color)&&Tp(t).toStack(),t.isSkinnedMesh===!0&&fp(t).toStack(),this.displacementMap){const r=ot("displacementMap","texture"),n=ot("displacementScale","float"),i=ot("displacementBias","float");Te.addAssign(Xe.normalize().mul(r.x.mul(n).add(i)))}return t.isBatchedMesh&&pp(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&hp(t).toStack(),this.positionNode!==null&&Te.assign(Ss(this.positionNode,"POSITION","vec3")),Te}setupDiffuseColor({object:e,geometry:t}){this.maskNode!==null&&Vn(this.maskNode).not().discard();let s=this.colorNode?k(this.colorNode):Dh;this.vertexColors===!0&&t.hasAttribute("color")&&(s=s.mul(vp())),e.instanceColor&&(s=ar("vec3","vInstanceColor").mul(s)),e.isBatchedMesh&&e._colorsTexture&&(s=ar("vec3","vBatchColor").mul(s)),K.assign(s);const r=this.opacityNode?b(this.opacityNode):gu;K.a.assign(K.a.mul(r));let n=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(n=this.alphaTestNode!==null?b(this.alphaTestNode):Ph,K.a.lessThanEqual(n).discard()),this.alphaHash===!0&&K.a.lessThan(Cp(Te)).discard(),this.transparent===!1&&this.blending===l.NormalBlending&&this.alphaToCoverage===!1?K.a.assign(1):n===null&&K.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?A(0):K.rgb}setupNormal(){return this.normalNode?A(this.normalNode):kh}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?ot("envMap","cubeTexture"):ot("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Cu(mu)),t}setupLights(e){const t=[],s=this.setupEnvironment(e);s&&s.isLightingNode&&t.push(s);const r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){const i=this.aoNode!==null?this.aoNode:lp;t.push(new Ru(i))}let n=this.lightsNode||e.lightsNode;return t.length>0&&(n=e.renderer.lighting.createNode([...n.getLights(),...t])),n}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:s,backdropAlphaNode:r,emissiveNode:n}=this,u=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let a=this.setupOutgoingLight(e);if(u&&u.getScope().hasLights){const c=this.setupLightingModel(e)||null;a=yp(u,c,s,r)}else s!==null&&(a=A(r!==null?ne(a,s,r):s));return(n&&n.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(Mi.assign(A(n||Uh)),a=a.add(Mi)),a}setupFog(e,t){const s=e.fogNode;return s&&(xs.assign(t),t=k(s)),t}setupPremultipliedAlpha(e,t){return Ep(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(const s in e){const r=e[s];this[s]===void 0&&(this[s]=r,r&&r.clone&&(this[s]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const s in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,s)===void 0&&t[s].get!==void 0&&Object.defineProperty(this.constructor.prototype,s,t[s])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const s=l.Material.prototype.toJSON.call(this,e),r=nr(this);s.inputNodes={};for(const{property:i,childNode:u}of r)s.inputNodes[i]=u.toJSON(e).uuid;function n(i){const u=[];for(const a in i){const c=i[a];delete c.metadata,u.push(c)}return u}if(t){const i=n(e.textures),u=n(e.images),a=n(e.nodes);i.length>0&&(s.textures=i),u.length>0&&(s.images=u),a.length>0&&(s.nodes=a)}return s}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const Bp=new l.LineBasicMaterial;class Du extends ce{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(Bp),this.setValues(e)}}const Mp=new l.LineDashedMaterial;class Lu extends ce{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(Mp),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?b(this.offsetNode):op,t=this.dashScaleNode?b(this.dashScaleNode):rp,s=this.dashSizeNode?b(this.dashSizeNode):np,r=this.gapSizeNode?b(this.gapSizeNode):ip;Mr.assign(s),Fi.assign(r);const n=ht(ct("lineDistance").mul(t));(e?n.add(e):n).mod(Mr.add(Fi)).greaterThan(Mr).discard()}}const Fp=o=>E(o).mul(.5).add(.5),wp=new l.MeshNormalMaterial;class Uu extends ce{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(wp),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?b(this.opacityNode):gu;K.assign(ti(k(Fp(Z),e),l.SRGBColorSpace))}}const Gu=v(([o=Ya])=>{const e=o.z.atan(o.x).mul(1/(Math.PI*2)).add(.5),t=o.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return w(e,t)});class Iu extends l.WebGLCubeRenderTarget{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const s=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n=new l.BoxGeometry(5,5,5),i=Gu(Ya),u=new ce;u.colorNode=X(t,i,0),u.side=l.BackSide,u.blending=l.NoBlending;const a=new l.Mesh(n,u),c=new l.Scene;c.add(a),t.minFilter===l.LinearMipmapLinearFilter&&(t.minFilter=l.LinearFilter);const d=new l.CubeCamera(1,10,this),h=e.getMRT();return e.setMRT(null),d.update(e,c),e.setMRT(h),t.minFilter=s,t.currentGenerateMipmaps=r,a.geometry.dispose(),a.material.dispose(),this}}const As=new WeakMap;class Pp extends fe{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Fs(null);const t=new l.CubeTexture;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=z.RENDER}updateBefore(e){const{renderer:t,material:s}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const n=r.isTextureNode?r.value:s[r.property];if(n&&n.isTexture){const i=n.mapping;if(i===l.EquirectangularReflectionMapping||i===l.EquirectangularRefractionMapping){if(As.has(n)){const u=As.get(n);Ki(u,n.mapping),this._cubeTexture=u}else{const u=n.image;if(Dp(u)){const a=new Iu(u.height);a.fromEquirectangularTexture(t,n),Ki(a.texture,n.mapping),this._cubeTexture=a.texture,As.set(n,a.texture),n.addEventListener("dispose",Ou)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function Dp(o){return o==null?!1:o.height>0}function Ou(o){const e=o.target;e.removeEventListener("dispose",Ou);const t=As.get(e);t!==void 0&&(As.delete(e),t.dispose())}function Ki(o,e){e===l.EquirectangularReflectionMapping?o.mapping=l.CubeReflectionMapping:e===l.EquirectangularRefractionMapping&&(o.mapping=l.CubeRefractionMapping)}const Vu=B(Pp).setParameterLength(1);class Nr extends Ft{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=Vu(this.envNode)}}class Lp extends Ft{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=b(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class Ls{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class ku extends Ls{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,s=e.reflectedLight,r=e.irradianceLightMap;s.indirectDiffuse.assign(k(0)),r?s.indirectDiffuse.addAssign(r):s.indirectDiffuse.addAssign(k(1,1,1,0)),s.indirectDiffuse.mulAssign(t),s.indirectDiffuse.mulAssign(K.rgb)}finish(e){const{material:t,context:s}=e,r=s.outgoingLight,n=e.context.environment;if(n)switch(t.combine){case l.MultiplyOperation:r.rgb.assign(ne(r.rgb,r.rgb.mul(n.rgb),tr.mul(Pr)));break;case l.MixOperation:r.rgb.assign(ne(r.rgb,n.rgb,tr.mul(Pr)));break;case l.AddOperation:r.rgb.addAssign(n.rgb.mul(tr.mul(Pr)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine);break}}}const Up=new l.MeshBasicMaterial;class zu extends ce{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Up),this.setValues(e)}setupNormal(){return Ds(Ms)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Nr(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Lp(mu)),t}setupOutgoingLight(){return K.rgb}setupLightingModel(){return new ku}}const ws=v(({f0:o,f90:e,dotVH:t})=>{const s=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return o.mul(s.oneMinus()).add(e.mul(s))}),Yt=v(o=>o.diffuseColor.mul(1/Math.PI)),Gp=()=>b(.25),Ip=v(({dotNH:o})=>xn.mul(b(.5)).add(1).mul(b(1/Math.PI)).mul(o.pow(xn))),Op=v(({lightDirection:o})=>{const e=o.add(oe).normalize(),t=Z.dot(e).clamp(),s=oe.dot(e).clamp(),r=ws({f0:Be,f90:1,dotVH:s}),n=Gp(),i=Ip({dotNH:t});return r.mul(n).mul(i)});class ci extends ku{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:s}){const n=Z.dot(e).clamp().mul(t);s.directDiffuse.addAssign(n.mul(Yt({diffuseColor:K.rgb}))),this.specular===!0&&s.directSpecular.addAssign(n.mul(Op({lightDirection:e})).mul(tr))}indirect(e){const{ambientOcclusion:t,irradiance:s,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(s.mul(Yt({diffuseColor:K}))),r.indirectDiffuse.mulAssign(t)}}const Vp=new l.MeshLambertMaterial;class $u extends ce{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Vp),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Nr(t):null}setupLightingModel(){return new ci(!1)}}const kp=new l.MeshPhongMaterial;class Wu extends ce{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(kp),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Nr(t):null}setupLightingModel(){return new ci}setupVariants(){const e=(this.shininessNode?b(this.shininessNode):Lh).max(1e-4);xn.assign(e);const t=this.specularNode||Gh;Be.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const zp=v(o=>{if(o.geometry.hasAttribute("normal")===!1)return b(0);const e=Ms.dFdx().abs().max(Ms.dFdy().abs());return e.x.max(e.y).max(e.z)}),Hu=v(o=>{const{roughness:e}=o,t=zp();let s=e.max(.0525);return s=s.add(t),s=s.min(1),s}),$p=v(({alpha:o,dotNL:e,dotNV:t})=>{const s=o.pow2(),r=e.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt()),n=t.mul(s.add(s.oneMinus().mul(e.pow2())).sqrt());return qe(.5,r.add(n).max(nd))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Wp=v(({alphaT:o,alphaB:e,dotTV:t,dotBV:s,dotTL:r,dotBL:n,dotNV:i,dotNL:u})=>{const a=u.mul(A(o.mul(t),e.mul(s),i).length()),c=i.mul(A(o.mul(r),e.mul(n),u).length());return qe(.5,a.add(c)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),Hp=v(({alpha:o,dotNH:e})=>{const t=o.pow2(),s=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(s.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),qp=b(1/Math.PI),Xp=v(({alphaT:o,alphaB:e,dotNH:t,dotTH:s,dotBH:r})=>{const n=o.mul(e),i=A(e.mul(s),o.mul(r),n.mul(t)),u=i.dot(i),a=n.div(u);return qp.mul(n.mul(a.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),Qi=v(({lightDirection:o,f0:e,f90:t,roughness:s,f:r,normalView:n=Z,USE_IRIDESCENCE:i,USE_ANISOTROPY:u})=>{const a=s.pow2(),c=o.add(oe).normalize(),d=n.dot(o).clamp(),h=n.dot(oe).clamp(),p=n.dot(c).clamp(),f=oe.dot(c).clamp();let g=ws({f0:e,f90:t,dotVH:f}),m,y;if(Bi(i)&&(g=$n.mix(g,r)),Bi(u)){const _=Zs.dot(o),C=Zs.dot(oe),R=Zs.dot(c),U=Wt.dot(o),M=Wt.dot(oe),D=Wt.dot(c);m=Wp({alphaT:yn,alphaB:a,dotTV:C,dotBV:M,dotTL:_,dotBL:U,dotNV:h,dotNL:d}),y=Xp({alphaT:yn,alphaB:a,dotNH:p,dotTH:R,dotBH:D})}else m=$p({alpha:a,dotNL:d,dotNV:h}),y=Hp({alpha:a,dotNH:p});return g.mul(m).mul(y)}),qu=v(({roughness:o,dotNV:e})=>{const t=k(-1,-.0275,-.572,.022),s=k(1,.0425,1.04,-.04),r=o.mul(t).add(s),n=r.x.mul(r.x).min(e.mul(-9.28).exp2()).mul(r.x).add(r.y);return w(-1.04,1.04).mul(n).add(r.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),Xu=v(o=>{const{dotNV:e,specularColor:t,specularF90:s,roughness:r}=o,n=qu({dotNV:e,roughness:r});return t.mul(n.x).add(s.mul(n.y))}),Kp=v(({f:o,f90:e,dotVH:t})=>{const s=t.oneMinus().saturate(),r=s.mul(s),n=s.mul(r,r).clamp(0,.9999);return o.sub(A(e).mul(n)).div(n.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),Qp=v(({roughness:o,dotNH:e})=>{const t=o.pow2(),s=b(1).div(t),n=e.pow2().oneMinus().max(.0078125);return b(2).add(s).mul(n.pow(s.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),Yp=v(({dotNV:o,dotNL:e})=>b(1).div(b(4).mul(e.add(o).sub(e.mul(o))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),jp=v(({lightDirection:o})=>{const e=o.add(oe).normalize(),t=Z.dot(o).clamp(),s=Z.dot(oe).clamp(),r=Z.dot(e).clamp(),n=Qp({roughness:zn,dotNH:r}),i=Yp({dotNV:s,dotNL:t});return It.mul(n).mul(i)}),Zp=v(({N:o,V:e,roughness:t})=>{const n=.0078125,i=o.dot(e).saturate(),u=w(t,i.oneMinus().sqrt());return u.assign(u.mul(.984375).add(n)),u}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),Jp=v(({f:o})=>{const e=o.length();return ye(e.mul(e).add(o.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),Gs=v(({v1:o,v2:e})=>{const t=o.dot(e),s=t.abs().toVar(),r=s.mul(.0145206).add(.4965155).mul(s).add(.8543985).toVar(),n=s.add(4.1616724).mul(s).add(3.417594).toVar(),i=r.div(n),u=t.greaterThan(0).select(i,ye(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(i));return o.cross(e).mul(u)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),Yi=v(({N:o,V:e,P:t,mInv:s,p0:r,p1:n,p2:i,p3:u})=>{const a=n.sub(r).toVar(),c=u.sub(r).toVar(),d=a.cross(c),h=A().toVar();return le(d.dot(t.sub(r)).greaterThanEqual(0),()=>{const p=e.sub(o.mul(e.dot(o))).normalize(),f=o.cross(p).negate(),g=s.mul(Re(p,f,o).transpose()).toVar(),m=g.mul(r.sub(t)).normalize().toVar(),y=g.mul(n.sub(t)).normalize().toVar(),_=g.mul(i.sub(t)).normalize().toVar(),C=g.mul(u.sub(t)).normalize().toVar(),R=A(0).toVar();R.addAssign(Gs({v1:m,v2:y})),R.addAssign(Gs({v1:y,v2:_})),R.addAssign(Gs({v1:_,v2:C})),R.addAssign(Gs({v1:C,v2:m})),h.assign(A(Jp({f:R})))}),h}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),br=1/6,Ku=o=>$(br,$(o,$(o,o.negate().add(3)).sub(3)).add(1)),An=o=>$(br,$(o,$(o,$(3,o).sub(6))).add(4)),Qu=o=>$(br,$(o,$(o,$(-3,o).add(3)).add(3)).add(1)),Cn=o=>$(br,mr(o,3)),ji=o=>Ku(o).add(An(o)),Zi=o=>Qu(o).add(Cn(o)),Ji=o=>Ce(-1,An(o).div(Ku(o).add(An(o)))),eo=o=>Ce(1,Cn(o).div(Qu(o).add(Cn(o)))),to=(o,e,t)=>{const s=o.uvNode,r=$(s,e.zw).add(.5),n=vt(r),i=dt(r),u=ji(i.x),a=Zi(i.x),c=Ji(i.x),d=eo(i.x),h=Ji(i.y),p=eo(i.y),f=w(n.x.add(c),n.y.add(h)).sub(.5).mul(e.xy),g=w(n.x.add(d),n.y.add(h)).sub(.5).mul(e.xy),m=w(n.x.add(c),n.y.add(p)).sub(.5).mul(e.xy),y=w(n.x.add(d),n.y.add(p)).sub(.5).mul(e.xy),_=ji(i.y).mul(Ce(u.mul(o.sample(f).level(t)),a.mul(o.sample(g).level(t)))),C=Zi(i.y).mul(Ce(u.mul(o.sample(m).level(t)),a.mul(o.sample(y).level(t))));return _.add(C)},ef=v(([o,e])=>{const t=w(o.size(se(e))),s=w(o.size(se(e.add(1)))),r=qe(1,t),n=qe(1,s),i=to(o,k(r,t),vt(e)),u=to(o,k(n,s),Kn(e));return dt(e).mix(i,u)}),so=v(([o,e,t,s,r])=>{const n=A(wa(e.negate(),Es(o),qe(1,s))),i=A(Je(r[0].xyz),Je(r[1].xyz),Je(r[2].xyz));return Es(n).mul(t.mul(i))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),tf=v(([o,e])=>o.mul(et(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),sf=vu(),rf=vu(),ro=v(([o,e,t],{material:s})=>{const n=(s.side===l.BackSide?sf:rf).sample(o),i=Ze(Rn.x).mul(tf(e,t));return ef(n,i)}),no=v(([o,e,t])=>(le(t.notEqual(0),()=>{const s=Na(e).negate().div(t);return Sa(s.negate().mul(o))}),A(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),nf=v(([o,e,t,s,r,n,i,u,a,c,d,h,p,f,g])=>{let m,y;if(g){m=k().toVar(),y=A().toVar();const M=d.sub(1).mul(g.mul(.025)),D=A(d.sub(M),d,d.add(M));Ve({start:0,end:3},({i:F})=>{const L=D.element(F),G=so(o,e,h,L,u),H=i.add(G),q=c.mul(a.mul(k(H,1))),ee=w(q.xy.div(q.w)).toVar();ee.addAssign(1),ee.divAssign(2),ee.assign(w(ee.x,ee.y.oneMinus()));const te=ro(ee,t,L);m.element(F).assign(te.element(F)),m.a.addAssign(te.a),y.element(F).assign(s.element(F).mul(no(Je(G),p,f).element(F)))}),m.a.divAssign(3)}else{const M=so(o,e,h,d,u),D=i.add(M),F=c.mul(a.mul(k(D,1))),L=w(F.xy.div(F.w)).toVar();L.addAssign(1),L.divAssign(2),L.assign(w(L.x,L.y.oneMinus())),m=ro(L,t,d),y=s.mul(no(Je(M),p,f))}const _=y.rgb.mul(m.rgb),C=o.dot(e).clamp(),R=A(Xu({dotNV:C,specularColor:r,specularF90:n,roughness:t})),U=y.r.add(y.g,y.b).div(3);return k(R.oneMinus().mul(_),m.a.oneMinus().mul(U).oneMinus())}),of=Re(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),af=o=>{const e=o.sqrt();return A(1).add(e).div(A(1).sub(e))},io=(o,e)=>o.sub(e).div(o.add(e)).pow2(),uf=(o,e)=>{const t=o.mul(2*Math.PI*1e-9),s=A(54856e-17,44201e-17,52481e-17),r=A(1681e3,1795300,2208400),n=A(43278e5,93046e5,66121e5),i=b(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let u=s.mul(n.mul(2*Math.PI).sqrt()).mul(r.mul(t).add(e).cos()).mul(t.pow2().negate().mul(n).exp());return u=A(u.x.add(i),u.y,u.z).div(10685e-11),of.mul(u)},lf=v(({outsideIOR:o,eta2:e,cosTheta1:t,thinFilmThickness:s,baseF0:r})=>{const n=ne(o,e,lt(0,.03,s)),u=o.div(n).pow2().mul(t.pow2().oneMinus()).oneMinus();le(u.lessThan(0),()=>A(1));const a=u.sqrt(),c=io(n,o),d=ws({f0:c,f90:1,dotVH:t}),h=d.oneMinus(),p=n.lessThan(o).select(Math.PI,0),f=b(Math.PI).sub(p),g=af(r.clamp(0,.9999)),m=io(g,n.toVec3()),y=ws({f0:m,f90:1,dotVH:a}),_=A(g.x.lessThan(n).select(Math.PI,0),g.y.lessThan(n).select(Math.PI,0),g.z.lessThan(n).select(Math.PI,0)),C=n.mul(s,a,2),R=A(f).add(_),U=d.mul(y).clamp(1e-5,.9999),M=U.sqrt(),D=h.pow2().mul(y).div(A(1).sub(U)),L=d.add(D).toVar(),G=D.sub(h).toVar();return Ve({start:1,end:2,condition:"<=",name:"m"},({m:H})=>{G.mulAssign(M);const q=uf(b(H).mul(C),b(H).mul(R)).mul(2);L.addAssign(G.mul(q))}),L.max(A(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),cf=v(({normal:o,viewDir:e,roughness:t})=>{const s=o.dot(e).saturate(),r=t.pow2(),n=Se(t.lessThan(.25),b(-339.2).mul(r).add(b(161.4).mul(t)).sub(25.9),b(-8.48).mul(r).add(b(14.3).mul(t)).sub(9.95)),i=Se(t.lessThan(.25),b(44).mul(r).sub(b(23.7).mul(t)).add(3.26),b(1.97).mul(r).sub(b(3.27).mul(t)).add(.72));return Se(t.lessThan(.25),0,b(.1).mul(t).sub(.025)).add(n.mul(s).add(i).exp()).mul(1/Math.PI).saturate()}),Ur=A(.04),Gr=b(1);class di extends Ls{constructor(e=!1,t=!1,s=!1,r=!1,n=!1,i=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=s,this.anisotropy=r,this.transmission=n,this.dispersion=i,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=A().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=A().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=A().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=A().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=A().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=Z.dot(oe).clamp();this.iridescenceFresnel=lf({outsideIOR:b(1),eta2:da,cosTheta1:t,thinFilmThickness:ha,baseF0:Be}),this.iridescenceF0=Kp({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=Bs,s=ah.sub(Bs).normalize(),r=es,n=e.context;n.backdrop=nf(r,s,je,K,Be,cr,t,Et,tt,oi,Js,pa,ga,fa,this.dispersion?ma:null),n.backdropAlpha=_n,K.a.mulAssign(ne(1,n.backdrop.a,_n))}super.start(e)}computeMultiscattering(e,t,s){const r=Z.dot(oe).clamp(),n=qu({roughness:je,dotNV:r}),u=(this.iridescenceF0?$n.mix(Be,this.iridescenceF0):Be).mul(n.x).add(s.mul(n.y)),c=n.x.add(n.y).oneMinus(),d=Be.add(Be.oneMinus().mul(.047619)),h=u.mul(d).div(c.mul(d).oneMinus());e.addAssign(u),t.addAssign(h.mul(c))}direct({lightDirection:e,lightColor:t,reflectedLight:s}){const n=Z.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(n.mul(jp({lightDirection:e}))),this.clearcoat===!0){const u=Ot.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(u.mul(Qi({lightDirection:e,f0:Ur,f90:Gr,roughness:lr,normalView:Ot})))}s.directDiffuse.addAssign(n.mul(Yt({diffuseColor:K.rgb}))),s.directSpecular.addAssign(n.mul(Qi({lightDirection:e,f0:Be,f90:1,roughness:je,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:s,halfHeight:r,reflectedLight:n,ltc_1:i,ltc_2:u}){const a=t.add(s).sub(r),c=t.sub(s).sub(r),d=t.sub(s).add(r),h=t.add(s).add(r),p=Z,f=oe,g=ue.toVar(),m=Zp({N:p,V:f,roughness:je}),y=i.sample(m).toVar(),_=u.sample(m).toVar(),C=Re(A(y.x,0,y.y),A(0,1,0),A(y.z,0,y.w)).toVar(),R=Be.mul(_.x).add(Be.oneMinus().mul(_.y)).toVar();n.directSpecular.addAssign(e.mul(R).mul(Yi({N:p,V:f,P:g,mInv:C,p0:a,p1:c,p2:d,p3:h}))),n.directDiffuse.addAssign(e.mul(K).mul(Yi({N:p,V:f,P:g,mInv:Re(1,0,0,0,1,0,0,0,1),p0:a,p1:c,p2:d,p3:h})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(t.mul(Yt({diffuseColor:K})))}indirectSpecular(e){const{radiance:t,iblIrradiance:s,reflectedLight:r}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(s.mul(It,cf({normal:Z,viewDir:oe,roughness:zn}))),this.clearcoat===!0){const d=Ot.dot(oe).clamp(),h=Xu({dotNV:d,specularColor:Ur,specularF90:Gr,roughness:lr});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(h))}const n=A().toVar("singleScattering"),i=A().toVar("multiScattering"),u=s.mul(1/Math.PI);this.computeMultiscattering(n,i,cr);const a=n.add(i),c=K.mul(a.r.max(a.g).max(a.b).oneMinus());r.indirectSpecular.addAssign(t.mul(n)),r.indirectSpecular.addAssign(i.mul(u)),r.indirectDiffuse.addAssign(c.mul(u))}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:s}=e.context,n=Z.dot(oe).clamp().add(t),i=je.mul(-16).oneMinus().negate().exp2(),u=t.sub(n.pow(i).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),s.indirectDiffuse.mulAssign(t),s.indirectSpecular.mulAssign(u)}finish({context:e}){const{outgoingLight:t}=e;if(this.clearcoat===!0){const s=Ot.dot(oe).clamp(),r=ws({dotVH:s,f0:Ur,f90:Gr}),n=t.mul(Tn.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Tn));t.assign(n)}if(this.sheen===!0){const s=It.r.max(It.g).max(It.b).mul(.157).oneMinus(),r=t.mul(s).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const oo=b(1),vn=b(-2),Is=b(.8),Ir=b(-1),Os=b(.4),Or=b(2),Vs=b(.305),Vr=b(3),ao=b(.21),df=b(4),uo=b(4),hf=b(16),pf=v(([o])=>{const e=A(we(o)).toVar(),t=b(-1).toVar();return le(e.x.greaterThan(e.z),()=>{le(e.x.greaterThan(e.y),()=>{t.assign(Se(o.x.greaterThan(0),0,3))}).Else(()=>{t.assign(Se(o.y.greaterThan(0),1,4))})}).Else(()=>{le(e.z.greaterThan(e.y),()=>{t.assign(Se(o.z.greaterThan(0),2,5))}).Else(()=>{t.assign(Se(o.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),ff=v(([o,e])=>{const t=w().toVar();return le(e.equal(0),()=>{t.assign(w(o.z,o.y).div(we(o.x)))}).ElseIf(e.equal(1),()=>{t.assign(w(o.x.negate(),o.z.negate()).div(we(o.y)))}).ElseIf(e.equal(2),()=>{t.assign(w(o.x.negate(),o.y).div(we(o.z)))}).ElseIf(e.equal(3),()=>{t.assign(w(o.z.negate(),o.y).div(we(o.x)))}).ElseIf(e.equal(4),()=>{t.assign(w(o.x.negate(),o.z).div(we(o.y)))}).Else(()=>{t.assign(w(o.x,o.y).div(we(o.z)))}),$(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),gf=v(([o])=>{const e=b(0).toVar();return le(o.greaterThanEqual(Is),()=>{e.assign(oo.sub(o).mul(Ir.sub(vn)).div(oo.sub(Is)).add(vn))}).ElseIf(o.greaterThanEqual(Os),()=>{e.assign(Is.sub(o).mul(Or.sub(Ir)).div(Is.sub(Os)).add(Ir))}).ElseIf(o.greaterThanEqual(Vs),()=>{e.assign(Os.sub(o).mul(Vr.sub(Or)).div(Os.sub(Vs)).add(Or))}).ElseIf(o.greaterThanEqual(ao),()=>{e.assign(Vs.sub(o).mul(df.sub(Vr)).div(Vs.sub(ao)).add(Vr))}).Else(()=>{e.assign(b(-2).mul(Ze($(1.16,o))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),mf=v(([o,e])=>{const t=o.toVar();t.assign($(2,t).sub(1));const s=A(t,1).toVar();return le(e.equal(0),()=>{s.assign(s.zyx)}).ElseIf(e.equal(1),()=>{s.assign(s.xzy),s.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{s.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{s.assign(s.zyx),s.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{s.assign(s.xzy),s.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{s.z.mulAssign(-1)}),s}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),Tf=v(([o,e,t,s,r,n])=>{const i=b(t),u=A(e),a=et(gf(i),vn,n),c=dt(a),d=vt(a),h=A(En(o,u,d,s,r,n)).toVar();return le(c.notEqual(0),()=>{const p=A(En(o,u,d.add(1),s,r,n)).toVar();h.assign(ne(h,p,c))}),h}),En=v(([o,e,t,s,r,n])=>{const i=b(t).toVar(),u=A(e),a=b(pf(u)).toVar(),c=b(ye(uo.sub(i),0)).toVar();i.assign(ye(i,uo));const d=b(vs(i)).toVar(),h=w(ff(u,a).mul(d.sub(2)).add(1)).toVar();return le(a.greaterThan(2),()=>{h.y.addAssign(d),a.subAssign(3)}),h.x.addAssign(a.mul(d)),h.x.addAssign(c.mul($(3,hf))),h.y.addAssign($(4,vs(n).sub(d))),h.x.mulAssign(s),h.y.mulAssign(r),o.sample(h).grad(w(),w())}),kr=v(({envMap:o,mipInt:e,outputDirection:t,theta:s,axis:r,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:i,CUBEUV_MAX_MIP:u})=>{const a=it(s),c=t.mul(a).add(r.cross(t).mul(Oe(s))).add(r.mul(r.dot(t).mul(a.oneMinus())));return En(o,c,e,n,i,u)}),yf=v(({n:o,latitudinal:e,poleAxis:t,outputDirection:s,weights:r,samples:n,dTheta:i,mipInt:u,envMap:a,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h})=>{const p=A(Se(e,t,Ea(t,s))).toVar();le(p.equal(A(0)),()=>{p.assign(A(s.z,0,s.x.negate()))}),p.assign(Es(p));const f=A().toVar();return f.addAssign(r.element(0).mul(kr({theta:0,axis:p,outputDirection:s,mipInt:u,envMap:a,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h}))),Ve({start:se(1),end:o},({i:g})=>{le(g.greaterThanEqual(n),()=>{gp()});const m=b(i.mul(b(g))).toVar();f.addAssign(r.element(g).mul(kr({theta:m.mul(-1),axis:p,outputDirection:s,mipInt:u,envMap:a,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h}))),f.addAssign(r.element(g).mul(kr({theta:m,axis:p,outputDirection:s,mipInt:u,envMap:a,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h})))}),k(f,1)}),Vt=4,lo=[.125,.215,.35,.446,.526,.582],At=20,zr=new l.OrthographicCamera(-1,1,1,-1,0,1),xf=new l.PerspectiveCamera(90,1),co=new l.Color;let $r=null,Wr=0,Hr=0;const Nt=(1+Math.sqrt(5))/2,wt=1/Nt,ho=[new l.Vector3(-Nt,wt,0),new l.Vector3(Nt,wt,0),new l.Vector3(-wt,0,Nt),new l.Vector3(wt,0,Nt),new l.Vector3(0,Nt,-wt),new l.Vector3(0,Nt,wt),new l.Vector3(-1,1,-1),new l.Vector3(1,1,-1),new l.Vector3(-1,1,1),new l.Vector3(1,1,1)],_f=new l.Vector3,Yu=new WeakMap,Sf=[3,1,5,0,4,2],qr=mf(Ps(),ct("faceIndex")).normalize(),hi=A(qr.x,qr.y,qr.z);class ju{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,s=.1,r=100,n={}){const{size:i=256,position:u=_f,renderTarget:a=null}=n;if(this._setSize(i),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const d=a||this._allocateTarget();return n.renderTarget=d,this.fromSceneAsync(e,t,s,r,n),d}$r=this._renderer.getRenderTarget(),Wr=this._renderer.getActiveCubeFace(),Hr=this._renderer.getActiveMipmapLevel();const c=a||this._allocateTarget();return c.depthBuffer=!0,this._init(c),this._sceneToCubeUV(e,s,r,c,u),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}async fromSceneAsync(e,t=0,s=.1,r=100,n={}){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,t,s,r,n)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const s=t||this._allocateTarget();return this.fromEquirectangularAsync(e,s),s}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const s=t||this._allocateTarget();return this.fromCubemapAsync(e,t),s}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=fo(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=go(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===l.CubeReflectionMapping||e.mapping===l.CubeRefractionMapping?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget($r,Wr,Hr),e.scissorTest=!1,ks(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),$r=this._renderer.getRenderTarget(),Wr=this._renderer.getActiveCubeFace(),Hr=this._renderer.getActiveMipmapLevel();const s=t||this._allocateTarget();return this._init(s),this._textureToCubeUV(e,s),this._applyPMREM(s),this._cleanup(s),s}_allocateTarget(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize;return po(e,t)}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=po(e.width,e.height);const{_lodMax:t}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=Nf(t)),this._blurMaterial=bf(t,e.width,e.height)}}async _compileMaterial(e){const t=new l.Mesh(this._lodPlanes[0],e);await this._renderer.compile(t,zr)}_sceneToCubeUV(e,t,s,r,n){const i=xf;i.near=t,i.far=s;const u=[1,1,1,1,-1,1],a=[1,-1,1,-1,1,-1],c=this._renderer,d=c.autoClear;c.getClearColor(co),c.autoClear=!1;let h=this._backgroundBox;if(h===null){const g=new l.MeshBasicMaterial({name:"PMREM.Background",side:l.BackSide,depthWrite:!1,depthTest:!1});h=new l.Mesh(new l.BoxGeometry,g)}let p=!1;const f=e.background;f?f.isColor&&(h.material.color.copy(f),e.background=null,p=!0):(h.material.color.copy(co),p=!0),c.setRenderTarget(r),c.clear(),p&&c.render(h,i);for(let g=0;g<6;g++){const m=g%3;m===0?(i.up.set(0,u[g],0),i.position.set(n.x,n.y,n.z),i.lookAt(n.x+a[g],n.y,n.z)):m===1?(i.up.set(0,0,u[g]),i.position.set(n.x,n.y,n.z),i.lookAt(n.x,n.y+a[g],n.z)):(i.up.set(0,u[g],0),i.position.set(n.x,n.y,n.z),i.lookAt(n.x,n.y,n.z+a[g]));const y=this._cubeSize;ks(r,m*y,g>2?y:0,y,y),c.render(e,i)}c.autoClear=d,e.background=f}_textureToCubeUV(e,t){const s=this._renderer,r=e.mapping===l.CubeReflectionMapping||e.mapping===l.CubeRefractionMapping;r?this._cubemapMaterial===null&&(this._cubemapMaterial=fo(e)):this._equirectMaterial===null&&(this._equirectMaterial=go(e));const n=r?this._cubemapMaterial:this._equirectMaterial;n.fragmentNode.value=e;const i=this._lodMeshes[0];i.material=n;const u=this._cubeSize;ks(t,0,0,3*u,2*u),s.setRenderTarget(t),s.render(i,zr)}_applyPMREM(e){const t=this._renderer,s=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let n=1;n<r;n++){const i=Math.sqrt(this._sigmas[n]*this._sigmas[n]-this._sigmas[n-1]*this._sigmas[n-1]),u=ho[(r-n-1)%ho.length];this._blur(e,n-1,n,i,u)}t.autoClear=s}_blur(e,t,s,r,n){const i=this._pingPongRenderTarget;this._halfBlur(e,i,t,s,r,"latitudinal",n),this._halfBlur(i,e,s,s,r,"longitudinal",n)}_halfBlur(e,t,s,r,n,i,u){const a=this._renderer,c=this._blurMaterial;i!=="latitudinal"&&i!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,h=this._lodMeshes[r];h.material=c;const p=Yu.get(c),f=this._sizeLods[s]-1,g=isFinite(n)?Math.PI/(2*f):2*Math.PI/(2*At-1),m=n/g,y=isFinite(n)?1+Math.floor(d*m):At;y>At&&console.warn(`sigmaRadians, ${n}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${At}`);const _=[];let C=0;for(let F=0;F<At;++F){const L=F/m,G=Math.exp(-L*L/2);_.push(G),F===0?C+=G:F<y&&(C+=2*G)}for(let F=0;F<_.length;F++)_[F]=_[F]/C;e.texture.frame=(e.texture.frame||0)+1,p.envMap.value=e.texture,p.samples.value=y,p.weights.array=_,p.latitudinal.value=i==="latitudinal"?1:0,u&&(p.poleAxis.value=u);const{_lodMax:R}=this;p.dTheta.value=g,p.mipInt.value=R-s;const U=this._sizeLods[r],M=3*U*(r>R-Vt?r-R+Vt:0),D=4*(this._cubeSize-U);ks(t,M,D,3*U,2*U),a.setRenderTarget(t),a.render(h,zr)}}function Nf(o){const e=[],t=[],s=[],r=[];let n=o;const i=o-Vt+1+lo.length;for(let u=0;u<i;u++){const a=Math.pow(2,n);t.push(a);let c=1/a;u>o-Vt?c=lo[u-o+Vt-1]:u===0&&(c=0),s.push(c);const d=1/(a-2),h=-d,p=1+d,f=[h,h,p,h,p,p,h,h,p,p,h,p],g=6,m=6,y=3,_=2,C=1,R=new Float32Array(y*m*g),U=new Float32Array(_*m*g),M=new Float32Array(C*m*g);for(let F=0;F<g;F++){const L=F%3*2/3-1,G=F>2?0:-1,H=[L,G,0,L+2/3,G,0,L+2/3,G+1,0,L,G,0,L+2/3,G+1,0,L,G+1,0],q=Sf[F];R.set(H,y*m*q),U.set(f,_*m*q);const ee=[q,q,q,q,q,q];M.set(ee,C*m*q)}const D=new l.BufferGeometry;D.setAttribute("position",new l.BufferAttribute(R,y)),D.setAttribute("uv",new l.BufferAttribute(U,_)),D.setAttribute("faceIndex",new l.BufferAttribute(M,C)),e.push(D),r.push(new l.Mesh(D,null)),n>Vt&&n--}return{lodPlanes:e,sizeLods:t,sigmas:s,lodMeshes:r}}function po(o,e){const t={magFilter:l.LinearFilter,minFilter:l.LinearFilter,generateMipmaps:!1,type:l.HalfFloatType,format:l.RGBAFormat,colorSpace:l.LinearSRGBColorSpace},s=new l.RenderTarget(o,e,t);return s.texture.mapping=l.CubeUVReflectionMapping,s.texture.name="PMREM.cubeUv",s.texture.isPMREMTexture=!0,s.scissorTest=!0,s}function ks(o,e,t,s,r){o.viewport.set(e,t,s,r),o.scissor.set(e,t,s,r)}function pi(o){const e=new ce;return e.depthTest=!1,e.depthWrite=!1,e.blending=l.NoBlending,e.name=`PMREM_${o}`,e}function bf(o,e,t){const s=We(new Array(At).fill(0)),r=O(new l.Vector3(0,1,0)),n=O(0),i=b(At),u=O(0),a=O(1),c=X(null),d=O(0),h=b(1/e),p=b(1/t),f=b(o),g={n:i,latitudinal:u,weights:s,poleAxis:r,outputDirection:hi,dTheta:n,samples:a,envMap:c,mipInt:d,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:f},m=pi("blur");return m.fragmentNode=yf({...g,latitudinal:u.equal(1)}),Yu.set(m,g),m}function fo(o){const e=pi("cubemap");return e.fragmentNode=Fs(o,hi),e}function go(o){const e=pi("equirect");return e.fragmentNode=X(o,Gu(hi),0),e}const mo=new WeakMap;function Rf(o){const e=Math.log2(o)-2,t=1/o;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function Af(o,e,t){const s=Cf(e);let r=s.get(o);if((r!==void 0?r.pmremVersion:-1)!==o.pmremVersion){const i=o.image;if(o.isCubeTexture)if(vf(i))r=t.fromCubemap(o,r);else return null;else if(Ef(i))r=t.fromEquirectangular(o,r);else return null;r.pmremVersion=o.pmremVersion,s.set(o,r)}return r.texture}function Cf(o){let e=mo.get(o);return e===void 0&&(e=new WeakMap,mo.set(o,e)),e}class Zu extends fe{static get type(){return"PMREMNode"}constructor(e,t=null,s=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=s,this._generator=null;const r=new l.Texture;r.isRenderTargetTexture=!0,this._texture=X(r),this._width=O(0),this._height=O(0),this._maxMip=O(0),this.updateBeforeType=z.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=Rf(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const s=t?t.pmremVersion:-1,r=this._value;s!==r.pmremVersion&&(r.isPMREMTexture===!0?t=r:t=Af(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new ju(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this)),t=tu.mul(A(t.x,t.y.negate(),t.z));let s=this.levelNode;return s===null&&e.context.getTextureLevel&&(s=e.context.getTextureLevel(this)),Tf(this._texture,t,s,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}}function vf(o){if(o==null)return!1;let e=0;const t=6;for(let s=0;s<t;s++)o[s]!==void 0&&e++;return e===t}function Ef(o){return o==null?!1:o.height>0}const Ju=B(Zu).setParameterLength(1,3),To=new WeakMap;class el extends Ft{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const h=s.isTextureNode?s.value:t[s.property];let p=To.get(h);p===void 0&&(p=Ju(h),To.set(h,p)),s=p}const n=t.useAnisotropy===!0||t.anisotropy>0?Bh:Z,i=s.context(yo(je,n)).mul(wr),u=s.context(Bf(es)).mul(Math.PI).mul(wr),a=er(i),c=er(u);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(c);const d=e.context.lightingModel.clearcoatRadiance;if(d){const h=s.context(yo(lr,Ot)).mul(wr),p=er(h);d.addAssign(p)}}}const yo=(o,e)=>{let t=null;return{getUV:()=>(t===null&&(t=oe.negate().reflect(e),t=o.mul(o).mix(t,e).normalize(),t=t.transformDirection(tt)),t),getTextureLevel:()=>o}},Bf=o=>({getUV:()=>o,getTextureLevel:()=>b(1)}),Mf=new l.MeshStandardMaterial;class fi extends ce{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(Mf),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new el(t):null}setupLightingModel(){return new di}setupSpecular(){const e=ne(A(.04),K.rgb,ur);Be.assign(e),cr.assign(1)}setupVariants(){const e=this.metalnessNode?b(this.metalnessNode):Vh;ur.assign(e);let t=this.roughnessNode?b(this.roughnessNode):Oh;t=Hu({roughness:t}),je.assign(t),this.setupSpecular(),K.assign(k(K.rgb.mul(e.oneMinus()),K.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const Ff=new l.MeshPhysicalMaterial;class tl extends fi{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(Ff),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?b(this.iorNode):ep;Js.assign(e),Be.assign(ne(Kt(Ba(Js.sub(1).div(Js.add(1))).mul(Ih),A(1)).mul($i),K.rgb,ur)),cr.assign(ne($i,1,ur))}setupLightingModel(){return new di(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?b(this.clearcoatNode):zh,s=this.clearcoatRoughnessNode?b(this.clearcoatRoughnessNode):$h;Tn.assign(t),lr.assign(Hu({roughness:s}))}if(this.useSheen){const t=this.sheenNode?A(this.sheenNode):qh,s=this.sheenRoughnessNode?b(this.sheenRoughnessNode):Xh;It.assign(t),zn.assign(s)}if(this.useIridescence){const t=this.iridescenceNode?b(this.iridescenceNode):Qh,s=this.iridescenceIORNode?b(this.iridescenceIORNode):Yh,r=this.iridescenceThicknessNode?b(this.iridescenceThicknessNode):jh;$n.assign(t),da.assign(s),ha.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?w(this.anisotropyNode):Kh).toVar();St.assign(t.length()),le(St.equal(0),()=>{t.assign(w(1,0))}).Else(()=>{t.divAssign(w(St)),St.assign(St.saturate())}),yn.assign(St.pow2().mix(je.pow2(),1)),Zs.assign(ms[0].mul(t.x).add(ms[1].mul(t.y))),Wt.assign(ms[1].mul(t.x).sub(ms[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?b(this.transmissionNode):Zh,s=this.thicknessNode?b(this.thicknessNode):Jh,r=this.attenuationDistanceNode?b(this.attenuationDistanceNode):tp,n=this.attenuationColorNode?A(this.attenuationColorNode):sp;if(_n.assign(t),pa.assign(s),fa.assign(r),ga.assign(n),this.useDispersion){const i=this.dispersionNode?b(this.dispersionNode):up;ma.assign(i)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?A(this.clearcoatNormalNode):Wh}setup(e){e.context.setupClearcoatNormal=()=>Ss(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}const wf=v(({normal:o,lightDirection:e,builder:t})=>{const s=o.dot(e),r=w(s.mul(.5).add(.5),0);if(t.material.gradientMap){const n=ot("gradientMap","texture").context({getUV:()=>r});return A(n.r)}else{const n=r.fwidth().mul(.5);return ne(A(.7),A(1),lt(b(.7).sub(n.x),b(.7).add(n.x),r.x))}});class Pf extends Ls{direct({lightDirection:e,lightColor:t,reflectedLight:s},r){const n=wf({normal:Ja,lightDirection:e,builder:r}).mul(t);s.directDiffuse.addAssign(n.mul(Yt({diffuseColor:K.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:s,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(s.mul(Yt({diffuseColor:K}))),r.indirectDiffuse.mulAssign(t)}}const Df=new l.MeshToonMaterial;class sl extends ce{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Df),this.setValues(e)}setupLightingModel(){return new Pf}}const Lf=v(()=>{const o=A(oe.z,0,oe.x.negate()).normalize(),e=oe.cross(o);return w(o.dot(Z),e.dot(Z)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),Uf=new l.MeshMatcapMaterial;class rl extends ce{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(Uf),this.setValues(e)}setupVariants(e){const t=Lf;let s;e.material.matcap?s=ot("matcap","texture").context({getUV:()=>t}):s=A(ne(.2,.8,t.y)),K.rgb.mulAssign(s.rgb)}}class nl extends fe{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:s}=this;if(this.getNodeType(e)==="vec2"){const n=t.cos(),i=t.sin();return kn(n,i,i.negate(),n).mul(s)}else{const n=t,i=$t(k(1,0,0,0),k(0,it(n.x),Oe(n.x).negate(),0),k(0,Oe(n.x),it(n.x),0),k(0,0,0,1)),u=$t(k(it(n.y),0,Oe(n.y),0),k(0,1,0,0),k(Oe(n.y).negate(),0,it(n.y),0),k(0,0,0,1)),a=$t(k(it(n.z),Oe(n.z).negate(),0,0),k(Oe(n.z),it(n.z),0,0),k(0,0,1,0),k(0,0,0,1));return i.mul(u).mul(a).mul(k(s,1)).xyz}}}const il=B(nl).setParameterLength(2),Gf=new l.SpriteMaterial;class gi extends ce{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(Gf),this.setValues(e)}setupPositionView(e){const{object:t,camera:s}=e,r=this.sizeAttenuation,{positionNode:n,rotationNode:i,scaleNode:u}=this,a=yr.mul(A(n||0));let c=w(Et[0].xyz.length(),Et[1].xyz.length());if(u!==null&&(c=c.mul(w(u))),r===!1)if(s.isPerspectiveCamera)c=c.mul(a.z.negate());else{const f=b(2).div(oi.element(1).element(1));c=c.mul(f.mul(2))}let d=xr.xy;if(t.center&&t.center.isVector2===!0){const f=Hd("center","vec2",t);d=d.sub(f.sub(.5))}d=d.mul(c);const h=b(i||Hh),p=il(d,h);return k(a.xy.add(p),a.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const If=new l.PointsMaterial;class ol extends gi{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(If),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return yr.mul(A(e||Te)).xyz}setupVertex(e){const t=super.setupVertex(e);if(e.material.isNodeMaterial!==!0)return t;const{rotationNode:s,scaleNode:r,sizeNode:n}=this,i=xr.xy.toVar(),u=bs.z.div(bs.w);if(s&&s.isNode){const c=b(s);i.assign(il(i,c))}let a=n!==null?w(n):ap;return this.sizeAttenuation===!0&&(a=a.mul(a.div(ue.z.negate()))),r&&r.isNode&&(a=a.mul(w(r))),i.mulAssign(a.mul(2)),i.assign(i.div(bs.z)),i.y.assign(i.y.mul(u)),i.assign(i.mul(t.w)),t.addAssign(k(i,0,0)),t}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}class Of extends Ls{constructor(){super(),this.shadowNode=b(1).toVar("shadowMask")}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){K.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(K.rgb)}}const Vf=new l.ShadowMaterial;class al extends ce{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(Vf),this.setValues(e)}setupLightingModel(){return new Of}}ut("vec3");ut("vec3");ut("vec3");class kf{constructor(e,t){this.nodes=e,this.info=t,this._context=typeof self<"u"?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,s)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this._animationLoop!==null&&this._animationLoop(t,s)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class ke{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let s=0;s<e.length-1;s++)if(t=t.get(e[s]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let s=this.weakMap;for(let r=0;r<e.length-1;r++){const n=e[r];s.has(n)===!1&&s.set(n,new WeakMap),s=s.get(n)}return s.set(e[e.length-1],t),this}delete(e){let t=this.weakMap;for(let s=0;s<e.length-1;s++)if(t=t.get(e[s]),t===void 0)return!1;return t.delete(e[e.length-1])}}let zf=0;function $f(o){const e=Object.keys(o);let t=Object.getPrototypeOf(o);for(;t;){const s=Object.getOwnPropertyDescriptors(t);for(const r in s)if(s[r]!==void 0){const n=s[r];n&&typeof n.get=="function"&&e.push(r)}t=Object.getPrototypeOf(t)}return e}class Wf{constructor(e,t,s,r,n,i,u,a,c,d){this.id=zf++,this._nodes=e,this._geometries=t,this.renderer=s,this.object=r,this.material=n,this.scene=i,this.camera=u,this.lightsNode=a,this.context=c,this.geometry=r.geometry,this.version=n.version,this.drawRange=null,this.attributes=null,this.attributesId=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=d,this.clippingContextCacheKey=d!==null?d.cacheKey:"",this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,s=[],r=new Set,n={};for(const i of e){let u;if(i.node&&i.node.attribute?u=i.node.attribute:(u=t.getAttribute(i.name),n[i.name]=u.version),u===void 0)continue;s.push(u);const a=u.isInterleavedBufferAttribute?u.data:u;r.add(a)}return this.attributes=s,this.attributesId=n,this.vertexBuffers=Array.from(r.values()),s}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:s,group:r,drawRange:n}=this,i=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),u=this.getIndex(),a=u!==null;let c=1;if(s.isInstancedBufferGeometry===!0?c=s.instanceCount:e.count!==void 0&&(c=Math.max(0,e.count)),c===0)return null;if(i.instanceCount=c,e.isBatchedMesh===!0)return i;let d=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(d=2);let h=n.start*d,p=(n.start+n.count)*d;r!==null&&(h=Math.max(h,r.start*d),p=Math.min(p,(r.start+r.count)*d));const f=s.attributes.position;let g=1/0;a?g=u.count:f!=null&&(g=f.count),h=Math.max(h,0),p=Math.min(p,g);const m=p-h;return m<0||m===1/0?null:(i.vertexCount=m,i.firstVertex=h,i)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const s of Object.keys(e.attributes).sort()){const r=e.attributes[s];t+=s+",",r.data&&(t+=r.data.stride+","),r.offset&&(t+=r.offset+","),r.itemSize&&(t+=r.itemSize+","),r.normalized&&(t+="n,")}for(const s of Object.keys(e.morphAttributes).sort()){const r=e.morphAttributes[s];t+="morph-"+s+",";for(let n=0,i=r.length;n<i;n++){const u=r[n];t+=u.id+","}}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t}=this;let s=t.customProgramCacheKey();for(const r of $f(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(r))continue;const n=t[r];let i;if(n!==null){const u=typeof n;u==="number"?i=n!==0?"1":"0":u==="object"?(i="{",n.isTexture&&(i+=n.mapping),i+="}"):i=String(n)}else i=String(n);s+=i+","}return s+=this.clippingContextCacheKey+",",e.geometry&&(s+=this.getGeometryCacheKey()),e.skeleton&&(s+=e.skeleton.bones.length+","),e.isBatchedMesh&&(s+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(s+=e._colorsTexture.uuid+",")),e.count>1&&(s+=e.uuid+","),s+=e.receiveShadow+",",Jl(s)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){const e=this.attributesId;for(const t in e){const s=this.geometry.getAttribute(t);if(s===void 0||e[t]!==s.id)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=rr(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=rr(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}}const Tt=[];class Hf{constructor(e,t,s,r,n,i){this.renderer=e,this.nodes=t,this.geometries=s,this.pipelines=r,this.bindings=n,this.info=i,this.chainMaps={}}get(e,t,s,r,n,i,u,a){const c=this.getChainMap(a);Tt[0]=e,Tt[1]=t,Tt[2]=i,Tt[3]=n;let d=c.get(Tt);return d===void 0?(d=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,s,r,n,i,u,a),c.set(Tt,d)):(d.updateClipping(u),d.needsGeometryUpdate&&d.setGeometry(e.geometry),(d.version!==t.version||d.needsUpdate)&&(d.initialCacheKey!==d.getCacheKey()?(d.dispose(),d=this.get(e,t,s,r,n,i,u,a)):d.version=t.version)),Tt.length=0,d}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new ke)}dispose(){this.chainMaps={}}createRenderObject(e,t,s,r,n,i,u,a,c,d,h){const p=this.getChainMap(h),f=new Wf(e,t,s,r,n,i,u,a,c,d);return f.onDispose=()=>{this.pipelines.delete(f),this.bindings.delete(f),this.nodes.delete(f),p.delete(f.getChainArray())},f}}class pt{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Pe={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},at=16,qf=211,Xf=212;class Kf extends pt{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==null&&this.backend.destroyAttribute(e),t}update(e,t){const s=this.get(e);if(s.version===void 0)t===Pe.VERTEX?this.backend.createAttribute(e):t===Pe.INDEX?this.backend.createIndexAttribute(e):t===Pe.STORAGE?this.backend.createStorageAttribute(e):t===Pe.INDIRECT&&this.backend.createIndirectStorageAttribute(e),s.version=this._getBufferAttribute(e).version;else{const r=this._getBufferAttribute(e);(s.version<r.version||r.usage===l.DynamicDrawUsage)&&(this.backend.updateAttribute(e),s.version=r.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}function ul(o){return o.index!==null?o.index.version:o.attributes.position.version}function xo(o){const e=[],t=o.index,s=o.attributes.position;if(t!==null){const n=t.array;for(let i=0,u=n.length;i<u;i+=3){const a=n[i+0],c=n[i+1],d=n[i+2];e.push(a,c,c,d,d,a)}}else{const n=s.array;for(let i=0,u=n.length/3-1;i<u;i+=3){const a=i+0,c=i+1,d=i+2;e.push(a,c,c,d,d,a)}}const r=new(l.arrayNeedsUint32(e)?l.Uint32BufferAttribute:l.Uint16BufferAttribute)(e,1);return r.version=ul(o),r}class Qf extends pt{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap}has(e){const t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry,s=this.get(t);s.initialized=!0,this.info.memory.geometries++;const r=()=>{this.info.memory.geometries--;const n=t.index,i=e.getAttributes();n!==null&&this.attributes.delete(n);for(const a of i)this.attributes.delete(a);const u=this.wireframes.get(t);u!==void 0&&this.attributes.delete(u),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const n of t)n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute?this.updateAttribute(n,Pe.STORAGE):this.updateAttribute(n,Pe.VERTEX);const s=this.getIndex(e);s!==null&&this.updateAttribute(s,Pe.INDEX);const r=e.geometry.indirect;r!==null&&this.updateAttribute(r,Pe.INDIRECT)}updateAttribute(e,t){const s=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,s)):this.attributeCall.get(e.data)!==s&&(this.attributes.update(e,t),this.attributeCall.set(e.data,s),this.attributeCall.set(e,s)):this.attributeCall.get(e)!==s&&(this.attributes.update(e,t),this.attributeCall.set(e,s))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:s}=e;let r=t.index;if(s.wireframe===!0){const n=this.wireframes;let i=n.get(t);i===void 0?(i=xo(t),n.set(t,i)):i.version!==ul(t)&&(this.attributes.delete(i),i=xo(t),n.set(t,i)),r=i}return r}}class Yf{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,s){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=s*(t/3):e.isPoints?this.render.points+=s*t:e.isLineSegments?this.render.lines+=s*(t/2):e.isLine?this.render.lines+=s*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class ll{constructor(e){this.cacheKey=e,this.usedTimes=0}}class jf extends ll{constructor(e,t,s){super(e),this.vertexProgram=t,this.fragmentProgram=s}}class Zf extends ll{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Jf=0;class Xr{constructor(e,t,s,r=null,n=null){this.id=Jf++,this.code=e,this.stage=t,this.name=s,this.transforms=r,this.attributes=n,this.usedTimes=0}}class eg extends pt{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:s}=this,r=this.get(e);if(this._needsComputeUpdate(e)){const n=r.pipeline;n&&(n.usedTimes--,n.computeProgram.usedTimes--);const i=this.nodes.getForCompute(e);let u=this.programs.compute.get(i.computeShader);u===void 0&&(n&&n.computeProgram.usedTimes===0&&this._releaseProgram(n.computeProgram),u=new Xr(i.computeShader,"compute",e.name,i.transforms,i.nodeAttributes),this.programs.compute.set(i.computeShader,u),s.createProgram(u));const a=this._getComputeCacheKey(e,u);let c=this.caches.get(a);c===void 0&&(n&&n.usedTimes===0&&this._releasePipeline(n),c=this._getComputePipeline(e,u,a,t)),c.usedTimes++,u.usedTimes++,r.version=e.version,r.pipeline=c}return r.pipeline}getForRender(e,t=null){const{backend:s}=this,r=this.get(e);if(this._needsRenderUpdate(e)){const n=r.pipeline;n&&(n.usedTimes--,n.vertexProgram.usedTimes--,n.fragmentProgram.usedTimes--);const i=e.getNodeBuilderState(),u=e.material?e.material.name:"";let a=this.programs.vertex.get(i.vertexShader);a===void 0&&(n&&n.vertexProgram.usedTimes===0&&this._releaseProgram(n.vertexProgram),a=new Xr(i.vertexShader,"vertex",u),this.programs.vertex.set(i.vertexShader,a),s.createProgram(a));let c=this.programs.fragment.get(i.fragmentShader);c===void 0&&(n&&n.fragmentProgram.usedTimes===0&&this._releaseProgram(n.fragmentProgram),c=new Xr(i.fragmentShader,"fragment",u),this.programs.fragment.set(i.fragmentShader,c),s.createProgram(c));const d=this._getRenderCacheKey(e,a,c);let h=this.caches.get(d);h===void 0?(n&&n.usedTimes===0&&this._releasePipeline(n),h=this._getRenderPipeline(e,a,c,d,t)):e.pipeline=h,h.usedTimes++,a.usedTimes++,c.usedTimes++,r.pipeline=h}return r.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,s,r){s=s||this._getComputeCacheKey(e,t);let n=this.caches.get(s);return n===void 0&&(n=new Zf(s,t),this.caches.set(s,n),this.backend.createComputePipeline(n,r)),n}_getRenderPipeline(e,t,s,r,n){r=r||this._getRenderCacheKey(e,t,s);let i=this.caches.get(r);return i===void 0&&(i=new jf(r,t,s),this.caches.set(r,i),e.pipeline=i,this.backend.createRenderPipeline(e,n)),i}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,s){return t.id+","+s.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,s=e.stage;this.programs[s].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class tg extends pt{constructor(e,t,s,r,n,i){super(),this.backend=e,this.textures=s,this.pipelines=n,this.attributes=r,this.nodes=t,this.info=i,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const s of t){const r=this.get(s);r.bindGroup===void 0&&(this._init(s),this.backend.createBindings(s,t,0),r.bindGroup=s)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const s of t){const r=this.get(s);r.bindGroup===void 0&&(this._init(s),this.backend.createBindings(s,t,0),r.bindGroup=s)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const s=t.attribute,r=s.isIndirectStorageBufferAttribute?Pe.INDIRECT:Pe.STORAGE;this.attributes.update(s,r)}}_update(e,t){const{backend:s}=this;let r=!1,n=!0,i=0,u=0;for(const a of e.bindings)if(!(a.isNodeUniformsGroup&&this.nodes.updateGroup(a)===!1)){if(a.isStorageBuffer){const c=a.attribute,d=c.isIndirectStorageBufferAttribute?Pe.INDIRECT:Pe.STORAGE;this.attributes.update(c,d)}if(a.isUniformBuffer)a.update()&&s.updateBinding(a);else if(a.isSampler)a.update();else if(a.isSampledTexture){const c=this.textures.get(a.texture);a.needsBindingsUpdate(c.generation)&&(r=!0);const d=a.update(),h=a.texture;d&&this.textures.updateTexture(h);const p=s.get(h);if(p.externalTexture!==void 0||c.isDefaultTexture?n=!1:(i=i*10+h.id,u+=h.version),s.isWebGPUBackend===!0&&p.texture===void 0&&p.externalTexture===void 0&&(console.error("Bindings._update: binding should be available:",a,d,h,a.textureNode.value,r),this.textures.updateTexture(h),r=!0),h.isStorageTexture===!0){const f=this.get(h);a.store===!0?f.needsMipmap=!0:this.textures.needsMipmaps(h)&&f.needsMipmap===!0&&(this.backend.generateMipmaps(h),f.needsMipmap=!1)}}}r===!0&&this.backend.updateBindings(e,t,n?i:0,u)}}function sg(o,e){return o.groupOrder!==e.groupOrder?o.groupOrder-e.groupOrder:o.renderOrder!==e.renderOrder?o.renderOrder-e.renderOrder:o.z!==e.z?o.z-e.z:o.id-e.id}function _o(o,e){return o.groupOrder!==e.groupOrder?o.groupOrder-e.groupOrder:o.renderOrder!==e.renderOrder?o.renderOrder-e.renderOrder:o.z!==e.z?e.z-o.z:o.id-e.id}function So(o){return(o.transmission>0||o.transmissionNode)&&o.side===l.DoubleSide&&o.forceSinglePass===!1}class rg{constructor(e,t,s){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,s),this.lightsArray=[],this.scene=t,this.camera=s,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,s,r,n,i,u){let a=this.renderItems[this.renderItemsIndex];return a===void 0?(a={id:e.id,object:e,geometry:t,material:s,groupOrder:r,renderOrder:e.renderOrder,z:n,group:i,clippingContext:u},this.renderItems[this.renderItemsIndex]=a):(a.id=e.id,a.object=e,a.geometry=t,a.material=s,a.groupOrder=r,a.renderOrder=e.renderOrder,a.z=n,a.group=i,a.clippingContext=u),this.renderItemsIndex++,a}push(e,t,s,r,n,i,u){const a=this.getNextRenderItem(e,t,s,r,n,i,u);e.occlusionTest===!0&&this.occlusionQueryCount++,s.transparent===!0||s.transmission>0?(So(s)&&this.transparentDoublePass.push(a),this.transparent.push(a)):this.opaque.push(a)}unshift(e,t,s,r,n,i,u){const a=this.getNextRenderItem(e,t,s,r,n,i,u);s.transparent===!0||s.transmission>0?(So(s)&&this.transparentDoublePass.unshift(a),this.transparent.unshift(a)):this.opaque.unshift(a)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||sg),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||_o),this.transparent.length>1&&this.transparent.sort(t||_o)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){const s=this.renderItems[e];if(s.id===null)break;s.id=null,s.object=null,s.geometry=null,s.material=null,s.groupOrder=null,s.renderOrder=null,s.z=null,s.group=null,s.clippingContext=null}}}const is=[];class ng{constructor(e){this.lighting=e,this.lists=new ke}get(e,t){const s=this.lists;is[0]=e,is[1]=t;let r=s.get(is);return r===void 0&&(r=new rg(this.lighting,e,t),s.set(is,r)),is.length=0,r}dispose(){this.lists=new ke}}let ig=0;class og{constructor(){this.id=ig++,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new l.Vector4,this.scissor=!1,this.scissorValue=new l.Vector4,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.isRenderContext=!0}getCacheKey(){return cl(this)}}function cl(o){const{textures:e,activeCubeFace:t}=o,s=[t];for(const r of e)s.push(r.id);return Dn(s)}const os=[],ag=new l.Scene,ug=new l.Camera;class lg{constructor(){this.chainMaps={}}get(e,t,s=null){os[0]=e,os[1]=t;let r;if(s===null)r="default";else{const u=s.texture.format;r=`${s.textures.length}:${u}:${s.samples}:${s.depthBuffer}:${s.stencilBuffer}`}const n=this._getChainMap(r);let i=n.get(os);return i===void 0&&(i=new og,n.set(os,i)),os.length=0,s!==null&&(i.sampleCount=s.samples===0?1:s.samples),i}getForClear(e=null){return this.get(ag,ug,e)}_getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new ke)}dispose(){this.chainMaps={}}}const cg=new l.Vector3;class dg extends pt{constructor(e,t,s){super(),this.renderer=e,this.backend=t,this.info=s}updateRenderTarget(e,t=0){const s=this.get(e),r=e.samples===0?1:e.samples,n=s.depthTextureMips||(s.depthTextureMips={}),i=e.textures,u=this.getSize(i[0]),a=u.width>>t,c=u.height>>t;let d=e.depthTexture||n[t];const h=e.depthBuffer===!0||e.stencilBuffer===!0;let p=!1;d===void 0&&h&&(d=new l.DepthTexture,d.format=e.stencilBuffer?l.DepthStencilFormat:l.DepthFormat,d.type=e.stencilBuffer?l.UnsignedInt248Type:l.UnsignedIntType,d.image.width=a,d.image.height=c,d.image.depth=u.depth,d.isArrayTexture=e.multiview===!0&&u.depth>1,n[t]=d),(s.width!==u.width||u.height!==s.height)&&(p=!0,d&&(d.needsUpdate=!0,d.image.width=a,d.image.height=c,d.image.depth=d.isArrayTexture?d.image.depth:1)),s.width=u.width,s.height=u.height,s.textures=i,s.depthTexture=d||null,s.depth=e.depthBuffer,s.stencil=e.stencilBuffer,s.renderTarget=e,s.sampleCount!==r&&(p=!0,d&&(d.needsUpdate=!0),s.sampleCount=r);const f={sampleCount:r};if(e.isXRRenderTarget!==!0){for(let g=0;g<i.length;g++){const m=i[g];p&&(m.needsUpdate=!0),this.updateTexture(m,f)}d&&this.updateTexture(d,f)}if(s.initialized!==!0){s.initialized=!0;const g=()=>{e.removeEventListener("dispose",g);for(let m=0;m<i.length;m++)this._destroyTexture(i[m]);d&&this._destroyTexture(d),this.delete(e)};e.addEventListener("dispose",g)}}updateTexture(e,t={}){const s=this.get(e);if(s.initialized===!0&&s.version===e.version)return;const r=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,n=this.backend;if(r&&s.initialized===!0&&(n.destroySampler(e),n.destroyTexture(e)),e.isFramebufferTexture){const c=this.renderer.getRenderTarget();c?e.type=c.texture.type:e.type=l.UnsignedByteType}const{width:i,height:u,depth:a}=this.getSize(e);if(t.width=i,t.height=u,t.depth=a,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,i,u):1,r||e.isStorageTexture===!0)n.createSampler(e),n.createTexture(e,t),s.generation=e.version;else if(s.initialized!==!0&&n.createSampler(e),e.version>0){const d=e.image;if(d===void 0)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(d.complete===!1)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const h=[];for(const p of e.images)h.push(p);t.images=h}else t.image=d;(s.isDefaultTexture===void 0||s.isDefaultTexture===!0)&&(n.createTexture(e,t),s.isDefaultTexture=!1,s.generation=e.version),e.source.dataReady===!0&&n.updateTexture(e,t),t.needsMipmaps&&e.mipmaps.length===0&&n.generateMipmaps(e)}}else n.createDefaultTexture(e),s.isDefaultTexture=!0,s.generation=e.version;if(s.initialized!==!0){s.initialized=!0,s.generation=e.version,this.info.memory.textures++;const c=()=>{e.removeEventListener("dispose",c),this._destroyTexture(e)};e.addEventListener("dispose",c)}s.version=e.version}getSize(e,t=cg){let s=e.images?e.images[0]:e.image;return s?(s.image!==void 0&&(s=s.image),t.width=s.width||1,t.height=s.height||1,t.depth=e.isCubeTexture?6:s.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,s){let r;return e.isCompressedTexture?e.mipmaps?r=e.mipmaps.length:r=1:r=Math.floor(Math.log2(Math.max(t,s)))+1,r}needsMipmaps(e){return e.isCompressedTexture===!0||e.generateMipmaps}_destroyTexture(e){this.has(e)===!0&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class mi extends l.Color{constructor(e,t,s,r=1){super(e,t,s),this.a=r}set(e,t,s,r=1){return this.a=r,super.set(e,t,s)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class dl extends Y{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}class hl extends V{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}add(e){return this.nodes.push(e),this}If(e,t){const s=new gs(t);return this._currentCond=Se(e,s),this.add(this._currentCond)}ElseIf(e,t){const s=new gs(t),r=Se(e,s);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new gs(e),this}Switch(e){return this._expressionNode=E(e),this}Case(...e){const t=[];if(e.length>=2)for(let u=0;u<e.length-1;u++)t.push(this._expressionNode.equal(E(e[u])));else throw new Error("TSL: Invalid parameter length. Case() requires at least two parameters.");const s=e[e.length-1],r=new gs(s);let n=t[0];for(let u=1;u<t.length;u++)n=n.or(t[u]);const i=Se(n,r);return this._currentCond===null?(this._currentCond=i,this.add(this._currentCond)):(this._currentCond.elseNode=i,this._currentCond=i,this)}Default(e){return this.Else(e),this}build(e,...t){const s=e.currentStack,r=la();or(this),e.currentStack=this;const n=e.buildStage;for(const u of this.nodes)if(n==="setup")u.build(e);else if(n==="analyze")u.build(e,this);else if(n==="generate"){const a=e.getDataFromNode(u,"any").stages,c=a&&a[e.shaderStage];if(u.isVarNode&&c&&c.length===1&&c[0]&&c[0].isStackNode)continue;u.build(e,"void")}const i=this.outputNode?this.outputNode.build(e,...t):super.build(e,...t);return or(r),e.currentStack=s,i}}const Kr=B(hl).setParameterLength(0,1);new l.Plane;new l.Vector3;new l.Vector3;new l.Vector3;new l.Matrix4;new l.Vector3(0,0,-1);new l.Vector4;new l.Vector3;new l.Vector3;new l.Vector4;new l.Vector2;const hg=new l.RenderTarget;qt.flipX();hg.depthTexture=new l.DepthTexture(1,1);const Qr=new l.OrthographicCamera(-1,1,1,-1,0,1);class pg extends l.BufferGeometry{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new l.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new l.Float32BufferAttribute(t,2))}}const fg=new pg;class Rr extends l.Mesh{constructor(e=null){super(fg,e),this.camera=Qr,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,Qr)}render(e){e.render(this,Qr)}}const as=new l.Euler,Yr=new l.Matrix4;class be extends V{static get type(){return"SceneNode"}constructor(e=be.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,s=this.scene!==null?this.scene:e.scene;let r;return t===be.BACKGROUND_BLURRINESS?r=J("backgroundBlurriness","float",s):t===be.BACKGROUND_INTENSITY?r=J("backgroundIntensity","float",s):t===be.BACKGROUND_ROTATION?r=O("mat4").label("backgroundRotation").setGroup(I).onRenderUpdate(()=>{const n=s.background;return n!==null&&n.isTexture&&n.mapping!==l.UVMapping?(as.copy(s.backgroundRotation),as.x*=-1,as.y*=-1,as.z*=-1,Yr.makeRotationFromEuler(as)):Yr.identity(),Yr}):console.error("THREE.SceneNode: Unknown scope:",t),r}}be.BACKGROUND_BLURRINESS="backgroundBlurriness";be.BACKGROUND_INTENSITY="backgroundIntensity";be.BACKGROUND_ROTATION="backgroundRotation";const gg=P(be,be.BACKGROUND_BLURRINESS),No=P(be,be.BACKGROUND_INTENSITY),mg=P(be,be.BACKGROUND_ROTATION),Tg=v(({texture:o,uv:e})=>{const s=A().toVar();return le(e.x.lessThan(1e-4),()=>{s.assign(A(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{s.assign(A(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{s.assign(A(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{s.assign(A(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{s.assign(A(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{s.assign(A(0,0,-1))}).Else(()=>{const n=o.sample(e.add(A(-.01,0,0))).r.sub(o.sample(e.add(A(.01,0,0))).r),i=o.sample(e.add(A(0,-.01,0))).r.sub(o.sample(e.add(A(0,.01,0))).r),u=o.sample(e.add(A(0,0,-.01))).r.sub(o.sample(e.add(A(0,0,.01))).r);s.assign(A(n,i,u))}),s.normalize()});class pl extends Mt{static get type(){return"Texture3DNode"}constructor(e,t=null,s=null){super(e,t,s),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return A(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const s=this.value;return e.isFlipY()&&(s.isRenderTargetTexture===!0||s.isFramebufferTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(se(Ht(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return Tg({texture:this,uv:e})}}const yg=B(pl).setParameterLength(1,3),zs=new l.Vector2;class xg extends Mt{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class bo extends xg{static get type(){return"PassMultipleTextureNode"}constructor(e,t,s=!1){super(e,null),this.textureName=t,this.previousTexture=s}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){const e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}class Us extends fe{static get type(){return"PassNode"}constructor(e,t,s,r={}){super("vec4"),this.scope=e,this.scene=t,this.camera=s,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;const n=new l.DepthTexture;n.isRenderTargetTexture=!0,n.name="depth";const i=new l.RenderTarget(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:l.HalfFloatType,...r});i.texture.name="output",i.depthTexture=n,this.renderTarget=i,this._textures={output:i.texture,depth:n},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=O(0),this._cameraFar=O(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=z.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const s=this._textures[e],r=this.renderTarget.textures.indexOf(s);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=s,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=E(new bo(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=E(new bo(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const s=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=Bu(this.getTextureNode(e),s,r)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const s=this._cameraNear,r=this._cameraFar,n=this.getViewZNode(e);this._linearDepthNodes[e]=t=Rs(n,s,r)}return t}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,this.renderTarget.texture.type=e.getColorBufferType(),this.scope===Us.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:s}=this;let r,n;const i=t.getOutputRenderTarget();i&&i.isXRRenderTarget===!0?(n=1,r=t.xr.getCamera(),t.xr.updateCamera(r),zs.set(i.width,i.height)):(r=this.camera,n=t.getPixelRatio(),t.getSize(zs)),this._pixelRatio=n,this.setSize(zs.width,zs.height);const u=t.getRenderTarget(),a=t.getMRT(),c=r.layers.mask;this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask);for(const d in this._previousTextures)this.toggleTexture(d);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(s,r),t.setRenderTarget(u),t.setMRT(a),r.layers.mask=c}setSize(e,t){this._width=e,this._height=t;const s=this._width*this._pixelRatio*this._resolution,r=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(s,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}Us.COLOR="color";Us.DEPTH="depth";const _g=v(([o,e])=>o.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Sg=v(([o,e])=>(o=o.mul(e),o.div(o.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Ng=v(([o,e])=>{o=o.mul(e),o=o.sub(.004).max(0);const t=o.mul(o.mul(6.2).add(.5)),s=o.mul(o.mul(6.2).add(1.7)).add(.06);return t.div(s).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),bg=v(([o])=>{const e=o.mul(o.add(.0245786)).sub(90537e-9),t=o.mul(o.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),Rg=v(([o,e])=>{const t=Re(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=Re(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return o=o.mul(e).div(.6),o=t.mul(o),o=bg(o),o=s.mul(o),o.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Ag=Re(A(1.6605,-.1246,-.0182),A(-.5876,1.1329,-.1006),A(-.0728,-.0083,1.1187)),Cg=Re(A(.6274,.0691,.0164),A(.3293,.9195,.088),A(.0433,.0113,.8956)),vg=v(([o])=>{const e=A(o).toVar(),t=A(e.mul(e)).toVar(),s=A(t.mul(t)).toVar();return b(15.5).mul(s.mul(t)).sub($(40.14,s.mul(e))).add($(31.96,s).sub($(6.868,t.mul(e))).add($(.4298,t).add($(.1191,e).sub(.00232))))}),Eg=v(([o,e])=>{const t=A(o).toVar(),s=Re(A(.856627153315983,.137318972929847,.11189821299995),A(.0951212405381588,.761241990602591,.0767994186031903),A(.0482516061458583,.101439036467562,.811302368396859)),r=Re(A(1.1271005818144368,-.1413297634984383,-.14132976349843826),A(-.11060664309660323,1.157823702216272,-.11060664309660294),A(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=b(-12.47393),i=b(4.026069);return t.mulAssign(e),t.assign(Cg.mul(t)),t.assign(s.mul(t)),t.assign(ye(t,1e-10)),t.assign(Ze(t)),t.assign(t.sub(n).div(i.sub(n))),t.assign(et(t,0,1)),t.assign(vg(t)),t.assign(r.mul(t)),t.assign(mr(ye(A(0),t),A(2.2))),t.assign(Ag.mul(t)),t.assign(et(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Bg=v(([o,e])=>{const t=b(.76),s=b(.15);o=o.mul(e);const r=Kt(o.r,Kt(o.g,o.b)),n=Se(r.lessThan(.08),r.sub($(6.25,r.mul(r))),.04);o.subAssign(n);const i=ye(o.r,ye(o.g,o.b));le(i.lessThan(t),()=>o);const u=_e(1,t),a=_e(1,u.mul(u).div(i.add(u.sub(t))));o.mulAssign(a.div(i));const c=_e(1,qe(1,s.mul(i.sub(a)).add(1)));return ne(o,A(a),c)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class de extends V{static get type(){return"CodeNode"}constructor(e="",t=[],s=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=s}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const s=e.getCodeFromNode(this,this.getNodeType(e));return s.code=this.code,s.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}class fl extends de{static get type(){return"FunctionNode"}constructor(e="",t=[],s=""){super(e,t,s)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let s=t.nodeFunction;return s===void 0&&(s=e.parser.parseFunction(this.code),t.nodeFunction=s),s}generate(e,t){super.generate(e);const s=this.getNodeFunction(e),r=s.name,n=s.type,i=e.getCodeFromNode(this,n);r!==""&&(i.name=r);const u=e.getPropertyName(i),a=this.getNodeFunction(e).getCode(u);return i.code=a+`
29
- `,t==="property"?u:e.format(`${u}()`,n,t)}}function gl(o){let e;const t=o.context.getViewZ;return t!==void 0&&(e=t(this)),(e||ue.z).negate()}const Mg=v(([o,e],t)=>{const s=gl(t);return lt(o,e,s)}),Fg=v(([o],e)=>{const t=gl(e);return o.mul(o,t,t).negate().exp().oneMinus()}),Ro=v(([o,e])=>k(e.toFloat().mix(xs.rgb,o.toVec3()),xs.a));class wg extends V{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:s}=e;s.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier
30
- `):e.addLineFlowCode(`${t}Barrier()`,this)}}B(wg);class Qe extends V{static get type(){return"AtomicFunctionNode"}constructor(e,t,s){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=s,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),s=t.parents,r=this.method,n=this.getNodeType(e),i=this.getInputType(e),u=this.pointerNode,a=this.valueNode,c=[];c.push(`&${u.build(e,i)}`),a!==null&&c.push(a.build(e,i));const d=`${e.getMethod(r,n)}( ${c.join(", ")} )`;if(s.length===1&&s[0].isStackNode===!0)e.addLineFlowCode(d,this);else return t.constNode===void 0&&(t.constNode=Qt(d,n).toConst()),t.constNode.build(e)}}Qe.ATOMIC_LOAD="atomicLoad";Qe.ATOMIC_STORE="atomicStore";Qe.ATOMIC_ADD="atomicAdd";Qe.ATOMIC_SUB="atomicSub";Qe.ATOMIC_MAX="atomicMax";Qe.ATOMIC_MIN="atomicMin";Qe.ATOMIC_AND="atomicAnd";Qe.ATOMIC_OR="atomicOr";Qe.ATOMIC_XOR="atomicXor";B(Qe);let $s;function Ar(o){$s=$s||new WeakMap;let e=$s.get(o);return e===void 0&&$s.set(o,e={}),e}function ml(o){const e=Ar(o);return e.shadowMatrix||(e.shadowMatrix=O("mat4").setGroup(I).onRenderUpdate(t=>((o.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&o.shadow.updateMatrices(o),o.shadow.matrix)))}function Pg(o,e=Bs){const t=ml(o).mul(e);return t.xyz.div(t.w)}function Tl(o){const e=Ar(o);return e.position||(e.position=O(new l.Vector3).setGroup(I).onRenderUpdate((t,s)=>s.value.setFromMatrixPosition(o.matrixWorld)))}function Dg(o){const e=Ar(o);return e.targetPosition||(e.targetPosition=O(new l.Vector3).setGroup(I).onRenderUpdate((t,s)=>s.value.setFromMatrixPosition(o.target.matrixWorld)))}function yl(o){const e=Ar(o);return e.viewPosition||(e.viewPosition=O(new l.Vector3).setGroup(I).onRenderUpdate(({camera:t},s)=>{s.value=s.value||new l.Vector3,s.value.setFromMatrixPosition(o.matrixWorld),s.value.applyMatrix4(t.matrixWorldInverse)}))}const xl=o=>tt.transformDirection(Tl(o).sub(Dg(o))),Lg=o=>o.sort((e,t)=>e.id-t.id),Ug=(o,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===o)return t;return null},jr=new WeakMap,us=[];class Ti extends V{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=ut("vec3","totalDiffuse"),this.totalSpecularNode=ut("vec3","totalSpecular"),this.outgoingLightNode=ut("vec3","outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let s=0;s<e.length;s++){const r=e[s];if(us.push(r.id),us.push(r.castShadow?1:0),r.isSpotLight===!0){const n=r.map!==null?r.map.id:-1,i=r.colorNode?r.colorNode.getCacheKey():-1;us.push(n,i)}}const t=Dn(us);return us.length=0,t}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);const t=[];for(const s of this._lightNodes)t.push(s.getSelf().getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){const t=e.getNodeProperties(this);for(const s of t.nodes)s.build(e);t.outputNode.build(e)}setupLightsNode(e){const t=[],s=this._lightNodes,r=Lg(this._lights),n=e.renderer.library;for(const i of r)if(i.isNode)t.push(E(i));else{let u=null;if(s!==null&&(u=Ug(i.id,s)),u===null){const a=n.getLightNodeClass(i.constructor);if(a===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${i.constructor.name}`);continue}let c=null;jr.has(i)?c=jr.get(i):(c=E(new a(i)),jr.set(i,c)),t.push(c)}}this._lightNodes=t}setupDirectLight(e,t,s){const{lightingModel:r,reflectedLight:n}=e.context;r.direct({...s,lightNode:t,reflectedLight:n},e)}setupDirectRectAreaLight(e,t,s){const{lightingModel:r,reflectedLight:n}=e.context;r.directRectArea({...s,lightNode:t,reflectedLight:n},e)}setupLights(e,t){for(const s of t)s.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let s=this.outgoingLightNode;const r=e.context,n=r.lightingModel,i=e.getNodeProperties(this);if(n){const{totalDiffuseNode:u,totalSpecularNode:a}=this;r.outgoingLight=s;const c=e.addStack();i.nodes=c.nodes,n.start(e);const{backdrop:d,backdropAlpha:h}=r,{directDiffuse:p,directSpecular:f,indirectDiffuse:g,indirectSpecular:m}=r.reflectedLight;let y=p.add(g);d!==null&&(h!==null?y=A(h.mix(y,d)):y=A(d),r.material.transparent=!0),u.assign(y),a.assign(f.add(m)),s.assign(u.add(a)),n.finish(e),s=s.bypass(e.removeStack())}else i.nodes=[];return e.lightsNode=t,s}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class _l extends V{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=z.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){Sl.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Bs)}}const Sl=ut("vec3","shadowPositionWorld");function Gg(o,e={}){return e.toneMapping=o.toneMapping,e.toneMappingExposure=o.toneMappingExposure,e.outputColorSpace=o.outputColorSpace,e.renderTarget=o.getRenderTarget(),e.activeCubeFace=o.getActiveCubeFace(),e.activeMipmapLevel=o.getActiveMipmapLevel(),e.renderObjectFunction=o.getRenderObjectFunction(),e.pixelRatio=o.getPixelRatio(),e.mrt=o.getMRT(),e.clearColor=o.getClearColor(e.clearColor||new l.Color),e.clearAlpha=o.getClearAlpha(),e.autoClear=o.autoClear,e.scissorTest=o.getScissorTest(),e}function Ig(o,e){return e=Gg(o,e),o.setMRT(null),o.setRenderObjectFunction(null),o.setClearColor(0,1),o.autoClear=!0,e}function Og(o,e){o.toneMapping=e.toneMapping,o.toneMappingExposure=e.toneMappingExposure,o.outputColorSpace=e.outputColorSpace,o.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),o.setRenderObjectFunction(e.renderObjectFunction),o.setPixelRatio(e.pixelRatio),o.setMRT(e.mrt),o.setClearColor(e.clearColor,e.clearAlpha),o.autoClear=e.autoClear,o.setScissorTest(e.scissorTest)}function Vg(o,e={}){return e.background=o.background,e.backgroundNode=o.backgroundNode,e.overrideMaterial=o.overrideMaterial,e}function kg(o,e){return e=Vg(o,e),o.background=null,o.backgroundNode=null,o.overrideMaterial=null,e}function zg(o,e){o.background=e.background,o.backgroundNode=e.backgroundNode,o.overrideMaterial=e.overrideMaterial}function $g(o,e,t){return t=Ig(o,t),t=kg(e,t),t}function Wg(o,e,t){Og(o,t),zg(e,t)}const Ao=new WeakMap,Hg=v(({depthTexture:o,shadowCoord:e,depthLayer:t})=>{let s=X(o,e.xy).label("t_basic");return o.isArrayTexture&&(s=s.depth(t)),s.compare(e.z)}),qg=v(({depthTexture:o,shadowCoord:e,shadow:t,depthLayer:s})=>{const r=(y,_)=>{let C=X(o,y);return o.isArrayTexture&&(C=C.depth(s)),C.compare(_)},n=J("mapSize","vec2",t).setGroup(I),i=J("radius","float",t).setGroup(I),u=w(1).div(n),a=u.x.negate().mul(i),c=u.y.negate().mul(i),d=u.x.mul(i),h=u.y.mul(i),p=a.div(2),f=c.div(2),g=d.div(2),m=h.div(2);return Ce(r(e.xy.add(w(a,c)),e.z),r(e.xy.add(w(0,c)),e.z),r(e.xy.add(w(d,c)),e.z),r(e.xy.add(w(p,f)),e.z),r(e.xy.add(w(0,f)),e.z),r(e.xy.add(w(g,f)),e.z),r(e.xy.add(w(a,0)),e.z),r(e.xy.add(w(p,0)),e.z),r(e.xy,e.z),r(e.xy.add(w(g,0)),e.z),r(e.xy.add(w(d,0)),e.z),r(e.xy.add(w(p,m)),e.z),r(e.xy.add(w(0,m)),e.z),r(e.xy.add(w(g,m)),e.z),r(e.xy.add(w(a,h)),e.z),r(e.xy.add(w(0,h)),e.z),r(e.xy.add(w(d,h)),e.z)).mul(1/17)}),Xg=v(({depthTexture:o,shadowCoord:e,shadow:t,depthLayer:s})=>{const r=(h,p)=>{let f=X(o,h);return o.isArrayTexture&&(f=f.depth(s)),f.compare(p)},n=J("mapSize","vec2",t).setGroup(I),i=w(1).div(n),u=i.x,a=i.y,c=e.xy,d=dt(c.mul(n).add(.5));return c.subAssign(d.mul(i)),Ce(r(c,e.z),r(c.add(w(u,0)),e.z),r(c.add(w(0,a)),e.z),r(c.add(i),e.z),ne(r(c.add(w(u.negate(),0)),e.z),r(c.add(w(u.mul(2),0)),e.z),d.x),ne(r(c.add(w(u.negate(),a)),e.z),r(c.add(w(u.mul(2),a)),e.z),d.x),ne(r(c.add(w(0,a.negate())),e.z),r(c.add(w(0,a.mul(2))),e.z),d.y),ne(r(c.add(w(u,a.negate())),e.z),r(c.add(w(u,a.mul(2))),e.z),d.y),ne(ne(r(c.add(w(u.negate(),a.negate())),e.z),r(c.add(w(u.mul(2),a.negate())),e.z),d.x),ne(r(c.add(w(u.negate(),a.mul(2))),e.z),r(c.add(w(u.mul(2),a.mul(2))),e.z),d.x),d.y)).mul(1/9)}),Kg=v(({depthTexture:o,shadowCoord:e,depthLayer:t})=>{const s=b(1).toVar();let r=X(o).sample(e.xy);o.isArrayTexture&&(r=r.depth(t)),r=r.rg;const n=va(e.z,r.x);return le(n.notEqual(b(1)),()=>{const i=e.z.sub(r.x),u=ye(0,r.y.mul(r.y));let a=u.div(u.add(i.mul(i)));a=et(_e(a,.3).div(.95-.3)),s.assign(et(ye(n,a)))}),s}),Qg=v(([o,e,t])=>{let s=Bs.sub(o).length();return s=s.sub(e).div(t.sub(e)),s=s.saturate(),s}),Yg=o=>{const e=o.shadow.camera,t=J("near","float",e).setGroup(I),s=J("far","float",e).setGroup(I),r=uh(o);return Qg(r,t,s)},jg=o=>{let e=Ao.get(o);if(e===void 0){const t=o.isPointLight?Yg(o):null;e=new ce,e.colorNode=k(0,0,0,1),e.depthNode=t,e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.fog=!1,Ao.set(o,e)}return e},Co=new ke,Pt=[],Zg=(o,e,t,s)=>{Pt[0]=o,Pt[1]=e;let r=Co.get(Pt);return(r===void 0||r.shadowType!==t||r.useVelocity!==s)&&(r=(n,i,u,a,c,d,...h)=>{(n.castShadow===!0||n.receiveShadow&&t===l.VSMShadowMap)&&(s&&(ta(n).useVelocity=!0),n.onBeforeShadow(o,n,u,e.camera,a,i.overrideMaterial,d),o.renderObject(n,i,u,a,c,d,...h),n.onAfterShadow(o,n,u,e.camera,a,i.overrideMaterial,d))},r.shadowType=t,r.useVelocity=s,Co.set(Pt,r)),Pt[0]=null,Pt[1]=null,r},Jg=v(({samples:o,radius:e,size:t,shadowPass:s,depthLayer:r})=>{const n=b(0).toVar("meanVertical"),i=b(0).toVar("squareMeanVertical"),u=o.lessThanEqual(b(1)).select(b(0),b(2).div(o.sub(1))),a=o.lessThanEqual(b(1)).select(b(0),b(-1));Ve({start:se(0),end:se(o),type:"int",condition:"<"},({i:d})=>{const h=a.add(b(d).mul(u));let p=s.sample(Ce(Sr.xy,w(0,h).mul(e)).div(t));s.value.isArrayTexture&&(p=p.depth(r)),p=p.x,n.addAssign(p),i.addAssign(p.mul(p))}),n.divAssign(o),i.divAssign(o);const c=Xn(i.sub(n.mul(n)));return w(n,c)}),em=v(({samples:o,radius:e,size:t,shadowPass:s,depthLayer:r})=>{const n=b(0).toVar("meanHorizontal"),i=b(0).toVar("squareMeanHorizontal"),u=o.lessThanEqual(b(1)).select(b(0),b(2).div(o.sub(1))),a=o.lessThanEqual(b(1)).select(b(0),b(-1));Ve({start:se(0),end:se(o),type:"int",condition:"<"},({i:d})=>{const h=a.add(b(d).mul(u));let p=s.sample(Ce(Sr.xy,w(h,0).mul(e)).div(t));s.value.isArrayTexture&&(p=p.depth(r)),n.addAssign(p.x),i.addAssign(Ce(p.y.mul(p.y),p.x.mul(p.x)))}),n.divAssign(o),i.divAssign(o);const c=Xn(i.sub(n.mul(n)));return w(n,c)}),tm=[Hg,qg,Xg,Kg];let Zr;const Ws=new Rr;class yi extends _l{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:s,shadowCoord:r,shadow:n,depthLayer:i}){const u=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),a=t({depthTexture:s,shadowCoord:r,shadow:n,depthLayer:i});return u.select(a,b(1))}setupShadowCoord(e,t){const{shadow:s}=this,{renderer:r}=e,n=J("bias","float",s).setGroup(I);let i=t,u;if(s.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)i=i.xyz.div(i.w),u=i.z,r.coordinateSystem===l.WebGPUCoordinateSystem&&(u=u.mul(2).sub(1));else{const a=i.w;i=i.xy.div(a);const c=J("near","float",s.camera).setGroup(I),d=J("far","float",s.camera).setGroup(I);u=Mu(a.negate(),c,d)}return i=A(i.x,i.y.oneMinus(),u.add(n)),i}getShadowFilterFn(e){return tm[e]}setupRenderTarget(e,t){const s=new l.DepthTexture(e.mapSize.width,e.mapSize.height);s.name="ShadowDepthTexture",s.compareFunction=l.LessCompare;const r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name="ShadowMap",r.texture.type=e.mapType,r.depthTexture=s,{shadowMap:r,depthTexture:s}}setupShadow(e){const{renderer:t}=e,{light:s,shadow:r}=this,n=t.shadowMap.type,{depthTexture:i,shadowMap:u}=this.setupRenderTarget(r,e);if(r.camera.updateProjectionMatrix(),n===l.VSMShadowMap&&r.isPointLightShadow!==!0){i.compareFunction=null,u.depth>1?(u._vsmShadowMapVertical||(u._vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:l.RGFormat,type:l.HalfFloatType,depth:u.depth,depthBuffer:!1}),u._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=u._vsmShadowMapVertical,u._vsmShadowMapHorizontal||(u._vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:l.RGFormat,type:l.HalfFloatType,depth:u.depth,depthBuffer:!1}),u._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=u._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:l.RGFormat,type:l.HalfFloatType,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:l.RGFormat,type:l.HalfFloatType,depthBuffer:!1}));let _=X(i);i.isArrayTexture&&(_=_.depth(this.depthLayer));let C=X(this.vsmShadowMapVertical.texture);i.isArrayTexture&&(C=C.depth(this.depthLayer));const R=J("blurSamples","float",r).setGroup(I),U=J("radius","float",r).setGroup(I),M=J("mapSize","vec2",r).setGroup(I);let D=this.vsmMaterialVertical||(this.vsmMaterialVertical=new ce);D.fragmentNode=Jg({samples:R,radius:U,size:M,shadowPass:_,depthLayer:this.depthLayer}).context(e.getSharedContext()),D.name="VSMVertical",D=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new ce),D.fragmentNode=em({samples:R,radius:U,size:M,shadowPass:C,depthLayer:this.depthLayer}).context(e.getSharedContext()),D.name="VSMHorizontal"}const a=J("intensity","float",r).setGroup(I),c=J("normalBias","float",r).setGroup(I),d=ml(s).mul(Sl.add(es.mul(c))),h=this.setupShadowCoord(e,d),p=r.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(p===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const f=n===l.VSMShadowMap&&r.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:i,g=this.setupShadowFilter(e,{filterFn:p,shadowTexture:u.texture,depthTexture:f,shadowCoord:h,shadow:r,depthLayer:this.depthLayer});let m=X(u.texture,h);i.isArrayTexture&&(m=m.depth(this.depthLayer));const y=ne(1,g.rgb.mix(m,1),a.mul(m.a)).toVar();return this.shadowMap=u,this.shadow.map=u,y}setup(e){if(e.renderer.shadowMap.enabled!==!1)return v(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){const{shadow:t,shadowMap:s,light:r}=this,{renderer:n,scene:i}=e;t.updateMatrices(r),s.setSize(t.mapSize.width,t.mapSize.height,s.depth),n.render(i,t.camera)}updateShadow(e){const{shadowMap:t,light:s,shadow:r}=this,{renderer:n,scene:i,camera:u}=e,a=n.shadowMap.type,c=t.depthTexture.version;this._depthVersionCached=c;const d=r.camera.layers.mask;(r.camera.layers.mask&4294967294)===0&&(r.camera.layers.mask=u.layers.mask);const h=n.getRenderObjectFunction(),p=n.getMRT(),f=p?p.has("velocity"):!1;Zr=$g(n,i,Zr),i.overrideMaterial=jg(s),n.setRenderObjectFunction(Zg(n,r,a,f)),n.setClearColor(0,0),n.setRenderTarget(t),this.renderShadow(e),n.setRenderObjectFunction(h),a===l.VSMShadowMap&&r.isPointLightShadow!==!0&&this.vsmPass(n),r.camera.layers.mask=d,Wg(n,i,Zr)}vsmPass(e){const{shadow:t}=this,s=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,s),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,s),e.setRenderTarget(this.vsmShadowMapVertical),Ws.material=this.vsmMaterialVertical,Ws.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Ws.material=this.vsmMaterialHorizontal,Ws.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;let s=t.needsUpdate||t.autoUpdate;s&&(this._cameraFrameId[e.camera]===e.frameId&&(s=!1),this._cameraFrameId[e.camera]=e.frameId),s&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const sm=(o,e)=>E(new yi(o,e)),rm=new l.Color,$e=v(([o,e])=>{const t=o.toVar(),s=we(t),r=qe(1,ye(s.x,ye(s.y,s.z)));s.mulAssign(r),t.mulAssign(r.mul(e.mul(2).oneMinus()));const n=w(t.xy).toVar(),u=e.mul(1.5).oneMinus();return le(s.z.greaterThanEqual(u),()=>{le(t.z.greaterThan(0),()=>{n.x.assign(_e(4,t.x))})}).ElseIf(s.x.greaterThanEqual(u),()=>{const a=dr(t.x);n.x.assign(t.z.mul(a).add(a.mul(2)))}).ElseIf(s.y.greaterThanEqual(u),()=>{const a=dr(t.y);n.x.assign(t.x.add(a.mul(2)).add(2)),n.y.assign(t.z.mul(a).sub(2))}),w(.125,.25).mul(n).add(w(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),nm=v(({depthTexture:o,bd3D:e,dp:t,texelSize:s})=>X(o,$e(e,s.y)).compare(t)),im=v(({depthTexture:o,bd3D:e,dp:t,texelSize:s,shadow:r})=>{const n=J("radius","float",r).setGroup(I),i=w(-1,1).mul(n).mul(s.y);return X(o,$e(e.add(i.xyy),s.y)).compare(t).add(X(o,$e(e.add(i.yyy),s.y)).compare(t)).add(X(o,$e(e.add(i.xyx),s.y)).compare(t)).add(X(o,$e(e.add(i.yyx),s.y)).compare(t)).add(X(o,$e(e,s.y)).compare(t)).add(X(o,$e(e.add(i.xxy),s.y)).compare(t)).add(X(o,$e(e.add(i.yxy),s.y)).compare(t)).add(X(o,$e(e.add(i.xxx),s.y)).compare(t)).add(X(o,$e(e.add(i.yxx),s.y)).compare(t)).mul(1/9)}),om=v(({filterFn:o,depthTexture:e,shadowCoord:t,shadow:s})=>{const r=t.xyz.toVar(),n=r.length(),i=O("float").setGroup(I).onRenderUpdate(()=>s.camera.near),u=O("float").setGroup(I).onRenderUpdate(()=>s.camera.far),a=J("bias","float",s).setGroup(I),c=O(s.mapSize).setGroup(I),d=b(1).toVar();return le(n.sub(u).lessThanEqual(0).and(n.sub(i).greaterThanEqual(0)),()=>{const h=n.sub(i).div(u.sub(i)).toVar();h.addAssign(a);const p=r.normalize(),f=w(1).div(c.mul(w(4,2)));d.assign(o({depthTexture:e,bd3D:p,dp:h,texelSize:f,shadow:s}))}),d}),vo=new l.Vector4,Dt=new l.Vector2,ls=new l.Vector2;class am extends yi{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===l.BasicShadowMap?nm:im}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:s,depthTexture:r,shadowCoord:n,shadow:i}){return om({filterFn:t,shadowTexture:s,depthTexture:r,shadowCoord:n,shadow:i})}renderShadow(e){const{shadow:t,shadowMap:s,light:r}=this,{renderer:n,scene:i}=e,u=t.getFrameExtents();ls.copy(t.mapSize),ls.multiply(u),s.setSize(ls.width,ls.height),Dt.copy(t.mapSize);const a=n.autoClear,c=n.getClearColor(rm),d=n.getClearAlpha();n.autoClear=!1,n.setClearColor(t.clearColor,t.clearAlpha),n.clear();const h=t.getViewportCount();for(let p=0;p<h;p++){const f=t.getViewport(p),g=Dt.x*f.x,m=ls.y-Dt.y-Dt.y*f.y;vo.set(g,m,Dt.x*f.z,Dt.y*f.w),s.viewport.copy(vo),t.updateMatrices(r,p),n.render(i,t.camera)}n.autoClear=a,n.setClearColor(c,d)}}const um=(o,e)=>E(new am(o,e));class ft extends Ft{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new l.Color,this.colorNode=e&&e.colorNode||O(this.color).setGroup(I),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=z.FRAME}getHash(){return this.light.uuid}getLightVector(e){return yl(this.light).sub(e.context.positionView||ue)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return sm(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let s=this.shadowColorNode;if(s===null){const r=this.light.shadow.shadowNode;let n;r!==void 0?n=E(r):n=this.setupShadowNode(),this.shadowNode=n,this.shadowColorNode=s=this.colorNode.mul(n),this.baseColorNode=this.colorNode}this.colorNode=s}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),s=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),s&&e.lightsNode.setupDirectRectAreaLight(e,this,s)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const Nl=v(({lightDistance:o,cutoffDistance:e,decayExponent:t})=>{const s=o.pow(t).max(.01).reciprocal();return e.greaterThan(0).select(s.mul(o.div(e).pow4().oneMinus().clamp().pow2()),s)}),lm=({color:o,lightVector:e,cutoffDistance:t,decayExponent:s})=>{const r=e.normalize(),n=e.length(),i=Nl({lightDistance:n,cutoffDistance:t,decayExponent:s}),u=o.mul(i);return{lightDirection:r,lightColor:u}};class bl extends ft{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=O(0).setGroup(I),this.decayExponentNode=O(2).setGroup(I)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return um(this.light)}setupDirect(e){return lm({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}v(([o=Ps()],{renderer:e,material:t})=>{const s=Ma(o.mul(2).sub(1));let r;if(t.alphaToCoverage&&e.samples>1){const n=b(s.fwidth()).toVar();r=lt(n.oneMinus(),n.add(1),s).oneMinus()}else r=Se(s.greaterThan(1),0,1);return r});const cm=v(([o,e])=>{const t=o.x,s=o.y,r=o.z;let n=e.element(0).mul(.886227);return n=n.add(e.element(1).mul(2*.511664).mul(s)),n=n.add(e.element(2).mul(2*.511664).mul(r)),n=n.add(e.element(3).mul(2*.511664).mul(t)),n=n.add(e.element(4).mul(2*.429043).mul(t).mul(s)),n=n.add(e.element(5).mul(2*.429043).mul(s).mul(r)),n=n.add(e.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),n=n.add(e.element(7).mul(2*.429043).mul(t).mul(r)),n=n.add(e.element(8).mul(.429043).mul($(t,t).sub($(s,s)))),n}),Ge=new mi;class dm extends pt{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,s){const r=this.renderer,n=this.nodes.getBackgroundNode(e)||e.background;let i=!1;if(n===null)r._clearColor.getRGB(Ge),Ge.a=r._clearColor.a;else if(n.isColor===!0)n.getRGB(Ge),Ge.a=1,i=!0;else if(n.isNode===!0){const a=this.get(e),c=n;Ge.copy(r._clearColor);let d=a.backgroundMesh;if(d===void 0){let m=function(){n.removeEventListener("dispose",m),d.material.dispose(),d.geometry.dispose()};const p=jn(k(c).mul(No),{getUV:()=>mg.mul(ph),getTextureLevel:()=>gg});let f=Tu;f=f.setZ(f.w);const g=new ce;g.name="Background.material",g.side=l.BackSide,g.depthTest=!1,g.depthWrite=!1,g.allowOverride=!1,g.fog=!1,g.lights=!1,g.vertexNode=f,g.colorNode=p,a.backgroundMeshNode=p,a.backgroundMesh=d=new l.Mesh(new l.SphereGeometry(1,32,32),g),d.frustumCulled=!1,d.name="Background.mesh",d.onBeforeRender=function(y,_,C){this.matrixWorld.copyPosition(C.matrixWorld)},n.addEventListener("dispose",m)}const h=c.getCacheKey();a.backgroundCacheKey!==h&&(a.backgroundMeshNode.node=k(c).mul(No),a.backgroundMeshNode.needsUpdate=!0,d.material.needsUpdate=!0,a.backgroundCacheKey=h),t.unshift(d,d.geometry,d.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",n);const u=r.xr.getEnvironmentBlendMode();if(u==="additive"?Ge.set(0,0,0,1):u==="alpha-blend"&&Ge.set(0,0,0,0),r.autoClear===!0||i===!0){const a=s.clearColorValue;a.r=Ge.r,a.g=Ge.g,a.b=Ge.b,a.a=Ge.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(a.r*=a.a,a.g*=a.a,a.b*=a.a),s.depthClearValue=r._clearDepth,s.stencilClearValue=r._clearStencil,s.clearColor=r.autoClearColor===!0,s.clearDepth=r.autoClearDepth===!0,s.clearStencil=r.autoClearStencil===!0}else s.clearColor=!1,s.clearDepth=!1,s.clearStencil=!1}}let hm=0;class Bn{constructor(e="",t=[],s=0,r=[]){this.name=e,this.bindings=t,this.index=s,this.bindingsReference=r,this.id=hm++}}class pm{constructor(e,t,s,r,n,i,u,a,c,d=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=s,this.transforms=d,this.nodeAttributes=r,this.bindings=n,this.updateNodes=i,this.updateBeforeNodes=u,this.updateAfterNodes=a,this.observer=c,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const r=new Bn(t.name,[],t.index,t);e.push(r);for(const n of t.bindings)r.bindings.push(n.clone())}else e.push(t);return e}}class Mn{constructor(e,t,s=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=s}}class Rl{constructor(e,t,s){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=s.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class xi{constructor(e,t,s=!1,r=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=s,this.count=r}}class Al extends xi{constructor(e,t,s=null,r=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=s,this.interpolationSampling=r}}class Cl{constructor(e,t,s=""){this.name=e,this.type=t,this.code=s,Object.defineProperty(this,"isNodeCode",{value:!0})}}let fm=0;class sr{constructor(e=null){this.id=fm++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class gm{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class gt{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class mm extends gt{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class Tm extends gt{constructor(e,t=new l.Vector2){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class ym extends gt{constructor(e,t=new l.Vector3){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class xm extends gt{constructor(e,t=new l.Vector4){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class _m extends gt{constructor(e,t=new l.Color){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class Sm extends gt{constructor(e,t=new l.Matrix2){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class Nm extends gt{constructor(e,t=new l.Matrix3){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class bm extends gt{constructor(e,t=new l.Matrix4){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class Rm extends mm{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Am extends Tm{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Cm extends ym{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class vm extends xm{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Em extends _m{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Bm extends Sm{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Mm extends Nm{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Fm extends bm{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const Eo=new WeakMap,wm=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),Hs=o=>/e/g.test(o)?String(o).replace(/\+/g,""):(o=Number(o),o+(o%1?"":".0"));class _i{constructor(e,t,s){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=s,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=Kr(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new sr,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.currentStack=null,this.subBuildFn=null}getBindGroupsCache(){let e=Eo.get(this.renderer);return e===void 0&&(e=new ke,Eo.set(this.renderer,e)),e}createRenderTarget(e,t,s){return new l.RenderTarget(e,t,s)}createCubeRenderTarget(e,t){return new Iu(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const s=this.getBindGroupsCache(),r=[];let n=!0;for(const u of t)r.push(u),n=n&&u.groupNode.shared!==!0;let i;return n?(i=s.get(r),i===void 0&&(i=new Bn(e,r,this.bindingsIndexes[e].group,r),s.set(r,i))):i=new Bn(e,r,this.bindingsIndexes[e].group,r),i}getBindGroupArray(e,t){const s=this.bindings[t];let r=s[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),s[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){const t={},s=this.bindings;for(const r of fn)for(const n in s[r]){const i=s[r][n];(t[n]||(t[n]=[])).push(...i)}e=[];for(const r in t){const n=t[r],i=this._getBindGroup(r,n);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,s)=>t.bindings[0].groupNode.order-s.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){const s=e[t];this.bindingsIndexes[s.name].group=t,s.index=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.includes(e)===!1&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}addSequentialNode(e){this.sequentialNodes.includes(e)===!1&&this.sequentialNodes.push(e)}buildUpdateNodes(){for(const e of this.nodes)e.getUpdateType()!==z.NONE&&this.updateNodes.push(e.getSelf());for(const e of this.sequentialNodes){const t=e.getUpdateBeforeType(),s=e.getUpdateAfterType();t!==z.NONE&&this.updateBeforeNodes.push(e.getSelf()),s!==z.NONE&&this.updateAfterNodes.push(e.getSelf())}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===l.LinearFilter||e.magFilter===l.LinearMipmapNearestFilter||e.magFilter===l.NearestMipmapLinearFilter||e.magFilter===l.LinearMipmapLinearFilter||e.minFilter===l.LinearFilter||e.minFilter===l.LinearMipmapNearestFilter||e.minFilter===l.NearestMipmapLinearFilter||e.minFilter===l.LinearMipmapLinearFilter}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw new Error("NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}getSharedContext(){return{...this.context},this.context}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){const s=this.getDataFromNode(e);return s.cache===void 0&&(s.cache=new sr(t?this.getCache():null)),s.cache}isAvailable(){return!1}getVertexIndex(){console.warn("Abstract function.")}getInstanceIndex(){console.warn("Abstract function.")}getDrawIndex(){console.warn("Abstract function.")}getFrontFacing(){console.warn("Abstract function.")}getFragCoord(){console.warn("Abstract function.")}isFlipY(){return!1}increaseUsage(e){const t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,t.usageCount}generateTexture(){console.warn("Abstract function.")}generateTextureLod(){console.warn("Abstract function.")}generateArrayDeclaration(e,t){return this.getType(e)+"[ "+t+" ]"}generateArray(e,t,s=null){let r=this.generateArrayDeclaration(e,t)+"( ";for(let n=0;n<t;n++){const i=s?s[n]:null;i!==null?r+=i.build(this,e):r+=this.generateConst(e),n<t-1&&(r+=", ")}return r+=" )",r}generateStruct(e,t,s=null){const r=[];for(const n of t){const{name:i,type:u}=n;s&&s[i]&&s[i].isNode?r.push(s[i].build(this,u)):r.push(this.generateConst(u))}return e+"( "+r.join(", ")+" )"}generateConst(e,t=null){if(t===null&&(e==="float"||e==="int"||e==="uint"?t=0:e==="bool"?t=!1:e==="color"?t=new l.Color:e==="vec2"?t=new l.Vector2:e==="vec3"?t=new l.Vector3:e==="vec4"&&(t=new l.Vector4)),e==="float")return Hs(t);if(e==="int")return`${Math.round(t)}`;if(e==="uint")return t>=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${Hs(t.r)}, ${Hs(t.g)}, ${Hs(t.b)} )`;const s=this.getTypeLength(e),r=this.getComponentType(e),n=i=>this.generateConst(r,i);if(s===2)return`${this.getType(e)}( ${n(t.x)}, ${n(t.y)} )`;if(s===3)return`${this.getType(e)}( ${n(t.x)}, ${n(t.y)}, ${n(t.z)} )`;if(s===4&&e!=="mat2")return`${this.getType(e)}( ${n(t.x)}, ${n(t.y)}, ${n(t.z)}, ${n(t.w)} )`;if(s>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(n).join(", ")} )`;if(s>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const s=this.attributes;for(const n of s)if(n.name===e)return n;const r=new Mn(e,t);return this.registerDeclaration(r),s.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="samplerComparison"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===l.IntType)return"int";if(t===l.UnsignedIntType)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;let s=tc(e);const r=t==="float"?"":t[0];return/mat2/.test(t)===!0&&(s=s.replace("vec","mat")),r+s}getTypeFromArray(e){return wm.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const s=t.array,r=e.itemSize,n=e.normalized;let i;return!(e instanceof l.Float16BufferAttribute)&&n!==!0&&(i=this.getTypeFromArray(s)),this.getTypeFromLength(r,i)}getTypeLength(e){const t=this.getVectorType(e),s=/vec([2-4])/.exec(t);return s!==null?Number(s[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}addStack(){return this.stack=Kr(this.stack),this.stacks.push(la()||this.stack),or(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,or(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,s=null){s=s===null?e.isGlobal(this)?this.globalCache:this.cache:s;let r=s.getData(e);r===void 0&&(r={},s.setData(e,r)),r[t]===void 0&&(r[t]={});let n=r[t];const i=r.any?r.any.subBuilds:null,u=this.getClosestSubBuild(i);return u&&(n.subBuildsCache===void 0&&(n.subBuildsCache={}),n=n.subBuildsCache[u]||(n.subBuildsCache[u]={}),n.subBuilds=i),n}getNodeProperties(e,t="any"){const s=this.getDataFromNode(e,t);return s.properties||(s.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const s=this.getDataFromNode(e);let r=s.bufferAttribute;if(r===void 0){const n=this.uniforms.index++;r=new Mn("nodeAttribute"+n,t,e),this.bufferAttributes.push(r),s.bufferAttribute=r}return r}getStructTypeFromNode(e,t,s=null,r=this.shaderStage){const n=this.getDataFromNode(e,r,this.globalCache);let i=n.structType;if(i===void 0){const u=this.structs.index++;s===null&&(s="StructType"+u),i=new gm(s,t),this.structs[r].push(i),n.structType=i}return i}getOutputStructTypeFromNode(e,t){const s=this.getStructTypeFromNode(e,t,"OutputType","fragment");return s.output=!0,s}getUniformFromNode(e,t,s=this.shaderStage,r=null){const n=this.getDataFromNode(e,s,this.globalCache);let i=n.uniform;if(i===void 0){const u=this.uniforms.index++;i=new Rl(r||"nodeUniform"+u,t,e),this.uniforms[s].push(i),this.registerDeclaration(i),n.uniform=i}return i}getArrayCount(e){let t=null;return e.isArrayNode?t=e.count:e.isVarNode&&e.node.isArrayNode&&(t=e.node.count),t}getVarFromNode(e,t=null,s=e.getNodeType(this),r=this.shaderStage,n=!1){const i=this.getDataFromNode(e,r),u=this.getSubBuildProperty("variable",i.subBuilds);let a=i[u];if(a===void 0){const c=n?"_const":"_var",d=this.vars[r]||(this.vars[r]=[]),h=this.vars[c]||(this.vars[c]=0);t===null&&(t=(n?"nodeConst":"nodeVar")+h,this.vars[c]++),u!=="variable"&&(t=this.getSubBuildProperty(t,i.subBuilds));const p=this.getArrayCount(e);a=new xi(t,s,n,p),n||d.push(a),this.registerDeclaration(a),i[u]=a}return a}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0)&&(e.cNode?this.isDeterministic(e.cNode):!0);if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0);if(e.isArrayNode){if(e.values!==null){for(const t of e.values)if(!this.isDeterministic(t))return!1}return!0}else if(e.isConstNode)return!0;return!1}getVaryingFromNode(e,t=null,s=e.getNodeType(this),r=null,n=null){const i=this.getDataFromNode(e,"any"),u=this.getSubBuildProperty("varying",i.subBuilds);let a=i[u];if(a===void 0){const c=this.varyings,d=c.length;t===null&&(t="nodeVarying"+d),u!=="varying"&&(t=this.getSubBuildProperty(t,i.subBuilds)),a=new Al(t,s,r,n),c.push(a),this.registerDeclaration(a),i[u]=a}return a}registerDeclaration(e){const t=this.shaderStage,s=this.declarations[t]||(this.declarations[t]={}),r=this.getPropertyName(e);let n=1,i=r;for(;s[i]!==void 0;)i=r+"_"+n++;n>1&&(e.name=i,console.warn(`THREE.TSL: Declaration name '${r}' of '${e.type}' already in use. Renamed to '${i}'.`)),s[i]=e}getCodeFromNode(e,t,s=this.shaderStage){const r=this.getDataFromNode(e);let n=r.code;if(n===void 0){const i=this.codes[s]||(this.codes[s]=[]),u=i.length;n=new Cl("nodeCode"+u,t),i.push(n),r.code=n}return n}addFlowCodeHierarchy(e,t){const{flowCodes:s,flowCodeBlock:r}=this.getDataFromNode(e);let n=!0,i=t;for(;i;){if(r.get(i)===!0){n=!1;break}i=this.getDataFromNode(i).parentNodeBlock}if(n)for(const u of s)this.addLineFlowCode(u)}addLineFlowCodeBlock(e,t,s){const r=this.getDataFromNode(e),n=r.flowCodes||(r.flowCodes=[]),i=r.flowCodeBlock||(r.flowCodeBlock=new WeakMap);n.push(t),i.set(s,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`;
31
- `),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),s=this.flowChildNode(e,t);return this.flowsData.set(e,s),s}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new fl,s=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=s,t}flowShaderNode(e){const t=e.layout,s={[Symbol.iterator](){let i=0;const u=Object.values(this);return{next:()=>({value:u[i],done:i++>=u.length})}}};for(const i of t.inputs)s[i.name]=new dl(i.type,i.name);e.layout=null;const r=e.call(s),n=this.flowStagesNode(r,t.type);return e.layout=t,n}flowStagesNode(e,t=null){const s=this.flow,r=this.vars,n=this.declarations,i=this.cache,u=this.buildStage,a=this.stack,c={code:""};this.flow=c,this.vars={},this.declarations={},this.cache=new sr,this.stack=Kr();for(const d of pn)this.setBuildStage(d),c.result=e.build(this,t);return c.vars=this.getVars(this.shaderStage),this.flow=s,this.vars=r,this.declarations=n,this.cache=i,this.stack=a,this.setBuildStage(u),c}getFunctionOperator(){return null}buildFunctionCode(){console.warn("Abstract function.")}flowChildNode(e,t=null){const s=this.flow,r={code:""};return this.flow=r,r.result=e.build(this,t),this.flow=s,r}flowNodeFromShaderStage(e,t,s=null,r=null){const n=this.tab,i=this.cache,u=this.shaderStage,a=this.context;this.setShaderStage(e);const c={...this.context};delete c.nodeBlock,this.cache=this.globalCache,this.tab=" ",this.context=c;let d=null;if(this.buildStage==="generate"){const h=this.flowChildNode(t,s);r!==null&&(h.code+=`${this.tab+r} = ${h.result};
32
- `),this.flowCode[e]=this.flowCode[e]+h.code,d=h}else d=t.build(this);return this.setShaderStage(u),this.cache=i,this.tab=n,this.context=a,d}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t,s=null){return`${s!==null?this.generateArrayDeclaration(e,s):this.getType(e)} ${t}`}getVars(e){let t="";const s=this.vars[e];if(s!==void 0)for(const r of s)t+=`${this.getVar(r.type,r.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let s="";if(t!==void 0)for(const r of t)s+=r.code+`
33
- `;return s}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(e&&e.isNode?e.isShaderCallNodeInternal?t=e.shaderNode.subBuilds:e.isStackNode?t=[e.subBuild]:t=this.getDataFromNode(e,"any").subBuilds:e instanceof Set?t=[...e]:t=e,!t)return null;const s=this.subBuildLayers;for(let r=t.length-1;r>=0;r--){const n=t[r];if(s.includes(n))return n}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let s;t!==null?s=this.getClosestSubBuild(t):s=this.subBuildFn;let r;return s?r=e?s+"_"+e:s:r=e,r}build(){const{object:e,material:t,renderer:s}=this;if(t!==null){let r=s.library.fromMaterial(t);r===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new ce),r.build(this)}else this.addFlow("compute",e);for(const r of pn){this.setBuildStage(r),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const n of fn){this.setShaderStage(n);const i=this.flowNodes[n];for(const u of i)r==="generate"?this.flowNode(u):u.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if(t==="float"||t==="int"||t==="uint")return new Rm(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new Am(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new Cm(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new vm(e);if(t==="color")return new Em(e);if(t==="mat2")return new Bm(e);if(t==="mat3")return new Mm(e);if(t==="mat4")return new Fm(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,s){if(t=this.getVectorType(t),s=this.getVectorType(s),t===s||s===null||this.isReference(s))return e;const r=this.getTypeLength(t),n=this.getTypeLength(s);return r===16&&n===9?`${this.getType(s)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:r===9&&n===4?`${this.getType(s)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:r>4||n>4||n===0?e:r===n?`${this.getType(s)}( ${e} )`:r>n?(e=s==="bool"?`all( ${e} )`:`${e}.${"xyz".slice(0,n)}`,this.format(e,this.getTypeFromLength(n,this.getComponentType(t)),s)):n===4&&r>1?`${this.getType(s)}( ${this.format(e,t,"vec3")}, 1.0 )`:r===2?`${this.getType(s)}( ${this.format(e,t,"vec2")}, 0.0 )`:(r===1&&n>1&&t!==this.getComponentType(s)&&(e=`${this.getType(this.getComponentType(s))}( ${e} )`),`${this.getType(s)}( ${e} )`)}getSignature(){return`// Three.js r${l.REVISION} - Node System
34
- `}*[Symbol.iterator](){}}class Fn{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let s=e.get(t);return s===void 0&&(s={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,s)),s}updateBeforeNode(e){const t=e.getUpdateBeforeType(),s=e.updateReference(this);if(t===z.FRAME){const{frameMap:r}=this._getMaps(this.updateBeforeMap,s);r.get(s)!==this.frameId&&e.updateBefore(this)!==!1&&r.set(s,this.frameId)}else if(t===z.RENDER){const{renderMap:r}=this._getMaps(this.updateBeforeMap,s);r.get(s)!==this.renderId&&e.updateBefore(this)!==!1&&r.set(s,this.renderId)}else t===z.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),s=e.updateReference(this);if(t===z.FRAME){const{frameMap:r}=this._getMaps(this.updateAfterMap,s);r.get(s)!==this.frameId&&e.updateAfter(this)!==!1&&r.set(s,this.frameId)}else if(t===z.RENDER){const{renderMap:r}=this._getMaps(this.updateAfterMap,s);r.get(s)!==this.renderId&&e.updateAfter(this)!==!1&&r.set(s,this.renderId)}else t===z.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),s=e.updateReference(this);if(t===z.FRAME){const{frameMap:r}=this._getMaps(this.updateMap,s);r.get(s)!==this.frameId&&e.update(this)!==!1&&r.set(s,this.frameId)}else if(t===z.RENDER){const{renderMap:r}=this._getMaps(this.updateMap,s);r.get(s)!==this.renderId&&e.update(this)!==!1&&r.set(s,this.renderId)}else t===z.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class Cr{constructor(e,t,s=null,r="",n=!1){this.type=e,this.name=t,this.count=s,this.qualifier=r,this.isConst=n}}Cr.isNodeFunctionInput=!0;class vl extends ft{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:xl(this.light),lightColor:e}}}const Jr=new l.Matrix4,qs=new l.Matrix4;let cs=null;class El extends ft{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=O(new l.Vector3).setGroup(I),this.halfWidth=O(new l.Vector3).setGroup(I),this.updateType=z.RENDER}update(e){super.update(e);const{light:t}=this,s=e.camera.matrixWorldInverse;qs.identity(),Jr.copy(t.matrixWorld),Jr.premultiply(s),qs.extractRotation(Jr),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(qs),this.halfHeight.value.applyMatrix4(qs)}setupDirectRectArea(e){let t,s;e.isAvailable("float32Filterable")?(t=X(cs.LTC_FLOAT_1),s=X(cs.LTC_FLOAT_2)):(t=X(cs.LTC_HALF_1),s=X(cs.LTC_HALF_2));const{colorNode:r,light:n}=this,i=yl(n);return{lightColor:r,lightPosition:i,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:s}}static setLTC(e){cs=e}}class vr extends ft{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=O(0).setGroup(I),this.penumbraCosNode=O(0).setGroup(I),this.cutoffDistanceNode=O(0).setGroup(I),this.decayExponentNode=O(0).setGroup(I),this.colorNode=O(this.color).setGroup(I)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:s,penumbraCosNode:r}=this;return lt(s,r,t)}getLightCoord(e){const t=e.getNodeProperties(this);let s=t.projectionUV;return s===void 0&&(s=Pg(this.light,e.context.positionWorld),t.projectionUV=s),s}setupDirect(e){const{colorNode:t,cutoffDistanceNode:s,decayExponentNode:r,light:n}=this,i=this.getLightVector(e),u=i.normalize(),a=u.dot(xl(n)),c=this.getSpotAttenuation(e,a),d=i.length(),h=Nl({lightDistance:d,cutoffDistance:s,decayExponent:r});let p=t.mul(c).mul(h),f,g;return n.colorNode?(g=this.getLightCoord(e),f=n.colorNode(g)):n.map&&(g=this.getLightCoord(e),f=X(n.map,g.xy).onRenderUpdate(()=>n.map)),f&&(p=g.mul(2).sub(1).abs().lessThan(1).all().select(p.mul(f),p)),{lightColor:p,lightDirection:u}}}class Bl extends vr{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const s=this.light.iesMap;let r=null;if(s&&s.isTexture===!0){const n=t.acos().mul(1/Math.PI);r=X(s,w(n,0),0).r}else r=super.getSpotAttenuation(t);return r}}const Pm=v(([o,e])=>{const t=o.abs().sub(e);return Je(ye(t,0)).add(Kt(ye(t.x,t.y),0))});class Ml extends vr{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let s=1;t.map!==null&&(s=t.map.width/t.map.height),t.shadow.aspect=s}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=this.penumbraCosNode,s=this.getLightCoord(e),r=s.xyz.div(s.w),n=Pm(r.xy.sub(w(.5)),w(.5)),i=qe(-1,_e(1,ba(t)).sub(1));return Fa(n.mul(-2).mul(i))}}class Fl extends ft{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class wl extends ft{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=Tl(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=O(new l.Color).setGroup(I)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:s,lightDirectionNode:r}=this,i=es.dot(r).mul(.5).add(.5),u=ne(s,t,i);e.context.irradiance.addAssign(u)}}class Pl extends ft{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let s=0;s<9;s++)t.push(new l.Vector3);this.lightProbe=We(t)}update(e){const{light:t}=this;super.update(e);for(let s=0;s<9;s++)this.lightProbe.array[s].copy(t.sh.coefficients[s]).multiplyScalar(t.intensity)}setup(e){const t=cm(es,this.lightProbe);e.context.irradiance.addAssign(t)}}class Dl{parseFunction(){console.warn("Abstract function.")}}class Si{constructor(e,t,s="",r=""){this.type=e,this.inputs=t,this.name=s,this.precision=r}getCode(){console.warn("Abstract function.")}}Si.isNodeFunction=!0;const Dm=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,Lm=/[a-z_0-9]+/ig,Bo="#pragma main",Um=o=>{o=o.trim();const e=o.indexOf(Bo),t=e!==-1?o.slice(e+Bo.length):o,s=t.match(Dm);if(s!==null&&s.length===5){const r=s[4],n=[];let i=null;for(;(i=Lm.exec(r))!==null;)n.push(i);const u=[];let a=0;for(;a<n.length;){const g=n[a][0]==="const";g===!0&&a++;let m=n[a][0];m==="in"||m==="out"||m==="inout"?a++:m="";const y=n[a++][0];let _=Number.parseInt(n[a][0]);Number.isNaN(_)===!1?a++:_=null;const C=n[a++][0];u.push(new Cr(y,C,_,m,g))}const c=t.substring(s[0].length),d=s[3]!==void 0?s[3]:"",h=s[2],p=s[1]!==void 0?s[1]:"",f=e!==-1?o.slice(0,e):"";return{type:h,inputs:u,name:d,precision:p,inputsCode:r,blockCode:c,headerCode:f}}else throw new Error("FunctionNode: Function is not a GLSL code.")};class Gm extends Si{constructor(e){const{type:t,inputs:s,name:r,precision:n,inputsCode:i,blockCode:u,headerCode:a}=Um(e);super(t,s,r,n),this.inputsCode=i,this.blockCode=u,this.headerCode=a}getCode(e=this.name){let t;const s=this.blockCode;if(s!==""){const{type:r,inputsCode:n,headerCode:i,precision:u}=this;let a=`${r} ${e} ( ${n.trim()} )`;u!==""&&(a=`${u} ${a}`),t=i+a+s}else t="";return t}}class Ll extends Dl{parseFunction(e){return new Gm(e)}}const Mo=new WeakMap,ze=[],yt=[];class Im extends pt{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new Fn,this.nodeBuilderCache=new Map,this.callHashCache=new ke,this.groupsData=new ke,this.cacheLib={}}updateGroup(e){const t=e.groupNode,s=t.name;if(s===Ta.name)return!0;if(s===I.name){const n=this.get(e),i=this.nodeFrame.renderId;return n.renderId!==i?(n.renderId=i,!0):!1}if(s===Pc.name){const n=this.get(e),i=this.nodeFrame.frameId;return n.frameId!==i?(n.frameId=i,!0):!1}ze[0]=t,ze[1]=e;let r=this.groupsData.get(ze);return r===void 0&&this.groupsData.set(ze,r={}),ze.length=0,r.version!==t.version?(r.version=t.version,!0):!1}getForRenderCacheKey(e){return e.initialCacheKey}getForRender(e){const t=this.get(e);let s=t.nodeBuilderState;if(s===void 0){const{nodeBuilderCache:r}=this,n=this.getForRenderCacheKey(e);if(s=r.get(n),s===void 0){const i=this.backend.createNodeBuilder(e.object,this.renderer);i.scene=e.scene,i.material=e.material,i.camera=e.camera,i.context.material=e.material,i.lightsNode=e.lightsNode,i.environmentNode=this.getEnvironmentNode(e.scene),i.fogNode=this.getFogNode(e.scene),i.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&i.enableMultiview(),i.build(),s=this._createNodeBuilderState(i),r.set(n,s)}s.usedTimes++,t.nodeBuilderState=s}return s}delete(e){if(e.isRenderObject){const t=this.get(e).nodeBuilderState;t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e))}return super.delete(e)}getForCompute(e){const t=this.get(e);let s=t.nodeBuilderState;if(s===void 0){const r=this.backend.createNodeBuilder(e,this.renderer);r.build(),s=this._createNodeBuilderState(r),t.nodeBuilderState=s}return s}_createNodeBuilderState(e){return new pm(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.transforms)}getEnvironmentNode(e){this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{const s=this.get(e);s.environmentNode&&(t=s.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{const s=this.get(e);s.backgroundNode&&(t=s.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){ze[0]=e,ze[1]=t;const s=this.renderer.info.calls,r=this.callHashCache.get(ze)||{};if(r.callId!==s){const n=this.getEnvironmentNode(e),i=this.getFogNode(e);t&&yt.push(t.getCacheKey(!0)),n&&yt.push(n.getCacheKey()),i&&yt.push(i.getCacheKey()),yt.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),yt.push(this.renderer.shadowMap.enabled?1:0),r.callId=s,r.cacheKey=Dn(yt),this.callHashCache.set(ze,r),yt.length=0}return ze.length=0,r.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),s=e.background;if(s){const r=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==s||r){const n=this.getCacheNode("background",s,()=>{if(s.isCubeTexture===!0||s.mapping===l.EquirectangularReflectionMapping||s.mapping===l.EquirectangularRefractionMapping||s.mapping===l.CubeUVReflectionMapping){if(e.backgroundBlurriness>0||s.mapping===l.CubeUVReflectionMapping)return Ju(s);{let i;return s.isCubeTexture===!0?i=Fs(s):i=X(s),Vu(i)}}else{if(s.isTexture===!0)return X(s,qt.flipY()).setUpdateMatrix(!0);s.isColor!==!0&&console.error("WebGPUNodes: Unsupported background configuration.",s)}},r);t.backgroundNode=n,t.background=s,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,s,r=!1){const n=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let i=n.get(t);return(i===void 0||r)&&(i=s(),n.set(t,i)),i}updateFog(e){const t=this.get(e),s=e.fog;if(s){if(t.fog!==s){const r=this.getCacheNode("fog",s,()=>{if(s.isFogExp2){const n=J("color","color",s).setGroup(I),i=J("density","float",s).setGroup(I);return Ro(n,Fg(i))}else if(s.isFog){const n=J("color","color",s).setGroup(I),i=J("near","float",s).setGroup(I),u=J("far","float",s).setGroup(I);return Ro(n,Mg(i,u))}else console.error("THREE.Renderer: Unsupported fog configuration.",s)});t.fogNode=r,t.fog=s}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),s=e.environment;if(s){if(t.environment!==s){const r=this.getCacheNode("environment",s,()=>{if(s.isCubeTexture===!0)return Fs(s);if(s.isTexture===!0)return X(s);console.error("Nodes: Unsupported environment configuration.",s)});t.environmentNode=r,t.environment=s}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,s=null,r=null,n=null){const i=this.nodeFrame;return i.renderer=e,i.scene=t,i.object=s,i.camera=r,i.material=n,i}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){return Mo.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,s=this.getOutputCacheKey(),r=e.isArrayTexture?yg(e,A(qt,Tr("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):X(e,qt).renderOutput(t.toneMapping,t.currentColorSpace);return Mo.set(e,s),r}updateBefore(e){const t=e.getNodeBuilderState();for(const s of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(s)}updateAfter(e){const t=e.getNodeBuilderState();for(const s of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(s)}updateForCompute(e){const t=this.getNodeFrame(),s=this.getForCompute(e);for(const r of s.updateNodes)t.updateNode(r)}updateForRender(e){const t=this.getNodeFrameForRender(e),s=e.getNodeBuilderState();for(const r of s.updateNodes)t.updateNode(r)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new Fn,this.nodeBuilderCache=new Map,this.cacheLib={}}}const en=new l.Plane;class hr{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new l.Matrix3,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,s){const r=e.length;for(let n=0;n<r;n++){en.copy(e[n]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);const i=t[s+n],u=en.normal;i.x=-u.x,i.y=-u.y,i.z=-u.z,i.w=en.constant}}updateGlobal(e,t){this.shadowPass=e.overrideMaterial!==null&&e.overrideMaterial.isShadowPassMaterial,this.viewMatrix=t.matrixWorldInverse,this.viewNormalMatrix.getNormalMatrix(this.viewMatrix)}update(e,t){let s=!1;e.version!==this.parentVersion&&(this.intersectionPlanes=Array.from(e.intersectionPlanes),this.unionPlanes=Array.from(e.unionPlanes),this.parentVersion=e.version),this.clipIntersection!==t.clipIntersection&&(this.clipIntersection=t.clipIntersection,this.clipIntersection?this.unionPlanes.length=e.unionPlanes.length:this.intersectionPlanes.length=e.intersectionPlanes.length);const r=t.clippingPlanes,n=r.length;let i,u;if(this.clipIntersection?(i=this.intersectionPlanes,u=e.intersectionPlanes.length):(i=this.unionPlanes,u=e.unionPlanes.length),i.length!==u+n){i.length=u+n;for(let a=0;a<n;a++)i[u+a]=new l.Vector4;s=!0}this.projectPlanes(r,i,u),s&&(this.version++,this.cacheKey=`${this.intersectionPlanes.length}:${this.unionPlanes.length}`)}getGroupContext(e){if(this.shadowPass&&!e.clipShadows)return this;let t=this.clippingGroupContexts.get(e);return t===void 0&&(t=new hr(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}get unionClippingCount(){return this.unionPlanes.length}}class Om{constructor(e,t){this.bundleGroup=e,this.camera=t}}const ds=[];class Vm{constructor(){this.bundles=new ke}get(e,t){const s=this.bundles;ds[0]=e,ds[1]=t;let r=s.get(ds);return r===void 0&&(r=new Om(e,t),s.set(ds,r)),ds.length=0,r}dispose(){this.bundles=new ke}}class Ul{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null;const s=this.getMaterialNodeClass(e.type);if(s!==null){t=new s;for(const r in e)t[r]=e[r]}return t}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,s){if(s.has(t)){console.warn(`Redefinition of node ${t}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t=="function"||typeof t=="object")throw new Error(`Base class ${t} is not a class.`);s.set(t,e)}addClass(e,t,s){if(s.has(t)){console.warn(`Redefinition of node ${t.name}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t!="function")throw new Error(`Base class ${t.name} is not a class.`);s.set(t,e)}}const km=new Ti,hs=[];class Gl extends ke{constructor(){super()}createNode(e=[]){return new Ti().setLights(e)}getNode(e,t){if(e.isQuadMesh)return km;hs[0]=e,hs[1]=t;let s=this.get(hs);return s===void 0&&(s=this.createNode(),this.set(hs,s)),hs.length=0,s}}class Ts extends l.RenderTarget{constructor(e=1,t=1,s={}){super(e,t,s),this.isXRRenderTarget=!0,this._hasExternalTextures=!1,this._autoAllocateDepthBuffer=!0,this._isOpaqueFramebuffer=!1}copy(e){return super.copy(e),this._hasExternalTextures=e._hasExternalTextures,this._autoAllocateDepthBuffer=e._autoAllocateDepthBuffer,this._isOpaqueFramebuffer=e._isOpaqueFramebuffer,this}}const Fo=new l.Vector3,wo=new l.Vector3;class zm extends l.EventDispatcher{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new l.PerspectiveCamera,this._cameraL.viewport=new l.Vector4,this._cameraR=new l.PerspectiveCamera,this._cameraR.viewport=new l.Vector4,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new l.ArrayCamera,this._currentDepthNear=null,this._currentDepthFar=null,this._controllers=[],this._controllerInputSources=[],this._xrRenderTarget=null,this._layers=[],this._supportsLayers=!1,this._frameBufferTargets=null,this._createXRLayer=Km.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new l.Vector2,this._onSessionEvent=Hm.bind(this),this._onSessionEnd=qm.bind(this),this._onInputSourcesChange=Xm.bind(this),this._onAnimationFrame=Qm.bind(this),this._referenceSpace=null,this._referenceSpaceType="local-floor",this._customReferenceSpace=null,this._framebufferScaleFactor=1,this._foveation=1,this._session=null,this._glBaseLayer=null,this._glBinding=null,this._glProjLayer=null,this._xrFrame=null,this._useLayers=typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype,this._useMultiviewIfPossible=t,this._useMultiview=!1}getController(e){return this._getController(e).getTargetRaySpace()}getControllerGrip(e){return this._getController(e).getGripSpace()}getHand(e){return this._getController(e).getHandSpace()}getFoveation(){if(!(this._glProjLayer===null&&this._glBaseLayer===null))return this._foveation}setFoveation(e){this._foveation=e,this._glProjLayer!==null&&(this._glProjLayer.fixedFoveation=e),this._glBaseLayer!==null&&this._glBaseLayer.fixedFoveation!==void 0&&(this._glBaseLayer.fixedFoveation=e)}getFramebufferScaleFactor(){return this._framebufferScaleFactor}setFramebufferScaleFactor(e){this._framebufferScaleFactor=e,this.isPresenting===!0&&console.warn("THREE.XRManager: Cannot change framebuffer scale while presenting.")}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,this.isPresenting===!0&&console.warn("THREE.XRManager: Cannot change reference space type while presenting.")}getReferenceSpace(){return this._customReferenceSpace||this._referenceSpace}setReferenceSpace(e){this._customReferenceSpace=e}getCamera(){return this._cameraXR}getEnvironmentBlendMode(){if(this._session!==null)return this._session.environmentBlendMode}getFrame(){return this._xrFrame}useMultiview(){return this._useMultiview}createQuadLayer(e,t,s,r,n,i,u,a={}){const c=new l.PlaneGeometry(e,t),d=new Ts(n,i,{format:l.RGBAFormat,type:l.UnsignedByteType,depthTexture:new l.DepthTexture(n,i,a.stencil?l.UnsignedInt248Type:l.UnsignedIntType,void 0,void 0,void 0,void 0,void 0,void 0,a.stencil?l.DepthStencilFormat:l.DepthFormat),stencilBuffer:a.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});d._autoAllocateDepthBuffer=!0;const h=new l.MeshBasicMaterial({color:16777215,side:l.FrontSide});h.map=d.texture,h.map.offset.y=1,h.map.repeat.y=-1;const p=new l.Mesh(c,h);p.position.copy(s),p.quaternion.copy(r);const f={type:"quad",width:e,height:t,translation:s,quaternion:r,pixelwidth:n,pixelheight:i,plane:p,material:h,rendercall:u,renderTarget:d};if(this._layers.push(f),this._session!==null){f.plane.material=new l.MeshBasicMaterial({color:16777215,side:l.FrontSide}),f.plane.material.blending=l.CustomBlending,f.plane.material.blendEquation=l.AddEquation,f.plane.material.blendSrc=l.ZeroFactor,f.plane.material.blendDst=l.ZeroFactor,f.xrlayer=this._createXRLayer(f);const g=this._session.renderState.layers;g.unshift(f.xrlayer),this._session.updateRenderState({layers:g})}else d.isXRRenderTarget=!1;return p}createCylinderLayer(e,t,s,r,n,i,u,a,c={}){const d=new l.CylinderGeometry(e,e,e*t/s,64,64,!0,Math.PI-t/2,t),h=new Ts(i,u,{format:l.RGBAFormat,type:l.UnsignedByteType,depthTexture:new l.DepthTexture(i,u,c.stencil?l.UnsignedInt248Type:l.UnsignedIntType,void 0,void 0,void 0,void 0,void 0,void 0,c.stencil?l.DepthStencilFormat:l.DepthFormat),stencilBuffer:c.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});h._autoAllocateDepthBuffer=!0;const p=new l.MeshBasicMaterial({color:16777215,side:l.BackSide});p.map=h.texture,p.map.offset.y=1,p.map.repeat.y=-1;const f=new l.Mesh(d,p);f.position.copy(r),f.quaternion.copy(n);const g={type:"cylinder",radius:e,centralAngle:t,aspectratio:s,translation:r,quaternion:n,pixelwidth:i,pixelheight:u,plane:f,material:p,rendercall:a,renderTarget:h};if(this._layers.push(g),this._session!==null){g.plane.material=new l.MeshBasicMaterial({color:16777215,side:l.BackSide}),g.plane.material.blending=l.CustomBlending,g.plane.material.blendEquation=l.AddEquation,g.plane.material.blendSrc=l.ZeroFactor,g.plane.material.blendDst=l.ZeroFactor,g.xrlayer=this._createXRLayer(g);const m=this._session.renderState.layers;m.unshift(g.xrlayer),this._session.updateRenderState({layers:m})}else h.isXRRenderTarget=!1;return f}renderLayers(){const e=new l.Vector3,t=new l.Quaternion,s=this._renderer,r=this.isPresenting,n=s.getOutputRenderTarget(),i=s._frameBufferTarget;this.isPresenting=!1;const u=new l.Vector2;s.getSize(u);const a=s._quad;for(const c of this._layers)if(c.renderTarget.isXRRenderTarget=this._session!==null,c.renderTarget._hasExternalTextures=c.renderTarget.isXRRenderTarget,c.renderTarget.isXRRenderTarget&&this._supportsLayers){c.xrlayer.transform=new XRRigidTransform(c.plane.getWorldPosition(e),c.plane.getWorldQuaternion(t));const d=this._glBinding.getSubImage(c.xrlayer,this._xrFrame);s.backend.setXRRenderTargetTextures(c.renderTarget,d.colorTexture,void 0),s._setXRLayerSize(c.renderTarget.width,c.renderTarget.height),s.setOutputRenderTarget(c.renderTarget),s.setRenderTarget(null),s._frameBufferTarget=null,this._frameBufferTargets||(this._frameBufferTargets=new WeakMap);const{frameBufferTarget:h,quad:p}=this._frameBufferTargets.get(c.renderTarget)||{frameBufferTarget:null,quad:null};h?(s._frameBufferTarget=h,s._quad=p):(s._quad=new Rr(new ce),this._frameBufferTargets.set(c.renderTarget,{frameBufferTarget:s._getFrameBufferTarget(),quad:s._quad})),c.rendercall(),s._frameBufferTarget=null}else s.setRenderTarget(c.renderTarget),c.rendercall();s.setRenderTarget(null),s.setOutputRenderTarget(n),s._frameBufferTarget=i,s._setXRLayerSize(u.x,u.y),s._quad=a,this.isPresenting=r}getSession(){return this._session}async setSession(e){const t=this._renderer,s=t.backend;this._gl=t.getContext();const r=this._gl,n=r.getContextAttributes();if(this._session=e,e!==null){if(s.isWebGPUBackend===!0)throw new Error('THREE.XRManager: XR is currently not supported with a WebGPU backend. Use WebGL by passing "{ forceWebGL: true }" to the constructor of the renderer.');if(e.addEventListener("select",this._onSessionEvent),e.addEventListener("selectstart",this._onSessionEvent),e.addEventListener("selectend",this._onSessionEvent),e.addEventListener("squeeze",this._onSessionEvent),e.addEventListener("squeezestart",this._onSessionEvent),e.addEventListener("squeezeend",this._onSessionEvent),e.addEventListener("end",this._onSessionEnd),e.addEventListener("inputsourceschange",this._onInputSourcesChange),await s.makeXRCompatible(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._useLayers===!0){let i=null,u=null,a=null;t.depth&&(a=t.stencil?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24,i=t.stencil?l.DepthStencilFormat:l.DepthFormat,u=t.stencil?l.UnsignedInt248Type:l.UnsignedIntType);const c={colorFormat:r.RGBA8,depthFormat:a,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(c.textureType="texture-array",this._useMultiview=!0);const d=new XRWebGLBinding(e,r),h=d.createProjectionLayer(c),p=[h];this._glBinding=d,this._glProjLayer=h,t.setPixelRatio(1),t._setXRLayerSize(h.textureWidth,h.textureHeight);const f=this._useMultiview?2:1,g=new l.DepthTexture(h.textureWidth,h.textureHeight,u,void 0,void 0,void 0,void 0,void 0,void 0,i,f);if(this._xrRenderTarget=new Ts(h.textureWidth,h.textureHeight,{format:l.RGBAFormat,type:l.UnsignedByteType,colorSpace:t.outputColorSpace,depthTexture:g,stencilBuffer:t.stencil,samples:n.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._supportsLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._supportsLayers)for(const m of this._layers)m.plane.material=new l.MeshBasicMaterial({color:16777215,side:m.type==="cylinder"?l.BackSide:l.FrontSide}),m.plane.material.blending=l.CustomBlending,m.plane.material.blendEquation=l.AddEquation,m.plane.material.blendSrc=l.ZeroFactor,m.plane.material.blendDst=l.ZeroFactor,m.xrlayer=this._createXRLayer(m),p.unshift(m.xrlayer);e.updateRenderState({layers:p})}else{const i={antialias:t.samples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},u=new XRWebGLLayer(e,r,i);this._glBaseLayer=u,e.updateRenderState({baseLayer:u}),t.setPixelRatio(1),t._setXRLayerSize(u.framebufferWidth,u.framebufferHeight),this._xrRenderTarget=new Ts(u.framebufferWidth,u.framebufferHeight,{format:l.RGBAFormat,type:l.UnsignedByteType,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(t===null)return;const s=e.near,r=e.far,n=this._cameraXR,i=this._cameraL,u=this._cameraR;n.near=u.near=i.near=s,n.far=u.far=i.far=r,n.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==n.near||this._currentDepthFar!==n.far)&&(t.updateRenderState({depthNear:n.near,depthFar:n.far}),this._currentDepthNear=n.near,this._currentDepthFar=n.far),i.layers.mask=e.layers.mask|2,u.layers.mask=e.layers.mask|4,n.layers.mask=i.layers.mask|u.layers.mask;const a=e.parent,c=n.cameras;Po(n,a);for(let d=0;d<c.length;d++)Po(c[d],a);c.length===2?$m(n,i,u):n.projectionMatrix.copy(i.projectionMatrix),Wm(e,n,a)}_getController(e){let t=this._controllers[e];return t===void 0&&(t=new l.WebXRController,this._controllers[e]=t),t}}function $m(o,e,t){Fo.setFromMatrixPosition(e.matrixWorld),wo.setFromMatrixPosition(t.matrixWorld);const s=Fo.distanceTo(wo),r=e.projectionMatrix.elements,n=t.projectionMatrix.elements,i=r[14]/(r[10]-1),u=r[14]/(r[10]+1),a=(r[9]+1)/r[5],c=(r[9]-1)/r[5],d=(r[8]-1)/r[0],h=(n[8]+1)/n[0],p=i*d,f=i*h,g=s/(-d+h),m=g*-d;if(e.matrixWorld.decompose(o.position,o.quaternion,o.scale),o.translateX(m),o.translateZ(g),o.matrixWorld.compose(o.position,o.quaternion,o.scale),o.matrixWorldInverse.copy(o.matrixWorld).invert(),r[10]===-1)o.projectionMatrix.copy(e.projectionMatrix),o.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const y=i+g,_=u+g,C=p-m,R=f+(s-m),U=a*u/_*y,M=c*u/_*y;o.projectionMatrix.makePerspective(C,R,U,M,y,_),o.projectionMatrixInverse.copy(o.projectionMatrix).invert()}}function Po(o,e){e===null?o.matrixWorld.copy(o.matrix):o.matrixWorld.multiplyMatrices(e.matrixWorld,o.matrix),o.matrixWorldInverse.copy(o.matrixWorld).invert()}function Wm(o,e,t){t===null?o.matrix.copy(e.matrixWorld):(o.matrix.copy(t.matrixWorld),o.matrix.invert(),o.matrix.multiply(e.matrixWorld)),o.matrix.decompose(o.position,o.quaternion,o.scale),o.updateMatrixWorld(!0),o.projectionMatrix.copy(e.projectionMatrix),o.projectionMatrixInverse.copy(e.projectionMatrixInverse),o.isPerspectiveCamera&&(o.fov=l.RAD2DEG*2*Math.atan(1/o.projectionMatrix.elements[5]),o.zoom=1)}function Hm(o){const e=this._controllerInputSources.indexOf(o.inputSource);if(e===-1)return;const t=this._controllers[e];if(t!==void 0){const s=this.getReferenceSpace();t.update(o.inputSource,o.frame,s),t.dispatchEvent({type:o.type,data:o.inputSource})}}function qm(){const o=this._session,e=this._renderer;o.removeEventListener("select",this._onSessionEvent),o.removeEventListener("selectstart",this._onSessionEvent),o.removeEventListener("selectend",this._onSessionEvent),o.removeEventListener("squeeze",this._onSessionEvent),o.removeEventListener("squeezestart",this._onSessionEvent),o.removeEventListener("squeezeend",this._onSessionEvent),o.removeEventListener("end",this._onSessionEnd),o.removeEventListener("inputsourceschange",this._onInputSourcesChange);for(let t=0;t<this._controllers.length;t++){const s=this._controllerInputSources[t];s!==null&&(this._controllerInputSources[t]=null,this._controllers[t].disconnect(s))}if(this._currentDepthNear=null,this._currentDepthFar=null,e._resetXRState(),this._session=null,this._xrRenderTarget=null,this._supportsLayers===!0)for(const t of this._layers)t.renderTarget=new Ts(t.pixelwidth,t.pixelheight,{format:l.RGBAFormat,type:l.UnsignedByteType,depthTexture:new l.DepthTexture(t.pixelwidth,t.pixelheight,t.stencilBuffer?l.UnsignedInt248Type:l.UnsignedIntType,void 0,void 0,void 0,void 0,void 0,void 0,t.stencilBuffer?l.DepthStencilFormat:l.DepthFormat),stencilBuffer:t.stencilBuffer,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),t.renderTarget.isXRRenderTarget=!1,t.plane.material=t.material,t.material.map=t.renderTarget.texture,t.material.map.offset.y=1,t.material.map.repeat.y=-1,delete t.xrlayer;this.isPresenting=!1,this._useMultiview=!1,e._animation.stop(),e._animation.setAnimationLoop(this._currentAnimationLoop),e._animation.setContext(this._currentAnimationContext),e._animation.start(),e.setPixelRatio(this._currentPixelRatio),e.setSize(this._currentSize.width,this._currentSize.height,!1),this.dispatchEvent({type:"sessionend"})}function Xm(o){const e=this._controllers,t=this._controllerInputSources;for(let s=0;s<o.removed.length;s++){const r=o.removed[s],n=t.indexOf(r);n>=0&&(t[n]=null,e[n].disconnect(r))}for(let s=0;s<o.added.length;s++){const r=o.added[s];let n=t.indexOf(r);if(n===-1){for(let u=0;u<e.length;u++)if(u>=t.length){t.push(r),n=u;break}else if(t[u]===null){t[u]=r,n=u;break}if(n===-1)break}const i=e[n];i&&i.connect(r)}}function Km(o){return o.type==="quad"?this._glBinding.createQuadLayer({transform:new XRRigidTransform(o.translation,o.quaternion),width:o.width/2,height:o.height/2,space:this._referenceSpace,viewPixelWidth:o.pixelwidth,viewPixelHeight:o.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(o.translation,o.quaternion),radius:o.radius,centralAngle:o.centralAngle,aspectRatio:o.aspectRatio,space:this._referenceSpace,viewPixelWidth:o.pixelwidth,viewPixelHeight:o.pixelheight,clearOnAccess:!1})}function Qm(o,e){if(e===void 0)return;const t=this._cameraXR,s=this._renderer,r=s.backend,n=this._glBaseLayer,i=this.getReferenceSpace(),u=e.getViewerPose(i);if(this._xrFrame=e,u!==null){const a=u.views;this._glBaseLayer!==null&&r.setXRTarget(n.framebuffer);let c=!1;a.length!==t.cameras.length&&(t.cameras.length=0,c=!0);for(let d=0;d<a.length;d++){const h=a[d];let p;if(this._useLayers===!0){const g=this._glBinding.getViewSubImage(this._glProjLayer,h);p=g.viewport,d===0&&r.setXRRenderTargetTextures(this._xrRenderTarget,g.colorTexture,this._glProjLayer.ignoreDepthValues&&!this._useMultiview?void 0:g.depthStencilTexture)}else p=n.getViewport(h);let f=this._cameras[d];f===void 0&&(f=new l.PerspectiveCamera,f.layers.enable(d),f.viewport=new l.Vector4,this._cameras[d]=f),f.matrix.fromArray(h.transform.matrix),f.matrix.decompose(f.position,f.quaternion,f.scale),f.projectionMatrix.fromArray(h.projectionMatrix),f.projectionMatrixInverse.copy(f.projectionMatrix).invert(),f.viewport.set(p.x,p.y,p.width,p.height),d===0&&(t.matrix.copy(f.matrix),t.matrix.decompose(t.position,t.quaternion,t.scale)),c===!0&&t.cameras.push(f)}s.setOutputRenderTarget(this._xrRenderTarget)}for(let a=0;a<this._controllers.length;a++){const c=this._controllerInputSources[a],d=this._controllers[a];c!==null&&d!==void 0&&d.update(c,e,i)}this._currentAnimationLoop&&this._currentAnimationLoop(o,e),e.detectedPlanes&&this.dispatchEvent({type:"planesdetected",data:e}),this._xrFrame=null}const Do=new l.Scene,Xs=new l.Vector2,tn=new l.Vector4,sn=new l.Frustum,rn=new l.FrustumArray,Ks=new l.Matrix4,rt=new l.Vector4;class Ym{constructor(e,t={}){this.isRenderer=!0;const{logarithmicDepthBuffer:s=!1,alpha:r=!0,depth:n=!0,stencil:i=!1,antialias:u=!1,samples:a=0,getFallback:c=null,colorBufferType:d=l.HalfFloatType,multiview:h=!1}=t;this.domElement=e.getDomElement(),this.backend=e,this.samples=a||u===!0?4:0,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=r,this.logarithmicDepthBuffer=s,this.outputColorSpace=l.SRGBColorSpace,this.toneMapping=l.NoToneMapping,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=n,this.stencil=i,this.info=new Yf,this.overrideNodes={modelViewMatrix:null,modelNormalViewMatrix:null},this.library=new Ul,this.lighting=new Gl,this._getFallback=c,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new l.Vector4(0,0,this._width,this._height),this._scissor=new l.Vector4(0,0,this._width,this._height),this._scissorTest=!1,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quad=new Rr(new ce),this._quad.material.name="Renderer_output",this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTarget=null;const p=this.alpha===!0?0:1;this._clearColor=new mi(0,0,0,p),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._outputRenderTarget=null,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this._colorBufferType=d,this._initialized=!1,this._initPromise=null,this._compilationPromises=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,type:l.PCFShadowMap},this.xr=new zm(this,h),this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:async(f,g,m)=>{await this.compileAsync(f,g);const y=this._renderLists.get(f,g),_=this._renderContexts.get(f,g,this._renderTarget),C=f.overrideMaterial||m.material,R=this._objects.get(m,C,f,g,y.lightsNode,_,_.clippingContext),{fragmentShader:U,vertexShader:M}=R.getNodeBuilderState();return{fragmentShader:U,vertexShader:M}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise(async(e,t)=>{let s=this.backend;try{await s.init(this)}catch(r){if(this._getFallback!==null)try{this.backend=s=this._getFallback(r),await s.init(this)}catch(n){t(n);return}else{t(r);return}}this._nodes=new Im(this,s),this._animation=new kf(this._nodes,this.info),this._attributes=new Kf(s),this._background=new dm(this,this._nodes),this._geometries=new Qf(this._attributes,this.info),this._textures=new dg(this,s,this.info),this._pipelines=new eg(s,this._nodes),this._bindings=new tg(s,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new Hf(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new ng(this.lighting),this._bundles=new Vm,this._renderContexts=new lg,this._animation.start(),this._initialized=!0,e(this)}),this._initPromise)}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,s=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();const r=this._nodes.nodeFrame,n=r.renderId,i=this._currentRenderContext,u=this._currentRenderObjectFunction,a=this._compilationPromises,c=e.isScene===!0?e:Do;s===null&&(s=e);const d=this._renderTarget,h=this._renderContexts.get(s,t,d),p=this._activeMipmapLevel,f=[];this._currentRenderContext=h,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=f,r.renderId++,r.update(),h.depth=this.depth,h.stencil=this.stencil,h.clippingContext||(h.clippingContext=new hr),h.clippingContext.updateGlobal(c,t),c.onBeforeRender(this,e,t,d);const g=this._renderLists.get(e,t);if(g.begin(),this._projectObject(e,t,0,g,h.clippingContext),s!==e&&s.traverseVisible(function(R){R.isLight&&R.layers.test(t.layers)&&g.pushLight(R)}),g.finish(),d!==null){this._textures.updateRenderTarget(d,p);const R=this._textures.get(d);h.textures=R.textures,h.depthTexture=R.depthTexture}else h.textures=null,h.depthTexture=null;this._background.update(c,g,h);const m=g.opaque,y=g.transparent,_=g.transparentDoublePass,C=g.lightsNode;this.opaque===!0&&m.length>0&&this._renderObjects(m,t,c,C),this.transparent===!0&&y.length>0&&this._renderTransparents(y,_,t,c,C),r.renderId=n,this._currentRenderContext=i,this._currentRenderObjectFunction=u,this._compilationPromises=a,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(f)}async renderAsync(e,t){this._initialized===!1&&await this.init(),this._renderScene(e,t)}async waitForGPU(){await this.backend.waitForGPU()}set highPrecision(e){e===!0?(this.overrideNodes.modelViewMatrix=Li,this.overrideNodes.modelNormalViewMatrix=Ui):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===Li&&this.overrideNodes.modelNormalViewMatrix===Ui}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:
35
-
36
- Message: ${e.message}`;e.reason&&(t+=`
37
- Reason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,s){const{bundleGroup:r,camera:n,renderList:i}=e,u=this._currentRenderContext,a=this._bundles.get(r,n),c=this.backend.get(a);c.renderContexts===void 0&&(c.renderContexts=new Set);const d=r.version!==c.version,h=c.renderContexts.has(u)===!1||d;if(c.renderContexts.add(u),h){this.backend.beginBundle(u),(c.renderObjects===void 0||d)&&(c.renderObjects=[]),this._currentRenderBundle=a;const{transparentDoublePass:p,transparent:f,opaque:g}=i;this.opaque===!0&&g.length>0&&this._renderObjects(g,n,t,s),this.transparent===!0&&f.length>0&&this._renderTransparents(f,p,n,t,s),this._currentRenderBundle=null,this.backend.finishBundle(u,a),c.version=r.version}else{const{renderObjects:p}=c;for(let f=0,g=p.length;f<g;f++){const m=p[f];this._nodes.needsRefresh(m)&&(this._nodes.updateBefore(m),this._nodes.updateForRender(m),this._bindings.updateForRender(m),this._nodes.updateAfter(m))}}this.backend.addBundle(u,a)}render(e,t){if(this._initialized===!1)return console.warn("THREE.Renderer: .render() called before the backend is initialized. Try using .renderAsync() instead."),this.renderAsync(e,t);this._renderScene(e,t)}_getFrameBufferTarget(){const{currentToneMapping:e,currentColorSpace:t}=this,s=e!==l.NoToneMapping,r=t!==l.LinearSRGBColorSpace;if(s===!1&&r===!1)return null;const{width:n,height:i}=this.getDrawingBufferSize(Xs),{depth:u,stencil:a}=this;let c=this._frameBufferTarget;c===null&&(c=new l.RenderTarget(n,i,{depthBuffer:u,stencilBuffer:a,type:this._colorBufferType,format:l.RGBAFormat,colorSpace:l.LinearSRGBColorSpace,generateMipmaps:!1,minFilter:l.LinearFilter,magFilter:l.LinearFilter,samples:this.samples}),c.isPostProcessingRenderTarget=!0,this._frameBufferTarget=c);const d=this.getOutputRenderTarget();return c.depthBuffer=u,c.stencilBuffer=a,d!==null?c.setSize(d.width,d.height,d.depth):c.setSize(n,i,1),c.viewport.copy(this._viewport),c.scissor.copy(this._scissor),c.viewport.multiplyScalar(this._pixelRatio),c.scissor.multiplyScalar(this._pixelRatio),c.scissorTest=this._scissorTest,c.multiview=d!==null?d.multiview:!1,c.resolveDepthBuffer=d!==null?d.resolveDepthBuffer:!0,c._autoAllocateDepthBuffer=d!==null?d._autoAllocateDepthBuffer:!1,c}_renderScene(e,t,s=!0){if(this._isDeviceLost===!0)return;const r=s?this._getFrameBufferTarget():null,n=this._nodes.nodeFrame,i=n.renderId,u=this._currentRenderContext,a=this._currentRenderObjectFunction,c=e.isScene===!0?e:Do,d=this._renderTarget||this._outputRenderTarget,h=this._activeCubeFace,p=this._activeMipmapLevel;let f;r!==null?(f=r,this.setRenderTarget(f)):f=d;const g=this._renderContexts.get(e,t,f);this._currentRenderContext=g,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,n.renderId=this.info.calls;const m=this.coordinateSystem,y=this.xr;if(t.coordinateSystem!==m&&y.isPresenting===!1&&(t.coordinateSystem=m,t.updateProjectionMatrix(),t.isArrayCamera))for(const te of t.cameras)te.coordinateSystem=m,te.updateProjectionMatrix();e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),y.enabled===!0&&y.isPresenting===!0&&(y.cameraAutoUpdate===!0&&y.updateCamera(t),t=y.getCamera());let _=this._viewport,C=this._scissor,R=this._pixelRatio;f!==null&&(_=f.viewport,C=f.scissor,R=1),this.getDrawingBufferSize(Xs),tn.set(0,0,Xs.width,Xs.height);const U=_.minDepth===void 0?0:_.minDepth,M=_.maxDepth===void 0?1:_.maxDepth;g.viewportValue.copy(_).multiplyScalar(R).floor(),g.viewportValue.width>>=p,g.viewportValue.height>>=p,g.viewportValue.minDepth=U,g.viewportValue.maxDepth=M,g.viewport=g.viewportValue.equals(tn)===!1,g.scissorValue.copy(C).multiplyScalar(R).floor(),g.scissor=this._scissorTest&&g.scissorValue.equals(tn)===!1,g.scissorValue.width>>=p,g.scissorValue.height>>=p,g.clippingContext||(g.clippingContext=new hr),g.clippingContext.updateGlobal(c,t),c.onBeforeRender(this,e,t,f);const D=t.isArrayCamera?rn:sn;t.isArrayCamera||(Ks.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),D.setFromProjectionMatrix(Ks,m));const F=this._renderLists.get(e,t);if(F.begin(),this._projectObject(e,t,0,F,g.clippingContext),F.finish(),this.sortObjects===!0&&F.sort(this._opaqueSort,this._transparentSort),f!==null){this._textures.updateRenderTarget(f,p);const te=this._textures.get(f);g.textures=te.textures,g.depthTexture=te.depthTexture,g.width=te.width,g.height=te.height,g.renderTarget=f,g.depth=f.depthBuffer,g.stencil=f.stencilBuffer}else g.textures=null,g.depthTexture=null,g.width=this.domElement.width,g.height=this.domElement.height,g.depth=this.depth,g.stencil=this.stencil;g.width>>=p,g.height>>=p,g.activeCubeFace=h,g.activeMipmapLevel=p,g.occlusionQueryCount=F.occlusionQueryCount,this._background.update(c,F,g),g.camera=t,this.backend.beginRender(g);const{bundles:L,lightsNode:G,transparentDoublePass:H,transparent:q,opaque:ee}=F;return L.length>0&&this._renderBundles(L,c,G),this.opaque===!0&&ee.length>0&&this._renderObjects(ee,t,c,G),this.transparent===!0&&q.length>0&&this._renderTransparents(q,H,t,c,G),this.backend.finishRender(g),n.renderId=i,this._currentRenderContext=u,this._currentRenderObjectFunction=a,r!==null&&(this.setRenderTarget(d,h,p),this._renderOutput(f)),c.onAfterRender(this,e,t,f),g}_setXRLayerSize(e,t){this._width=e,this._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);const s=this.autoClear,r=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=s,this.xr.enabled=r}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,s){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=s,this.domElement.width=Math.floor(e*s),this.domElement.height=Math.floor(t*s),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setSize(e,t,s=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),s===!0&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,s,r){const n=this._scissor;e.isVector4?n.copy(e):n.set(e,t,s,r)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,s,r,n=0,i=1){const u=this._viewport;e.isVector4?u.copy(e):u.set(e,t,s,r),u.minDepth=n,u.maxDepth=i}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,s=!0){if(this._initialized===!1)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,s);const r=this._renderTarget||this._getFrameBufferTarget();let n=null;if(r!==null){this._textures.updateRenderTarget(r);const i=this._textures.get(r);n=this._renderContexts.getForClear(r),n.textures=i.textures,n.depthTexture=i.depthTexture,n.width=i.width,n.height=i.height,n.renderTarget=r,n.depth=r.depthBuffer,n.stencil=r.stencilBuffer,n.clearColorValue=this.backend.getClearColor(),n.activeCubeFace=this.getActiveCubeFace(),n.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,s,n),r!==null&&this._renderTarget===null&&this._renderOutput(r)}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,s=!0){this._initialized===!1&&await this.init(),this.clear(e,t,s)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:l.NoToneMapping}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:l.LinearSRGBColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this._frameBufferTarget!==null&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()}),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,s=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=s}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,s=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const r=this.backend,n=this._pipelines,i=this._bindings,u=this._nodes,a=Array.isArray(e)?e:[e];if(a[0]===void 0||a[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");r.beginCompute(e);for(const c of a){if(n.has(c)===!1){const p=()=>{c.removeEventListener("dispose",p),n.delete(c),i.delete(c),u.delete(c)};c.addEventListener("dispose",p);const f=c.onInitFunction;f!==null&&f.call(c,{renderer:this})}u.updateForCompute(c),i.updateForCompute(c);const d=i.getForCompute(c),h=n.getForCompute(c,d);r.compute(e,c,d,h)}r.finishCompute(e),t.renderId=s}async computeAsync(e){this._initialized===!1&&await this.init(),this.compute(e)}async hasFeatureAsync(e){return this._initialized===!1&&await this.init(),this.backend.hasFeature(e)}async resolveTimestampsAsync(e="render"){return this._initialized===!1&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){return this._initialized===!1?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){this._initialized===!1&&await this.init(),this._textures.updateTexture(e)}initTexture(e){this._initialized===!1&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=rt.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=rt.copy(t).floor();else{console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=rt.set(0,0,e.image.width,e.image.height);let s=this._currentRenderContext,r;s!==null?r=s.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),r!==null&&(this._textures.updateRenderTarget(r),s=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,s,t)}copyTextureToTexture(e,t,s=null,r=null,n=0,i=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,s,r,n,i)}async readRenderTargetPixelsAsync(e,t,s,r,n,i=0,u=0){return this.backend.copyTextureToBuffer(e.textures[i],t,s,r,n,u)}_projectObject(e,t,s,r,n){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)s=e.renderOrder,e.isClippingGroup&&e.enabled&&(n=n.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){const a=t.isArrayCamera?rn:sn;if(!e.frustumCulled||a.intersectsSprite(e,t)){this.sortObjects===!0&&rt.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Ks);const{geometry:c,material:d}=e;d.visible&&r.push(e,c,d,s,rt.z,null,n)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const a=t.isArrayCamera?rn:sn;if(!e.frustumCulled||a.intersectsObject(e,t)){const{geometry:c,material:d}=e;if(this.sortObjects===!0&&(c.boundingSphere===null&&c.computeBoundingSphere(),rt.copy(c.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(Ks)),Array.isArray(d)){const h=c.groups;for(let p=0,f=h.length;p<f;p++){const g=h[p],m=d[g.materialIndex];m&&m.visible&&r.push(e,c,m,s,rt.z,g,n)}}else d.visible&&r.push(e,c,d,s,rt.z,null,n)}}}if(e.isBundleGroup===!0&&this.backend.beginBundle!==void 0){const a=r;r=this._renderLists.get(e,t),r.begin(),a.pushBundle({bundleGroup:e,camera:t,renderList:r}),r.finish()}const u=e.children;for(let a=0,c=u.length;a<c;a++)this._projectObject(u[a],t,s,r,n)}_renderBundles(e,t,s){for(const r of e)this._renderBundle(r,t,s)}_renderTransparents(e,t,s,r,n){if(t.length>0){for(const{material:i}of t)i.side=l.BackSide;this._renderObjects(t,s,r,n,"backSide");for(const{material:i}of t)i.side=l.FrontSide;this._renderObjects(e,s,r,n);for(const{material:i}of t)i.side=l.DoubleSide}else this._renderObjects(e,s,r,n)}_renderObjects(e,t,s,r,n=null){for(let i=0,u=e.length;i<u;i++){const{object:a,geometry:c,material:d,group:h,clippingContext:p}=e[i];this._currentRenderObjectFunction(a,s,t,c,d,h,r,p,n)}}renderObject(e,t,s,r,n,i,u,a=null,c=null){let d,h,p;if(e.onBeforeRender(this,t,s,r,n,i),n.allowOverride===!0&&t.overrideMaterial!==null){const f=t.overrideMaterial;n.positionNode&&n.positionNode.isNode&&(d=f.positionNode,f.positionNode=n.positionNode),f.alphaTest=n.alphaTest,f.alphaMap=n.alphaMap,f.transparent=n.transparent||n.transmission>0,f.isShadowPassMaterial&&(f.side=n.shadowSide===null?n.side:n.shadowSide,n.depthNode&&n.depthNode.isNode&&(p=f.depthNode,f.depthNode=n.depthNode),n.castShadowNode&&n.castShadowNode.isNode&&(h=f.colorNode,f.colorNode=n.castShadowNode),n.castShadowPositionNode&&n.castShadowPositionNode.isNode&&(d=f.positionNode,f.positionNode=n.castShadowPositionNode)),n=f}n.transparent===!0&&n.side===l.DoubleSide&&n.forceSinglePass===!1?(n.side=l.BackSide,this._handleObjectFunction(e,n,t,s,u,i,a,"backSide"),n.side=l.FrontSide,this._handleObjectFunction(e,n,t,s,u,i,a,c),n.side=l.DoubleSide):this._handleObjectFunction(e,n,t,s,u,i,a,c),d!==void 0&&(t.overrideMaterial.positionNode=d),p!==void 0&&(t.overrideMaterial.depthNode=p),h!==void 0&&(t.overrideMaterial.colorNode=h),e.onAfterRender(this,t,s,r,n,i)}_renderObjectDirect(e,t,s,r,n,i,u,a){const c=this._objects.get(e,t,s,r,n,this._currentRenderContext,u,a);c.drawRange=e.geometry.drawRange,c.group=i;const d=this._nodes.needsRefresh(c);d&&(this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c)),this._pipelines.updateForRender(c),this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(c),c.bundle=this._currentRenderBundle.bundleGroup),this.backend.draw(c,this.info),d&&this._nodes.updateAfter(c)}_createObjectPipeline(e,t,s,r,n,i,u,a){const c=this._objects.get(e,t,s,r,n,this._currentRenderContext,u,a);c.drawRange=e.geometry.drawRange,c.group=i,this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c),this._pipelines.getForRender(c,this._compilationPromises),this._nodes.updateAfter(c)}get compile(){return this.compileAsync}}class Ni{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}function jm(o){return o+(at-o%at)%at}class Il extends Ni{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return jm(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class Ol extends Il{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let Zm=0;class Vl extends Ol{constructor(e,t){super("UniformBuffer_"+Zm++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class Jm extends Ol{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let s=0,r=this.uniforms.length;s<r;s++){const n=this.uniforms[s],i=n.boundary,u=n.itemSize*e,a=t%at,c=a%i,d=a+c;t+=c,d!==0&&at-d<u&&(t+=at-d),n.offset=t/e,t+=u}return Math.ceil(t/at)*at}update(){let e=!1;for(const t of this.uniforms)this.updateByType(t)===!0&&(e=!0);return e}updateByType(e){if(e.isNumberUniform)return this.updateNumber(e);if(e.isVector2Uniform)return this.updateVector2(e);if(e.isVector3Uniform)return this.updateVector3(e);if(e.isVector4Uniform)return this.updateVector4(e);if(e.isColorUniform)return this.updateColor(e);if(e.isMatrix3Uniform)return this.updateMatrix3(e);if(e.isMatrix4Uniform)return this.updateMatrix4(e);console.error("THREE.WebGPUUniformsGroup: Unsupported uniform type.",e)}updateNumber(e){let t=!1;const s=this.values,r=e.getValue(),n=e.offset,i=e.getType();if(s[n]!==r){const u=this._getBufferForType(i);u[n]=s[n]=r,t=!0}return t}updateVector2(e){let t=!1;const s=this.values,r=e.getValue(),n=e.offset,i=e.getType();if(s[n+0]!==r.x||s[n+1]!==r.y){const u=this._getBufferForType(i);u[n+0]=s[n+0]=r.x,u[n+1]=s[n+1]=r.y,t=!0}return t}updateVector3(e){let t=!1;const s=this.values,r=e.getValue(),n=e.offset,i=e.getType();if(s[n+0]!==r.x||s[n+1]!==r.y||s[n+2]!==r.z){const u=this._getBufferForType(i);u[n+0]=s[n+0]=r.x,u[n+1]=s[n+1]=r.y,u[n+2]=s[n+2]=r.z,t=!0}return t}updateVector4(e){let t=!1;const s=this.values,r=e.getValue(),n=e.offset,i=e.getType();if(s[n+0]!==r.x||s[n+1]!==r.y||s[n+2]!==r.z||s[n+4]!==r.w){const u=this._getBufferForType(i);u[n+0]=s[n+0]=r.x,u[n+1]=s[n+1]=r.y,u[n+2]=s[n+2]=r.z,u[n+3]=s[n+3]=r.w,t=!0}return t}updateColor(e){let t=!1;const s=this.values,r=e.getValue(),n=e.offset;if(s[n+0]!==r.r||s[n+1]!==r.g||s[n+2]!==r.b){const i=this.buffer;i[n+0]=s[n+0]=r.r,i[n+1]=s[n+1]=r.g,i[n+2]=s[n+2]=r.b,t=!0}return t}updateMatrix3(e){let t=!1;const s=this.values,r=e.getValue().elements,n=e.offset;if(s[n+0]!==r[0]||s[n+1]!==r[1]||s[n+2]!==r[2]||s[n+4]!==r[3]||s[n+5]!==r[4]||s[n+6]!==r[5]||s[n+8]!==r[6]||s[n+9]!==r[7]||s[n+10]!==r[8]){const i=this.buffer;i[n+0]=s[n+0]=r[0],i[n+1]=s[n+1]=r[1],i[n+2]=s[n+2]=r[2],i[n+4]=s[n+4]=r[3],i[n+5]=s[n+5]=r[4],i[n+6]=s[n+6]=r[5],i[n+8]=s[n+8]=r[6],i[n+9]=s[n+9]=r[7],i[n+10]=s[n+10]=r[8],t=!0}return t}updateMatrix4(e){let t=!1;const s=this.values,r=e.getValue().elements,n=e.offset;return tT(s,r,n)===!1&&(this.buffer.set(r,n),eT(s,r,n),t=!0),t}_getBufferForType(e){return e==="int"||e==="ivec2"||e==="ivec3"||e==="ivec4"?new Int32Array(this.buffer.buffer):e==="uint"||e==="uvec2"||e==="uvec3"||e==="uvec4"?new Uint32Array(this.buffer.buffer):this.buffer}}function eT(o,e,t){for(let s=0,r=e.length;s<r;s++)o[t+s]=e[s]}function tT(o,e,t){for(let s=0,r=e.length;s<r;s++)if(o[t+s]!==e[s])return!1;return!0}let sT=0;class kl extends Jm{constructor(e,t){super(e),this.id=sT++,this.groupNode=t,this.isNodeUniformsGroup=!0}}let rT=0;class nT extends Ni{constructor(e,t){super(e),this.id=rT++,this.texture=t,this.version=t?t.version:0,this.store=!1,this.generation=null,this.isSampledTexture=!0}needsBindingsUpdate(e){const{texture:t}=this;return e!==this.generation?(this.generation=e,!0):t.isVideoTexture}update(){const{texture:e,version:t}=this;return t!==e.version?(this.version=e.version,!0):!1}}class Er extends nT{constructor(e,t,s,r=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=s,this.access=r}needsBindingsUpdate(e){return this.textureNode.value!==this.texture||super.needsBindingsUpdate(e)}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class zl extends Er{constructor(e,t,s,r=null){super(e,t,s,r),this.isSampledCubeTexture=!0}}class $l extends Er{constructor(e,t,s,r=null){super(e,t,s,r),this.isSampledTexture3D=!0}}const iT={textureDimensions:"textureSize",equals:"equal"},oT={low:"lowp",medium:"mediump",high:"highp"},Lo={swizzleAssign:!0,storageBuffer:!1},Uo={perspective:"smooth",linear:"noperspective"},Go={centroid:"centroid"},Io=`
38
- precision highp float;
39
- precision highp int;
40
- precision highp sampler2D;
41
- precision highp sampler3D;
42
- precision highp samplerCube;
43
- precision highp sampler2DArray;
44
-
45
- precision highp usampler2D;
46
- precision highp usampler3D;
47
- precision highp usamplerCube;
48
- precision highp usampler2DArray;
49
-
50
- precision highp isampler2D;
51
- precision highp isampler3D;
52
- precision highp isamplerCube;
53
- precision highp isampler2DArray;
54
-
55
- precision lowp sampler2DShadow;
56
- precision lowp sampler2DArrayShadow;
57
- precision lowp samplerCubeShadow;
58
- `;class aT extends _i{constructor(e,t){super(e,t,new Ll),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==l.NoColorSpace}getMethod(e){return iT[e]||e}getOutputStructName(){return""}buildFunctionCode(e){const t=e.layout,s=this.flowShaderNode(e),r=[];for(const i of t.inputs)r.push(this.getType(i.type)+" "+i.name);return`${this.getType(t.type)} ${t.name}( ${r.join(", ")} ) {
59
-
60
- ${s.vars}
61
-
62
- ${s.code}
63
- return ${s.result};
64
-
65
- }`}setupPBO(e){const t=e.value;if(t.pbo===void 0){const s=t.array,r=t.count*t.itemSize,{itemSize:n}=t,i=t.array.constructor.name.toLowerCase().includes("int");let u=i?l.RedIntegerFormat:l.RedFormat;n===2?u=i?l.RGIntegerFormat:l.RGFormat:n===3?u=i?l.RGBIntegerFormat:l.RGBFormat:n===4&&(u=i?l.RGBAIntegerFormat:l.RGBAFormat);const a={Float32Array:l.FloatType,Uint8Array:l.UnsignedByteType,Uint16Array:l.UnsignedShortType,Uint32Array:l.UnsignedIntType,Int8Array:l.ByteType,Int16Array:l.ShortType,Int32Array:l.IntType,Uint8ClampedArray:l.UnsignedByteType},c=Math.pow(2,Math.ceil(Math.log2(Math.sqrt(r/n))));let d=Math.ceil(r/n/c);c*d*n<r&&d++;const h=c*d*n,p=new s.constructor(h);p.set(s,0),t.array=p;const f=new l.DataTexture(t.array,c,d,u,a[t.array.constructor.name]||l.FloatType);f.needsUpdate=!0,f.isPBOTexture=!0;const g=new Mt(f,null,null);g.setPrecision("high"),t.pboNode=g,t.pbo=g.value,this.getUniformFromNode(t.pboNode,"texture",this.shaderStage,this.context.label)}}getPropertyName(e,t=this.shaderStage){return e.isNodeUniform&&e.node.isTextureNode!==!0&&e.node.isBufferNode!==!0?t.charAt(0)+"_"+e.name:super.getPropertyName(e,t)}generatePBO(e){const{node:t,indexNode:s}=e,r=t.value;if(this.renderer.backend.has(r)){const d=this.renderer.backend.get(r);d.pbo=r.pbo}const n=this.getUniformFromNode(r.pboNode,"texture",this.shaderStage,this.context.label),i=this.getPropertyName(n);this.increaseUsage(s);const u=s.build(this,"uint"),a=this.getDataFromNode(e);let c=a.propertyName;if(c===void 0){const d=this.getVarFromNode(e);c=this.getPropertyName(d);const h=this.getDataFromNode(t);let p=h.propertySizeName;p===void 0&&(p=c+"Size",this.getVarFromNode(t,p,"uint"),this.addLineFlowCode(`${p} = uint( textureSize( ${i}, 0 ).x )`,e),h.propertySizeName=p);const{itemSize:f}=r,g="."+Bt.join("").slice(0,f),m=`ivec2(${u} % ${p}, ${u} / ${p})`,y=this.generateTextureLoad(null,i,m,null,"0");let _="vec4";r.pbo.type===l.UnsignedIntType?_="uvec4":r.pbo.type===l.IntType&&(_="ivec4"),this.addLineFlowCode(`${c} = ${_}(${y})${g}`,e),a.propertyName=c}return c}generateTextureLoad(e,t,s,r,n="0"){return r?`texelFetch( ${t}, ivec3( ${s}, ${r} ), ${n} )`:`texelFetch( ${t}, ${s}, ${n} )`}generateTexture(e,t,s,r){return e.isDepthTexture?(r&&(s=`vec4( ${s}, ${r} )`),`texture( ${t}, ${s} ).x`):(r&&(s=`vec3( ${s}, ${r} )`),`texture( ${t}, ${s} )`)}generateTextureLevel(e,t,s,r){return`textureLod( ${t}, ${s}, ${r} )`}generateTextureBias(e,t,s,r){return`texture( ${t}, ${s}, ${r} )`}generateTextureGrad(e,t,s,r){return`textureGrad( ${t}, ${s}, ${r[0]}, ${r[1]} )`}generateTextureCompare(e,t,s,r,n,i=this.shaderStage){if(i==="fragment")return n?`texture( ${t}, vec4( ${s}, ${n}, ${r} ) )`:`texture( ${t}, vec3( ${s}, ${r} ) )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${i} shader.`)}getVars(e){const t=[],s=this.vars[e];if(s!==void 0)for(const r of s)t.push(`${this.getVar(r.type,r.name,r.count)};`);return t.join(`
66
- `)}getUniforms(e){const t=this.uniforms[e],s=[],r={};for(const i of t){let u=null,a=!1;if(i.type==="texture"||i.type==="texture3D"){const d=i.node.value;let h="";(d.isDataTexture===!0||d.isData3DTexture===!0)&&(d.type===l.UnsignedIntType?h="u":d.type===l.IntType&&(h="i")),i.type==="texture3D"&&d.isArrayTexture===!1?u=`${h}sampler3D ${i.name};`:d.compareFunction?d.isArrayTexture===!0?u=`sampler2DArrayShadow ${i.name};`:u=`sampler2DShadow ${i.name};`:d.isArrayTexture===!0||d.isDataArrayTexture===!0||d.isCompressedArrayTexture===!0?u=`${h}sampler2DArray ${i.name};`:u=`${h}sampler2D ${i.name};`}else if(i.type==="cubeTexture")u=`samplerCube ${i.name};`;else if(i.type==="buffer"){const d=i.node,h=this.getType(d.bufferType),p=d.bufferCount,f=p>0?p:"";u=`${d.name} {
67
- ${h} ${i.name}[${f}];
68
- };
69
- `}else u=`${this.getVectorType(i.type)} ${this.getPropertyName(i,e)};`,a=!0;const c=i.node.precision;if(c!==null&&(u=oT[c]+" "+u),a){u=" "+u;const d=i.groupNode.name;(r[d]||(r[d]=[])).push(u)}else u="uniform "+u,s.push(u)}let n="";for(const i in r){const u=r[i];n+=this._getGLSLUniformStruct(e+"_"+i,u.join(`
70
- `))+`
71
- `}return n+=s.join(`
72
- `),n}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==l.IntType){let s=e;e.isInterleavedBufferAttribute&&(s=e.data);const r=s.array;r instanceof Uint32Array||r instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const s=this.getAttributesArray();let r=0;for(const n of s)t+=`layout( location = ${r++} ) in ${n.type} ${n.name};
73
- `}return t}getStructMembers(e){const t=[];for(const s of e.members)t.push(` ${s.type} ${s.name};`);return t.join(`
74
- `)}getStructs(e){const t=[],s=this.structs[e],r=[];for(const n of s)if(n.output)for(const i of n.members)r.push(`layout( location = ${i.index} ) out ${i.type} ${i.name};`);else{let i="struct "+n.name+` {
75
- `;i+=this.getStructMembers(n),i+=`
76
- };
77
- `,t.push(i)}return r.length===0&&r.push("layout( location = 0 ) out vec4 fragColor;"),`
78
- `+r.join(`
79
- `)+`
80
-
81
- `+t.join(`
82
- `)}getVaryings(e){let t="";const s=this.varyings;if(e==="vertex"||e==="compute")for(const r of s){e==="compute"&&(r.needsInterpolation=!0);const n=this.getType(r.type);if(r.needsInterpolation)if(r.interpolationType){const i=Uo[r.interpolationType]||r.interpolationType,u=Go[r.interpolationSampling]||"";t+=`${i} ${u} out ${n} ${r.name};
83
- `}else{const i=n.includes("int")||n.includes("uv")||n.includes("iv")?"flat ":"";t+=`${i}out ${n} ${r.name};
84
- `}else t+=`${n} ${r.name};
85
- `}else if(e==="fragment"){for(const r of s)if(r.needsInterpolation){const n=this.getType(r.type);if(r.interpolationType){const i=Uo[r.interpolationType]||r.interpolationType,u=Go[r.interpolationSampling]||"";t+=`${i} ${u} in ${n} ${r.name};
86
- `}else{const i=n.includes("int")||n.includes("uv")||n.includes("iv")?"flat ":"";t+=`${i}in ${n} ${r.name};
87
- `}}}for(const r of this.builtins[e])t+=`${r};
88
- `;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((s,r)=>s*r,1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,s=this.shaderStage){const r=this.extensions[s]||(this.extensions[s]=new Map);r.has(e)===!1&&r.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const r=this.renderer.backend.extensions;this.object.isBatchedMesh&&r.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const s=this.extensions[e];if(s!==void 0)for(const{name:r,behavior:n}of s.values())t.push(`#extension ${r} : ${n}`);return t.join(`
89
- `)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=Lo[e];if(t===void 0){let s;switch(t=!1,e){case"float32Filterable":s="OES_texture_float_linear";break;case"clipDistance":s="WEBGL_clip_cull_distance";break}if(s!==void 0){const r=this.renderer.backend.extensions;r.has(s)&&(r.get(s),t=!0)}Lo[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let s=0;s<e.length;s++){const r=e[s],n=this.getPropertyName(r.attributeNode);n&&(t+=`${r.varyingName} = ${n};
90
- `)}return t}_getGLSLUniformStruct(e,t){return`
91
- layout( std140 ) uniform ${e} {
92
- ${t}
93
- };`}_getGLSLVertexCode(e){return`#version 300 es
94
-
95
- ${this.getSignature()}
96
-
97
- // extensions
98
- ${e.extensions}
99
-
100
- // precision
101
- ${Io}
102
-
103
- // uniforms
104
- ${e.uniforms}
105
-
106
- // varyings
107
- ${e.varyings}
108
-
109
- // attributes
110
- ${e.attributes}
111
-
112
- // codes
113
- ${e.codes}
114
-
115
- void main() {
116
-
117
- // vars
118
- ${e.vars}
119
-
120
- // transforms
121
- ${e.transforms}
122
-
123
- // flow
124
- ${e.flow}
125
-
126
- gl_PointSize = 1.0;
127
-
128
- }
129
- `}_getGLSLFragmentCode(e){return`#version 300 es
130
-
131
- ${this.getSignature()}
132
-
133
- // extensions
134
- ${e.extensions}
135
-
136
- // precision
137
- ${Io}
138
-
139
- // uniforms
140
- ${e.uniforms}
141
-
142
- // varyings
143
- ${e.varyings}
144
-
145
- // codes
146
- ${e.codes}
147
-
148
- // structs
149
- ${e.structs}
150
-
151
- void main() {
152
-
153
- // vars
154
- ${e.vars}
155
-
156
- // flow
157
- ${e.flow}
158
-
159
- }
160
- `}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){let s=`// code
161
-
162
- `;s+=this.flowCode[t];const r=this.flowNodes[t],n=r[r.length-1];for(const u of r){const a=this.getFlowData(u),c=u.name;c&&(s.length>0&&(s+=`
163
- `),s+=` // flow -> ${c}
164
- `),s+=`${a.code}
165
- `,u===n&&t!=="compute"&&(s+=`// result
166
- `,t==="vertex"?(s+="gl_Position = ",s+=`${a.result};`):t==="fragment"&&(u.outputNode.isOutputStructNode||(s+="fragColor = ",s+=`${a.result};`)))}const i=e[t];i.extensions=this.getExtensions(t),i.uniforms=this.getUniforms(t),i.attributes=this.getAttributes(t),i.varyings=this.getVaryings(t),i.vars=this.getVars(t),i.structs=this.getStructs(t),i.codes=this.getCodes(t),i.transforms=this.getTransforms(t),i.flow=s}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,s,r=null){const n=super.getUniformFromNode(e,t,s,r),i=this.getDataFromNode(e,s,this.globalCache);let u=i.uniformGPU;if(u===void 0){const a=e.groupNode,c=a.name,d=this.getBindGroupArray(c,s);if(t==="texture")u=new Er(n.name,n.node,a),d.push(u);else if(t==="cubeTexture")u=new zl(n.name,n.node,a),d.push(u);else if(t==="texture3D")u=new $l(n.name,n.node,a),d.push(u);else if(t==="buffer"){e.name=`NodeBuffer_${e.id}`,n.name=`buffer${e.id}`;const h=new Vl(e,a);h.name=e.name,d.push(h),u=h}else{const h=this.uniformGroups[s]||(this.uniformGroups[s]={});let p=h[c];p===void 0&&(p=new kl(s+"_"+c,a),h[c]=p,d.push(p)),u=this.getNodeUniform(n,t),p.addUniform(u)}i.uniformGPU=u}return n}}let nn=null,Lt=null;class Wl{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={render:null,compute:null},this.trackTimestamp=e.trackTimestamp===!0}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp){l.warnOnce("WebGPURenderer: Timestamp tracking is disabled.");return}const t=this.timestampQueryPool[e];if(!t){l.warnOnce(`WebGPURenderer: No timestamp query pool for type '${e}' found.`);return}const s=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=s,s}async waitForGPU(){}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return nn=nn||new l.Vector2,this.renderer.getDrawingBufferSize(nn)}setScissorTest(){}getClearColor(){const e=this.renderer;return Lt=Lt||new mi,e.getClearColor(Lt),Lt.getRGB(Lt),Lt}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:l.createCanvasElement(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${l.REVISION} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let uT=0;class lT{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}}class cT{constructor(e){this.backend=e}createAttribute(e,t){const s=this.backend,{gl:r}=s,n=e.array,i=e.usage||r.STATIC_DRAW,u=e.isInterleavedBufferAttribute?e.data:e,a=s.get(u);let c=a.bufferGPU;c===void 0&&(c=this._createBuffer(r,t,n,i),a.bufferGPU=c,a.bufferType=t,a.version=u.version);let d;if(n instanceof Float32Array)d=r.FLOAT;else if(typeof Float16Array<"u"&&n instanceof Float16Array)d=r.HALF_FLOAT;else if(n instanceof Uint16Array)e.isFloat16BufferAttribute?d=r.HALF_FLOAT:d=r.UNSIGNED_SHORT;else if(n instanceof Int16Array)d=r.SHORT;else if(n instanceof Uint32Array)d=r.UNSIGNED_INT;else if(n instanceof Int32Array)d=r.INT;else if(n instanceof Int8Array)d=r.BYTE;else if(n instanceof Uint8Array)d=r.UNSIGNED_BYTE;else if(n instanceof Uint8ClampedArray)d=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+n);let h={bufferGPU:c,bufferType:t,type:d,byteLength:n.byteLength,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:d===r.INT||d===r.UNSIGNED_INT||e.gpuType===l.IntType,id:uT++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const p=this._createBuffer(r,t,n,i);h=new lT(h,p)}s.set(e,h)}updateAttribute(e){const t=this.backend,{gl:s}=t,r=e.array,n=e.isInterleavedBufferAttribute?e.data:e,i=t.get(n),u=i.bufferType,a=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(s.bindBuffer(u,i.bufferGPU),a.length===0)s.bufferSubData(u,0,r);else{for(let c=0,d=a.length;c<d;c++){const h=a[c];s.bufferSubData(u,h.start*r.BYTES_PER_ELEMENT,r,h.start,h.count)}n.clearUpdateRanges()}s.bindBuffer(u,null),i.version=n.version}destroyAttribute(e){const t=this.backend,{gl:s}=t;e.isInterleavedBufferAttribute&&t.delete(e.data);const r=t.get(e);s.deleteBuffer(r.bufferGPU),t.delete(e)}async getArrayBufferAsync(e){const t=this.backend,{gl:s}=t,r=e.isInterleavedBufferAttribute?e.data:e,{bufferGPU:n}=t.get(r),i=e.array,u=i.byteLength;s.bindBuffer(s.COPY_READ_BUFFER,n);const a=s.createBuffer();s.bindBuffer(s.COPY_WRITE_BUFFER,a),s.bufferData(s.COPY_WRITE_BUFFER,u,s.STREAM_READ),s.copyBufferSubData(s.COPY_READ_BUFFER,s.COPY_WRITE_BUFFER,0,0,u),await t.utils._clientWaitAsync();const c=new e.array.constructor(i.length);return s.bindBuffer(s.COPY_WRITE_BUFFER,a),s.getBufferSubData(s.COPY_WRITE_BUFFER,0,c),s.deleteBuffer(a),s.bindBuffer(s.COPY_READ_BUFFER,null),s.bindBuffer(s.COPY_WRITE_BUFFER,null),c.buffer}_createBuffer(e,t,s,r){const n=e.createBuffer();return e.bindBuffer(t,n),e.bufferData(t,s,r),e.bindBuffer(t,null),n}}let on,ps;class dT{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){const e=this.gl;on={[l.AddEquation]:e.FUNC_ADD,[l.SubtractEquation]:e.FUNC_SUBTRACT,[l.ReverseSubtractEquation]:e.FUNC_REVERSE_SUBTRACT},ps={[l.ZeroFactor]:e.ZERO,[l.OneFactor]:e.ONE,[l.SrcColorFactor]:e.SRC_COLOR,[l.SrcAlphaFactor]:e.SRC_ALPHA,[l.SrcAlphaSaturateFactor]:e.SRC_ALPHA_SATURATE,[l.DstColorFactor]:e.DST_COLOR,[l.DstAlphaFactor]:e.DST_ALPHA,[l.OneMinusSrcColorFactor]:e.ONE_MINUS_SRC_COLOR,[l.OneMinusSrcAlphaFactor]:e.ONE_MINUS_SRC_ALPHA,[l.OneMinusDstColorFactor]:e.ONE_MINUS_DST_COLOR,[l.OneMinusDstAlphaFactor]:e.ONE_MINUS_DST_ALPHA};const t=e.getParameter(e.SCISSOR_BOX),s=e.getParameter(e.VIEWPORT);this.currentScissor=new l.Vector4().fromArray(t),this.currentViewport=new l.Vector4().fromArray(s),this._tempVec4=new l.Vector4}enable(e){const{enabled:t}=this;t[e]!==!0&&(this.gl.enable(e),t[e]=!0)}disable(e){const{enabled:t}=this;t[e]!==!1&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){const{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){const{gl:t}=this;e!==l.CullFaceNone?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===l.CullFaceBack?t.cullFace(t.BACK):e===l.CullFaceFront?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}setLineWidth(e){const{currentLineWidth:t,gl:s}=this;e!==t&&(s.lineWidth(e),this.currentLineWidth=e)}setBlending(e,t,s,r,n,i,u,a){const{gl:c}=this;if(e===l.NoBlending){this.currentBlendingEnabled===!0&&(this.disable(c.BLEND),this.currentBlendingEnabled=!1);return}if(this.currentBlendingEnabled===!1&&(this.enable(c.BLEND),this.currentBlendingEnabled=!0),e!==l.CustomBlending){if(e!==this.currentBlending||a!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==l.AddEquation||this.currentBlendEquationAlpha!==l.AddEquation)&&(c.blendEquation(c.FUNC_ADD),this.currentBlendEquation=l.AddEquation,this.currentBlendEquationAlpha=l.AddEquation),a)switch(e){case l.NormalBlending:c.blendFuncSeparate(c.ONE,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA);break;case l.AdditiveBlending:c.blendFunc(c.ONE,c.ONE);break;case l.SubtractiveBlending:c.blendFuncSeparate(c.ZERO,c.ONE_MINUS_SRC_COLOR,c.ZERO,c.ONE);break;case l.MultiplyBlending:c.blendFuncSeparate(c.DST_COLOR,c.ONE_MINUS_SRC_ALPHA,c.ZERO,c.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",e);break}else switch(e){case l.NormalBlending:c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA);break;case l.AdditiveBlending:c.blendFuncSeparate(c.SRC_ALPHA,c.ONE,c.ONE,c.ONE);break;case l.SubtractiveBlending:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case l.MultiplyBlending:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",e);break}this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlending=e,this.currentPremultipledAlpha=a}return}n=n||t,i=i||s,u=u||r,(t!==this.currentBlendEquation||n!==this.currentBlendEquationAlpha)&&(c.blendEquationSeparate(on[t],on[n]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=n),(s!==this.currentBlendSrc||r!==this.currentBlendDst||i!==this.currentBlendSrcAlpha||u!==this.currentBlendDstAlpha)&&(c.blendFuncSeparate(ps[s],ps[r],ps[i],ps[u]),this.currentBlendSrc=s,this.currentBlendDst=r,this.currentBlendSrcAlpha=i,this.currentBlendDstAlpha=u),this.currentBlending=e,this.currentPremultipledAlpha=!1}setColorMask(e){this.currentColorMask!==e&&(this.gl.colorMask(e,e,e,e),this.currentColorMask=e)}setDepthTest(e){const{gl:t}=this;e?this.enable(t.DEPTH_TEST):this.disable(t.DEPTH_TEST)}setDepthMask(e){this.currentDepthMask!==e&&(this.gl.depthMask(e),this.currentDepthMask=e)}setDepthFunc(e){if(this.currentDepthFunc!==e){const{gl:t}=this;switch(e){case l.NeverDepth:t.depthFunc(t.NEVER);break;case l.AlwaysDepth:t.depthFunc(t.ALWAYS);break;case l.LessDepth:t.depthFunc(t.LESS);break;case l.LessEqualDepth:t.depthFunc(t.LEQUAL);break;case l.EqualDepth:t.depthFunc(t.EQUAL);break;case l.GreaterEqualDepth:t.depthFunc(t.GEQUAL);break;case l.GreaterDepth:t.depthFunc(t.GREATER);break;case l.NotEqualDepth:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}this.currentDepthFunc=e}}scissor(e,t,s,r){const n=this._tempVec4.set(e,t,s,r);if(this.currentScissor.equals(n)===!1){const{gl:i}=this;i.scissor(n.x,n.y,n.z,n.w),this.currentScissor.copy(n)}}viewport(e,t,s,r){const n=this._tempVec4.set(e,t,s,r);if(this.currentViewport.equals(n)===!1){const{gl:i}=this;i.viewport(n.x,n.y,n.z,n.w),this.currentViewport.copy(n)}}setScissorTest(e){const t=this.gl;e?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST)}setStencilTest(e){const{gl:t}=this;e?this.enable(t.STENCIL_TEST):this.disable(t.STENCIL_TEST)}setStencilMask(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)}setStencilFunc(e,t,s){(this.currentStencilFunc!==e||this.currentStencilRef!==t||this.currentStencilFuncMask!==s)&&(this.gl.stencilFunc(e,t,s),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=s)}setStencilOp(e,t,s){(this.currentStencilFail!==e||this.currentStencilZFail!==t||this.currentStencilZPass!==s)&&(this.gl.stencilOp(e,t,s),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=s)}setMaterial(e,t,s){const{gl:r}=this;e.side===l.DoubleSide?this.disable(r.CULL_FACE):this.enable(r.CULL_FACE);let n=e.side===l.BackSide;t&&(n=!n),this.setFlipSided(n),e.blending===l.NormalBlending&&e.transparent===!1?this.setBlending(l.NoBlending):this.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),this.setDepthFunc(e.depthFunc),this.setDepthTest(e.depthTest),this.setDepthMask(e.depthWrite),this.setColorMask(e.colorWrite);const i=e.stencilWrite;if(this.setStencilTest(i),i&&(this.setStencilMask(e.stencilWriteMask),this.setStencilFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),this.setStencilOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),this.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),e.alphaToCoverage===!0&&this.backend.renderer.samples>1?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),s>0&&this.currentClippingPlanes!==s)for(let a=0;a<8;a++)a<s?this.enable(12288+a):this.disable(12288+a)}setPolygonOffset(e,t,s){const{gl:r}=this;e?(this.enable(r.POLYGON_OFFSET_FILL),(this.currentPolygonOffsetFactor!==t||this.currentPolygonOffsetUnits!==s)&&(r.polygonOffset(t,s),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=s)):this.disable(r.POLYGON_OFFSET_FILL)}useProgram(e){return this.currentProgram!==e?(this.gl.useProgram(e),this.currentProgram=e,!0):!1}setVertexState(e,t=null){const s=this.gl;return this.currentVAO!==e||this.currentIndex!==t?(s.bindVertexArray(e),t!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t),this.currentVAO=e,this.currentIndex=t,!0):!1}resetVertexState(){const e=this.gl;e.bindVertexArray(null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),this.currentVAO=null,this.currentIndex=null}bindFramebuffer(e,t){const{gl:s,currentBoundFramebuffers:r}=this;return r[e]!==t?(s.bindFramebuffer(e,t),r[e]=t,e===s.DRAW_FRAMEBUFFER&&(r[s.FRAMEBUFFER]=t),e===s.FRAMEBUFFER&&(r[s.DRAW_FRAMEBUFFER]=t),!0):!1}drawBuffers(e,t){const{gl:s}=this;let r=[],n=!1;if(e.textures!==null){r=this.currentDrawbuffers.get(t),r===void 0&&(r=[],this.currentDrawbuffers.set(t,r));const i=e.textures;if(r.length!==i.length||r[0]!==s.COLOR_ATTACHMENT0){for(let u=0,a=i.length;u<a;u++)r[u]=s.COLOR_ATTACHMENT0+u;r.length=i.length,n=!0}}else r[0]!==s.BACK&&(r[0]=s.BACK,n=!0);n&&s.drawBuffers(r)}activeTexture(e){const{gl:t,currentTextureSlot:s,maxTextures:r}=this;e===void 0&&(e=t.TEXTURE0+r-1),s!==e&&(t.activeTexture(e),this.currentTextureSlot=e)}bindTexture(e,t,s){const{gl:r,currentTextureSlot:n,currentBoundTextures:i,maxTextures:u}=this;s===void 0&&(n===null?s=r.TEXTURE0+u-1:s=n);let a=i[s];a===void 0&&(a={type:void 0,texture:void 0},i[s]=a),(a.type!==e||a.texture!==t)&&(n!==s&&(r.activeTexture(s),this.currentTextureSlot=s),r.bindTexture(e,t),a.type=e,a.texture=t)}bindBufferBase(e,t,s){const{gl:r}=this,n=`${e}-${t}`;return this.currentBoundBufferBases[n]!==s?(r.bindBufferBase(e,t,s),this.currentBoundBufferBases[n]=s,!0):!1}unbindTexture(){const{gl:e,currentTextureSlot:t,currentBoundTextures:s}=this,r=s[t];r!==void 0&&r.type!==void 0&&(e.bindTexture(r.type,null),r.type=void 0,r.texture=void 0)}}class hT{constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=l.NoColorSpace){const{gl:s,extensions:r}=this;let n;const i=l.ColorManagement.getTransfer(t);if(e===l.UnsignedByteType)return s.UNSIGNED_BYTE;if(e===l.UnsignedShort4444Type)return s.UNSIGNED_SHORT_4_4_4_4;if(e===l.UnsignedShort5551Type)return s.UNSIGNED_SHORT_5_5_5_1;if(e===l.UnsignedInt5999Type)return s.UNSIGNED_INT_5_9_9_9_REV;if(e===l.ByteType)return s.BYTE;if(e===l.ShortType)return s.SHORT;if(e===l.UnsignedShortType)return s.UNSIGNED_SHORT;if(e===l.IntType)return s.INT;if(e===l.UnsignedIntType)return s.UNSIGNED_INT;if(e===l.FloatType)return s.FLOAT;if(e===l.HalfFloatType)return s.HALF_FLOAT;if(e===l.AlphaFormat)return s.ALPHA;if(e===l.RGBFormat)return s.RGB;if(e===l.RGBAFormat)return s.RGBA;if(e===l.DepthFormat)return s.DEPTH_COMPONENT;if(e===l.DepthStencilFormat)return s.DEPTH_STENCIL;if(e===l.RedFormat)return s.RED;if(e===l.RedIntegerFormat)return s.RED_INTEGER;if(e===l.RGFormat)return s.RG;if(e===l.RGIntegerFormat)return s.RG_INTEGER;if(e===l.RGBAIntegerFormat)return s.RGBA_INTEGER;if(e===l.RGB_S3TC_DXT1_Format||e===l.RGBA_S3TC_DXT1_Format||e===l.RGBA_S3TC_DXT3_Format||e===l.RGBA_S3TC_DXT5_Format)if(i===l.SRGBTransfer)if(n=r.get("WEBGL_compressed_texture_s3tc_srgb"),n!==null){if(e===l.RGB_S3TC_DXT1_Format)return n.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===l.RGBA_S3TC_DXT1_Format)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===l.RGBA_S3TC_DXT3_Format)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===l.RGBA_S3TC_DXT5_Format)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(n=r.get("WEBGL_compressed_texture_s3tc"),n!==null){if(e===l.RGB_S3TC_DXT1_Format)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===l.RGBA_S3TC_DXT1_Format)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===l.RGBA_S3TC_DXT3_Format)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===l.RGBA_S3TC_DXT5_Format)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(e===l.RGB_PVRTC_4BPPV1_Format||e===l.RGB_PVRTC_2BPPV1_Format||e===l.RGBA_PVRTC_4BPPV1_Format||e===l.RGBA_PVRTC_2BPPV1_Format)if(n=r.get("WEBGL_compressed_texture_pvrtc"),n!==null){if(e===l.RGB_PVRTC_4BPPV1_Format)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===l.RGB_PVRTC_2BPPV1_Format)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===l.RGBA_PVRTC_4BPPV1_Format)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===l.RGBA_PVRTC_2BPPV1_Format)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(e===l.RGB_ETC1_Format||e===l.RGB_ETC2_Format||e===l.RGBA_ETC2_EAC_Format)if(n=r.get("WEBGL_compressed_texture_etc"),n!==null){if(e===l.RGB_ETC1_Format||e===l.RGB_ETC2_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB8_ETC2:n.COMPRESSED_RGB8_ETC2;if(e===l.RGBA_ETC2_EAC_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:n.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(e===l.RGBA_ASTC_4x4_Format||e===l.RGBA_ASTC_5x4_Format||e===l.RGBA_ASTC_5x5_Format||e===l.RGBA_ASTC_6x5_Format||e===l.RGBA_ASTC_6x6_Format||e===l.RGBA_ASTC_8x5_Format||e===l.RGBA_ASTC_8x6_Format||e===l.RGBA_ASTC_8x8_Format||e===l.RGBA_ASTC_10x5_Format||e===l.RGBA_ASTC_10x6_Format||e===l.RGBA_ASTC_10x8_Format||e===l.RGBA_ASTC_10x10_Format||e===l.RGBA_ASTC_12x10_Format||e===l.RGBA_ASTC_12x12_Format)if(n=r.get("WEBGL_compressed_texture_astc"),n!==null){if(e===l.RGBA_ASTC_4x4_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:n.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===l.RGBA_ASTC_5x4_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:n.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===l.RGBA_ASTC_5x5_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:n.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===l.RGBA_ASTC_6x5_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:n.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===l.RGBA_ASTC_6x6_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:n.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===l.RGBA_ASTC_8x5_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:n.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===l.RGBA_ASTC_8x6_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:n.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===l.RGBA_ASTC_8x8_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:n.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===l.RGBA_ASTC_10x5_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:n.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===l.RGBA_ASTC_10x6_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:n.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===l.RGBA_ASTC_10x8_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:n.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===l.RGBA_ASTC_10x10_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:n.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===l.RGBA_ASTC_12x10_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:n.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===l.RGBA_ASTC_12x12_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:n.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(e===l.RGBA_BPTC_Format)if(n=r.get("EXT_texture_compression_bptc"),n!==null){if(e===l.RGBA_BPTC_Format)return i===l.SRGBTransfer?n.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:n.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(e===l.RED_RGTC1_Format||e===l.SIGNED_RED_RGTC1_Format||e===l.RED_GREEN_RGTC2_Format||e===l.SIGNED_RED_GREEN_RGTC2_Format)if(n=r.get("EXT_texture_compression_rgtc"),n!==null){if(e===l.RGBA_BPTC_Format)return n.COMPRESSED_RED_RGTC1_EXT;if(e===l.SIGNED_RED_RGTC1_Format)return n.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===l.RED_GREEN_RGTC2_Format)return n.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===l.SIGNED_RED_GREEN_RGTC2_Format)return n.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return e===l.UnsignedInt248Type?s.UNSIGNED_INT_24_8:s[e]!==void 0?s[e]:null}_clientWaitAsync(){const{gl:e}=this,t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new Promise((s,r)=>{function n(){const i=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(i===e.WAIT_FAILED){e.deleteSync(t),r();return}if(i===e.TIMEOUT_EXPIRED){requestAnimationFrame(n);return}e.deleteSync(t),s()}n()})}}let Oo=!1,Qs,an,Vo;class pT{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},Oo===!1&&(this._init(),Oo=!0)}_init(){const e=this.gl;Qs={[l.RepeatWrapping]:e.REPEAT,[l.ClampToEdgeWrapping]:e.CLAMP_TO_EDGE,[l.MirroredRepeatWrapping]:e.MIRRORED_REPEAT},an={[l.NearestFilter]:e.NEAREST,[l.NearestMipmapNearestFilter]:e.NEAREST_MIPMAP_NEAREST,[l.NearestMipmapLinearFilter]:e.NEAREST_MIPMAP_LINEAR,[l.LinearFilter]:e.LINEAR,[l.LinearMipmapNearestFilter]:e.LINEAR_MIPMAP_NEAREST,[l.LinearMipmapLinearFilter]:e.LINEAR_MIPMAP_LINEAR},Vo={[l.NeverCompare]:e.NEVER,[l.AlwaysCompare]:e.ALWAYS,[l.LessCompare]:e.LESS,[l.LessEqualCompare]:e.LEQUAL,[l.EqualCompare]:e.EQUAL,[l.GreaterEqualCompare]:e.GEQUAL,[l.GreaterCompare]:e.GREATER,[l.NotEqualCompare]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let s;return e.isCubeTexture===!0?s=t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?s=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?s=t.TEXTURE_3D:s=t.TEXTURE_2D,s}getInternalFormat(e,t,s,r,n=!1){const{gl:i,extensions:u}=this;if(e!==null){if(i[e]!==void 0)return i[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let a=t;if(t===i.RED&&(s===i.FLOAT&&(a=i.R32F),s===i.HALF_FLOAT&&(a=i.R16F),s===i.UNSIGNED_BYTE&&(a=i.R8),s===i.UNSIGNED_SHORT&&(a=i.R16),s===i.UNSIGNED_INT&&(a=i.R32UI),s===i.BYTE&&(a=i.R8I),s===i.SHORT&&(a=i.R16I),s===i.INT&&(a=i.R32I)),t===i.RED_INTEGER&&(s===i.UNSIGNED_BYTE&&(a=i.R8UI),s===i.UNSIGNED_SHORT&&(a=i.R16UI),s===i.UNSIGNED_INT&&(a=i.R32UI),s===i.BYTE&&(a=i.R8I),s===i.SHORT&&(a=i.R16I),s===i.INT&&(a=i.R32I)),t===i.RG&&(s===i.FLOAT&&(a=i.RG32F),s===i.HALF_FLOAT&&(a=i.RG16F),s===i.UNSIGNED_BYTE&&(a=i.RG8),s===i.UNSIGNED_SHORT&&(a=i.RG16),s===i.UNSIGNED_INT&&(a=i.RG32UI),s===i.BYTE&&(a=i.RG8I),s===i.SHORT&&(a=i.RG16I),s===i.INT&&(a=i.RG32I)),t===i.RG_INTEGER&&(s===i.UNSIGNED_BYTE&&(a=i.RG8UI),s===i.UNSIGNED_SHORT&&(a=i.RG16UI),s===i.UNSIGNED_INT&&(a=i.RG32UI),s===i.BYTE&&(a=i.RG8I),s===i.SHORT&&(a=i.RG16I),s===i.INT&&(a=i.RG32I)),t===i.RGB){const c=n?l.LinearTransfer:l.ColorManagement.getTransfer(r);s===i.FLOAT&&(a=i.RGB32F),s===i.HALF_FLOAT&&(a=i.RGB16F),s===i.UNSIGNED_BYTE&&(a=i.RGB8),s===i.UNSIGNED_SHORT&&(a=i.RGB16),s===i.UNSIGNED_INT&&(a=i.RGB32UI),s===i.BYTE&&(a=i.RGB8I),s===i.SHORT&&(a=i.RGB16I),s===i.INT&&(a=i.RGB32I),s===i.UNSIGNED_BYTE&&(a=c===l.SRGBTransfer?i.SRGB8:i.RGB8),s===i.UNSIGNED_SHORT_5_6_5&&(a=i.RGB565),s===i.UNSIGNED_SHORT_5_5_5_1&&(a=i.RGB5_A1),s===i.UNSIGNED_SHORT_4_4_4_4&&(a=i.RGB4),s===i.UNSIGNED_INT_5_9_9_9_REV&&(a=i.RGB9_E5)}if(t===i.RGB_INTEGER&&(s===i.UNSIGNED_BYTE&&(a=i.RGB8UI),s===i.UNSIGNED_SHORT&&(a=i.RGB16UI),s===i.UNSIGNED_INT&&(a=i.RGB32UI),s===i.BYTE&&(a=i.RGB8I),s===i.SHORT&&(a=i.RGB16I),s===i.INT&&(a=i.RGB32I)),t===i.RGBA){const c=n?l.LinearTransfer:l.ColorManagement.getTransfer(r);s===i.FLOAT&&(a=i.RGBA32F),s===i.HALF_FLOAT&&(a=i.RGBA16F),s===i.UNSIGNED_BYTE&&(a=i.RGBA8),s===i.UNSIGNED_SHORT&&(a=i.RGBA16),s===i.UNSIGNED_INT&&(a=i.RGBA32UI),s===i.BYTE&&(a=i.RGBA8I),s===i.SHORT&&(a=i.RGBA16I),s===i.INT&&(a=i.RGBA32I),s===i.UNSIGNED_BYTE&&(a=c===l.SRGBTransfer?i.SRGB8_ALPHA8:i.RGBA8),s===i.UNSIGNED_SHORT_4_4_4_4&&(a=i.RGBA4),s===i.UNSIGNED_SHORT_5_5_5_1&&(a=i.RGB5_A1)}return t===i.RGBA_INTEGER&&(s===i.UNSIGNED_BYTE&&(a=i.RGBA8UI),s===i.UNSIGNED_SHORT&&(a=i.RGBA16UI),s===i.UNSIGNED_INT&&(a=i.RGBA32UI),s===i.BYTE&&(a=i.RGBA8I),s===i.SHORT&&(a=i.RGBA16I),s===i.INT&&(a=i.RGBA32I)),t===i.DEPTH_COMPONENT&&(s===i.UNSIGNED_SHORT&&(a=i.DEPTH_COMPONENT16),s===i.UNSIGNED_INT&&(a=i.DEPTH_COMPONENT24),s===i.FLOAT&&(a=i.DEPTH_COMPONENT32F)),t===i.DEPTH_STENCIL&&s===i.UNSIGNED_INT_24_8&&(a=i.DEPTH24_STENCIL8),(a===i.R16F||a===i.R32F||a===i.RG16F||a===i.RG32F||a===i.RGBA16F||a===i.RGBA32F)&&u.get("EXT_color_buffer_float"),a}setTextureParameters(e,t){const{gl:s,extensions:r,backend:n}=this,i=l.ColorManagement.getPrimaries(l.ColorManagement.workingColorSpace),u=t.colorSpace===l.NoColorSpace?null:l.ColorManagement.getPrimaries(t.colorSpace),a=t.colorSpace===l.NoColorSpace||i===u?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,t.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,t.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,a),s.texParameteri(e,s.TEXTURE_WRAP_S,Qs[t.wrapS]),s.texParameteri(e,s.TEXTURE_WRAP_T,Qs[t.wrapT]),(e===s.TEXTURE_3D||e===s.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||s.texParameteri(e,s.TEXTURE_WRAP_R,Qs[t.wrapR])),s.texParameteri(e,s.TEXTURE_MAG_FILTER,an[t.magFilter]);const c=t.mipmaps!==void 0&&t.mipmaps.length>0,d=t.minFilter===l.LinearFilter&&c?l.LinearMipmapLinearFilter:t.minFilter;if(s.texParameteri(e,s.TEXTURE_MIN_FILTER,an[d]),t.compareFunction&&(s.texParameteri(e,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(e,s.TEXTURE_COMPARE_FUNC,Vo[t.compareFunction])),r.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===l.NearestFilter||t.minFilter!==l.NearestMipmapLinearFilter&&t.minFilter!==l.LinearMipmapLinearFilter||t.type===l.FloatType&&r.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const h=r.get("EXT_texture_filter_anisotropic");s.texParameterf(e,h.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,n.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:s,defaultTextures:r}=this,n=this.getGLTextureType(e);let i=r[n];i===void 0&&(i=t.createTexture(),s.state.bindTexture(n,i),t.texParameteri(n,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(n,t.TEXTURE_MAG_FILTER,t.NEAREST),r[n]=i),s.set(e,{textureGPU:i,glTextureType:n,isDefault:!0})}createTexture(e,t){const{gl:s,backend:r}=this,{levels:n,width:i,height:u,depth:a}=t,c=r.utils.convert(e.format,e.colorSpace),d=r.utils.convert(e.type),h=this.getInternalFormat(e.internalFormat,c,d,e.colorSpace,e.isVideoTexture),p=s.createTexture(),f=this.getGLTextureType(e);r.state.bindTexture(f,p),this.setTextureParameters(f,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?s.texStorage3D(s.TEXTURE_2D_ARRAY,n,h,i,u,a):e.isData3DTexture?s.texStorage3D(s.TEXTURE_3D,n,h,i,u,a):e.isVideoTexture||s.texStorage2D(f,n,h,i,u),r.set(e,{textureGPU:p,glTextureType:f,glFormat:c,glType:d,glInternalFormat:h})}copyBufferToTexture(e,t){const{gl:s,backend:r}=this,{textureGPU:n,glTextureType:i,glFormat:u,glType:a}=r.get(t),{width:c,height:d}=t.source.data;s.bindBuffer(s.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(i,n),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.texSubImage2D(i,0,0,0,c,d,u,a,0),s.bindBuffer(s.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){const{gl:s}=this,{width:r,height:n}=t,{textureGPU:i,glTextureType:u,glFormat:a,glType:c,glInternalFormat:d}=this.backend.get(e);if(!(e.isRenderTargetTexture||i===void 0))if(this.backend.state.bindTexture(u,i),this.setTextureParameters(u,e),e.isCompressedTexture){const h=e.mipmaps,p=t.image;for(let f=0;f<h.length;f++){const g=h[f];e.isCompressedArrayTexture?e.format!==s.RGBA?a!==null?s.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,f,0,0,0,g.width,g.height,p.depth,a,g.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):s.texSubImage3D(s.TEXTURE_2D_ARRAY,f,0,0,0,g.width,g.height,p.depth,a,c,g.data):a!==null?s.compressedTexSubImage2D(s.TEXTURE_2D,f,0,0,g.width,g.height,a,g.data):console.warn("Unsupported compressed texture format")}}else if(e.isCubeTexture){const h=t.images;for(let p=0;p<6;p++){const f=ko(h[p]);s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,0,0,r,n,a,c,f)}}else if(e.isDataArrayTexture||e.isArrayTexture){const h=t.image;s.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,h.width,h.height,h.depth,a,c,h.data)}else if(e.isData3DTexture){const h=t.image;s.texSubImage3D(s.TEXTURE_3D,0,0,0,0,h.width,h.height,h.depth,a,c,h.data)}else if(e.isVideoTexture)e.update(),s.texImage2D(u,0,d,a,c,t.image);else{const h=ko(t.image);s.texSubImage2D(u,0,0,0,r,n,a,c,h)}}generateMipmaps(e){const{gl:t,backend:s}=this,{textureGPU:r,glTextureType:n}=s.get(e);s.state.bindTexture(n,r),t.generateMipmap(n)}deallocateRenderBuffers(e){const{gl:t,backend:s}=this;if(e){const r=s.get(e);if(r.renderBufferStorageSetup=void 0,r.framebuffers){for(const n in r.framebuffers)t.deleteFramebuffer(r.framebuffers[n]);delete r.framebuffers}if(r.depthRenderbuffer&&(t.deleteRenderbuffer(r.depthRenderbuffer),delete r.depthRenderbuffer),r.stencilRenderbuffer&&(t.deleteRenderbuffer(r.stencilRenderbuffer),delete r.stencilRenderbuffer),r.msaaFrameBuffer&&(t.deleteFramebuffer(r.msaaFrameBuffer),delete r.msaaFrameBuffer),r.msaaRenderbuffers){for(let n=0;n<r.msaaRenderbuffers.length;n++)t.deleteRenderbuffer(r.msaaRenderbuffers[n]);delete r.msaaRenderbuffers}}}destroyTexture(e){const{gl:t,backend:s}=this,{textureGPU:r,renderTarget:n}=s.get(e);this.deallocateRenderBuffers(n),t.deleteTexture(r),s.delete(e)}copyTextureToTexture(e,t,s=null,r=null,n=0,i=0){const{gl:u,backend:a}=this,{state:c}=this.backend,{textureGPU:d,glTextureType:h,glType:p,glFormat:f}=a.get(t);c.bindTexture(h,d);let g,m,y,_,C,R,U,M,D;const F=e.isCompressedTexture?e.mipmaps[i]:e.image;if(s!==null)g=s.max.x-s.min.x,m=s.max.y-s.min.y,y=s.isBox3?s.max.z-s.min.z:1,_=s.min.x,C=s.min.y,R=s.isBox3?s.min.z:0;else{const ge=Math.pow(2,-n);g=Math.floor(F.width*ge),m=Math.floor(F.height*ge),e.isDataArrayTexture||e.isArrayTexture?y=F.depth:e.isData3DTexture?y=Math.floor(F.depth*ge):y=1,_=0,C=0,R=0}r!==null?(U=r.x,M=r.y,D=r.z):(U=0,M=0,D=0),u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,t.flipY),u.pixelStorei(u.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),u.pixelStorei(u.UNPACK_ALIGNMENT,t.unpackAlignment);const L=u.getParameter(u.UNPACK_ROW_LENGTH),G=u.getParameter(u.UNPACK_IMAGE_HEIGHT),H=u.getParameter(u.UNPACK_SKIP_PIXELS),q=u.getParameter(u.UNPACK_SKIP_ROWS),ee=u.getParameter(u.UNPACK_SKIP_IMAGES);u.pixelStorei(u.UNPACK_ROW_LENGTH,F.width),u.pixelStorei(u.UNPACK_IMAGE_HEIGHT,F.height),u.pixelStorei(u.UNPACK_SKIP_PIXELS,_),u.pixelStorei(u.UNPACK_SKIP_ROWS,C),u.pixelStorei(u.UNPACK_SKIP_IMAGES,R);const te=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isRenderTargetTexture||e.isDepthTexture){const ge=a.get(e),Le=a.get(t),Ae=a.get(ge.renderTarget),st=a.get(Le.renderTarget),ve=Ae.framebuffers[ge.cacheKey],Ue=st.framebuffers[Le.cacheKey];c.bindFramebuffer(u.READ_FRAMEBUFFER,ve),c.bindFramebuffer(u.DRAW_FRAMEBUFFER,Ue);let mt=u.COLOR_BUFFER_BIT;e.isDepthTexture&&(mt=u.DEPTH_BUFFER_BIT),u.blitFramebuffer(_,C,g,m,U,M,g,m,mt,u.NEAREST),c.bindFramebuffer(u.READ_FRAMEBUFFER,null),c.bindFramebuffer(u.DRAW_FRAMEBUFFER,null)}else te?e.isDataTexture||e.isData3DTexture?u.texSubImage3D(h,i,U,M,D,g,m,y,f,p,F.data):t.isCompressedArrayTexture?u.compressedTexSubImage3D(h,i,U,M,D,g,m,y,f,F.data):u.texSubImage3D(h,i,U,M,D,g,m,y,f,p,F):e.isDataTexture?u.texSubImage2D(h,i,U,M,g,m,f,p,F.data):e.isCompressedTexture?u.compressedTexSubImage2D(h,i,U,M,F.width,F.height,f,F.data):u.texSubImage2D(h,i,U,M,g,m,f,p,F);u.pixelStorei(u.UNPACK_ROW_LENGTH,L),u.pixelStorei(u.UNPACK_IMAGE_HEIGHT,G),u.pixelStorei(u.UNPACK_SKIP_PIXELS,H),u.pixelStorei(u.UNPACK_SKIP_ROWS,q),u.pixelStorei(u.UNPACK_SKIP_IMAGES,ee),i===0&&t.generateMipmaps&&u.generateMipmap(h),c.unbindTexture()}copyFramebufferToTexture(e,t,s){const{gl:r}=this,{state:n}=this.backend,{textureGPU:i}=this.backend.get(e),{x:u,y:a,z:c,w:d}=s,h=e.isDepthTexture===!0||t.renderTarget&&t.renderTarget.samples>0,p=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(h){const f=u!==0||a!==0;let g,m;if(e.isDepthTexture===!0?(g=r.DEPTH_BUFFER_BIT,m=r.DEPTH_ATTACHMENT,t.stencil&&(g|=r.STENCIL_BUFFER_BIT)):(g=r.COLOR_BUFFER_BIT,m=r.COLOR_ATTACHMENT0),f){const y=this.backend.get(t.renderTarget),_=y.framebuffers[t.getCacheKey()],C=y.msaaFrameBuffer;n.bindFramebuffer(r.DRAW_FRAMEBUFFER,_),n.bindFramebuffer(r.READ_FRAMEBUFFER,C);const R=p-a-d;r.blitFramebuffer(u,R,u+c,R+d,u,R,u+c,R+d,g,r.NEAREST),n.bindFramebuffer(r.READ_FRAMEBUFFER,_),n.bindTexture(r.TEXTURE_2D,i),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,u,R,c,d),n.unbindTexture()}else{const y=r.createFramebuffer();n.bindFramebuffer(r.DRAW_FRAMEBUFFER,y),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,m,r.TEXTURE_2D,i,0),r.blitFramebuffer(0,0,c,d,0,0,c,d,g,r.NEAREST),r.deleteFramebuffer(y)}}else n.bindTexture(r.TEXTURE_2D,i),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,u,p-d-a,c,d),n.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,s,r=!1){const{gl:n}=this,i=t.renderTarget,{depthTexture:u,depthBuffer:a,stencilBuffer:c,width:d,height:h}=i;if(n.bindRenderbuffer(n.RENDERBUFFER,e),a&&!c){let p=n.DEPTH_COMPONENT24;r===!0?this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(n.RENDERBUFFER,i.samples,p,d,h):s>0?(u&&u.isDepthTexture&&u.type===n.FLOAT&&(p=n.DEPTH_COMPONENT32F),n.renderbufferStorageMultisample(n.RENDERBUFFER,s,p,d,h)):n.renderbufferStorage(n.RENDERBUFFER,p,d,h),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e)}else a&&c&&(s>0?n.renderbufferStorageMultisample(n.RENDERBUFFER,s,n.DEPTH24_STENCIL8,d,h):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,d,h),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e));n.bindRenderbuffer(n.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,s,r,n,i){const{backend:u,gl:a}=this,{textureGPU:c,glFormat:d,glType:h}=this.backend.get(e),p=a.createFramebuffer();a.bindFramebuffer(a.READ_FRAMEBUFFER,p);const f=e.isCubeTexture?a.TEXTURE_CUBE_MAP_POSITIVE_X+i:a.TEXTURE_2D;a.framebufferTexture2D(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,f,c,0);const g=this._getTypedArrayType(h),m=this._getBytesPerTexel(h,d),_=r*n*m,C=a.createBuffer();a.bindBuffer(a.PIXEL_PACK_BUFFER,C),a.bufferData(a.PIXEL_PACK_BUFFER,_,a.STREAM_READ),a.readPixels(t,s,r,n,d,h,0),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),await u.utils._clientWaitAsync();const R=new g(_/g.BYTES_PER_ELEMENT);return a.bindBuffer(a.PIXEL_PACK_BUFFER,C),a.getBufferSubData(a.PIXEL_PACK_BUFFER,0,R),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),a.deleteFramebuffer(p),R}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:s}=this;let r=0;if(e===s.UNSIGNED_BYTE&&(r=1),(e===s.UNSIGNED_SHORT_4_4_4_4||e===s.UNSIGNED_SHORT_5_5_5_1||e===s.UNSIGNED_SHORT_5_6_5||e===s.UNSIGNED_SHORT||e===s.HALF_FLOAT)&&(r=2),(e===s.UNSIGNED_INT||e===s.FLOAT)&&(r=4),t===s.RGBA)return r*4;if(t===s.RGB)return r*3;if(t===s.ALPHA)return r}}function ko(o){return o.isDataTexture?o.image.data:typeof HTMLImageElement<"u"&&o instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&o instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&o instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&o instanceof OffscreenCanvas?o:o.data}class fT{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class gT{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){const s=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const zo={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class mT{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:s,mode:r,object:n,type:i,info:u,index:a}=this;a!==0?s.drawElements(r,t,i,e):s.drawArrays(r,e,t),u.update(n,t,1)}renderInstances(e,t,s){const{gl:r,mode:n,type:i,index:u,object:a,info:c}=this;s!==0&&(u!==0?r.drawElementsInstanced(n,t,i,e,s):r.drawArraysInstanced(n,e,t,s),c.update(a,t,s))}renderMultiDraw(e,t,s){const{extensions:r,mode:n,object:i,info:u}=this;if(s===0)return;const a=r.get("WEBGL_multi_draw");if(a===null)for(let c=0;c<s;c++)this.render(e[c],t[c]);else{this.index!==0?a.multiDrawElementsWEBGL(n,t,0,this.type,e,0,s):a.multiDrawArraysWEBGL(n,e,0,t,0,s);let c=0;for(let d=0;d<s;d++)c+=t[d];u.update(i,c,1)}}renderMultiDrawInstances(e,t,s,r){const{extensions:n,mode:i,object:u,info:a}=this;if(s===0)return;const c=n.get("WEBGL_multi_draw");if(c===null)for(let d=0;d<s;d++)this.renderInstances(e[d],t[d],r[d]);else{this.index!==0?c.multiDrawElementsInstancedWEBGL(i,t,0,this.type,e,0,r,0,s):c.multiDrawArraysInstancedWEBGL(i,e,0,t,0,r,0,s);let d=0;for(let h=0;h<s;h++)d+=t[h]*r[h];a.update(u,d,1)}}}class Hl{constructor(e=256){this.trackTimestamp=!0,this.maxQueries=e,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.pendingResolve=!1}allocateQueriesForContext(){}async resolveQueriesAsync(){}dispose(){}}class TT extends Hl{constructor(e,t,s=2048){if(super(s),this.gl=e,this.type=t,this.ext=e.getExtension("EXT_disjoint_timer_query_webgl2")||e.getExtension("EXT_disjoint_timer_query"),!this.ext){console.warn("EXT_disjoint_timer_query not supported; timestamps will be disabled."),this.trackTimestamp=!1;return}this.queries=[];for(let r=0;r<this.maxQueries;r++)this.queries.push(e.createQuery());this.activeQuery=null,this.queryStates=new Map}allocateQueriesForContext(e){if(!this.trackTimestamp)return null;if(this.currentQueryIndex+2>this.maxQueries)return l.warnOnce(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e.id,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(t==null||this.activeQuery!==null)return;const s=this.queries[t];if(s)try{this.queryStates.get(t)==="inactive"&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,s),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(r){console.error("Error in beginQuery:",r),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(s){console.error("Error in endQuery:",s),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=[];for(const[r,n]of this.queryStates)if(n==="ended"){const i=this.queries[r];e.push(this.resolveQuery(i))}if(e.length===0)return this.lastValue;const s=(await Promise.all(e)).reduce((r,n)=>r+n,0);return this.lastValue=s,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,s}catch(e){return console.error("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let s,r=!1;const n=()=>{s&&(clearTimeout(s),s=null)},i=a=>{r||(r=!0,n(),t(a))},u=()=>{if(this.isDisposed){i(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){i(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){s=setTimeout(u,1);return}const d=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(d)/1e6)}catch(a){console.error("Error checking query:",a),t(this.lastValue)}};u()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,!!this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}const $o=new l.Vector2;class Wo extends Wl{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,s={antialias:e.samples>0,alpha:!0,depth:e.depth,stencil:e.stencil},r=t.context!==void 0?t.context:e.domElement.getContext("webgl2",s);function n(i){i.preventDefault();const u={api:"WebGL",message:i.statusMessage||"Unknown reason",reason:null,originalEvent:i};e.onDeviceLost(u)}this._onContextLost=n,e.domElement.addEventListener("webglcontextlost",n,!1),this.gl=r,this.extensions=new fT(this),this.capabilities=new gT(this),this.attributeUtils=new cT(this),this.textureUtils=new pT(this),this.bufferRenderer=new mT(this),this.state=new dT(this),this.utils=new hT(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile")}get coordinateSystem(){return l.WebGLCoordinateSystem}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async waitForGPU(){await this.utils._clientWaitAsync()}async makeXRCompatible(){this.gl.getContextAttributes().xrCompatible!==!0&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,s=null){const r=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:r.RGBA8}),s!==null){const n=e.stencilBuffer?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:s,glInternalFormat:n}),this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&console.warn("THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t]||(this.timestampQueryPool[t]=new TT(this.gl,t,2048));const s=this.timestampQueryPool[t];s.allocateQueriesForContext(e)!==null&&s.beginQuery(e)}prepareTimestampBuffer(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t].endQuery(e)}getContext(){return this.gl}beginRender(e){const{state:t}=this,s=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:n,height:i}=this.getDrawingBufferSize($o);t.viewport(0,0,n,i)}if(e.scissor){const{x:n,y:i,width:u,height:a}=e.scissorValue;t.scissor(n,e.height-a-i,u,a)}this.initTimestampQuery(e),s.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const r=e.occlusionQueryCount;r>0&&(s.currentOcclusionQueries=s.occlusionQueries,s.currentOcclusionQueryObjects=s.occlusionQueryObjects,s.lastOcclusionObject=null,s.occlusionQueries=new Array(r),s.occlusionQueryObjects=new Array(r),s.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:s}=this,r=this.get(e),n=r.previousContext;s.resetVertexState();const i=e.occlusionQueryCount;i>0&&(i>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const u=e.textures;if(u!==null)for(let c=0;c<u.length;c++){const d=u[c];d.generateMipmaps&&this.generateMipmaps(d)}this._currentContext=n;const a=e.renderTarget;if(e.textures!==null&&a){const c=this.get(a);if(a.samples>0&&this._useMultisampledExtension(a)===!1){const d=c.framebuffers[e.getCacheKey()];let h=t.COLOR_BUFFER_BIT;a.resolveDepthBuffer&&(a.depthBuffer&&(h|=t.DEPTH_BUFFER_BIT),a.stencilBuffer&&a.resolveStencilBuffer&&(h|=t.STENCIL_BUFFER_BIT));const p=c.msaaFrameBuffer,f=c.msaaRenderbuffers,g=e.textures,m=g.length>1;if(s.bindFramebuffer(t.READ_FRAMEBUFFER,p),s.bindFramebuffer(t.DRAW_FRAMEBUFFER,d),m)for(let y=0;y<g.length;y++)t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+y,t.RENDERBUFFER,null),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+y,t.TEXTURE_2D,null,0);for(let y=0;y<g.length;y++){if(m){const{textureGPU:_}=this.get(g[y]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,f[y]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,_,0)}if(e.scissor){const{x:_,y:C,width:R,height:U}=e.scissorValue,M=e.height-U-C;t.blitFramebuffer(_,M,_+R,M+U,_,M,_+R,M+U,h,t.NEAREST)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,h,t.NEAREST)}if(m)for(let y=0;y<g.length;y++){const{textureGPU:_}=this.get(g[y]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+y,t.RENDERBUFFER,f[y]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+y,t.TEXTURE_2D,_,0)}this._supportsInvalidateFramebuffer===!0&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,c.invalidationArray)}else if(a.resolveDepthBuffer===!1&&c.framebuffers){const d=c.framebuffers[e.getCacheKey()];s.bindFramebuffer(t.DRAW_FRAMEBUFFER,d),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,c.depthInvalidationArray)}}if(n!==null)if(this._setFramebuffer(n),n.viewport)this.updateViewport(n);else{const{width:c,height:d}=this.getDrawingBufferSize($o);s.viewport(0,0,c,d)}this.prepareTimestampBuffer(e)}resolveOccludedAsync(e){const t=this.get(e),{currentOcclusionQueries:s,currentOcclusionQueryObjects:r}=t;if(s&&r){const n=new WeakSet,{gl:i}=this;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueries=null;const u=()=>{let a=0;for(let c=0;c<s.length;c++){const d=s[c];d!==null&&i.getQueryParameter(d,i.QUERY_RESULT_AVAILABLE)&&(i.getQueryParameter(d,i.QUERY_RESULT)===0&&n.add(r[c]),s[c]=null,i.deleteQuery(d),a++)}a<s.length?requestAnimationFrame(u):t.occluded=n};u()}}isOccluded(e,t){const s=this.get(e);return s.occluded&&s.occluded.has(t)}updateViewport(e){const{state:t}=this,{x:s,y:r,width:n,height:i}=e.viewportValue;t.viewport(s,e.height-i-r,n,i)}setScissorTest(e){this.state.setScissorTest(e)}getClearColor(){const e=super.getClearColor();return e.r*=e.a,e.g*=e.a,e.b*=e.a,e}clear(e,t,s,r=null,n=!0){const{gl:i,renderer:u}=this;r===null&&(r={textures:null,clearColorValue:this.getClearColor()});let a=0;if(e&&(a|=i.COLOR_BUFFER_BIT),t&&(a|=i.DEPTH_BUFFER_BIT),s&&(a|=i.STENCIL_BUFFER_BIT),a!==0){let c;r.clearColorValue?c=r.clearColorValue:c=this.getClearColor();const d=u.getClearDepth(),h=u.getClearStencil();if(t&&this.state.setDepthMask(!0),r.textures===null)i.clearColor(c.r,c.g,c.b,c.a),i.clear(a);else{if(n&&this._setFramebuffer(r),e)for(let p=0;p<r.textures.length;p++)p===0?i.clearBufferfv(i.COLOR,p,[c.r,c.g,c.b,c.a]):i.clearBufferfv(i.COLOR,p,[0,0,0,1]);t&&s?i.clearBufferfi(i.DEPTH_STENCIL,0,d,h):t?i.clearBufferfv(i.DEPTH,0,[d]):s&&i.clearBufferiv(i.STENCIL,0,[h])}}}beginCompute(e){const{state:t,gl:s}=this;t.bindFramebuffer(s.FRAMEBUFFER,null),this.initTimestampQuery(e)}compute(e,t,s,r){const{state:n,gl:i}=this;this.discard===!1&&(i.enable(i.RASTERIZER_DISCARD),this.discard=!0);const{programGPU:u,transformBuffers:a,attributes:c}=this.get(r),d=this._getVaoKey(c),h=this.vaoCache[d];h===void 0?this.vaoCache[d]=this._createVao(c):n.setVertexState(h),n.useProgram(u),this._bindUniforms(s);const p=this._getTransformFeedback(a);i.bindTransformFeedback(i.TRANSFORM_FEEDBACK,p),i.beginTransformFeedback(i.POINTS),c[0].isStorageInstancedBufferAttribute?i.drawArraysInstanced(i.POINTS,0,1,t.count):i.drawArrays(i.POINTS,0,t.count),i.endTransformFeedback(),i.bindTransformFeedback(i.TRANSFORM_FEEDBACK,null);for(let f=0;f<a.length;f++){const g=a[f];g.pbo&&this.has(g.pbo)&&this.textureUtils.copyBufferToTexture(g.transformBuffer,g.pbo),g.switchBuffers()}}finishCompute(e){const t=this.gl;this.discard=!1,t.disable(t.RASTERIZER_DISCARD),this.prepareTimestampBuffer(e),this._currentContext&&this._setFramebuffer(this._currentContext)}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.isArrayTexture&&e.camera.isArrayCamera}draw(e){const{object:t,pipeline:s,material:r,context:n,hardwareClippingPlanes:i}=e,{programGPU:u}=this.get(s),{gl:a,state:c}=this,d=this.get(n),h=e.getDrawParameters();if(h===null)return;this._bindUniforms(e.getBindings());const p=t.isMesh&&t.matrixWorld.determinant()<0;c.setMaterial(r,p,i),c.useProgram(u);const f=e.getAttributes(),g=this.get(f);let m=g.vaoGPU;if(m===void 0){const L=this._getVaoKey(f);m=this.vaoCache[L],m===void 0&&(m=this._createVao(f),this.vaoCache[L]=m,g.vaoGPU=m)}const y=e.getIndex(),_=y!==null?this.get(y).bufferGPU:null;c.setVertexState(m,_);const C=d.lastOcclusionObject;if(C!==t&&C!==void 0){if(C!==null&&C.occlusionTest===!0&&(a.endQuery(a.ANY_SAMPLES_PASSED),d.occlusionQueryIndex++),t.occlusionTest===!0){const L=a.createQuery();a.beginQuery(a.ANY_SAMPLES_PASSED,L),d.occlusionQueries[d.occlusionQueryIndex]=L,d.occlusionQueryObjects[d.occlusionQueryIndex]=t}d.lastOcclusionObject=t}const R=this.bufferRenderer;t.isPoints?R.mode=a.POINTS:t.isLineSegments?R.mode=a.LINES:t.isLine?R.mode=a.LINE_STRIP:t.isLineLoop?R.mode=a.LINE_LOOP:r.wireframe===!0?(c.setLineWidth(r.wireframeLinewidth*this.renderer.getPixelRatio()),R.mode=a.LINES):R.mode=a.TRIANGLES;const{vertexCount:U,instanceCount:M}=h;let{firstVertex:D}=h;if(R.object=t,y!==null){D*=y.array.BYTES_PER_ELEMENT;const L=this.get(y);R.index=y.count,R.type=L.type}else R.index=0;const F=()=>{t.isBatchedMesh?t._multiDrawInstances!==null?(l.warnOnce("THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),R.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?R.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):l.warnOnce("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):M>1?R.renderInstances(D,U,M):R.render(D,U)};if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){const L=this.get(e.camera),G=e.camera.cameras,H=e.getBindingGroup("cameraIndex").bindings[0];if(L.indexesGPU===void 0||L.indexesGPU.length!==G.length){const Ae=new Uint32Array([0,0,0,0]),st=[];for(let ve=0,Ue=G.length;ve<Ue;ve++){const mt=a.createBuffer();Ae[0]=ve,a.bindBuffer(a.UNIFORM_BUFFER,mt),a.bufferData(a.UNIFORM_BUFFER,Ae,a.STATIC_DRAW),st.push(mt)}L.indexesGPU=st}const q=this.get(H),ee=this.renderer.getPixelRatio(),te=this._currentContext.renderTarget,ge=this._isRenderCameraDepthArray(this._currentContext),Le=this._currentContext.activeCubeFace;if(ge){const Ae=this.get(te.depthTexture);if(Ae.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){Ae.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;const{stencilBuffer:st}=te;for(let ve=0,Ue=G.length;ve<Ue;ve++)this.renderer._activeCubeFace=ve,this._currentContext.activeCubeFace=ve,this._setFramebuffer(this._currentContext),this.clear(!1,!0,st,this._currentContext,!1);this.renderer._activeCubeFace=Le,this._currentContext.activeCubeFace=Le}}for(let Ae=0,st=G.length;Ae<st;Ae++){const ve=G[Ae];if(t.layers.test(ve.layers)){ge&&(this.renderer._activeCubeFace=Ae,this._currentContext.activeCubeFace=Ae,this._setFramebuffer(this._currentContext));const Ue=ve.viewport;if(Ue!==void 0){const mt=Ue.x*ee,Yl=Ue.y*ee,jl=Ue.width*ee,bi=Ue.height*ee;c.viewport(Math.floor(mt),Math.floor(e.context.height-bi-Yl),Math.floor(jl),Math.floor(bi))}c.bindBufferBase(a.UNIFORM_BUFFER,q.index,L.indexesGPU[Ae]),F()}this._currentContext.activeCubeFace=Le,this.renderer._activeCubeFace=Le}}else F()}needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}async copyTextureToBuffer(e,t,s,r,n,i){return this.textureUtils.copyTextureToBuffer(e,t,s,r,n,i)}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new aT(e,t)}createProgram(e){const t=this.gl,{stage:s,code:r}=e,n=s==="fragment"?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(n,r),t.compileShader(n),this.set(e,{shaderGPU:n})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){const s=this.gl,r=e.pipeline,{fragmentProgram:n,vertexProgram:i}=r,u=s.createProgram(),a=this.get(n).shaderGPU,c=this.get(i).shaderGPU;if(s.attachShader(u,a),s.attachShader(u,c),s.linkProgram(u),this.set(r,{programGPU:u,fragmentShader:a,vertexShader:c}),t!==null&&this.parallel){const d=new Promise(h=>{const p=this.parallel,f=()=>{s.getProgramParameter(u,p.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),h()):requestAnimationFrame(f)};f()});t.push(d);return}this._completeCompile(e,r)}_handleSource(e,t){const s=e.split(`
167
- `),r=[],n=Math.max(t-6,0),i=Math.min(t+6,s.length);for(let u=n;u<i;u++){const a=u+1;r.push(`${a===t?">":" "} ${a}: ${s[u]}`)}return r.join(`
168
- `)}_getShaderErrors(e,t,s){const r=e.getShaderParameter(t,e.COMPILE_STATUS),n=e.getShaderInfoLog(t).trim();if(r&&n==="")return"";const i=/ERROR: 0:(\d+)/.exec(n);if(i){const u=parseInt(i[1]);return s.toUpperCase()+`
169
-
170
- `+n+`
171
-
172
- `+this._handleSource(e.getShaderSource(t),u)}else return n}_logProgramError(e,t,s){if(this.renderer.debug.checkShaderErrors){const r=this.gl,n=r.getProgramInfoLog(e).trim();if(r.getProgramParameter(e,r.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(r,e,s,t);else{const i=this._getShaderErrors(r,s,"vertex"),u=this._getShaderErrors(r,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(e,r.VALIDATE_STATUS)+`
173
-
174
- Program Info Log: `+n+`
175
- `+i+`
176
- `+u)}else n!==""&&console.warn("THREE.WebGLProgram: Program Info Log:",n)}}_completeCompile(e,t){const{state:s,gl:r}=this,n=this.get(t),{programGPU:i,fragmentShader:u,vertexShader:a}=n;r.getProgramParameter(i,r.LINK_STATUS)===!1&&this._logProgramError(i,u,a),s.useProgram(i);const c=e.getBindings();this._setupBindings(c,i),this.set(t,{programGPU:i})}createComputePipeline(e,t){const{state:s,gl:r}=this,n={stage:"fragment",code:`#version 300 es
177
- precision highp float;
178
- void main() {}`};this.createProgram(n);const{computeProgram:i}=e,u=r.createProgram(),a=this.get(n).shaderGPU,c=this.get(i).shaderGPU,d=i.transforms,h=[],p=[];for(let y=0;y<d.length;y++){const _=d[y];h.push(_.varyingName),p.push(_.attributeNode)}r.attachShader(u,a),r.attachShader(u,c),r.transformFeedbackVaryings(u,h,r.SEPARATE_ATTRIBS),r.linkProgram(u),r.getProgramParameter(u,r.LINK_STATUS)===!1&&this._logProgramError(u,a,c),s.useProgram(u),this._setupBindings(t,u);const f=i.attributes,g=[],m=[];for(let y=0;y<f.length;y++){const _=f[y].node.attribute;g.push(_),this.has(_)||this.attributeUtils.createAttribute(_,r.ARRAY_BUFFER)}for(let y=0;y<p.length;y++){const _=p[y].attribute;this.has(_)||this.attributeUtils.createAttribute(_,r.ARRAY_BUFFER);const C=this.get(_);m.push(C)}this.set(e,{programGPU:u,transformBuffers:m,attributes:g})}createBindings(e,t){if(this._knownBindings.has(t)===!1){this._knownBindings.add(t);let s=0,r=0;for(const n of t){this.set(n,{textures:r,uniformBuffers:s});for(const i of n.bindings)i.isUniformBuffer&&s++,i.isSampledTexture&&r++}}this.updateBindings(e,t)}updateBindings(e){const{gl:t}=this,s=this.get(e);let r=s.uniformBuffers,n=s.textures;for(const i of e.bindings)if(i.isUniformsGroup||i.isUniformBuffer){const u=i.buffer,a=t.createBuffer();t.bindBuffer(t.UNIFORM_BUFFER,a),t.bufferData(t.UNIFORM_BUFFER,u,t.DYNAMIC_DRAW),this.set(i,{index:r++,bufferGPU:a})}else if(i.isSampledTexture){const{textureGPU:u,glTextureType:a}=this.get(i.texture);this.set(i,{index:n++,textureGPU:u,glTextureType:a})}}updateBinding(e){const t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){const r=this.get(e).bufferGPU,n=e.buffer;t.bindBuffer(t.UNIFORM_BUFFER,r),t.bufferData(t.UNIFORM_BUFFER,n,t.DYNAMIC_DRAW)}}createIndexAttribute(e){const t=this.gl;this.attributeUtils.createAttribute(e,t.ELEMENT_ARRAY_BUFFER)}createAttribute(e){if(this.has(e))return;const t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}createStorageAttribute(e){if(this.has(e))return;const t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}hasFeature(e){const t=Object.keys(zo).filter(r=>zo[r]===e),s=this.extensions;for(let r=0;r<t.length;r++)if(s.has(t[r]))return!0;return!1}getMaxAnisotropy(){return this.capabilities.getMaxAnisotropy()}copyTextureToTexture(e,t,s=null,r=null,n=0,i=0){this.textureUtils.copyTextureToTexture(e,t,s,r,n,i)}copyFramebufferToTexture(e,t,s){this.textureUtils.copyFramebufferToTexture(e,t,s)}_setFramebuffer(e){const{gl:t,state:s}=this;let r=null;if(e.textures!==null){const n=e.renderTarget,i=this.get(n),{samples:u,depthBuffer:a,stencilBuffer:c}=n,d=n.isWebGLCubeRenderTarget===!0,h=n.isRenderTarget3D===!0,p=n.depth>1,f=n.isXRRenderTarget===!0,g=f===!0&&n._hasExternalTextures===!0;let m=i.msaaFrameBuffer,y=i.depthRenderbuffer;const _=this.extensions.get("WEBGL_multisampled_render_to_texture"),C=this.extensions.get("OVR_multiview2"),R=this._useMultisampledExtension(n),U=cl(e);let M;if(d?(i.cubeFramebuffers||(i.cubeFramebuffers={}),M=i.cubeFramebuffers[U]):f&&g===!1?M=this._xrFramebuffer:(i.framebuffers||(i.framebuffers={}),M=i.framebuffers[U]),M===void 0){M=t.createFramebuffer(),s.bindFramebuffer(t.FRAMEBUFFER,M);const D=e.textures,F=[];if(d){i.cubeFramebuffers[U]=M;const{textureGPU:G}=this.get(D[0]),H=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+H,G,0)}else{i.framebuffers[U]=M;for(let G=0;G<D.length;G++){const H=D[G],q=this.get(H);q.renderTarget=e.renderTarget,q.cacheKey=U;const ee=t.COLOR_ATTACHMENT0+G;if(n.multiview)C.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,ee,q.textureGPU,0,u,0,2);else if(h||p){const te=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,ee,q.textureGPU,0,te)}else R?_.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ee,t.TEXTURE_2D,q.textureGPU,0,u):t.framebufferTexture2D(t.FRAMEBUFFER,ee,t.TEXTURE_2D,q.textureGPU,0)}}const L=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(n._autoAllocateDepthBuffer===!0){const G=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(G,e,0,R),i.xrDepthRenderbuffer=G,F.push(c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,G),t.framebufferRenderbuffer(t.FRAMEBUFFER,L,t.RENDERBUFFER,G)}else if(e.depthTexture!==null){F.push(c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);const G=this.get(e.depthTexture);if(G.renderTarget=e.renderTarget,G.cacheKey=U,n.multiview)C.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,L,G.textureGPU,0,u,0,2);else if(g&&R)_.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,L,t.TEXTURE_2D,G.textureGPU,0,u);else if(e.depthTexture.isArrayTexture){const H=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,L,G.textureGPU,0,H)}else t.framebufferTexture2D(t.FRAMEBUFFER,L,t.TEXTURE_2D,G.textureGPU,0)}i.depthInvalidationArray=F}else{if(this._isRenderCameraDepthArray(e)){s.bindFramebuffer(t.FRAMEBUFFER,M);const F=this.renderer._activeCubeFace,L=this.get(e.depthTexture),G=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,G,L.textureGPU,0,F)}if((f||R||n.multiview)&&n._isOpaqueFramebuffer!==!0){s.bindFramebuffer(t.FRAMEBUFFER,M);const F=this.get(e.textures[0]);n.multiview?C.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,F.textureGPU,0,u,0,2):R?_.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,F.textureGPU,0,u):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,F.textureGPU,0);const L=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(n._autoAllocateDepthBuffer===!0){const G=i.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,G),t.framebufferRenderbuffer(t.FRAMEBUFFER,L,t.RENDERBUFFER,G)}else{const G=this.get(e.depthTexture);n.multiview?C.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,L,G.textureGPU,0,u,0,2):R?_.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,L,t.TEXTURE_2D,G.textureGPU,0,u):t.framebufferTexture2D(t.FRAMEBUFFER,L,t.TEXTURE_2D,G.textureGPU,0)}}}if(u>0&&R===!1&&!n.multiview){if(m===void 0){const D=[];m=t.createFramebuffer(),s.bindFramebuffer(t.FRAMEBUFFER,m);const F=[],L=e.textures;for(let G=0;G<L.length;G++){F[G]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,F[G]),D.push(t.COLOR_ATTACHMENT0+G);const H=e.textures[G],q=this.get(H);t.renderbufferStorageMultisample(t.RENDERBUFFER,u,q.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+G,t.RENDERBUFFER,F[G])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),i.msaaFrameBuffer=m,i.msaaRenderbuffers=F,a&&y===void 0){y=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(y,e,u),i.depthRenderbuffer=y;const G=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;D.push(G)}i.invalidationArray=D}r=i.msaaFrameBuffer}else r=M;s.drawBuffers(e,M)}s.bindFramebuffer(t.FRAMEBUFFER,r)}_getVaoKey(e){let t="";for(let s=0;s<e.length;s++){const r=this.get(e[s]);t+=":"+r.id}return t}_createVao(e){const{gl:t}=this,s=t.createVertexArray();t.bindVertexArray(s);for(let r=0;r<e.length;r++){const n=e[r],i=this.get(n);t.bindBuffer(t.ARRAY_BUFFER,i.bufferGPU),t.enableVertexAttribArray(r);let u,a;n.isInterleavedBufferAttribute===!0?(u=n.data.stride*i.bytesPerElement,a=n.offset*i.bytesPerElement):(u=0,a=0),i.isInteger?t.vertexAttribIPointer(r,n.itemSize,i.type,u,a):t.vertexAttribPointer(r,n.itemSize,i.type,n.normalized,u,a),n.isInstancedBufferAttribute&&!n.isInterleavedBufferAttribute?t.vertexAttribDivisor(r,n.meshPerAttribute):n.isInterleavedBufferAttribute&&n.data.isInstancedInterleavedBuffer&&t.vertexAttribDivisor(r,n.data.meshPerAttribute)}return t.bindBuffer(t.ARRAY_BUFFER,null),s}_getTransformFeedback(e){let t="";for(let n=0;n<e.length;n++)t+=":"+e[n].id;let s=this.transformFeedbackCache[t];if(s!==void 0)return s;const{gl:r}=this;s=r.createTransformFeedback(),r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,s);for(let n=0;n<e.length;n++){const i=e[n];r.bindBufferBase(r.TRANSFORM_FEEDBACK_BUFFER,n,i.transformBuffer)}return r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,null),this.transformFeedbackCache[t]=s,s}_setupBindings(e,t){const s=this.gl;for(const r of e)for(const n of r.bindings){const u=this.get(n).index;if(n.isUniformsGroup||n.isUniformBuffer){const a=s.getUniformBlockIndex(t,n.name);s.uniformBlockBinding(t,a,u)}else if(n.isSampledTexture){const a=s.getUniformLocation(t,n.name);s.uniform1i(a,u)}}}_bindUniforms(e){const{gl:t,state:s}=this;for(const r of e)for(const n of r.bindings){const i=this.get(n),u=i.index;n.isUniformsGroup||n.isUniformBuffer?s.bindBufferBase(t.UNIFORM_BUFFER,u,i.bufferGPU):n.isSampledTexture&&s.bindTexture(i.glTextureType,i.textureGPU,t.TEXTURE0+u)}}_useMultisampledExtension(e){return e.multiview===!0?!0:e.samples>0&&this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer!==!1}dispose(){const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const kt={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list",TriangleStrip:"triangle-strip"},me={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},xe={Store:"store"},Q={Load:"load",Clear:"clear"},un={CCW:"ccw"},ln={None:"none",Front:"front",Back:"back"},jt={Uint16:"uint16",Uint32:"uint32"},T={R8Unorm:"r8unorm",R8Snorm:"r8snorm",R8Uint:"r8uint",R8Sint:"r8sint",R16Uint:"r16uint",R16Sint:"r16sint",R16Float:"r16float",RG8Unorm:"rg8unorm",RG8Snorm:"rg8snorm",RG8Uint:"rg8uint",RG8Sint:"rg8sint",R32Uint:"r32uint",R32Sint:"r32sint",R32Float:"r32float",RG16Uint:"rg16uint",RG16Sint:"rg16sint",RG16Float:"rg16float",RGBA8Unorm:"rgba8unorm",RGBA8UnormSRGB:"rgba8unorm-srgb",RGBA8Snorm:"rgba8snorm",RGBA8Uint:"rgba8uint",RGBA8Sint:"rgba8sint",BGRA8Unorm:"bgra8unorm",BGRA8UnormSRGB:"bgra8unorm-srgb",RGB9E5UFloat:"rgb9e5ufloat",RGB10A2Unorm:"rgb10a2unorm",RG11B10UFloat:"rgb10a2unorm",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",RGBA32Uint:"rgba32uint",RGBA32Sint:"rgba32sint",RGBA32Float:"rgba32float",Depth16Unorm:"depth16unorm",Depth24Plus:"depth24plus",Depth24PlusStencil8:"depth24plus-stencil8",Depth32Float:"depth32float",Depth32FloatStencil8:"depth32float-stencil8",BC1RGBAUnorm:"bc1-rgba-unorm",BC1RGBAUnormSRGB:"bc1-rgba-unorm-srgb",BC2RGBAUnorm:"bc2-rgba-unorm",BC2RGBAUnormSRGB:"bc2-rgba-unorm-srgb",BC3RGBAUnorm:"bc3-rgba-unorm",BC3RGBAUnormSRGB:"bc3-rgba-unorm-srgb",BC4RUnorm:"bc4-r-unorm",BC4RSnorm:"bc4-r-snorm",BC5RGUnorm:"bc5-rg-unorm",BC5RGSnorm:"bc5-rg-snorm",BC6HRGBUFloat:"bc6h-rgb-ufloat",BC6HRGBFloat:"bc6h-rgb-float",BC7RGBAUnorm:"bc7-rgba-unorm",BC7RGBAUnormSRGB:"bc7-rgba-srgb",ETC2RGB8Unorm:"etc2-rgb8unorm",ETC2RGB8UnormSRGB:"etc2-rgb8unorm-srgb",ETC2RGB8A1Unorm:"etc2-rgb8a1unorm",ETC2RGB8A1UnormSRGB:"etc2-rgb8a1unorm-srgb",ETC2RGBA8Unorm:"etc2-rgba8unorm",ETC2RGBA8UnormSRGB:"etc2-rgba8unorm-srgb",EACR11Unorm:"eac-r11unorm",EACR11Snorm:"eac-r11snorm",EACRG11Unorm:"eac-rg11unorm",EACRG11Snorm:"eac-rg11snorm",ASTC4x4Unorm:"astc-4x4-unorm",ASTC4x4UnormSRGB:"astc-4x4-unorm-srgb",ASTC5x4Unorm:"astc-5x4-unorm",ASTC5x4UnormSRGB:"astc-5x4-unorm-srgb",ASTC5x5Unorm:"astc-5x5-unorm",ASTC5x5UnormSRGB:"astc-5x5-unorm-srgb",ASTC6x5Unorm:"astc-6x5-unorm",ASTC6x5UnormSRGB:"astc-6x5-unorm-srgb",ASTC6x6Unorm:"astc-6x6-unorm",ASTC6x6UnormSRGB:"astc-6x6-unorm-srgb",ASTC8x5Unorm:"astc-8x5-unorm",ASTC8x5UnormSRGB:"astc-8x5-unorm-srgb",ASTC8x6Unorm:"astc-8x6-unorm",ASTC8x6UnormSRGB:"astc-8x6-unorm-srgb",ASTC8x8Unorm:"astc-8x8-unorm",ASTC8x8UnormSRGB:"astc-8x8-unorm-srgb",ASTC10x5Unorm:"astc-10x5-unorm",ASTC10x5UnormSRGB:"astc-10x5-unorm-srgb",ASTC10x6Unorm:"astc-10x6-unorm",ASTC10x6UnormSRGB:"astc-10x6-unorm-srgb",ASTC10x8Unorm:"astc-10x8-unorm",ASTC10x8UnormSRGB:"astc-10x8-unorm-srgb",ASTC10x10Unorm:"astc-10x10-unorm",ASTC10x10UnormSRGB:"astc-10x10-unorm-srgb",ASTC12x10Unorm:"astc-12x10-unorm",ASTC12x10UnormSRGB:"astc-12x10-unorm-srgb",ASTC12x12Unorm:"astc-12x12-unorm",ASTC12x12UnormSRGB:"astc-12x12-unorm-srgb"},cn={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},Ct={Linear:"linear",Nearest:"nearest"},W={Zero:"zero",One:"one",Src:"src",OneMinusSrc:"one-minus-src",SrcAlpha:"src-alpha",OneMinusSrcAlpha:"one-minus-src-alpha",Dst:"dst",OneMinusDst:"one-minus-dst",DstAlpha:"dst-alpha",OneMinusDstAlpha:"one-minus-dst-alpha",SrcAlphaSaturated:"src-alpha-saturated",Constant:"constant",OneMinusConstant:"one-minus-constant"},xt={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},Ho={None:0,All:15},nt={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},dn={Storage:"storage",ReadOnlyStorage:"read-only-storage"},hn={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},qo={NonFiltering:"non-filtering",Comparison:"comparison"},_t={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},Xo={TwoD:"2d",ThreeD:"3d"},he={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},yT={All:"all"},Ys={Vertex:"vertex",Instance:"instance"},wn={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"};class xT extends Ni{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.isSampler=!0}}class _T extends xT{constructor(e,t,s){super(e,t?t.value:null),this.textureNode=t,this.groupNode=s}update(){this.texture=this.textureNode.value}}class ST extends Il{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let NT=0;class bT extends ST{constructor(e,t){super("StorageBuffer_"+NT++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:He.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class RT extends pt{constructor(e){super(),this.device=e;const t=`
179
- struct VarysStruct {
180
- @builtin( position ) Position: vec4<f32>,
181
- @location( 0 ) vTex : vec2<f32>
182
- };
183
-
184
- @vertex
185
- fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {
186
-
187
- var Varys : VarysStruct;
188
-
189
- var pos = array< vec2<f32>, 4 >(
190
- vec2<f32>( -1.0, 1.0 ),
191
- vec2<f32>( 1.0, 1.0 ),
192
- vec2<f32>( -1.0, -1.0 ),
193
- vec2<f32>( 1.0, -1.0 )
194
- );
195
-
196
- var tex = array< vec2<f32>, 4 >(
197
- vec2<f32>( 0.0, 0.0 ),
198
- vec2<f32>( 1.0, 0.0 ),
199
- vec2<f32>( 0.0, 1.0 ),
200
- vec2<f32>( 1.0, 1.0 )
201
- );
202
-
203
- Varys.vTex = tex[ vertexIndex ];
204
- Varys.Position = vec4<f32>( pos[ vertexIndex ], 0.0, 1.0 );
205
-
206
- return Varys;
207
-
208
- }
209
- `,s=`
210
- @group( 0 ) @binding( 0 )
211
- var imgSampler : sampler;
212
-
213
- @group( 0 ) @binding( 1 )
214
- var img : texture_2d<f32>;
215
-
216
- @fragment
217
- fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
218
-
219
- return textureSample( img, imgSampler, vTex );
220
-
221
- }
222
- `,r=`
223
- @group( 0 ) @binding( 0 )
224
- var imgSampler : sampler;
225
-
226
- @group( 0 ) @binding( 1 )
227
- var img : texture_2d<f32>;
228
-
229
- @fragment
230
- fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
231
-
232
- return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );
233
-
234
- }
235
- `;this.mipmapSampler=e.createSampler({minFilter:Ct.Linear}),this.flipYSampler=e.createSampler({minFilter:Ct.Nearest}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:t}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:s}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:r})}getTransferPipeline(e){let t=this.transferPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:kt.TriangleStrip,stripIndexFormat:jt.Uint32},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:kt.TriangleStrip,stripIndexFormat:jt.Uint32},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,s=0){const r=t.format,{width:n,height:i}=t.size,u=this.getTransferPipeline(r),a=this.getFlipYPipeline(r),c=this.device.createTexture({size:{width:n,height:i,depthOrArrayLayers:1},format:r,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),d=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:he.TwoD,baseArrayLayer:s}),h=c.createView({baseMipLevel:0,mipLevelCount:1,dimension:he.TwoD,baseArrayLayer:0}),p=this.device.createCommandEncoder({}),f=(g,m,y)=>{const _=g.getBindGroupLayout(0),C=this.device.createBindGroup({layout:_,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:m}]}),R=p.beginRenderPass({colorAttachments:[{view:y,loadOp:Q.Clear,storeOp:xe.Store,clearValue:[0,0,0,0]}]});R.setPipeline(g),R.setBindGroup(0,C),R.draw(4,1,0,0),R.end()};f(u,d,h),f(a,h,d),this.device.queue.submit([p.finish()]),c.destroy()}generateMipmaps(e,t,s=0){const r=this.get(e);r.useCount===void 0&&(r.useCount=0,r.layers=[]);const n=r.layers[s]||this._mipmapCreateBundles(e,t,s),i=this.device.createCommandEncoder({});this._mipmapRunBundles(i,n),this.device.queue.submit([i.finish()]),r.useCount!==0&&(r.layers[s]=n),r.useCount++}_mipmapCreateBundles(e,t,s){const r=this.getTransferPipeline(t.format),n=r.getBindGroupLayout(0);let i=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:he.TwoD,baseArrayLayer:s});const u=[];for(let a=1;a<t.mipLevelCount;a++){const c=this.device.createBindGroup({layout:n,entries:[{binding:0,resource:this.mipmapSampler},{binding:1,resource:i}]}),d=e.createView({baseMipLevel:a,mipLevelCount:1,dimension:he.TwoD,baseArrayLayer:s}),h={colorAttachments:[{view:d,loadOp:Q.Clear,storeOp:xe.Store,clearValue:[0,0,0,0]}]},p=this.device.createRenderBundleEncoder({colorFormats:[t.format]});p.setPipeline(r),p.setBindGroup(0,c),p.draw(4,1,0,0),u.push({renderBundles:[p.finish()],passDescriptor:h}),i=d}return u}_mipmapRunBundles(e,t){const s=t.length;for(let r=0;r<s;r++){const n=t[r],i=e.beginRenderPass(n.passDescriptor);i.executeBundles(n.renderBundles),i.end()}}}const AT={[l.NeverCompare]:"never",[l.LessCompare]:"less",[l.EqualCompare]:"equal",[l.LessEqualCompare]:"less-equal",[l.GreaterCompare]:"greater",[l.GreaterEqualCompare]:"greater-equal",[l.AlwaysCompare]:"always",[l.NotEqualCompare]:"not-equal"},CT=[0,1,3,2,4,5];class vT{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this.colorBuffer=null,this.depthTexture=new l.DepthTexture,this.depthTexture.name="depthBuffer"}createSampler(e){const t=this.backend,s=t.device,r=t.get(e),n={addressModeU:this._convertAddressMode(e.wrapS),addressModeV:this._convertAddressMode(e.wrapT),addressModeW:this._convertAddressMode(e.wrapR),magFilter:this._convertFilterMode(e.magFilter),minFilter:this._convertFilterMode(e.minFilter),mipmapFilter:this._convertFilterMode(e.minFilter),maxAnisotropy:1};n.magFilter===Ct.Linear&&n.minFilter===Ct.Linear&&n.mipmapFilter===Ct.Linear&&(n.maxAnisotropy=e.anisotropy),e.isDepthTexture&&e.compareFunction!==null&&(n.compare=AT[e.compareFunction]),r.sampler=s.createSampler(n)}createDefaultTexture(e){let t;const s=Pn(e);e.isCubeTexture?t=this._getDefaultCubeTextureGPU(s):e.isVideoTexture?this.backend.get(e).externalTexture=this._getDefaultVideoFrame():t=this._getDefaultTextureGPU(s),this.backend.get(e).texture=t}createTexture(e,t={}){const s=this.backend,r=s.get(e);if(r.initialized)throw new Error("WebGPUTextureUtils: Texture already initialized.");t.needsMipmaps===void 0&&(t.needsMipmaps=!1),t.levels===void 0&&(t.levels=1),t.depth===void 0&&(t.depth=1);const{width:n,height:i,depth:u,levels:a}=t;e.isFramebufferTexture&&(t.renderTarget?t.format=this.backend.utils.getCurrentColorFormat(t.renderTarget):t.format=this.backend.utils.getPreferredCanvasFormat());const c=this._getDimension(e),d=e.internalFormat||t.format||Pn(e,s.device);r.format=d;const{samples:h,primarySamples:p,isMSAA:f}=s.utils.getTextureSampleData(e);let g=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;e.isStorageTexture===!0&&(g|=GPUTextureUsage.STORAGE_BINDING),e.isCompressedTexture!==!0&&e.isCompressedArrayTexture!==!0&&(g|=GPUTextureUsage.RENDER_ATTACHMENT);const m={label:e.name,size:{width:n,height:i,depthOrArrayLayers:u},mipLevelCount:a,sampleCount:p,dimension:c,format:d,usage:g};if(e.isVideoTexture){const y=e.source.data,_=new VideoFrame(y);m.size.width=_.displayWidth,m.size.height=_.displayHeight,_.close(),r.externalTexture=y}else{if(d===void 0){console.warn("WebGPURenderer: Texture format not supported."),this.createDefaultTexture(e);return}e.isCubeTexture&&(m.textureBindingViewDimension=he.Cube),r.texture=s.device.createTexture(m)}if(f){const y=Object.assign({},m);y.label=y.label+"-msaa",y.sampleCount=h,r.msaaTexture=s.device.createTexture(y)}r.initialized=!0,r.textureDescriptorGPU=m}destroyTexture(e){const t=this.backend,s=t.get(e);s.texture!==void 0&&s.texture.destroy(),s.msaaTexture!==void 0&&s.msaaTexture.destroy(),t.delete(e)}destroySampler(e){const s=this.backend.get(e);delete s.sampler}generateMipmaps(e){const t=this.backend.get(e);if(e.isCubeTexture)for(let s=0;s<6;s++)this._generateMipmaps(t.texture,t.textureDescriptorGPU,s);else{const s=e.image.depth||1;for(let r=0;r<s;r++)this._generateMipmaps(t.texture,t.textureDescriptorGPU,r)}}getColorBuffer(){this.colorBuffer&&this.colorBuffer.destroy();const e=this.backend,{width:t,height:s}=e.getDrawingBufferSize();return this.colorBuffer=e.device.createTexture({label:"colorBuffer",size:{width:t,height:s,depthOrArrayLayers:1},sampleCount:e.utils.getSampleCount(e.renderer.samples),format:e.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC}),this.colorBuffer}getDepthBuffer(e=!0,t=!1){const s=this.backend,{width:r,height:n}=s.getDrawingBufferSize(),i=this.depthTexture,u=s.get(i).texture;let a,c;if(t?(a=l.DepthStencilFormat,c=l.UnsignedInt248Type):e&&(a=l.DepthFormat,c=l.UnsignedIntType),u!==void 0){if(i.image.width===r&&i.image.height===n&&i.format===a&&i.type===c)return u;this.destroyTexture(i)}return i.name="depthBuffer",i.format=a,i.type=c,i.image.width=r,i.image.height=n,this.createTexture(i,{width:r,height:n}),s.get(i).texture}updateTexture(e,t){const s=this.backend.get(e),{textureDescriptorGPU:r}=s;if(!(e.isRenderTargetTexture||r===void 0)){if(e.isDataTexture)this._copyBufferToTexture(t.image,s.texture,r,0,e.flipY);else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)for(let n=0;n<t.image.depth;n++)this._copyBufferToTexture(t.image,s.texture,r,n,e.flipY,n);else if(e.isCompressedTexture||e.isCompressedArrayTexture)this._copyCompressedBufferToTexture(e.mipmaps,s.texture,r);else if(e.isCubeTexture)this._copyCubeMapToTexture(t.images,s.texture,r,e.flipY,e.premultiplyAlpha);else if(e.isVideoTexture){const n=e.source.data;s.externalTexture=n}else this._copyImageToTexture(t.image,s.texture,r,0,e.flipY,e.premultiplyAlpha);s.version=e.version,e.onUpdate&&e.onUpdate(e)}}async copyTextureToBuffer(e,t,s,r,n,i){const u=this.backend.device,a=this.backend.get(e),c=a.texture,d=a.textureDescriptorGPU.format,h=this._getBytesPerTexel(d);let p=r*h;p=Math.ceil(p/256)*256;const f=u.createBuffer({size:r*n*h,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),g=u.createCommandEncoder();g.copyTextureToBuffer({texture:c,origin:{x:t,y:s,z:i}},{buffer:f,bytesPerRow:p},{width:r,height:n});const m=this._getTypedArrayType(d);u.queue.submit([g.finish()]),await f.mapAsync(GPUMapMode.READ);const y=f.getMappedRange();return new m(y)}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){const s=new l.Texture;s.minFilter=l.NearestFilter,s.magFilter=l.NearestFilter,this.createTexture(s,{width:1,height:1,format:e}),this.defaultTexture[e]=t=s}return this.backend.get(t).texture}_getDefaultCubeTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){const s=new l.CubeTexture;s.minFilter=l.NearestFilter,s.magFilter=l.NearestFilter,this.createTexture(s,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=s}return this.backend.get(t).texture}_getDefaultVideoFrame(){let e=this.defaultVideoFrame;if(e===null){const t={timestamp:0,codedWidth:1,codedHeight:1,format:"RGBA"};this.defaultVideoFrame=e=new VideoFrame(new Uint8Array([0,0,0,255]),t)}return e}_copyCubeMapToTexture(e,t,s,r,n){for(let i=0;i<6;i++){const u=e[i],a=r===!0?CT[i]:i;u.isDataTexture?this._copyBufferToTexture(u.image,t,s,a,r):this._copyImageToTexture(u,t,s,a,r,n)}}_copyImageToTexture(e,t,s,r,n,i){this.backend.device.queue.copyExternalImageToTexture({source:e,flipY:n},{texture:t,mipLevel:0,origin:{x:0,y:0,z:r},premultipliedAlpha:i},{width:e.width,height:e.height,depthOrArrayLayers:1})}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new RT(this.backend.device)),e}_generateMipmaps(e,t,s=0){this._getPassUtils().generateMipmaps(e,t,s)}_flipY(e,t,s=0){this._getPassUtils().flipY(e,t,s)}_copyBufferToTexture(e,t,s,r,n,i=0){const u=this.backend.device,a=e.data,c=this._getBytesPerTexel(s.format),d=e.width*c;u.queue.writeTexture({texture:t,mipLevel:0,origin:{x:0,y:0,z:r}},a,{offset:e.width*e.height*c*i,bytesPerRow:d},{width:e.width,height:e.height,depthOrArrayLayers:1}),n===!0&&this._flipY(t,s,r)}_copyCompressedBufferToTexture(e,t,s){const r=this.backend.device,n=this._getBlockData(s.format),i=s.size.depthOrArrayLayers>1;for(let u=0;u<e.length;u++){const a=e[u],c=a.width,d=a.height,h=i?s.size.depthOrArrayLayers:1,p=Math.ceil(c/n.width)*n.byteLength,f=p*Math.ceil(d/n.height);for(let g=0;g<h;g++)r.queue.writeTexture({texture:t,mipLevel:u,origin:{x:0,y:0,z:g}},a.data,{offset:g*f,bytesPerRow:p,rowsPerImage:Math.ceil(d/n.height)},{width:Math.ceil(c/n.width)*n.width,height:Math.ceil(d/n.height)*n.height,depthOrArrayLayers:1})}}_getBlockData(e){if(e===T.BC1RGBAUnorm||e===T.BC1RGBAUnormSRGB)return{byteLength:8,width:4,height:4};if(e===T.BC2RGBAUnorm||e===T.BC2RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===T.BC3RGBAUnorm||e===T.BC3RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===T.BC4RUnorm||e===T.BC4RSnorm)return{byteLength:8,width:4,height:4};if(e===T.BC5RGUnorm||e===T.BC5RGSnorm)return{byteLength:16,width:4,height:4};if(e===T.BC6HRGBUFloat||e===T.BC6HRGBFloat)return{byteLength:16,width:4,height:4};if(e===T.BC7RGBAUnorm||e===T.BC7RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===T.ETC2RGB8Unorm||e===T.ETC2RGB8UnormSRGB)return{byteLength:8,width:4,height:4};if(e===T.ETC2RGB8A1Unorm||e===T.ETC2RGB8A1UnormSRGB)return{byteLength:8,width:4,height:4};if(e===T.ETC2RGBA8Unorm||e===T.ETC2RGBA8UnormSRGB)return{byteLength:16,width:4,height:4};if(e===T.EACR11Unorm)return{byteLength:8,width:4,height:4};if(e===T.EACR11Snorm)return{byteLength:8,width:4,height:4};if(e===T.EACRG11Unorm)return{byteLength:16,width:4,height:4};if(e===T.EACRG11Snorm)return{byteLength:16,width:4,height:4};if(e===T.ASTC4x4Unorm||e===T.ASTC4x4UnormSRGB)return{byteLength:16,width:4,height:4};if(e===T.ASTC5x4Unorm||e===T.ASTC5x4UnormSRGB)return{byteLength:16,width:5,height:4};if(e===T.ASTC5x5Unorm||e===T.ASTC5x5UnormSRGB)return{byteLength:16,width:5,height:5};if(e===T.ASTC6x5Unorm||e===T.ASTC6x5UnormSRGB)return{byteLength:16,width:6,height:5};if(e===T.ASTC6x6Unorm||e===T.ASTC6x6UnormSRGB)return{byteLength:16,width:6,height:6};if(e===T.ASTC8x5Unorm||e===T.ASTC8x5UnormSRGB)return{byteLength:16,width:8,height:5};if(e===T.ASTC8x6Unorm||e===T.ASTC8x6UnormSRGB)return{byteLength:16,width:8,height:6};if(e===T.ASTC8x8Unorm||e===T.ASTC8x8UnormSRGB)return{byteLength:16,width:8,height:8};if(e===T.ASTC10x5Unorm||e===T.ASTC10x5UnormSRGB)return{byteLength:16,width:10,height:5};if(e===T.ASTC10x6Unorm||e===T.ASTC10x6UnormSRGB)return{byteLength:16,width:10,height:6};if(e===T.ASTC10x8Unorm||e===T.ASTC10x8UnormSRGB)return{byteLength:16,width:10,height:8};if(e===T.ASTC10x10Unorm||e===T.ASTC10x10UnormSRGB)return{byteLength:16,width:10,height:10};if(e===T.ASTC12x10Unorm||e===T.ASTC12x10UnormSRGB)return{byteLength:16,width:12,height:10};if(e===T.ASTC12x12Unorm||e===T.ASTC12x12UnormSRGB)return{byteLength:16,width:12,height:12}}_convertAddressMode(e){let t=cn.ClampToEdge;return e===l.RepeatWrapping?t=cn.Repeat:e===l.MirroredRepeatWrapping&&(t=cn.MirrorRepeat),t}_convertFilterMode(e){let t=Ct.Linear;return(e===l.NearestFilter||e===l.NearestMipmapNearestFilter||e===l.NearestMipmapLinearFilter)&&(t=Ct.Nearest),t}_getBytesPerTexel(e){if(e===T.R8Unorm||e===T.R8Snorm||e===T.R8Uint||e===T.R8Sint)return 1;if(e===T.R16Uint||e===T.R16Sint||e===T.R16Float||e===T.RG8Unorm||e===T.RG8Snorm||e===T.RG8Uint||e===T.RG8Sint)return 2;if(e===T.R32Uint||e===T.R32Sint||e===T.R32Float||e===T.RG16Uint||e===T.RG16Sint||e===T.RG16Float||e===T.RGBA8Unorm||e===T.RGBA8UnormSRGB||e===T.RGBA8Snorm||e===T.RGBA8Uint||e===T.RGBA8Sint||e===T.BGRA8Unorm||e===T.BGRA8UnormSRGB||e===T.RGB9E5UFloat||e===T.RGB10A2Unorm||e===T.RG11B10UFloat||e===T.Depth32Float||e===T.Depth24Plus||e===T.Depth24PlusStencil8||e===T.Depth32FloatStencil8)return 4;if(e===T.RG32Uint||e===T.RG32Sint||e===T.RG32Float||e===T.RGBA16Uint||e===T.RGBA16Sint||e===T.RGBA16Float)return 8;if(e===T.RGBA32Uint||e===T.RGBA32Sint||e===T.RGBA32Float)return 16}_getTypedArrayType(e){if(e===T.R8Uint)return Uint8Array;if(e===T.R8Sint)return Int8Array;if(e===T.R8Unorm)return Uint8Array;if(e===T.R8Snorm)return Int8Array;if(e===T.RG8Uint)return Uint8Array;if(e===T.RG8Sint)return Int8Array;if(e===T.RG8Unorm)return Uint8Array;if(e===T.RG8Snorm)return Int8Array;if(e===T.RGBA8Uint)return Uint8Array;if(e===T.RGBA8Sint)return Int8Array;if(e===T.RGBA8Unorm)return Uint8Array;if(e===T.RGBA8Snorm)return Int8Array;if(e===T.R16Uint)return Uint16Array;if(e===T.R16Sint)return Int16Array;if(e===T.RG16Uint)return Uint16Array;if(e===T.RG16Sint)return Int16Array;if(e===T.RGBA16Uint)return Uint16Array;if(e===T.RGBA16Sint)return Int16Array;if(e===T.R16Float||e===T.RG16Float||e===T.RGBA16Float)return Uint16Array;if(e===T.R32Uint)return Uint32Array;if(e===T.R32Sint)return Int32Array;if(e===T.R32Float)return Float32Array;if(e===T.RG32Uint)return Uint32Array;if(e===T.RG32Sint)return Int32Array;if(e===T.RG32Float)return Float32Array;if(e===T.RGBA32Uint)return Uint32Array;if(e===T.RGBA32Sint)return Int32Array;if(e===T.RGBA32Float)return Float32Array;if(e===T.BGRA8Unorm||e===T.BGRA8UnormSRGB)return Uint8Array;if(e===T.RGB10A2Unorm||e===T.RGB9E5UFloat||e===T.RG11B10UFloat)return Uint32Array;if(e===T.Depth32Float)return Float32Array;if(e===T.Depth24Plus||e===T.Depth24PlusStencil8)return Uint32Array;if(e===T.Depth32FloatStencil8)return Float32Array}_getDimension(e){let t;return e.is3DTexture||e.isData3DTexture?t=Xo.ThreeD:t=Xo.TwoD,t}}function Pn(o,e=null){const t=o.format,s=o.type,r=o.colorSpace,n=l.ColorManagement.getTransfer(r);let i;if(o.isCompressedTexture===!0||o.isCompressedArrayTexture===!0)switch(t){case l.RGBA_S3TC_DXT1_Format:i=n===l.SRGBTransfer?T.BC1RGBAUnormSRGB:T.BC1RGBAUnorm;break;case l.RGBA_S3TC_DXT3_Format:i=n===l.SRGBTransfer?T.BC2RGBAUnormSRGB:T.BC2RGBAUnorm;break;case l.RGBA_S3TC_DXT5_Format:i=n===l.SRGBTransfer?T.BC3RGBAUnormSRGB:T.BC3RGBAUnorm;break;case l.RGB_ETC2_Format:i=n===l.SRGBTransfer?T.ETC2RGB8UnormSRGB:T.ETC2RGB8Unorm;break;case l.RGBA_ETC2_EAC_Format:i=n===l.SRGBTransfer?T.ETC2RGBA8UnormSRGB:T.ETC2RGBA8Unorm;break;case l.RGBA_ASTC_4x4_Format:i=n===l.SRGBTransfer?T.ASTC4x4UnormSRGB:T.ASTC4x4Unorm;break;case l.RGBA_ASTC_5x4_Format:i=n===l.SRGBTransfer?T.ASTC5x4UnormSRGB:T.ASTC5x4Unorm;break;case l.RGBA_ASTC_5x5_Format:i=n===l.SRGBTransfer?T.ASTC5x5UnormSRGB:T.ASTC5x5Unorm;break;case l.RGBA_ASTC_6x5_Format:i=n===l.SRGBTransfer?T.ASTC6x5UnormSRGB:T.ASTC6x5Unorm;break;case l.RGBA_ASTC_6x6_Format:i=n===l.SRGBTransfer?T.ASTC6x6UnormSRGB:T.ASTC6x6Unorm;break;case l.RGBA_ASTC_8x5_Format:i=n===l.SRGBTransfer?T.ASTC8x5UnormSRGB:T.ASTC8x5Unorm;break;case l.RGBA_ASTC_8x6_Format:i=n===l.SRGBTransfer?T.ASTC8x6UnormSRGB:T.ASTC8x6Unorm;break;case l.RGBA_ASTC_8x8_Format:i=n===l.SRGBTransfer?T.ASTC8x8UnormSRGB:T.ASTC8x8Unorm;break;case l.RGBA_ASTC_10x5_Format:i=n===l.SRGBTransfer?T.ASTC10x5UnormSRGB:T.ASTC10x5Unorm;break;case l.RGBA_ASTC_10x6_Format:i=n===l.SRGBTransfer?T.ASTC10x6UnormSRGB:T.ASTC10x6Unorm;break;case l.RGBA_ASTC_10x8_Format:i=n===l.SRGBTransfer?T.ASTC10x8UnormSRGB:T.ASTC10x8Unorm;break;case l.RGBA_ASTC_10x10_Format:i=n===l.SRGBTransfer?T.ASTC10x10UnormSRGB:T.ASTC10x10Unorm;break;case l.RGBA_ASTC_12x10_Format:i=n===l.SRGBTransfer?T.ASTC12x10UnormSRGB:T.ASTC12x10Unorm;break;case l.RGBA_ASTC_12x12_Format:i=n===l.SRGBTransfer?T.ASTC12x12UnormSRGB:T.ASTC12x12Unorm;break;case l.RGBAFormat:i=n===l.SRGBTransfer?T.RGBA8UnormSRGB:T.RGBA8Unorm;break;default:console.error("WebGPURenderer: Unsupported texture format.",t)}else switch(t){case l.RGBAFormat:switch(s){case l.ByteType:i=T.RGBA8Snorm;break;case l.ShortType:i=T.RGBA16Sint;break;case l.UnsignedShortType:i=T.RGBA16Uint;break;case l.UnsignedIntType:i=T.RGBA32Uint;break;case l.IntType:i=T.RGBA32Sint;break;case l.UnsignedByteType:i=n===l.SRGBTransfer?T.RGBA8UnormSRGB:T.RGBA8Unorm;break;case l.HalfFloatType:i=T.RGBA16Float;break;case l.FloatType:i=T.RGBA32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBAFormat.",s)}break;case l.RGBFormat:switch(s){case l.UnsignedInt5999Type:i=T.RGB9E5UFloat;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBFormat.",s)}break;case l.RedFormat:switch(s){case l.ByteType:i=T.R8Snorm;break;case l.ShortType:i=T.R16Sint;break;case l.UnsignedShortType:i=T.R16Uint;break;case l.UnsignedIntType:i=T.R32Uint;break;case l.IntType:i=T.R32Sint;break;case l.UnsignedByteType:i=T.R8Unorm;break;case l.HalfFloatType:i=T.R16Float;break;case l.FloatType:i=T.R32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RedFormat.",s)}break;case l.RGFormat:switch(s){case l.ByteType:i=T.RG8Snorm;break;case l.ShortType:i=T.RG16Sint;break;case l.UnsignedShortType:i=T.RG16Uint;break;case l.UnsignedIntType:i=T.RG32Uint;break;case l.IntType:i=T.RG32Sint;break;case l.UnsignedByteType:i=T.RG8Unorm;break;case l.HalfFloatType:i=T.RG16Float;break;case l.FloatType:i=T.RG32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RGFormat.",s)}break;case l.DepthFormat:switch(s){case l.UnsignedShortType:i=T.Depth16Unorm;break;case l.UnsignedIntType:i=T.Depth24Plus;break;case l.FloatType:i=T.Depth32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with DepthFormat.",s)}break;case l.DepthStencilFormat:switch(s){case l.UnsignedInt248Type:i=T.Depth24PlusStencil8;break;case l.FloatType:e&&e.features.has(wn.Depth32FloatStencil8)===!1&&console.error('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),i=T.Depth32FloatStencil8;break;default:console.error("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",s)}break;case l.RedIntegerFormat:switch(s){case l.IntType:i=T.R32Sint;break;case l.UnsignedIntType:i=T.R32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",s)}break;case l.RGIntegerFormat:switch(s){case l.IntType:i=T.RG32Sint;break;case l.UnsignedIntType:i=T.RG32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",s)}break;case l.RGBAIntegerFormat:switch(s){case l.IntType:i=T.RGBA32Sint;break;case l.UnsignedIntType:i=T.RGBA32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",s)}break;default:console.error("WebGPURenderer: Unsupported texture format.",t)}return i}const ET=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,BT=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,Ko={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2<f32>":"vec2","vec2<i32>":"ivec2","vec2<u32>":"uvec2","vec2<bool>":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3<f32>":"vec3","vec3<i32>":"ivec3","vec3<u32>":"uvec3","vec3<bool>":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4<f32>":"vec4","vec4<i32>":"ivec4","vec4<u32>":"uvec4","vec4<bool>":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2<f32>":"mat2",mat2x2f:"mat2","mat3x3<f32>":"mat3",mat3x3f:"mat3","mat4x4<f32>":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},MT=o=>{o=o.trim();const e=o.match(ET);if(e!==null&&e.length===4){const t=e[2],s=[];let r=null;for(;(r=BT.exec(t))!==null;)s.push({name:r[1],type:r[2]});const n=[];for(let d=0;d<s.length;d++){const{name:h,type:p}=s[d];let f=p;f.startsWith("ptr")?f="pointer":(f.startsWith("texture")&&(f=p.split("<")[0]),f=Ko[f]),n.push(new Cr(f,h))}const i=o.substring(e[0].length),u=e[3]||"void",a=e[1]!==void 0?e[1]:"";return{type:Ko[u]||u,inputs:n,name:a,inputsCode:t,blockCode:i,outputType:u}}else throw new Error("FunctionNode: Function is not a WGSL code.")};class FT extends Si{constructor(e){const{type:t,inputs:s,name:r,inputsCode:n,blockCode:i,outputType:u}=MT(e);super(t,s,r),this.inputsCode=n,this.blockCode=i,this.outputType=u}getCode(e=this.name){const t=this.outputType!=="void"?"-> "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class wT extends Dl{parseFunction(e){return new FT(e)}}const Ut=typeof self<"u"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},PT={[He.READ_ONLY]:"read",[He.WRITE_ONLY]:"write",[He.READ_WRITE]:"read_write"},Qo={[l.RepeatWrapping]:"repeat",[l.ClampToEdgeWrapping]:"clamp",[l.MirroredRepeatWrapping]:"mirror"},js={vertex:Ut?Ut.VERTEX:1,fragment:Ut?Ut.FRAGMENT:2,compute:Ut?Ut.COMPUTE:4},Yo={instance:!0,swizzleAssign:!1,storageBuffer:!0},DT={"^^":"tsl_xor"},LT={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3<f32>",vec2:"vec2<f32>",ivec2:"vec2<i32>",uvec2:"vec2<u32>",bvec2:"vec2<bool>",vec3:"vec3<f32>",ivec3:"vec3<i32>",uvec3:"vec3<u32>",bvec3:"vec3<bool>",vec4:"vec4<f32>",ivec4:"vec4<i32>",uvec4:"vec4<u32>",bvec4:"vec4<bool>",mat2:"mat2x2<f32>",mat3:"mat3x3<f32>",mat4:"mat4x4<f32>"},jo={},Fe={tsl_xor:new de("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new de("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new de("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new de("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new de("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new de("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new de("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new de("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new de("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new de("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new de("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new de("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new de(`
236
- fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
237
-
238
- let res = vec2f( iRes );
239
-
240
- let uvScaled = coord * res;
241
- let uvWrapping = ( ( uvScaled % res ) + res ) % res;
242
-
243
- // https://www.shadertoy.com/view/WtyXRy
244
-
245
- let uv = uvWrapping - 0.5;
246
- let iuv = floor( uv );
247
- let f = fract( uv );
248
-
249
- let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
250
- let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
251
- let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
252
- let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
253
-
254
- return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
255
-
256
- }
257
- `)},ys={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast<f32>"};typeof navigator<"u"&&/Windows/g.test(navigator.userAgent)&&(Fe.pow_float=new de("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),Fe.pow_vec2=new de("fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }",[Fe.pow_float]),Fe.pow_vec3=new de("fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }",[Fe.pow_float]),Fe.pow_vec4=new de("fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }",[Fe.pow_float]),ys.pow_float="tsl_pow_float",ys.pow_vec2="tsl_pow_vec2",ys.pow_vec3="tsl_pow_vec3",ys.pow_vec4="tsl_pow_vec4");let ql="";(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(ql+=`diagnostic( off, derivative_uniformity );
258
- `);class UT extends _i{constructor(e,t){super(e,t,new wT),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==l.NoColorSpace}_generateTextureSample(e,t,s,r,n=this.shaderStage){return n==="fragment"?r?`textureSample( ${t}, ${t}_sampler, ${s}, ${r} )`:`textureSample( ${t}, ${t}_sampler, ${s} )`:this._generateTextureSampleLevel(e,t,s,"0",r)}_generateVideoSample(e,t,s=this.shaderStage){if(s==="fragment")return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2<f32>( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${s} shader.`)}_generateTextureSampleLevel(e,t,s,r,n){return this.isUnfilterable(e)===!1?`textureSampleLevel( ${t}, ${t}_sampler, ${s}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,s,r):this.generateTextureLod(e,t,s,n,r)}generateWrapFunction(e){const t=`tsl_coord_${Qo[e.wrapS]}S_${Qo[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let s=jo[t];if(s===void 0){const r=[],n=e.isData3DTexture?"vec3f":"vec2f";let i=`fn ${t}( coord : ${n} ) -> ${n} {
259
-
260
- return ${n}(
261
- `;const u=(a,c)=>{a===l.RepeatWrapping?(r.push(Fe.repeatWrapping_float),i+=` tsl_repeatWrapping_float( coord.${c} )`):a===l.ClampToEdgeWrapping?(r.push(Fe.clampWrapping_float),i+=` tsl_clampWrapping_float( coord.${c} )`):a===l.MirroredRepeatWrapping?(r.push(Fe.mirrorWrapping_float),i+=` tsl_mirrorWrapping_float( coord.${c} )`):(i+=` coord.${c}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${a}" for vertex shader.`))};u(e.wrapS,"x"),i+=`,
262
- `,u(e.wrapT,"y"),e.isData3DTexture&&(i+=`,
263
- `,u(e.wrapR,"z")),i+=`
264
- );
265
-
266
- }
267
- `,jo[t]=s=new de(i,r)}return s.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,s){const r=this.getDataFromNode(e,this.shaderStage,this.globalCache);r.dimensionsSnippet===void 0&&(r.dimensionsSnippet={});let n=r.dimensionsSnippet[s];if(r.dimensionsSnippet[s]===void 0){let i,u;const{primarySamples:a}=this.renderer.backend.utils.getTextureSampleData(e),c=a>1;e.isData3DTexture?u="vec3<u32>":u="vec2<u32>",c||e.isVideoTexture||e.isStorageTexture?i=t:i=`${t}${s?`, u32( ${s} )`:""}`,n=new _s(new Ns(`textureDimensions( ${i} )`,u)),r.dimensionsSnippet[s]=n,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(r.arrayLayerCount=new _s(new Ns(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(r.cubeFaceCount=new _s(new Ns("6u","u32")))}return n.build(this)}generateFilteredTexture(e,t,s,r="0u"){this._include("biquadraticTexture");const n=this.generateWrapFunction(e),i=this.generateTextureDimension(e,t,r);return`tsl_biquadraticTexture( ${t}, ${n}( ${s} ), ${i}, u32( ${r} ) )`}generateTextureLod(e,t,s,r,n="0u"){const i=this.generateWrapFunction(e),u=this.generateTextureDimension(e,t,n),a=e.isData3DTexture?"vec3":"vec2",c=`${a}<u32>( ${i}( ${s} ) * ${a}<f32>( ${u} ) )`;return this.generateTextureLoad(e,t,c,r,n)}generateTextureLoad(e,t,s,r,n="0u"){let i;return e.isVideoTexture===!0?i=`textureLoad( ${t}, ${s} )`:r?i=`textureLoad( ${t}, ${s}, ${r}, u32( ${n} ) )`:(i=`textureLoad( ${t}, ${s}, u32( ${n} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(i+=".x")),i}generateTextureStore(e,t,s,r,n){let i;return r?i=`textureStore( ${t}, ${s}, ${r}, ${n} )`:i=`textureStore( ${t}, ${s}, ${n} )`,i}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.isDataTexture===!0&&e.type===l.FloatType||this.isSampleCompare(e)===!1&&e.minFilter===l.NearestFilter&&e.magFilter===l.NearestFilter||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,s,r,n=this.shaderStage){let i=null;return e.isVideoTexture===!0?i=this._generateVideoSample(t,s,n):this.isUnfilterable(e)?i=this.generateTextureLod(e,t,s,r,"0",n):i=this._generateTextureSample(e,t,s,r,n),i}generateTextureGrad(e,t,s,r,n,i=this.shaderStage){if(i==="fragment")return`textureSampleGrad( ${t}, ${t}_sampler, ${s}, ${r[0]}, ${r[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${i} shader.`)}generateTextureCompare(e,t,s,r,n,i=this.shaderStage){if(i==="fragment")return e.isDepthTexture===!0&&e.isArrayTexture===!0?`textureSampleCompare( ${t}, ${t}_sampler, ${s}, ${n}, ${r} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${s}, ${r} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${i} shader.`)}generateTextureLevel(e,t,s,r,n,i=this.shaderStage){let u=null;return e.isVideoTexture===!0?u=this._generateVideoSample(t,s,i):u=this._generateTextureSampleLevel(e,t,s,r,n),u}generateTextureBias(e,t,s,r,n,i=this.shaderStage){if(i==="fragment")return`textureSampleBias( ${t}, ${t}_sampler, ${s}, ${r} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${i} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){const s=e.name,r=e.type;return r==="texture"||r==="cubeTexture"||r==="storageTexture"||r==="texture3D"?s:r==="buffer"||r==="storageBuffer"||r==="indirectStorageBuffer"?this.isCustomStruct(e)?s:s+".value":e.groupNode.name+"."+s}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=DT[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?He.READ_ONLY:e.access}getStorageAccess(e,t){return PT[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,s,r=null){const n=super.getUniformFromNode(e,t,s,r),i=this.getDataFromNode(e,s,this.globalCache);if(i.uniformGPU===void 0){let u;const a=e.groupNode,c=a.name,d=this.getBindGroupArray(c,s);if(t==="texture"||t==="cubeTexture"||t==="storageTexture"||t==="texture3D"){let h=null;const p=this.getNodeAccess(e,s);if(t==="texture"||t==="storageTexture"?h=new Er(n.name,n.node,a,p):t==="cubeTexture"?h=new zl(n.name,n.node,a,p):t==="texture3D"&&(h=new $l(n.name,n.node,a,p)),h.store=e.isStorageTextureNode===!0,h.setVisibility(js[s]),this.isUnfilterable(e.value)===!1&&h.store===!1){const f=new _T(`${n.name}_sampler`,n.node,a);f.setVisibility(js[s]),d.push(f,h),u=[f,h]}else d.push(h),u=[h]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const h=t==="buffer"?Vl:bT,p=new h(e,a);p.setVisibility(js[s]),d.push(p),u=p,n.name=r||"NodeBuffer_"+n.id}else{const h=this.uniformGroups[s]||(this.uniformGroups[s]={});let p=h[c];p===void 0&&(p=new kl(c,a),p.setVisibility(js[s]),h[c]=p,d.push(p)),u=this.getNodeUniform(n,t),p.addUniform(u)}i.uniformGPU=u}return n}getBuiltin(e,t,s,r=this.shaderStage){const n=this.builtins[r]||(this.builtins[r]=new Map);return n.has(e)===!1&&n.set(e,{name:e,property:t,type:s}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,s=this.flowShaderNode(e),r=[];for(const i of t.inputs)r.push(i.name+" : "+this.getType(i.type));let n=`fn ${t.name}( ${r.join(", ")} ) -> ${this.getType(t.type)} {
268
- ${s.vars}
269
- ${s.code}
270
- `;return s.result&&(n+=` return ${s.result};
271
- `),n+=`
272
- }
273
- `,n}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4<f32>")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],s=this.directives[e];if(s!==void 0)for(const r of s)t.push(`enable ${r};`);return t.join(`
274
- `)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array<f32, ${e} >`,"vertex")}getBuiltins(e){const t=[],s=this.builtins[e];if(s!==void 0)for(const{name:r,property:n,type:i}of s.values())t.push(`@builtin( ${r} ) ${n} : ${i}`);return t.join(`,
275
- `)}getScopedArray(e,t,s,r){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:s,bufferCount:r}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:s,scope:r,bufferType:n,bufferCount:i}of this.scopedArrays.values()){const u=this.getType(n);t.push(`var<${r}> ${s}: array< ${u}, ${i} >;`)}return t.join(`
276
- `)}getAttributes(e){const t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","globalId","vec3<u32>","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3<u32>","attribute"),this.getBuiltin("local_invocation_id","localId","vec3<u32>","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3<u32>","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){const s=this.getBuiltins("attribute");s&&t.push(s);const r=this.getAttributesArray();for(let n=0,i=r.length;n<i;n++){const u=r[n],a=u.name,c=this.getType(u.type);t.push(`@location( ${n} ) ${a} : ${c}`)}}return t.join(`,
277
- `)}getStructMembers(e){const t=[];for(const s of e.members){const r=e.output?"@location( "+s.index+" ) ":"";let n=this.getType(s.type);s.atomic&&(n="atomic< "+n+" >"),t.push(` ${r+s.name} : ${n}`)}return e.output&&t.push(` ${this.getBuiltins("output")}`),t.join(`,
278
- `)}getStructs(e){let t="";const s=this.structs[e];if(s.length>0){const r=[];for(const n of s){let i=`struct ${n.name} {
279
- `;i+=this.getStructMembers(n),i+=`
280
- };`,r.push(i)}t=`
281
- `+r.join(`
282
-
283
- `)+`
284
- `}return t}getVar(e,t,s=null){let r=`var ${t} : `;return s!==null?r+=this.generateArrayDeclaration(e,s):r+=this.getType(e),r}getVars(e){const t=[],s=this.vars[e];if(s!==void 0)for(const r of s)t.push(` ${this.getVar(r.type,r.name,r.count)};`);return`
285
- ${t.join(`
286
- `)}
287
- `}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","Vertex","vec4<f32>","vertex"),e==="vertex"||e==="fragment"){const n=this.varyings,i=this.vars[e];for(let u=0;u<n.length;u++){const a=n[u];if(a.needsInterpolation){let c=`@location( ${u} )`;if(a.interpolationType){const d=a.interpolationSampling!==null?`, ${a.interpolationSampling} )`:" )";c+=` @interpolate( ${a.interpolationType}${d}`}else/^(int|uint|ivec|uvec)/.test(a.type)&&(c+=` @interpolate( ${this.renderer.backend.compatibilityMode?"flat, either":"flat"} )`);t.push(`${c} ${a.name} : ${this.getType(a.type)}`)}else e==="vertex"&&i.includes(a)===!1&&i.push(a)}}const s=this.getBuiltins(e);s&&t.push(s);const r=t.join(`,
288
- `);return e==="vertex"?this._getWGSLStruct("VaryingsStruct"," "+r):r}isCustomStruct(e){const t=e.value,s=e.node,r=(t.isBufferAttribute||t.isInstancedBufferAttribute)&&s.structTypeNode!==null,n=s.value&&s.value.array&&typeof s.value.itemSize=="number"&&s.value.array.length>s.value.itemSize;return r&&!n}getUniforms(e){const t=this.uniforms[e],s=[],r=[],n=[],i={};for(const a of t){const c=a.groupNode.name,d=this.bindingsIndexes[c];if(a.type==="texture"||a.type==="cubeTexture"||a.type==="storageTexture"||a.type==="texture3D"){const h=a.node.value;this.isUnfilterable(h)===!1&&a.node.isStorageTextureNode!==!0&&(this.isSampleCompare(h)?s.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${a.name}_sampler : sampler_comparison;`):s.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${a.name}_sampler : sampler;`));let p,f="";const{primarySamples:g}=this.renderer.backend.utils.getTextureSampleData(h);if(g>1&&(f="_multisampled"),h.isCubeTexture===!0)p="texture_cube<f32>";else if(h.isDepthTexture===!0)this.renderer.backend.compatibilityMode&&h.compareFunction===null?p=`texture${f}_2d<f32>`:p=`texture_depth${f}_2d${h.isArrayTexture===!0?"_array":""}`;else if(a.node.isStorageTextureNode===!0){const m=Pn(h),y=this.getStorageAccess(a.node,e),_=a.node.value.is3DTexture,C=a.node.value.isArrayTexture;p=`texture_storage_${_?"3d":`2d${C?"_array":""}`}<${m}, ${y}>`}else if(h.isArrayTexture===!0||h.isDataArrayTexture===!0||h.isCompressedArrayTexture===!0)p="texture_2d_array<f32>";else if(h.is3DTexture===!0||h.isData3DTexture===!0)p="texture_3d<f32>";else if(h.isVideoTexture===!0)p="texture_external";else{const m=this.getComponentTypeFromTexture(h).charAt(0);p=`texture${f}_2d<${m}32>`}s.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${a.name} : ${p};`)}else if(a.type==="buffer"||a.type==="storageBuffer"||a.type==="indirectStorageBuffer"){const h=a.node,p=this.getType(h.getNodeType(this)),f=h.bufferCount,g=f>0&&a.type==="buffer"?", "+f:"",m=h.isStorageBufferNode?`storage, ${this.getStorageAccess(h,e)}`:"uniform";if(this.isCustomStruct(a))r.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var<${m}> ${a.name} : ${p};`);else{const _=` value : array< ${h.isAtomic?`atomic<${p}>`:`${p}`}${g} >`;r.push(this._getWGSLStructBinding(a.name,_,m,d.binding++,d.group))}}else{const h=this.getType(this.getVectorType(a.type)),p=a.groupNode.name;(i[p]||(i[p]={index:d.binding++,id:d.group,snippets:[]})).snippets.push(` ${a.name} : ${h}`)}}for(const a in i){const c=i[a];n.push(this._getWGSLStructBinding(a,c.snippets.join(`,
289
- `),"uniform",c.index,c.id))}let u=s.join(`
290
- `);return u+=r.join(`
291
- `),u+=n.join(`
292
- `),u}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const s=e[t];s.uniforms=this.getUniforms(t),s.attributes=this.getAttributes(t),s.varyings=this.getVaryings(t),s.structs=this.getStructs(t),s.vars=this.getVars(t),s.codes=this.getCodes(t),s.directives=this.getDirectives(t),s.scopedArrays=this.getScopedArrays(t);let r=`// code
293
-
294
- `;r+=this.flowCode[t];const n=this.flowNodes[t],i=n[n.length-1],u=i.outputNode,a=u!==void 0&&u.isOutputStructNode===!0;for(const c of n){const d=this.getFlowData(c),h=c.name;if(h&&(r.length>0&&(r+=`
295
- `),r+=` // flow -> ${h}
296
- `),r+=`${d.code}
297
- `,c===i&&t!=="compute"){if(r+=`// result
298
-
299
- `,t==="vertex")r+=`varyings.Vertex = ${d.result};`;else if(t==="fragment")if(a)s.returnType=u.getNodeType(this),s.structs+="var<private> output : "+s.returnType+";",r+=`return ${d.result};`;else{let p=" @location(0) color: vec4<f32>";const f=this.getBuiltins("output");f&&(p+=`,
300
- `+f),s.returnType="OutputStruct",s.structs+=this._getWGSLStruct("OutputStruct",p),s.structs+=`
301
- var<private> output : OutputStruct;`,r+=`output.color = ${d.result};
302
-
303
- return output;`}}}s.flow=r}this.shaderStage=null,this.material!==null?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let s;return t!==null&&(s=this._getWGSLMethod(e+"_"+t)),s===void 0&&(s=this._getWGSLMethod(e)),s||e}getType(e){return LT[e]||e}isAvailable(e){let t=Yo[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),Yo[e]=t),t}_getWGSLMethod(e){return Fe[e]!==void 0&&this._include(e),ys[e]}_include(e){const t=Fe[e];return t.build(this),this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}
304
- // directives
305
- ${e.directives}
306
-
307
- // structs
308
- ${e.structs}
309
-
310
- // uniforms
311
- ${e.uniforms}
312
-
313
- // varyings
314
- ${e.varyings}
315
- var<private> varyings : VaryingsStruct;
316
-
317
- // codes
318
- ${e.codes}
319
-
320
- @vertex
321
- fn main( ${e.attributes} ) -> VaryingsStruct {
322
-
323
- // vars
324
- ${e.vars}
325
-
326
- // flow
327
- ${e.flow}
328
-
329
- return varyings;
330
-
331
- }
332
- `}_getWGSLFragmentCode(e){return`${this.getSignature()}
333
- // global
334
- ${ql}
335
-
336
- // structs
337
- ${e.structs}
338
-
339
- // uniforms
340
- ${e.uniforms}
341
-
342
- // codes
343
- ${e.codes}
344
-
345
- @fragment
346
- fn main( ${e.varyings} ) -> ${e.returnType} {
347
-
348
- // vars
349
- ${e.vars}
350
-
351
- // flow
352
- ${e.flow}
353
-
354
- }
355
- `}_getWGSLComputeCode(e,t){return`${this.getSignature()}
356
- // directives
357
- ${e.directives}
358
-
359
- // system
360
- var<private> instanceIndex : u32;
361
-
362
- // locals
363
- ${e.scopedArrays}
364
-
365
- // structs
366
- ${e.structs}
367
-
368
- // uniforms
369
- ${e.uniforms}
370
-
371
- // codes
372
- ${e.codes}
373
-
374
- @compute @workgroup_size( ${t} )
375
- fn main( ${e.attributes} ) {
376
-
377
- // system
378
- instanceIndex = globalId.x + globalId.y * numWorkgroups.x * u32(${t}) + globalId.z * numWorkgroups.x * numWorkgroups.y * u32(${t});
379
-
380
- // vars
381
- ${e.vars}
382
-
383
- // flow
384
- ${e.flow}
385
-
386
- }
387
- `}_getWGSLStruct(e,t){return`
388
- struct ${e} {
389
- ${t}
390
- };`}_getWGSLStructBinding(e,t,s,r=0,n=0){const i=e+"Struct";return`${this._getWGSLStruct(i,t)}
391
- @binding( ${r} ) @group( ${n} )
392
- var<${s}> ${e} : ${i};`}}class GT{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=T.Depth24PlusStencil8:e.depth&&(t=T.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const n=this.backend.renderer,i=n.getRenderTarget();t=i?i.samples:n.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const s=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:s?1:t,isMSAA:s}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return kt.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return kt.LineList;if(e.isLine)return kt.LineStrip;if(e.isMesh)return kt.TriangleList}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),t===2&&(t=4)),t}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(e===void 0)return navigator.gpu.getPreferredCanvasFormat();if(e===l.UnsignedByteType)return T.BGRA8Unorm;if(e===l.HalfFloatType)return T.RGBA16Float;throw new Error("Unsupported outputType")}}const Xl=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);typeof Float16Array<"u"&&Xl.set(Float16Array,["float16"]);const IT=new Map([[l.Float16BufferAttribute,["float16"]]]),OT=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class VT{constructor(e){this.backend=e}createAttribute(e,t){const s=this._getBufferAttribute(e),r=this.backend,n=r.get(s);let i=n.buffer;if(i===void 0){const u=r.device;let a=s.array;if(e.normalized===!1){if(a.constructor===Int16Array||a.constructor===Int8Array)a=new Int32Array(a);else if((a.constructor===Uint16Array||a.constructor===Uint8Array)&&(a=new Uint32Array(a),t&GPUBufferUsage.INDEX))for(let h=0;h<a.length;h++)a[h]===65535&&(a[h]=4294967295)}if(s.array=a,(s.isStorageBufferAttribute||s.isStorageInstancedBufferAttribute)&&s.itemSize===3){a=new a.constructor(s.count*4);for(let h=0;h<s.count;h++)a.set(s.array.subarray(h*3,h*3+3),h*4);s.itemSize=4,s.array=a,n._force3to4BytesAlignment=!0}const c=a.byteLength,d=c+(4-c%4)%4;i=u.createBuffer({label:s.name,size:d,usage:t,mappedAtCreation:!0}),new a.constructor(i.getMappedRange()).set(a),i.unmap(),n.buffer=i}}updateAttribute(e){const t=this._getBufferAttribute(e),s=this.backend,r=s.device,n=s.get(t),i=s.get(t).buffer;let u=t.array;if(n._force3to4BytesAlignment===!0){u=new u.constructor(t.count*4);for(let d=0;d<t.count;d++)u.set(t.array.subarray(d*3,d*3+3),d*4);t.array=u}const a=this._isTypedArray(u),c=t.updateRanges;if(c.length===0)r.queue.writeBuffer(i,0,u,0);else{const d=a?1:u.BYTES_PER_ELEMENT;for(let h=0,p=c.length;h<p;h++){const f=c[h];let g,m;if(n._force3to4BytesAlignment===!0){const _=Math.floor(f.start/3),C=Math.ceil(f.count/3);g=_*4*d,m=C*4*d}else g=f.start*d,m=f.count*d;const y=g*(a?u.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(i,y,u,g,m)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){const t=e.getAttributes(),s=new Map;for(let r=0;r<t.length;r++){const n=t[r],i=n.array.BYTES_PER_ELEMENT,u=this._getBufferAttribute(n);let a=s.get(u);if(a===void 0){let h,p;n.isInterleavedBufferAttribute===!0?(h=n.data.stride*i,p=n.data.isInstancedInterleavedBuffer?Ys.Instance:Ys.Vertex):(h=n.itemSize*i,p=n.isInstancedBufferAttribute?Ys.Instance:Ys.Vertex),n.normalized===!1&&(n.array.constructor===Int16Array||n.array.constructor===Uint16Array)&&(h=4),a={arrayStride:h,attributes:[],stepMode:p},s.set(u,a)}const c=this._getVertexFormat(n),d=n.isInterleavedBufferAttribute===!0?n.offset*i:0;a.attributes.push({shaderLocation:r,offset:d,format:c})}return Array.from(s.values())}destroyAttribute(e){const t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e){const t=this.backend,s=t.device,n=t.get(this._getBufferAttribute(e)).buffer,i=n.size,u=s.createBuffer({label:`${e.name}_readback`,size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=s.createCommandEncoder({label:`readback_encoder_${e.name}`});a.copyBufferToBuffer(n,0,u,0,i);const c=a.finish();s.queue.submit([c]),await u.mapAsync(GPUMapMode.READ);const d=u.getMappedRange(),h=new e.array.constructor(d.slice(0));return u.unmap(),h.buffer}_getVertexFormat(e){const{itemSize:t,normalized:s}=e,r=e.array.constructor,n=e.constructor;let i;if(t===1)i=OT.get(r);else{const a=(IT.get(n)||Xl.get(r))[s?1:0];if(a){const c=r.BYTES_PER_ELEMENT*t,h=Math.floor((c+3)/4)*4/r.BYTES_PER_ELEMENT;if(h%1)throw new Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");i=`${a}x${h}`}}return i||console.error("THREE.WebGPUAttributeUtils: Vertex format not supported yet."),i}_isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}class kT{constructor(e){this.backend=e,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(e){const t=this.backend,s=t.device,r=[];let n=0;for(const i of e.bindings){const u={binding:n++,visibility:i.visibility};if(i.isUniformBuffer||i.isStorageBuffer){const a={};i.isStorageBuffer&&(i.visibility&4&&(i.access===He.READ_WRITE||i.access===He.WRITE_ONLY)?a.type=dn.Storage:a.type=dn.ReadOnlyStorage),u.buffer=a}else if(i.isSampler){const a={};i.texture.isDepthTexture&&(i.texture.compareFunction!==null?a.type=qo.Comparison:t.compatibilityMode&&(a.type=qo.NonFiltering)),u.sampler=a}else if(i.isSampledTexture&&i.texture.isVideoTexture)u.externalTexture={};else if(i.isSampledTexture&&i.store){const a={};a.format=this.backend.get(i.texture).texture.format;const c=i.access;c===He.READ_WRITE?a.access=hn.ReadWrite:c===He.WRITE_ONLY?a.access=hn.WriteOnly:a.access=hn.ReadOnly,i.texture.isArrayTexture?a.viewDimension=he.TwoDArray:i.texture.is3DTexture&&(a.viewDimension=he.ThreeD),u.storageTexture=a}else if(i.isSampledTexture){const a={},{primarySamples:c}=t.utils.getTextureSampleData(i.texture);if(c>1&&(a.multisampled=!0,i.texture.isDepthTexture||(a.sampleType=_t.UnfilterableFloat)),i.texture.isDepthTexture)t.compatibilityMode&&i.texture.compareFunction===null?a.sampleType=_t.UnfilterableFloat:a.sampleType=_t.Depth;else if(i.texture.isDataTexture||i.texture.isDataArrayTexture||i.texture.isData3DTexture){const d=i.texture.type;d===l.IntType?a.sampleType=_t.SInt:d===l.UnsignedIntType?a.sampleType=_t.UInt:d===l.FloatType&&(this.backend.hasFeature("float32-filterable")?a.sampleType=_t.Float:a.sampleType=_t.UnfilterableFloat)}i.isSampledCubeTexture?a.viewDimension=he.Cube:i.texture.isArrayTexture||i.texture.isDataArrayTexture||i.texture.isCompressedArrayTexture?a.viewDimension=he.TwoDArray:i.isSampledTexture3D&&(a.viewDimension=he.ThreeD),u.texture=a}else console.error(`WebGPUBindingUtils: Unsupported binding "${i}".`);r.push(u)}return s.createBindGroupLayout({entries:r})}createBindings(e,t,s,r=0){const{backend:n,bindGroupLayoutCache:i}=this,u=n.get(e);let a=i.get(e.bindingsReference);a===void 0&&(a=this.createBindingsLayout(e),i.set(e.bindingsReference,a));let c;s>0&&(u.groups===void 0&&(u.groups=[],u.versions=[]),u.versions[s]===r&&(c=u.groups[s])),c===void 0&&(c=this.createBindGroup(e,a),s>0&&(u.groups[s]=c,u.versions[s]=r)),u.group=c,u.layout=a}updateBinding(e){const t=this.backend,s=t.device,r=e.buffer,n=t.get(e).buffer;s.queue.writeBuffer(n,0,r,0)}createBindGroupIndex(e,t){const r=this.backend.device,n=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=e[0],u=r.createBuffer({label:"bindingCameraIndex_"+i,size:16,usage:n});r.queue.writeBuffer(u,0,e,0);const a=[{binding:0,resource:{buffer:u}}];return r.createBindGroup({label:"bindGroupCameraIndex_"+i,layout:t,entries:a})}createBindGroup(e,t){const s=this.backend,r=s.device;let n=0;const i=[];for(const u of e.bindings){if(u.isUniformBuffer){const a=s.get(u);if(a.buffer===void 0){const c=u.byteLength,d=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,h=r.createBuffer({label:"bindingBuffer_"+u.name,size:c,usage:d});a.buffer=h}i.push({binding:n,resource:{buffer:a.buffer}})}else if(u.isStorageBuffer){const a=s.get(u);if(a.buffer===void 0){const c=u.attribute;a.buffer=s.get(c).buffer}i.push({binding:n,resource:{buffer:a.buffer}})}else if(u.isSampler){const a=s.get(u.texture);i.push({binding:n,resource:a.sampler})}else if(u.isSampledTexture){const a=s.get(u.texture);let c;if(a.externalTexture!==void 0)c=r.importExternalTexture({source:a.externalTexture});else{const d=u.store?1:a.texture.mipLevelCount,h=`view-${a.texture.width}-${a.texture.height}-${d}`;if(c=a[h],c===void 0){const p=yT.All;let f;u.isSampledCubeTexture?f=he.Cube:u.isSampledTexture3D?f=he.ThreeD:u.texture.isArrayTexture||u.texture.isDataArrayTexture||u.texture.isCompressedArrayTexture?f=he.TwoDArray:f=he.TwoD,c=a[h]=a.texture.createView({aspect:p,dimension:f,mipLevelCount:d})}}i.push({binding:n,resource:c})}n++}return r.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:i})}}class zT{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:s,material:r,geometry:n,pipeline:i}=e,{vertexProgram:u,fragmentProgram:a}=i,c=this.backend,d=c.device,h=c.utils,p=c.get(i),f=[];for(const te of e.getBindings()){const ge=c.get(te);f.push(ge.layout)}const g=c.attributeUtils.createShaderVertexBuffers(e);let m;r.blending!==l.NoBlending&&(r.blending!==l.NormalBlending||r.transparent!==!1)&&(m=this._getBlending(r));let y={};r.stencilWrite===!0&&(y={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});const _=this._getColorWriteMask(r),C=[];if(e.context.textures!==null){const te=e.context.textures;for(let ge=0;ge<te.length;ge++){const Le=h.getTextureFormatGPU(te[ge]);C.push({format:Le,blend:m,writeMask:_})}}else{const te=h.getCurrentColorFormat(e.context);C.push({format:te,blend:m,writeMask:_})}const R=c.get(u).module,U=c.get(a).module,M=this._getPrimitiveState(s,n,r),D=this._getDepthCompare(r),F=h.getCurrentDepthStencilFormat(e.context),L=this._getSampleCount(e.context),G={label:`renderPipeline_${r.name||r.type}_${r.id}`,vertex:Object.assign({},R,{buffers:g}),fragment:Object.assign({},U,{targets:C}),primitive:M,multisample:{count:L,alphaToCoverageEnabled:r.alphaToCoverage&&L>1},layout:d.createPipelineLayout({bindGroupLayouts:f})},H={},q=e.context.depth,ee=e.context.stencil;if((q===!0||ee===!0)&&(q===!0&&(H.format=F,H.depthWriteEnabled=r.depthWrite,H.depthCompare=D),ee===!0&&(H.stencilFront=y,H.stencilBack={},H.stencilReadMask=r.stencilFuncMask,H.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&(H.depthBias=r.polygonOffsetUnits,H.depthBiasSlopeScale=r.polygonOffsetFactor,H.depthBiasClamp=0),G.depthStencil=H),t===null)p.pipeline=d.createRenderPipeline(G);else{const te=new Promise(ge=>{d.createRenderPipelineAsync(G).then(Le=>{p.pipeline=Le,ge()})});t.push(te)}}createBundleEncoder(e,t="renderBundleEncoder"){const s=this.backend,{utils:r,device:n}=s,i=r.getCurrentDepthStencilFormat(e),u=r.getCurrentColorFormat(e),a=this._getSampleCount(e),c={label:t,colorFormats:[u],depthStencilFormat:i,sampleCount:a};return n.createRenderBundleEncoder(c)}createComputePipeline(e,t){const s=this.backend,r=s.device,n=s.get(e.computeProgram).module,i=s.get(e),u=[];for(const a of t){const c=s.get(a);u.push(c.layout)}i.pipeline=r.createComputePipeline({compute:n,layout:r.createPipelineLayout({bindGroupLayouts:u})})}_getBlending(e){let t,s;const r=e.blending,n=e.blendSrc,i=e.blendDst,u=e.blendEquation;if(r===l.CustomBlending){const a=e.blendSrcAlpha!==null?e.blendSrcAlpha:n,c=e.blendDstAlpha!==null?e.blendDstAlpha:i,d=e.blendEquationAlpha!==null?e.blendEquationAlpha:u;t={srcFactor:this._getBlendFactor(n),dstFactor:this._getBlendFactor(i),operation:this._getBlendOperation(u)},s={srcFactor:this._getBlendFactor(a),dstFactor:this._getBlendFactor(c),operation:this._getBlendOperation(d)}}else{const a=e.premultipliedAlpha,c=(d,h,p,f)=>{t={srcFactor:d,dstFactor:h,operation:xt.Add},s={srcFactor:p,dstFactor:f,operation:xt.Add}};if(a)switch(r){case l.NormalBlending:c(W.One,W.OneMinusSrcAlpha,W.One,W.OneMinusSrcAlpha);break;case l.AdditiveBlending:c(W.One,W.One,W.One,W.One);break;case l.SubtractiveBlending:c(W.Zero,W.OneMinusSrc,W.Zero,W.One);break;case l.MultiplyBlending:c(W.Dst,W.OneMinusSrcAlpha,W.Zero,W.One);break}else switch(r){case l.NormalBlending:c(W.SrcAlpha,W.OneMinusSrcAlpha,W.One,W.OneMinusSrcAlpha);break;case l.AdditiveBlending:c(W.SrcAlpha,W.One,W.One,W.One);break;case l.SubtractiveBlending:console.error("THREE.WebGPURenderer: SubtractiveBlending requires material.premultipliedAlpha = true");break;case l.MultiplyBlending:console.error("THREE.WebGPURenderer: MultiplyBlending requires material.premultipliedAlpha = true");break}}if(t!==void 0&&s!==void 0)return{color:t,alpha:s};console.error("THREE.WebGPURenderer: Invalid blending: ",r)}_getBlendFactor(e){let t;switch(e){case l.ZeroFactor:t=W.Zero;break;case l.OneFactor:t=W.One;break;case l.SrcColorFactor:t=W.Src;break;case l.OneMinusSrcColorFactor:t=W.OneMinusSrc;break;case l.SrcAlphaFactor:t=W.SrcAlpha;break;case l.OneMinusSrcAlphaFactor:t=W.OneMinusSrcAlpha;break;case l.DstColorFactor:t=W.Dst;break;case l.OneMinusDstColorFactor:t=W.OneMinusDst;break;case l.DstAlphaFactor:t=W.DstAlpha;break;case l.OneMinusDstAlphaFactor:t=W.OneMinusDstAlpha;break;case l.SrcAlphaSaturateFactor:t=W.SrcAlphaSaturated;break;case qf:t=W.Constant;break;case Xf:t=W.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const s=e.stencilFunc;switch(s){case l.NeverStencilFunc:t=me.Never;break;case l.AlwaysStencilFunc:t=me.Always;break;case l.LessStencilFunc:t=me.Less;break;case l.LessEqualStencilFunc:t=me.LessEqual;break;case l.EqualStencilFunc:t=me.Equal;break;case l.GreaterEqualStencilFunc:t=me.GreaterEqual;break;case l.GreaterStencilFunc:t=me.Greater;break;case l.NotEqualStencilFunc:t=me.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",s)}return t}_getStencilOperation(e){let t;switch(e){case l.KeepStencilOp:t=nt.Keep;break;case l.ZeroStencilOp:t=nt.Zero;break;case l.ReplaceStencilOp:t=nt.Replace;break;case l.InvertStencilOp:t=nt.Invert;break;case l.IncrementStencilOp:t=nt.IncrementClamp;break;case l.DecrementStencilOp:t=nt.DecrementClamp;break;case l.IncrementWrapStencilOp:t=nt.IncrementWrap;break;case l.DecrementWrapStencilOp:t=nt.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case l.AddEquation:t=xt.Add;break;case l.SubtractEquation:t=xt.Subtract;break;case l.ReverseSubtractEquation:t=xt.ReverseSubtract;break;case l.MinEquation:t=xt.Min;break;case l.MaxEquation:t=xt.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,s){const r={},n=this.backend.utils;switch(r.topology=n.getPrimitiveTopology(e,s),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?jt.Uint16:jt.Uint32),s.side){case l.FrontSide:r.frontFace=un.CCW,r.cullMode=ln.Back;break;case l.BackSide:r.frontFace=un.CCW,r.cullMode=ln.Front;break;case l.DoubleSide:r.frontFace=un.CCW,r.cullMode=ln.None;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",s.side);break}return r}_getColorWriteMask(e){return e.colorWrite===!0?Ho.All:Ho.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=me.Always;else{const s=e.depthFunc;switch(s){case l.NeverDepth:t=me.Never;break;case l.AlwaysDepth:t=me.Always;break;case l.LessDepth:t=me.Less;break;case l.LessEqualDepth:t=me.LessEqual;break;case l.EqualDepth:t=me.Equal;break;case l.GreaterEqualDepth:t=me.GreaterEqual;break;case l.GreaterDepth:t=me.Greater;break;case l.NotEqualDepth:t=me.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",s)}}return t}}class $T extends Hl{constructor(e,t,s=2048){super(s),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});const r=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return l.warnOnce(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,s=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();const r=this.device.createCommandEncoder();r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,s);const n=r.finish();if(this.device.queue.submit([n]),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,s),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;const i=new BigUint64Array(this.resultBuffer.getMappedRange(0,s));let u=0;for(const[,a]of e){const c=i[a],d=i[a+1],h=Number(d-c)/1e6;u+=h}return this.resultBuffer.unmap(),this.lastValue=u,u}catch(e){return console.error("Error resolving queries:",e),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){console.error("Error waiting for pending resolve:",e)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(e){console.error("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class WT extends Wl{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.compatibilityMode=e.compatibilityMode===void 0?!1:e.compatibilityMode,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new GT(this),this.attributeUtils=new VT(this),this.bindingUtils=new kT(this),this.pipelineUtils=new zT(this),this.textureUtils=new vT(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let s;if(t.device===void 0){const i={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},u=typeof navigator<"u"?await navigator.gpu.requestAdapter(i):null;if(u===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const a=Object.values(wn),c=[];for(const h of a)u.features.has(h)&&c.push(h);const d={requiredFeatures:c,requiredLimits:t.requiredLimits};s=await u.requestDevice(d)}else s=t.device;s.lost.then(i=>{const u={api:"WebGPU",message:i.message||"Unknown reason",reason:i.reason||null,originalEvent:i};e.onDeviceLost(u)});const r=t.context!==void 0?t.context:e.domElement.getContext("webgpu");this.device=s,this.context=r;const n=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(wn.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:n}),this.updateSize()}get coordinateSystem(){return l.WebGPUCoordinateSystem}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){const s=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(s.depth,s.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const s=e.renderTarget,r=this.get(s);let n=r.descriptors;if(n===void 0||r.width!==s.width||r.height!==s.height||r.dimensions!==s.dimensions||r.activeMipmapLevel!==e.activeMipmapLevel||r.activeCubeFace!==e.activeCubeFace||r.samples!==s.samples){n={},r.descriptors=n;const c=()=>{s.removeEventListener("dispose",c),this.delete(s)};s.hasEventListener("dispose",c)===!1&&s.addEventListener("dispose",c)}const i=e.getCacheKey();let u=n[i];if(u===void 0){const c=e.textures,d=[];let h;const p=this._isRenderCameraDepthArray(e);for(let f=0;f<c.length;f++){const g=this.get(c[f]),m={label:`colorAttachment_${f}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:he.TwoD};if(s.isRenderTarget3D)h=e.activeCubeFace,m.baseArrayLayer=0,m.dimension=he.ThreeD,m.depthOrArrayLayers=c[f].image.depth;else if(s.isRenderTarget&&c[f].image.depth>1)if(p===!0){const y=e.camera.cameras;for(let _=0;_<y.length;_++){const C={...m,baseArrayLayer:_,arrayLayerCount:1,dimension:he.TwoD},R=g.texture.createView(C);d.push({view:R,resolveTarget:void 0,depthSlice:void 0})}}else m.dimension=he.TwoDArray,m.depthOrArrayLayers=c[f].image.depth;if(p!==!0){const y=g.texture.createView(m);let _,C;g.msaaTexture!==void 0?(_=g.msaaTexture.createView(),C=y):(_=y,C=void 0),d.push({view:_,resolveTarget:C,depthSlice:h})}}if(u={textureViews:d},e.depth){const f=this.get(e.depthTexture),g={};e.depthTexture.isArrayTexture&&(g.dimension=he.TwoD,g.arrayLayerCount=1,g.baseArrayLayer=e.activeCubeFace),u.depthStencilView=f.texture.createView(g)}n[i]=u,r.width=s.width,r.height=s.height,r.samples=s.samples,r.activeMipmapLevel=e.activeMipmapLevel,r.activeCubeFace=e.activeCubeFace,r.dimensions=s.dimensions}const a={colorAttachments:[]};for(let c=0;c<u.textureViews.length;c++){const d=u.textureViews[c];let h={r:0,g:0,b:0,a:1};c===0&&t.clearValue&&(h=t.clearValue),a.colorAttachments.push({view:d.view,depthSlice:d.depthSlice,resolveTarget:d.resolveTarget,loadOp:t.loadOp||Q.Load,storeOp:t.storeOp||xe.Store,clearValue:h})}return u.depthStencilView&&(a.depthStencilAttachment={view:u.depthStencilView}),a}beginRender(e){const t=this.get(e),s=this.device,r=e.occlusionQueryCount;let n;r>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,n=s.createQuerySet({type:"occlusion",count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=n,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(r),t.lastOcclusionObject=null);let i;e.textures===null?i=this._getDefaultRenderPassDescriptor():i=this._getRenderPassDescriptor(e,{loadOp:Q.Load}),this.initTimestampQuery(e,i),i.occlusionQuerySet=n;const u=i.depthStencilAttachment;if(e.textures!==null){const c=i.colorAttachments;for(let d=0;d<c.length;d++){const h=c[d];e.clearColor?(h.clearValue=d===0?e.clearColorValue:{r:0,g:0,b:0,a:1},h.loadOp=Q.Clear):h.loadOp=Q.Load,h.storeOp=xe.Store}}else{const c=i.colorAttachments[0];e.clearColor?(c.clearValue=e.clearColorValue,c.loadOp=Q.Clear):c.loadOp=Q.Load,c.storeOp=xe.Store}e.depth&&(e.clearDepth?(u.depthClearValue=e.clearDepthValue,u.depthLoadOp=Q.Clear):u.depthLoadOp=Q.Load,u.depthStoreOp=xe.Store),e.stencil&&(e.clearStencil?(u.stencilClearValue=e.clearStencilValue,u.stencilLoadOp=Q.Clear):u.stencilLoadOp=Q.Load,u.stencilStoreOp=xe.Store);const a=s.createCommandEncoder({label:"renderContext_"+e.id});if(this._isRenderCameraDepthArray(e)===!0){const c=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==c.length?this._createDepthLayerDescriptors(e,t,i,c):this._updateDepthLayerDescriptors(e,t,c),t.bundleEncoders=[],t.bundleSets=[];for(let d=0;d<c.length;d++){const h=this.pipelineUtils.createBundleEncoder(e,"renderBundleArrayCamera_"+d),p={attributes:{},bindingGroups:[],pipeline:null,index:null};t.bundleEncoders.push(h),t.bundleSets.push(p)}t.currentPass=null}else{const c=a.beginRenderPass(i);if(t.currentPass=c,e.viewport&&this.updateViewport(e),e.scissor){const{x:d,y:h,width:p,height:f}=e.scissorValue;c.setScissorRect(d,h,p,f)}}t.descriptor=i,t.encoder=a,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createDepthLayerDescriptors(e,t,s,r){const n=s.depthStencilAttachment;t.layerDescriptors=[];const i=this.get(e.depthTexture);i.viewCache||(i.viewCache=[]);for(let u=0;u<r.length;u++){const a={...s,colorAttachments:[{...s.colorAttachments[0],view:s.colorAttachments[u].view}]};if(s.depthStencilAttachment){const c=u;i.viewCache[c]||(i.viewCache[c]=i.texture.createView({dimension:he.TwoD,baseArrayLayer:u,arrayLayerCount:1})),a.depthStencilAttachment={view:i.viewCache[c],depthLoadOp:n.depthLoadOp||Q.Clear,depthStoreOp:n.depthStoreOp||xe.Store,depthClearValue:n.depthClearValue||1},e.stencil&&(a.depthStencilAttachment.stencilLoadOp=n.stencilLoadOp,a.depthStencilAttachment.stencilStoreOp=n.stencilStoreOp,a.depthStencilAttachment.stencilClearValue=n.stencilClearValue)}else a.depthStencilAttachment={...n};t.layerDescriptors.push(a)}}_updateDepthLayerDescriptors(e,t,s){for(let r=0;r<s.length;r++){const n=t.layerDescriptors[r];if(n.depthStencilAttachment){const i=n.depthStencilAttachment;e.depth&&(e.clearDepth?(i.depthClearValue=e.clearDepthValue,i.depthLoadOp=Q.Clear):i.depthLoadOp=Q.Load),e.stencil&&(e.clearStencil?(i.stencilClearValue=e.clearStencilValue,i.stencilLoadOp=Q.Clear):i.stencilLoadOp=Q.Load)}}}finishRender(e){const t=this.get(e),s=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),s>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){const n=[];for(let i=0;i<t.bundleEncoders.length;i++){const u=t.bundleEncoders[i];n.push(u.finish())}for(let i=0;i<t.layerDescriptors.length;i++)if(i<n.length){const u=t.layerDescriptors[i],a=r.beginRenderPass(u);if(e.viewport){const{x:c,y:d,width:h,height:p,minDepth:f,maxDepth:g}=e.viewportValue;a.setViewport(c,d,h,p,f,g)}if(e.scissor){const{x:c,y:d,width:h,height:p}=e.scissorValue;a.setScissorRect(c,d,h,p)}a.executeBundles([n[i]]),a.end()}}else t.currentPass&&t.currentPass.end();if(s>0){const n=s*8;let i=this.occludedResolveCache.get(n);i===void 0&&(i=this.device.createBuffer({size:n,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(n,i));const u=this.device.createBuffer({size:n,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,s,i,0),t.encoder.copyBufferToBuffer(i,0,u,0,n),t.occlusionQueryBuffer=u,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){const n=e.textures;for(let i=0;i<n.length;i++){const u=n[i];u.generateMipmaps===!0&&this.textureUtils.generateMipmaps(u)}}}isOccluded(e,t){const s=this.get(e);return s.occluded&&s.occluded.has(t)}async resolveOccludedAsync(e){const t=this.get(e),{currentOcclusionQueryBuffer:s,currentOcclusionQueryObjects:r}=t;if(s&&r){const n=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await s.mapAsync(GPUMapMode.READ);const i=s.getMappedRange(),u=new BigUint64Array(i);for(let a=0;a<r.length;a++)u[a]===BigInt(0)&&n.add(r[a]);s.destroy(),t.occluded=n}}updateViewport(e){const{currentPass:t}=this.get(e),{x:s,y:r,width:n,height:i,minDepth:u,maxDepth:a}=e.viewportValue;t.setViewport(s,r,n,i,u,a)}getClearColor(){const e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,s,r=null){const n=this.device,i=this.renderer;let u=[],a,c,d,h;if(e){const g=this.getClearColor();c={r:g.r,g:g.g,b:g.b,a:g.a}}if(r===null){d=i.depth,h=i.stencil;const g=this._getDefaultRenderPassDescriptor();if(e){u=g.colorAttachments;const m=u[0];m.clearValue=c,m.loadOp=Q.Clear,m.storeOp=xe.Store}(d||h)&&(a=g.depthStencilAttachment)}else{d=r.depth,h=r.stencil;const g={loadOp:e?Q.Clear:Q.Load,clearValue:e?c:void 0};d&&(g.depthLoadOp=t?Q.Clear:Q.Load,g.depthClearValue=t?i.getClearDepth():void 0,g.depthStoreOp=xe.Store),h&&(g.stencilLoadOp=s?Q.Clear:Q.Load,g.stencilClearValue=s?i.getClearStencil():void 0,g.stencilStoreOp=xe.Store);const m=this._getRenderPassDescriptor(r,g);u=m.colorAttachments,a=m.depthStencilAttachment}d&&a&&a.depthLoadOp===void 0&&(t?(a.depthLoadOp=Q.Clear,a.depthClearValue=i.getClearDepth(),a.depthStoreOp=xe.Store):(a.depthLoadOp=Q.Load,a.depthStoreOp=xe.Store)),h&&a&&a.stencilLoadOp===void 0&&(s?(a.stencilLoadOp=Q.Clear,a.stencilClearValue=i.getClearStencil(),a.stencilStoreOp=xe.Store):(a.stencilLoadOp=Q.Load,a.stencilStoreOp=xe.Store));const p=n.createCommandEncoder({label:"clear"});p.beginRenderPass({colorAttachments:u,depthStencilAttachment:a}).end(),n.queue.submit([p.finish()])}beginCompute(e){const t=this.get(e),s={label:"computeGroup_"+e.id};this.initTimestampQuery(e,s),t.cmdEncoderGPU=this.device.createCommandEncoder({label:"computeGroup_"+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(s)}compute(e,t,s,r){const{passEncoderGPU:n}=this.get(e),i=this.get(r).pipeline;this.pipelineUtils.setPipeline(n,i);for(let d=0,h=s.length;d<h;d++){const p=s[d],f=this.get(p);n.setBindGroup(d,f.group)}const u=this.device.limits.maxComputeWorkgroupsPerDimension,a=this.get(t);a.dispatchSize===void 0&&(a.dispatchSize={x:0,y:1,z:1});const{dispatchSize:c}=a;t.dispatchCount>u?(c.x=Math.min(t.dispatchCount,u),c.y=Math.ceil(t.dispatchCount/u)):c.x=t.dispatchCount,n.dispatchWorkgroups(c.x,c.y,c.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:s,material:r,context:n,pipeline:i}=e,u=e.getBindings(),a=this.get(n),c=this.get(i).pipeline,d=e.getIndex(),h=d!==null,p=e.getDrawParameters();if(p===null)return;const f=(m,y)=>{this.pipelineUtils.setPipeline(m,c),y.pipeline=c;const _=y.bindingGroups;for(let R=0,U=u.length;R<U;R++){const M=u[R],D=this.get(M);_[M.index]!==M.id&&(m.setBindGroup(M.index,D.group),_[M.index]=M.id)}if(h===!0&&y.index!==d){const R=this.get(d).buffer,U=d.array instanceof Uint16Array?jt.Uint16:jt.Uint32;m.setIndexBuffer(R,U),y.index=d}const C=e.getVertexBuffers();for(let R=0,U=C.length;R<U;R++){const M=C[R];if(y.attributes[R]!==M){const D=this.get(M).buffer;m.setVertexBuffer(R,D),y.attributes[R]=M}}n.stencil===!0&&r.stencilWrite===!0&&a.currentStencilRef!==r.stencilRef&&(m.setStencilReference(r.stencilRef),a.currentStencilRef=r.stencilRef)},g=(m,y)=>{if(f(m,y),s.isBatchedMesh===!0){const _=s._multiDrawStarts,C=s._multiDrawCounts,R=s._multiDrawCount,U=s._multiDrawInstances;U!==null&&l.warnOnce("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let M=0;M<R;M++){const D=U?U[M]:1,F=D>1?0:M;h===!0?m.drawIndexed(C[M],D,_[M]/d.array.BYTES_PER_ELEMENT,0,F):m.draw(C[M],D,_[M],F),t.update(s,C[M],D)}}else if(h===!0){const{vertexCount:_,instanceCount:C,firstVertex:R}=p,U=e.getIndirect();if(U!==null){const M=this.get(U).buffer;m.drawIndexedIndirect(M,0)}else m.drawIndexed(_,C,R,0,0);t.update(s,_,C)}else{const{vertexCount:_,instanceCount:C,firstVertex:R}=p,U=e.getIndirect();if(U!==null){const M=this.get(U).buffer;m.drawIndirect(M,0)}else m.draw(_,C,R,0);t.update(s,_,C)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){const m=this.get(e.camera),y=e.camera.cameras,_=e.getBindingGroup("cameraIndex");if(m.indexesGPU===void 0||m.indexesGPU.length!==y.length){const R=this.get(_),U=[],M=new Uint32Array([0,0,0,0]);for(let D=0,F=y.length;D<F;D++){M[0]=D;const L=this.bindingUtils.createBindGroupIndex(M,R.layout);U.push(L)}m.indexesGPU=U}const C=this.renderer.getPixelRatio();for(let R=0,U=y.length;R<U;R++){const M=y[R];if(s.layers.test(M.layers)){const D=M.viewport;let F=a.currentPass,L=a.currentSets;if(a.bundleEncoders){const G=a.bundleEncoders[R],H=a.bundleSets[R];F=G,L=H}D&&F.setViewport(Math.floor(D.x*C),Math.floor(D.y*C),Math.floor(D.width*C),Math.floor(D.height*C),n.viewportValue.minDepth,n.viewportValue.maxDepth),_&&m.indexesGPU&&(F.setBindGroup(_.index,m.indexesGPU[R]),L.bindingGroups[_.index]=_.id),g(F,L)}}}else if(a.currentPass){if(a.occlusionQuerySet!==void 0){const m=a.lastOcclusionObject;m!==s&&(m!==null&&m.occlusionTest===!0&&(a.currentPass.endOcclusionQuery(),a.occlusionQueryIndex++),s.occlusionTest===!0&&(a.currentPass.beginOcclusionQuery(a.occlusionQueryIndex),a.occlusionQueryObjects[a.occlusionQueryIndex]=s),a.lastOcclusionObject=s)}g(a.currentPass,a.currentSets)}}needsRenderUpdate(e){const t=this.get(e),{object:s,material:r}=e,n=this.utils,i=n.getSampleCountRenderContext(e.context),u=n.getCurrentColorSpace(e.context),a=n.getCurrentColorFormat(e.context),c=n.getCurrentDepthStencilFormat(e.context),d=n.getPrimitiveTopology(s,r);let h=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==i||t.colorSpace!==u||t.colorFormat!==a||t.depthStencilFormat!==c||t.primitiveTopology!==d||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=i,t.colorSpace=u,t.colorFormat=a,t.depthStencilFormat=c,t.primitiveTopology=d,t.clippingContextCacheKey=e.clippingContextCacheKey,h=!0),h}getRenderCacheKey(e){const{object:t,material:s}=e,r=this.utils,n=e.context;return[s.transparent,s.blending,s.premultipliedAlpha,s.blendSrc,s.blendDst,s.blendEquation,s.blendSrcAlpha,s.blendDstAlpha,s.blendEquationAlpha,s.colorWrite,s.depthWrite,s.depthTest,s.depthFunc,s.stencilWrite,s.stencilFunc,s.stencilFail,s.stencilZFail,s.stencilZPass,s.stencilFuncMask,s.stencilWriteMask,s.side,r.getSampleCountRenderContext(n),r.getCurrentColorSpace(n),r.getCurrentColorFormat(n),r.getCurrentDepthStencilFormat(n),r.getPrimitiveTopology(t,s),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}async copyTextureToBuffer(e,t,s,r,n,i){return this.textureUtils.copyTextureToBuffer(e,t,s,r,n,i)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;const s=e.isComputeNode?"compute":"render";this.timestampQueryPool[s]||(this.timestampQueryPool[s]=new $T(this.device,s,2048));const r=this.timestampQueryPool[s],n=r.allocateQueriesForContext(e);t.timestampWrites={querySet:r.querySet,beginningOfPassWriteIndex:n,endOfPassWriteIndex:n+1}}createNodeBuilder(e,t){return new UT(e,t)}createProgram(e){const t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name!==""?`_${e.name}`:"")}),entryPoint:"main"}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){const t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){const s=this.get(e),n=s.currentPass.finish();this.get(t).bundleGPU=n,s.currentSets=s._currentSets,s.currentPass=s._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,s,r){this.bindingUtils.createBindings(e,t,s,r)}updateBindings(e,t,s,r){this.bindingUtils.createBindings(e,t,s,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){let t=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST;(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t|=GPUBufferUsage.STORAGE),this.attributeUtils.createAttribute(e,t)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,s=null,r=null,n=0,i=0){let u=0,a=0,c=0,d=0,h=0,p=0,f=e.image.width,g=e.image.height,m=1;s!==null&&(s.isBox3===!0?(d=s.min.x,h=s.min.y,p=s.min.z,f=s.max.x-s.min.x,g=s.max.y-s.min.y,m=s.max.z-s.min.z):(d=s.min.x,h=s.min.y,f=s.max.x-s.min.x,g=s.max.y-s.min.y,m=1)),r!==null&&(u=r.x,a=r.y,c=r.z||0);const y=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),_=this.get(e).texture,C=this.get(t).texture;y.copyTextureToTexture({texture:_,mipLevel:n,origin:{x:d,y:h,z:p}},{texture:C,mipLevel:i,origin:{x:u,y:a,z:c}},[f,g,m]),this.device.queue.submit([y.finish()]),i===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,s){const r=this.get(t);let n=null;t.renderTarget?e.isDepthTexture?n=this.get(t.depthTexture).texture:n=this.get(t.textures[0]).texture:e.isDepthTexture?n=this.textureUtils.getDepthBuffer(t.depth,t.stencil):n=this.context.getCurrentTexture();const i=this.get(e).texture;if(n.format!==i.format){console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",n.format,i.format);return}let u;if(r.currentPass?(r.currentPass.end(),u=r.encoder):u=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),u.copyTextureToTexture({texture:n,origin:[s.x,s.y,0]},{texture:i},[s.z,s.w]),r.currentPass){const{descriptor:a}=r;for(let c=0;c<a.colorAttachments.length;c++)a.colorAttachments[c].loadOp=Q.Load;if(t.depth&&(a.depthStencilAttachment.depthLoadOp=Q.Load),t.stencil&&(a.depthStencilAttachment.stencilLoadOp=Q.Load),r.currentPass=u.beginRenderPass(a),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor){const{x:c,y:d,width:h,height:p}=t.scissorValue;r.currentPass.setScissorRect(c,d,h,p)}}else this.device.queue.submit([u.finish()]);e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}}class Kl extends l.SpotLight{constructor(e,t,s,r,n,i){super(e,t,s,r,n,i),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class Ql extends l.SpotLight{constructor(e,t,s,r,n,i){super(e,t,s,r,n,i),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}}class HT extends Ul{constructor(){super(),this.addMaterial(Wu,"MeshPhongMaterial"),this.addMaterial(fi,"MeshStandardMaterial"),this.addMaterial(tl,"MeshPhysicalMaterial"),this.addMaterial(sl,"MeshToonMaterial"),this.addMaterial(zu,"MeshBasicMaterial"),this.addMaterial($u,"MeshLambertMaterial"),this.addMaterial(Uu,"MeshNormalMaterial"),this.addMaterial(rl,"MeshMatcapMaterial"),this.addMaterial(Du,"LineBasicMaterial"),this.addMaterial(Lu,"LineDashedMaterial"),this.addMaterial(ol,"PointsMaterial"),this.addMaterial(gi,"SpriteMaterial"),this.addMaterial(al,"ShadowMaterial"),this.addLight(bl,l.PointLight),this.addLight(vl,l.DirectionalLight),this.addLight(El,l.RectAreaLight),this.addLight(vr,l.SpotLight),this.addLight(Fl,l.AmbientLight),this.addLight(wl,l.HemisphereLight),this.addLight(Pl,l.LightProbe),this.addLight(Bl,Kl),this.addLight(Ml,Ql),this.addToneMapping(_g,l.LinearToneMapping),this.addToneMapping(Sg,l.ReinhardToneMapping),this.addToneMapping(Ng,l.CineonToneMapping),this.addToneMapping(Rg,l.ACESFilmicToneMapping),this.addToneMapping(Eg,l.AgXToneMapping),this.addToneMapping(Bg,l.NeutralToneMapping)}}class qT extends Ym{constructor(e={}){let t;e.forceWebGL?t=Wo:(t=WT,e.getFallback=()=>(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new Wo(e)));const s=new t(e);super(s,e),this.library=new HT,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}exports.ACESFilmicToneMapping=l.ACESFilmicToneMapping;exports.AddEquation=l.AddEquation;exports.AddOperation=l.AddOperation;exports.AdditiveBlending=l.AdditiveBlending;exports.AgXToneMapping=l.AgXToneMapping;exports.AlphaFormat=l.AlphaFormat;exports.AlwaysCompare=l.AlwaysCompare;exports.AlwaysDepth=l.AlwaysDepth;exports.AlwaysStencilFunc=l.AlwaysStencilFunc;exports.AmbientLight=l.AmbientLight;exports.ArcCurve=l.ArcCurve;exports.ArrayCamera=l.ArrayCamera;exports.BackSide=l.BackSide;exports.BasicDepthPacking=l.BasicDepthPacking;exports.BasicShadowMap=l.BasicShadowMap;exports.Box3=l.Box3;exports.BoxGeometry=l.BoxGeometry;exports.BufferAttribute=l.BufferAttribute;exports.BufferGeometry=l.BufferGeometry;exports.ByteType=l.ByteType;exports.Cache=l.Cache;exports.Camera=l.Camera;exports.CatmullRomCurve3=l.CatmullRomCurve3;exports.CineonToneMapping=l.CineonToneMapping;exports.ClampToEdgeWrapping=l.ClampToEdgeWrapping;exports.Clock=l.Clock;exports.Color=l.Color;exports.ColorManagement=l.ColorManagement;exports.ConeGeometry=l.ConeGeometry;exports.ConstantAlphaFactor=l.ConstantAlphaFactor;exports.ConstantColorFactor=l.ConstantColorFactor;exports.Controls=l.Controls;exports.CubeCamera=l.CubeCamera;exports.CubeReflectionMapping=l.CubeReflectionMapping;exports.CubeRefractionMapping=l.CubeRefractionMapping;exports.CubeTexture=l.CubeTexture;exports.CubeUVReflectionMapping=l.CubeUVReflectionMapping;exports.CubicBezierCurve=l.CubicBezierCurve;exports.CubicBezierCurve3=l.CubicBezierCurve3;exports.CullFaceBack=l.CullFaceBack;exports.CullFaceFront=l.CullFaceFront;exports.CullFaceNone=l.CullFaceNone;exports.Curve=l.Curve;exports.CustomBlending=l.CustomBlending;exports.CustomToneMapping=l.CustomToneMapping;exports.CylinderGeometry=l.CylinderGeometry;exports.Data3DTexture=l.Data3DTexture;exports.DataArrayTexture=l.DataArrayTexture;exports.DataTexture=l.DataTexture;exports.DecrementStencilOp=l.DecrementStencilOp;exports.DecrementWrapStencilOp=l.DecrementWrapStencilOp;exports.DefaultLoadingManager=l.DefaultLoadingManager;exports.DepthFormat=l.DepthFormat;exports.DepthStencilFormat=l.DepthStencilFormat;exports.DepthTexture=l.DepthTexture;exports.DirectionalLight=l.DirectionalLight;exports.DoubleSide=l.DoubleSide;exports.DstAlphaFactor=l.DstAlphaFactor;exports.DstColorFactor=l.DstColorFactor;exports.DynamicDrawUsage=l.DynamicDrawUsage;exports.EllipseCurve=l.EllipseCurve;exports.EqualCompare=l.EqualCompare;exports.EqualDepth=l.EqualDepth;exports.EqualStencilFunc=l.EqualStencilFunc;exports.EquirectangularReflectionMapping=l.EquirectangularReflectionMapping;exports.EquirectangularRefractionMapping=l.EquirectangularRefractionMapping;exports.Euler=l.Euler;exports.EventDispatcher=l.EventDispatcher;exports.Float16BufferAttribute=l.Float16BufferAttribute;exports.Float32BufferAttribute=l.Float32BufferAttribute;exports.FloatType=l.FloatType;exports.FramebufferTexture=l.FramebufferTexture;exports.FrontSide=l.FrontSide;exports.Frustum=l.Frustum;exports.FrustumArray=l.FrustumArray;exports.GLSL3=l.GLSL3;exports.GreaterCompare=l.GreaterCompare;exports.GreaterDepth=l.GreaterDepth;exports.GreaterEqualCompare=l.GreaterEqualCompare;exports.GreaterEqualDepth=l.GreaterEqualDepth;exports.GreaterEqualStencilFunc=l.GreaterEqualStencilFunc;exports.GreaterStencilFunc=l.GreaterStencilFunc;exports.Group=l.Group;exports.HalfFloatType=l.HalfFloatType;exports.HemisphereLight=l.HemisphereLight;exports.ImageLoader=l.ImageLoader;exports.ImageUtils=l.ImageUtils;exports.IncrementStencilOp=l.IncrementStencilOp;exports.IncrementWrapStencilOp=l.IncrementWrapStencilOp;exports.InstancedBufferAttribute=l.InstancedBufferAttribute;exports.InstancedInterleavedBuffer=l.InstancedInterleavedBuffer;exports.IntType=l.IntType;exports.InterleavedBuffer=l.InterleavedBuffer;exports.InterleavedBufferAttribute=l.InterleavedBufferAttribute;exports.InvertStencilOp=l.InvertStencilOp;exports.KeepStencilOp=l.KeepStencilOp;exports.Layers=l.Layers;exports.LessCompare=l.LessCompare;exports.LessDepth=l.LessDepth;exports.LessEqualCompare=l.LessEqualCompare;exports.LessEqualDepth=l.LessEqualDepth;exports.LessEqualStencilFunc=l.LessEqualStencilFunc;exports.LessStencilFunc=l.LessStencilFunc;exports.Light=l.Light;exports.LightProbe=l.LightProbe;exports.Line=l.Line;exports.LineBasicMaterial=l.LineBasicMaterial;exports.LineCurve=l.LineCurve;exports.LineCurve3=l.LineCurve3;exports.LineDashedMaterial=l.LineDashedMaterial;exports.LinearFilter=l.LinearFilter;exports.LinearMipmapLinearFilter=l.LinearMipmapLinearFilter;exports.LinearMipmapNearestFilter=l.LinearMipmapNearestFilter;exports.LinearSRGBColorSpace=l.LinearSRGBColorSpace;exports.LinearToneMapping=l.LinearToneMapping;exports.LinearTransfer=l.LinearTransfer;exports.Loader=l.Loader;exports.LoadingManager=l.LoadingManager;exports.MOUSE=l.MOUSE;exports.Material=l.Material;exports.MathUtils=l.MathUtils;exports.Matrix2=l.Matrix2;exports.Matrix3=l.Matrix3;exports.Matrix4=l.Matrix4;exports.MaxEquation=l.MaxEquation;exports.Mesh=l.Mesh;exports.MeshBasicMaterial=l.MeshBasicMaterial;exports.MeshDepthMaterial=l.MeshDepthMaterial;exports.MeshDistanceMaterial=l.MeshDistanceMaterial;exports.MeshLambertMaterial=l.MeshLambertMaterial;exports.MeshMatcapMaterial=l.MeshMatcapMaterial;exports.MeshNormalMaterial=l.MeshNormalMaterial;exports.MeshPhongMaterial=l.MeshPhongMaterial;exports.MeshPhysicalMaterial=l.MeshPhysicalMaterial;exports.MeshStandardMaterial=l.MeshStandardMaterial;exports.MeshToonMaterial=l.MeshToonMaterial;exports.MinEquation=l.MinEquation;exports.MirroredRepeatWrapping=l.MirroredRepeatWrapping;exports.MixOperation=l.MixOperation;exports.MultiplyBlending=l.MultiplyBlending;exports.MultiplyOperation=l.MultiplyOperation;exports.NearestFilter=l.NearestFilter;exports.NearestMipmapLinearFilter=l.NearestMipmapLinearFilter;exports.NearestMipmapNearestFilter=l.NearestMipmapNearestFilter;exports.NeutralToneMapping=l.NeutralToneMapping;exports.NeverCompare=l.NeverCompare;exports.NeverDepth=l.NeverDepth;exports.NeverStencilFunc=l.NeverStencilFunc;exports.NoBlending=l.NoBlending;exports.NoColorSpace=l.NoColorSpace;exports.NoToneMapping=l.NoToneMapping;exports.NormalBlending=l.NormalBlending;exports.NotEqualCompare=l.NotEqualCompare;exports.NotEqualDepth=l.NotEqualDepth;exports.NotEqualStencilFunc=l.NotEqualStencilFunc;exports.Object3D=l.Object3D;exports.ObjectSpaceNormalMap=l.ObjectSpaceNormalMap;exports.OneFactor=l.OneFactor;exports.OneMinusConstantAlphaFactor=l.OneMinusConstantAlphaFactor;exports.OneMinusConstantColorFactor=l.OneMinusConstantColorFactor;exports.OneMinusDstAlphaFactor=l.OneMinusDstAlphaFactor;exports.OneMinusDstColorFactor=l.OneMinusDstColorFactor;exports.OneMinusSrcAlphaFactor=l.OneMinusSrcAlphaFactor;exports.OneMinusSrcColorFactor=l.OneMinusSrcColorFactor;exports.OrthographicCamera=l.OrthographicCamera;exports.PCFShadowMap=l.PCFShadowMap;exports.PCFSoftShadowMap=l.PCFSoftShadowMap;exports.PerspectiveCamera=l.PerspectiveCamera;exports.Plane=l.Plane;exports.PlaneGeometry=l.PlaneGeometry;exports.PointLight=l.PointLight;exports.PointsMaterial=l.PointsMaterial;exports.QuadraticBezierCurve=l.QuadraticBezierCurve;exports.QuadraticBezierCurve3=l.QuadraticBezierCurve3;exports.Quaternion=l.Quaternion;exports.RED_GREEN_RGTC2_Format=l.RED_GREEN_RGTC2_Format;exports.RED_RGTC1_Format=l.RED_RGTC1_Format;exports.REVISION=l.REVISION;exports.RGBADepthPacking=l.RGBADepthPacking;exports.RGBAFormat=l.RGBAFormat;exports.RGBAIntegerFormat=l.RGBAIntegerFormat;exports.RGBA_ASTC_10x10_Format=l.RGBA_ASTC_10x10_Format;exports.RGBA_ASTC_10x5_Format=l.RGBA_ASTC_10x5_Format;exports.RGBA_ASTC_10x6_Format=l.RGBA_ASTC_10x6_Format;exports.RGBA_ASTC_10x8_Format=l.RGBA_ASTC_10x8_Format;exports.RGBA_ASTC_12x10_Format=l.RGBA_ASTC_12x10_Format;exports.RGBA_ASTC_12x12_Format=l.RGBA_ASTC_12x12_Format;exports.RGBA_ASTC_4x4_Format=l.RGBA_ASTC_4x4_Format;exports.RGBA_ASTC_5x4_Format=l.RGBA_ASTC_5x4_Format;exports.RGBA_ASTC_5x5_Format=l.RGBA_ASTC_5x5_Format;exports.RGBA_ASTC_6x5_Format=l.RGBA_ASTC_6x5_Format;exports.RGBA_ASTC_6x6_Format=l.RGBA_ASTC_6x6_Format;exports.RGBA_ASTC_8x5_Format=l.RGBA_ASTC_8x5_Format;exports.RGBA_ASTC_8x6_Format=l.RGBA_ASTC_8x6_Format;exports.RGBA_ASTC_8x8_Format=l.RGBA_ASTC_8x8_Format;exports.RGBA_BPTC_Format=l.RGBA_BPTC_Format;exports.RGBA_ETC2_EAC_Format=l.RGBA_ETC2_EAC_Format;exports.RGBA_PVRTC_2BPPV1_Format=l.RGBA_PVRTC_2BPPV1_Format;exports.RGBA_PVRTC_4BPPV1_Format=l.RGBA_PVRTC_4BPPV1_Format;exports.RGBA_S3TC_DXT1_Format=l.RGBA_S3TC_DXT1_Format;exports.RGBA_S3TC_DXT3_Format=l.RGBA_S3TC_DXT3_Format;exports.RGBA_S3TC_DXT5_Format=l.RGBA_S3TC_DXT5_Format;exports.RGBFormat=l.RGBFormat;exports.RGBIntegerFormat=l.RGBIntegerFormat;exports.RGB_BPTC_SIGNED_Format=l.RGB_BPTC_SIGNED_Format;exports.RGB_BPTC_UNSIGNED_Format=l.RGB_BPTC_UNSIGNED_Format;exports.RGB_ETC1_Format=l.RGB_ETC1_Format;exports.RGB_ETC2_Format=l.RGB_ETC2_Format;exports.RGB_PVRTC_2BPPV1_Format=l.RGB_PVRTC_2BPPV1_Format;exports.RGB_PVRTC_4BPPV1_Format=l.RGB_PVRTC_4BPPV1_Format;exports.RGB_S3TC_DXT1_Format=l.RGB_S3TC_DXT1_Format;exports.RGFormat=l.RGFormat;exports.RGIntegerFormat=l.RGIntegerFormat;exports.Ray=l.Ray;exports.Raycaster=l.Raycaster;exports.RectAreaLight=l.RectAreaLight;exports.RedFormat=l.RedFormat;exports.RedIntegerFormat=l.RedIntegerFormat;exports.ReinhardToneMapping=l.ReinhardToneMapping;exports.RenderTarget=l.RenderTarget;exports.RepeatWrapping=l.RepeatWrapping;exports.ReplaceStencilOp=l.ReplaceStencilOp;exports.ReverseSubtractEquation=l.ReverseSubtractEquation;exports.SIGNED_RED_GREEN_RGTC2_Format=l.SIGNED_RED_GREEN_RGTC2_Format;exports.SIGNED_RED_RGTC1_Format=l.SIGNED_RED_RGTC1_Format;exports.SRGBColorSpace=l.SRGBColorSpace;exports.SRGBTransfer=l.SRGBTransfer;exports.Scene=l.Scene;exports.ShaderMaterial=l.ShaderMaterial;exports.ShadowMaterial=l.ShadowMaterial;exports.ShortType=l.ShortType;exports.Source=l.Source;exports.Sphere=l.Sphere;exports.SphereGeometry=l.SphereGeometry;exports.Spherical=l.Spherical;exports.SphericalHarmonics3=l.SphericalHarmonics3;exports.SplineCurve=l.SplineCurve;exports.SpotLight=l.SpotLight;exports.SpriteMaterial=l.SpriteMaterial;exports.SrcAlphaFactor=l.SrcAlphaFactor;exports.SrcAlphaSaturateFactor=l.SrcAlphaSaturateFactor;exports.SrcColorFactor=l.SrcColorFactor;exports.StaticDrawUsage=l.StaticDrawUsage;exports.SubtractEquation=l.SubtractEquation;exports.SubtractiveBlending=l.SubtractiveBlending;exports.TOUCH=l.TOUCH;exports.TangentSpaceNormalMap=l.TangentSpaceNormalMap;exports.Texture=l.Texture;exports.TextureLoader=l.TextureLoader;exports.Triangle=l.Triangle;exports.TubeGeometry=l.TubeGeometry;exports.UVMapping=l.UVMapping;exports.Uint16BufferAttribute=l.Uint16BufferAttribute;exports.Uint32BufferAttribute=l.Uint32BufferAttribute;exports.UnsignedByteType=l.UnsignedByteType;exports.UnsignedInt248Type=l.UnsignedInt248Type;exports.UnsignedInt5999Type=l.UnsignedInt5999Type;exports.UnsignedIntType=l.UnsignedIntType;exports.UnsignedShort4444Type=l.UnsignedShort4444Type;exports.UnsignedShort5551Type=l.UnsignedShort5551Type;exports.UnsignedShortType=l.UnsignedShortType;exports.VSMShadowMap=l.VSMShadowMap;exports.Vector2=l.Vector2;exports.Vector3=l.Vector3;exports.Vector4=l.Vector4;exports.WebGLCoordinateSystem=l.WebGLCoordinateSystem;exports.WebGLCubeRenderTarget=l.WebGLCubeRenderTarget;exports.WebGLRenderTarget=l.WebGLRenderTarget;exports.WebGPUCoordinateSystem=l.WebGPUCoordinateSystem;exports.WebXRController=l.WebXRController;exports.ZeroFactor=l.ZeroFactor;exports.ZeroStencilOp=l.ZeroStencilOp;exports.createCanvasElement=l.createCanvasElement;exports.AONode=Ru;exports.AmbientLightNode=Fl;exports.AnalyticLightNode=ft;exports.ArrayElementNode=Zt;exports.ArrayNode=Sn;exports.AssignNode=ya;exports.AttributeNode=ni;exports.BasicEnvironmentNode=Nr;exports.BatchNode=_u;exports.BufferAttributeNode=Ia;exports.BufferNode=ii;exports.BumpMapNode=fu;exports.BypassNode=ka;exports.CacheNode=Va;exports.CodeNode=de;exports.ColorSpaceNode=ei;exports.ComputeNode=Oa;exports.ConstNode=Ke;exports.ContextNode=Yn;exports.ConvertNode=Ln;exports.CubeTextureNode=su;exports.DebugNode=$a;exports.DirectionalLightNode=vl;exports.EnvironmentNode=el;exports.ExpressionNode=Ns;exports.FrontFacingNode=ja;exports.FunctionCallNode=xa;exports.FunctionNode=fl;exports.GLSLNodeParser=Ll;exports.HemisphereLightNode=wl;exports.IESSpotLight=Kl;exports.IESSpotLightNode=Bl;exports.IndexNode=re;exports.InstanceNode=yu;exports.InstancedMeshNode=xu;exports.IrradianceNode=Cu;exports.JoinNode=ra;exports.LightProbeNode=Pl;exports.Lighting=Gl;exports.LightingContextNode=Au;exports.LightingModel=Ls;exports.LightingNode=Ft;exports.LightsNode=Ti;exports.LineBasicNodeMaterial=Du;exports.LineDashedNodeMaterial=Lu;exports.LoopNode=Nu;exports.MaterialNode=S;exports.MaterialReferenceNode=ru;exports.MaxMipLevelNode=Ha;exports.MemberNode=ia;exports.MeshBasicNodeMaterial=zu;exports.MeshLambertNodeMaterial=$u;exports.MeshMatcapNodeMaterial=rl;exports.MeshNormalNodeMaterial=Uu;exports.MeshPhongNodeMaterial=Wu;exports.MeshPhysicalNodeMaterial=tl;exports.MeshStandardNodeMaterial=fi;exports.MeshToonNodeMaterial=sl;exports.ModelNode=Me;exports.MorphNode=bu;exports.Node=V;exports.NodeAccess=He;exports.NodeAttribute=Mn;exports.NodeBuilder=_i;exports.NodeCache=sr;exports.NodeCode=Cl;exports.NodeFrame=Fn;exports.NodeFunctionInput=Cr;exports.NodeMaterial=ce;exports.NodeMaterialObserver=Zo;exports.NodeShaderStage=fs;exports.NodeUniform=Rl;exports.NodeUpdateType=z;exports.NodeVar=xi;exports.NodeVarying=Al;exports.NormalMapNode=pu;exports.Object3DNode=j;exports.PMREMGenerator=ju;exports.PMREMNode=Zu;exports.ParameterNode=dl;exports.PassNode=Us;exports.PhongLightingModel=ci;exports.PhysicalLightingModel=di;exports.PointLightNode=bl;exports.PointsNodeMaterial=ol;exports.ProjectorLight=Ql;exports.ProjectorLightNode=Ml;exports.PropertyNode=Y;exports.QuadMesh=Rr;exports.RectAreaLightNode=El;exports.ReferenceNode=_r;exports.RemapNode=ri;exports.RenderOutputNode=za;exports.RendererReferenceNode=Ua;exports.RotateNode=nl;exports.SceneNode=be;exports.ScreenNode=ae;exports.SetNode=na;exports.ShadowBaseNode=_l;exports.ShadowNode=yi;exports.ShadowNodeMaterial=al;exports.SkinningNode=Su;exports.SplitNode=gn;exports.SpotLightNode=vr;exports.SpriteNodeMaterial=gi;exports.StackNode=hl;exports.SubBuildNode=Pa;exports.TempNode=fe;exports.Texture3DNode=pl;exports.TextureNode=Mt;exports.TextureSizeNode=Wa;exports.ToneMappingNode=Ga;exports.UniformArrayNode=Ka;exports.UniformGroupNode=Wn;exports.UniformNode=Jt;exports.VarNode=_s;exports.VaryingNode=Da;exports.VertexColorNode=Pu;exports.ViewportDepthNode=Ne;exports.ViewportDepthTextureNode=Eu;exports.ViewportTextureNode=li;exports.WebGPURenderer=qT;exports.defaultBuildStages=pn;exports.defaultShaderStages=sa;exports.shaderStages=fn;exports.vectorComponents=Bt;