@xiping/react-components 1.0.18 → 1.0.20

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 (511) hide show
  1. package/dist/cjs/_virtual/_commonjsHelpers.js +1 -0
  2. package/dist/cjs/_virtual/alignment-pattern.js +1 -0
  3. package/dist/cjs/_virtual/browser.js +1 -0
  4. package/dist/cjs/_virtual/browser2.js +1 -0
  5. package/dist/cjs/_virtual/canvas.js +1 -0
  6. package/dist/cjs/_virtual/dijkstra.js +1 -0
  7. package/dist/cjs/_virtual/error-correction-code.js +1 -0
  8. package/dist/cjs/_virtual/error-correction-level.js +1 -0
  9. package/dist/cjs/_virtual/finder-pattern.js +1 -0
  10. package/dist/cjs/_virtual/format-info.js +1 -0
  11. package/dist/cjs/_virtual/galois-field.js +1 -0
  12. package/dist/cjs/_virtual/generateBounds.js +1 -0
  13. package/dist/cjs/_virtual/generateCreateBody.js +1 -0
  14. package/dist/cjs/_virtual/generateCreateDragForce.js +1 -0
  15. package/dist/cjs/_virtual/generateCreateSpringForce.js +1 -0
  16. package/dist/cjs/_virtual/generateIntegrator.js +1 -0
  17. package/dist/cjs/_virtual/generateQuadTree.js +1 -0
  18. package/dist/cjs/_virtual/index.js +1 -0
  19. package/dist/cjs/_virtual/index2.js +1 -0
  20. package/dist/cjs/_virtual/index3.js +1 -0
  21. package/dist/cjs/_virtual/index4.js +1 -0
  22. package/dist/cjs/_virtual/index5.js +1 -0
  23. package/dist/cjs/_virtual/index6.js +1 -0
  24. package/dist/cjs/_virtual/index7.js +1 -0
  25. package/dist/cjs/_virtual/mask-pattern.js +1 -0
  26. package/dist/cjs/_virtual/mode.js +1 -0
  27. package/dist/cjs/_virtual/polynomial.js +1 -0
  28. package/dist/cjs/_virtual/qrcode.js +1 -0
  29. package/dist/cjs/_virtual/react-is.development.js +1 -0
  30. package/dist/cjs/_virtual/react-is.production.min.js +1 -0
  31. package/dist/cjs/_virtual/regex.js +1 -0
  32. package/dist/cjs/_virtual/segments.js +1 -0
  33. package/dist/cjs/_virtual/svg-tag.js +1 -0
  34. package/dist/cjs/_virtual/utils.js +1 -0
  35. package/dist/cjs/_virtual/utils2.js +1 -0
  36. package/dist/cjs/_virtual/version-check.js +1 -0
  37. package/dist/cjs/_virtual/version.js +1 -0
  38. package/dist/cjs/components/qr-code/index.js +1 -0
  39. package/dist/cjs/components/react-force-graph-3d/index.d.ts +1 -0
  40. package/dist/cjs/index.d.ts +2 -0
  41. package/dist/cjs/index.js +1 -1
  42. package/dist/cjs/node_modules/.pnpm/3d-force-graph@1.77.0/node_modules/3d-force-graph/dist/3d-force-graph.js +28 -0
  43. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js +1 -0
  44. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/construct.js +1 -0
  45. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/extends.js +1 -0
  46. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js +1 -0
  47. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +1 -0
  48. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/isNativeFunction.js +1 -0
  49. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js +1 -0
  50. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +1 -0
  51. package/dist/cjs/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js +1 -0
  52. package/dist/cjs/node_modules/.pnpm/@tweenjs_tween.js@23.1.3/node_modules/@tweenjs/tween.js/dist/tween.esm.js +1 -0
  53. package/dist/cjs/node_modules/.pnpm/accessor-fn@1.5.3/node_modules/accessor-fn/dist/accessor-fn.js +1 -0
  54. package/dist/cjs/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/ascending.js +1 -0
  55. package/dist/cjs/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/bisect.js +1 -0
  56. package/dist/cjs/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/bisector.js +1 -0
  57. package/dist/cjs/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/max.js +1 -0
  58. package/dist/cjs/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/min.js +1 -0
  59. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/add.js +1 -0
  60. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/binarytree.js +1 -0
  61. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/cover.js +1 -0
  62. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/data.js +1 -0
  63. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/extent.js +1 -0
  64. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/find.js +1 -0
  65. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/half.js +1 -0
  66. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/remove.js +1 -0
  67. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/root.js +1 -0
  68. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/size.js +1 -0
  69. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/visit.js +1 -0
  70. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/visitAfter.js +1 -0
  71. package/dist/cjs/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/x.js +1 -0
  72. package/dist/cjs/node_modules/.pnpm/d3-dispatch@3.0.1/node_modules/d3-dispatch/src/dispatch.js +1 -0
  73. package/dist/cjs/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/center.js +1 -0
  74. package/dist/cjs/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/constant.js +1 -0
  75. package/dist/cjs/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/jiggle.js +1 -0
  76. package/dist/cjs/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/lcg.js +1 -0
  77. package/dist/cjs/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/link.js +1 -0
  78. package/dist/cjs/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/manyBody.js +1 -0
  79. package/dist/cjs/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/radial.js +1 -0
  80. package/dist/cjs/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/simulation.js +1 -0
  81. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/add.js +1 -0
  82. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/cover.js +1 -0
  83. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/data.js +1 -0
  84. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/extent.js +1 -0
  85. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/find.js +1 -0
  86. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/findAll.js +1 -0
  87. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/octant.js +1 -0
  88. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/octree.js +1 -0
  89. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/remove.js +1 -0
  90. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/root.js +1 -0
  91. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/size.js +1 -0
  92. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/visit.js +1 -0
  93. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/visitAfter.js +1 -0
  94. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/x.js +1 -0
  95. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/y.js +1 -0
  96. package/dist/cjs/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/z.js +1 -0
  97. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/add.js +1 -0
  98. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/cover.js +1 -0
  99. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/data.js +1 -0
  100. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/extent.js +1 -0
  101. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/find.js +1 -0
  102. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/quad.js +1 -0
  103. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/quadtree.js +1 -0
  104. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/remove.js +1 -0
  105. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/root.js +1 -0
  106. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/size.js +1 -0
  107. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/visit.js +1 -0
  108. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/visitAfter.js +1 -0
  109. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/x.js +1 -0
  110. package/dist/cjs/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/y.js +1 -0
  111. package/dist/cjs/node_modules/.pnpm/d3-scale-chromatic@3.1.0/node_modules/d3-scale-chromatic/src/categorical/Paired.js +1 -0
  112. package/dist/cjs/node_modules/.pnpm/d3-scale-chromatic@3.1.0/node_modules/d3-scale-chromatic/src/colors.js +1 -0
  113. package/dist/cjs/node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/init.js +1 -0
  114. package/dist/cjs/node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/ordinal.js +1 -0
  115. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/array.js +1 -0
  116. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/constant.js +1 -0
  117. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/creator.js +1 -0
  118. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/matcher.js +1 -0
  119. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/namespace.js +1 -0
  120. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/namespaces.js +1 -0
  121. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/pointer.js +1 -0
  122. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/select.js +1 -0
  123. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/append.js +1 -0
  124. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/attr.js +1 -0
  125. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/call.js +1 -0
  126. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/classed.js +1 -0
  127. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/clone.js +1 -0
  128. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/data.js +1 -0
  129. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/datum.js +1 -0
  130. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/dispatch.js +1 -0
  131. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/each.js +1 -0
  132. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/empty.js +1 -0
  133. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/enter.js +1 -0
  134. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/exit.js +1 -0
  135. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/filter.js +1 -0
  136. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/html.js +1 -0
  137. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/index.js +1 -0
  138. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/insert.js +1 -0
  139. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/iterator.js +1 -0
  140. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/join.js +1 -0
  141. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/lower.js +1 -0
  142. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/merge.js +1 -0
  143. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/node.js +1 -0
  144. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/nodes.js +1 -0
  145. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/on.js +1 -0
  146. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/order.js +1 -0
  147. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/property.js +1 -0
  148. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/raise.js +1 -0
  149. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/remove.js +1 -0
  150. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/select.js +1 -0
  151. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/selectAll.js +1 -0
  152. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/selectChild.js +1 -0
  153. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/selectChildren.js +1 -0
  154. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/size.js +1 -0
  155. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/sort.js +1 -0
  156. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/sparse.js +1 -0
  157. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/style.js +1 -0
  158. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/text.js +1 -0
  159. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selector.js +1 -0
  160. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selectorAll.js +1 -0
  161. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/sourceEvent.js +1 -0
  162. package/dist/cjs/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/window.js +1 -0
  163. package/dist/cjs/node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/timer.js +1 -0
  164. package/dist/cjs/node_modules/.pnpm/data-bind-mapper@1.0.3/node_modules/data-bind-mapper/dist/data-bind-mapper.js +3 -0
  165. package/dist/cjs/node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js +1 -0
  166. package/dist/cjs/node_modules/.pnpm/float-tooltip@1.7.5/node_modules/float-tooltip/dist/float-tooltip.js +13 -0
  167. package/dist/cjs/node_modules/.pnpm/internmap@2.0.3/node_modules/internmap/src/index.js +1 -0
  168. package/dist/cjs/node_modules/.pnpm/jerrypick@1.1.2/node_modules/jerrypick/dist/jerrypick.js +3 -0
  169. package/dist/cjs/node_modules/.pnpm/kapsule@1.16.3/node_modules/kapsule/dist/kapsule.js +2 -0
  170. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.js +1 -0
  171. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.js +1 -0
  172. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseTrim.js +1 -0
  173. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js +1 -0
  174. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.js +1 -0
  175. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.js +1 -0
  176. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.js +1 -0
  177. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_trimmedEndIndex.js +1 -0
  178. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/debounce.js +1 -0
  179. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.js +1 -0
  180. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObjectLike.js +1 -0
  181. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isSymbol.js +1 -0
  182. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/now.js +1 -0
  183. package/dist/cjs/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/toNumber.js +1 -0
  184. package/dist/cjs/node_modules/.pnpm/ngraph.events@1.2.2/node_modules/ngraph.events/index.js +1 -0
  185. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/index.js +1 -0
  186. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/createPatternBuilder.js +2 -0
  187. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateBounds.js +55 -0
  188. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateCreateBody.js +47 -0
  189. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateCreateDragForce.js +9 -0
  190. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateCreateSpringForce.js +33 -0
  191. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateIntegrator.js +35 -0
  192. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateQuadTree.js +325 -0
  193. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/getVariableName.js +1 -0
  194. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/createPhysicsSimulator.js +1 -0
  195. package/dist/cjs/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/spring.js +1 -0
  196. package/dist/cjs/node_modules/.pnpm/ngraph.graph@20.0.1/node_modules/ngraph.graph/index.js +3 -0
  197. package/dist/cjs/node_modules/.pnpm/ngraph.merge@1.0.0/node_modules/ngraph.merge/index.js +1 -0
  198. package/dist/cjs/node_modules/.pnpm/ngraph.random@1.2.0/node_modules/ngraph.random/index.js +1 -0
  199. package/dist/cjs/node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js +5 -0
  200. package/dist/cjs/node_modules/.pnpm/polished@4.3.1/node_modules/polished/dist/polished.esm.js +149 -0
  201. package/dist/cjs/node_modules/.pnpm/preact@10.26.9/node_modules/preact/dist/preact.module.js +1 -0
  202. package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/checkPropTypes.js +1 -0
  203. package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithThrowingShims.js +1 -0
  204. package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithTypeCheckers.js +2 -0
  205. package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +1 -0
  206. package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js +1 -0
  207. package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/has.js +1 -0
  208. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js +1 -0
  209. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js +1 -0
  210. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js +1 -0
  211. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js +1 -0
  212. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js +1 -0
  213. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js +1 -0
  214. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js +1 -0
  215. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js +1 -0
  216. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js +1 -0
  217. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js +1 -0
  218. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js +1 -0
  219. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js +1 -0
  220. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js +2 -0
  221. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js +1 -0
  222. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js +1 -0
  223. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js +1 -0
  224. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js +1 -0
  225. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js +4 -0
  226. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js +1 -0
  227. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js +2 -0
  228. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js +2 -0
  229. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js +1 -0
  230. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js +1 -0
  231. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js +1 -0
  232. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js +1 -0
  233. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js +2 -0
  234. package/dist/cjs/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js +1 -0
  235. package/dist/cjs/node_modules/.pnpm/react-force-graph-3d@1.27.0_react@18.3.1/node_modules/react-force-graph-3d/dist/react-force-graph-3d.js +1 -0
  236. package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js +8 -0
  237. package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.production.min.js +8 -0
  238. package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js +1 -0
  239. package/dist/cjs/node_modules/.pnpm/react-kapsule@2.5.7_react@18.3.1/node_modules/react-kapsule/dist/react-kapsule.js +3 -0
  240. package/dist/cjs/node_modules/.pnpm/three-forcegraph@1.42.13_three@0.171.0/node_modules/three-forcegraph/dist/three-forcegraph.js +3 -0
  241. package/dist/cjs/node_modules/.pnpm/three-render-objects@1.40.2_three@0.171.0/node_modules/three-render-objects/dist/three-render-objects.js +18 -0
  242. package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/build/three.core.js +44 -0
  243. package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/build/three.module.js +3789 -0
  244. package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/build/three.webgpu.js +373 -0
  245. package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/controls/DragControls.js +1 -0
  246. package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/controls/FlyControls.js +1 -0
  247. package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -0
  248. package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/controls/TrackballControls.js +1 -0
  249. package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/postprocessing/EffectComposer.js +1 -0
  250. package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/postprocessing/MaskPass.js +1 -0
  251. package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/postprocessing/Pass.js +1 -0
  252. package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/postprocessing/RenderPass.js +1 -0
  253. package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/postprocessing/ShaderPass.js +1 -0
  254. package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/shaders/CopyShader.js +24 -0
  255. package/dist/cjs/node_modules/.pnpm/tinycolor2@1.6.0/node_modules/tinycolor2/esm/tinycolor.js +1 -0
  256. package/dist/es/_virtual/_commonjsHelpers.js +6 -0
  257. package/dist/es/_virtual/alignment-pattern.js +4 -0
  258. package/dist/es/_virtual/browser.js +7 -0
  259. package/dist/es/_virtual/browser2.js +4 -0
  260. package/dist/es/_virtual/canvas.js +4 -0
  261. package/dist/es/_virtual/dijkstra.js +4 -0
  262. package/dist/es/_virtual/error-correction-code.js +4 -0
  263. package/dist/es/_virtual/error-correction-level.js +4 -0
  264. package/dist/es/_virtual/finder-pattern.js +4 -0
  265. package/dist/es/_virtual/format-info.js +4 -0
  266. package/dist/es/_virtual/galois-field.js +4 -0
  267. package/dist/es/_virtual/generateBounds.js +4 -0
  268. package/dist/es/_virtual/generateCreateBody.js +4 -0
  269. package/dist/es/_virtual/generateCreateDragForce.js +4 -0
  270. package/dist/es/_virtual/generateCreateSpringForce.js +4 -0
  271. package/dist/es/_virtual/generateIntegrator.js +4 -0
  272. package/dist/es/_virtual/generateQuadTree.js +4 -0
  273. package/dist/es/_virtual/index.js +7 -0
  274. package/dist/es/_virtual/index2.js +4 -0
  275. package/dist/es/_virtual/index3.js +4 -0
  276. package/dist/es/_virtual/index4.js +7 -0
  277. package/dist/es/_virtual/index5.js +7 -0
  278. package/dist/es/_virtual/index6.js +4 -0
  279. package/dist/es/_virtual/index7.js +4 -0
  280. package/dist/es/_virtual/mask-pattern.js +4 -0
  281. package/dist/es/_virtual/mode.js +4 -0
  282. package/dist/es/_virtual/polynomial.js +4 -0
  283. package/dist/es/_virtual/qrcode.js +4 -0
  284. package/dist/es/_virtual/react-is.development.js +4 -0
  285. package/dist/es/_virtual/react-is.production.min.js +4 -0
  286. package/dist/es/_virtual/regex.js +4 -0
  287. package/dist/es/_virtual/segments.js +4 -0
  288. package/dist/es/_virtual/svg-tag.js +4 -0
  289. package/dist/es/_virtual/utils.js +4 -0
  290. package/dist/es/_virtual/utils2.js +4 -0
  291. package/dist/es/_virtual/version-check.js +4 -0
  292. package/dist/es/_virtual/version.js +4 -0
  293. package/dist/es/components/qr-code/index.js +49 -0
  294. package/dist/es/components/react-force-graph-3d/index.d.ts +1 -0
  295. package/dist/es/index.d.ts +2 -0
  296. package/dist/es/index.js +18 -14
  297. package/dist/es/node_modules/.pnpm/3d-force-graph@1.77.0/node_modules/3d-force-graph/dist/3d-force-graph.js +398 -0
  298. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js +7 -0
  299. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/construct.js +12 -0
  300. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/extends.js +12 -0
  301. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js +8 -0
  302. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +7 -0
  303. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/isNativeFunction.js +10 -0
  304. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js +13 -0
  305. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +8 -0
  306. package/dist/es/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js +29 -0
  307. package/dist/es/node_modules/.pnpm/@tweenjs_tween.js@23.1.3/node_modules/@tweenjs/tween.js/dist/tween.esm.js +379 -0
  308. package/dist/es/node_modules/.pnpm/accessor-fn@1.5.3/node_modules/accessor-fn/dist/accessor-fn.js +10 -0
  309. package/dist/es/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/ascending.js +6 -0
  310. package/dist/es/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/bisect.js +3 -0
  311. package/dist/es/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/bisector.js +27 -0
  312. package/dist/es/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/max.js +17 -0
  313. package/dist/es/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/min.js +17 -0
  314. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/add.js +32 -0
  315. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/binarytree.js +48 -0
  316. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/cover.js +22 -0
  317. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/data.js +11 -0
  318. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/extent.js +6 -0
  319. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/find.js +20 -0
  320. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/half.js +6 -0
  321. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/remove.js +20 -0
  322. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/root.js +6 -0
  323. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/size.js +11 -0
  324. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/visit.js +13 -0
  325. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/visitAfter.js +18 -0
  326. package/dist/es/node_modules/.pnpm/d3-binarytree@1.0.2/node_modules/d3-binarytree/src/x.js +10 -0
  327. package/dist/es/node_modules/.pnpm/d3-dispatch@3.0.1/node_modules/d3-dispatch/src/dispatch.js +64 -0
  328. package/dist/es/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/center.js +25 -0
  329. package/dist/es/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/constant.js +8 -0
  330. package/dist/es/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/jiggle.js +6 -0
  331. package/dist/es/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/lcg.js +7 -0
  332. package/dist/es/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/link.js +58 -0
  333. package/dist/es/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/manyBody.js +58 -0
  334. package/dist/es/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/radial.js +34 -0
  335. package/dist/es/node_modules/.pnpm/d3-force-3d@3.0.6/node_modules/d3-force-3d/src/simulation.js +95 -0
  336. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/add.js +32 -0
  337. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/cover.js +40 -0
  338. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/data.js +11 -0
  339. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/extent.js +6 -0
  340. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/find.js +29 -0
  341. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/findAll.js +15 -0
  342. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/octant.js +6 -0
  343. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/octree.js +54 -0
  344. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/remove.js +20 -0
  345. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/root.js +6 -0
  346. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/size.js +11 -0
  347. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/visit.js +13 -0
  348. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/visitAfter.js +18 -0
  349. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/x.js +10 -0
  350. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/y.js +10 -0
  351. package/dist/es/node_modules/.pnpm/d3-octree@1.1.0/node_modules/d3-octree/src/z.js +10 -0
  352. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/add.js +29 -0
  353. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/cover.js +28 -0
  354. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/data.js +11 -0
  355. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/extent.js +6 -0
  356. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/find.js +25 -0
  357. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/quad.js +6 -0
  358. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/quadtree.js +50 -0
  359. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/remove.js +20 -0
  360. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/root.js +6 -0
  361. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/size.js +11 -0
  362. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/visit.js +13 -0
  363. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/visitAfter.js +18 -0
  364. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/x.js +10 -0
  365. package/dist/es/node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/y.js +10 -0
  366. package/dist/es/node_modules/.pnpm/d3-scale-chromatic@3.1.0/node_modules/d3-scale-chromatic/src/categorical/Paired.js +5 -0
  367. package/dist/es/node_modules/.pnpm/d3-scale-chromatic@3.1.0/node_modules/d3-scale-chromatic/src/colors.js +7 -0
  368. package/dist/es/node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/init.js +16 -0
  369. package/dist/es/node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/ordinal.js +31 -0
  370. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/array.js +6 -0
  371. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/constant.js +8 -0
  372. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/creator.js +20 -0
  373. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/matcher.js +14 -0
  374. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/namespace.js +8 -0
  375. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/namespaces.js +12 -0
  376. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/pointer.js +18 -0
  377. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/select.js +7 -0
  378. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/append.js +10 -0
  379. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/attr.js +44 -0
  380. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/call.js +7 -0
  381. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/classed.js +54 -0
  382. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/clone.js +14 -0
  383. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/data.js +42 -0
  384. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/datum.js +6 -0
  385. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/dispatch.js +21 -0
  386. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/each.js +9 -0
  387. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/empty.js +6 -0
  388. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/enter.js +27 -0
  389. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/exit.js +8 -0
  390. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/filter.js +12 -0
  391. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/html.js +20 -0
  392. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/index.js +83 -0
  393. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/insert.js +14 -0
  394. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/iterator.js +8 -0
  395. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/join.js +7 -0
  396. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/lower.js +9 -0
  397. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/merge.js +12 -0
  398. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/node.js +11 -0
  399. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/nodes.js +6 -0
  400. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/on.js +52 -0
  401. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/order.js +9 -0
  402. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/property.js +22 -0
  403. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/raise.js +9 -0
  404. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/remove.js +10 -0
  405. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/select.js +12 -0
  406. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/selectAll.js +18 -0
  407. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/selectChild.js +16 -0
  408. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/selectChildren.js +16 -0
  409. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/size.js +8 -0
  410. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/sort.js +19 -0
  411. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/sparse.js +6 -0
  412. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/style.js +27 -0
  413. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/text.js +20 -0
  414. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selector.js +10 -0
  415. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selectorAll.js +11 -0
  416. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/sourceEvent.js +8 -0
  417. package/dist/es/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/window.js +6 -0
  418. package/dist/es/node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/timer.js +62 -0
  419. package/dist/es/node_modules/.pnpm/data-bind-mapper@1.0.3/node_modules/data-bind-mapper/dist/data-bind-mapper.js +173 -0
  420. package/dist/es/node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js +72 -0
  421. package/dist/es/node_modules/.pnpm/float-tooltip@1.7.5/node_modules/float-tooltip/dist/float-tooltip.js +169 -0
  422. package/dist/es/node_modules/.pnpm/internmap@2.0.3/node_modules/internmap/src/index.js +35 -0
  423. package/dist/es/node_modules/.pnpm/jerrypick@1.1.2/node_modules/jerrypick/dist/jerrypick.js +92 -0
  424. package/dist/es/node_modules/.pnpm/kapsule@1.16.3/node_modules/kapsule/dist/kapsule.js +113 -0
  425. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.js +5 -0
  426. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.js +10 -0
  427. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseTrim.js +8 -0
  428. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js +4 -0
  429. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.js +15 -0
  430. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.js +7 -0
  431. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.js +5 -0
  432. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_trimmedEndIndex.js +9 -0
  433. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/debounce.js +54 -0
  434. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.js +7 -0
  435. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObjectLike.js +6 -0
  436. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isSymbol.js +9 -0
  437. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/now.js +7 -0
  438. package/dist/es/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/toNumber.js +22 -0
  439. package/dist/es/node_modules/.pnpm/ngraph.events@1.2.2/node_modules/ngraph.events/index.js +57 -0
  440. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/index.js +239 -0
  441. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/createPatternBuilder.js +22 -0
  442. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateBounds.js +74 -0
  443. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateCreateBody.js +74 -0
  444. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateCreateDragForce.js +28 -0
  445. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateCreateSpringForce.js +53 -0
  446. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateIntegrator.js +55 -0
  447. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/generateQuadTree.js +403 -0
  448. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/codeGenerators/getVariableName.js +9 -0
  449. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/createPhysicsSimulator.js +273 -0
  450. package/dist/es/node_modules/.pnpm/ngraph.forcelayout@3.3.1/node_modules/ngraph.forcelayout/lib/spring.js +12 -0
  451. package/dist/es/node_modules/.pnpm/ngraph.graph@20.0.1/node_modules/ngraph.graph/index.js +319 -0
  452. package/dist/es/node_modules/.pnpm/ngraph.merge@1.0.0/node_modules/ngraph.merge/index.js +20 -0
  453. package/dist/es/node_modules/.pnpm/ngraph.random@1.2.0/node_modules/ngraph.random/index.js +71 -0
  454. package/dist/es/node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js +54 -0
  455. package/dist/es/node_modules/.pnpm/polished@4.3.1/node_modules/polished/dist/polished.esm.js +717 -0
  456. package/dist/es/node_modules/.pnpm/preact@10.26.9/node_modules/preact/dist/preact.module.js +257 -0
  457. package/dist/es/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/checkPropTypes.js +54 -0
  458. package/dist/es/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithThrowingShims.js +52 -0
  459. package/dist/es/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithTypeCheckers.js +329 -0
  460. package/dist/es/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +17 -0
  461. package/dist/es/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js +10 -0
  462. package/dist/es/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/has.js +7 -0
  463. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js +44 -0
  464. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js +9 -0
  465. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js +26 -0
  466. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js +73 -0
  467. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js +28 -0
  468. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js +23 -0
  469. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js +23 -0
  470. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js +362 -0
  471. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js +41 -0
  472. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js +22 -0
  473. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js +18 -0
  474. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js +24 -0
  475. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js +36 -0
  476. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js +102 -0
  477. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js +68 -0
  478. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js +26 -0
  479. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js +34 -0
  480. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js +154 -0
  481. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js +27 -0
  482. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js +23 -0
  483. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js +146 -0
  484. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js +74 -0
  485. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js +10 -0
  486. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js +75 -0
  487. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js +32 -0
  488. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js +32 -0
  489. package/dist/es/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js +58 -0
  490. package/dist/es/node_modules/.pnpm/react-force-graph-3d@1.27.0_react@18.3.1/node_modules/react-force-graph-3d/dist/react-force-graph-3d.js +145 -0
  491. package/dist/es/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js +95 -0
  492. package/dist/es/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.production.min.js +78 -0
  493. package/dist/es/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js +10 -0
  494. package/dist/es/node_modules/.pnpm/react-kapsule@2.5.7_react@18.3.1/node_modules/react-kapsule/dist/react-kapsule.js +113 -0
  495. package/dist/es/node_modules/.pnpm/three-forcegraph@1.42.13_three@0.171.0/node_modules/three-forcegraph/dist/three-forcegraph.js +1020 -0
  496. package/dist/es/node_modules/.pnpm/three-render-objects@1.40.2_three@0.171.0/node_modules/three-render-objects/dist/three-render-objects.js +453 -0
  497. package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/build/three.core.js +6662 -0
  498. package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/build/three.module.js +9671 -0
  499. package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/build/three.webgpu.js +13421 -0
  500. package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/controls/DragControls.js +109 -0
  501. package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/controls/FlyControls.js +182 -0
  502. package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/controls/OrbitControls.js +422 -0
  503. package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/controls/TrackballControls.js +211 -0
  504. package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/postprocessing/EffectComposer.js +77 -0
  505. package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/postprocessing/MaskPass.js +24 -0
  506. package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/postprocessing/Pass.js +42 -0
  507. package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/postprocessing/RenderPass.js +17 -0
  508. package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/postprocessing/ShaderPass.js +23 -0
  509. package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/shaders/CopyShader.js +41 -0
  510. package/dist/es/node_modules/.pnpm/tinycolor2@1.6.0/node_modules/tinycolor2/esm/tinycolor.js +711 -0
  511. package/package.json +2 -2
@@ -0,0 +1,373 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./three.core.js");/**
2
+ * @license
3
+ * Copyright 2010-2024 Three.js Authors
4
+ * SPDX-License-Identifier: MIT
5
+ */const zu=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveMap","envMap","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class ro{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=zu,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){const{geometry:s,material:n,object:r}=e;if(t={material:this.getMaterialData(n),geometry:{attributes:this.getAttributesData(s.attributes),indexVersion:s.index?s.index.version:null,drawRange:{start:s.drawRange.start,count:s.drawRange.count}},worldMatrix:r.matrixWorld.clone()},r.center&&(t.center=r.center.clone()),r.morphTargetInfluences&&(t.morphTargetInfluences=r.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 n=e[s];t[s]={version:n.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.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const s of this.refreshUniforms){const n=e[s];n!=null&&(typeof n=="object"&&n.clone!==void 0?n.isTexture===!0?t[s]={id:n.id,version:n.version}:t[s]=n.clone():t[s]=n)}return t}equals(e){const{object:t,material:s,geometry:n}=e,r=this.getRenderObjectData(e);if(r.worldMatrix.equals(t.matrixWorld)!==!0)return r.worldMatrix.copy(t.matrixWorld),!1;const i=r.material;for(const m in i){const y=i[m],S=s[m];if(y.equals!==void 0){if(y.equals(S)===!1)return y.copy(S),!1}else if(S.isTexture===!0){if(y.id!==S.id||y.version!==S.version)return y.id=S.id,y.version=S.version,!1}else if(y!==S)return i[m]=S,!1}if(i.transmission>0){const{width:m,height:y}=e.context;if(r.bufferWidth!==m||r.bufferHeight!==y)return r.bufferWidth=m,r.bufferHeight=y,!1}const u=r.geometry,a=n.attributes,l=u.attributes,d=Object.keys(l),h=Object.keys(a);if(d.length!==h.length)return r.geometry.attributes=this.getAttributesData(a),!1;for(const m of d){const y=l[m],S=a[m];if(S===void 0)return delete l[m],!1;if(y.version!==S.version)return y.version=S.version,!1}const p=n.index,f=u.indexVersion,g=p?p.version:null;if(f!==g)return u.indexVersion=g,!1;if(u.drawRange.start!==n.drawRange.start||u.drawRange.count!==n.drawRange.count)return u.drawRange.start=n.drawRange.start,u.drawRange.count=n.drawRange.count,!1;if(r.morphTargetInfluences){let m=!1;for(let y=0;y<r.morphTargetInfluences.length;y++)r.morphTargetInfluences[y]!==t.morphTargetInfluences[y]&&(m=!0);if(m)return!0}return r.center&&r.center.equals(t.center)===!1?(r.center.copy(t.center),!0):(e.bundle!==null&&(r.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e))return!0;const{renderId:s}=t;if(this.renderId!==s)return this.renderId=s,!0;const n=e.object.static===!0,r=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;return n||r?!1:this.equals(e)!==!0}}function ts(o,e=0){let t=3735928559^e,s=1103547991^e;if(o instanceof Array)for(let n=0,r;n<o.length;n++)r=o[n],t=Math.imul(t^r,2654435761),s=Math.imul(s^r,1597334677);else for(let n=0,r;n<o.length;n++)r=o.charCodeAt(n),t=Math.imul(t^r,2654435761),s=Math.imul(s^r,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 $u=o=>ts(o),io=o=>ts(o),oo=(...o)=>ts(o);function ao(o,e=!1){const t=[];o.isNode===!0&&(t.push(o.id),o=o.getSelf());for(const{property:s,childNode:n}of Ps(o))t.push(t,ts(s.slice(0,-4)),n.getCacheKey(e));return ts(t)}function*Ps(o,e=!1){for(const t in o){if(t.startsWith("_")===!0)continue;const s=o[t];if(Array.isArray(s)===!0)for(let n=0;n<s.length;n++){const r=s[n];r&&(r.isNode===!0||e&&typeof r.toJSON=="function")&&(yield{property:t,index:n,childNode:r})}else if(s&&s.isNode===!0)yield{property:t,childNode:s};else if(typeof s=="object")for(const n in s){const r=s[n];r&&(r.isNode===!0||e&&typeof r.toJSON=="function")&&(yield{property:t,index:n,childNode:r})}}}const Wu=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]);function Hu(o){return Wu.get(o)}function Ds(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.isMatrix3===!0?"mat3":o.isMatrix4===!0?"mat4":o.isColor===!0?"color":o instanceof ArrayBuffer?"ArrayBuffer":null}function uo(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 c.Color(...e):t==="vec2"?new c.Vector2(...e):t==="vec3"?new c.Vector3(...e):t==="vec4"?new c.Vector4(...e):t==="mat3"?new c.Matrix3(...e):t==="mat4"?new c.Matrix4(...e):o==="bool"?e[0]||!1:o==="float"||o==="int"||o==="uint"?e[0]||0:o==="string"?e[0]||"":o==="ArrayBuffer"?Ku(e[0]):null}function qu(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 Ku(o){return Uint8Array.from(atob(o),e=>e.charCodeAt(0)).buffer}const Vn={VERTEX:"vertex"},z={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},De={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},co=["fragment","vertex"],kn=["setup","analyze","generate"],zn=[...co,"compute"],yt=["x","y","z","w"];let Xu=0;class V extends c.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=c.MathUtils.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:Xu++})}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 Ps(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=ao(this,e),this._cacheKeyVersion=this.version),this._cacheKey}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)}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 n of this.getChildren())t["node"+s++]=n;return null}analyze(e){if(e.increaseUsage(this)===1){const s=e.getNodeProperties(this);for(const n of Object.values(s))n&&n.isNode===!0&&n.build(e)}}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);e.addNode(this),e.addChain(this);let n=null;const r=e.getBuildStage();if(r==="setup"){this.updateReference(e);const i=e.getNodeProperties(this);if(i.initialized!==!0){const u=e.stack.nodes.length;i.initialized=!0,i.outputNode=this.setup(e),i.outputNode!==null&&e.stack.nodes.length;for(const a of Object.values(i))a&&a.isNode===!0&&a.build(e)}}else if(r==="analyze")this.analyze(e);else if(r==="generate")if(this.generate.length===1){const u=this.getNodeType(e),a=e.getDataFromNode(this);n=a.snippet,n===void 0?(n=this.generate(e)||"",a.snippet=n):a.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),n=e.format(n,u,t)}else n=this.generate(e,t)||"";return e.removeChain(this),e.addSequentialNode(this),n}getSerializeChildren(){return Ps(this)}serialize(e){const t=this.getSerializeChildren(),s={};for(const{property:n,index:r,childNode:i}of t)r!==void 0?(s[n]===void 0&&(s[n]=Number.isInteger(r)?[]:{}),s[n][r]=i.toJSON(e.meta).uuid):s[n]=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 n=[];for(const r of e.inputNodes[s])n.push(t[r]);this[s]=n}else if(typeof e.inputNodes[s]=="object"){const n={};for(const r in e.inputNodes[s]){const i=e.inputNodes[s][r];n[r]=t[i]}this[s]=n}else{const n=e.inputNodes[s];this[s]=t[n]}}}toJSON(e){const{uuid:t,type:s}=this,n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{},nodes:{}});let r=e.nodes[t];r===void 0&&(r={uuid:t,type:s,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},n!==!0&&(e.nodes[r.uuid]=r),this.serialize(r),delete r.meta);function i(u){const a=[];for(const l in u){const d=u[l];delete d.metadata,a.push(d)}return a}if(n){const u=i(e.textures),a=i(e.images),l=i(e.nodes);u.length>0&&(r.textures=u),a.length>0&&(r.images=a),l.length>0&&(r.nodes=l)}return r}}class It 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.node.build(e),s=this.indexNode.build(e,"uint");return`${t}[ ${s} ]`}}class ir 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 n of this.convertTo.split("|"))(s===null||e.getTypeLength(t)===e.getTypeLength(n))&&(s=n);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,n=this.getNodeType(e),r=s.build(e,n);return e.format(r,n,t)}}class ie extends V{static get type(){return"TempNode"}constructor(e){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!=="void"&&t!=="void"&&this.hasDependencies(e)){const i=super.build(e,n),u=e.getVarFromNode(this,null,n),a=e.getPropertyName(u);return e.addLineFlowCode(`${a} = ${i}`,this),r.snippet=i,r.propertyName=a,e.format(r.propertyName,n,t)}}return super.build(e,t)}}class lo extends ie{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),n=this.nodes,r=e.getComponentType(s),i=[];for(const a of n){let l=a.build(e);const d=e.getComponentType(a.getNodeType(e));d!==r&&(l=e.format(l,d,r)),i.push(l)}const u=`${e.getType(s)}( ${i.join(", ")} )`;return e.format(u,s,t)}}const Yu=yt.join("");class $n 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(yt.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,n=e.getTypeLength(s.getNodeType(e));let r=null;if(n>1){let i=null;this.getVectorLength()>=n&&(i=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const a=s.build(e,i);this.components.length===n&&this.components===Yu.slice(0,this.components.length)?r=e.format(a,i,t):r=e.format(`${a}.${this.components}`,this.getNodeType(e),t)}else r=s.build(e,t);return r}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class ho extends ie{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:n}=this,r=this.getNodeType(e),i=e.getTypeFromLength(s.length,n.getNodeType(e)),u=n.build(e,i),a=t.build(e,r),l=e.getTypeLength(r),d=[];for(let h=0;h<l;h++){const p=yt[h];p===s[0]?(d.push(u),h+=s.length-1):d.push(a+"."+p)}return`${e.getType(r)}( ${d.join(", ")} )`}}class Qu extends ie{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,n=this.getNodeType(e),r=s.build(e),i=e.getVarFromNode(this),u=e.getPropertyName(i);e.addLineFlowCode(u+" = "+r,this);const a=e.getTypeLength(n),l=[];let d=0;for(let h=0;h<a;h++){const p=yt[h];p===t[d]?(l.push("1.0 - "+(u+"."+p)),d++):l.push(u+"."+p)}return`${e.getType(n)}( ${l.join(", ")} )`}}class or 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?Ds(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=Ds(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=qu(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?uo(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.")}}class Ve extends or{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 e.format(this.generateConst(e),s,t)}}let Gt=null;const vt=new Map;function b(o,e){if(vt.has(o)){console.warn(`Redefinition of method chaining ${o}`);return}if(typeof e!="function")throw new Error(`Node element ${o} is not a function`);vt.set(o,e)}const po=o=>o.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),qr=o=>po(o).split("").sort().join(""),fo={setup(o,e){const t=e.shift();return o(Xs(t),...e)},get(o,e,t){if(typeof e=="string"&&o[e]===void 0){if(o.isStackNode!==!0&&e==="assign")return(...s)=>(Gt.assign(t,...s),t);if(vt.has(e)){const s=vt.get(e);return o.isStackNode?(...n)=>t.add(s(...n)):(...n)=>s(t,...n)}else{if(e==="self")return o;if(e.endsWith("Assign")&&vt.has(e.slice(0,e.length-6))){const s=vt.get(e.slice(0,e.length-6));return o.isStackNode?(...n)=>t.assign(n[0],s(...n)):(...n)=>t.assign(s(t,...n))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=po(e),v(new $n(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=qr(e.slice(3).toLowerCase()),s=>v(new ho(o,e,s));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=qr(e.slice(4).toLowerCase()),()=>v(new Qu(v(o),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),v(new $n(o,e));if(/^\d+$/.test(e)===!0)return v(new It(t,new Ve(Number(e),"uint")))}}}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)}},on=new WeakMap,Kr=new WeakMap,ju=function(o,e=null){const t=Ds(o);if(t==="node"){let s=on.get(o);return s===void 0&&(s=new Proxy(o,fo),on.set(o,s),on.set(s,s)),s}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return v(Wn(o,e));if(t==="shader")return M(o)}return o},Zu=function(o,e=null){for(const t in o)o[t]=v(o[t],e);return o},Ju=function(o,e=null){const t=o.length;for(let s=0;s<t;s++)o[s]=v(o[s],e);return o},ec=function(o,e=null,t=null,s=null){const n=r=>v(s!==null?Object.assign(r,s):r);return e===null?(...r)=>n(new o(...Ft(r))):t!==null?(t=v(t),(...r)=>n(new o(e,...Ft(r),t))):(...r)=>n(new o(e,...Ft(r)))},tc=function(o,...e){return v(new o(...Ft(e)))};class sc extends V{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:s}=this,n=e.getNodeProperties(t);if(n.onceOutput)return n.onceOutput;let r=null;if(t.layout){let i=Kr.get(e.constructor);i===void 0&&(i=new WeakMap,Kr.set(e.constructor,i));let u=i.get(t);u===void 0&&(u=v(e.buildFunctionNode(t)),i.set(t,u)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(u),r=v(u.call(s))}else{const i=t.jsFunc,u=s!==null?i(s,e):i(e);r=v(u)}return t.once&&(n.onceOutput=r),r}getOutputNode(e){const t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class nc 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 Xs(e),v(new sc(this,e))}setup(){return this.call()}}const rc=[!1,!0],ic=[0,1,2,3],oc=[-1,-2],go=[.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],ar=new Map;for(const o of rc)ar.set(o,new Ve(o));const ur=new Map;for(const o of ic)ur.set(o,new Ve(o,"uint"));const cr=new Map([...ur].map(o=>new Ve(o.value,"int")));for(const o of oc)cr.set(o,new Ve(o,"int"));const qs=new Map([...cr].map(o=>new Ve(o.value)));for(const o of go)qs.set(o,new Ve(o));for(const o of go)qs.set(-o,new Ve(-o));const Ks={bool:ar,uint:ur,ints:cr,float:qs},Xr=new Map([...ar,...qs]),Wn=(o,e)=>Xr.has(o)?Xr.get(o):o.isNode===!0?o:new Ve(o,e),ac=o=>{try{return o.getNodeType()}catch{return}},le=function(o,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(o)&&t.every(n=>typeof n!="object"))&&(t=[uo(o,...t)]),t.length===1&&e!==null&&e.has(t[0]))return v(e.get(t[0]));if(t.length===1){const n=Wn(t[0],o);return ac(n)===o?v(n):v(new ir(n,o))}const s=t.map(n=>Wn(n));return v(new lo(s,o))}},Yr=o=>typeof o=="object"&&o!==null?o.value:o,uc=o=>o!=null?o.nodeType||o.convertTo||(typeof o=="string"?o:null):null;function Ms(o,e){return new Proxy(new nc(o,e),fo)}const v=(o,e=null)=>ju(o,e),Xs=(o,e=null)=>new Zu(o,e),Ft=(o,e=null)=>new Ju(o,e),C=(...o)=>new ec(...o),B=(...o)=>new tc(...o),M=(o,e)=>{const t=new Ms(o,e),s=(...n)=>{let r;return Xs(n),n[0]&&n[0].isNode?r=[...n]:r=n[0],t.call(r)};return s.shaderNode=t,s.setLayout=n=>(t.setLayout(n),s),s.once=()=>(t.once=!0,s),s};b("toGlobal",o=>(o.global=!0,o));const Is=o=>{Gt=o},mo=()=>Gt,ce=(...o)=>Gt.If(...o);function cc(o){return Gt&&Gt.add(o),o}b("append",cc);const lc=new le("color"),x=new le("float",Ks.float),te=new le("int",Ks.ints),dc=new le("uint",Ks.uint),To=new le("bool",Ks.bool),F=new le("vec2"),We=new le("ivec2"),hc=new le("uvec2"),pc=new le("bvec2"),R=new le("vec3"),fc=new le("ivec3"),gc=new le("uvec3"),mc=new le("bvec3"),k=new le("vec4"),Tc=new le("ivec4"),yc=new le("uvec4"),_c=new le("bvec4"),lr=new le("mat2"),Te=new le("mat3"),wt=new le("mat4");b("toColor",lc);b("toFloat",x);b("toInt",te);b("toUint",dc);b("toBool",To);b("toVec2",F);b("toIVec2",We);b("toUVec2",hc);b("toBVec2",pc);b("toVec3",R);b("toIVec3",fc);b("toUVec3",gc);b("toBVec3",mc);b("toVec4",k);b("toIVec4",Tc);b("toUVec4",yc);b("toBVec4",_c);b("toMat2",lr);b("toMat3",Te);b("toMat4",wt);const Sc=C(It),Nc=(o,e)=>v(new ir(v(o),e));b("element",Sc);b("convert",Nc);class dr extends V{static get type(){return"UniformGroupNode"}constructor(e,t=!1,s=1){super("string"),this.name=e,this.version=0,this.shared=t,this.order=s,this.isUniformGroup=!0}set needsUpdate(e){e===!0&&this.version++}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 xc=o=>new dr(o),yo=(o,e=0)=>new dr(o,!0,e),bc=yo("frame"),L=yo("render"),_o=xc("object");class Lt extends or{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=_o}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(n=>{const r=e(n,s);r!==void 0&&(this.value=r)},t)}generate(e,t){const s=this.getNodeType(e),n=this.getUniformHash(e);let r=e.getNodeFromHash(n);r===void 0&&(e.setHashNode(this,n),r=this);const i=r.getInputType(e),u=e.getUniformFromNode(r,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=uc(e||o),s=o&&o.isNode===!0?o.node&&o.node.value||o.value:o;return v(new Lt(s,t))};class K extends V{static get type(){return"PropertyNode"}constructor(e,t=null,s=!1){super(e),this.name=t,this.varying=s,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}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 Rc=(o,e)=>v(new K(o,e)),Ls=(o,e)=>v(new K(o,e,!0)),q=B(K,"vec4","DiffuseColor"),Qr=B(K,"vec3","EmissiveColor"),He=B(K,"float","Roughness"),Os=B(K,"float","Metalness"),Hn=B(K,"float","Clearcoat"),Vs=B(K,"float","ClearcoatRoughness"),Et=B(K,"vec3","Sheen"),hr=B(K,"float","SheenRoughness"),pr=B(K,"float","Iridescence"),So=B(K,"float","IridescenceIOR"),No=B(K,"float","IridescenceThickness"),qn=B(K,"float","AlphaT"),ct=B(K,"float","Anisotropy"),Bs=B(K,"vec3","AnisotropyT"),Ut=B(K,"vec3","AnisotropyB"),Ae=B(K,"color","SpecularColor"),ks=B(K,"float","SpecularF90"),Kn=B(K,"float","Shininess"),Ac=B(K,"vec4","Output"),an=B(K,"float","dashSize"),jr=B(K,"float","gapSize"),Fs=B(K,"float","IOR"),Xn=B(K,"float","Transmission"),xo=B(K,"float","Thickness"),bo=B(K,"float","AttenuationDistance"),Ro=B(K,"color","AttenuationColor"),Ao=B(K,"float","Dispersion");class Co extends ie{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}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 yt.join("").slice(0,s)!==t.components}return!1}generate(e,t){const{targetNode:s,sourceNode:n}=this,r=this.needsSplitAssign(e),i=s.getNodeType(e),u=s.context({assign:!0}).build(e),a=n.build(e,i),l=n.getNodeType(e),d=e.getDataFromNode(this);let h;if(d.initialized===!0)t!=="void"&&(h=u);else if(r){const p=e.getVarFromNode(this,null,i),f=e.getPropertyName(p);e.addLineFlowCode(`${f} = ${a}`,this);const g=s.node.context({assign:!0}).build(e);for(let m=0;m<s.components.length;m++){const y=s.components[m];e.addLineFlowCode(`${g}.${y} = ${f}[ ${m} ]`,this)}t!=="void"&&(h=u)}else h=`${u} = ${a}`,(t==="void"||l==="void")&&(e.addLineFlowCode(h,this),t!=="void"&&(h=u));return d.initialized=!0,e.format(h,i,t)}}const Cc=C(Co);b("assign",Cc);class vo extends ie{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,n=s.getInputs(e),r=this.parameters,i=(a,l)=>{const d=l.type,h=d==="pointer";let p;return h?p="&"+a.build(e):p=a.build(e,d),p};if(Array.isArray(r))for(let a=0;a<r.length;a++)t.push(i(r[a],n[a]));else for(const a of n){const l=r[a.name];if(l!==void 0)t.push(i(l,a));else throw new Error(`FunctionCallNode: Input '${a.name}' not found in FunctionNode.`)}return`${s.build(e,"property")}( ${t.join(", ")} )`}}const vc=(o,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?Ft(e):Xs(e[0]),v(new vo(v(o),e)));b("call",vc);class J extends ie{static get type(){return"OperatorNode"}constructor(e,t,s,...n){if(super(),n.length>0){let r=new J(e,t,s);for(let i=0;i<n.length-1;i++)r=new J(e,r,n[i]);t=r,s=n[n.length-1]}this.op=e,this.aNode=t,this.bNode=s}getNodeType(e,t){const s=this.op,n=this.aNode,r=this.bNode,i=n.getNodeType(e),u=typeof r<"u"?r.getNodeType(e):null;if(i==="void"||u==="void")return"void";if(s==="%")return i;if(s==="~"||s==="&"||s==="|"||s==="^"||s===">>"||s==="<<")return e.getIntegerType(i);if(s==="!"||s==="=="||s==="&&"||s==="||"||s==="^^")return"bool";if(s==="<"||s===">"||s==="<="||s===">="){const a=t?e.getTypeLength(t):Math.max(e.getTypeLength(i),e.getTypeLength(u));return a>1?`bvec${a}`:"bool"}else return i==="float"&&e.isMatrix(u)?u:e.isMatrix(i)&&e.isVector(u)?e.getVectorFromMatrix(i):e.isVector(i)&&e.isMatrix(u)?e.getVectorFromMatrix(u):e.getTypeLength(u)>e.getTypeLength(i)?u:i}generate(e,t){const s=this.op,n=this.aNode,r=this.bNode,i=this.getNodeType(e,t);let u=null,a=null;i!=="void"?(u=n.getNodeType(e),a=typeof r<"u"?r.getNodeType(e):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="?e.isVector(u)?a=u:u!==a&&(u=a="float"):s===">>"||s==="<<"?(u=i,a=e.changeComponentType(a,"uint")):e.isMatrix(u)&&e.isVector(a)?a=e.getVectorFromMatrix(u):e.isVector(u)&&e.isMatrix(a)?u=e.getVectorFromMatrix(a):u=a=i):u=a=i;const l=n.build(e,u),d=typeof r<"u"?r.build(e,a):null,h=e.getTypeLength(t),p=e.getFunctionOperator(s);if(t!=="void")return s==="<"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${l}, ${d} )`,i,t):e.format(`( ${l} < ${d} )`,i,t):s==="<="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${l}, ${d} )`,i,t):e.format(`( ${l} <= ${d} )`,i,t):s===">"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${l}, ${d} )`,i,t):e.format(`( ${l} > ${d} )`,i,t):s===">="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${l}, ${d} )`,i,t):e.format(`( ${l} >= ${d} )`,i,t):s==="!"||s==="~"?e.format(`(${s}${l})`,u,t):p?e.format(`${p}( ${l}, ${d} )`,i,t):e.format(`( ${l} ${s} ${d} )`,i,t);if(u!=="void")return p?e.format(`${p}( ${l}, ${d} )`,i,t):e.format(`${l} ${s} ${d}`,i,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const ye=C(J,"+"),_e=C(J,"-"),$=C(J,"*"),Ke=C(J,"/"),Eo=C(J,"%"),Ec=C(J,"=="),Mc=C(J,"!="),Bc=C(J,"<"),Fc=C(J,">"),wc=C(J,"<="),Uc=C(J,">="),Gc=C(J,"&&"),Pc=C(J,"||"),Dc=C(J,"!"),Ic=C(J,"^^"),Lc=C(J,"&"),Oc=C(J,"~"),Vc=C(J,"|"),kc=C(J,"^"),zc=C(J,"<<"),$c=C(J,">>");b("add",ye);b("sub",_e);b("mul",$);b("div",Ke);b("modInt",Eo);b("equal",Ec);b("notEqual",Mc);b("lessThan",Bc);b("greaterThan",Fc);b("lessThanEqual",wc);b("greaterThanEqual",Uc);b("and",Gc);b("or",Pc);b("not",Dc);b("xor",Ic);b("bitAnd",Lc);b("bitNot",Oc);b("bitOr",Vc);b("bitXor",kc);b("shiftLeft",zc);b("shiftRight",$c);const Wc=(...o)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),Eo(...o));b("remainder",Wc);class _ extends ie{static get type(){return"MathNode"}constructor(e,t,s=null,n=null){super(),this.method=e,this.aNode=t,this.bNode=s,this.cNode=n}getInputType(e){const t=this.aNode.getNodeType(e),s=this.bNode?this.bNode.getNodeType(e):null,n=this.cNode?this.cNode.getNodeType(e):null,r=e.isMatrix(t)?0:e.getTypeLength(t),i=e.isMatrix(s)?0:e.getTypeLength(s),u=e.isMatrix(n)?0:e.getTypeLength(n);return r>i&&r>u?t:i>u?s:u>r?n:t}getNodeType(e){const t=this.method;return t===_.LENGTH||t===_.DISTANCE||t===_.DOT?"float":t===_.CROSS?"vec3":t===_.ALL?"bool":t===_.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===_.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){const s=this.method,n=this.getNodeType(e),r=this.getInputType(e),i=this.aNode,u=this.bNode,a=this.cNode,l=e.renderer.isWebGLRenderer===!0;if(s===_.TRANSFORM_DIRECTION){let d=i,h=u;e.isMatrix(d.getNodeType(e))?h=k(R(h),0):d=k(R(d),0);const p=$(d,h).xyz;return ns(p).build(e,t)}else{if(s===_.NEGATE)return e.format("( - "+i.build(e,r)+" )",n,t);if(s===_.ONE_MINUS)return _e(1,i).build(e,t);if(s===_.RECIPROCAL)return Ke(1,i).build(e,t);if(s===_.DIFFERENCE)return Ee(_e(i,u)).build(e,t);{const d=[];return s===_.CROSS||s===_.MOD?d.push(i.build(e,n),u.build(e,n)):l&&s===_.STEP?d.push(i.build(e,e.getTypeLength(i.getNodeType(e))===1?"float":r),u.build(e,r)):l&&(s===_.MIN||s===_.MAX)||s===_.MOD?d.push(i.build(e,r),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":r)):s===_.REFRACT?d.push(i.build(e,r),u.build(e,r),a.build(e,"float")):s===_.MIX?d.push(i.build(e,r),u.build(e,r),a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":r)):(d.push(i.build(e,r)),u!==null&&d.push(u.build(e,r)),a!==null&&d.push(a.build(e,r))),e.format(`${e.getMethod(s,n)}( ${d.join(", ")} )`,n,t)}}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}_.ALL="all";_.ANY="any";_.EQUALS="equals";_.RADIANS="radians";_.DEGREES="degrees";_.EXP="exp";_.EXP2="exp2";_.LOG="log";_.LOG2="log2";_.SQRT="sqrt";_.INVERSE_SQRT="inversesqrt";_.FLOOR="floor";_.CEIL="ceil";_.NORMALIZE="normalize";_.FRACT="fract";_.SIN="sin";_.COS="cos";_.TAN="tan";_.ASIN="asin";_.ACOS="acos";_.ATAN="atan";_.ABS="abs";_.SIGN="sign";_.LENGTH="length";_.NEGATE="negate";_.ONE_MINUS="oneMinus";_.DFDX="dFdx";_.DFDY="dFdy";_.ROUND="round";_.RECIPROCAL="reciprocal";_.TRUNC="trunc";_.FWIDTH="fwidth";_.BITCAST="bitcast";_.TRANSPOSE="transpose";_.ATAN2="atan2";_.MIN="min";_.MAX="max";_.MOD="mod";_.STEP="step";_.REFLECT="reflect";_.DISTANCE="distance";_.DIFFERENCE="difference";_.DOT="dot";_.CROSS="cross";_.POW="pow";_.TRANSFORM_DIRECTION="transformDirection";_.MIX="mix";_.CLAMP="clamp";_.REFRACT="refract";_.SMOOTHSTEP="smoothstep";_.FACEFORWARD="faceforward";const Hc=x(1e-6),qc=x(Math.PI),Mo=C(_,_.ALL),Kc=C(_,_.ANY),Xc=C(_,_.EQUALS),Yc=C(_,_.RADIANS),Qc=C(_,_.DEGREES),Bo=C(_,_.EXP),ss=C(_,_.EXP2),Fo=C(_,_.LOG),qe=C(_,_.LOG2),fr=C(_,_.SQRT),jc=C(_,_.INVERSE_SQRT),gt=C(_,_.FLOOR),gr=C(_,_.CEIL),ns=C(_,_.NORMALIZE),it=C(_,_.FRACT),Fe=C(_,_.SIN),et=C(_,_.COS),Zc=C(_,_.TAN),Jc=C(_,_.ASIN),el=C(_,_.ACOS),tl=C(_,_.ATAN),Ee=C(_,_.ABS),zs=C(_,_.SIGN),rt=C(_,_.LENGTH),sl=C(_,_.NEGATE),nl=C(_,_.ONE_MINUS),wo=C(_,_.DFDX),Uo=C(_,_.DFDY),rl=C(_,_.ROUND),il=C(_,_.RECIPROCAL),ol=C(_,_.TRUNC),al=C(_,_.FWIDTH);_.BITCAST;const ul=C(_,_.TRANSPOSE),cl=C(_,_.ATAN2),rs=C(_,_.MIN),Ne=C(_,_.MAX),Go=C(_,_.MOD),Po=C(_,_.STEP),ll=C(_,_.REFLECT),dl=C(_,_.DISTANCE),hl=C(_,_.DIFFERENCE),mr=C(_,_.DOT),Do=C(_,_.CROSS),Ys=C(_,_.POW),Io=C(_,_.POW,2),pl=C(_,_.POW,3),fl=C(_,_.POW,4),gl=C(_,_.TRANSFORM_DIRECTION),ml=o=>$(zs(o),Ys(Ee(o),1/3)),Tl=o=>mr(o,o),Z=C(_,_.MIX),Xe=(o,e=0,t=1)=>v(new _(_.CLAMP,v(o),v(e),v(t))),yl=o=>Xe(o),Lo=C(_,_.REFRACT),mt=C(_,_.SMOOTHSTEP),_l=C(_,_.FACEFORWARD),Sl=M(([o])=>{const s=43758.5453,n=mr(o.xy,F(12.9898,78.233)),r=Go(n,qc);return it(Fe(r).mul(s))}),Nl=(o,e,t)=>Z(e,t,o),xl=(o,e,t)=>mt(e,t,o);b("all",Mo);b("any",Kc);b("equals",Xc);b("radians",Yc);b("degrees",Qc);b("exp",Bo);b("exp2",ss);b("log",Fo);b("log2",qe);b("sqrt",fr);b("inverseSqrt",jc);b("floor",gt);b("ceil",gr);b("normalize",ns);b("fract",it);b("sin",Fe);b("cos",et);b("tan",Zc);b("asin",Jc);b("acos",el);b("atan",tl);b("abs",Ee);b("sign",zs);b("length",rt);b("lengthSq",Tl);b("negate",sl);b("oneMinus",nl);b("dFdx",wo);b("dFdy",Uo);b("round",rl);b("reciprocal",il);b("trunc",ol);b("fwidth",al);b("atan2",cl);b("min",rs);b("max",Ne);b("mod",Go);b("step",Po);b("reflect",ll);b("distance",dl);b("dot",mr);b("cross",Do);b("pow",Ys);b("pow2",Io);b("pow3",pl);b("pow4",fl);b("transformDirection",gl);b("mix",Nl);b("clamp",Xe);b("refract",Lo);b("smoothstep",xl);b("faceForward",_l);b("difference",hl);b("saturate",yl);b("cbrt",ml);b("transpose",ul);b("rand",Sl);class bl 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 t=this.ifNode.getNodeType(e);if(this.elseNode!==null){const s=this.elseNode.getNodeType(e);if(e.getTypeLength(s)>e.getTypeLength(t))return s}return t}setup(e){const t=this.condNode.cache(),s=this.ifNode.cache(),n=this.elseNode?this.elseNode.cache():null,r=e.context.nodeBlock;e.getDataFromNode(s).parentNodeBlock=r,n!==null&&(e.getDataFromNode(n).parentNodeBlock=r);const i=e.getNodeProperties(this);i.condNode=t,i.ifNode=s.context({nodeBlock:s}),i.elseNode=n?n.context({nodeBlock:n}):null}generate(e,t){const s=this.getNodeType(e),n=e.getDataFromNode(this);if(n.nodeProperty!==void 0)return n.nodeProperty;const{condNode:r,ifNode:i,elseNode:u}=e.getNodeProperties(this),a=t!=="void",l=a?Rc(s).build(e):"";n.nodeProperty=l;const d=r.build(e,"bool");e.addFlowCode(`
6
+ ${e.tab}if ( ${d} ) {
7
+
8
+ `).addFlowTab();let h=i.build(e,s);if(h&&(a?h=l+" = "+h+";":h="return "+h+";"),e.removeFlowTab().addFlowCode(e.tab+" "+h+`
9
+
10
+ `+e.tab+"}"),u!==null){e.addFlowCode(` else {
11
+
12
+ `).addFlowTab();let p=u.build(e,s);p&&(a?p=l+" = "+p+";":p="return "+p+";"),e.removeFlowTab().addFlowCode(e.tab+" "+p+`
13
+
14
+ `+e.tab+`}
15
+
16
+ `)}else e.addFlowCode(`
17
+
18
+ `);return e.format(l,s,t)}}const Se=C(bl);b("select",Se);const Rl=(...o)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),Se(...o));b("cond",Rl);class Tr 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){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const s=this.node.build(e);return e.setContext(t),s}generate(e,t){const s=e.getContext();e.setContext({...e.context,...this.value});const n=this.node.build(e,t);return e.setContext(s),n}}const yr=C(Tr),Al=(o,e)=>yr(o,{label:e});b("context",yr);b("label",Al);class _r extends V{static get type(){return"VarNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:s}=this,n=e.getVarFromNode(this,s,e.getVectorType(this.getNodeType(e))),r=e.getPropertyName(n),i=t.build(e,n.type);return e.addLineFlowCode(`${r} = ${i}`,this),r}}const Oo=C(_r);b("toVar",(...o)=>Oo(...o).append());const Cl=o=>(console.warn('TSL: "temp" is deprecated. Use ".toVar()" instead.'),Oo(o));b("temp",Cl);class Vo extends V{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}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 n=this.name,r=this.getNodeType(e);t.varying=s=e.getVaryingFromNode(this,n,r),t.node=this.node}return s.needsInterpolation||(s.needsInterpolation=e.shaderStage==="fragment"),s}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),s=this.setupVarying(e);if(t.propertyName===void 0){const n=this.getNodeType(e),r=e.getPropertyName(s,Vn.VERTEX);e.flowNodeFromShaderStage(Vn.VERTEX,this.node,n,r),t.propertyName=r}return e.getPropertyName(s)}}const Qe=C(Vo);b("varying",Qe);const vl=M(([o])=>{const e=o.mul(.9478672986).add(.0521327014).pow(2.4),t=o.mul(.0773993808),s=o.lessThanEqual(.04045);return Z(e,t,s)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),El=M(([o])=>{const e=o.pow(.41666).mul(1.055).sub(.055),t=o.mul(12.92),s=o.lessThanEqual(.0031308);return Z(e,t,s)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),ls="WorkingColorSpace",Sr="OutputColorSpace";class ds extends ie{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===ls?c.ColorManagement.workingColorSpace:t===Sr?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,s=this.resolveColorSpace(e,this.source),n=this.resolveColorSpace(e,this.target);let r=t;return c.ColorManagement.enabled===!1||s===n||!s||!n||(c.ColorManagement.getTransfer(s)===c.SRGBTransfer&&(r=k(vl(r.rgb),r.a)),c.ColorManagement.getPrimaries(s)!==c.ColorManagement.getPrimaries(n)&&(r=k(Te(c.ColorManagement._getMatrix(new c.Matrix3,s,n)).mul(r.rgb),r.a)),c.ColorManagement.getTransfer(n)===c.SRGBTransfer&&(r=k(El(r.rgb),r.a))),r}}const Ml=o=>v(new ds(v(o),ls,Sr)),Bl=o=>v(new ds(v(o),Sr,ls)),Fl=(o,e)=>v(new ds(v(o),ls,e)),ko=(o,e)=>v(new ds(v(o),e,ls));b("toOutputColorSpace",Ml);b("toWorkingColorSpace",Bl);b("workingToColorSpace",Fl);b("colorSpaceToWorking",ko);let wl=class extends It{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(),n=this.getNodeType();return e.format(t,s,n)}};class zo extends V{static get type(){return"ReferenceBaseNode"}constructor(e,t,s=null,n=null){super(),this.property=e,this.uniformType=t,this.object=s,this.count=n,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 v(new wl(this,v(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 n=1;n<t.length;n++)s=s[t[n]];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 Ul=(o,e,t)=>v(new zo(o,e,t));class $o extends zo{static get type(){return"RendererReferenceNode"}constructor(e,t,s=null){super(e,t,s),this.renderer=s,this.setGroup(L)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const Gl=(o,e,t)=>v(new $o(o,e,t));class Wo extends ie{static get type(){return"ToneMappingNode"}constructor(e,t=Dl,s=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=s}getCacheKey(){return oo(super.getCacheKey(),this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,s=this.toneMapping;if(s===c.NoToneMapping)return t;let n=null;const r=e.renderer.library.getToneMappingFunction(s);return r!==null?n=k(r(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",s),n=t),n}}const Pl=(o,e,t)=>v(new Wo(o,v(e),v(t))),Dl=Gl("toneMappingExposure","float");b("toneMapping",(o,e,t)=>Pl(e,t,o));class Ho extends or{static get type(){return"BufferAttributeNode"}constructor(e,t=null,s=0,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=s,this.bufferOffset=n,this.usage=c.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,n=e.getTypeLength(t),r=this.bufferStride||n,i=this.bufferOffset,u=s.isInterleavedBuffer===!0?s:new c.InterleavedBuffer(s,r),a=new c.InterleavedBufferAttribute(u,n,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),n=e.getPropertyName(s);let r=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=n,r=n):r=Qe(this).build(e,t),r}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 Nr=(o,e,t,s)=>v(new Ho(o,e,t,s)),Il=(o,e,t,s)=>Nr(o,e,t,s).setUsage(c.DynamicDrawUsage),Zr=(o,e,t,s)=>Nr(o,e,t,s).setInstanced(!0),Jr=(o,e,t,s)=>Il(o,e,t,s).setInstanced(!0);b("toAttribute",o=>Nr(o.value));class qo 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.updateBeforeType=z.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let s=t[0];for(let n=1;n<t.length;n++)s*=t[n];this.dispatchCount=Math.ceil(e/s)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}generate(e){const{shaderStage:t}=e;if(t==="compute"){const s=this.computeNode.build(e,"void");s!==""&&e.addLineFlowCode(s,this)}}}const Ll=(o,e,t)=>v(new qo(v(o),e,t));b("compute",Ll);class Ko extends V{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){return this.node.getNodeType(e)}build(e,...t){const s=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);const r=this.node.build(e,...t);return e.setCache(s),r}}const ws=(o,...e)=>v(new Ko(v(o),...e));b("cache",ws);class Xo 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 Ol=C(Xo);b("bypass",Ol);class xr extends V{static get type(){return"RemapNode"}constructor(e,t,s,n=x(0),r=x(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=s,this.outLowNode=n,this.outHighNode=r,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:s,outLowNode:n,outHighNode:r,doClamp:i}=this;let u=e.sub(t).div(s.sub(t));return i===!0&&(u=u.clamp()),u.mul(r.sub(n)).add(n)}}const Vl=C(xr,null,null,{doClamp:!1}),kl=C(xr);b("remap",Vl);b("remapClamp",kl);class br extends V{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const s=this.getNodeType(e),n=this.snippet;if(s==="void")e.addLineFlowCode(n,this);else return e.format(`( ${n} )`,s,t)}}const is=C(br),zl=o=>(o?Se(o,is("discard")):is("discard")).append();b("discard",zl);class Yo extends ie{static get type(){return"RenderOutputNode"}constructor(e,t,s){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=s,this.isRenderOutput=!0}setup({context:e}){let t=this.colorNode||e.color;const s=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||c.NoToneMapping,n=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||c.NoColorSpace;return s!==c.NoToneMapping&&(t=t.toneMapping(s)),n!==c.NoColorSpace&&n!==c.ColorManagement.workingColorSpace&&(t=t.workingToColorSpace(n)),t}}const $l=(o,e=null,t=null)=>v(new Yo(v(o),e,t));b("renderOutput",$l);class Qo 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 n=e.geometry.getAttribute(s);t=e.getTypeFromAttribute(n)}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 r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),u=e.getAttribute(t,i);return e.shaderStage==="vertex"?e.format(u.name,i,s):Qe(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 Ye=(o,e)=>v(new Qo(o,e)),Qs=o=>Ye("uv"+(o>0?o:""),"vec2");class jo 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"),n=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${s}, ${n} )`,this.getNodeType(e),t)}}const Zt=C(jo);class Zo extends Lt{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:n,height:r}=s;this.value=Math.log2(Math.max(n,r))}}}const Wl=C(Zo);class Ot extends Lt{static get type(){return"TextureNode"}constructor(e,t=null,s=null,n=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=s,this.biasNode=n,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===c.UnsignedIntType?"uvec4":this.value.type===c.IntType?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Qs(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=O(this.value.matrix)),this._matrixUniform.mul(R(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?z.FRAME: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(te(Zt(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let s=this.uvNode;(s===null||e.context.forceUVContext===!0)&&e.context.getUV&&(s=e.context.getUV(this)),s||(s=this.getDefaultUV()),this.updateMatrix===!0&&(s=this.getTransformedUV(s)),s=this.setupUV(e,s);let n=this.levelNode;n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),t.uvNode=s,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,n,r,i,u,a){const l=this.value;let d;return n?d=e.generateTextureLevel(l,t,s,n,i):r?d=e.generateTextureBias(l,t,s,r,i):a?d=e.generateTextureGrad(l,t,s,a,i):u?d=e.generateTextureCompare(l,t,s,u,i):this.sampler===!1?d=e.generateTextureLoad(l,t,s,i):d=e.generateTexture(l,t,s,i),d}generate(e,t){const s=e.getNodeProperties(this),n=this.value;if(!n||n.isTexture!==!0)throw new Error("TextureNode: Need a three.js texture.");const r=super.generate(e,"property");if(t==="sampler")return r+"_sampler";if(e.isReference(t))return r;{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}=s,y=this.generateUV(e,d),S=h?h.build(e,"float"):null,A=p?p.build(e,"float"):null,E=g?g.build(e,"int"):null,D=f?f.build(e,"float"):null,w=m?[m[0].build(e,"vec2"),m[1].build(e,"vec2")]:null,U=e.getVarFromNode(this);u=e.getPropertyName(U);const G=this.generateSnippet(e,r,y,S,A,E,D,w);e.addLineFlowCode(`${u} = ${G}`,this),i.snippet=G,i.propertyName=u}let a=u;const l=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(a=ko(is(a,l),n.colorSpace).setup(e).build(e,l)),e.format(a,l,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){const t=this.clone();return t.uvNode=v(e),t.referenceNode=this.getSelf(),v(t)}blur(e){const t=this.clone();return t.biasNode=v(e).mul(Wl(t)),t.referenceNode=this.getSelf(),v(t)}level(e){const t=this.clone();return t.levelNode=v(e),t.referenceNode=this.getSelf(),v(t)}size(e){return Zt(this,e)}bias(e){const t=this.clone();return t.biasNode=v(e),t.referenceNode=this.getSelf(),v(t)}compare(e){const t=this.clone();return t.compareNode=v(e),t.referenceNode=this.getSelf(),v(t)}grad(e,t){const s=this.clone();return s.gradNode=[v(e),v(t)],s.referenceNode=this.getSelf(),v(s)}depth(e){const t=this.clone();return t.depthNode=v(e),t.referenceNode=this.getSelf(),v(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}}const H=C(Ot),Be=(...o)=>H(...o).setSampler(!1),dt=O("float").label("cameraNear").setGroup(L).onRenderUpdate(({camera:o})=>o.near),ht=O("float").label("cameraFar").setGroup(L).onRenderUpdate(({camera:o})=>o.far),$s=O("mat4").label("cameraProjectionMatrix").setGroup(L).onRenderUpdate(({camera:o})=>o.projectionMatrix),je=O("mat4").label("cameraViewMatrix").setGroup(L).onRenderUpdate(({camera:o})=>o.matrixWorldInverse),Hl=O(new c.Vector3).label("cameraPosition").setGroup(L).onRenderUpdate(({camera:o},e)=>e.value.setFromMatrixPosition(o.matrixWorld));class W 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 Lt(null)}getNodeType(){const e=this.scope;if(e===W.WORLD_MATRIX)return"mat4";if(e===W.POSITION||e===W.VIEW_POSITION||e===W.DIRECTION||e===W.SCALE)return"vec3"}update(e){const t=this.object3d,s=this._uniformNode,n=this.scope;if(n===W.WORLD_MATRIX)s.value=t.matrixWorld;else if(n===W.POSITION)s.value=s.value||new c.Vector3,s.value.setFromMatrixPosition(t.matrixWorld);else if(n===W.SCALE)s.value=s.value||new c.Vector3,s.value.setFromMatrixScale(t.matrixWorld);else if(n===W.DIRECTION)s.value=s.value||new c.Vector3,t.getWorldDirection(s.value);else if(n===W.VIEW_POSITION){const r=e.camera;s.value=s.value||new c.Vector3,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(r.matrixWorldInverse)}}generate(e){const t=this.scope;return t===W.WORLD_MATRIX?this._uniformNode.nodeType="mat4":(t===W.POSITION||t===W.VIEW_POSITION||t===W.DIRECTION||t===W.SCALE)&&(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}W.WORLD_MATRIX="worldMatrix";W.POSITION="position";W.SCALE="scale";W.VIEW_POSITION="viewPosition";W.DIRECTION="direction";W.DIRECTION;W.WORLD_MATRIX;const ql=C(W,W.POSITION);W.SCALE;W.VIEW_POSITION;class Ue extends W{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}Ue.DIRECTION;const Tt=B(Ue,Ue.WORLD_MATRIX);Ue.POSITION;Ue.SCALE;Ue.VIEW_POSITION;const Kl=O(new c.Matrix3).onObjectUpdate(({object:o},e)=>e.value.getNormalMatrix(o.matrixWorld)),js=je.mul(Tt).toVar("modelViewMatrix"),Jo=Ye("position","vec3"),fe=Jo.varying("positionLocal"),ei=Jo.varying("positionPrevious"),os=Tt.mul(fe).xyz.varying("v_positionWorld"),ea=fe.transformDirection(Tt).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),de=js.mul(fe).xyz.varying("v_positionView"),ee=de.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class ta extends V{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:s}=e;return t.coordinateSystem===c.WebGLCoordinateSystem&&s.side===c.BackSide?"false":e.getFrontFacing()}}const Xl=B(ta),Zs=x(Xl).mul(2).sub(1),sa=Ye("normal","vec3"),Le=M(o=>o.geometry.hasAttribute("normal")===!1?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),R(0,1,0)):sa,"vec3").once()().toVar("normalLocal"),Yl=de.dFdx().cross(de.dFdy()).normalize().toVar("normalFlat"),Ge=M(o=>{let e;return o.material.flatShading===!0?e=Yl:e=Qe(ra(Le),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),na=Qe(Ge.transformDirection(je),"v_normalWorld").normalize().toVar("normalWorld"),ue=M(o=>o.context.setupNormal(),"vec3").once()().mul(Zs).toVar("transformedNormalView"),Rr=ue.transformDirection(je).toVar("transformedNormalWorld"),Yt=M(o=>o.context.setupClearcoatNormal(),"vec3").once()().mul(Zs).toVar("transformedClearcoatNormalView"),Ql=M(([o,e=Tt])=>{const t=Te(e),s=o.div(R(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(s).xyz}),ra=M(([o],e)=>{const t=e.renderer.nodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(o);const s=Kl.mul(o);return je.transformDirection(s)}),jl=O(0).onReference(({material:o})=>o).onRenderUpdate(({material:o})=>o.refractionRatio),Zl=ee.negate().reflect(ue),Jl=ee.negate().refract(ue,jl),ed=Zl.transformDirection(je).toVar("reflectVector"),td=Jl.transformDirection(je).toVar("reflectVector");class ia extends Ot{static get type(){return"CubeTextureNode"}constructor(e,t=null,s=null,n=null){super(e,t,s,n),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===c.CubeReflectionMapping?ed:e.mapping===c.CubeRefractionMapping?td:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),R(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const s=this.value;return e.renderer.coordinateSystem===c.WebGPUCoordinateSystem||!s.isRenderTargetTexture?R(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,"vec3")}}const as=C(ia);class Ar extends Lt{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 Cr=(o,e,t)=>v(new Ar(o,e,t));class sd extends It{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),s=this.getNodeType();return e.format(t,"vec4",s)}}class oa extends Ar{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null,"vec4"),this.array=e,this.elementType=t,this._elementType=null,this._elementLength=0,this.updateType=z.RENDER,this.isArrayBufferNode=!0}getElementType(){return this.elementType||this._elementType}getElementLength(){return this._elementLength}update(){const{array:e,value:t}=this,s=this.getElementLength(),n=this.getElementType();if(s===1)for(let r=0;r<e.length;r++){const i=r*4;t[i]=e[r]}else if(n==="color")for(let r=0;r<e.length;r++){const i=r*4,u=e[r];t[i]=u.r,t[i+1]=u.g,t[i+2]=u.b||0}else for(let r=0;r<e.length;r++){const i=r*4,u=e[r];t[i]=u.x,t[i+1]=u.y,t[i+2]=u.z||0,t[i+3]=u.w||0}}setup(e){const t=this.array.length;this._elementType=this.elementType===null?Ds(this.array[0]):this.elementType,this._elementLength=e.getTypeLength(this._elementType);let s=Float32Array;return this._elementType.charAt(0)==="i"?s=Int32Array:this._elementType.charAt(0)==="u"&&(s=Uint32Array),this.value=new s(t*4),this.bufferCount=t,this.bufferType=e.changeComponentType("vec4",e.getComponentType(this._elementType)),super.setup(e)}element(e){return v(new sd(this,v(e)))}}const tt=(o,e)=>v(new oa(o,e));class nd extends It{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(),n=this.getNodeType();return e.format(t,s,n)}}class Js extends V{static get type(){return"ReferenceNode"}constructor(e,t,s=null,n=null){super(),this.property=e,this.uniformType=t,this.object=s,this.count=n,this.properties=e.split("."),this.reference=s,this.node=null,this.group=null,this.name=null,this.updateType=z.OBJECT}element(e){return v(new nd(this,v(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;this.count!==null?t=Cr(null,e,this.count):Array.isArray(this.getValueFromReference())?t=tt(null,e):e==="texture"?t=H(null):e==="cubeTexture"?t=as(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 n=1;n<t.length;n++)s=s[t[n]];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 Y=(o,e,t)=>v(new Js(o,e,t)),ti=(o,e,t,s)=>v(new Js(o,e,s,t));class aa extends Js{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 st=(o,e,t)=>v(new aa(o,e,t)),ua=M(o=>(o.geometry.hasAttribute("tangent")===!1&&o.geometry.computeTangents(),Ye("tangent","vec4")))(),vr=ua.xyz.toVar("tangentLocal"),ca=js.mul(k(vr,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),rd=o=>o.mul(ua.w).xyz,id=Qe(rd(Ge.cross(ca)),"v_bitangentView").normalize().toVar("bitangentView"),Qt=Te(ca,id,Ge),od=(()=>{let o=Ut.cross(ee);return o=o.cross(Ut).normalize(),o=Z(o,ue,ct.mul(He.oneMinus()).oneMinus().pow2().pow2()).normalize(),o})(),ad=M(o=>{const{eye_pos:e,surf_norm:t,mapN:s,uv:n}=o,r=e.dFdx(),i=e.dFdy(),u=n.dFdx(),a=n.dFdy(),l=t,d=i.cross(l),h=l.cross(r),p=d.mul(u.x).add(h.mul(a.x)),f=d.mul(u.y).add(h.mul(a.y)),g=p.dot(p).max(f.dot(f)),m=Zs.mul(g.inverseSqrt());return ye(p.mul(s.x,m),f.mul(s.y,m),l.mul(s.z)).normalize()});class la extends ie{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=c.TangentSpaceNormalMap}setup(e){const{normalMapType:t,scaleNode:s}=this;let n=this.node.mul(2).sub(1);s!==null&&(n=R(n.xy.mul(s),n.z));let r=null;return t===c.ObjectSpaceNormalMap?r=ra(n):t===c.TangentSpaceNormalMap&&(e.hasGeometryAttribute("tangent")===!0?r=Qt.mul(n).normalize():r=ad({eye_pos:de,surf_norm:Ge,mapN:n,uv:Qs()})),r}}const si=C(la),ud=M(({textureNode:o,bumpScale:e})=>{const t=n=>o.cache().context({getUV:r=>n(r.uvNode||Qs()),forceUVContext:!0}),s=x(t(n=>n));return F(x(t(n=>n.add(n.dFdx()))).sub(s),x(t(n=>n.add(n.dFdy()))).sub(s)).mul(e)}),cd=M(o=>{const{surf_pos:e,surf_norm:t,dHdxy:s}=o,n=e.dFdx().normalize(),r=e.dFdy().normalize(),i=t,u=r.cross(i),a=i.cross(n),l=n.dot(u).mul(Zs),d=l.sign().mul(s.x.mul(u).add(s.y.mul(a)));return l.abs().mul(t).sub(d).normalize()});class da extends ie{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=ud({textureNode:this.textureNode,bumpScale:e});return cd({surf_pos:de,surf_norm:Ge,dHdxy:t})}}const ld=C(da),ni=new Map;class N extends V{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let s=ni.get(e);return s===void 0&&(s=st(e,t),ni.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 n=null;if(s===N.COLOR){const r=t.color!==void 0?this.getColor(s):R();t.map&&t.map.isTexture===!0?n=r.mul(this.getTexture("map")):n=r}else if(s===N.OPACITY){const r=this.getFloat(s);t.alphaMap&&t.alphaMap.isTexture===!0?n=r.mul(this.getTexture("alpha")):n=r}else if(s===N.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?n=this.getTexture("specular").r:n=x(1);else if(s===N.SPECULAR_INTENSITY){const r=this.getFloat(s);t.specularMap?n=r.mul(this.getTexture(s).a):n=r}else if(s===N.SPECULAR_COLOR){const r=this.getColor(s);t.specularColorMap&&t.specularColorMap.isTexture===!0?n=r.mul(this.getTexture(s).rgb):n=r}else if(s===N.ROUGHNESS){const r=this.getFloat(s);t.roughnessMap&&t.roughnessMap.isTexture===!0?n=r.mul(this.getTexture(s).g):n=r}else if(s===N.METALNESS){const r=this.getFloat(s);t.metalnessMap&&t.metalnessMap.isTexture===!0?n=r.mul(this.getTexture(s).b):n=r}else if(s===N.EMISSIVE){const r=this.getFloat("emissiveIntensity"),i=this.getColor(s).mul(r);t.emissiveMap&&t.emissiveMap.isTexture===!0?n=i.mul(this.getTexture(s)):n=i}else if(s===N.NORMAL)t.normalMap?(n=si(this.getTexture("normal"),this.getCache("normalScale","vec2")),n.normalMapType=t.normalMapType):t.bumpMap?n=ld(this.getTexture("bump").r,this.getFloat("bumpScale")):n=Ge;else if(s===N.CLEARCOAT){const r=this.getFloat(s);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?n=r.mul(this.getTexture(s).r):n=r}else if(s===N.CLEARCOAT_ROUGHNESS){const r=this.getFloat(s);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?n=r.mul(this.getTexture(s).r):n=r}else if(s===N.CLEARCOAT_NORMAL)t.clearcoatNormalMap?n=si(this.getTexture(s),this.getCache(s+"Scale","vec2")):n=Ge;else if(s===N.SHEEN){const r=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?n=r.mul(this.getTexture("sheenColor").rgb):n=r}else if(s===N.SHEEN_ROUGHNESS){const r=this.getFloat(s);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?n=r.mul(this.getTexture(s).a):n=r,n=n.clamp(.07,1)}else if(s===N.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const r=this.getTexture(s);n=lr(Vt.x,Vt.y,Vt.y.negate(),Vt.x).mul(r.rg.mul(2).sub(F(1)).normalize().mul(r.b))}else n=Vt;else if(s===N.IRIDESCENCE_THICKNESS){const r=Y("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const i=Y("0","float",t.iridescenceThicknessRange);n=r.sub(i).mul(this.getTexture(s).g).add(i)}else n=r}else if(s===N.TRANSMISSION){const r=this.getFloat(s);t.transmissionMap?n=r.mul(this.getTexture(s).r):n=r}else if(s===N.THICKNESS){const r=this.getFloat(s);t.thicknessMap?n=r.mul(this.getTexture(s).g):n=r}else if(s===N.IOR)n=this.getFloat(s);else if(s===N.LIGHT_MAP)n=this.getTexture(s).rgb.mul(this.getFloat("lightMapIntensity"));else if(s===N.AO_MAP)n=this.getTexture(s).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const r=this.getNodeType(e);n=this.getCache(s,r)}return n}}N.ALPHA_TEST="alphaTest";N.COLOR="color";N.OPACITY="opacity";N.SHININESS="shininess";N.SPECULAR="specular";N.SPECULAR_STRENGTH="specularStrength";N.SPECULAR_INTENSITY="specularIntensity";N.SPECULAR_COLOR="specularColor";N.REFLECTIVITY="reflectivity";N.ROUGHNESS="roughness";N.METALNESS="metalness";N.NORMAL="normal";N.CLEARCOAT="clearcoat";N.CLEARCOAT_ROUGHNESS="clearcoatRoughness";N.CLEARCOAT_NORMAL="clearcoatNormal";N.EMISSIVE="emissive";N.ROTATION="rotation";N.SHEEN="sheen";N.SHEEN_ROUGHNESS="sheenRoughness";N.ANISOTROPY="anisotropy";N.IRIDESCENCE="iridescence";N.IRIDESCENCE_IOR="iridescenceIOR";N.IRIDESCENCE_THICKNESS="iridescenceThickness";N.IOR="ior";N.TRANSMISSION="transmission";N.THICKNESS="thickness";N.ATTENUATION_DISTANCE="attenuationDistance";N.ATTENUATION_COLOR="attenuationColor";N.LINE_SCALE="scale";N.LINE_DASH_SIZE="dashSize";N.LINE_GAP_SIZE="gapSize";N.LINE_WIDTH="linewidth";N.LINE_DASH_OFFSET="dashOffset";N.POINT_WIDTH="pointWidth";N.DISPERSION="dispersion";N.LIGHT_MAP="light";N.AO_MAP="ao";const dd=B(N,N.ALPHA_TEST),hd=B(N,N.COLOR),pd=B(N,N.SHININESS),fd=B(N,N.EMISSIVE),ha=B(N,N.OPACITY),gd=B(N,N.SPECULAR),ri=B(N,N.SPECULAR_INTENSITY),md=B(N,N.SPECULAR_COLOR),Us=B(N,N.SPECULAR_STRENGTH),un=B(N,N.REFLECTIVITY),Td=B(N,N.ROUGHNESS),yd=B(N,N.METALNESS),_d=B(N,N.NORMAL).context({getUV:null}),Sd=B(N,N.CLEARCOAT),Nd=B(N,N.CLEARCOAT_ROUGHNESS),xd=B(N,N.CLEARCOAT_NORMAL).context({getUV:null}),bd=B(N,N.ROTATION),Rd=B(N,N.SHEEN),Ad=B(N,N.SHEEN_ROUGHNESS),Cd=B(N,N.ANISOTROPY),vd=B(N,N.IRIDESCENCE),Ed=B(N,N.IRIDESCENCE_IOR),Md=B(N,N.IRIDESCENCE_THICKNESS),Bd=B(N,N.TRANSMISSION),Fd=B(N,N.THICKNESS),wd=B(N,N.IOR),Ud=B(N,N.ATTENUATION_DISTANCE),Gd=B(N,N.ATTENUATION_COLOR),Pd=B(N,N.LINE_SCALE),Dd=B(N,N.LINE_DASH_SIZE),Id=B(N,N.LINE_GAP_SIZE);N.LINE_WIDTH;const Ld=B(N,N.LINE_DASH_OFFSET);N.POINT_WIDTH;const Od=B(N,N.DISPERSION),pa=B(N,N.LIGHT_MAP),Vd=B(N,N.AO_MAP),Vt=O(new c.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))});class fa extends ie{static get type(){return"ModelViewProjectionNode"}constructor(e=null){super("vec4"),this.positionNode=e}setup(e){if(e.shaderStage==="fragment")return Qe(e.context.mvp);const t=this.positionNode||fe,s=e.renderer.nodes.modelViewMatrix||js;return $s.mul(s).mul(t)}}const ga=C(fa);class j extends V{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isInstanceIndexNode=!0}generate(e){const t=this.getNodeType(e),s=this.scope;let n;if(s===j.VERTEX)n=e.getVertexIndex();else if(s===j.INSTANCE)n=e.getInstanceIndex();else if(s===j.DRAW)n=e.getDrawIndex();else if(s===j.INVOCATION_LOCAL)n=e.getInvocationLocalIndex();else if(s===j.INVOCATION_SUBGROUP)n=e.getInvocationSubgroupIndex();else if(s===j.SUBGROUP)n=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+s);let r;return e.shaderStage==="vertex"||e.shaderStage==="compute"?r=n:r=Qe(this).build(e,t),r}}j.VERTEX="vertex";j.INSTANCE="instance";j.SUBGROUP="subgroup";j.INVOCATION_LOCAL="invocationLocal";j.INVOCATION_SUBGROUP="invocationSubgroup";j.DRAW="draw";const kd=B(j,j.VERTEX),Er=B(j,j.INSTANCE);j.SUBGROUP;j.INVOCATION_SUBGROUP;j.INVOCATION_LOCAL;const zd=B(j,j.DRAW);class ma extends V{static get type(){return"InstanceNode"}constructor(e,t,s){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:n}=this;let{instanceMatrixNode:r,instanceColorNode:i}=this;if(r===null){if(t<=1e3)r=Cr(s.array,"mat4",Math.max(t,1)).element(Er);else{const a=new c.InstancedInterleavedBuffer(s.array,16,1);this.buffer=a;const l=s.usage===c.DynamicDrawUsage?Jr:Zr,d=[l(a,"vec4",16,0),l(a,"vec4",16,4),l(a,"vec4",16,8),l(a,"vec4",16,12)];r=wt(...d)}this.instanceMatrixNode=r}if(n&&i===null){const a=new c.InstancedBufferAttribute(n.array,3),l=n.usage===c.DynamicDrawUsage?Jr:Zr;this.bufferColor=a,i=R(l(a,"vec3",3,0)),this.instanceColorNode=i}const u=r.mul(fe).xyz;if(fe.assign(u),e.hasGeometryAttribute("normal")){const a=Ql(Le,r);Le.assign(a)}this.instanceColorNode!==null&&Ls("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==c.DynamicDrawUsage&&this.buffer!=null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==c.DynamicDrawUsage&&this.bufferColor!=null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}class Ta extends ma{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:s,instanceColor:n}=e;super(t,s,n),this.instanceMesh=e}}const $d=C(Ta);class ya 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=Er:this.batchingIdNode=zd);const s=M(([g])=>{const m=Zt(Be(this.batchMesh._indirectTexture),0),y=te(g).modInt(te(m)),S=te(g).div(te(m));return Be(this.batchMesh._indirectTexture,We(y,S)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(te(this.batchingIdNode)),n=this.batchMesh._matricesTexture,r=Zt(Be(n),0),i=x(s).mul(4).toInt().toVar(),u=i.modInt(r),a=i.div(te(r)),l=wt(Be(n,We(u,a)),Be(n,We(u.add(1),a)),Be(n,We(u.add(2),a)),Be(n,We(u.add(3),a))),d=this.batchMesh._colorsTexture;if(d!==null){const m=M(([y])=>{const S=Zt(Be(d),0).x,A=y,E=A.modInt(S),D=A.div(S);return Be(d,We(E,D)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(s);Ls("vec3","vBatchColor").assign(m)}const h=Te(l);fe.assign(l.mul(fe));const p=Le.div(R(h[0].dot(h[0]),h[1].dot(h[1]),h[2].dot(h[2]))),f=h.mul(p).xyz;Le.assign(f),e.hasGeometryAttribute("tangent")&&vr.mulAssign(h)}}const Wd=C(ya),ii=new WeakMap;class _a extends V{static get type(){return"SkinningNode"}constructor(e,t=!1){super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=z.OBJECT,this.skinIndexNode=Ye("skinIndex","uvec4"),this.skinWeightNode=Ye("skinWeight","vec4");let s,n,r;t?(s=Y("bindMatrix","mat4"),n=Y("bindMatrixInverse","mat4"),r=ti("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(s=O(e.bindMatrix,"mat4"),n=O(e.bindMatrixInverse,"mat4"),r=Cr(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=s,this.bindMatrixInverseNode=n,this.boneMatricesNode=r,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=fe){const{skinIndexNode:s,skinWeightNode:n,bindMatrixNode:r,bindMatrixInverseNode:i}=this,u=e.element(s.x),a=e.element(s.y),l=e.element(s.z),d=e.element(s.w),h=r.mul(t),p=ye(u.mul(n.x).mul(h),a.mul(n.y).mul(h),l.mul(n.z).mul(h),d.mul(n.w).mul(h));return i.mul(p).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=Le){const{skinIndexNode:s,skinWeightNode:n,bindMatrixNode:r,bindMatrixInverseNode:i}=this,u=e.element(s.x),a=e.element(s.y),l=e.element(s.z),d=e.element(s.w);let h=ye(n.x.mul(u),n.y.mul(a),n.z.mul(l),n.w.mul(d));return h=i.mul(h).mul(r),h.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=ti("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,ei)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")}setup(e){this.needsPreviousBoneMatrices(e)&&ei.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(fe.assign(t),e.hasGeometryAttribute("normal")){const s=this.getSkinnedNormal();Le.assign(s),e.hasGeometryAttribute("tangent")&&vr.assign(s)}}generate(e,t){if(t!=="void")return fe.build(e,t)}update(e){const s=(this.useReference?e.object:this.skinnedMesh).skeleton;ii.get(s)!==e.frameId&&(ii.set(s,e.frameId),this.previousBoneMatricesNode!==null&&s.previousBoneMatrices.set(s.boneMatrices),s.update())}}const Hd=o=>v(new _a(o,!0));class Sa 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 r=0,i=this.params.length-1;r<i;r++){const u=this.params[r],a=u.isNode!==!0&&u.name||this.getVarName(r),l=u.isNode!==!0&&u.type||"int";s[a]=is(a,l)}const n=e.addStack();return t.returnsNode=this.params[this.params.length-1](s,n,e),t.stackNode=n,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,n=t.stackNode;for(let u=0,a=s.length-1;u<a;u++){const l=s[u];let d=null,h=null,p=null,f=null,g=null,m=null;l.isNode?(f="int",p=this.getVarName(u),d="0",h=l.build(e,f),g="<"):(f=l.type||"int",p=l.name||this.getVarName(u),d=l.start,h=l.end,g=l.condition,m=l.update,typeof d=="number"?d=e.generateConst(f,d):d&&d.isNode&&(d=d.build(e,f)),typeof h=="number"?h=e.generateConst(f,h):h&&h.isNode&&(h=h.build(e,f)),d!==void 0&&h===void 0?(d=d+" - 1",h="0",g=">="):h!==void 0&&d===void 0&&(d="0",g="<"),g===void 0&&(Number(d)>Number(h)?g=">=":g="<"));const y={start:d,end:h},S=y.start,A=y.end;let E="",D="",w="";m||(f==="int"||f==="uint"?g.includes("<")?m="++":m="--":g.includes("<")?m="+= 1.":m="-= 1."),E+=e.getVar(f,p)+" = "+S,D+=p+" "+g+" "+A,w+=p+" "+m;const U=`for ( ${E}; ${D}; ${w} )`;e.addFlowCode((u===0?`
19
+ `:"")+e.tab+U+` {
20
+
21
+ `).addFlowTab()}const r=n.build(e,"void"),i=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(`
22
+ `+e.tab+r);for(let u=0,a=this.params.length-1;u<a;u++)e.addFlowCode((u===0?"":e.tab)+`}
23
+
24
+ `).removeFlowTab();return e.addFlowTab(),i}}const we=(...o)=>v(new Sa(Ft(o,"int"))).append(),qd=()=>is("break").append(),cn=new WeakMap,Re=new c.Vector4,oi=M(({bufferMap:o,influence:e,stride:t,width:s,depth:n,offset:r})=>{const i=te(kd).mul(t).add(r),u=i.div(s),a=i.sub(u.mul(s));return Be(o,We(a,u)).depth(n).mul(e)});function Kd(o){const e=o.morphAttributes.position!==void 0,t=o.morphAttributes.normal!==void 0,s=o.morphAttributes.color!==void 0,n=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,r=n!==void 0?n.length:0;let i=cn.get(o);if(i===void 0||i.count!==r){let S=function(){m.dispose(),cn.delete(o),o.removeEventListener("dispose",S)};i!==void 0&&i.texture.dispose();const u=o.morphAttributes.position||[],a=o.morphAttributes.normal||[],l=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*r),m=new c.DataArrayTexture(g,h,p,r);m.type=c.FloatType,m.needsUpdate=!0;const y=d*4;for(let A=0;A<r;A++){const E=u[A],D=a[A],w=l[A],U=h*p*4*A;for(let G=0;G<E.count;G++){const P=G*y;e===!0&&(Re.fromBufferAttribute(E,G),g[U+P+0]=Re.x,g[U+P+1]=Re.y,g[U+P+2]=Re.z,g[U+P+3]=0),t===!0&&(Re.fromBufferAttribute(D,G),g[U+P+4]=Re.x,g[U+P+5]=Re.y,g[U+P+6]=Re.z,g[U+P+7]=0),s===!0&&(Re.fromBufferAttribute(w,G),g[U+P+8]=Re.x,g[U+P+9]=Re.y,g[U+P+10]=Re.z,g[U+P+11]=w.itemSize===4?Re.w:1)}}i={count:r,texture:m,stride:d,size:new c.Vector2(h,p)},cn.set(o,i),o.addEventListener("dispose",S)}return i}class Na 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,n=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,r=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,i=r!==void 0?r.length:0,{texture:u,stride:a,size:l}=Kd(t);s===!0&&fe.mulAssign(this.morphBaseInfluence),n===!0&&Le.mulAssign(this.morphBaseInfluence);const d=te(l.width);we(i,({i:h})=>{const p=x(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?p.assign(Be(this.mesh.morphTexture,We(te(h).add(1),te(Er))).r):p.assign(Y("morphTargetInfluences","float").element(h).toVar()),s===!0&&fe.addAssign(oi({bufferMap:u,influence:p,stride:a,width:d,depth:h,offset:te(0)})),n===!0&&Le.addAssign(oi({bufferMap:u,influence:p,stride:a,width:d,depth:h,offset:te(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 Xd=C(Na);class _t extends V{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}generate(){console.warn("Abstract function.")}}class xa extends _t{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class ba extends Tr{static get type(){return"LightingContextNode"}constructor(e,t=null,s=null,n=null){super(e),this.lightingModel=t,this.backdropNode=s,this.backdropAlphaNode=n,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,s=R().toVar("directDiffuse"),n=R().toVar("directSpecular"),r=R().toVar("indirectDiffuse"),i=R().toVar("indirectSpecular"),u={directDiffuse:s,directSpecular:n,indirectDiffuse:r,indirectSpecular:i};return{radiance:R().toVar("radiance"),irradiance:R().toVar("irradiance"),iblIrradiance:R().toVar("iblIrradiance"),ambientOcclusion:x(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 Yd=C(ba);class Ra extends _t{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let kt,zt;class ne extends V{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===ne.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=z.NONE;return(this.scope===ne.SIZE||this.scope===ne.VIEWPORT)&&(e=z.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===ne.VIEWPORT?t!==null?zt.copy(t.viewport):(e.getViewport(zt),zt.multiplyScalar(e.getPixelRatio())):t!==null?(kt.width=t.width,kt.height=t.height):e.getDrawingBufferSize(kt)}setup(){const e=this.scope;let t=null;return e===ne.SIZE?t=O(kt||(kt=new c.Vector2)):e===ne.VIEWPORT?t=O(zt||(zt=new c.Vector4)):t=F(en.div(Yn)),t}generate(e){if(this.scope===ne.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const s=e.getNodeProperties(Yn).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${s}.y - ${t}.y )`}return t}return super.generate(e)}}ne.COORDINATE="coordinate";ne.VIEWPORT="viewport";ne.SIZE="size";ne.UV="uv";const us=B(ne,ne.UV),Yn=B(ne,ne.SIZE),en=B(ne,ne.COORDINATE),Aa=B(ne,ne.VIEWPORT);Aa.zw;Aa.xy;const $t=new c.Vector2;class Mr extends Ot{static get type(){return"ViewportTextureNode"}constructor(e=us,t=null,s=null){s===null&&(s=new c.FramebufferTexture,s.minFilter=c.LinearMipmapLinearFilter),super(s,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=z.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize($t);const s=this.value;(s.image.width!==$t.width||s.image.height!==$t.height)&&(s.image.width=$t.width,s.image.height=$t.height,s.needsUpdate=!0);const n=s.generateMipmaps;s.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(s),s.generateMipmaps=n}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Ca=C(Mr,null,null,{generateMipmaps:!0});let ln=null;class va extends Mr{static get type(){return"ViewportDepthTextureNode"}constructor(e=us,t=null){ln===null&&(ln=new c.DepthTexture),super(e,t,ln)}}const Qd=C(va);class ge 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===ge.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,s=this.valueNode;let n=null;if(t===ge.DEPTH_BASE)s!==null&&(n=Ba().assign(s));else if(t===ge.DEPTH)e.isPerspectiveCamera?n=jd(de.z,dt,ht):n=Jt(de.z,dt,ht);else if(t===ge.LINEAR_DEPTH)if(s!==null)if(e.isPerspectiveCamera){const r=Ea(s,dt,ht);n=Jt(r,dt,ht)}else n=s;else n=Jt(de.z,dt,ht);return n}}ge.DEPTH_BASE="depthBase";ge.DEPTH="depth";ge.LINEAR_DEPTH="linearDepth";const Jt=(o,e,t)=>o.add(e).div(e.sub(t)),jd=(o,e,t)=>e.add(o).mul(t).div(t.sub(e).mul(o)),Ea=(o,e,t)=>e.mul(t).div(t.sub(e).mul(o).sub(t)),Ma=(o,e,t)=>{e=e.max(1e-6).toVar();const s=qe(o.negate().div(e)),n=qe(t.div(e));return s.div(n)},Ba=C(ge,ge.DEPTH_BASE),Fa=B(ge,ge.DEPTH),Zd=C(ge,ge.LINEAR_DEPTH);Qd();Fa.assign=o=>Ba(o);class Jd extends V{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const eh=C(Jd);class Me extends V{static get type(){return"ClippingNode"}constructor(e=Me.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:s,unionPlanes:n}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===Me.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(s,n):this.scope===Me.HARDWARE?this.setupHardwareClipping(n,e):this.setupDefault(s,n)}setupAlphaToCoverage(e,t){return M(()=>{const s=x().toVar("distanceToPlane"),n=x().toVar("distanceToGradient"),r=x(1).toVar("clipOpacity"),i=t.length;if(!this.hardwareClipping&&i>0){const a=tt(t);we(i,({i:l})=>{const d=a.element(l);s.assign(de.dot(d.xyz).negate().add(d.w)),n.assign(s.fwidth().div(2)),r.mulAssign(mt(n.negate(),n,s))})}const u=e.length;if(u>0){const a=tt(e),l=x(1).toVar("intersectionClipOpacity");we(u,({i:d})=>{const h=a.element(d);s.assign(de.dot(h.xyz).negate().add(h.w)),n.assign(s.fwidth().div(2)),l.mulAssign(mt(n.negate(),n,s).oneMinus())}),r.mulAssign(l.oneMinus())}q.a.mulAssign(r),q.a.equal(0).discard()})()}setupDefault(e,t){return M(()=>{const s=t.length;if(!this.hardwareClipping&&s>0){const r=tt(t);we(s,({i})=>{const u=r.element(i);de.dot(u.xyz).greaterThan(u.w).discard()})}const n=e.length;if(n>0){const r=tt(e),i=To(!0).toVar("clipped");we(n,({i:u})=>{const a=r.element(u);i.assign(de.dot(a.xyz).greaterThan(a.w).and(i))}),i.discard()}})()}setupHardwareClipping(e,t){const s=e.length;return t.enableHardwareClipping(s),M(()=>{const n=tt(e),r=eh(t.getClipDistance());we(s,({i})=>{const u=n.element(i),a=de.dot(u.xyz).sub(u.w).negate();r.element(i).assign(a)})})()}}Me.ALPHA_TO_COVERAGE="alphaToCoverage";Me.DEFAULT="default";Me.HARDWARE="hardware";const th=()=>v(new Me),sh=()=>v(new Me(Me.ALPHA_TO_COVERAGE)),nh=()=>v(new Me(Me.HARDWARE)),rh=.05,ai=M(([o])=>it($(1e4,Fe($(17,o.x).add($(.1,o.y)))).mul(ye(.1,Ee(Fe($(13,o.y).add(o.x))))))),ui=M(([o])=>ai(F(ai(o.xy),o.z))),ih=M(([o])=>{const e=Ne(rt(wo(o.xyz)),rt(Uo(o.xyz))),t=x(1).div(x(rh).mul(e)).toVar("pixScale"),s=F(ss(gt(qe(t))),ss(gr(qe(t)))),n=F(ui(gt(s.x.mul(o.xyz))),ui(gt(s.y.mul(o.xyz)))),r=it(qe(t)),i=ye($(r.oneMinus(),n.x),$(r,n.y)),u=rs(r,r.oneMinus()),a=R(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))))),l=i.lessThan(u.oneMinus()).select(i.lessThan(u).select(a.x,a.y),a.z);return Xe(l,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class re extends c.Material{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.forceSinglePass=!1,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.positionNode=null,this.geometryNode=null,this.depthNode=null,this.shadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+ao(this)}build(e){this.setup(e)}setupObserver(e){return new ro(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e);const t=e.renderer,s=t.getRenderTarget();e.addStack(),e.stack.outputNode=this.vertexNode||this.setupPosition(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let n;const r=this.setupClipping(e);if(this.depthWrite===!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 i=this.setupLighting(e);r!==null&&e.stack.add(r);const u=k(i,q.a).max(0);if(n=this.setupOutput(e,u),Ac.assign(n),this.outputNode!==null&&(n=this.outputNode),s!==null){const a=t.getMRT(),l=this.mrtNode;a!==null?(n=a,l!==null&&(n=a.merge(l))):l!==null&&(n=l)}}else{let i=this.fragmentNode;i.isOutputStructNode!==!0&&(i=k(i)),n=this.setupOutput(e,i)}e.stack.outputNode=n,e.addFlow("fragment",e.removeStack()),e.monitor=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:s}=e.clippingContext;let n=null;if(t.length>0||s.length>0){const r=e.renderer.samples;this.alphaToCoverage&&r>1?n=sh():e.stack.add(th())}return n}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(nh()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:s}=e;let n=this.depthNode;if(n===null){const r=t.getMRT();r&&r.has("depth")?n=r.get("depth"):t.logarithmicDepthBuffer===!0&&(s.isPerspectiveCamera?n=Ma(de.z,dt,ht):n=Jt(de.z,dt,ht))}n!==null&&Fa.assign(n).append()}setupPosition(e){const{object:t}=e,s=t.geometry;if(e.addStack(),(s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color)&&Xd(t).append(),t.isSkinnedMesh===!0&&Hd(t).append(),this.displacementMap){const r=st("displacementMap","texture"),i=st("displacementScale","float"),u=st("displacementBias","float");fe.addAssign(Le.normalize().mul(r.x.mul(i).add(u)))}t.isBatchedMesh&&Wd(t).append(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&$d(t).append(),this.positionNode!==null&&fe.assign(this.positionNode),this.setupHardwareClipping(e);const n=ga();return e.context.vertex=e.removeStack(),e.context.mvp=n,n}setupDiffuseColor({object:e,geometry:t}){let s=this.colorNode?k(this.colorNode):hd;this.vertexColors===!0&&t.hasAttribute("color")&&(s=k(s.xyz.mul(Ye("color","vec3")),s.a)),e.instanceColor&&(s=Ls("vec3","vInstanceColor").mul(s)),e.isBatchedMesh&&e._colorsTexture&&(s=Ls("vec3","vBatchColor").mul(s)),q.assign(s);const n=this.opacityNode?x(this.opacityNode):ha;if(q.a.assign(q.a.mul(n)),this.alphaTestNode!==null||this.alphaTest>0){const r=this.alphaTestNode!==null?x(this.alphaTestNode):dd;q.a.lessThanEqual(r).discard()}this.alphaHash===!0&&q.a.lessThan(ih(fe)).discard(),this.transparent===!1&&this.blending===c.NormalBlending&&this.alphaToCoverage===!1&&q.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?R(0):q.rgb}setupNormal(){return this.normalNode?R(this.normalNode):_d}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?st("envMap","cubeTexture"):st("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Ra(pa)),t}setupLights(e){const t=[],s=this.setupEnvironment(e);s&&s.isLightingNode&&t.push(s);const n=this.setupLightMap(e);if(n&&n.isLightingNode&&t.push(n),this.aoNode!==null||e.material.aoMap){const i=this.aoNode!==null?this.aoNode:Vd;t.push(new xa(i))}let r=this.lightsNode||e.lightsNode;return t.length>0&&(r=e.renderer.lighting.createNode([...r.getLights(),...t])),r}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:s,backdropAlphaNode:n,emissiveNode:r}=this,u=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let a=this.setupOutgoingLight(e);if(u&&u.getScope().hasLights){const l=this.setupLightingModel(e);a=Yd(u,l,s,n)}else s!==null&&(a=R(n!==null?Z(a,s,n):s));return(r&&r.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(Qr.assign(R(r||fd)),a=a.add(Qr)),a}setupOutput(e,t){if(this.fog===!0){const s=e.fogNode;s&&(t=k(s.mix(t.rgb,s.colorNode),t.a))}return t}setDefaultValues(e){for(const s in e){const n=e[s];this[s]===void 0&&(this[s]=n,n&&n.clone&&(this[s]=n.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=c.Material.prototype.toJSON.call(this,e),n=Ps(this);s.inputNodes={};for(const{property:i,childNode:u}of n)s.inputNodes[i]=u.toJSON(e).uuid;function r(i){const u=[];for(const a in i){const l=i[a];delete l.metadata,u.push(l)}return u}if(t){const i=r(e.textures),u=r(e.images),a=r(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.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.shadowPositionNode=e.shadowPositionNode,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 oh=new c.LineBasicMaterial;class wa extends re{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.lights=!1,this.setDefaultValues(oh),this.setValues(e)}}const ah=new c.LineDashedMaterial;class Ua extends re{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.lights=!1,this.setDefaultValues(ah),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?x(this.offsetNodeNode):Ld,t=this.dashScaleNode?x(this.dashScaleNode):Pd,s=this.dashSizeNode?x(this.dashSizeNode):Dd,n=this.dashSizeNode?x(this.dashGapNode):Id;an.assign(s),jr.assign(n);const r=Qe(Ye("lineDistance").mul(t));(e?r.add(e):r).mod(an.add(jr)).greaterThan(an).discard()}}const uh=o=>v(o).mul(.5).add(.5),ch=new c.MeshNormalMaterial;class Ga extends re{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(ch),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?x(this.opacityNode):ha;q.assign(k(uh(ue),e))}}class Pa extends ie{static get type(){return"EquirectUVNode"}constructor(e=ea){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan2(e.x).mul(1/(Math.PI*2)).add(.5),s=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return F(t,s)}}const Da=C(Pa);class Ia extends c.WebGLCubeRenderTarget{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const s=t.minFilter,n=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 r=new c.BoxGeometry(5,5,5),i=Da(ea),u=new re;u.colorNode=H(t,i,0),u.side=c.BackSide,u.blending=c.NoBlending;const a=new c.Mesh(r,u),l=new c.Scene;l.add(a),t.minFilter===c.LinearMipmapLinearFilter&&(t.minFilter=c.LinearFilter);const d=new c.CubeCamera(1,10,this),h=e.getMRT();return e.setMRT(null),d.update(e,l),e.setMRT(h),t.minFilter=s,t.currentGenerateMipmaps=n,a.geometry.dispose(),a.material.dispose(),this}}const es=new WeakMap;class lh extends ie{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=as();const t=new c.CubeTexture;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=z.RENDER}updateBefore(e){const{renderer:t,material:s}=e,n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const r=n.isTextureNode?n.value:s[n.property];if(r&&r.isTexture){const i=r.mapping;if(i===c.EquirectangularReflectionMapping||i===c.EquirectangularRefractionMapping){if(es.has(r)){const u=es.get(r);ci(u,r.mapping),this._cubeTexture=u}else{const u=r.image;if(dh(u)){const a=new Ia(u.height);a.fromEquirectangularTexture(t,r),ci(a.texture,r.mapping),this._cubeTexture=a.texture,es.set(r,a.texture),r.addEventListener("dispose",La)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function dh(o){return o==null?!1:o.height>0}function La(o){const e=o.target;e.removeEventListener("dispose",La);const t=es.get(e);t!==void 0&&(es.delete(e),t.dispose())}function ci(o,e){e===c.EquirectangularReflectionMapping?o.mapping=c.CubeReflectionMapping:e===c.EquirectangularRefractionMapping&&(o.mapping=c.CubeRefractionMapping)}const Oa=C(lh);class tn extends _t{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=Oa(this.envNode)}}class hh extends _t{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=x(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class hs{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class Va extends hs{constructor(){super()}indirect(e,t,s){const n=e.ambientOcclusion,r=e.reflectedLight,i=s.context.irradianceLightMap;r.indirectDiffuse.assign(k(0)),i?r.indirectDiffuse.addAssign(i):r.indirectDiffuse.addAssign(k(1,1,1,0)),r.indirectDiffuse.mulAssign(n),r.indirectDiffuse.mulAssign(q.rgb)}finish(e,t,s){const n=s.material,r=e.outgoingLight,i=s.context.environment;if(i)switch(n.combine){case c.MultiplyOperation:r.rgb.assign(Z(r.rgb,r.rgb.mul(i.rgb),Us.mul(un)));break;case c.MixOperation:r.rgb.assign(Z(r.rgb,i.rgb,Us.mul(un)));break;case c.AddOperation:r.rgb.addAssign(i.rgb.mul(Us.mul(un)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",n.combine);break}}}const ph=new c.MeshBasicMaterial;class ka extends re{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(ph),this.setValues(e)}setupNormal(){return Ge}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new tn(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new hh(pa)),t}setupOutgoingLight(){return q.rgb}setupLightingModel(){return new Va}}const cs=M(({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))}),Pt=M(o=>o.diffuseColor.mul(1/Math.PI)),fh=()=>x(.25),gh=M(({dotNH:o})=>Kn.mul(x(.5)).add(1).mul(x(1/Math.PI)).mul(o.pow(Kn))),mh=M(({lightDirection:o})=>{const e=o.add(ee).normalize(),t=ue.dot(e).clamp(),s=ee.dot(e).clamp(),n=cs({f0:Ae,f90:1,dotVH:s}),r=fh(),i=gh({dotNH:t});return n.mul(r).mul(i)});class Br extends Va{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:s}){const r=ue.dot(e).clamp().mul(t);s.directDiffuse.addAssign(r.mul(Pt({diffuseColor:q.rgb}))),this.specular===!0&&s.directSpecular.addAssign(r.mul(mh({lightDirection:e})).mul(Us))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:s}){s.indirectDiffuse.addAssign(t.mul(Pt({diffuseColor:q}))),s.indirectDiffuse.mulAssign(e)}}const Th=new c.MeshLambertMaterial;class za extends re{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Th),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new tn(t):null}setupLightingModel(){return new Br(!1)}}const yh=new c.MeshPhongMaterial;class $a extends re{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(yh),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new tn(t):null}setupLightingModel(){return new Br}setupVariants(){const e=(this.shininessNode?x(this.shininessNode):pd).max(1e-4);Kn.assign(e);const t=this.specularNode||gd;Ae.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const _h=M(o=>{if(o.geometry.hasAttribute("normal")===!1)return x(0);const e=Ge.dFdx().abs().max(Ge.dFdy().abs());return e.x.max(e.y).max(e.z)}),Wa=M(o=>{const{roughness:e}=o,t=_h();let s=e.max(.0525);return s=s.add(t),s=s.min(1),s}),Sh=M(({alpha:o,dotNL:e,dotNV:t})=>{const s=o.pow2(),n=e.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt()),r=t.mul(s.add(s.oneMinus().mul(e.pow2())).sqrt());return Ke(.5,n.add(r).max(Hc))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Nh=M(({alphaT:o,alphaB:e,dotTV:t,dotBV:s,dotTL:n,dotBL:r,dotNV:i,dotNL:u})=>{const a=u.mul(R(o.mul(t),e.mul(s),i).length()),l=i.mul(R(o.mul(n),e.mul(r),u).length());return Ke(.5,a.add(l)).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"}]}),xh=M(({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"}]}),bh=x(1/Math.PI),Rh=M(({alphaT:o,alphaB:e,dotNH:t,dotTH:s,dotBH:n})=>{const r=o.mul(e),i=R(e.mul(s),o.mul(n),r.mul(t)),u=i.dot(i),a=r.div(u);return bh.mul(r.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"}]}),li=M(o=>{const{lightDirection:e,f0:t,f90:s,roughness:n,f:r,USE_IRIDESCENCE:i,USE_ANISOTROPY:u}=o,a=o.normalView||ue,l=n.pow2(),d=e.add(ee).normalize(),h=a.dot(e).clamp(),p=a.dot(ee).clamp(),f=a.dot(d).clamp(),g=ee.dot(d).clamp();let m=cs({f0:t,f90:s,dotVH:g}),y,S;if(Yr(i)&&(m=pr.mix(m,r)),Yr(u)){const A=Bs.dot(e),E=Bs.dot(ee),D=Bs.dot(d),w=Ut.dot(e),U=Ut.dot(ee),G=Ut.dot(d);y=Nh({alphaT:qn,alphaB:l,dotTV:E,dotBV:U,dotTL:A,dotBL:w,dotNV:p,dotNL:h}),S=Rh({alphaT:qn,alphaB:l,dotNH:f,dotTH:D,dotBH:G})}else y=Sh({alpha:l,dotNL:h,dotNV:p}),S=xh({alpha:l,dotNH:f});return m.mul(y).mul(S)}),Ha=M(({roughness:o,dotNV:e})=>{const t=k(-1,-.0275,-.572,.022),s=k(1,.0425,1.04,-.04),n=o.mul(t).add(s),r=n.x.mul(n.x).min(e.mul(-9.28).exp2()).mul(n.x).add(n.y);return F(-1.04,1.04).mul(r).add(n.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),qa=M(o=>{const{dotNV:e,specularColor:t,specularF90:s,roughness:n}=o,r=Ha({dotNV:e,roughness:n});return t.mul(r.x).add(s.mul(r.y))}),Ah=M(({f:o,f90:e,dotVH:t})=>{const s=t.oneMinus().saturate(),n=s.mul(s),r=s.mul(n,n).clamp(0,.9999);return o.sub(R(e).mul(r)).div(r.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),Ch=M(({roughness:o,dotNH:e})=>{const t=o.pow2(),s=x(1).div(t),r=e.pow2().oneMinus().max(.0078125);return x(2).add(s).mul(r.pow(s.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),vh=M(({dotNV:o,dotNL:e})=>x(1).div(x(4).mul(e.add(o).sub(e.mul(o))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),Eh=M(({lightDirection:o})=>{const e=o.add(ee).normalize(),t=ue.dot(o).clamp(),s=ue.dot(ee).clamp(),n=ue.dot(e).clamp(),r=Ch({roughness:hr,dotNH:n}),i=vh({dotNV:s,dotNL:t});return Et.mul(r).mul(i)}),Mh=M(({N:o,V:e,roughness:t})=>{const r=.0078125,i=o.dot(e).saturate(),u=F(t,i.oneMinus().sqrt());return u.assign(u.mul(.984375).add(r)),u}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),Bh=M(({f:o})=>{const e=o.length();return Ne(e.mul(e).add(o.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),gs=M(({v1:o,v2:e})=>{const t=o.dot(e),s=t.abs().toVar(),n=s.mul(.0145206).add(.4965155).mul(s).add(.8543985).toVar(),r=s.add(4.1616724).mul(s).add(3.417594).toVar(),i=n.div(r),u=t.greaterThan(0).select(i,Ne(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"}]}),di=M(({N:o,V:e,P:t,mInv:s,p0:n,p1:r,p2:i,p3:u})=>{const a=r.sub(n).toVar(),l=u.sub(n).toVar(),d=a.cross(l),h=R().toVar();return ce(d.dot(t.sub(n)).greaterThanEqual(0),()=>{const p=e.sub(o.mul(e.dot(o))).normalize(),f=o.cross(p).negate(),g=s.mul(Te(p,f,o).transpose()).toVar(),m=g.mul(n.sub(t)).normalize().toVar(),y=g.mul(r.sub(t)).normalize().toVar(),S=g.mul(i.sub(t)).normalize().toVar(),A=g.mul(u.sub(t)).normalize().toVar(),E=R(0).toVar();E.addAssign(gs({v1:m,v2:y})),E.addAssign(gs({v1:y,v2:S})),E.addAssign(gs({v1:S,v2:A})),E.addAssign(gs({v1:A,v2:m})),h.assign(R(Bh({f:E})))}),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"}]}),sn=1/6,Ka=o=>$(sn,$(o,$(o,o.negate().add(3)).sub(3)).add(1)),Qn=o=>$(sn,$(o,$(o,$(3,o).sub(6))).add(4)),Xa=o=>$(sn,$(o,$(o,$(-3,o).add(3)).add(3)).add(1)),jn=o=>$(sn,Ys(o,3)),hi=o=>Ka(o).add(Qn(o)),pi=o=>Xa(o).add(jn(o)),fi=o=>ye(-1,Qn(o).div(Ka(o).add(Qn(o)))),gi=o=>ye(1,jn(o).div(Xa(o).add(jn(o)))),mi=(o,e,t)=>{const s=o.uvNode,n=$(s,e.zw).add(.5),r=gt(n),i=it(n),u=hi(i.x),a=pi(i.x),l=fi(i.x),d=gi(i.x),h=fi(i.y),p=gi(i.y),f=F(r.x.add(l),r.y.add(h)).sub(.5).mul(e.xy),g=F(r.x.add(d),r.y.add(h)).sub(.5).mul(e.xy),m=F(r.x.add(l),r.y.add(p)).sub(.5).mul(e.xy),y=F(r.x.add(d),r.y.add(p)).sub(.5).mul(e.xy),S=hi(i.y).mul(ye(u.mul(o.uv(f).level(t)),a.mul(o.uv(g).level(t)))),A=pi(i.y).mul(ye(u.mul(o.uv(m).level(t)),a.mul(o.uv(y).level(t))));return S.add(A)},Fh=M(([o,e=x(3)])=>{const t=F(o.size(te(e))),s=F(o.size(te(e.add(1)))),n=Ke(1,t),r=Ke(1,s),i=mi(o,k(n,t),gt(e)),u=mi(o,k(r,s),gr(e));return it(e).mix(i,u)}),Ti=M(([o,e,t,s,n])=>{const r=R(Lo(e.negate(),ns(o),Ke(1,s))),i=R(rt(n[0].xyz),rt(n[1].xyz),rt(n[2].xyz));return ns(r).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"}]}),wh=M(([o,e])=>o.mul(Xe(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),Uh=Ca(),Gh=Ca(),yi=M(([o,e,t],{material:s})=>{const r=(s.side==c.BackSide?Uh:Gh).uv(o),i=qe(Yn.x).mul(wh(e,t));return Fh(r,i)}),_i=M(([o,e,t])=>(ce(t.notEqual(0),()=>{const s=Fo(e).negate().div(t);return Bo(s.negate().mul(o))}),R(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),Ph=M(([o,e,t,s,n,r,i,u,a,l,d,h,p,f,g])=>{let m,y;if(g){m=k().toVar(),y=R().toVar();const w=d.sub(1).mul(g.mul(.025)),U=R(d.sub(w),d,d.add(w));we({start:0,end:3},({i:G})=>{const P=U.element(G),Q=Ti(o,e,h,P,u),se=i.add(Q),X=l.mul(a.mul(k(se,1))),xe=F(X.xy.div(X.w)).toVar();xe.addAssign(1),xe.divAssign(2),xe.assign(F(xe.x,xe.y.oneMinus()));const be=yi(xe,t,P);m.element(G).assign(be.element(G)),m.a.addAssign(be.a),y.element(G).assign(s.element(G).mul(_i(rt(Q),p,f).element(G)))}),m.a.divAssign(3)}else{const w=Ti(o,e,h,d,u),U=i.add(w),G=l.mul(a.mul(k(U,1))),P=F(G.xy.div(G.w)).toVar();P.addAssign(1),P.divAssign(2),P.assign(F(P.x,P.y.oneMinus())),m=yi(P,t,d),y=s.mul(_i(rt(w),p,f))}const S=y.rgb.mul(m.rgb),A=o.dot(e).clamp(),E=R(qa({dotNV:A,specularColor:n,specularF90:r,roughness:t})),D=y.r.add(y.g,y.b).div(3);return k(E.oneMinus().mul(S),m.a.oneMinus().mul(D).oneMinus())}),Dh=Te(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Ih=o=>{const e=o.sqrt();return R(1).add(e).div(R(1).sub(e))},Si=(o,e)=>o.sub(e).div(o.add(e)).pow2(),Lh=(o,e)=>{const t=o.mul(2*Math.PI*1e-9),s=R(54856e-17,44201e-17,52481e-17),n=R(1681e3,1795300,2208400),r=R(43278e5,93046e5,66121e5),i=x(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(r.mul(2*Math.PI).sqrt()).mul(n.mul(t).add(e).cos()).mul(t.pow2().negate().mul(r).exp());return u=R(u.x.add(i),u.y,u.z).div(10685e-11),Dh.mul(u)},Oh=M(({outsideIOR:o,eta2:e,cosTheta1:t,thinFilmThickness:s,baseF0:n})=>{const r=Z(o,e,mt(0,.03,s)),u=o.div(r).pow2().mul(t.pow2().oneMinus()).oneMinus();ce(u.lessThan(0),()=>R(1));const a=u.sqrt(),l=Si(r,o),d=cs({f0:l,f90:1,dotVH:t}),h=d.oneMinus(),p=r.lessThan(o).select(Math.PI,0),f=x(Math.PI).sub(p),g=Ih(n.clamp(0,.9999)),m=Si(g,r.toVec3()),y=cs({f0:m,f90:1,dotVH:a}),S=R(g.x.lessThan(r).select(Math.PI,0),g.y.lessThan(r).select(Math.PI,0),g.z.lessThan(r).select(Math.PI,0)),A=r.mul(s,a,2),E=R(f).add(S),D=d.mul(y).clamp(1e-5,.9999),w=D.sqrt(),U=h.pow2().mul(y).div(R(1).sub(D)),P=d.add(U).toVar(),Q=U.sub(h).toVar();return we({start:1,end:2,condition:"<=",name:"m"},({m:se})=>{Q.mulAssign(w);const X=Lh(x(se).mul(A),x(se).mul(E)).mul(2);P.addAssign(Q.mul(X))}),P.max(R(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"}]}),Vh=M(({normal:o,viewDir:e,roughness:t})=>{const s=o.dot(e).saturate(),n=t.pow2(),r=Se(t.lessThan(.25),x(-339.2).mul(n).add(x(161.4).mul(t)).sub(25.9),x(-8.48).mul(n).add(x(14.3).mul(t)).sub(9.95)),i=Se(t.lessThan(.25),x(44).mul(n).sub(x(23.7).mul(t)).add(3.26),x(1.97).mul(n).sub(x(3.27).mul(t)).add(.72));return Se(t.lessThan(.25),0,x(.1).mul(t).sub(.025)).add(r.mul(s).add(i).exp()).mul(1/Math.PI).saturate()}),dn=R(.04),hn=x(1);class Fr extends hs{constructor(e=!1,t=!1,s=!1,n=!1,r=!1,i=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=s,this.anisotropy=n,this.transmission=r,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=R().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=R().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=R().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=R().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=R().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=ue.dot(ee).clamp();this.iridescenceFresnel=Oh({outsideIOR:x(1),eta2:So,cosTheta1:t,thinFilmThickness:No,baseF0:Ae}),this.iridescenceF0=Ah({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=os,s=Hl.sub(os).normalize(),n=Rr;e.backdrop=Ph(n,s,He,q,Ae,ks,t,Tt,je,$s,Fs,xo,Ro,bo,this.dispersion?Ao:null),e.backdropAlpha=Xn,q.a.mulAssign(Z(1,e.backdrop.a,Xn))}}computeMultiscattering(e,t,s){const n=ue.dot(ee).clamp(),r=Ha({roughness:He,dotNV:n}),u=(this.iridescenceF0?pr.mix(Ae,this.iridescenceF0):Ae).mul(r.x).add(s.mul(r.y)),l=r.x.add(r.y).oneMinus(),d=Ae.add(Ae.oneMinus().mul(.047619)),h=u.mul(d).div(l.mul(d).oneMinus());e.addAssign(u),t.addAssign(h.mul(l))}direct({lightDirection:e,lightColor:t,reflectedLight:s}){const r=ue.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(r.mul(Eh({lightDirection:e}))),this.clearcoat===!0){const u=Yt.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(u.mul(li({lightDirection:e,f0:dn,f90:hn,roughness:Vs,normalView:Yt})))}s.directDiffuse.addAssign(r.mul(Pt({diffuseColor:q.rgb}))),s.directSpecular.addAssign(r.mul(li({lightDirection:e,f0:Ae,f90:1,roughness:He,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:s,halfHeight:n,reflectedLight:r,ltc_1:i,ltc_2:u}){const a=t.add(s).sub(n),l=t.sub(s).sub(n),d=t.sub(s).add(n),h=t.add(s).add(n),p=ue,f=ee,g=de.toVar(),m=Mh({N:p,V:f,roughness:He}),y=i.uv(m).toVar(),S=u.uv(m).toVar(),A=Te(R(y.x,0,y.y),R(0,1,0),R(y.z,0,y.w)).toVar(),E=Ae.mul(S.x).add(Ae.oneMinus().mul(S.y)).toVar();r.directSpecular.addAssign(e.mul(E).mul(di({N:p,V:f,P:g,mInv:A,p0:a,p1:l,p2:d,p3:h}))),r.directDiffuse.addAssign(e.mul(q).mul(di({N:p,V:f,P:g,mInv:Te(1,0,0,0,1,0,0,0,1),p0:a,p1:l,p2:d,p3:h})))}indirect(e,t,s){this.indirectDiffuse(e,t,s),this.indirectSpecular(e,t,s),this.ambientOcclusion(e,t,s)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(Pt({diffuseColor:q})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:s}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul(Et,Vh({normal:ue,viewDir:ee,roughness:hr}))),this.clearcoat===!0){const l=Yt.dot(ee).clamp(),d=qa({dotNV:l,specularColor:dn,specularF90:hn,roughness:Vs});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(d))}const n=R().toVar("singleScattering"),r=R().toVar("multiScattering"),i=t.mul(1/Math.PI);this.computeMultiscattering(n,r,ks);const u=n.add(r),a=q.mul(u.r.max(u.g).max(u.b).oneMinus());s.indirectSpecular.addAssign(e.mul(n)),s.indirectSpecular.addAssign(r.mul(i)),s.indirectDiffuse.addAssign(a.mul(i))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const n=ue.dot(ee).clamp().add(e),r=He.mul(-16).oneMinus().negate().exp2(),i=e.sub(n.pow(r).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(e),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(i)}finish(e){const{outgoingLight:t}=e;if(this.clearcoat===!0){const s=Yt.dot(ee).clamp(),n=cs({dotVH:s,f0:dn,f90:hn}),r=t.mul(Hn.mul(n).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Hn));t.assign(r)}if(this.sheen===!0){const s=Et.r.max(Et.g).max(Et.b).mul(.157).oneMinus(),n=t.mul(s).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(n)}}}const Ni=x(1),Zn=x(-2),ms=x(.8),pn=x(-1),Ts=x(.4),fn=x(2),ys=x(.305),gn=x(3),xi=x(.21),kh=x(4),bi=x(4),zh=x(16),$h=M(([o])=>{const e=R(Ee(o)).toVar(),t=x(-1).toVar();return ce(e.x.greaterThan(e.z),()=>{ce(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(()=>{ce(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"}]}),Wh=M(([o,e])=>{const t=F().toVar();return ce(e.equal(0),()=>{t.assign(F(o.z,o.y).div(Ee(o.x)))}).ElseIf(e.equal(1),()=>{t.assign(F(o.x.negate(),o.z.negate()).div(Ee(o.y)))}).ElseIf(e.equal(2),()=>{t.assign(F(o.x.negate(),o.y).div(Ee(o.z)))}).ElseIf(e.equal(3),()=>{t.assign(F(o.z.negate(),o.y).div(Ee(o.x)))}).ElseIf(e.equal(4),()=>{t.assign(F(o.x.negate(),o.z).div(Ee(o.y)))}).Else(()=>{t.assign(F(o.x,o.y).div(Ee(o.z)))}),$(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Hh=M(([o])=>{const e=x(0).toVar();return ce(o.greaterThanEqual(ms),()=>{e.assign(Ni.sub(o).mul(pn.sub(Zn)).div(Ni.sub(ms)).add(Zn))}).ElseIf(o.greaterThanEqual(Ts),()=>{e.assign(ms.sub(o).mul(fn.sub(pn)).div(ms.sub(Ts)).add(pn))}).ElseIf(o.greaterThanEqual(ys),()=>{e.assign(Ts.sub(o).mul(gn.sub(fn)).div(Ts.sub(ys)).add(fn))}).ElseIf(o.greaterThanEqual(xi),()=>{e.assign(ys.sub(o).mul(kh.sub(gn)).div(ys.sub(xi)).add(gn))}).Else(()=>{e.assign(x(-2).mul(qe($(1.16,o))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),qh=M(([o,e])=>{const t=o.toVar();t.assign($(2,t).sub(1));const s=R(t,1).toVar();return ce(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"}]}),Kh=M(([o,e,t,s,n,r])=>{const i=x(t),u=R(e),a=Xe(Hh(i),Zn,r),l=it(a),d=gt(a),h=R(Jn(o,u,d,s,n,r)).toVar();return ce(l.notEqual(0),()=>{const p=R(Jn(o,u,d.add(1),s,n,r)).toVar();h.assign(Z(h,p,l))}),h}),Jn=M(([o,e,t,s,n,r])=>{const i=x(t).toVar(),u=R(e),a=x($h(u)).toVar(),l=x(Ne(bi.sub(i),0)).toVar();i.assign(Ne(i,bi));const d=x(ss(i)).toVar(),h=F(Wh(u,a).mul(d.sub(2)).add(1)).toVar();return ce(a.greaterThan(2),()=>{h.y.addAssign(d),a.subAssign(3)}),h.x.addAssign(a.mul(d)),h.x.addAssign(l.mul($(3,zh))),h.y.addAssign($(4,ss(r).sub(d))),h.x.mulAssign(s),h.y.mulAssign(n),o.uv(h).grad(F(),F())}),mn=M(({envMap:o,mipInt:e,outputDirection:t,theta:s,axis:n,CUBEUV_TEXEL_WIDTH:r,CUBEUV_TEXEL_HEIGHT:i,CUBEUV_MAX_MIP:u})=>{const a=et(s),l=t.mul(a).add(n.cross(t).mul(Fe(s))).add(n.mul(n.dot(t).mul(a.oneMinus())));return Jn(o,l,e,r,i,u)}),Xh=M(({n:o,latitudinal:e,poleAxis:t,outputDirection:s,weights:n,samples:r,dTheta:i,mipInt:u,envMap:a,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h})=>{const p=R(Se(e,t,Do(t,s))).toVar();ce(Mo(p.equals(R(0))),()=>{p.assign(R(s.z,0,s.x.negate()))}),p.assign(ns(p));const f=R().toVar();return f.addAssign(n.element(te(0)).mul(mn({theta:0,axis:p,outputDirection:s,mipInt:u,envMap:a,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h}))),we({start:te(1),end:o},({i:g})=>{ce(g.greaterThanEqual(r),()=>{qd()});const m=x(i.mul(x(g))).toVar();f.addAssign(n.element(g).mul(mn({theta:m.mul(-1),axis:p,outputDirection:s,mipInt:u,envMap:a,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h}))),f.addAssign(n.element(g).mul(mn({theta:m,axis:p,outputDirection:s,mipInt:u,envMap:a,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h})))}),k(f,1)});let Ws=null;const Ri=new WeakMap;function Yh(o){const e=Math.log2(o)-2,t=1/o;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:t,maxMip:e}}function Qh(o){let e=Ri.get(o);if((e!==void 0?e.pmremVersion:-1)!==o.pmremVersion){const s=o.image;if(o.isCubeTexture)if(jh(s))e=Ws.fromCubemap(o,e);else return null;else if(Zh(s))e=Ws.fromEquirectangular(o,e);else return null;e.pmremVersion=o.pmremVersion,Ri.set(o,e)}return e.texture}class Ya extends ie{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 n=new c.Texture;n.isRenderTargetTexture=!0,this._texture=H(n),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=Yh(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem;const t=e?e.pmremVersion:-1,s=this._value;t!==s.pmremVersion&&(s.isPMREMTexture===!0?e=s:e=Qh(s),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){Ws===null&&(Ws=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this));const s=this.value;e.renderer.coordinateSystem===c.WebGLCoordinateSystem&&s.isPMREMTexture!==!0&&s.isRenderTargetTexture===!0&&(t=R(t.x.negate(),t.yz));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),Kh(this._texture,t,n,this._width,this._height,this._maxMip)}}function jh(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 Zh(o){return o==null?!1:o.height>0}const Qa=C(Ya),Ai=new WeakMap;class ja extends _t{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 f=s.isTextureNode?s.value:t[s.property];let g=Ai.get(f);g===void 0&&(g=Qa(f),Ai.set(f,g)),s=g}const r=t.envMap?Y("envMapIntensity","float",e.material):Y("environmentIntensity","float",e.scene),u=t.useAnisotropy===!0||t.anisotropy>0?od:ue,a=s.context(Ci(He,u)).mul(r),l=s.context(Jh(Rr)).mul(Math.PI).mul(r),d=ws(a),h=ws(l);e.context.radiance.addAssign(d),e.context.iblIrradiance.addAssign(h);const p=e.context.lightingModel.clearcoatRadiance;if(p){const f=s.context(Ci(Vs,Yt)).mul(r),g=ws(f);p.addAssign(g)}}}const Ci=(o,e)=>{let t=null;return{getUV:()=>(t===null&&(t=ee.negate().reflect(e),t=o.mul(o).mix(t,e).normalize(),t=t.transformDirection(je)),t),getTextureLevel:()=>o}},Jh=o=>({getUV:()=>o,getTextureLevel:()=>x(1)}),ep=new c.MeshStandardMaterial;class wr extends re{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(ep),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new ja(t):null}setupLightingModel(){return new Fr}setupSpecular(){const e=Z(R(.04),q.rgb,Os);Ae.assign(e),ks.assign(1)}setupVariants(){const e=this.metalnessNode?x(this.metalnessNode):yd;Os.assign(e);let t=this.roughnessNode?x(this.roughnessNode):Td;t=Wa({roughness:t}),He.assign(t),this.setupSpecular(),q.assign(k(q.rgb.mul(e.oneMinus()),q.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const tp=new c.MeshPhysicalMaterial;class Za extends wr{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(tp),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?x(this.iorNode):wd;Fs.assign(e),Ae.assign(Z(rs(Io(Fs.sub(1).div(Fs.add(1))).mul(md),R(1)).mul(ri),q.rgb,Os)),ks.assign(Z(ri,1,Os))}setupLightingModel(){return new Fr(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?x(this.clearcoatNode):Sd,s=this.clearcoatRoughnessNode?x(this.clearcoatRoughnessNode):Nd;Hn.assign(t),Vs.assign(Wa({roughness:s}))}if(this.useSheen){const t=this.sheenNode?R(this.sheenNode):Rd,s=this.sheenRoughnessNode?x(this.sheenRoughnessNode):Ad;Et.assign(t),hr.assign(s)}if(this.useIridescence){const t=this.iridescenceNode?x(this.iridescenceNode):vd,s=this.iridescenceIORNode?x(this.iridescenceIORNode):Ed,n=this.iridescenceThicknessNode?x(this.iridescenceThicknessNode):Md;pr.assign(t),So.assign(s),No.assign(n)}if(this.useAnisotropy){const t=(this.anisotropyNode?F(this.anisotropyNode):Cd).toVar();ct.assign(t.length()),ce(ct.equal(0),()=>{t.assign(F(1,0))}).Else(()=>{t.divAssign(F(ct)),ct.assign(ct.saturate())}),qn.assign(ct.pow2().mix(He.pow2(),1)),Bs.assign(Qt[0].mul(t.x).add(Qt[1].mul(t.y))),Ut.assign(Qt[1].mul(t.x).sub(Qt[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?x(this.transmissionNode):Bd,s=this.thicknessNode?x(this.thicknessNode):Fd,n=this.attenuationDistanceNode?x(this.attenuationDistanceNode):Ud,r=this.attenuationColorNode?R(this.attenuationColorNode):Gd;if(Xn.assign(t),xo.assign(s),bo.assign(n),Ro.assign(r),this.useDispersion){const i=this.dispersionNode?x(this.dispersionNode):Od;Ao.assign(i)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?R(this.clearcoatNormalNode):xd}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),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 sp=M(({normal:o,lightDirection:e,builder:t})=>{const s=o.dot(e),n=F(s.mul(.5).add(.5),0);if(t.material.gradientMap){const r=st("gradientMap","texture").context({getUV:()=>n});return R(r.r)}else{const r=n.fwidth().mul(.5);return Z(R(.7),R(1),mt(x(.7).sub(r.x),x(.7).add(r.x),n.x))}});class np extends hs{direct({lightDirection:e,lightColor:t,reflectedLight:s},n,r){const i=sp({normal:sa,lightDirection:e,builder:r}).mul(t);s.directDiffuse.addAssign(i.mul(Pt({diffuseColor:q.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:s}){s.indirectDiffuse.addAssign(t.mul(Pt({diffuseColor:q}))),s.indirectDiffuse.mulAssign(e)}}const rp=new c.MeshToonMaterial;class Ja extends re{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(rp),this.setValues(e)}setupLightingModel(){return new np}}class eu extends ie{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=R(ee.z,0,ee.x.negate()).normalize(),t=ee.cross(e);return F(e.dot(ue),t.dot(ue)).mul(.495).add(.5)}}const ip=B(eu),op=new c.MeshMatcapMaterial;class tu extends re{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(op),this.setValues(e)}setupVariants(e){const t=ip;let s;e.material.matcap?s=st("matcap","texture").context({getUV:()=>t}):s=R(Z(.2,.8,t.y)),q.rgb.mulAssign(s.rgb)}}const ap=new c.PointsMaterial;class su extends re{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.lights=!1,this.transparent=!0,this.sizeNode=null,this.setDefaultValues(ap),this.setValues(e)}copy(e){return this.sizeNode=e.sizeNode,super.copy(e)}}class nu extends ie{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 r=t.cos(),i=t.sin();return lr(r,i,i.negate(),r).mul(s)}else{const r=t,i=wt(k(1,0,0,0),k(0,et(r.x),Fe(r.x).negate(),0),k(0,Fe(r.x),et(r.x),0),k(0,0,0,1)),u=wt(k(et(r.y),0,Fe(r.y),0),k(0,1,0,0),k(Fe(r.y).negate(),0,et(r.y),0),k(0,0,0,1)),a=wt(k(et(r.z),Fe(r.z).negate(),0,0),k(Fe(r.z),et(r.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 up=C(nu),cp=new c.SpriteMaterial;class ru extends re{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this.lights=!1,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues(cp),this.setValues(e)}setupPosition({object:e,camera:t,context:s}){const n=this.sizeAttenuation,{positionNode:r,rotationNode:i,scaleNode:u}=this,a=fe;let l=js.mul(R(r||0)),d=F(Tt[0].xyz.length(),Tt[1].xyz.length());if(u!==null&&(d=d.mul(u)),!n)if(t.isPerspectiveCamera)d=d.mul(l.z.negate());else{const m=x(2).div($s.element(1).element(1));d=d.mul(m.mul(2))}let h=a.xy;if(e.center&&e.center.isVector2===!0){const m=Ul("center","vec2");h=h.sub(m.sub(.5))}h=h.mul(d);const p=x(i||bd),f=up(h,p);l=k(l.xy.add(f),l.zw);const g=$s.mul(l);return s.vertex=a,g}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)}}class lp extends hs{constructor(){super(),this.shadowNode=x(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){q.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(q.rgb)}}const dp=new c.ShadowMaterial;class iu extends re{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(dp),this.setValues(e)}setupLightingModel(){return new lp}}M(({texture:o,uv:e})=>{const s=R().toVar();return ce(e.x.lessThan(1e-4),()=>{s.assign(R(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{s.assign(R(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{s.assign(R(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{s.assign(R(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{s.assign(R(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{s.assign(R(0,0,-1))}).Else(()=>{const r=o.uv(e.add(R(-.01,0,0))).r.sub(o.uv(e.add(R(.01,0,0))).r),i=o.uv(e.add(R(0,-.01,0))).r.sub(o.uv(e.add(R(0,.01,0))).r),u=o.uv(e.add(R(0,0,-.01))).r.sub(o.uv(e.add(R(0,0,.01))).r);s.assign(R(r,i,u))}),s.normalize()});class hp{constructor(e,t){this.nodes=e,this.info=t,this._context=self,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}setAnimationLoop(e){this._animationLoop=e}setContext(e){this._context=e}dispose(){this.stop()}}class Oe{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let s=0;s<e.length;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 n=0;n<e.length;n++){const r=e[n];s.has(r)===!1&&s.set(r,new WeakMap),s=s.get(r)}return s.set(e[e.length-1],t)}delete(e){let t=this.weakMap;for(let s=0;s<e.length;s++)if(t=t.get(e[s]),t===void 0)return!1;return t.delete(e[e.length-1])}}let pp=0;function fp(o){const e=Object.keys(o);let t=Object.getPrototypeOf(o);for(;t;){const s=Object.getOwnPropertyDescriptors(t);for(const n in s)if(s[n]!==void 0){const r=s[n];r&&typeof r.get=="function"&&e.push(n)}t=Object.getPrototypeOf(t)}return e}class gp{constructor(e,t,s,n,r,i,u,a,l,d){this._nodes=e,this._geometries=t,this.id=pp++,this.renderer=s,this.object=n,this.material=r,this.scene=i,this.camera=u,this.lightsNode=a,this.context=l,this.geometry=n.geometry,this.version=r.version,this.drawRange=null,this.attributes=null,this.pipeline=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.material.addEventListener("dispose",this.onMaterialDispose)}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().monitor)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}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}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,s=[],n=new Set;for(const r of e){const i=r.node&&r.node.attribute?r.node.attribute:t.getAttribute(r.name);if(i===void 0)continue;s.push(i);const u=i.isInterleavedBufferAttribute?i.data:i;n.add(u)}return this.attributes=s,this.vertexBuffers=Array.from(n.values()),s}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:s,group:n,drawRange:r}=this,i=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),u=this.getIndex(),a=u!==null,l=s.isInstancedBufferGeometry?s.instanceCount:e.count>1?e.count:1;if(l===0)return null;if(i.instanceCount=l,e.isBatchedMesh===!0)return i;let d=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(d=2);let h=r.start*d,p=(r.start+r.count)*d;n!==null&&(h=Math.max(h,n.start*d),p=Math.min(p,(n.start+n.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 n=e.attributes[s];t+=s+",",n.data&&(t+=n.data.stride+","),n.offset&&(t+=n.offset+","),n.itemSize&&(t+=n.itemSize+","),n.normalized&&(t+="n,")}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t}=this;let s=t.customProgramCacheKey();for(const n of fp(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(n))continue;const r=t[n];let i;if(r!==null){const u=typeof r;u==="number"?i=r!==0?"1":"0":u==="object"?(i="{",r.isTexture&&(i+=r.mapping),i+="}"):i=String(r)}else i=String(r);s+=i+","}return s+=this.clippingContextCacheKey+",",e.geometry&&(s+=this.getGeometryCacheKey()),e.skeleton&&(s+=e.skeleton.bones.length+","),e.morphTargetInfluences&&(s+=e.morphTargetInfluences.length+","),e.isBatchedMesh&&(s+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(s+=e._colorsTexture.uuid+",")),e.count>1&&(s+=e.uuid+","),s+=e.receiveShadow+",",$u(s)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=this._nodes.getCacheKey(this.scene,this.lightsNode);return this.object.receiveShadow&&(e+=1),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const xt=[];class mp{constructor(e,t,s,n,r,i){this.renderer=e,this.nodes=t,this.geometries=s,this.pipelines=n,this.bindings=r,this.info=i,this.chainMaps={}}get(e,t,s,n,r,i,u,a){const l=this.getChainMap(a);xt[0]=e,xt[1]=t,xt[2]=i,xt[3]=r;let d=l.get(xt);return d===void 0?(d=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,s,n,r,i,u,a),l.set(xt,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,n,r,i,u,a)):d.version=t.version)),d}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new Oe)}dispose(){this.chainMaps={}}createRenderObject(e,t,s,n,r,i,u,a,l,d,h){const p=this.getChainMap(h),f=new gp(e,t,s,n,r,i,u,a,l,d);return f.onDispose=()=>{this.pipelines.delete(f),this.bindings.delete(f),this.nodes.delete(f),p.delete(f.getChainArray())},f}}class ot{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;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 Ie={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},nt=16,Tp=211,yp=212;class _p extends ot{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==void 0&&this.backend.destroyAttribute(e),t}update(e,t){const s=this.get(e);if(s.version===void 0)t===Ie.VERTEX?this.backend.createAttribute(e):t===Ie.INDEX?this.backend.createIndexAttribute(e):t===Ie.STORAGE?this.backend.createStorageAttribute(e):t===Ie.INDIRECT&&this.backend.createIndirectStorageAttribute(e),s.version=this._getBufferAttribute(e).version;else{const n=this._getBufferAttribute(e);(s.version<n.version||n.usage===c.DynamicDrawUsage)&&(this.backend.updateAttribute(e),s.version=n.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}function Sp(o){for(let e=o.length-1;e>=0;--e)if(o[e]>=65535)return!0;return!1}function ou(o){return o.index!==null?o.index.version:o.attributes.position.version}function vi(o){const e=[],t=o.index,s=o.attributes.position;if(t!==null){const r=t.array;for(let i=0,u=r.length;i<u;i+=3){const a=r[i+0],l=r[i+1],d=r[i+2];e.push(a,l,l,d,d,a)}}else{const r=s.array;for(let i=0,u=r.length/3-1;i<u;i+=3){const a=i+0,l=i+1,d=i+2;e.push(a,l,l,d,d,a)}}const n=new(Sp(e)?c.Uint32BufferAttribute:c.Uint16BufferAttribute)(e,1);return n.version=ou(o),n}class Np extends ot{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 n=()=>{this.info.memory.geometries--;const r=t.index,i=e.getAttributes();r!==null&&this.attributes.delete(r);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",n)};t.addEventListener("dispose",n)}updateAttributes(e){const t=e.getAttributes();for(const r of t)r.isStorageBufferAttribute||r.isStorageInstancedBufferAttribute?this.updateAttribute(r,Ie.STORAGE):this.updateAttribute(r,Ie.VERTEX);const s=this.getIndex(e);s!==null&&this.updateAttribute(s,Ie.INDEX);const n=e.geometry.indirect;n!==null&&this.updateAttribute(n,Ie.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 n=t.index;if(s.wireframe===!0){const r=this.wireframes;let i=r.get(t);i===void 0?(i=vi(t),r.set(t,i)):i.version!==ou(t)&&(this.attributes.delete(i),i=vi(t),r.set(t,i)),n=i}return n}}class xp{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,previousFrameCalls:0,timestampCalls:0},this.compute={calls:0,frameCalls:0,timestamp:0,previousFrameCalls:0,timestampCalls: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.")}updateTimestamp(e,t){this[e].timestampCalls===0&&(this[e].timestamp=0),this[e].timestamp+=t,this[e].timestampCalls++,this[e].timestampCalls>=this[e].previousFrameCalls&&(this[e].timestampCalls=0)}reset(){const e=this.render.frameCalls;this.render.previousFrameCalls=e;const t=this.compute.frameCalls;this.compute.previousFrameCalls=t,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 au{constructor(e){this.cacheKey=e,this.usedTimes=0}}class bp extends au{constructor(e,t,s){super(e),this.vertexProgram=t,this.fragmentProgram=s}}class Rp extends au{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Ap=0;class Tn{constructor(e,t,s=null,n=null){this.id=Ap++,this.code=e,this.stage=t,this.transforms=s,this.attributes=n,this.usedTimes=0}}class Cp extends ot{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,n=this.get(e);if(this._needsComputeUpdate(e)){const r=n.pipeline;r&&(r.usedTimes--,r.computeProgram.usedTimes--);const i=this.nodes.getForCompute(e);let u=this.programs.compute.get(i.computeShader);u===void 0&&(r&&r.computeProgram.usedTimes===0&&this._releaseProgram(r.computeProgram),u=new Tn(i.computeShader,"compute",i.transforms,i.nodeAttributes),this.programs.compute.set(i.computeShader,u),s.createProgram(u));const a=this._getComputeCacheKey(e,u);let l=this.caches.get(a);l===void 0&&(r&&r.usedTimes===0&&this._releasePipeline(r),l=this._getComputePipeline(e,u,a,t)),l.usedTimes++,u.usedTimes++,n.version=e.version,n.pipeline=l}return n.pipeline}getForRender(e,t=null){const{backend:s}=this,n=this.get(e);if(this._needsRenderUpdate(e)){const r=n.pipeline;r&&(r.usedTimes--,r.vertexProgram.usedTimes--,r.fragmentProgram.usedTimes--);const i=e.getNodeBuilderState();let u=this.programs.vertex.get(i.vertexShader);u===void 0&&(r&&r.vertexProgram.usedTimes===0&&this._releaseProgram(r.vertexProgram),u=new Tn(i.vertexShader,"vertex"),this.programs.vertex.set(i.vertexShader,u),s.createProgram(u));let a=this.programs.fragment.get(i.fragmentShader);a===void 0&&(r&&r.fragmentProgram.usedTimes===0&&this._releaseProgram(r.fragmentProgram),a=new Tn(i.fragmentShader,"fragment"),this.programs.fragment.set(i.fragmentShader,a),s.createProgram(a));const l=this._getRenderCacheKey(e,u,a);let d=this.caches.get(l);d===void 0?(r&&r.usedTimes===0&&this._releasePipeline(r),d=this._getRenderPipeline(e,u,a,l,t)):e.pipeline=d,d.usedTimes++,u.usedTimes++,a.usedTimes++,n.pipeline=d}return n.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,n){s=s||this._getComputeCacheKey(e,t);let r=this.caches.get(s);return r===void 0&&(r=new Rp(s,t),this.caches.set(s,r),this.backend.createComputePipeline(r,n)),r}_getRenderPipeline(e,t,s,n,r){n=n||this._getRenderCacheKey(e,t,s);let i=this.caches.get(n);return i===void 0&&(i=new bp(n,t,s),this.caches.set(n,i),e.pipeline=i,this.backend.createRenderPipeline(e,r)),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 vp extends ot{constructor(e,t,s,n,r,i){super(),this.backend=e,this.textures=s,this.pipelines=r,this.attributes=n,this.nodes=t,this.info=i,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const s of t){const n=this.get(s);n.bindGroup===void 0&&(this._init(s),this.backend.createBindings(s,t,0),n.bindGroup=s)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const s of t){const n=this.get(s);n.bindGroup===void 0&&(this._init(s),this.backend.createBindings(s,t,0),n.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,n=s.isIndirectStorageBufferAttribute?Ie.INDIRECT:Ie.STORAGE;this.attributes.update(s,n)}}_update(e,t){const{backend:s}=this;let n=!1,r=!0,i=0,u=0;for(const a of e.bindings)if(!(a.isNodeUniformsGroup&&!this.nodes.updateGroup(a))){if(a.isUniformBuffer)a.update()&&s.updateBinding(a);else if(a.isSampler)a.update();else if(a.isSampledTexture){const l=this.textures.get(a.texture);a.needsBindingsUpdate(l.generation)&&(n=!0);const d=a.update(),h=a.texture;d&&this.textures.updateTexture(h);const p=s.get(h);if(p.externalTexture!==void 0||l.isDefaultTexture?r=!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,n),this.textures.updateTexture(h),n=!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)}}}n===!0&&this.backend.updateBindings(e,t,r?i:0,u)}}function Ep(o,e){return o.groupOrder!==e.groupOrder?o.groupOrder-e.groupOrder:o.renderOrder!==e.renderOrder?o.renderOrder-e.renderOrder:o.material.id!==e.material.id?o.material.id-e.material.id:o.z!==e.z?o.z-e.z:o.id-e.id}function Ei(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 Mi(o){return(o.transmission>0||o.transmissionNode)&&o.side===c.DoubleSide&&o.forceSinglePass===!1}class Mp{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,n,r,i,u){let a=this.renderItems[this.renderItemsIndex];return a===void 0?(a={id:e.id,object:e,geometry:t,material:s,groupOrder:n,renderOrder:e.renderOrder,z:r,group:i,clippingContext:u},this.renderItems[this.renderItemsIndex]=a):(a.id=e.id,a.object=e,a.geometry=t,a.material=s,a.groupOrder=n,a.renderOrder=e.renderOrder,a.z=r,a.group=i,a.clippingContext=u),this.renderItemsIndex++,a}push(e,t,s,n,r,i,u){const a=this.getNextRenderItem(e,t,s,n,r,i,u);e.occlusionTest===!0&&this.occlusionQueryCount++,s.transparent===!0||s.transmission>0?(Mi(s)&&this.transparentDoublePass.push(a),this.transparent.push(a)):this.opaque.push(a)}unshift(e,t,s,n,r,i,u){const a=this.getNextRenderItem(e,t,s,n,r,i,u);s.transparent===!0||s.transmission>0?(Mi(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||Ep),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||Ei),this.transparent.length>1&&this.transparent.sort(t||Ei)}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}}}class Bp{constructor(e){this.lighting=e,this.lists=new Oe}get(e,t){const s=this.lists,n=[e,t];let r=s.get(n);return r===void 0&&(r=new Mp(this.lighting,e,t),s.set(n,r)),r}dispose(){this.lists=new Oe}}let Fp=0;class wp{constructor(){this.id=Fp++,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 c.Vector4,this.scissor=!1,this.scissorValue=new c.Vector4,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.sampleCount=1,this.width=0,this.height=0,this.isRenderContext=!0}getCacheKey(){return uu(this)}}function uu(o){const{textures:e,activeCubeFace:t}=o,s=[t];for(const n of e)s.push(n.id);return io(s)}class Up{constructor(){this.chainMaps={}}get(e,t,s=null){const n=[e,t];let r;if(s===null)r="default";else{const a=s.texture.format;r=`${s.textures.length}:${a}:${s.samples}:${s.depthBuffer}:${s.stencilBuffer}`}const i=this.getChainMap(r);let u=i.get(n);return u===void 0&&(u=new wp,i.set(n,u)),s!==null&&(u.sampleCount=s.samples===0?1:s.samples),u}getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new Oe)}dispose(){this.chainMaps={}}}const Gp=new c.Vector3;class Pp extends ot{constructor(e,t,s){super(),this.renderer=e,this.backend=t,this.info=s}updateRenderTarget(e,t=0){const s=this.get(e),n=e.samples===0?1:e.samples,r=s.depthTextureMips||(s.depthTextureMips={}),i=e.textures,u=this.getSize(i[0]),a=u.width>>t,l=u.height>>t;let d=e.depthTexture||r[t];const h=e.depthBuffer===!0||e.stencilBuffer===!0;let p=!1;d===void 0&&h&&(d=new c.DepthTexture,d.format=e.stencilBuffer?c.DepthStencilFormat:c.DepthFormat,d.type=e.stencilBuffer?c.UnsignedInt248Type:c.UnsignedIntType,d.image.width=a,d.image.height=l,r[t]=d),(s.width!==u.width||u.height!==s.height)&&(p=!0,d&&(d.needsUpdate=!0,d.image.width=a,d.image.height=l)),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!==n&&(p=!0,d&&(d.needsUpdate=!0),s.sampleCount=n);const f={sampleCount:n};for(let g=0;g<i.length;g++){const m=i[g];p&&(m.needsUpdate=!0),this.updateTexture(m,f)}if(d&&this.updateTexture(d,f),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 n=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,r=this.backend;if(n&&s.initialized===!0&&(r.destroySampler(e),r.destroyTexture(e)),e.isFramebufferTexture){const l=this.renderer.getRenderTarget();l?e.type=l.texture.type:e.type=c.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,n||e.isStorageTexture===!0)r.createSampler(e),r.createTexture(e,t),s.generation=e.version;else if(s.initialized!==!0&&r.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)&&(r.createTexture(e,t),s.isDefaultTexture=!1,s.generation=e.version),e.source.dataReady===!0&&r.updateTexture(e,t),t.needsMipmaps&&e.mipmaps.length===0&&r.generateMipmaps(e)}}else r.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 l=()=>{e.removeEventListener("dispose",l),this._destroyTexture(e),this.info.memory.textures--};e.addEventListener("dispose",l)}s.version=e.version}getSize(e,t=Gp){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 n;return e.isCompressedTexture?e.mipmaps?n=e.mipmaps.length:n=1:n=Math.floor(Math.log2(Math.max(t,s)))+1,n}needsMipmaps(e){return this.isEnvironmentTexture(e)||e.isCompressedTexture===!0||e.generateMipmaps}isEnvironmentTexture(e){const t=e.mapping;return t===c.EquirectangularReflectionMapping||t===c.EquirectangularRefractionMapping||t===c.CubeReflectionMapping||t===c.CubeRefractionMapping}_destroyTexture(e){this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e)}}class Ur extends c.Color{constructor(e,t,s,n=1){super(e,t,s),this.a=n}set(e,t,s,n=1){return this.a=n,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 cu extends K{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}class lu extends V{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const s=new Ms(t);return this._currentCond=Se(e,s),this.add(this._currentCond)}ElseIf(e,t){const s=new Ms(t),n=Se(e,s);return this._currentCond.elseNode=n,this._currentCond=n,this}Else(e){return this._currentCond.elseNode=new Ms(e),this}build(e,...t){const s=mo();Is(this);for(const n of this.nodes)n.build(e,"void");return Is(s),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const yn=C(lu);new c.Plane;new c.Vector3;new c.Vector3;new c.Vector3;new c.Matrix4;new c.Vector3(0,0,-1);new c.Vector4;new c.Vector3;new c.Vector3;new c.Vector4;new c.Vector2;const Dp=new c.RenderTarget;us.flipX();Dp.depthTexture=new c.DepthTexture(1,1);const _n=new c.OrthographicCamera(-1,1,1,-1,0,1);class Ip extends c.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 c.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new c.Float32BufferAttribute(t,2))}}const Lp=new Ip;class Gr extends c.Mesh{constructor(e=null){super(Lp,e),this.camera=_n,this.isQuadMesh=!0}renderAsync(e){return e.renderAsync(this,_n)}render(e){e.render(this,_n)}}const Wt=new c.Euler,Sn=new c.Matrix4;class me extends V{static get type(){return"SceneNode"}constructor(e=me.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 n;return t===me.BACKGROUND_BLURRINESS?n=Y("backgroundBlurriness","float",s):t===me.BACKGROUND_INTENSITY?n=Y("backgroundIntensity","float",s):t===me.BACKGROUND_ROTATION?n=O("mat4").label("backgroundRotation").setGroup(L).onRenderUpdate(()=>{const r=s.background;return r!==null&&r.isTexture&&r.mapping!==c.UVMapping?(Wt.copy(s.backgroundRotation),Wt.x*=-1,Wt.y*=-1,Wt.z*=-1,Sn.makeRotationFromEuler(Wt)):Sn.identity(),Sn}):console.error("THREE.SceneNode: Unknown scope:",t),n}}me.BACKGROUND_BLURRINESS="backgroundBlurriness";me.BACKGROUND_INTENSITY="backgroundIntensity";me.BACKGROUND_ROTATION="backgroundRotation";const Op=B(me,me.BACKGROUND_BLURRINESS),Bi=B(me,me.BACKGROUND_INTENSITY),Vp=B(me,me.BACKGROUND_ROTATION),kp=new c.Vector2;class zp extends Ot{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 Fi extends zp{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(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class ps extends ie{static get type(){return"PassNode"}constructor(e,t,s,n={}){super("vec4"),this.scope=e,this.scene=t,this.camera=s,this.options=n,this._pixelRatio=1,this._width=1,this._height=1;const r=new c.DepthTexture;r.isRenderTargetTexture=!0,r.name="depth";const i=new c.RenderTarget(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:c.HalfFloatType,...n});i.texture.name="output",i.depthTexture=r,this.renderTarget=i,this.updateBeforeType=z.FRAME,this._textures={output:i.texture,depth:r},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=O(0),this._cameraFar=O(0),this._mrt=null,this.isPassNode=!0}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.isRenderTargetTexture=!0,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(),t.isRenderTargetTexture=!0,this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const s=this._textures[e],n=this.renderTarget.textures.indexOf(s);this.renderTarget.textures[n]=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=v(new Fi(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=v(new Fi(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,n=this._cameraFar;this._viewZNodes[e]=t=Ea(this.getTextureNode(e),s,n)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const s=this._cameraNear,n=this._cameraFar,r=this.getViewZNode(e);this._linearDepthNodes[e]=t=Jt(r,s,n)}return t}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,e.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.depthTexture.isMultisampleRenderTargetTexture=this.renderTarget.samples>1,this.scope===ps.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:s,camera:n}=this;this._pixelRatio=t.getPixelRatio();const r=t.getSize(kp);this.setSize(r.width,r.height);const i=t.getRenderTarget(),u=t.getMRT();this._cameraNear.value=n.near,this._cameraFar.value=n.far;for(const a in this._previousTextures)this.toggleTexture(a);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(s,n),t.setRenderTarget(i),t.setMRT(u)}setSize(e,t){this._width=e,this._height=t;const s=this._width*this._pixelRatio,n=this._height*this._pixelRatio;this.renderTarget.setSize(s,n)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}ps.COLOR="color";ps.DEPTH="depth";const $p=M(([o,e])=>o.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Wp=M(([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"}]}),Hp=M(([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"}]}),qp=M(([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)}),Kp=M(([o,e])=>{const t=Te(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=Te(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return o=o.mul(e).div(.6),o=t.mul(o),o=qp(o),o=s.mul(o),o.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Xp=Te(R(1.6605,-.1246,-.0182),R(-.5876,1.1329,-.1006),R(-.0728,-.0083,1.1187)),Yp=Te(R(.6274,.0691,.0164),R(.3293,.9195,.088),R(.0433,.0113,.8956)),Qp=M(([o])=>{const e=R(o).toVar(),t=R(e.mul(e)).toVar(),s=R(t.mul(t)).toVar();return x(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))))}),jp=M(([o,e])=>{const t=R(o).toVar(),s=Te(R(.856627153315983,.137318972929847,.11189821299995),R(.0951212405381588,.761241990602591,.0767994186031903),R(.0482516061458583,.101439036467562,.811302368396859)),n=Te(R(1.1271005818144368,-.1413297634984383,-.14132976349843826),R(-.11060664309660323,1.157823702216272,-.11060664309660294),R(-.016493938717834573,-.016493938717834257,1.2519364065950405)),r=x(-12.47393),i=x(4.026069);return t.mulAssign(e),t.assign(Yp.mul(t)),t.assign(s.mul(t)),t.assign(Ne(t,1e-10)),t.assign(qe(t)),t.assign(t.sub(r).div(i.sub(r))),t.assign(Xe(t,0,1)),t.assign(Qp(t)),t.assign(n.mul(t)),t.assign(Ys(Ne(R(0),t),R(2.2))),t.assign(Xp.mul(t)),t.assign(Xe(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Zp=M(([o,e])=>{const t=x(.76),s=x(.15);o=o.mul(e);const n=rs(o.r,rs(o.g,o.b)),r=Se(n.lessThan(.08),n.sub($(6.25,n.mul(n))),.04);o.subAssign(r);const i=Ne(o.r,Ne(o.g,o.b));ce(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 l=_e(1,Ke(1,s.mul(i.sub(a)).add(1)));return Z(o,R(a),l)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class ae extends V{static get type(){return"CodeNode"}constructor(e="",t=[],s=""){super("code"),this.isCodeNode=!0,this.code=e,this.language=s,this.includes=t}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const n of t)n.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 du extends ae{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),n=s.name,r=s.type,i=e.getCodeFromNode(this,r);n!==""&&(i.name=n);const u=e.getPropertyName(i),a=this.getNodeFunction(e).getCode(u);return i.code=a+`
25
+ `,t==="property"?u:e.format(`${u}()`,r,t)}}class Pr extends V{static get type(){return"FogNode"}constructor(e,t){super("float"),this.isFogNode=!0,this.colorNode=e,this.factorNode=t}getViewZNode(e){let t;const s=e.context.getViewZ;return s!==void 0&&(t=s(this)),(t||de.z).negate()}setup(){return this.factorNode}}class hu extends Pr{static get type(){return"FogRangeNode"}constructor(e,t,s){super(e),this.isFogRangeNode=!0,this.nearNode=t,this.farNode=s}setup(e){const t=this.getViewZNode(e);return mt(this.nearNode,this.farNode,t)}}const Jp=C(hu);class pu extends Pr{static get type(){return"FogExp2Node"}constructor(e,t){super(e),this.isFogExp2Node=!0,this.densityNode=t}setup(e){const t=this.getViewZNode(e),s=this.densityNode;return s.mul(s,t,t).negate().exp().oneMinus()}}const ef=C(pu);class tf 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
26
+ `):e.addLineFlowCode(`${t}Barrier()`,this)}}C(tf);class ke extends ie{static get type(){return"AtomicFunctionNode"}constructor(e,t,s,n=null){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=s,this.storeNode=n}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=this.method,s=this.getNodeType(e),n=this.getInputType(e),r=this.pointerNode,i=this.valueNode,u=[];u.push(`&${r.build(e,n)}`),u.push(i.build(e,n));const a=`${e.getMethod(t,s)}( ${u.join(", ")} )`;if(this.storeNode!==null){const l=this.storeNode.build(e,n);e.addLineFlowCode(`${l} = ${a}`,this)}else e.addLineFlowCode(a,this)}}ke.ATOMIC_LOAD="atomicLoad";ke.ATOMIC_STORE="atomicStore";ke.ATOMIC_ADD="atomicAdd";ke.ATOMIC_SUB="atomicSub";ke.ATOMIC_MAX="atomicMax";ke.ATOMIC_MIN="atomicMin";ke.ATOMIC_AND="atomicAnd";ke.ATOMIC_OR="atomicOr";ke.ATOMIC_XOR="atomicXor";C(ke);let _s;function fs(o){_s=_s||new WeakMap;let e=_s.get(o);return e===void 0&&_s.set(o,e={}),e}function fu(o){const e=fs(o);return e.shadowMatrix||(e.shadowMatrix=O("mat4").setGroup(L).onRenderUpdate(()=>(o.shadow.updateMatrices(o),o.shadow.matrix)))}function sf(o){const e=fs(o);if(e.projectionUV===void 0){const t=fu(o).mul(os);e.projectionUV=t.xyz.div(t.w)}return e.projectionUV}function gu(o){const e=fs(o);return e.position||(e.position=O(new c.Vector3).setGroup(L).onRenderUpdate((t,s)=>s.value.setFromMatrixPosition(o.matrixWorld)))}function nf(o){const e=fs(o);return e.targetPosition||(e.targetPosition=O(new c.Vector3).setGroup(L).onRenderUpdate((t,s)=>s.value.setFromMatrixPosition(o.target.matrixWorld)))}function Dr(o){const e=fs(o);return e.viewPosition||(e.viewPosition=O(new c.Vector3).setGroup(L).onRenderUpdate(({camera:t},s)=>{s.value=s.value||new c.Vector3,s.value.setFromMatrixPosition(o.matrixWorld),s.value.applyMatrix4(t.matrixWorldInverse)}))}const mu=o=>je.transformDirection(gu(o).sub(nf(o))),rf=o=>o.sort((e,t)=>e.id-t.id),of=(o,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===o)return t;return null},Nn=new WeakMap;class Ir extends V{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=R().toVar("totalDiffuse"),this.totalSpecularNode=R().toVar("totalSpecular"),this.outgoingLightNode=R().toVar("outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}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.getDataFromNode(this);for(const s of t.nodes)s.build(e)}setupLightsNode(e){const t=[],s=this._lightNodes,n=rf(this._lights),r=e.renderer.library;for(const i of n)if(i.isNode)t.push(v(i));else{let u=null;if(s!==null&&(u=of(i.id,s)),u===null){const a=r.getLightNodeClass(i.constructor);if(a===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${i.constructor.name}`);continue}let l=null;Nn.has(i)?l=Nn.get(i):(l=v(new a(i)),Nn.set(i,l)),t.push(l)}}this._lightNodes=t}setupLights(e,t){for(const s of t)s.build(e)}setup(e){this._lightNodes===null&&this.setupLightsNode(e);const t=e.context,s=t.lightingModel;let n=this.outgoingLightNode;if(s){const{_lightNodes:r,totalDiffuseNode:i,totalSpecularNode:u}=this;t.outgoingLight=n;const a=e.addStack(),l=e.getDataFromNode(this);l.nodes=a.nodes,s.start(t,a,e),this.setupLights(e,r),s.indirect(t,a,e);const{backdrop:d,backdropAlpha:h}=t,{directDiffuse:p,directSpecular:f,indirectDiffuse:g,indirectSpecular:m}=t.reflectedLight;let y=p.add(g);d!==null&&(h!==null?y=R(h.mix(y,d)):y=R(d),t.material.transparent=!0),i.assign(y),u.assign(f.add(m)),n.assign(i.add(u)),s.finish(t,a,e),n=n.bypass(e.removeStack())}return n}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}const wi=new WeakMap,Ui=R().toVar("shadowWorldPosition"),af=M(([o,e,t])=>{let s=os.sub(o).length();return s=s.sub(e).div(t.sub(e)),s=s.saturate(),s}),uf=o=>{const e=o.shadow.camera,t=Y("near","float",e).setGroup(L),s=Y("far","float",e).setGroup(L),n=ql(o);return af(n,t,s)},cf=o=>{let e=wi.get(o);if(e===void 0){const t=o.isPointLight?uf(o):null;e=new re,e.colorNode=k(0,0,0,1),e.depthNode=t,e.isShadowNodeMaterial=!0,e.blending=c.NoBlending,e.name="ShadowMaterial",wi.set(o,e)}return e},lf=M(({depthTexture:o,shadowCoord:e})=>H(o,e.xy).compare(e.z)),df=M(({depthTexture:o,shadowCoord:e,shadow:t})=>{const s=(m,y)=>H(o,m).compare(y),n=Y("mapSize","vec2",t).setGroup(L),r=Y("radius","float",t).setGroup(L),i=F(1).div(n),u=i.x.negate().mul(r),a=i.y.negate().mul(r),l=i.x.mul(r),d=i.y.mul(r),h=u.div(2),p=a.div(2),f=l.div(2),g=d.div(2);return ye(s(e.xy.add(F(u,a)),e.z),s(e.xy.add(F(0,a)),e.z),s(e.xy.add(F(l,a)),e.z),s(e.xy.add(F(h,p)),e.z),s(e.xy.add(F(0,p)),e.z),s(e.xy.add(F(f,p)),e.z),s(e.xy.add(F(u,0)),e.z),s(e.xy.add(F(h,0)),e.z),s(e.xy,e.z),s(e.xy.add(F(f,0)),e.z),s(e.xy.add(F(l,0)),e.z),s(e.xy.add(F(h,g)),e.z),s(e.xy.add(F(0,g)),e.z),s(e.xy.add(F(f,g)),e.z),s(e.xy.add(F(u,d)),e.z),s(e.xy.add(F(0,d)),e.z),s(e.xy.add(F(l,d)),e.z)).mul(1/17)}),hf=M(({depthTexture:o,shadowCoord:e,shadow:t})=>{const s=(d,h)=>H(o,d).compare(h),n=Y("mapSize","vec2",t).setGroup(L),r=F(1).div(n),i=r.x,u=r.y,a=e.xy,l=it(a.mul(n).add(.5));return a.subAssign(l.mul(r)),ye(s(a,e.z),s(a.add(F(i,0)),e.z),s(a.add(F(0,u)),e.z),s(a.add(r),e.z),Z(s(a.add(F(i.negate(),0)),e.z),s(a.add(F(i.mul(2),0)),e.z),l.x),Z(s(a.add(F(i.negate(),u)),e.z),s(a.add(F(i.mul(2),u)),e.z),l.x),Z(s(a.add(F(0,u.negate())),e.z),s(a.add(F(0,u.mul(2))),e.z),l.y),Z(s(a.add(F(i,u.negate())),e.z),s(a.add(F(i,u.mul(2))),e.z),l.y),Z(Z(s(a.add(F(i.negate(),u.negate())),e.z),s(a.add(F(i.mul(2),u.negate())),e.z),l.x),Z(s(a.add(F(i.negate(),u.mul(2))),e.z),s(a.add(F(i.mul(2),u.mul(2))),e.z),l.x),l.y)).mul(1/9)}),pf=M(({depthTexture:o,shadowCoord:e})=>{const t=x(1).toVar(),s=H(o).uv(e.xy).rg,n=Po(e.z,s.x);return ce(n.notEqual(x(1)),()=>{const r=e.z.sub(s.x),i=Ne(0,s.y.mul(s.y));let u=i.div(i.add(r.mul(r)));u=Xe(_e(u,.3).div(.95-.3)),t.assign(Xe(Ne(n,u)))}),t}),ff=M(({samples:o,radius:e,size:t,shadowPass:s})=>{const n=x(0).toVar(),r=x(0).toVar(),i=o.lessThanEqual(x(1)).select(x(0),x(2).div(o.sub(1))),u=o.lessThanEqual(x(1)).select(x(0),x(-1));we({start:te(0),end:te(o),type:"int",condition:"<"},({i:l})=>{const d=u.add(x(l).mul(i)),h=s.uv(ye(en.xy,F(0,d).mul(e)).div(t)).x;n.addAssign(h),r.addAssign(h.mul(h))}),n.divAssign(o),r.divAssign(o);const a=fr(r.sub(n.mul(n)));return F(n,a)}),gf=M(({samples:o,radius:e,size:t,shadowPass:s})=>{const n=x(0).toVar(),r=x(0).toVar(),i=o.lessThanEqual(x(1)).select(x(0),x(2).div(o.sub(1))),u=o.lessThanEqual(x(1)).select(x(0),x(-1));we({start:te(0),end:te(o),type:"int",condition:"<"},({i:l})=>{const d=u.add(x(l).mul(i)),h=s.uv(ye(en.xy,F(d,0).mul(e)).div(t));n.addAssign(h.x),r.addAssign(ye(h.y.mul(h.y),h.x.mul(h.x)))}),n.divAssign(o),r.divAssign(o);const a=fr(r.sub(n.mul(n)));return F(n,a)}),mf=[lf,df,hf,pf],Ss=new Gr;class Lr extends V{static get type(){return"ShadowNode"}constructor(e,t=null){super(),this.light=e,this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this.updateBeforeType=z.RENDER,this._node=null,this.isShadowNode=!0}setupShadowFilter(e,{filterFn:t,depthTexture:s,shadowCoord:n,shadow:r}){const i=n.x.greaterThanEqual(0).and(n.x.lessThanEqual(1)).and(n.y.greaterThanEqual(0)).and(n.y.lessThanEqual(1)).and(n.z.lessThanEqual(1)),u=t({depthTexture:s,shadowCoord:n,shadow:r});return i.select(u,x(1))}setupShadowCoord(e,t){const{shadow:s}=this,{renderer:n}=e,r=Y("bias","float",s).setGroup(L);let i=t,u;if(s.camera.isOrthographicCamera||n.logarithmicDepthBuffer!==!0)i=i.xyz.div(i.w),u=i.z,n.coordinateSystem===c.WebGPUCoordinateSystem&&(u=u.mul(2).sub(1));else{const a=i.w;i=i.xy.div(a);const l=Y("near","float",s.camera).setGroup(L),d=Y("far","float",s.camera).setGroup(L);u=Ma(a.negate(),l,d)}return i=R(i.x,i.y.oneMinus(),u.add(r)),i}getShadowFilterFn(e){return mf[e]}setupShadow(e){const{renderer:t}=e,{light:s,shadow:n}=this,r=t.shadowMap.type,i=new c.DepthTexture(n.mapSize.width,n.mapSize.height);i.compareFunction=c.LessCompare;const u=e.createRenderTarget(n.mapSize.width,n.mapSize.height);if(u.depthTexture=i,n.camera.updateProjectionMatrix(),r===c.VSMShadowMap){i.compareFunction=null,this.vsmShadowMapVertical=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:c.RGFormat,type:c.HalfFloatType}),this.vsmShadowMapHorizontal=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:c.RGFormat,type:c.HalfFloatType});const S=H(i),A=H(this.vsmShadowMapVertical.texture),E=Y("blurSamples","float",n).setGroup(L),D=Y("radius","float",n).setGroup(L),w=Y("mapSize","vec2",n).setGroup(L);let U=this.vsmMaterialVertical||(this.vsmMaterialVertical=new re);U.fragmentNode=ff({samples:E,radius:D,size:w,shadowPass:S}).context(e.getSharedContext()),U.name="VSMVertical",U=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new re),U.fragmentNode=gf({samples:E,radius:D,size:w,shadowPass:A}).context(e.getSharedContext()),U.name="VSMHorizontal"}const a=Y("intensity","float",n).setGroup(L),l=Y("normalBias","float",n).setGroup(L),d=fu(s).mul(Ui.add(Rr.mul(l))),h=this.setupShadowCoord(e,d),p=n.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(p===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const f=r===c.VSMShadowMap?this.vsmShadowMapHorizontal.texture:i,g=this.setupShadowFilter(e,{filterFn:p,shadowTexture:u.texture,depthTexture:f,shadowCoord:h,shadow:n}),m=H(u.texture,h),y=Z(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 M(({material:t})=>{Ui.assign(t.shadowPositionNode||os);let s=this._node;return s===null&&(this._node=s=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(s=e.material.receivedShadowNode(s)),s})()}renderShadow(e){const{shadow:t,shadowMap:s}=this,{renderer:n,scene:r}=e;s.setSize(t.mapSize.width,t.mapSize.height),n.render(r,t.camera)}updateShadow(e){const{shadowMap:t,light:s,shadow:n}=this,{renderer:r,scene:i,camera:u}=e,a=r.shadowMap.type,l=t.depthTexture.version;this._depthVersionCached=l;const d=i.overrideMaterial;i.overrideMaterial=cf(s),n.camera.layers.mask=u.layers.mask;const h=r.getRenderTarget(),p=r.getRenderObjectFunction(),f=r.getMRT();r.setMRT(null),r.setRenderObjectFunction((g,...m)=>{(g.castShadow===!0||g.receiveShadow&&a===c.VSMShadowMap)&&r.renderObject(g,...m)}),r.setRenderTarget(t),this.renderShadow(e),r.setRenderObjectFunction(p),s.isPointLight!==!0&&a===c.VSMShadowMap&&this.vsmPass(r),r.setRenderTarget(h),r.setMRT(f),i.overrideMaterial=d}vsmPass(e){const{shadow:t}=this;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height),e.setRenderTarget(this.vsmShadowMapVertical),Ss.material=this.vsmMaterialVertical,Ss.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Ss.material=this.vsmMaterialHorizontal,Ss.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),this.updateBeforeType=z.NONE}updateBefore(e){const{shadow:t}=this;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const Tf=(o,e)=>v(new Lr(o,e));class at extends _t{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new c.Color,this.colorNode=e&&e.colorNode||O(this.color).setGroup(L),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=z.FRAME}getCacheKey(){return oo(super.getCacheKey(),this.light.id,this.light.castShadow?1:0)}getHash(){return this.light.uuid}setupShadowNode(){return Tf(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let s=this.shadowColorNode;if(s===null){const n=this.light.shadow.shadowNode;let r;n!==void 0?r=v(n):r=this.setupShadowNode(e),this.shadowNode=r,this.shadowColorNode=s=this.colorNode.mul(r),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)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const Tu=M(o=>{const{lightDistance:e,cutoffDistance:t,decayExponent:s}=o,n=e.pow(s).max(.01).reciprocal();return t.greaterThan(0).select(n.mul(e.div(t).pow4().oneMinus().clamp().pow2()),n)}),yf=new c.Color,Pe=M(([o,e])=>{const t=o.toVar(),s=Ee(t),n=Ke(1,Ne(s.x,Ne(s.y,s.z)));s.mulAssign(n),t.mulAssign(n.mul(e.mul(2).oneMinus()));const r=F(t.xy).toVar(),u=e.mul(1.5).oneMinus();return ce(s.z.greaterThanEqual(u),()=>{ce(t.z.greaterThan(0),()=>{r.x.assign(_e(4,t.x))})}).ElseIf(s.x.greaterThanEqual(u),()=>{const a=zs(t.x);r.x.assign(t.z.mul(a).add(a.mul(2)))}).ElseIf(s.y.greaterThanEqual(u),()=>{const a=zs(t.y);r.x.assign(t.x.add(a.mul(2)).add(2)),r.y.assign(t.z.mul(a).sub(2))}),F(.125,.25).mul(r).add(F(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),_f=M(({depthTexture:o,bd3D:e,dp:t,texelSize:s})=>H(o,Pe(e,s.y)).compare(t)),Sf=M(({depthTexture:o,bd3D:e,dp:t,texelSize:s,shadow:n})=>{const r=Y("radius","float",n).setGroup(L),i=F(-1,1).mul(r).mul(s.y);return H(o,Pe(e.add(i.xyy),s.y)).compare(t).add(H(o,Pe(e.add(i.yyy),s.y)).compare(t)).add(H(o,Pe(e.add(i.xyx),s.y)).compare(t)).add(H(o,Pe(e.add(i.yyx),s.y)).compare(t)).add(H(o,Pe(e,s.y)).compare(t)).add(H(o,Pe(e.add(i.xxy),s.y)).compare(t)).add(H(o,Pe(e.add(i.yxy),s.y)).compare(t)).add(H(o,Pe(e.add(i.xxx),s.y)).compare(t)).add(H(o,Pe(e.add(i.yxx),s.y)).compare(t)).mul(1/9)}),Nf=M(({filterFn:o,depthTexture:e,shadowCoord:t,shadow:s})=>{const n=t.xyz.toVar(),r=n.length(),i=O("float").setGroup(L).onRenderUpdate(()=>s.camera.near),u=O("float").setGroup(L).onRenderUpdate(()=>s.camera.far),a=Y("bias","float",s).setGroup(L),l=O(s.mapSize).setGroup(L),d=x(1).toVar();return ce(r.sub(u).lessThanEqual(0).and(r.sub(i).greaterThanEqual(0)),()=>{const h=r.sub(i).div(u.sub(i)).toVar();h.addAssign(a);const p=n.normalize(),f=F(1).div(l.mul(F(4,2)));d.assign(o({depthTexture:e,bd3D:p,dp:h,texelSize:f,shadow:s}))}),d}),Gi=new c.Vector4,bt=new c.Vector2,Ht=new c.Vector2;class xf extends Lr{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===c.BasicShadowMap?_f:Sf}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:s,depthTexture:n,shadowCoord:r,shadow:i}){return Nf({filterFn:t,shadowTexture:s,depthTexture:n,shadowCoord:r,shadow:i})}renderShadow(e){const{shadow:t,shadowMap:s,light:n}=this,{renderer:r,scene:i}=e,u=t.getFrameExtents();Ht.copy(t.mapSize),Ht.multiply(u),s.setSize(Ht.width,Ht.height),bt.copy(t.mapSize);const a=r.autoClear,l=r.getClearColor(yf),d=r.getClearAlpha();r.autoClear=!1,r.setClearColor(t.clearColor,t.clearAlpha),r.clear();const h=t.getViewportCount();for(let p=0;p<h;p++){const f=t.getViewport(p),g=bt.x*f.x,m=Ht.y-bt.y-bt.y*f.y;Gi.set(g,m,bt.x*f.z,bt.y*f.w),s.viewport.copy(Gi),t.updateMatrices(n,p),r.render(i,t.camera)}r.autoClear=a,r.setClearColor(l,d)}}const bf=(o,e)=>v(new xf(o,e)),Rf=M(({color:o,lightViewPosition:e,cutoffDistance:t,decayExponent:s},n)=>{const r=n.context.lightingModel,i=e.sub(de),u=i.normalize(),a=i.length(),l=Tu({lightDistance:a,cutoffDistance:t,decayExponent:s}),d=o.mul(l),h=n.context.reflectedLight;r.direct({lightDirection:u,lightColor:d,reflectedLight:h},n.stack,n)});class yu extends at{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=O(0).setGroup(L),this.decayExponentNode=O(0).setGroup(L)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return bf(this.light)}setup(e){super.setup(e),Rf({color:this.colorNode,lightViewPosition:Dr(this.light),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode}).append()}}const Af=M(([o,e])=>{const t=o.x,s=o.y,n=o.z;let r=e.element(0).mul(.886227);return r=r.add(e.element(1).mul(2*.511664).mul(s)),r=r.add(e.element(2).mul(2*.511664).mul(n)),r=r.add(e.element(3).mul(2*.511664).mul(t)),r=r.add(e.element(4).mul(2*.429043).mul(t).mul(s)),r=r.add(e.element(5).mul(2*.429043).mul(s).mul(n)),r=r.add(e.element(6).mul(n.mul(n).mul(.743125).sub(.247708))),r=r.add(e.element(7).mul(2*.429043).mul(t).mul(n)),r=r.add(e.element(8).mul(.429043).mul($(t,t).sub($(s,s)))),r}),$e=new Ur;class Cf extends ot{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,s){const n=this.renderer,r=this.nodes.getBackgroundNode(e)||e.background;let i=!1;if(r===null)n._clearColor.getRGB($e,c.LinearSRGBColorSpace),$e.a=n._clearColor.a;else if(r.isColor===!0)r.getRGB($e,c.LinearSRGBColorSpace),$e.a=1,i=!0;else if(r.isNode===!0){const u=this.get(e),a=r;$e.copy(n._clearColor);let l=u.backgroundMesh;if(l===void 0){const h=yr(k(a).mul(Bi),{getUV:()=>Vp.mul(na),getTextureLevel:()=>Op});let p=ga();p=p.setZ(p.w);const f=new re;f.name="Background.material",f.side=c.BackSide,f.depthTest=!1,f.depthWrite=!1,f.fog=!1,f.lights=!1,f.vertexNode=p,f.colorNode=h,u.backgroundMeshNode=h,u.backgroundMesh=l=new c.Mesh(new c.SphereGeometry(1,32,32),f),l.frustumCulled=!1,l.name="Background.mesh",l.onBeforeRender=function(g,m,y){this.matrixWorld.copyPosition(y.matrixWorld)}}const d=a.getCacheKey();u.backgroundCacheKey!==d&&(u.backgroundMeshNode.node=k(a).mul(Bi),u.backgroundMeshNode.needsUpdate=!0,l.material.needsUpdate=!0,u.backgroundCacheKey=d),t.unshift(l,l.geometry,l.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",r);if(n.autoClear===!0||i===!0){const u=s.clearColorValue;u.r=$e.r,u.g=$e.g,u.b=$e.b,u.a=$e.a,(n.backend.isWebGLBackend===!0||n.alpha===!0)&&(u.r*=u.a,u.g*=u.a,u.b*=u.a),s.depthClearValue=n._clearDepth,s.stencilClearValue=n._clearStencil,s.clearColor=n.autoClearColor===!0,s.clearDepth=n.autoClearDepth===!0,s.clearStencil=n.autoClearStencil===!0}else s.clearColor=!1,s.clearDepth=!1,s.clearStencil=!1}}let vf=0;class er{constructor(e="",t=[],s=0,n=[]){this.name=e,this.bindings=t,this.index=s,this.bindingsReference=n,this.id=vf++}}class Ef{constructor(e,t,s,n,r,i,u,a,l,d=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=s,this.transforms=d,this.nodeAttributes=n,this.bindings=r,this.updateNodes=i,this.updateBeforeNodes=u,this.updateAfterNodes=a,this.monitor=l,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const n=new er(t.name,[],t.index,t);e.push(n);for(const r of t.bindings)n.bindings.push(r.clone())}else e.push(t);return e}}class tr{constructor(e,t,s=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=s}}class _u{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 Or{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class Su extends Or{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class Nu{constructor(e,t,s=""){this.name=e,this.type=t,this.code=s,Object.defineProperty(this,"isNodeCode",{value:!0})}}let Mf=0;class Gs{constructor(e=null){this.id=Mf++,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 St{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 Bf extends St{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class Ff extends St{constructor(e,t=new c.Vector2){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class wf extends St{constructor(e,t=new c.Vector3){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class Uf extends St{constructor(e,t=new c.Vector4){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class Gf extends St{constructor(e,t=new c.Color){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class Pf extends St{constructor(e,t=new c.Matrix3){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class Df extends St{constructor(e,t=new c.Matrix4){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class If extends Bf{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Lf extends Ff{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Of extends wf{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Vf extends Uf{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class kf extends Gf{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class zf extends Pf{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class $f extends Df{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const Mt=4,Pi=[.125,.215,.35,.446,.526,.582],pt=20,xn=new c.OrthographicCamera(-1,1,1,-1,0,1),Wf=new c.PerspectiveCamera(90,1),Di=new c.Color;let bn=null,Rn=0,An=0;const lt=(1+Math.sqrt(5))/2,Rt=1/lt,Ii=[new c.Vector3(-lt,Rt,0),new c.Vector3(lt,Rt,0),new c.Vector3(-Rt,0,lt),new c.Vector3(Rt,0,lt),new c.Vector3(0,lt,-Rt),new c.Vector3(0,lt,Rt),new c.Vector3(-1,1,-1),new c.Vector3(1,1,-1),new c.Vector3(-1,1,1),new c.Vector3(1,1,1)],Hf=[3,1,5,0,4,2],Cn=qh(Qs(),Ye("faceIndex")).normalize(),Vr=R(Cn.x,Cn.y.negate(),Cn.z);class xu{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,n=100,r=null){if(this._setSize(256),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const u=r||this._allocateTargets();return this.fromSceneAsync(e,t,s,n,u),u}bn=this._renderer.getRenderTarget(),Rn=this._renderer.getActiveCubeFace(),An=this._renderer.getActiveMipmapLevel();const i=r||this._allocateTargets();return i.depthBuffer=!0,this._sceneToCubeUV(e,s,n,i),t>0&&this._blur(i,0,0,t),this._applyPMREM(i),this._cleanup(i),i}async fromSceneAsync(e,t=0,s=.1,n=100,r=null){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,t,s,n,r)}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._allocateTargets();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._allocateTargets();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=Oi(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Vi(),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===c.CubeReflectionMapping||e.mapping===c.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(bn,Rn,An),e.scissorTest=!1,Ns(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),bn=this._renderer.getRenderTarget(),Rn=this._renderer.getActiveCubeFace(),An=this._renderer.getActiveMipmapLevel();const s=t||this._allocateTargets();return this._textureToCubeUV(e,s),this._applyPMREM(s),this._cleanup(s),s}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,s={magFilter:c.LinearFilter,minFilter:c.LinearFilter,generateMipmaps:!1,type:c.HalfFloatType,format:c.RGBAFormat,colorSpace:c.LinearSRGBColorSpace},n=Li(e,t,s);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Li(e,t,s);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=qf(r)),this._blurMaterial=Kf(r,e,t)}return n}async _compileMaterial(e){const t=new c.Mesh(this._lodPlanes[0],e);await this._renderer.compile(t,xn)}_sceneToCubeUV(e,t,s,n){const r=Wf;r.near=t,r.far=s;const i=[-1,1,-1,-1,-1,-1],u=[1,1,1,-1,-1,-1],a=this._renderer,l=a.autoClear;a.getClearColor(Di),a.autoClear=!1;let d=this._backgroundBox;if(d===null){const f=new c.MeshBasicMaterial({name:"PMREM.Background",side:c.BackSide,depthWrite:!1,depthTest:!1});d=new c.Mesh(new c.BoxGeometry,f)}let h=!1;const p=e.background;p?p.isColor&&(d.material.color.copy(p),e.background=null,h=!0):(d.material.color.copy(Di),h=!0),a.setRenderTarget(n),a.clear(),h&&a.render(d,r);for(let f=0;f<6;f++){const g=f%3;g===0?(r.up.set(0,i[f],0),r.lookAt(u[f],0,0)):g===1?(r.up.set(0,0,i[f]),r.lookAt(0,u[f],0)):(r.up.set(0,i[f],0),r.lookAt(0,0,u[f]));const m=this._cubeSize;Ns(n,g*m,f>2?m:0,m,m),a.render(e,r)}a.autoClear=l,e.background=p}_textureToCubeUV(e,t){const s=this._renderer,n=e.mapping===c.CubeReflectionMapping||e.mapping===c.CubeRefractionMapping;n?this._cubemapMaterial===null&&(this._cubemapMaterial=Oi(e)):this._equirectMaterial===null&&(this._equirectMaterial=Vi(e));const r=n?this._cubemapMaterial:this._equirectMaterial;r.fragmentNode.value=e;const i=this._lodMeshes[0];i.material=r;const u=this._cubeSize;Ns(t,0,0,3*u,2*u),s.setRenderTarget(t),s.render(i,xn)}_applyPMREM(e){const t=this._renderer,s=t.autoClear;t.autoClear=!1;const n=this._lodPlanes.length;for(let r=1;r<n;r++){const i=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),u=Ii[(n-r-1)%Ii.length];this._blur(e,r-1,r,i,u)}t.autoClear=s}_blur(e,t,s,n,r){const i=this._pingPongRenderTarget;this._halfBlur(e,i,t,s,n,"latitudinal",r),this._halfBlur(i,e,s,s,n,"longitudinal",r)}_halfBlur(e,t,s,n,r,i,u){const a=this._renderer,l=this._blurMaterial;i!=="latitudinal"&&i!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,h=this._lodMeshes[n];h.material=l;const p=l.uniforms,f=this._sizeLods[s]-1,g=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*pt-1),m=r/g,y=isFinite(r)?1+Math.floor(d*m):pt;y>pt&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${pt}`);const S=[];let A=0;for(let G=0;G<pt;++G){const P=G/m,Q=Math.exp(-P*P/2);S.push(Q),G===0?A+=Q:G<y&&(A+=2*Q)}for(let G=0;G<S.length;G++)S[G]=S[G]/A;e.texture.frame=(e.texture.frame||0)+1,p.envMap.value=e.texture,p.samples.value=y,p.weights.array=S,p.latitudinal.value=i==="latitudinal"?1:0,u&&(p.poleAxis.value=u);const{_lodMax:E}=this;p.dTheta.value=g,p.mipInt.value=E-s;const D=this._sizeLods[n],w=3*D*(n>E-Mt?n-E+Mt:0),U=4*(this._cubeSize-D);Ns(t,w,U,3*D,2*D),a.setRenderTarget(t),a.render(h,xn)}}function qf(o){const e=[],t=[],s=[],n=[];let r=o;const i=o-Mt+1+Pi.length;for(let u=0;u<i;u++){const a=Math.pow(2,r);t.push(a);let l=1/a;u>o-Mt?l=Pi[u-o+Mt-1]:u===0&&(l=0),s.push(l);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,S=2,A=1,E=new Float32Array(y*m*g),D=new Float32Array(S*m*g),w=new Float32Array(A*m*g);for(let G=0;G<g;G++){const P=G%3*2/3-1,Q=G>2?0:-1,se=[P,Q,0,P+2/3,Q,0,P+2/3,Q+1,0,P,Q,0,P+2/3,Q+1,0,P,Q+1,0],X=Hf[G];E.set(se,y*m*X),D.set(f,S*m*X);const xe=[X,X,X,X,X,X];w.set(xe,A*m*X)}const U=new c.BufferGeometry;U.setAttribute("position",new c.BufferAttribute(E,y)),U.setAttribute("uv",new c.BufferAttribute(D,S)),U.setAttribute("faceIndex",new c.BufferAttribute(w,A)),e.push(U),n.push(new c.Mesh(U,null)),r>Mt&&r--}return{lodPlanes:e,sizeLods:t,sigmas:s,lodMeshes:n}}function Li(o,e,t){const s=new c.RenderTarget(o,e,t);return s.texture.mapping=c.CubeUVReflectionMapping,s.texture.name="PMREM.cubeUv",s.texture.isPMREMTexture=!0,s.scissorTest=!0,s}function Ns(o,e,t,s,n){o.viewport.set(e,t,s,n),o.scissor.set(e,t,s,n)}function kr(o){const e=new re;return e.depthTest=!1,e.depthWrite=!1,e.blending=c.NoBlending,e.name=`PMREM_${o}`,e}function Kf(o,e,t){const s=tt(new Array(pt).fill(0)),n=O(new c.Vector3(0,1,0)),r=O(0),i=x(pt),u=O(0),a=O(1),l=H(null),d=O(0),h=x(1/e),p=x(1/t),f=x(o),g={n:i,latitudinal:u,weights:s,poleAxis:n,outputDirection:Vr,dTheta:r,samples:a,envMap:l,mipInt:d,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:f},m=kr("blur");return m.uniforms=g,m.fragmentNode=Xh({...g,latitudinal:u.equal(1)}),m}function Oi(o){const e=kr("cubemap");return e.fragmentNode=as(o,Vr),e}function Vi(o){const e=kr("equirect");return e.fragmentNode=H(o,Da(Vr),0),e}const ki=new WeakMap,Xf=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),xs=o=>/e/g.test(o)?String(o).replace(/\+/g,""):(o=Number(o),o+(o%1?"":".0"));class zr{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.monitor=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.flow={code:""},this.chaining=[],this.stack=yn(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new Gs,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=ki.get(this.renderer);return e===void 0&&(e=new Oe,ki.set(this.renderer,e)),e}createRenderTarget(e,t,s){return new c.RenderTarget(e,t,s)}createCubeRenderTarget(e,t){return new Ia(e,t)}createPMREMGenerator(){return new xu(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const s=this.getBindGroupsCache(),n=[];let r=!0;for(const u of t)n.push(u),r=r&&u.groupNode.shared!==!0;let i;return r?(i=s.get(n),i===void 0&&(i=new er(e,n,this.bindingsIndexes[e].group,n),s.set(n,i))):i=new er(e,n,this.bindingsIndexes[e].group,n),i}getBindGroupArray(e,t){const s=this.bindings[t];let n=s[e];return n===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),s[e]=n=[]),n}getBindings(){let e=this.bindGroups;if(e===null){const t={},s=this.bindings;for(const n of zn)for(const r in s[n]){const i=s[n][r];(t[r]||(t[r]=[])).push(...i)}e=[];for(const n in t){const r=t[n],i=this._getBindGroup(n,r);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===c.LinearFilter||e.magFilter===c.LinearMipmapNearestFilter||e.magFilter===c.NearestMipmapLinearFilter||e.magFilter===c.LinearMipmapLinearFilter||e.minFilter===c.LinearFilter||e.minFilter===c.LinearMipmapNearestFilter||e.minFilter===c.NearestMipmapLinearFilter||e.minFilter===c.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 Gs(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.")}generateConst(e,t=null){if(t===null&&(e==="float"||e==="int"||e==="uint"?t=0:e==="bool"?t=!1:e==="color"?t=new c.Color:e==="vec2"?t=new c.Vector2:e==="vec3"?t=new c.Vector3:e==="vec4"&&(t=new c.Vector4)),e==="float")return xs(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")}( ${xs(t.r)}, ${xs(t.g)}, ${xs(t.b)} )`;const s=this.getTypeLength(e),n=this.getComponentType(e),r=i=>this.generateConst(n,i);if(s===2)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)} )`;if(s===3)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)}, ${r(t.z)} )`;if(s===4)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)}, ${r(t.z)}, ${r(t.w)} )`;if(s>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(r).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 r of s)if(r.name===e)return r;const n=new tr(e,t);return s.push(n),n}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==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===c.IntType)return"int";if(t===c.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;const s=Hu(e);return(t==="float"?"":t[0])+s}getTypeFromArray(e){return Xf.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const s=t.array,n=e.itemSize,r=e.normalized;let i;return!(e instanceof c.Float16BufferAttribute)&&r!==!0&&(i=this.getTypeFromArray(s)),this.getTypeFromLength(n,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=yn(this.stack),this.stacks.push(mo()||this.stack),Is(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Is(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,s=null){s=s===null?e.isGlobal(this)?this.globalCache:this.cache:s;let n=s.getData(e);return n===void 0&&(n={},s.setData(e,n)),n[t]===void 0&&(n[t]={}),n[t]}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 n=s.bufferAttribute;if(n===void 0){const r=this.uniforms.index++;n=new tr("nodeAttribute"+r,t,e),this.bufferAttributes.push(n),s.bufferAttribute=n}return n}getStructTypeFromNode(e,t=this.shaderStage){const s=this.getDataFromNode(e,t);if(s.structType===void 0){const n=this.structs.index++;e.name=`StructType${n}`,this.structs[t].push(e),s.structType=e}return e}getUniformFromNode(e,t,s=this.shaderStage,n=null){const r=this.getDataFromNode(e,s,this.globalCache);let i=r.uniform;if(i===void 0){const u=this.uniforms.index++;i=new _u(n||"nodeUniform"+u,t,e),this.uniforms[s].push(i),r.uniform=i}return i}getVarFromNode(e,t=null,s=e.getNodeType(this),n=this.shaderStage){const r=this.getDataFromNode(e,n);let i=r.variable;if(i===void 0){const u=this.vars[n]||(this.vars[n]=[]);t===null&&(t="nodeVar"+u.length),i=new Or(t,s),u.push(i),r.variable=i}return i}getVaryingFromNode(e,t=null,s=e.getNodeType(this)){const n=this.getDataFromNode(e,"any");let r=n.varying;if(r===void 0){const i=this.varyings,u=i.length;t===null&&(t="nodeVarying"+u),r=new Su(t,s),i.push(r),n.varying=r}return r}getCodeFromNode(e,t,s=this.shaderStage){const n=this.getDataFromNode(e);let r=n.code;if(r===void 0){const i=this.codes[s]||(this.codes[s]=[]),u=i.length;r=new Nu("nodeCode"+u,t),i.push(r),n.code=r}return r}addFlowCodeHierarchy(e,t){const{flowCodes:s,flowCodeBlock:n}=this.getDataFromNode(e);let r=!0,i=t;for(;i;){if(n.get(i)===!0){r=!1;break}i=this.getDataFromNode(i).parentNodeBlock}if(r)for(const u of s)this.addLineFlowCode(u)}addLineFlowCodeBlock(e,t,s){const n=this.getDataFromNode(e),r=n.flowCodes||(n.flowCodes=[]),i=n.flowCodeBlock||(n.flowCodeBlock=new WeakMap);r.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+`;
27
+ `),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}buildFunctionNode(e){const t=new du,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 cu(i.type,i.name);e.layout=null;const n=e.call(s),r=this.flowStagesNode(n,t.type);return e.layout=t,r}flowStagesNode(e,t=null){const s=this.flow,n=this.vars,r=this.cache,i=this.buildStage,u=this.stack,a={code:""};this.flow=a,this.vars={},this.cache=new Gs,this.stack=yn();for(const l of kn)this.setBuildStage(l),a.result=e.build(this,t);return a.vars=this.getVars(this.shaderStage),this.flow=s,this.vars=n,this.cache=r,this.stack=u,this.setBuildStage(i),a}getFunctionOperator(){return null}flowChildNode(e,t=null){const s=this.flow,n={code:""};return this.flow=n,n.result=e.build(this,t),this.flow=s,n}flowNodeFromShaderStage(e,t,s=null,n=null){const r=this.shaderStage;this.setShaderStage(e);const i=this.flowChildNode(t,s);return n!==null&&(i.code+=`${this.tab+n} = ${i.result};
28
+ `),this.flowCode[e]=this.flowCode[e]+i.code,this.setShaderStage(r),i}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t){return`${this.getType(e)} ${t}`}getVars(e){let t="";const s=this.vars[e];if(s!==void 0)for(const n of s)t+=`${this.getVar(n.type,n.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let s="";if(t!==void 0)for(const n of t)s+=n.code+`
29
+ `;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.")}build(){const{object:e,material:t,renderer:s}=this;if(t!==null){let n=s.library.fromMaterial(t);n===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),n=new re),n.build(this)}else this.addFlow("compute",e);for(const n of kn){this.setBuildStage(n),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const r of zn){this.setShaderStage(r);const i=this.flowNodes[r];for(const u of i)n==="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 If(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new Lf(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new Of(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new Vf(e);if(t==="color")return new kf(e);if(t==="mat3")return new zf(e);if(t==="mat4")return new $f(e);throw new Error(`Uniform "${t}" not declared.`)}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}format(e,t,s){if(t=this.getVectorType(t),s=this.getVectorType(s),t===s||s===null||this.isReference(s))return e;const n=this.getTypeLength(t),r=this.getTypeLength(s);return n===16&&r===9?`${this.getType(s)}(${e}[0].xyz, ${e}[1].xyz, ${e}[2].xyz)`:n===9&&r===4?`${this.getType(s)}(${e}[0].xy, ${e}[1].xy)`:n>4||r>4||r===0?e:n===r?`${this.getType(s)}( ${e} )`:n>r?this.format(`${e}.${"xyz".slice(0,r)}`,this.getTypeFromLength(r,this.getComponentType(t)),s):r===4&&n>1?`${this.getType(s)}( ${this.format(e,t,"vec3")}, 1.0 )`:n===2?`${this.getType(s)}( ${this.format(e,t,"vec2")}, 0.0 )`:(n===1&&r>1&&t!==this.getComponentType(s)&&(e=`${this.getType(this.getComponentType(s))}( ${e} )`),`${this.getType(s)}( ${e} )`)}getSignature(){return`// Three.js r${c.REVISION} - Node System
30
+ `}}class sr{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.startTime=null,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:n}=this._getMaps(this.updateBeforeMap,s);n.get(s)!==this.frameId&&e.updateBefore(this)!==!1&&n.set(s,this.frameId)}else if(t===z.RENDER){const{renderMap:n}=this._getMaps(this.updateBeforeMap,s);n.get(s)!==this.renderId&&e.updateBefore(this)!==!1&&n.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:n}=this._getMaps(this.updateAfterMap,s);n.get(s)!==this.frameId&&e.updateAfter(this)!==!1&&n.set(s,this.frameId)}else if(t===z.RENDER){const{renderMap:n}=this._getMaps(this.updateAfterMap,s);n.get(s)!==this.renderId&&e.updateAfter(this)!==!1&&n.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:n}=this._getMaps(this.updateMap,s);n.get(s)!==this.frameId&&e.update(this)!==!1&&n.set(s,this.frameId)}else if(t===z.RENDER){const{renderMap:n}=this._getMaps(this.updateMap,s);n.get(s)!==this.renderId&&e.update(this)!==!1&&n.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 nn{constructor(e,t,s=null,n="",r=!1){this.type=e,this.name=t,this.count=s,this.qualifier=n,this.isConst=r}}nn.isNodeFunctionInput=!0;class bu extends at{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,s=this.colorNode,n=mu(this.light),r=e.context.reflectedLight;t.direct({lightDirection:n,lightColor:s,reflectedLight:r},e.stack,e)}}const vn=new c.Matrix4,bs=new c.Matrix4;let qt=null;class Ru extends at{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=O(new c.Vector3).setGroup(L),this.halfWidth=O(new c.Vector3).setGroup(L),this.updateType=z.RENDER}update(e){super.update(e);const{light:t}=this,s=e.camera.matrixWorldInverse;bs.identity(),vn.copy(t.matrixWorld),vn.premultiply(s),bs.extractRotation(vn),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(bs),this.halfHeight.value.applyMatrix4(bs)}setup(e){super.setup(e);let t,s;e.isAvailable("float32Filterable")?(t=H(qt.LTC_FLOAT_1),s=H(qt.LTC_FLOAT_2)):(t=H(qt.LTC_HALF_1),s=H(qt.LTC_HALF_2));const{colorNode:n,light:r}=this,i=e.context.lightingModel,u=Dr(r),a=e.context.reflectedLight;i.directRectArea({lightColor:n,lightPosition:u,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:a,ltc_1:t,ltc_2:s},e.stack,e)}static setLTC(e){qt=e}}class $r extends at{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=O(0).setGroup(L),this.penumbraCosNode=O(0).setGroup(L),this.cutoffDistanceNode=O(0).setGroup(L),this.decayExponentNode=O(0).setGroup(L)}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){const{coneCosNode:t,penumbraCosNode:s}=this;return mt(t,s,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:s,cutoffDistanceNode:n,decayExponentNode:r,light:i}=this,u=Dr(i).sub(de),a=u.normalize(),l=a.dot(mu(i)),d=this.getSpotAttenuation(l),h=u.length(),p=Tu({lightDistance:h,cutoffDistance:n,decayExponent:r});let f=s.mul(d).mul(p);if(i.map){const m=sf(i),y=H(i.map,m.xy).onRenderUpdate(()=>i.map);f=m.mul(2).sub(1).abs().lessThan(1).all().select(f.mul(y),f)}const g=e.context.reflectedLight;t.direct({lightDirection:a,lightColor:f,reflectedLight:g},e.stack,e)}}class Au extends $r{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e){const t=this.light.iesMap;let s=null;if(t&&t.isTexture===!0){const n=e.acos().mul(1/Math.PI);s=H(t,F(n,0),0).r}else s=super.getSpotAttenuation(e);return s}}class Cu extends at{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class vu extends at{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=gu(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=O(new c.Color).setGroup(L)}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:n}=this,i=Ge.dot(n).mul(.5).add(.5),u=Z(s,t,i);e.context.irradiance.addAssign(u)}}class Eu extends at{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let s=0;s<9;s++)t.push(new c.Vector3);this.lightProbe=tt(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=Af(na,this.lightProbe);e.context.irradiance.addAssign(t)}}class Mu{parseFunction(){console.warn("Abstract function.")}}class Wr{constructor(e,t,s="",n=""){this.type=e,this.inputs=t,this.name=s,this.precision=n}getCode(){console.warn("Abstract function.")}}Wr.isNodeFunction=!0;const Yf=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,Qf=/[a-z_0-9]+/ig,zi="#pragma main",jf=o=>{o=o.trim();const e=o.indexOf(zi),t=e!==-1?o.slice(e+zi.length):o,s=t.match(Yf);if(s!==null&&s.length===5){const n=s[4],r=[];let i=null;for(;(i=Qf.exec(n))!==null;)r.push(i);const u=[];let a=0;for(;a<r.length;){const g=r[a][0]==="const";g===!0&&a++;let m=r[a][0];m==="in"||m==="out"||m==="inout"?a++:m="";const y=r[a++][0];let S=Number.parseInt(r[a][0]);Number.isNaN(S)===!1?a++:S=null;const A=r[a++][0];u.push(new nn(y,A,S,m,g))}const l=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:n,blockCode:l,headerCode:f}}else throw new Error("FunctionNode: Function is not a GLSL code.")};class Zf extends Wr{constructor(e){const{type:t,inputs:s,name:n,precision:r,inputsCode:i,blockCode:u,headerCode:a}=jf(e);super(t,s,n,r),this.inputsCode=i,this.blockCode=u,this.headerCode=a}getCode(e=this.name){let t;const s=this.blockCode;if(s!==""){const{type:n,inputsCode:r,headerCode:i,precision:u}=this;let a=`${n} ${e} ( ${r.trim()} )`;u!==""&&(a=`${u} ${a}`),t=i+a+s}else t="";return t}}class Bu extends Mu{parseFunction(e){return new Zf(e)}}const $i=new WeakMap;class Jf extends ot{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new sr,this.nodeBuilderCache=new Map,this.callHashCache=new Oe,this.groupsData=new Oe}updateGroup(e){const t=e.groupNode,s=t.name;if(s===_o.name)return!0;if(s===L.name){const i=this.get(e),u=this.nodeFrame.renderId;return i.renderId!==u?(i.renderId=u,!0):!1}if(s===bc.name){const i=this.get(e),u=this.nodeFrame.frameId;return i.frameId!==u?(i.frameId=u,!0):!1}const n=[t,e];let r=this.groupsData.get(n);return r===void 0&&this.groupsData.set(n,r={}),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:n}=this,r=this.getForRenderCacheKey(e);if(s=n.get(r),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,i.build(),s=this._createNodeBuilderState(i),n.set(r,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 n=this.backend.createNodeBuilder(e,this.renderer);n.build(),s=this._createNodeBuilderState(n),t.nodeBuilderState=s}return s}_createNodeBuilderState(e){return new Ef(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.monitor,e.transforms)}getEnvironmentNode(e){return e.environmentNode||this.get(e).environmentNode||null}getBackgroundNode(e){return e.backgroundNode||this.get(e).backgroundNode||null}getFogNode(e){return e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){const s=[e,t],n=this.renderer.info.calls;let r=this.callHashCache.get(s);if(r===void 0||r.callId!==n){const i=this.getEnvironmentNode(e),u=this.getFogNode(e),a=[];t&&a.push(t.getCacheKey(!0)),i&&a.push(i.getCacheKey()),u&&a.push(u.getCacheKey()),a.push(this.renderer.shadowMap.enabled?1:0),r={callId:n,cacheKey:io(a)},this.callHashCache.set(s,r)}return r.cacheKey}updateScene(e){this.updateEnvironment(e),this.updateFog(e),this.updateBackground(e)}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),s=e.background;if(s){const n=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==s||n){let r=null;if(s.isCubeTexture===!0||s.mapping===c.EquirectangularReflectionMapping||s.mapping===c.EquirectangularRefractionMapping||s.mapping===c.CubeUVReflectionMapping)if(e.backgroundBlurriness>0||s.mapping===c.CubeUVReflectionMapping)r=Qa(s);else{let i;s.isCubeTexture===!0?i=as(s):i=H(s),r=Oa(i)}else s.isTexture===!0?r=H(s,us.flipY()).setUpdateMatrix(!0):s.isColor!==!0&&console.error("WebGPUNodes: Unsupported background configuration.",s);t.backgroundNode=r,t.background=s,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}updateFog(e){const t=this.get(e),s=e.fog;if(s){if(t.fog!==s){let n=null;if(s.isFogExp2){const r=Y("color","color",s).setGroup(L),i=Y("density","float",s).setGroup(L);n=ef(r,i)}else if(s.isFog){const r=Y("color","color",s).setGroup(L),i=Y("near","float",s).setGroup(L),u=Y("far","float",s).setGroup(L);n=Jp(r,i,u)}else console.error("WebGPUNodes: Unsupported fog configuration.",s);t.fogNode=n,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){let n=null;s.isCubeTexture===!0?n=as(s):s.isTexture===!0?n=H(s):console.error("Nodes: Unsupported environment configuration.",s),t.environmentNode=n,t.environment=s}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,s=null,n=null,r=null){const i=this.nodeFrame;return i.renderer=e,i.scene=t,i.object=s,i.camera=n,i.material=r,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}hasOutputChange(e){return $i.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,s=this.getOutputCacheKey(),n=H(e,us).renderOutput(t.toneMapping,t.currentColorSpace);return $i.set(e,s),n}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 n of s.updateNodes)t.updateNode(n)}updateForRender(e){const t=this.getNodeFrameForRender(e),s=e.getNodeBuilderState();for(const n of s.updateNodes)t.updateNode(n)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new sr,this.nodeBuilderCache=new Map}}const En=new c.Plane;class Hs{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",e===null?(this.intersectionPlanes=[],this.unionPlanes=[],this.viewNormalMatrix=new c.Matrix3,this.clippingGroupContexts=new WeakMap,this.shadowPass=!1):(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix),this.parentVersion=null}projectPlanes(e,t,s){const n=e.length;for(let r=0;r<n;r++){En.copy(e[r]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);const i=t[s+r],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.isShadowNodeMaterial,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 n=t.clippingPlanes,r=n.length;let i,u;if(this.clipIntersection?(i=this.intersectionPlanes,u=e.intersectionPlanes.length):(i=this.unionPlanes,u=e.unionPlanes.length),i.length!==u+r){i.length=u+r;for(let a=0;a<r;a++)i[u+a]=new c.Vector4;s=!0}this.projectPlanes(n,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 Hs(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}get unionClippingCount(){return this.unionPlanes.length}}class eg{constructor(e,t){this.scene=e,this.camera=t}clone(){return Object.assign(new this.constructor,this)}}class tg{constructor(){this.lists=new Oe}get(e,t){const s=this.lists,n=[e,t];let r=s.get(n);return r===void 0&&(r=new eg(e,t),s.set(n,r)),r}dispose(){this.lists=new Oe}}class Fu{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 n in e)t[n]=e[n]}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 sg=new Ir;class wu extends Oe{constructor(){super()}createNode(e=[]){return new Ir().setLights(e)}getNode(e,t){if(e.isQuadMesh)return sg;const s=[e,t];let n=this.get(s);return n===void 0&&(n=this.createNode(),this.set(s,n)),n}}const Wi=new c.Scene,Rs=new c.Vector2,Mn=new c.Vector4,Bn=new c.Frustum,As=new c.Matrix4,Ze=new c.Vector4;class ng{constructor(e,t={}){this.isRenderer=!0;const{logarithmicDepthBuffer:s=!1,alpha:n=!0,depth:r=!0,stencil:i=!1,antialias:u=!1,samples:a=0,getFallback:l=null}=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=n,this.logarithmicDepthBuffer=s,this.outputColorSpace=c.SRGBColorSpace,this.toneMapping=c.NoToneMapping,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=r,this.stencil=i,this.info=new xp,this.nodes={modelViewMatrix:null,modelNormalViewMatrix:null},this.library=new Fu,this.lighting=new wu,this._getFallback=l,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new c.Vector4(0,0,this._width,this._height),this._scissor=new c.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 Gr(new re),this._quad.material.type="Renderer_output",this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTarget=null;const d=this.alpha===!0?0:1;this._clearColor=new Ur(0,0,0,d),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this._initialized=!1,this._initPromise=null,this._compilationPromises=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,type:c.PCFShadowMap},this.xr={enabled:!1},this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:async(h,p,f)=>{await this.compileAsync(h,p);const g=this._renderLists.get(h,p),m=this._renderContexts.get(h,p,this._renderTarget),y=h.overrideMaterial||f.material,S=this._objects.get(f,y,h,p,g.lightsNode,m,m.clippingContext),{fragmentShader:A,vertexShader:E}=S.getNodeBuilderState();return{fragmentShader:A,vertexShader:E}}}}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(n){if(this._getFallback!==null)try{this.backend=s=this._getFallback(n),await s.init(this)}catch(r){t(r);return}else{t(n);return}}this._nodes=new Jf(this,s),this._animation=new hp(this._nodes,this.info),this._attributes=new _p(s),this._background=new Cf(this,this._nodes),this._geometries=new Np(this._attributes,this.info),this._textures=new Pp(this,s,this.info),this._pipelines=new Cp(s,this._nodes),this._bindings=new vp(s,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new mp(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new Bp(this.lighting),this._bundles=new tg,this._renderContexts=new Up,this._animation.start(),this._initialized=!0,e()}),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 n=this._nodes.nodeFrame,r=n.renderId,i=this._currentRenderContext,u=this._currentRenderObjectFunction,a=this._compilationPromises,l=e.isScene===!0?e:Wi;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,n.renderId++,n.update(),h.depth=this.depth,h.stencil=this.stencil,h.clippingContext||(h.clippingContext=new Hs),h.clippingContext.updateGlobal(l,t),l.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(E){E.isLight&&E.layers.test(t.layers)&&g.pushLight(E)}),g.finish(),d!==null){this._textures.updateRenderTarget(d,p);const E=this._textures.get(d);h.textures=E.textures,h.depthTexture=E.depthTexture}else h.textures=null,h.depthTexture=null;this._nodes.updateScene(l),this._background.update(l,g,h);const m=g.opaque,y=g.transparent,S=g.transparentDoublePass,A=g.lightsNode;this.opaque===!0&&m.length>0&&this._renderObjects(m,t,l,A),this.transparent===!0&&y.length>0&&this._renderTransparents(y,S,t,l,A),n.renderId=r,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();const s=this._renderScene(e,t);await this.backend.resolveTimestampAsync(s,"render")}async waitForGPU(){await this.backend.waitForGPU()}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:
31
+
32
+ Message: ${e.message}`;e.reason&&(t+=`
33
+ Reason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,s){const{bundleGroup:n,camera:r,renderList:i}=e,u=this._currentRenderContext,a=this._bundles.get(n,r),l=this.backend.get(a);l.renderContexts===void 0&&(l.renderContexts=new Set);const d=n.version!==l.version,h=l.renderContexts.has(u)===!1||d;if(l.renderContexts.add(u),h){this.backend.beginBundle(u),(l.renderObjects===void 0||d)&&(l.renderObjects=[]),this._currentRenderBundle=a;const p=i.opaque;this.opaque===!0&&p.length>0&&this._renderObjects(p,r,t,s),this._currentRenderBundle=null,this.backend.finishBundle(u,a),l.version=n.version}else{const{renderObjects:p}=l;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!==c.NoToneMapping,n=t!==c.LinearSRGBColorSpace;if(s===!1&&n===!1)return null;const{width:r,height:i}=this.getDrawingBufferSize(Rs),{depth:u,stencil:a}=this;let l=this._frameBufferTarget;return l===null&&(l=new c.RenderTarget(r,i,{depthBuffer:u,stencilBuffer:a,type:c.HalfFloatType,format:c.RGBAFormat,colorSpace:c.LinearSRGBColorSpace,generateMipmaps:!1,minFilter:c.LinearFilter,magFilter:c.LinearFilter,samples:this.samples}),l.isPostProcessingRenderTarget=!0,this._frameBufferTarget=l),l.depthBuffer=u,l.stencilBuffer=a,l.setSize(r,i),l.viewport.copy(this._viewport),l.scissor.copy(this._scissor),l.viewport.multiplyScalar(this._pixelRatio),l.scissor.multiplyScalar(this._pixelRatio),l.scissorTest=this._scissorTest,l}_renderScene(e,t,s=!0){if(this._isDeviceLost===!0)return;const n=s?this._getFrameBufferTarget():null,r=this._nodes.nodeFrame,i=r.renderId,u=this._currentRenderContext,a=this._currentRenderObjectFunction,l=e.isScene===!0?e:Wi,d=this._renderTarget,h=this._activeCubeFace,p=this._activeMipmapLevel;let f;n!==null?(f=n,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++,r.renderId=this.info.calls;const m=this.coordinateSystem;t.coordinateSystem!==m&&(t.coordinateSystem=m,t.updateProjectionMatrix()),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld();let y=this._viewport,S=this._scissor,A=this._pixelRatio;f!==null&&(y=f.viewport,S=f.scissor,A=1),this.getDrawingBufferSize(Rs),Mn.set(0,0,Rs.width,Rs.height);const E=y.minDepth===void 0?0:y.minDepth,D=y.maxDepth===void 0?1:y.maxDepth;g.viewportValue.copy(y).multiplyScalar(A).floor(),g.viewportValue.width>>=p,g.viewportValue.height>>=p,g.viewportValue.minDepth=E,g.viewportValue.maxDepth=D,g.viewport=g.viewportValue.equals(Mn)===!1,g.scissorValue.copy(S).multiplyScalar(A).floor(),g.scissor=this._scissorTest&&g.scissorValue.equals(Mn)===!1,g.scissorValue.width>>=p,g.scissorValue.height>>=p,g.clippingContext||(g.clippingContext=new Hs),g.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,f),As.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),Bn.setFromProjectionMatrix(As,m);const w=this._renderLists.get(e,t);if(w.begin(),this._projectObject(e,t,0,w,g.clippingContext),w.finish(),this.sortObjects===!0&&w.sort(this._opaqueSort,this._transparentSort),f!==null){this._textures.updateRenderTarget(f,p);const X=this._textures.get(f);g.textures=X.textures,g.depthTexture=X.depthTexture,g.width=X.width,g.height=X.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=w.occlusionQueryCount,this._nodes.updateScene(l),this._background.update(l,w,g),this.backend.beginRender(g);const{bundles:U,lightsNode:G,transparentDoublePass:P,transparent:Q,opaque:se}=w;if(U.length>0&&this._renderBundles(U,l,G),this.opaque===!0&&se.length>0&&this._renderObjects(se,t,l,G),this.transparent===!0&&Q.length>0&&this._renderTransparents(Q,P,t,l,G),this.backend.finishRender(g),r.renderId=i,this._currentRenderContext=u,this._currentRenderObjectFunction=a,n!==null){this.setRenderTarget(d,h,p);const X=this._quad;this._nodes.hasOutputChange(f.texture)&&(X.material.fragmentNode=this._nodes.getOutputNode(f.texture),X.material.needsUpdate=!0),this._renderScene(X,X.camera,!1)}return l.onAfterRender(this,e,t,f),g}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._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._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,n){const r=this._scissor;e.isVector4?r.copy(e):r.set(e,t,s,n)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,s,n,r=0,i=1){const u=this._viewport;e.isVector4?u.copy(e):u.set(e,t,s,n),u.minDepth=r,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 n=this._renderTarget||this._getFrameBufferTarget();let r=null;if(n!==null&&(this._textures.updateRenderTarget(n),r=this._textures.get(n)),this.backend.clear(e,t,s,r),n!==null&&this._renderTarget===null){const i=this._quad;this._nodes.hasOutputChange(n.texture)&&(i.material.fragmentNode=this._nodes.getOutputNode(n.texture),i.material.needsUpdate=!0),this._renderScene(i,i.camera,!1)}}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)}clearColorAsync(){return this.clearAsync(!0,!1,!1)}clearDepthAsync(){return this.clearAsync(!1,!0,!1)}clearStencilAsync(){return this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this._renderTarget!==null?c.NoToneMapping:this.toneMapping}get currentColorSpace(){return this._renderTarget!==null?c.LinearSRGBColorSpace:this.outputColorSpace}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.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,s=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=s}getRenderTarget(){return this._renderTarget}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 n=this.backend,r=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.");n.beginCompute(e);for(const l of a){if(r.has(l)===!1){const p=()=>{l.removeEventListener("dispose",p),r.delete(l),i.delete(l),u.delete(l)};l.addEventListener("dispose",p);const f=l.onInitFunction;f!==null&&f.call(l,{renderer:this})}u.updateForCompute(l),i.updateForCompute(l);const d=i.getForCompute(l),h=r.getForCompute(l,d);n.compute(e,l,d,h)}n.finishCompute(e),t.renderId=s}async computeAsync(e){this._initialized===!1&&await this.init(),this.compute(e),await this.backend.resolveTimestampAsync(e,"compute")}async hasFeatureAsync(e){return this._initialized===!1&&await this.init(),this.backend.hasFeature(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){if(this._initialized===!1)return console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),!1;this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=Ze.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=Ze.copy(t).floor();else{console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=Ze.set(0,0,e.image.width,e.image.height);let s=this._currentRenderContext,n;s!==null?n=s.renderTarget:(n=this._renderTarget||this._getFrameBufferTarget(),n!==null&&(this._textures.updateRenderTarget(n),s=this._textures.get(n))),this._textures.updateTexture(e,{renderTarget:n}),this.backend.copyFramebufferToTexture(e,s,t)}copyTextureToTexture(e,t,s=null,n=null,r=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,s,n,r)}readRenderTargetPixelsAsync(e,t,s,n,r,i=0,u=0){return this.backend.copyTextureToBuffer(e.textures[i],t,s,n,r,u)}_projectObject(e,t,s,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)s=e.renderOrder,e.isClippingGroup&&e.enabled&&(r=r.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)n.pushLight(e);else if(e.isSprite){if(!e.frustumCulled||Bn.intersectsSprite(e)){this.sortObjects===!0&&Ze.setFromMatrixPosition(e.matrixWorld).applyMatrix4(As);const{geometry:a,material:l}=e;l.visible&&n.push(e,a,l,s,Ze.z,null,r)}}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)&&(!e.frustumCulled||Bn.intersectsObject(e))){const{geometry:a,material:l}=e;if(this.sortObjects===!0&&(a.boundingSphere===null&&a.computeBoundingSphere(),Ze.copy(a.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(As)),Array.isArray(l)){const d=a.groups;for(let h=0,p=d.length;h<p;h++){const f=d[h],g=l[f.materialIndex];g&&g.visible&&n.push(e,a,g,s,Ze.z,f,r)}}else l.visible&&n.push(e,a,l,s,Ze.z,null,r)}}if(e.isBundleGroup===!0&&this.backend.beginBundle!==void 0){const a=n;n=this._renderLists.get(e,t),n.begin(),a.pushBundle({bundleGroup:e,camera:t,renderList:n}),n.finish()}const u=e.children;for(let a=0,l=u.length;a<l;a++)this._projectObject(u[a],t,s,n,r)}_renderBundles(e,t,s){for(const n of e)this._renderBundle(n,t,s)}_renderTransparents(e,t,s,n,r){if(t.length>0){for(const{material:i}of t)i.side=c.BackSide;this._renderObjects(t,s,n,r,"backSide");for(const{material:i}of t)i.side=c.FrontSide;this._renderObjects(e,s,n,r);for(const{material:i}of t)i.side=c.DoubleSide}else this._renderObjects(e,s,n,r)}_renderObjects(e,t,s,n,r=null){for(let i=0,u=e.length;i<u;i++){const a=e[i],{object:l,geometry:d,material:h,group:p,clippingContext:f}=a;if(t.isArrayCamera){const g=t.cameras;for(let m=0,y=g.length;m<y;m++){const S=g[m];if(l.layers.test(S.layers)){const A=S.viewport,E=A.minDepth===void 0?0:A.minDepth,D=A.maxDepth===void 0?1:A.maxDepth,w=this._currentRenderContext.viewportValue;w.copy(A).multiplyScalar(this._pixelRatio).floor(),w.minDepth=E,w.maxDepth=D,this.backend.updateViewport(this._currentRenderContext),this._currentRenderObjectFunction(l,s,S,d,h,p,n,f,r)}}}else this._currentRenderObjectFunction(l,s,t,d,h,p,n,f,r)}}renderObject(e,t,s,n,r,i,u,a=null,l=null){let d,h,p;if(e.onBeforeRender(this,t,s,n,r,i),t.overrideMaterial!==null){const f=t.overrideMaterial;r.positionNode&&r.positionNode.isNode&&(d=f.positionNode,f.positionNode=r.positionNode),f.alphaTest=r.alphaTest,f.alphaMap=r.alphaMap,f.isShadowNodeMaterial&&(f.side=r.shadowSide===null?r.side:r.shadowSide,r.depthNode&&r.depthNode.isNode&&(p=f.depthNode,f.depthNode=r.depthNode),r.castShadowNode&&r.castShadowNode.isNode&&(h=f.colorNode,f.colorNode=r.castShadowNode)),r=f}r.transparent===!0&&r.side===c.DoubleSide&&r.forceSinglePass===!1?(r.side=c.BackSide,this._handleObjectFunction(e,r,t,s,u,i,a,"backSide"),r.side=c.FrontSide,this._handleObjectFunction(e,r,t,s,u,i,a,l),r.side=c.DoubleSide):this._handleObjectFunction(e,r,t,s,u,i,a,l),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,n,r,i)}_renderObjectDirect(e,t,s,n,r,i,u,a){const l=this._objects.get(e,t,s,n,r,this._currentRenderContext,u,a);l.drawRange=e.geometry.drawRange,l.group=i;const d=this._nodes.needsRefresh(l);d&&(this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l)),this._pipelines.updateForRender(l),this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(l),l.bundle=this._currentRenderBundle.scene),this.backend.draw(l,this.info),d&&this._nodes.updateAfter(l)}_createObjectPipeline(e,t,s,n,r,i,u){const a=this._objects.get(e,t,s,n,r,this._currentRenderContext,i,u);this._nodes.updateBefore(a),this._geometries.updateForRender(a),this._nodes.updateForRender(a),this._bindings.updateForRender(a),this._pipelines.getForRender(a,this._compilationPromises),this._nodes.updateAfter(a)}get compile(){return this.compileAsync}}class Hr{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}function rg(o){return o+(nt-o%nt)%nt}class Uu extends Hr{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return rg(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class Gu extends Uu{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let ig=0;class Pu extends Gu{constructor(e,t){super("UniformBuffer_"+ig++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class og extends Gu{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(){let e=0;for(let t=0,s=this.uniforms.length;t<s;t++){const n=this.uniforms[t],{boundary:r,itemSize:i}=n,u=e%nt,a=nt-u;u!==0&&a-r<0?e+=nt-u:u%r!==0&&(e+=u%r),n.offset=e/this.bytesPerElement,e+=i*this.bytesPerElement}return Math.ceil(e/nt)*nt}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,n=e.getValue(),r=e.offset,i=e.getType();if(s[r]!==n){const u=this._getBufferForType(i);u[r]=s[r]=n,t=!0}return t}updateVector2(e){let t=!1;const s=this.values,n=e.getValue(),r=e.offset,i=e.getType();if(s[r+0]!==n.x||s[r+1]!==n.y){const u=this._getBufferForType(i);u[r+0]=s[r+0]=n.x,u[r+1]=s[r+1]=n.y,t=!0}return t}updateVector3(e){let t=!1;const s=this.values,n=e.getValue(),r=e.offset,i=e.getType();if(s[r+0]!==n.x||s[r+1]!==n.y||s[r+2]!==n.z){const u=this._getBufferForType(i);u[r+0]=s[r+0]=n.x,u[r+1]=s[r+1]=n.y,u[r+2]=s[r+2]=n.z,t=!0}return t}updateVector4(e){let t=!1;const s=this.values,n=e.getValue(),r=e.offset,i=e.getType();if(s[r+0]!==n.x||s[r+1]!==n.y||s[r+2]!==n.z||s[r+4]!==n.w){const u=this._getBufferForType(i);u[r+0]=s[r+0]=n.x,u[r+1]=s[r+1]=n.y,u[r+2]=s[r+2]=n.z,u[r+3]=s[r+3]=n.w,t=!0}return t}updateColor(e){let t=!1;const s=this.values,n=e.getValue(),r=e.offset;if(s[r+0]!==n.r||s[r+1]!==n.g||s[r+2]!==n.b){const i=this.buffer;i[r+0]=s[r+0]=n.r,i[r+1]=s[r+1]=n.g,i[r+2]=s[r+2]=n.b,t=!0}return t}updateMatrix3(e){let t=!1;const s=this.values,n=e.getValue().elements,r=e.offset;if(s[r+0]!==n[0]||s[r+1]!==n[1]||s[r+2]!==n[2]||s[r+4]!==n[3]||s[r+5]!==n[4]||s[r+6]!==n[5]||s[r+8]!==n[6]||s[r+9]!==n[7]||s[r+10]!==n[8]){const i=this.buffer;i[r+0]=s[r+0]=n[0],i[r+1]=s[r+1]=n[1],i[r+2]=s[r+2]=n[2],i[r+4]=s[r+4]=n[3],i[r+5]=s[r+5]=n[4],i[r+6]=s[r+6]=n[5],i[r+8]=s[r+8]=n[6],i[r+9]=s[r+9]=n[7],i[r+10]=s[r+10]=n[8],t=!0}return t}updateMatrix4(e){let t=!1;const s=this.values,n=e.getValue().elements,r=e.offset;return ug(s,n,r)===!1&&(this.buffer.set(n,r),ag(s,n,r),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 ag(o,e,t){for(let s=0,n=e.length;s<n;s++)o[t+s]=e[s]}function ug(o,e,t){for(let s=0,n=e.length;s<n;s++)if(o[t+s]!==e[s])return!1;return!0}let cg=0;class Du extends og{constructor(e,t){super(e),this.id=cg++,this.groupNode=t,this.isNodeUniformsGroup=!0}getNodes(){const e=[];for(const t of this.uniforms){const s=t.nodeUniform.node;if(!s)throw new Error("NodeUniformsGroup: Uniform has no node.");e.push(s)}return e}}let lg=0;class dg extends Hr{constructor(e,t){super(e),this.id=lg++,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 rn extends dg{constructor(e,t,s,n=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=s,this.access=n}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 Iu extends rn{constructor(e,t,s,n){super(e,t,s,n),this.isSampledCubeTexture=!0}}class Lu extends rn{constructor(e,t,s,n){super(e,t,s,n),this.isSampledTexture3D=!0}}const hg={atan2:"atan",textureDimensions:"textureSize",equals:"equal"},pg={low:"lowp",medium:"mediump",high:"highp"},Hi={swizzleAssign:!0,storageBuffer:!1},qi=`
34
+ precision highp float;
35
+ precision highp int;
36
+ precision highp sampler2D;
37
+ precision highp sampler3D;
38
+ precision highp samplerCube;
39
+ precision highp sampler2DArray;
40
+
41
+ precision highp usampler2D;
42
+ precision highp usampler3D;
43
+ precision highp usamplerCube;
44
+ precision highp usampler2DArray;
45
+
46
+ precision highp isampler2D;
47
+ precision highp isampler3D;
48
+ precision highp isamplerCube;
49
+ precision highp isampler2DArray;
50
+
51
+ precision lowp sampler2DShadow;
52
+ `;class fg extends zr{constructor(e,t){super(e,t,new Bu),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]},this.useComparisonMethod=!0}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==c.NoColorSpace}getMethod(e){return hg[e]||e}getOutputStructName(){return""}buildFunctionCode(e){const t=e.layout,s=this.flowShaderNode(e),n=[];for(const i of t.inputs)n.push(this.getType(i.type)+" "+i.name);return`${this.getType(t.type)} ${t.name}( ${n.join(", ")} ) {
53
+
54
+ ${s.vars}
55
+
56
+ ${s.code}
57
+ return ${s.result};
58
+
59
+ }`}setupPBO(e){const t=e.value;if(t.pbo===void 0){const s=t.array,n=t.count*t.itemSize,{itemSize:r}=t,i=t.array.constructor.name.toLowerCase().includes("int");let u=i?c.RedIntegerFormat:c.RedFormat;r===2?u=i?c.RGIntegerFormat:c.RGFormat:r===3?u=i?c.RGBIntegerFormat:c.RGBFormat:r===4&&(u=i?c.RGBAIntegerFormat:c.RGBAFormat);const a={Float32Array:c.FloatType,Uint8Array:c.UnsignedByteType,Uint16Array:c.UnsignedShortType,Uint32Array:c.UnsignedIntType,Int8Array:c.ByteType,Int16Array:c.ShortType,Int32Array:c.IntType,Uint8ClampedArray:c.UnsignedByteType},l=Math.pow(2,Math.ceil(Math.log2(Math.sqrt(n/r))));let d=Math.ceil(n/r/l);l*d*r<n&&d++;const h=l*d*r,p=new s.constructor(h);p.set(s,0),t.array=p;const f=new c.DataTexture(t.array,l,d,u,a[t.array.constructor.name]||c.FloatType);f.needsUpdate=!0,f.isPBOTexture=!0;const g=new Ot(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,n=t.value;if(this.renderer.backend.has(n)){const d=this.renderer.backend.get(n);d.pbo=n.pbo}const r=this.getUniformFromNode(n.pboNode,"texture",this.shaderStage,this.context.label),i=this.getPropertyName(r);this.increaseUsage(s);const u=s.build(this,"uint"),a=this.getDataFromNode(e);let l=a.propertyName;if(l===void 0){const d=this.getVarFromNode(e);l=this.getPropertyName(d);const h=this.getDataFromNode(t);let p=h.propertySizeName;p===void 0&&(p=l+"Size",this.getVarFromNode(t,p,"uint"),this.addLineFlowCode(`${p} = uint( textureSize( ${i}, 0 ).x )`,e),h.propertySizeName=p);const{itemSize:f}=n,g="."+yt.join("").slice(0,f),m=`ivec2(${u} % ${p}, ${u} / ${p})`,y=this.generateTextureLoad(null,i,m,null,"0");let S="vec4";n.pbo.type===c.UnsignedIntType?S="uvec4":n.pbo.type===c.IntType&&(S="ivec4"),this.addLineFlowCode(`${l} = ${S}(${y})${g}`,e),a.propertyName=l}return l}generateTextureLoad(e,t,s,n,r="0"){return n?`texelFetch( ${t}, ivec3( ${s}, ${n} ), ${r} )`:`texelFetch( ${t}, ${s}, ${r} )`}generateTexture(e,t,s,n){return e.isDepthTexture?`texture( ${t}, ${s} ).x`:(n&&(s=`vec3( ${s}, ${n} )`),`texture( ${t}, ${s} )`)}generateTextureLevel(e,t,s,n){return`textureLod( ${t}, ${s}, ${n} )`}generateTextureBias(e,t,s,n){return`texture( ${t}, ${s}, ${n} )`}generateTextureGrad(e,t,s,n){return`textureGrad( ${t}, ${s}, ${n[0]}, ${n[1]} )`}generateTextureCompare(e,t,s,n,r,i=this.shaderStage){if(i==="fragment")return`texture( ${t}, vec3( ${s}, ${n} ) )`;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 n of s)t.push(`${this.getVar(n.type,n.name)};`);return t.join(`
60
+ `)}getUniforms(e){const t=this.uniforms[e],s=[],n={};for(const i of t){let u=null,a=!1;if(i.type==="texture"){const d=i.node.value;let h="";d.isDataTexture===!0&&(d.type===c.UnsignedIntType?h="u":d.type===c.IntType&&(h="i")),d.compareFunction?u=`sampler2DShadow ${i.name};`: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==="texture3D")u=`sampler3D ${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} {
61
+ ${h} ${i.name}[${f}];
62
+ };
63
+ `}else u=`${this.getVectorType(i.type)} ${this.getPropertyName(i,e)};`,a=!0;const l=i.node.precision;if(l!==null&&(u=pg[l]+" "+u),a){u=" "+u;const d=i.groupNode.name;(n[d]||(n[d]=[])).push(u)}else u="uniform "+u,s.push(u)}let r="";for(const i in n){const u=n[i];r+=this._getGLSLUniformStruct(e+"_"+i,u.join(`
64
+ `))+`
65
+ `}return r+=s.join(`
66
+ `),r}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==c.IntType){let s=e;e.isInterleavedBufferAttribute&&(s=e.data);const n=s.array;n instanceof Uint32Array||n instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const s=this.getAttributesArray();let n=0;for(const r of s)t+=`layout( location = ${n++} ) in ${r.type} ${r.name};
67
+ `}return t}getStructMembers(e){const t=[],s=e.getMemberTypes();for(let n=0;n<s.length;n++){const r=s[n];t.push(`layout( location = ${n} ) out ${r} m${n};`)}return t.join(`
68
+ `)}getStructs(e){const t=[],s=this.structs[e];if(s.length===0)return`layout( location = 0 ) out vec4 fragColor;
69
+ `;for(let n=0,r=s.length;n<r;n++){const i=s[n];let u=`
70
+ `;u+=this.getStructMembers(i),u+=`
71
+ `,t.push(u)}return t.join(`
72
+
73
+ `)}getVaryings(e){let t="";const s=this.varyings;if(e==="vertex"||e==="compute")for(const n of s){e==="compute"&&(n.needsInterpolation=!0);const r=this.getType(n.type),i=r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":"";t+=`${i}${n.needsInterpolation?"out":"/*out*/"} ${r} ${n.name};
74
+ `}else if(e==="fragment"){for(const n of s)if(n.needsInterpolation){const r=this.getType(n.type),i=r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":"";t+=`${i}in ${r} ${n.name};
75
+ `}}for(const n of this.builtins[e])t+=`${n};
76
+ `;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((s,n)=>s*n,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 n=this.extensions[s]||(this.extensions[s]=new Map);n.has(e)===!1&&n.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const n=this.renderer.backend.extensions;this.object.isBatchedMesh&&n.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const s=this.extensions[e];if(s!==void 0)for(const{name:n,behavior:r}of s.values())t.push(`#extension ${n} : ${r}`);return t.join(`
77
+ `)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=Hi[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 n=this.renderer.backend.extensions;n.has(s)&&(n.get(s),t=!0)}Hi[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} ]`)}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 n=e[s],r=this.getPropertyName(n.attributeNode);t+=`${n.varyingName} = ${r};
78
+ `}return t}_getGLSLUniformStruct(e,t){return`
79
+ layout( std140 ) uniform ${e} {
80
+ ${t}
81
+ };`}_getGLSLVertexCode(e){return`#version 300 es
82
+
83
+ ${this.getSignature()}
84
+
85
+ // extensions
86
+ ${e.extensions}
87
+
88
+ // precision
89
+ ${qi}
90
+
91
+ // uniforms
92
+ ${e.uniforms}
93
+
94
+ // varyings
95
+ ${e.varyings}
96
+
97
+ // attributes
98
+ ${e.attributes}
99
+
100
+ // codes
101
+ ${e.codes}
102
+
103
+ void main() {
104
+
105
+ // vars
106
+ ${e.vars}
107
+
108
+ // transforms
109
+ ${e.transforms}
110
+
111
+ // flow
112
+ ${e.flow}
113
+
114
+ gl_PointSize = 1.0;
115
+
116
+ }
117
+ `}_getGLSLFragmentCode(e){return`#version 300 es
118
+
119
+ ${this.getSignature()}
120
+
121
+ // precision
122
+ ${qi}
123
+
124
+ // uniforms
125
+ ${e.uniforms}
126
+
127
+ // varyings
128
+ ${e.varyings}
129
+
130
+ // codes
131
+ ${e.codes}
132
+
133
+ ${e.structs}
134
+
135
+ void main() {
136
+
137
+ // vars
138
+ ${e.vars}
139
+
140
+ // flow
141
+ ${e.flow}
142
+
143
+ }
144
+ `}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){let s=`// code
145
+
146
+ `;s+=this.flowCode[t];const n=this.flowNodes[t],r=n[n.length-1];for(const u of n){const a=this.getFlowData(u),l=u.name;l&&(s.length>0&&(s+=`
147
+ `),s+=` // flow -> ${l}
148
+ `),s+=`${a.code}
149
+ `,u===r&&t!=="compute"&&(s+=`// result
150
+ `,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,n=null){const r=super.getUniformFromNode(e,t,s,n),i=this.getDataFromNode(e,s,this.globalCache);let u=i.uniformGPU;if(u===void 0){const a=e.groupNode,l=a.name,d=this.getBindGroupArray(l,s);if(t==="texture")u=new rn(r.name,r.node,a),d.push(u);else if(t==="cubeTexture")u=new Iu(r.name,r.node,a),d.push(u);else if(t==="texture3D")u=new Lu(r.name,r.node,a),d.push(u);else if(t==="buffer"){e.name=`NodeBuffer_${e.id}`,r.name=`buffer${e.id}`;const h=new Pu(e,a);h.name=e.name,d.push(h),u=h}else{const h=this.uniformGroups[s]||(this.uniformGroups[s]={});let p=h[l];p===void 0&&(p=new Du(s+"_"+l,a),h[l]=p,d.push(p)),u=this.getNodeUniform(r,t),p.addUniform(u)}i.uniformGPU=u}return r}}let Fn=null,wn=null,At=null;class Ou{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null}async init(e){this.renderer=e}begin(){}finish(){}draw(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}createRenderPipeline(){}createComputePipeline(){}destroyPipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}createDefaultTexture(){}createTexture(){}copyTextureToBuffer(){}createAttribute(){}createIndexAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}resolveTimestampAsync(){}hasFeatureAsync(){}hasFeature(){}getInstanceCount(e){const{object:t,geometry:s}=e;return s.isInstancedBufferGeometry?s.instanceCount:t.count>1?t.count:1}getDrawingBufferSize(){return Fn=Fn||new c.Vector2,this.renderer.getDrawingBufferSize(Fn)}getScissor(){return wn=wn||new c.Vector4,this.renderer.getScissor(wn)}setScissorTest(){}getClearColor(){const e=this.renderer;return At=At||new Ur,e.getClearColor(At),At.getRGB(At,this.renderer.currentColorSpace),At}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:c.createCanvasElement(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${c.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 gg=0;class mg{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 Tg{constructor(e){this.backend=e}createAttribute(e,t){const s=this.backend,{gl:n}=s,r=e.array,i=e.usage||n.STATIC_DRAW,u=e.isInterleavedBufferAttribute?e.data:e,a=s.get(u);let l=a.bufferGPU;l===void 0&&(l=this._createBuffer(n,t,r,i),a.bufferGPU=l,a.bufferType=t,a.version=u.version);let d;if(r instanceof Float32Array)d=n.FLOAT;else if(r instanceof Uint16Array)e.isFloat16BufferAttribute?d=n.HALF_FLOAT:d=n.UNSIGNED_SHORT;else if(r instanceof Int16Array)d=n.SHORT;else if(r instanceof Uint32Array)d=n.UNSIGNED_INT;else if(r instanceof Int32Array)d=n.INT;else if(r instanceof Int8Array)d=n.BYTE;else if(r instanceof Uint8Array)d=n.UNSIGNED_BYTE;else if(r instanceof Uint8ClampedArray)d=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+r);let h={bufferGPU:l,bufferType:t,type:d,byteLength:r.byteLength,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:d===n.INT||d===n.UNSIGNED_INT||e.gpuType===c.IntType,id:gg++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const p=this._createBuffer(n,t,r,i);h=new mg(h,p)}s.set(e,h)}updateAttribute(e){const t=this.backend,{gl:s}=t,n=e.array,r=e.isInterleavedBufferAttribute?e.data:e,i=t.get(r),u=i.bufferType,a=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(s.bindBuffer(u,i.bufferGPU),a.length===0)s.bufferSubData(u,0,n);else{for(let l=0,d=a.length;l<d;l++){const h=a[l];s.bufferSubData(u,h.start*n.BYTES_PER_ELEMENT,n,h.start,h.count)}r.clearUpdateRanges()}s.bindBuffer(u,null),i.version=r.version}destroyAttribute(e){const t=this.backend,{gl:s}=t;e.isInterleavedBufferAttribute&&t.delete(e.data);const n=t.get(e);s.deleteBuffer(n.bufferGPU),t.delete(e)}async getArrayBufferAsync(e){const t=this.backend,{gl:s}=t,n=e.isInterleavedBufferAttribute?e.data:e,{bufferGPU:r}=t.get(n),i=e.array,u=i.byteLength;s.bindBuffer(s.COPY_READ_BUFFER,r);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 l=new e.array.constructor(i.length);return s.bindBuffer(s.COPY_WRITE_BUFFER,a),s.getBufferSubData(s.COPY_WRITE_BUFFER,0,l),s.deleteBuffer(a),s.bindBuffer(s.COPY_READ_BUFFER,null),s.bindBuffer(s.COPY_WRITE_BUFFER,null),l.buffer}_createBuffer(e,t,s,n){const r=e.createBuffer();return e.bindBuffer(t,r),e.bufferData(t,s,n),e.bindBuffer(t,null),r}}let Ki=!1,Un,Kt;class yg{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.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},Ki===!1&&(this._init(this.gl),Ki=!0)}_init(e){Un={[c.AddEquation]:e.FUNC_ADD,[c.SubtractEquation]:e.FUNC_SUBTRACT,[c.ReverseSubtractEquation]:e.FUNC_REVERSE_SUBTRACT},Kt={[c.ZeroFactor]:e.ZERO,[c.OneFactor]:e.ONE,[c.SrcColorFactor]:e.SRC_COLOR,[c.SrcAlphaFactor]:e.SRC_ALPHA,[c.SrcAlphaSaturateFactor]:e.SRC_ALPHA_SATURATE,[c.DstColorFactor]:e.DST_COLOR,[c.DstAlphaFactor]:e.DST_ALPHA,[c.OneMinusSrcColorFactor]:e.ONE_MINUS_SRC_COLOR,[c.OneMinusSrcAlphaFactor]:e.ONE_MINUS_SRC_ALPHA,[c.OneMinusDstColorFactor]:e.ONE_MINUS_DST_COLOR,[c.OneMinusDstAlphaFactor]:e.ONE_MINUS_DST_ALPHA}}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!==c.CullFaceNone?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===c.CullFaceBack?t.cullFace(t.BACK):e===c.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,n,r,i,u,a){const{gl:l}=this;if(e===c.NoBlending){this.currentBlendingEnabled===!0&&(this.disable(l.BLEND),this.currentBlendingEnabled=!1);return}if(this.currentBlendingEnabled===!1&&(this.enable(l.BLEND),this.currentBlendingEnabled=!0),e!==c.CustomBlending){if(e!==this.currentBlending||a!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==c.AddEquation||this.currentBlendEquationAlpha!==c.AddEquation)&&(l.blendEquation(l.FUNC_ADD),this.currentBlendEquation=c.AddEquation,this.currentBlendEquationAlpha=c.AddEquation),a)switch(e){case c.NormalBlending:l.blendFuncSeparate(l.ONE,l.ONE_MINUS_SRC_ALPHA,l.ONE,l.ONE_MINUS_SRC_ALPHA);break;case c.AdditiveBlending:l.blendFunc(l.ONE,l.ONE);break;case c.SubtractiveBlending:l.blendFuncSeparate(l.ZERO,l.ONE_MINUS_SRC_COLOR,l.ZERO,l.ONE);break;case c.MultiplyBlending:l.blendFuncSeparate(l.ZERO,l.SRC_COLOR,l.ZERO,l.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",e);break}else switch(e){case c.NormalBlending:l.blendFuncSeparate(l.SRC_ALPHA,l.ONE_MINUS_SRC_ALPHA,l.ONE,l.ONE_MINUS_SRC_ALPHA);break;case c.AdditiveBlending:l.blendFunc(l.SRC_ALPHA,l.ONE);break;case c.SubtractiveBlending:l.blendFuncSeparate(l.ZERO,l.ONE_MINUS_SRC_COLOR,l.ZERO,l.ONE);break;case c.MultiplyBlending:l.blendFunc(l.ZERO,l.SRC_COLOR);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}r=r||t,i=i||s,u=u||n,(t!==this.currentBlendEquation||r!==this.currentBlendEquationAlpha)&&(l.blendEquationSeparate(Un[t],Un[r]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=r),(s!==this.currentBlendSrc||n!==this.currentBlendDst||i!==this.currentBlendSrcAlpha||u!==this.currentBlendDstAlpha)&&(l.blendFuncSeparate(Kt[s],Kt[n],Kt[i],Kt[u]),this.currentBlendSrc=s,this.currentBlendDst=n,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 c.NeverDepth:t.depthFunc(t.NEVER);break;case c.AlwaysDepth:t.depthFunc(t.ALWAYS);break;case c.LessDepth:t.depthFunc(t.LESS);break;case c.LessEqualDepth:t.depthFunc(t.LEQUAL);break;case c.EqualDepth:t.depthFunc(t.EQUAL);break;case c.GreaterEqualDepth:t.depthFunc(t.GEQUAL);break;case c.GreaterDepth:t.depthFunc(t.GREATER);break;case c.NotEqualDepth:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}this.currentDepthFunc=e}}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:n}=this;e.side===c.DoubleSide?this.disable(n.CULL_FACE):this.enable(n.CULL_FACE);let r=e.side===c.BackSide;t&&(r=!r),this.setFlipSided(r),e.blending===c.NormalBlending&&e.transparent===!1?this.setBlending(c.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(n.SAMPLE_ALPHA_TO_COVERAGE):this.disable(n.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:n}=this;e?(this.enable(n.POLYGON_OFFSET_FILL),(this.currentPolygonOffsetFactor!==t||this.currentPolygonOffsetUnits!==s)&&(n.polygonOffset(t,s),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=s)):this.disable(n.POLYGON_OFFSET_FILL)}useProgram(e){return this.currentProgram!==e?(this.gl.useProgram(e),this.currentProgram=e,!0):!1}bindFramebuffer(e,t){const{gl:s,currentBoundFramebuffers:n}=this;return n[e]!==t?(s.bindFramebuffer(e,t),n[e]=t,e===s.DRAW_FRAMEBUFFER&&(n[s.FRAMEBUFFER]=t),e===s.FRAMEBUFFER&&(n[s.DRAW_FRAMEBUFFER]=t),!0):!1}drawBuffers(e,t){const{gl:s}=this;let n=[],r=!1;if(e.textures!==null){n=this.currentDrawbuffers.get(t),n===void 0&&(n=[],this.currentDrawbuffers.set(t,n));const i=e.textures;if(n.length!==i.length||n[0]!==s.COLOR_ATTACHMENT0){for(let u=0,a=i.length;u<a;u++)n[u]=s.COLOR_ATTACHMENT0+u;n.length=i.length,r=!0}}else n[0]!==s.BACK&&(n[0]=s.BACK,r=!0);r&&s.drawBuffers(n)}activeTexture(e){const{gl:t,currentTextureSlot:s,maxTextures:n}=this;e===void 0&&(e=t.TEXTURE0+n-1),s!==e&&(t.activeTexture(e),this.currentTextureSlot=e)}bindTexture(e,t,s){const{gl:n,currentTextureSlot:r,currentBoundTextures:i,maxTextures:u}=this;s===void 0&&(r===null?s=n.TEXTURE0+u-1:s=r);let a=i[s];a===void 0&&(a={type:void 0,texture:void 0},i[s]=a),(a.type!==e||a.texture!==t)&&(r!==s&&(n.activeTexture(s),this.currentTextureSlot=s),n.bindTexture(e,t),a.type=e,a.texture=t)}bindBufferBase(e,t,s){const{gl:n}=this,r=`${e}-${t}`;return this.currentBoundBufferBases[r]!==s?(n.bindBufferBase(e,t,s),this.currentBoundBufferBases[r]=s,!0):!1}unbindTexture(){const{gl:e,currentTextureSlot:t,currentBoundTextures:s}=this,n=s[t];n!==void 0&&n.type!==void 0&&(e.bindTexture(n.type,null),n.type=void 0,n.texture=void 0)}}class _g{constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=c.NoColorSpace){const{gl:s,extensions:n}=this;let r;if(e===c.UnsignedByteType)return s.UNSIGNED_BYTE;if(e===c.UnsignedShort4444Type)return s.UNSIGNED_SHORT_4_4_4_4;if(e===c.UnsignedShort5551Type)return s.UNSIGNED_SHORT_5_5_5_1;if(e===c.UnsignedInt5999Type)return s.UNSIGNED_INT_5_9_9_9_REV;if(e===c.ByteType)return s.BYTE;if(e===c.ShortType)return s.SHORT;if(e===c.UnsignedShortType)return s.UNSIGNED_SHORT;if(e===c.IntType)return s.INT;if(e===c.UnsignedIntType)return s.UNSIGNED_INT;if(e===c.FloatType)return s.FLOAT;if(e===c.HalfFloatType)return s.HALF_FLOAT;if(e===c.AlphaFormat)return s.ALPHA;if(e===c.RGBFormat)return s.RGB;if(e===c.RGBAFormat)return s.RGBA;if(e===c.LuminanceFormat)return s.LUMINANCE;if(e===c.LuminanceAlphaFormat)return s.LUMINANCE_ALPHA;if(e===c.DepthFormat)return s.DEPTH_COMPONENT;if(e===c.DepthStencilFormat)return s.DEPTH_STENCIL;if(e===c.RedFormat)return s.RED;if(e===c.RedIntegerFormat)return s.RED_INTEGER;if(e===c.RGFormat)return s.RG;if(e===c.RGIntegerFormat)return s.RG_INTEGER;if(e===c.RGBAIntegerFormat)return s.RGBA_INTEGER;if(e===c.RGB_S3TC_DXT1_Format||e===c.RGBA_S3TC_DXT1_Format||e===c.RGBA_S3TC_DXT3_Format||e===c.RGBA_S3TC_DXT5_Format)if(t===c.SRGBColorSpace)if(r=n.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(e===c.RGB_S3TC_DXT1_Format)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===c.RGBA_S3TC_DXT1_Format)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===c.RGBA_S3TC_DXT3_Format)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===c.RGBA_S3TC_DXT5_Format)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=n.get("WEBGL_compressed_texture_s3tc"),r!==null){if(e===c.RGB_S3TC_DXT1_Format)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===c.RGBA_S3TC_DXT1_Format)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===c.RGBA_S3TC_DXT3_Format)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===c.RGBA_S3TC_DXT5_Format)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(e===c.RGB_PVRTC_4BPPV1_Format||e===c.RGB_PVRTC_2BPPV1_Format||e===c.RGBA_PVRTC_4BPPV1_Format||e===c.RGBA_PVRTC_2BPPV1_Format)if(r=n.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(e===c.RGB_PVRTC_4BPPV1_Format)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===c.RGB_PVRTC_2BPPV1_Format)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===c.RGBA_PVRTC_4BPPV1_Format)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===c.RGBA_PVRTC_2BPPV1_Format)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(e===c.RGB_ETC1_Format||e===c.RGB_ETC2_Format||e===c.RGBA_ETC2_EAC_Format)if(r=n.get("WEBGL_compressed_texture_etc"),r!==null){if(e===c.RGB_ETC1_Format||e===c.RGB_ETC2_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(e===c.RGBA_ETC2_EAC_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(e===c.RGBA_ASTC_4x4_Format||e===c.RGBA_ASTC_5x4_Format||e===c.RGBA_ASTC_5x5_Format||e===c.RGBA_ASTC_6x5_Format||e===c.RGBA_ASTC_6x6_Format||e===c.RGBA_ASTC_8x5_Format||e===c.RGBA_ASTC_8x6_Format||e===c.RGBA_ASTC_8x8_Format||e===c.RGBA_ASTC_10x5_Format||e===c.RGBA_ASTC_10x6_Format||e===c.RGBA_ASTC_10x8_Format||e===c.RGBA_ASTC_10x10_Format||e===c.RGBA_ASTC_12x10_Format||e===c.RGBA_ASTC_12x12_Format)if(r=n.get("WEBGL_compressed_texture_astc"),r!==null){if(e===c.RGBA_ASTC_4x4_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===c.RGBA_ASTC_5x4_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===c.RGBA_ASTC_5x5_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===c.RGBA_ASTC_6x5_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===c.RGBA_ASTC_6x6_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===c.RGBA_ASTC_8x5_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===c.RGBA_ASTC_8x6_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===c.RGBA_ASTC_8x8_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===c.RGBA_ASTC_10x5_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===c.RGBA_ASTC_10x6_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===c.RGBA_ASTC_10x8_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===c.RGBA_ASTC_10x10_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===c.RGBA_ASTC_12x10_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===c.RGBA_ASTC_12x12_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(e===c.RGBA_BPTC_Format)if(r=n.get("EXT_texture_compression_bptc"),r!==null){if(e===c.RGBA_BPTC_Format)return t===c.SRGBColorSpace?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(e===c.RED_RGTC1_Format||e===c.SIGNED_RED_RGTC1_Format||e===c.RED_GREEN_RGTC2_Format||e===c.SIGNED_RED_GREEN_RGTC2_Format)if(r=n.get("EXT_texture_compression_rgtc"),r!==null){if(e===c.RGBA_BPTC_Format)return r.COMPRESSED_RED_RGTC1_EXT;if(e===c.SIGNED_RED_RGTC1_Format)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===c.RED_GREEN_RGTC2_Format)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===c.SIGNED_RED_GREEN_RGTC2_Format)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return e===c.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,n)=>{function r(){const i=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(i===e.WAIT_FAILED){e.deleteSync(t),n();return}if(i===e.TIMEOUT_EXPIRED){requestAnimationFrame(r);return}e.deleteSync(t),s()}r()})}}let Xi=!1,Cs,Gn,Yi;class Sg{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},Xi===!1&&(this._init(this.gl),Xi=!0)}_init(e){Cs={[c.RepeatWrapping]:e.REPEAT,[c.ClampToEdgeWrapping]:e.CLAMP_TO_EDGE,[c.MirroredRepeatWrapping]:e.MIRRORED_REPEAT},Gn={[c.NearestFilter]:e.NEAREST,[c.NearestMipmapNearestFilter]:e.NEAREST_MIPMAP_NEAREST,[c.NearestMipmapLinearFilter]:e.NEAREST_MIPMAP_LINEAR,[c.LinearFilter]:e.LINEAR,[c.LinearMipmapNearestFilter]:e.LINEAR_MIPMAP_NEAREST,[c.LinearMipmapLinearFilter]:e.LINEAR_MIPMAP_LINEAR},Yi={[c.NeverCompare]:e.NEVER,[c.AlwaysCompare]:e.ALWAYS,[c.LessCompare]:e.LESS,[c.LessEqualCompare]:e.LEQUAL,[c.EqualCompare]:e.EQUAL,[c.GreaterEqualCompare]:e.GEQUAL,[c.GreaterCompare]:e.GREATER,[c.NotEqualCompare]:e.NOTEQUAL}}filterFallback(e){const{gl:t}=this;return e===c.NearestFilter||e===c.NearestMipmapNearestFilter||e===c.NearestMipmapLinearFilter?t.NEAREST:t.LINEAR}getGLTextureType(e){const{gl:t}=this;let s;return e.isCubeTexture===!0?s=t.TEXTURE_CUBE_MAP: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,n,r=!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;return 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&&(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=n===c.SRGBColorSpace&&r===!1?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)),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&&(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=n===c.SRGBColorSpace&&r===!1?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)),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_INT&&(a=i.DEPTH24_STENCIL8),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:n,backend:r}=this;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,s.NONE),s.texParameteri(e,s.TEXTURE_WRAP_S,Cs[t.wrapS]),s.texParameteri(e,s.TEXTURE_WRAP_T,Cs[t.wrapT]),(e===s.TEXTURE_3D||e===s.TEXTURE_2D_ARRAY)&&s.texParameteri(e,s.TEXTURE_WRAP_R,Cs[t.wrapR]),s.texParameteri(e,s.TEXTURE_MAG_FILTER,Gn[t.magFilter]);const i=t.mipmaps!==void 0&&t.mipmaps.length>0,u=t.minFilter===c.LinearFilter&&i?c.LinearMipmapLinearFilter:t.minFilter;if(s.texParameteri(e,s.TEXTURE_MIN_FILTER,Gn[u]),t.compareFunction&&(s.texParameteri(e,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(e,s.TEXTURE_COMPARE_FUNC,Yi[t.compareFunction])),n.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===c.NearestFilter||t.minFilter!==c.NearestMipmapLinearFilter&&t.minFilter!==c.LinearMipmapLinearFilter||t.type===c.FloatType&&n.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const a=n.get("EXT_texture_filter_anisotropic");s.texParameterf(e,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,r.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:s,defaultTextures:n}=this,r=this.getGLTextureType(e);let i=n[r];i===void 0&&(i=t.createTexture(),s.state.bindTexture(r,i),t.texParameteri(r,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(r,t.TEXTURE_MAG_FILTER,t.NEAREST),n[r]=i),s.set(e,{textureGPU:i,glTextureType:r,isDefault:!0})}createTexture(e,t){const{gl:s,backend:n}=this,{levels:r,width:i,height:u,depth:a}=t,l=n.utils.convert(e.format,e.colorSpace),d=n.utils.convert(e.type),h=this.getInternalFormat(e.internalFormat,l,d,e.colorSpace,e.isVideoTexture),p=s.createTexture(),f=this.getGLTextureType(e);n.state.bindTexture(f,p),this.setTextureParameters(f,e),e.isDataArrayTexture||e.isCompressedArrayTexture?s.texStorage3D(s.TEXTURE_2D_ARRAY,r,h,i,u,a):e.isData3DTexture?s.texStorage3D(s.TEXTURE_3D,r,h,i,u,a):e.isVideoTexture||s.texStorage2D(f,r,h,i,u),n.set(e,{textureGPU:p,glTextureType:f,glFormat:l,glType:d,glInternalFormat:h})}copyBufferToTexture(e,t){const{gl:s,backend:n}=this,{textureGPU:r,glTextureType:i,glFormat:u,glType:a}=n.get(t),{width:l,height:d}=t.source.data;s.bindBuffer(s.PIXEL_UNPACK_BUFFER,e),n.state.bindTexture(i,r),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.texSubImage2D(i,0,0,0,l,d,u,a,0),s.bindBuffer(s.PIXEL_UNPACK_BUFFER,null),n.state.unbindTexture()}updateTexture(e,t){const{gl:s}=this,{width:n,height:r}=t,{textureGPU:i,glTextureType:u,glFormat:a,glType:l,glInternalFormat:d}=this.backend.get(e);if(e.isRenderTargetTexture||i===void 0)return;const h=p=>p.isDataTexture?p.image.data:typeof HTMLImageElement<"u"&&p instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&p instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&p instanceof ImageBitmap||p instanceof OffscreenCanvas?p:p.data;if(this.backend.state.bindTexture(u,i),this.setTextureParameters(u,e),e.isCompressedTexture){const p=e.mipmaps,f=t.image;for(let g=0;g<p.length;g++){const m=p[g];e.isCompressedArrayTexture?e.format!==s.RGBA?a!==null?s.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,g,0,0,0,m.width,m.height,f.depth,a,m.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):s.texSubImage3D(s.TEXTURE_2D_ARRAY,g,0,0,0,m.width,m.height,f.depth,a,l,m.data):a!==null?s.compressedTexSubImage2D(s.TEXTURE_2D,g,0,0,m.width,m.height,a,m.data):console.warn("Unsupported compressed texture format")}}else if(e.isCubeTexture){const p=t.images;for(let f=0;f<6;f++){const g=h(p[f]);s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,0,0,n,r,a,l,g)}}else if(e.isDataArrayTexture){const p=t.image;s.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,a,l,p.data)}else if(e.isData3DTexture){const p=t.image;s.texSubImage3D(s.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,a,l,p.data)}else if(e.isVideoTexture)e.update(),s.texImage2D(u,0,d,a,l,t.image);else{const p=h(t.image);s.texSubImage2D(u,0,0,0,n,r,a,l,p)}}generateMipmaps(e){const{gl:t,backend:s}=this,{textureGPU:n,glTextureType:r}=s.get(e);s.state.bindTexture(r,n),t.generateMipmap(r)}deallocateRenderBuffers(e){const{gl:t,backend:s}=this;if(e){const n=s.get(e);if(n.renderBufferStorageSetup=void 0,n.framebuffers){for(const r in n.framebuffers)t.deleteFramebuffer(n.framebuffers[r]);delete n.framebuffers}if(n.depthRenderbuffer&&(t.deleteRenderbuffer(n.depthRenderbuffer),delete n.depthRenderbuffer),n.stencilRenderbuffer&&(t.deleteRenderbuffer(n.stencilRenderbuffer),delete n.stencilRenderbuffer),n.msaaFrameBuffer&&(t.deleteFramebuffer(n.msaaFrameBuffer),delete n.msaaFrameBuffer),n.msaaRenderbuffers){for(let r=0;r<n.msaaRenderbuffers.length;r++)t.deleteRenderbuffer(n.msaaRenderbuffers[r]);delete n.msaaRenderbuffers}}}destroyTexture(e){const{gl:t,backend:s}=this,{textureGPU:n,renderTarget:r}=s.get(e);this.deallocateRenderBuffers(r),t.deleteTexture(n),s.delete(e)}copyTextureToTexture(e,t,s=null,n=null,r=0){const{gl:i,backend:u}=this,{state:a}=this.backend,{textureGPU:l,glTextureType:d,glType:h,glFormat:p}=u.get(t);let f,g,m,y,S,A;s!==null?(f=s.max.x-s.min.x,g=s.max.y-s.min.y,m=s.min.x,y=s.min.y):(f=e.image.width,g=e.image.height,m=0,y=0),n!==null?(S=n.x,A=n.y):(S=0,A=0),a.bindTexture(d,l),i.pixelStorei(i.UNPACK_ALIGNMENT,t.unpackAlignment),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,t.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,t.unpackAlignment);const E=i.getParameter(i.UNPACK_ROW_LENGTH),D=i.getParameter(i.UNPACK_IMAGE_HEIGHT),w=i.getParameter(i.UNPACK_SKIP_PIXELS),U=i.getParameter(i.UNPACK_SKIP_ROWS),G=i.getParameter(i.UNPACK_SKIP_IMAGES),P=e.isCompressedTexture?e.mipmaps[r]:e.image;if(i.pixelStorei(i.UNPACK_ROW_LENGTH,P.width),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,P.height),i.pixelStorei(i.UNPACK_SKIP_PIXELS,m),i.pixelStorei(i.UNPACK_SKIP_ROWS,y),e.isRenderTargetTexture||e.isDepthTexture){const Q=u.get(e),se=u.get(t),X=u.get(Q.renderTarget),xe=u.get(se.renderTarget),be=X.framebuffers[Q.cacheKey],ze=xe.framebuffers[se.cacheKey];a.bindFramebuffer(i.READ_FRAMEBUFFER,be),a.bindFramebuffer(i.DRAW_FRAMEBUFFER,ze);let Nt=i.COLOR_BUFFER_BIT;e.isDepthTexture&&(Nt=i.DEPTH_BUFFER_BIT),i.blitFramebuffer(m,y,f,g,S,A,f,g,Nt,i.NEAREST),a.bindFramebuffer(i.READ_FRAMEBUFFER,null),a.bindFramebuffer(i.DRAW_FRAMEBUFFER,null)}else e.isDataTexture?i.texSubImage2D(i.TEXTURE_2D,r,S,A,f,g,p,h,P.data):e.isCompressedTexture?i.compressedTexSubImage2D(i.TEXTURE_2D,r,S,A,P.width,P.height,p,P.data):i.texSubImage2D(i.TEXTURE_2D,r,S,A,f,g,p,h,P);i.pixelStorei(i.UNPACK_ROW_LENGTH,E),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,D),i.pixelStorei(i.UNPACK_SKIP_PIXELS,w),i.pixelStorei(i.UNPACK_SKIP_ROWS,U),i.pixelStorei(i.UNPACK_SKIP_IMAGES,G),r===0&&t.generateMipmaps&&i.generateMipmap(i.TEXTURE_2D),a.unbindTexture()}copyFramebufferToTexture(e,t,s){const{gl:n}=this,{state:r}=this.backend,{textureGPU:i}=this.backend.get(e),{x:u,y:a,z:l,w:d}=s,h=e.isDepthTexture===!0||t.renderTarget&&t.renderTarget.samples>0,p=t.renderTarget?t.renderTarget.height:this.backend.gerDrawingBufferSize().y;if(h){const f=u!==0||a!==0;let g,m;if(e.isDepthTexture===!0?(g=n.DEPTH_BUFFER_BIT,m=n.DEPTH_ATTACHMENT,t.stencil&&(g|=n.STENCIL_BUFFER_BIT)):(g=n.COLOR_BUFFER_BIT,m=n.COLOR_ATTACHMENT0),f){const y=this.backend.get(t.renderTarget),S=y.framebuffers[t.getCacheKey()],A=y.msaaFrameBuffer;r.bindFramebuffer(n.DRAW_FRAMEBUFFER,S),r.bindFramebuffer(n.READ_FRAMEBUFFER,A);const E=p-a-d;n.blitFramebuffer(u,E,u+l,E+d,u,E,u+l,E+d,g,n.NEAREST),r.bindFramebuffer(n.READ_FRAMEBUFFER,S),r.bindTexture(n.TEXTURE_2D,i),n.copyTexSubImage2D(n.TEXTURE_2D,0,0,0,u,E,l,d),r.unbindTexture()}else{const y=n.createFramebuffer();r.bindFramebuffer(n.DRAW_FRAMEBUFFER,y),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,m,n.TEXTURE_2D,i,0),n.blitFramebuffer(0,0,l,d,0,0,l,d,g,n.NEAREST),n.deleteFramebuffer(y)}}else r.bindTexture(n.TEXTURE_2D,i),n.copyTexSubImage2D(n.TEXTURE_2D,0,0,0,u,p-d-a,l,d),r.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t){const{gl:s}=this,n=t.renderTarget,{samples:r,depthTexture:i,depthBuffer:u,stencilBuffer:a,width:l,height:d}=n;if(s.bindRenderbuffer(s.RENDERBUFFER,e),u&&!a){let h=s.DEPTH_COMPONENT24;r>0?(i&&i.isDepthTexture&&i.type===s.FLOAT&&(h=s.DEPTH_COMPONENT32F),s.renderbufferStorageMultisample(s.RENDERBUFFER,r,h,l,d)):s.renderbufferStorage(s.RENDERBUFFER,h,l,d),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,e)}else u&&a&&(r>0?s.renderbufferStorageMultisample(s.RENDERBUFFER,r,s.DEPTH24_STENCIL8,l,d):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,l,d),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,s,n,r,i){const{backend:u,gl:a}=this,{textureGPU:l,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,l,0);const g=this._getTypedArrayType(h),m=this._getBytesPerTexel(h,d),S=n*r*m,A=a.createBuffer();a.bindBuffer(a.PIXEL_PACK_BUFFER,A),a.bufferData(a.PIXEL_PACK_BUFFER,S,a.STREAM_READ),a.readPixels(t,s,n,r,d,h,0),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),await u.utils._clientWaitAsync();const E=new g(S/g.BYTES_PER_ELEMENT);return a.bindBuffer(a.PIXEL_PACK_BUFFER,A),a.getBufferSubData(a.PIXEL_PACK_BUFFER,0,E),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),a.deleteFramebuffer(p),E}_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 n=0;if(e===s.UNSIGNED_BYTE&&(n=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)&&(n=2),(e===s.UNSIGNED_INT||e===s.FLOAT)&&(n=4),t===s.RGBA)return n*4;if(t===s.RGB)return n*3;if(t===s.ALPHA)return n}}class Ng{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 xg{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 Qi={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"};class bg{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:n,object:r,type:i,info:u,index:a}=this;a!==0?s.drawElements(n,t,i,e):s.drawArrays(n,e,t),u.update(r,t,n,1)}renderInstances(e,t,s){const{gl:n,mode:r,type:i,index:u,object:a,info:l}=this;s!==0&&(u!==0?n.drawElementsInstanced(r,t,i,e,s):n.drawArraysInstanced(r,e,t,s),l.update(a,t,r,s))}renderMultiDraw(e,t,s){const{extensions:n,mode:r,object:i,info:u}=this;if(s===0)return;const a=n.get("WEBGL_multi_draw");if(a===null)for(let l=0;l<s;l++)this.render(e[l],t[l]);else{this.index!==0?a.multiDrawElementsWEBGL(r,t,0,this.type,e,0,s):a.multiDrawArraysWEBGL(r,e,0,t,0,s);let l=0;for(let d=0;d<s;d++)l+=t[d];u.update(i,l,r,1)}}renderMultiDrawInstances(e,t,s,n){const{extensions:r,mode:i,object:u,info:a}=this;if(s===0)return;const l=r.get("WEBGL_multi_draw");if(l===null)for(let d=0;d<s;d++)this.renderInstances(e[d],t[d],n[d]);else{this.index!==0?l.multiDrawElementsInstancedWEBGL(i,t,0,this.type,e,0,n,0,s):l.multiDrawArraysInstancedWEBGL(i,e,0,t,0,n,0,s);let d=0;for(let h=0;h<s;h++)d+=t[h]*n[h];a.update(u,d,i,1)}}}class ji extends Ou{constructor(e={}){super(e),this.isWebGLBackend=!0}init(e){super.init(e);const t=this.parameters,s=t.context!==void 0?t.context:e.domElement.getContext("webgl2");function n(r){r.preventDefault();const i={api:"WebGL",message:r.statusMessage||"Unknown reason",reason:null,originalEvent:r};e.onDeviceLost(i)}this._onContextLost=n,e.domElement.addEventListener("webglcontextlost",n,!1),this.gl=s,this.extensions=new Ng(this),this.capabilities=new xg(this),this.attributeUtils=new Tg(this),this.textureUtils=new Sg(this),this.bufferRenderer=new bg(this),this.state=new yg(this),this.utils=new _g(this),this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.trackTimestamp=t.trackTimestamp===!0,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.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile"),this._knownBindings=new WeakSet,this._currentContext=null}get coordinateSystem(){return c.WebGLCoordinateSystem}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async waitForGPU(){await this.utils._clientWaitAsync()}initTimestampQuery(e){if(!this.disjoint||!this.trackTimestamp)return;const t=this.get(e);if(this.queryRunning){t.queryQueue||(t.queryQueue=[]),t.queryQueue.push(e);return}t.activeQuery&&(this.gl.endQuery(this.disjoint.TIME_ELAPSED_EXT),t.activeQuery=null),t.activeQuery=this.gl.createQuery(),t.activeQuery!==null&&(this.gl.beginQuery(this.disjoint.TIME_ELAPSED_EXT,t.activeQuery),this.queryRunning=!0)}prepareTimestampBuffer(e){if(!this.disjoint||!this.trackTimestamp)return;const t=this.get(e);if(t.activeQuery&&(this.gl.endQuery(this.disjoint.TIME_ELAPSED_EXT),t.gpuQueries||(t.gpuQueries=[]),t.gpuQueries.push({query:t.activeQuery}),t.activeQuery=null,this.queryRunning=!1,t.queryQueue&&t.queryQueue.length>0)){const s=t.queryQueue.shift();this.initTimestampQuery(s)}}async resolveTimestampAsync(e,t="render"){if(!this.disjoint||!this.trackTimestamp)return;const s=this.get(e);s.gpuQueries||(s.gpuQueries=[]);for(let n=0;n<s.gpuQueries.length;n++){const r=s.gpuQueries[n],i=this.gl.getQueryParameter(r.query,this.gl.QUERY_RESULT_AVAILABLE),u=this.gl.getParameter(this.disjoint.GPU_DISJOINT_EXT);if(i&&!u){const a=this.gl.getQueryParameter(r.query,this.gl.QUERY_RESULT),l=Number(a)/1e6;this.gl.deleteQuery(r.query),s.gpuQueries.splice(n,1),n--,this.renderer.info.updateTimestamp(t,l)}}}getContext(){return this.gl}beginRender(e){const{gl:t}=this,s=this.get(e);if(this.initTimestampQuery(e),s.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1),e.viewport?this.updateViewport(e):t.viewport(0,0,t.drawingBufferWidth,t.drawingBufferHeight),e.scissor){const{x:r,y:i,width:u,height:a}=e.scissorValue;t.scissor(r,e.height-a-i,u,a)}const n=e.occlusionQueryCount;n>0&&(s.currentOcclusionQueries=s.occlusionQueries,s.currentOcclusionQueryObjects=s.occlusionQueryObjects,s.lastOcclusionObject=null,s.occlusionQueries=new Array(n),s.occlusionQueryObjects=new Array(n),s.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:s}=this,n=this.get(e),r=n.previousContext,i=e.occlusionQueryCount;i>0&&(i>n.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const u=e.textures;if(u!==null)for(let a=0;a<u.length;a++){const l=u[a];l.generateMipmaps&&this.generateMipmaps(l)}if(this._currentContext=r,e.textures!==null&&e.renderTarget){const a=this.get(e.renderTarget),{samples:l}=e.renderTarget;if(l>0){const d=a.framebuffers[e.getCacheKey()],h=t.COLOR_BUFFER_BIT,p=a.msaaFrameBuffer,f=e.textures;s.bindFramebuffer(t.READ_FRAMEBUFFER,p),s.bindFramebuffer(t.DRAW_FRAMEBUFFER,d);for(let g=0;g<f.length;g++)if(e.scissor){const{x:m,y,width:S,height:A}=e.scissorValue,E=e.height-A-y;t.blitFramebuffer(m,E,m+S,E+A,m,E,m+S,E+A,h,t.NEAREST),t.invalidateSubFramebuffer(t.READ_FRAMEBUFFER,a.invalidationArray,m,E,S,A)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,h,t.NEAREST),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,a.invalidationArray)}}r!==null&&(this._setFramebuffer(r),r.viewport?this.updateViewport(r):t.viewport(0,0,t.drawingBufferWidth,t.drawingBufferHeight)),this.prepareTimestampBuffer(e)}resolveOccludedAsync(e){const t=this.get(e),{currentOcclusionQueries:s,currentOcclusionQueryObjects:n}=t;if(s&&n){const r=new WeakSet,{gl:i}=this;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueries=null;const u=()=>{let a=0;for(let l=0;l<s.length;l++){const d=s[l];d!==null&&i.getQueryParameter(d,i.QUERY_RESULT_AVAILABLE)&&(i.getQueryParameter(d,i.QUERY_RESULT)>0&&r.add(n[l]),s[l]=null,i.deleteQuery(d),a++)}a<s.length?requestAnimationFrame(u):t.occluded=r};u()}}isOccluded(e,t){const s=this.get(e);return s.occluded&&s.occluded.has(t)}updateViewport(e){const t=this.gl,{x:s,y:n,width:r,height:i}=e.viewportValue;t.viewport(s,e.height-i-n,r,i)}setScissorTest(e){const t=this.gl;e?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST)}clear(e,t,s,n=null,r=!0){const{gl:i}=this;if(n===null){const a=this.getClearColor();a.r*=a.a,a.g*=a.a,a.b*=a.a,n={textures:null,clearColorValue:a}}let u=0;if(e&&(u|=i.COLOR_BUFFER_BIT),t&&(u|=i.DEPTH_BUFFER_BIT),s&&(u|=i.STENCIL_BUFFER_BIT),u!==0){let a;if(n.clearColorValue?a=n.clearColorValue:(a=this.getClearColor(),a.r*=a.a,a.g*=a.a,a.b*=a.a),t&&this.state.setDepthMask(!0),n.textures===null)i.clearColor(a.r,a.g,a.b,a.a),i.clear(u);else{if(r&&this._setFramebuffer(n),e)for(let l=0;l<n.textures.length;l++)i.clearBufferfv(i.COLOR,l,[a.r,a.g,a.b,a.a]);t&&s?i.clearBufferfi(i.DEPTH_STENCIL,0,1,0):t?i.clearBufferfv(i.DEPTH,0,[1]):s&&i.clearBufferiv(i.STENCIL,0,[0])}}}beginCompute(e){const{state:t,gl:s}=this;t.bindFramebuffer(s.FRAMEBUFFER,null),this.initTimestampQuery(e)}compute(e,t,s,n){const{state:r,gl:i}=this;this.discard||(i.enable(i.RASTERIZER_DISCARD),this.discard=!0);const{programGPU:u,transformBuffers:a,attributes:l}=this.get(n),d=this._getVaoKey(null,l),h=this.vaoCache[d];h===void 0?this._createVao(null,l):i.bindVertexArray(h),r.useProgram(u),this._bindUniforms(s);const p=this._getTransformFeedback(a);i.bindTransformFeedback(i.TRANSFORM_FEEDBACK,p),i.beginTransformFeedback(i.POINTS),l[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.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)}draw(e){const{object:t,pipeline:s,material:n,context:r,hardwareClippingPlanes:i}=e,{programGPU:u}=this.get(s),{gl:a,state:l}=this,d=this.get(r),h=e.getDrawParameters();if(h===null)return;this._bindUniforms(e.getBindings());const p=t.isMesh&&t.matrixWorld.determinant()<0;l.setMaterial(n,p,i),l.useProgram(u);const f=this.get(e);let g=f.staticVao;if(g===void 0||f.geometryId!==e.geometry.id){const w=this._getVaoKey(e.getIndex(),e.getAttributes());if(g=this.vaoCache[w],g===void 0){let U;({vaoGPU:g,staticVao:U}=this._createVao(e.getIndex(),e.getAttributes())),U&&(f.staticVao=g,f.geometryId=e.geometry.id)}}a.bindVertexArray(g);const m=e.getIndex(),y=d.lastOcclusionObject;if(y!==t&&y!==void 0){if(y!==null&&y.occlusionTest===!0&&(a.endQuery(a.ANY_SAMPLES_PASSED),d.occlusionQueryIndex++),t.occlusionTest===!0){const w=a.createQuery();a.beginQuery(a.ANY_SAMPLES_PASSED,w),d.occlusionQueries[d.occlusionQueryIndex]=w,d.occlusionQueryObjects[d.occlusionQueryIndex]=t}d.lastOcclusionObject=t}const S=this.bufferRenderer;t.isPoints?S.mode=a.POINTS:t.isLineSegments?S.mode=a.LINES:t.isLine?S.mode=a.LINE_STRIP:t.isLineLoop?S.mode=a.LINE_LOOP:n.wireframe===!0?(l.setLineWidth(n.wireframeLinewidth*this.renderer.getPixelRatio()),S.mode=a.LINES):S.mode=a.TRIANGLES;const{vertexCount:A,instanceCount:E}=h;let{firstVertex:D}=h;if(S.object=t,m!==null){D*=m.array.BYTES_PER_ELEMENT;const w=this.get(m);S.index=m.count,S.type=w.type}else S.index=0;t.isBatchedMesh?t._multiDrawInstances!==null?S.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances):this.hasFeature("WEBGL_multi_draw")?S.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):c.warnOnce("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):E>1?S.renderInstances(D,A,E):S.render(D,A),a.bindVertexArray(null)}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)}copyTextureToBuffer(e,t,s,n,r,i){return this.textureUtils.copyTextureToBuffer(e,t,s,n,r,i)}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new fg(e,t)}createProgram(e){const t=this.gl,{stage:s,code:n}=e,r=s==="fragment"?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(r,n),t.compileShader(r),this.set(e,{shaderGPU:r})}destroyProgram(){console.warn("Abstract class.")}createRenderPipeline(e,t){const s=this.gl,n=e.pipeline,{fragmentProgram:r,vertexProgram:i}=n,u=s.createProgram(),a=this.get(r).shaderGPU,l=this.get(i).shaderGPU;if(s.attachShader(u,a),s.attachShader(u,l),s.linkProgram(u),this.set(n,{programGPU:u,fragmentShader:a,vertexShader:l}),t!==null&&this.parallel){const d=new Promise(h=>{const p=this.parallel,f=()=>{s.getProgramParameter(u,p.COMPLETION_STATUS_KHR)?(this._completeCompile(e,n),h()):requestAnimationFrame(f)};f()});t.push(d);return}this._completeCompile(e,n)}_handleSource(e,t){const s=e.split(`
151
+ `),n=[],r=Math.max(t-6,0),i=Math.min(t+6,s.length);for(let u=r;u<i;u++){const a=u+1;n.push(`${a===t?">":" "} ${a}: ${s[u]}`)}return n.join(`
152
+ `)}_getShaderErrors(e,t,s){const n=e.getShaderParameter(t,e.COMPILE_STATUS),r=e.getShaderInfoLog(t).trim();if(n&&r==="")return"";const i=/ERROR: 0:(\d+)/.exec(r);if(i){const u=parseInt(i[1]);return s.toUpperCase()+`
153
+
154
+ `+r+`
155
+
156
+ `+this._handleSource(e.getShaderSource(t),u)}else return r}_logProgramError(e,t,s){if(this.renderer.debug.checkShaderErrors){const n=this.gl,r=n.getProgramInfoLog(e).trim();if(n.getProgramParameter(e,n.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(n,e,s,t);else{const i=this._getShaderErrors(n,s,"vertex"),u=this._getShaderErrors(n,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(e,n.VALIDATE_STATUS)+`
157
+
158
+ Program Info Log: `+r+`
159
+ `+i+`
160
+ `+u)}else r!==""&&console.warn("THREE.WebGLProgram: Program Info Log:",r)}}_completeCompile(e,t){const{state:s,gl:n}=this,r=this.get(t),{programGPU:i,fragmentShader:u,vertexShader:a}=r;n.getProgramParameter(i,n.LINK_STATUS)===!1&&this._logProgramError(i,u,a),s.useProgram(i);const l=e.getBindings();this._setupBindings(l,i),this.set(t,{programGPU:i})}createComputePipeline(e,t){const{state:s,gl:n}=this,r={stage:"fragment",code:`#version 300 es
161
+ precision highp float;
162
+ void main() {}`};this.createProgram(r);const{computeProgram:i}=e,u=n.createProgram(),a=this.get(r).shaderGPU,l=this.get(i).shaderGPU,d=i.transforms,h=[],p=[];for(let y=0;y<d.length;y++){const S=d[y];h.push(S.varyingName),p.push(S.attributeNode)}n.attachShader(u,a),n.attachShader(u,l),n.transformFeedbackVaryings(u,h,n.SEPARATE_ATTRIBS),n.linkProgram(u),n.getProgramParameter(u,n.LINK_STATUS)===!1&&this._logProgramError(u,a,l),s.useProgram(u),this._setupBindings(t,u);const f=i.attributes,g=[],m=[];for(let y=0;y<f.length;y++){const S=f[y].node.attribute;g.push(S),this.has(S)||this.attributeUtils.createAttribute(S,n.ARRAY_BUFFER)}for(let y=0;y<p.length;y++){const S=p[y].attribute;this.has(S)||this.attributeUtils.createAttribute(S,n.ARRAY_BUFFER);const A=this.get(S);m.push(A)}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,n=0;for(const r of t){this.set(r,{textures:n,uniformBuffers:s});for(const i of r.bindings)i.isUniformBuffer&&s++,i.isSampledTexture&&n++}}this.updateBindings(e,t)}updateBindings(e){const{gl:t}=this,s=this.get(e);let n=s.uniformBuffers,r=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:n++,bufferGPU:a})}else if(i.isSampledTexture){const{textureGPU:u,glTextureType:a}=this.get(i.texture);this.set(i,{index:r++,textureGPU:u,glTextureType:a})}}updateBinding(e){const t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){const n=this.get(e).bufferGPU,r=e.buffer;t.bindBuffer(t.UNIFORM_BUFFER,n),t.bufferData(t.UNIFORM_BUFFER,r,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)}updateSize(){}hasFeature(e){const t=Object.keys(Qi).filter(n=>Qi[n]===e),s=this.extensions;for(let n=0;n<t.length;n++)if(s.has(t[n]))return!0;return!1}getMaxAnisotropy(){return this.capabilities.getMaxAnisotropy()}copyTextureToTexture(e,t,s,n,r){this.textureUtils.copyTextureToTexture(e,t,s,n,r)}copyFramebufferToTexture(e,t,s){this.textureUtils.copyFramebufferToTexture(e,t,s)}_setFramebuffer(e){const{gl:t,state:s}=this;let n=null;if(e.textures!==null){const r=e.renderTarget,i=this.get(r),{samples:u,depthBuffer:a,stencilBuffer:l}=r,d=r.isWebGLCubeRenderTarget===!0;let h=i.msaaFrameBuffer,p=i.depthRenderbuffer;const f=uu(e);let g;if(d?(i.cubeFramebuffers||(i.cubeFramebuffers={}),g=i.cubeFramebuffers[f]):(i.framebuffers||(i.framebuffers={}),g=i.framebuffers[f]),g===void 0){g=t.createFramebuffer(),s.bindFramebuffer(t.FRAMEBUFFER,g);const m=e.textures;if(d){i.cubeFramebuffers[f]=g;const{textureGPU:y}=this.get(m[0]),S=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+S,y,0)}else{i.framebuffers[f]=g;for(let y=0;y<m.length;y++){const S=m[y],A=this.get(S);A.renderTarget=e.renderTarget,A.cacheKey=f;const E=t.COLOR_ATTACHMENT0+y;t.framebufferTexture2D(t.FRAMEBUFFER,E,t.TEXTURE_2D,A.textureGPU,0)}s.drawBuffers(e,g)}if(e.depthTexture!==null){const y=this.get(e.depthTexture),S=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;y.renderTarget=e.renderTarget,y.cacheKey=f,t.framebufferTexture2D(t.FRAMEBUFFER,S,t.TEXTURE_2D,y.textureGPU,0)}}if(u>0){if(h===void 0){const m=[];h=t.createFramebuffer(),s.bindFramebuffer(t.FRAMEBUFFER,h);const y=[],S=e.textures;for(let A=0;A<S.length;A++){if(y[A]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,y[A]),m.push(t.COLOR_ATTACHMENT0+A),a){const w=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;m.push(w)}const E=e.textures[A],D=this.get(E);t.renderbufferStorageMultisample(t.RENDERBUFFER,u,D.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+A,t.RENDERBUFFER,y[A])}if(i.msaaFrameBuffer=h,i.msaaRenderbuffers=y,p===void 0){p=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(p,e),i.depthRenderbuffer=p;const A=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;m.push(A)}i.invalidationArray=m}n=i.msaaFrameBuffer}else n=g}s.bindFramebuffer(t.FRAMEBUFFER,n)}_getVaoKey(e,t){let s=[];if(e!==null){const n=this.get(e);s+=":"+n.id}for(let n=0;n<t.length;n++){const r=this.get(t[n]);s+=":"+r.id}return s}_createVao(e,t){const{gl:s}=this,n=s.createVertexArray();let r="",i=!0;if(s.bindVertexArray(n),e!==null){const u=this.get(e);s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,u.bufferGPU),r+=":"+u.id}for(let u=0;u<t.length;u++){const a=t[u],l=this.get(a);r+=":"+l.id,s.bindBuffer(s.ARRAY_BUFFER,l.bufferGPU),s.enableVertexAttribArray(u),(a.isStorageBufferAttribute||a.isStorageInstancedBufferAttribute)&&(i=!1);let d,h;a.isInterleavedBufferAttribute===!0?(d=a.data.stride*l.bytesPerElement,h=a.offset*l.bytesPerElement):(d=0,h=0),l.isInteger?s.vertexAttribIPointer(u,a.itemSize,l.type,d,h):s.vertexAttribPointer(u,a.itemSize,l.type,a.normalized,d,h),a.isInstancedBufferAttribute&&!a.isInterleavedBufferAttribute?s.vertexAttribDivisor(u,a.meshPerAttribute):a.isInterleavedBufferAttribute&&a.data.isInstancedInterleavedBuffer&&s.vertexAttribDivisor(u,a.data.meshPerAttribute)}return s.bindBuffer(s.ARRAY_BUFFER,null),this.vaoCache[r]=n,{vaoGPU:n,staticVao:i}}_getTransformFeedback(e){let t="";for(let r=0;r<e.length;r++)t+=":"+e[r].id;let s=this.transformFeedbackCache[t];if(s!==void 0)return s;const{gl:n}=this;s=n.createTransformFeedback(),n.bindTransformFeedback(n.TRANSFORM_FEEDBACK,s);for(let r=0;r<e.length;r++){const i=e[r];n.bindBufferBase(n.TRANSFORM_FEEDBACK_BUFFER,r,i.transformBuffer)}return n.bindTransformFeedback(n.TRANSFORM_FEEDBACK,null),this.transformFeedbackCache[t]=s,s}_setupBindings(e,t){const s=this.gl;for(const n of e)for(const r of n.bindings){const u=this.get(r).index;if(r.isUniformsGroup||r.isUniformBuffer){const a=s.getUniformBlockIndex(t,r.name);s.uniformBlockBinding(t,a,u)}else if(r.isSampledTexture){const a=s.getUniformLocation(t,r.name);s.uniform1i(a,u)}}}_bindUniforms(e){const{gl:t,state:s}=this;for(const n of e)for(const r of n.bindings){const i=this.get(r),u=i.index;r.isUniformsGroup||r.isUniformBuffer?s.bindBufferBase(t.UNIFORM_BUFFER,u,i.bufferGPU):r.isSampledTexture&&s.bindTexture(i.glTextureType,i.textureGPU,t.TEXTURE0+u)}}dispose(){this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const Bt={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list",TriangleStrip:"triangle-strip"},he={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},pe={Store:"store"},oe={Load:"load",Clear:"clear"},Pn={CCW:"ccw"},Dn={None:"none",Front:"front",Back:"back"},Dt={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",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",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"},In={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},ft={Linear:"linear",Nearest:"nearest"},I={Zero:"zero",One:"one",Src:"src",OneMinusSrc:"one-minus-src",SrcAlpha:"src-alpha",OneMinusSrcAlpha:"one-minus-src-alpha",Dst:"dst",OneMinusDstColor:"one-minus-dst",DstAlpha:"dst-alpha",OneMinusDstAlpha:"one-minus-dst-alpha",SrcAlphaSaturated:"src-alpha-saturated",Constant:"constant",OneMinusConstant:"one-minus-constant"},ut={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},Zi={None:0,All:15},Je={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},Ln={Storage:"storage",ReadOnlyStorage:"read-only-storage"},On={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},Xt={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},Ji={TwoD:"2d",ThreeD:"3d"},Ce={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},Rg={All:"all"},vs={Vertex:"vertex",Instance:"instance"},nr={DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups"};class Ag extends Hr{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.isSampler=!0}}class Cg extends Ag{constructor(e,t,s){super(e,t?t.value:null),this.textureNode=t,this.groupNode=s}update(){this.texture=this.textureNode.value}}class vg extends Uu{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let Eg=0;class Mg extends vg{constructor(e,t){super("StorageBuffer_"+Eg++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:De.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class Bg extends ot{constructor(e){super(),this.device=e;const t=`
163
+ struct VarysStruct {
164
+ @builtin( position ) Position: vec4<f32>,
165
+ @location( 0 ) vTex : vec2<f32>
166
+ };
167
+
168
+ @vertex
169
+ fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {
170
+
171
+ var Varys : VarysStruct;
172
+
173
+ var pos = array< vec2<f32>, 4 >(
174
+ vec2<f32>( -1.0, 1.0 ),
175
+ vec2<f32>( 1.0, 1.0 ),
176
+ vec2<f32>( -1.0, -1.0 ),
177
+ vec2<f32>( 1.0, -1.0 )
178
+ );
179
+
180
+ var tex = array< vec2<f32>, 4 >(
181
+ vec2<f32>( 0.0, 0.0 ),
182
+ vec2<f32>( 1.0, 0.0 ),
183
+ vec2<f32>( 0.0, 1.0 ),
184
+ vec2<f32>( 1.0, 1.0 )
185
+ );
186
+
187
+ Varys.vTex = tex[ vertexIndex ];
188
+ Varys.Position = vec4<f32>( pos[ vertexIndex ], 0.0, 1.0 );
189
+
190
+ return Varys;
191
+
192
+ }
193
+ `,s=`
194
+ @group( 0 ) @binding( 0 )
195
+ var imgSampler : sampler;
196
+
197
+ @group( 0 ) @binding( 1 )
198
+ var img : texture_2d<f32>;
199
+
200
+ @fragment
201
+ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
202
+
203
+ return textureSample( img, imgSampler, vTex );
204
+
205
+ }
206
+ `,n=`
207
+ @group( 0 ) @binding( 0 )
208
+ var imgSampler : sampler;
209
+
210
+ @group( 0 ) @binding( 1 )
211
+ var img : texture_2d<f32>;
212
+
213
+ @fragment
214
+ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
215
+
216
+ return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );
217
+
218
+ }
219
+ `;this.mipmapSampler=e.createSampler({minFilter:ft.Linear}),this.flipYSampler=e.createSampler({minFilter:ft.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:n})}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:Bt.TriangleStrip,stripIndexFormat:Dt.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:Bt.TriangleStrip,stripIndexFormat:Dt.Uint32},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,s=0){const n=t.format,{width:r,height:i}=t.size,u=this.getTransferPipeline(n),a=this.getFlipYPipeline(n),l=this.device.createTexture({size:{width:r,height:i,depthOrArrayLayers:1},format:n,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),d=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:Ce.TwoD,baseArrayLayer:s}),h=l.createView({baseMipLevel:0,mipLevelCount:1,dimension:Ce.TwoD,baseArrayLayer:0}),p=this.device.createCommandEncoder({}),f=(g,m,y)=>{const S=g.getBindGroupLayout(0),A=this.device.createBindGroup({layout:S,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:m}]}),E=p.beginRenderPass({colorAttachments:[{view:y,loadOp:oe.Clear,storeOp:pe.Store,clearValue:[0,0,0,0]}]});E.setPipeline(g),E.setBindGroup(0,A),E.draw(4,1,0,0),E.end()};f(u,d,h),f(a,h,d),this.device.queue.submit([p.finish()]),l.destroy()}generateMipmaps(e,t,s=0){const n=this.get(e);n.useCount===void 0&&(n.useCount=0,n.layers=[]);const r=n.layers[s]||this._mipmapCreateBundles(e,t,s),i=this.device.createCommandEncoder({});this._mipmapRunBundles(i,r),this.device.queue.submit([i.finish()]),n.useCount!==0&&(n.layers[s]=r),n.useCount++}_mipmapCreateBundles(e,t,s){const n=this.getTransferPipeline(t.format),r=n.getBindGroupLayout(0);let i=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:Ce.TwoD,baseArrayLayer:s});const u=[];for(let a=1;a<t.mipLevelCount;a++){const l=this.device.createBindGroup({layout:r,entries:[{binding:0,resource:this.mipmapSampler},{binding:1,resource:i}]}),d=e.createView({baseMipLevel:a,mipLevelCount:1,dimension:Ce.TwoD,baseArrayLayer:s}),h={colorAttachments:[{view:d,loadOp:oe.Clear,storeOp:pe.Store,clearValue:[0,0,0,0]}]},p=this.device.createRenderBundleEncoder({colorFormats:[t.format]});p.setPipeline(n),p.setBindGroup(0,l),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 n=0;n<s;n++){const r=t[n],i=e.beginRenderPass(r.passDescriptor);i.executeBundles(r.renderBundles),i.end()}}}const Fg={[c.NeverCompare]:"never",[c.LessCompare]:"less",[c.EqualCompare]:"equal",[c.LessEqualCompare]:"less-equal",[c.GreaterCompare]:"greater",[c.GreaterEqualCompare]:"greater-equal",[c.AlwaysCompare]:"always",[c.NotEqualCompare]:"not-equal"},wg=[0,1,3,2,4,5];class Ug{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this.colorBuffer=null,this.depthTexture=new c.DepthTexture,this.depthTexture.name="depthBuffer"}createSampler(e){const t=this.backend,s=t.device,n=t.get(e),r={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};r.magFilter===ft.Linear&&r.minFilter===ft.Linear&&r.mipmapFilter===ft.Linear&&(r.maxAnisotropy=e.anisotropy),e.isDepthTexture&&e.compareFunction!==null&&(r.compare=Fg[e.compareFunction]),n.sampler=s.createSampler(r)}createDefaultTexture(e){let t;const s=rr(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,n=s.get(e);if(n.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:r,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 l=this._getDimension(e),d=e.internalFormat||t.format||rr(e,s.device);n.format=d;let h=t.sampleCount!==void 0?t.sampleCount:1;h=s.utils.getSampleCount(h);const p=e.isRenderTargetTexture&&!e.isMultisampleRenderTargetTexture?1:h;let f=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;e.isStorageTexture===!0&&(f|=GPUTextureUsage.STORAGE_BINDING),e.isCompressedTexture!==!0&&e.isCompressedArrayTexture!==!0&&(f|=GPUTextureUsage.RENDER_ATTACHMENT);const g={label:e.name,size:{width:r,height:i,depthOrArrayLayers:u},mipLevelCount:a,sampleCount:p,dimension:l,format:d,usage:f};if(e.isVideoTexture){const m=e.source.data,y=new VideoFrame(m);g.size.width=y.displayWidth,g.size.height=y.displayHeight,y.close(),n.externalTexture=m}else{if(d===void 0)return console.warn("WebGPURenderer: Texture format not supported."),this.createDefaultTexture(e);n.texture=s.device.createTexture(g)}if(e.isRenderTargetTexture&&h>1&&!e.isMultisampleRenderTargetTexture){const m=Object.assign({},g);m.label=m.label+"-msaa",m.sampleCount=h,n.msaaTexture=s.device.createTexture(m)}n.initialized=!0,n.textureDescriptorGPU=g}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 n=0;n<s;n++)this._generateMipmaps(t.texture,t.textureDescriptorGPU,n)}}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:n,height:r}=s.getDrawingBufferSize(),i=this.depthTexture,u=s.get(i).texture;let a,l;if(t?(a=c.DepthStencilFormat,l=c.UnsignedInt248Type):e&&(a=c.DepthFormat,l=c.UnsignedIntType),u!==void 0){if(i.image.width===n&&i.image.height===r&&i.format===a&&i.type===l)return u;this.destroyTexture(i)}return i.name="depthBuffer",i.format=a,i.type=l,i.image.width=n,i.image.height=r,this.createTexture(i,{sampleCount:s.utils.getSampleCount(s.renderer.samples),width:n,height:r}),s.get(i).texture}updateTexture(e,t){const s=this.backend.get(e),{textureDescriptorGPU:n}=s;if(!(e.isRenderTargetTexture||n===void 0)){if(e.isDataTexture)this._copyBufferToTexture(t.image,s.texture,n,0,e.flipY);else if(e.isDataArrayTexture||e.isData3DTexture)for(let r=0;r<t.image.depth;r++)this._copyBufferToTexture(t.image,s.texture,n,r,e.flipY,r);else if(e.isCompressedTexture||e.isCompressedArrayTexture)this._copyCompressedBufferToTexture(e.mipmaps,s.texture,n);else if(e.isCubeTexture)this._copyCubeMapToTexture(t.images,s.texture,n,e.flipY);else if(e.isVideoTexture){const r=e.source.data;s.externalTexture=r}else this._copyImageToTexture(t.image,s.texture,n,0,e.flipY);s.version=e.version,e.onUpdate&&e.onUpdate(e)}}async copyTextureToBuffer(e,t,s,n,r,i){const u=this.backend.device,a=this.backend.get(e),l=a.texture,d=a.textureDescriptorGPU.format,h=this._getBytesPerTexel(d);let p=n*h;p=Math.ceil(p/256)*256;const f=u.createBuffer({size:n*r*h,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),g=u.createCommandEncoder();g.copyTextureToBuffer({texture:l,origin:{x:t,y:s,z:i}},{buffer:f,bytesPerRow:p},{width:n,height:r});const m=this._getTypedArrayType(d);u.queue.submit([g.finish()]),await f.mapAsync(GPUMapMode.READ);const y=f.getMappedRange();return new m(y)}_isEnvironmentTexture(e){const t=e.mapping;return t===c.EquirectangularReflectionMapping||t===c.EquirectangularRefractionMapping||t===c.CubeReflectionMapping||t===c.CubeRefractionMapping}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){const s=new c.Texture;s.minFilter=c.NearestFilter,s.magFilter=c.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 c.CubeTexture;s.minFilter=c.NearestFilter,s.magFilter=c.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,n){for(let r=0;r<6;r++){const i=e[r],u=n===!0?wg[r]:r;i.isDataTexture?this._copyBufferToTexture(i.image,t,s,u,n):this._copyImageToTexture(i,t,s,u,n)}}_copyImageToTexture(e,t,s,n,r){this.backend.device.queue.copyExternalImageToTexture({source:e},{texture:t,mipLevel:0,origin:{x:0,y:0,z:n}},{width:e.width,height:e.height,depthOrArrayLayers:1}),r===!0&&this._flipY(t,s,n)}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new Bg(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,n,r,i=0){const u=this.backend.device,a=e.data,l=this._getBytesPerTexel(s.format),d=e.width*l;u.queue.writeTexture({texture:t,mipLevel:0,origin:{x:0,y:0,z:n}},a,{offset:e.width*e.height*l*i,bytesPerRow:d},{width:e.width,height:e.height,depthOrArrayLayers:1}),r===!0&&this._flipY(t,s,n)}_copyCompressedBufferToTexture(e,t,s){const n=this.backend.device,r=this._getBlockData(s.format),i=s.size.depthOrArrayLayers>1;for(let u=0;u<e.length;u++){const a=e[u],l=a.width,d=a.height,h=i?s.size.depthOrArrayLayers:1,p=Math.ceil(l/r.width)*r.byteLength,f=p*Math.ceil(d/r.height);for(let g=0;g<h;g++)n.queue.writeTexture({texture:t,mipLevel:u,origin:{x:0,y:0,z:g}},a.data,{offset:g*f,bytesPerRow:p,rowsPerImage:Math.ceil(d/r.height)},{width:Math.ceil(l/r.width)*r.width,height:Math.ceil(d/r.height)*r.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=In.ClampToEdge;return e===c.RepeatWrapping?t=In.Repeat:e===c.MirroredRepeatWrapping&&(t=In.MirrorRepeat),t}_convertFilterMode(e){let t=ft.Linear;return(e===c.NearestFilter||e===c.NearestMipmapNearestFilter||e===c.NearestMipmapLinearFilter)&&(t=ft.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.isData3DTexture?t=Ji.ThreeD:t=Ji.TwoD,t}}function rr(o,e=null){const t=o.format,s=o.type,n=o.colorSpace;let r;if(o.isCompressedTexture===!0||o.isCompressedArrayTexture===!0)switch(t){case c.RGBA_S3TC_DXT1_Format:r=n===c.SRGBColorSpace?T.BC1RGBAUnormSRGB:T.BC1RGBAUnorm;break;case c.RGBA_S3TC_DXT3_Format:r=n===c.SRGBColorSpace?T.BC2RGBAUnormSRGB:T.BC2RGBAUnorm;break;case c.RGBA_S3TC_DXT5_Format:r=n===c.SRGBColorSpace?T.BC3RGBAUnormSRGB:T.BC3RGBAUnorm;break;case c.RGB_ETC2_Format:r=n===c.SRGBColorSpace?T.ETC2RGB8UnormSRGB:T.ETC2RGB8Unorm;break;case c.RGBA_ETC2_EAC_Format:r=n===c.SRGBColorSpace?T.ETC2RGBA8UnormSRGB:T.ETC2RGBA8Unorm;break;case c.RGBA_ASTC_4x4_Format:r=n===c.SRGBColorSpace?T.ASTC4x4UnormSRGB:T.ASTC4x4Unorm;break;case c.RGBA_ASTC_5x4_Format:r=n===c.SRGBColorSpace?T.ASTC5x4UnormSRGB:T.ASTC5x4Unorm;break;case c.RGBA_ASTC_5x5_Format:r=n===c.SRGBColorSpace?T.ASTC5x5UnormSRGB:T.ASTC5x5Unorm;break;case c.RGBA_ASTC_6x5_Format:r=n===c.SRGBColorSpace?T.ASTC6x5UnormSRGB:T.ASTC6x5Unorm;break;case c.RGBA_ASTC_6x6_Format:r=n===c.SRGBColorSpace?T.ASTC6x6UnormSRGB:T.ASTC6x6Unorm;break;case c.RGBA_ASTC_8x5_Format:r=n===c.SRGBColorSpace?T.ASTC8x5UnormSRGB:T.ASTC8x5Unorm;break;case c.RGBA_ASTC_8x6_Format:r=n===c.SRGBColorSpace?T.ASTC8x6UnormSRGB:T.ASTC8x6Unorm;break;case c.RGBA_ASTC_8x8_Format:r=n===c.SRGBColorSpace?T.ASTC8x8UnormSRGB:T.ASTC8x8Unorm;break;case c.RGBA_ASTC_10x5_Format:r=n===c.SRGBColorSpace?T.ASTC10x5UnormSRGB:T.ASTC10x5Unorm;break;case c.RGBA_ASTC_10x6_Format:r=n===c.SRGBColorSpace?T.ASTC10x6UnormSRGB:T.ASTC10x6Unorm;break;case c.RGBA_ASTC_10x8_Format:r=n===c.SRGBColorSpace?T.ASTC10x8UnormSRGB:T.ASTC10x8Unorm;break;case c.RGBA_ASTC_10x10_Format:r=n===c.SRGBColorSpace?T.ASTC10x10UnormSRGB:T.ASTC10x10Unorm;break;case c.RGBA_ASTC_12x10_Format:r=n===c.SRGBColorSpace?T.ASTC12x10UnormSRGB:T.ASTC12x10Unorm;break;case c.RGBA_ASTC_12x12_Format:r=n===c.SRGBColorSpace?T.ASTC12x12UnormSRGB:T.ASTC12x12Unorm;break;case c.RGBAFormat:r=n===c.SRGBColorSpace?T.RGBA8UnormSRGB:T.RGBA8Unorm;break;default:console.error("WebGPURenderer: Unsupported texture format.",t)}else switch(t){case c.RGBAFormat:switch(s){case c.ByteType:r=T.RGBA8Snorm;break;case c.ShortType:r=T.RGBA16Sint;break;case c.UnsignedShortType:r=T.RGBA16Uint;break;case c.UnsignedIntType:r=T.RGBA32Uint;break;case c.IntType:r=T.RGBA32Sint;break;case c.UnsignedByteType:r=n===c.SRGBColorSpace?T.RGBA8UnormSRGB:T.RGBA8Unorm;break;case c.HalfFloatType:r=T.RGBA16Float;break;case c.FloatType:r=T.RGBA32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBAFormat.",s)}break;case c.RGBFormat:switch(s){case c.UnsignedInt5999Type:r=T.RGB9E5UFloat;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBFormat.",s)}break;case c.RedFormat:switch(s){case c.ByteType:r=T.R8Snorm;break;case c.ShortType:r=T.R16Sint;break;case c.UnsignedShortType:r=T.R16Uint;break;case c.UnsignedIntType:r=T.R32Uint;break;case c.IntType:r=T.R32Sint;break;case c.UnsignedByteType:r=T.R8Unorm;break;case c.HalfFloatType:r=T.R16Float;break;case c.FloatType:r=T.R32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RedFormat.",s)}break;case c.RGFormat:switch(s){case c.ByteType:r=T.RG8Snorm;break;case c.ShortType:r=T.RG16Sint;break;case c.UnsignedShortType:r=T.RG16Uint;break;case c.UnsignedIntType:r=T.RG32Uint;break;case c.IntType:r=T.RG32Sint;break;case c.UnsignedByteType:r=T.RG8Unorm;break;case c.HalfFloatType:r=T.RG16Float;break;case c.FloatType:r=T.RG32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RGFormat.",s)}break;case c.DepthFormat:switch(s){case c.UnsignedShortType:r=T.Depth16Unorm;break;case c.UnsignedIntType:r=T.Depth24Plus;break;case c.FloatType:r=T.Depth32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with DepthFormat.",s)}break;case c.DepthStencilFormat:switch(s){case c.UnsignedInt248Type:r=T.Depth24PlusStencil8;break;case c.FloatType:e&&e.features.has(nr.Depth32FloatStencil8)===!1&&console.error('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),r=T.Depth32FloatStencil8;break;default:console.error("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",s)}break;case c.RedIntegerFormat:switch(s){case c.IntType:r=T.R32Sint;break;case c.UnsignedIntType:r=T.R32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",s)}break;case c.RGIntegerFormat:switch(s){case c.IntType:r=T.RG32Sint;break;case c.UnsignedIntType:r=T.RG32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",s)}break;case c.RGBAIntegerFormat:switch(s){case c.IntType:r=T.RGBA32Sint;break;case c.UnsignedIntType:r=T.RGBA32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",s)}break;default:console.error("WebGPURenderer: Unsupported texture format.",t)}return r}const Gg=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,Pg=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,eo={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_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"},Dg=o=>{o=o.trim();const e=o.match(Gg);if(e!==null&&e.length===4){const t=e[2],s=[];let n=null;for(;(n=Pg.exec(t))!==null;)s.push({name:n[1],type:n[2]});const r=[];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=eo[f]),r.push(new nn(f,h))}const i=o.substring(e[0].length),u=e[3]||"void",a=e[1]!==void 0?e[1]:"";return{type:eo[u]||u,inputs:r,name:a,inputsCode:t,blockCode:i,outputType:u}}else throw new Error("FunctionNode: Function is not a WGSL code.")};class Ig extends Wr{constructor(e){const{type:t,inputs:s,name:n,inputsCode:r,blockCode:i,outputType:u}=Dg(e);super(t,s,n),this.inputsCode=r,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 Lg extends Mu{parseFunction(e){return new Ig(e)}}const Ct=typeof self<"u"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},Og={[De.READ_ONLY]:"read",[De.WRITE_ONLY]:"write",[De.READ_WRITE]:"read_write"},to={[c.RepeatWrapping]:"repeat",[c.ClampToEdgeWrapping]:"clamp",[c.MirroredRepeatWrapping]:"mirror"},Es={vertex:Ct?Ct.VERTEX:1,fragment:Ct?Ct.FRAGMENT:2,compute:Ct?Ct.COMPUTE:4},so={instance:!0,swizzleAssign:!1,storageBuffer:!0},Vg={"^^":"tsl_xor"},kg={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>"},no={},ve={tsl_xor:new ae("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new ae("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new ae("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new ae("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new ae("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new ae("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new ae("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new ae("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 ae("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 ae("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new ae("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 ae("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new ae(`
220
+ fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
221
+
222
+ let res = vec2f( iRes );
223
+
224
+ let uvScaled = coord * res;
225
+ let uvWrapping = ( ( uvScaled % res ) + res ) % res;
226
+
227
+ // https://www.shadertoy.com/view/WtyXRy
228
+
229
+ let uv = uvWrapping - 0.5;
230
+ let iuv = floor( uv );
231
+ let f = fract( uv );
232
+
233
+ let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
234
+ let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
235
+ let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
236
+ let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
237
+
238
+ return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
239
+
240
+ }
241
+ `)},jt={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)&&(ve.pow_float=new ae("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),ve.pow_vec2=new ae("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 ) ); }",[ve.pow_float]),ve.pow_vec3=new ae("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 ) ); }",[ve.pow_float]),ve.pow_vec4=new ae("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 ) ); }",[ve.pow_float]),jt.pow_float="tsl_pow_float",jt.pow_vec2="tsl_pow_vec2",jt.pow_vec3="tsl_pow_vec3",jt.pow_vec4="tsl_pow_vec4");let Vu="";(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(Vu+=`diagnostic( off, derivative_uniformity );
242
+ `);class zg extends zr{constructor(e,t){super(e,t,new Lg),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==c.NoColorSpace}_generateTextureSample(e,t,s,n,r=this.shaderStage){return r==="fragment"?n?`textureSample( ${t}, ${t}_sampler, ${s}, ${n} )`:`textureSample( ${t}, ${t}_sampler, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,s):this.generateTextureLod(e,t,s,n,"0")}_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,n,r,i=this.shaderStage){return i==="fragment"&&this.isUnfilterable(e)===!1?`textureSampleLevel( ${t}, ${t}_sampler, ${s}, ${n} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,s,n):this.generateTextureLod(e,t,s,r,n)}generateWrapFunction(e){const t=`tsl_coord_${to[e.wrapS]}S_${to[e.wrapT]}T`;let s=no[t];if(s===void 0){const n=[];let r=`fn ${t}( coord : vec2f ) -> vec2f {
243
+
244
+ return vec2f(
245
+ `;const i=(u,a)=>{u===c.RepeatWrapping?(n.push(ve.repeatWrapping_float),r+=` tsl_repeatWrapping_float( coord.${a} )`):u===c.ClampToEdgeWrapping?(n.push(ve.clampWrapping_float),r+=` tsl_clampWrapping_float( coord.${a} )`):u===c.MirroredRepeatWrapping?(n.push(ve.mirrorWrapping_float),r+=` tsl_mirrorWrapping_float( coord.${a} )`):(r+=` coord.${a}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${u}" for vertex shader.`))};i(e.wrapS,"x"),r+=`,
246
+ `,i(e.wrapT,"y"),r+=`
247
+ );
248
+
249
+ }
250
+ `,no[t]=s=new ae(r,n)}return s.build(this),t}generateTextureDimension(e,t,s){const n=this.getDataFromNode(e,this.shaderStage,this.globalCache);n.dimensionsSnippet===void 0&&(n.dimensionsSnippet={});let r=n.dimensionsSnippet[s];if(n.dimensionsSnippet[s]===void 0){let i;e.isMultisampleRenderTargetTexture===!0?i=t:i=`${t}, u32( ${s} )`,r=new _r(new br(`textureDimensions( ${i} )`,"uvec2")),n.dimensionsSnippet[s]=r}return r.build(this)}generateFilteredTexture(e,t,s,n="0u"){this._include("biquadraticTexture");const r=this.generateWrapFunction(e),i=this.generateTextureDimension(e,t,n);return`tsl_biquadraticTexture( ${t}, ${r}( ${s} ), ${i}, u32( ${n} ) )`}generateTextureLod(e,t,s,n,r="0u"){const i=this.generateWrapFunction(e),u=this.generateTextureDimension(e,t,r),a=`vec2u( ${i}( ${s} ) * vec2f( ${u} ) )`;return this.generateTextureLoad(e,t,a,n,r)}generateTextureLoad(e,t,s,n,r="0u"){return e.isVideoTexture===!0||e.isStorageTexture===!0?`textureLoad( ${t}, ${s} )`:n?`textureLoad( ${t}, ${s}, ${n}, u32( ${r} ) )`:`textureLoad( ${t}, ${s}, u32( ${r} ) )`}generateTextureStore(e,t,s,n){return`textureStore( ${t}, ${s}, ${n} )`}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.isDataTexture===!0&&e.type===c.FloatType||this.isSampleCompare(e)===!1&&e.minFilter===c.NearestFilter&&e.magFilter===c.NearestFilter||e.isMultisampleRenderTargetTexture===!0}generateTexture(e,t,s,n,r=this.shaderStage){let i=null;return e.isVideoTexture===!0?i=this._generateVideoSample(t,s,r):this.isUnfilterable(e)?i=this.generateTextureLod(e,t,s,n,"0",r):i=this._generateTextureSample(e,t,s,n,r),i}generateTextureGrad(e,t,s,n,r,i=this.shaderStage){if(i==="fragment")return`textureSampleGrad( ${t}, ${t}_sampler, ${s}, ${n[0]}, ${n[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${i} shader.`)}generateTextureCompare(e,t,s,n,r,i=this.shaderStage){if(i==="fragment")return`textureSampleCompare( ${t}, ${t}_sampler, ${s}, ${n} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${i} shader.`)}generateTextureLevel(e,t,s,n,r,i=this.shaderStage){let u=null;return e.isVideoTexture===!0?u=this._generateVideoSample(t,s,i):u=this._generateTextureSampleLevel(e,t,s,n,r,i),u}generateTextureBias(e,t,s,n,r,i=this.shaderStage){if(i==="fragment")return`textureSampleBias( ${t}, ${t}_sampler, ${s}, ${n} )`;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,n=e.type;return n==="texture"||n==="cubeTexture"||n==="storageTexture"||n==="texture3D"?s:n==="buffer"||n==="storageBuffer"||n==="indirectStorageBuffer"?`NodeBuffer_${e.id}.${s}`:e.groupNode.name+"."+s}return super.getPropertyName(e)}getOutputStructName(){return"output"}_getUniformGroupCount(e){return Object.keys(this.uniforms[e]).length}getFunctionOperator(e){const t=Vg[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?De.READ_ONLY:e.access}getStorageAccess(e,t){return Og[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,s,n=null){const r=super.getUniformFromNode(e,t,s,n),i=this.getDataFromNode(e,s,this.globalCache);if(i.uniformGPU===void 0){let u;const a=e.groupNode,l=a.name,d=this.getBindGroupArray(l,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 rn(r.name,r.node,a,p):t==="cubeTexture"?h=new Iu(r.name,r.node,a,p):t==="texture3D"&&(h=new Lu(r.name,r.node,a,p)),h.store=e.isStorageTextureNode===!0,h.setVisibility(Es[s]),s==="fragment"&&this.isUnfilterable(e.value)===!1&&h.store===!1){const f=new Cg(`${r.name}_sampler`,r.node,a);f.setVisibility(Es[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"?Pu:Mg,p=new h(e,a);p.setVisibility(Es[s]),d.push(p),u=p}else{const h=this.uniformGroups[s]||(this.uniformGroups[s]={});let p=h[l];p===void 0&&(p=new Du(l,a),p.setVisibility(Es[s]),h[l]=p,d.push(p)),u=this.getNodeUniform(r,t),p.addUniform(u)}i.uniformGPU=u}return r}getBuiltin(e,t,s,n=this.shaderStage){const r=this.builtins[n]||(this.builtins[n]=new Map);return r.has(e)===!1&&r.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),n=[];for(const i of t.inputs)n.push(i.name+" : "+this.getType(i.type));let r=`fn ${t.name}( ${n.join(", ")} ) -> ${this.getType(t.type)} {
251
+ ${s.vars}
252
+ ${s.code}
253
+ `;return s.result&&(r+=` return ${s.result};
254
+ `),r+=`
255
+ }
256
+ `,r}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 n of s)t.push(`enable ${n};`);return t.join(`
257
+ `)}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:n,property:r,type:i}of s.values())t.push(`@builtin( ${n} ) ${r} : ${i}`);return t.join(`,
258
+ `)}getScopedArray(e,t,s,n){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:s,bufferCount:n}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:s,scope:n,bufferType:r,bufferCount:i}of this.scopedArrays.values()){const u=this.getType(r);t.push(`var<${n}> ${s}: array< ${u}, ${i} >;`)}return t.join(`
259
+ `)}getAttributes(e){const t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","id","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 n=this.getAttributesArray();for(let r=0,i=n.length;r<i;r++){const u=n[r],a=u.name,l=this.getType(u.type);t.push(`@location( ${r} ) ${a} : ${l}`)}}return t.join(`,
260
+ `)}getStructMembers(e){const t=[],s=e.getMemberTypes();for(let r=0;r<s.length;r++){const i=s[r];t.push(` @location( ${r} ) m${r} : ${i}<f32>`)}const n=this.getBuiltins("output");return n&&t.push(" "+n),t.join(`,
261
+ `)}getStructs(e){const t=[],s=this.structs[e];for(let n=0,r=s.length;n<r;n++){const i=s[n],u=i.name;let a=`struct ${u} {
262
+ `;a+=this.getStructMembers(i),a+=`
263
+ }`,t.push(a),t.push(`
264
+ var<private> output : ${u};
265
+
266
+ `)}return t.join(`
267
+
268
+ `)}getVar(e,t){return`var ${t} : ${this.getType(e)}`}getVars(e){const t=[],s=this.vars[e];if(s!==void 0)for(const n of s)t.push(` ${this.getVar(n.type,n.name)};`);return`
269
+ ${t.join(`
270
+ `)}
271
+ `}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","Vertex","vec4<f32>","vertex"),e==="vertex"||e==="fragment"){const r=this.varyings,i=this.vars[e];for(let u=0;u<r.length;u++){const a=r[u];if(a.needsInterpolation){let l=`@location( ${u} )`;/^(int|uint|ivec|uvec)/.test(a.type)&&(l+=" @interpolate( flat )"),t.push(`${l} ${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 n=t.join(`,
272
+ `);return e==="vertex"?this._getWGSLStruct("VaryingsStruct"," "+n):n}getUniforms(e){const t=this.uniforms[e],s=[],n=[],r=[],i={};for(const a of t){const l=a.groupNode.name,d=this.bindingsIndexes[l];if(a.type==="texture"||a.type==="cubeTexture"||a.type==="storageTexture"||a.type==="texture3D"){const h=a.node.value;e==="fragment"&&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="";if(h.isMultisampleRenderTargetTexture===!0&&(f="_multisampled"),h.isCubeTexture===!0)p="texture_cube<f32>";else if(h.isDataArrayTexture===!0||h.isCompressedArrayTexture===!0)p="texture_2d_array<f32>";else if(h.isDepthTexture===!0)p=`texture_depth${f}_2d`;else if(h.isVideoTexture===!0)p="texture_external";else if(h.isData3DTexture===!0)p="texture_3d<f32>";else if(a.node.isStorageTextureNode===!0){const g=rr(h),m=this.getStorageAccess(a.node,e);p=`texture_storage_2d<${g}, ${m}>`}else{const g=this.getComponentTypeFromTexture(h).charAt(0);p=`texture${f}_2d<${g}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.bufferType),f=h.bufferCount,g=f>0&&a.type==="buffer"?", "+f:"",m=h.isAtomic?`atomic<${p}>`:`${p}`,y=` ${a.name} : array< ${m}${g} >
273
+ `,S=h.isStorageBufferNode?`storage, ${this.getStorageAccess(h,e)}`:"uniform";n.push(this._getWGSLStructBinding("NodeBuffer_"+h.id,y,S,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 l=i[a];r.push(this._getWGSLStructBinding(a,l.snippets.join(`,
274
+ `),"uniform",l.index,l.id))}let u=s.join(`
275
+ `);return u+=n.join(`
276
+ `),u+=r.join(`
277
+ `),u}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){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 n=`// code
278
+
279
+ `;n+=this.flowCode[t];const r=this.flowNodes[t],i=r[r.length-1],u=i.outputNode,a=u!==void 0&&u.isOutputStructNode===!0;for(const l of r){const d=this.getFlowData(l),h=l.name;if(h&&(n.length>0&&(n+=`
280
+ `),n+=` // flow -> ${h}
281
+ `),n+=`${d.code}
282
+ `,l===i&&t!=="compute"){if(n+=`// result
283
+
284
+ `,t==="vertex")n+=`varyings.Vertex = ${d.result};`;else if(t==="fragment")if(a)s.returnType=u.nodeType,n+=`return ${d.result};`;else{let p=" @location(0) color: vec4<f32>";const f=this.getBuiltins("output");f&&(p+=`,
285
+ `+f),s.returnType="OutputStruct",s.structs+=this._getWGSLStruct("OutputStruct",p),s.structs+=`
286
+ var<private> output : OutputStruct;
287
+
288
+ `,n+=`output.color = ${d.result};
289
+
290
+ return output;`}}}s.flow=n}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 kg[e]||e}isAvailable(e){let t=so[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),so[e]=t),t}_getWGSLMethod(e){return ve[e]!==void 0&&this._include(e),jt[e]}_include(e){const t=ve[e];return t.build(this),this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}
291
+ // directives
292
+ ${e.directives}
293
+
294
+ // uniforms
295
+ ${e.uniforms}
296
+
297
+ // varyings
298
+ ${e.varyings}
299
+ var<private> varyings : VaryingsStruct;
300
+
301
+ // codes
302
+ ${e.codes}
303
+
304
+ @vertex
305
+ fn main( ${e.attributes} ) -> VaryingsStruct {
306
+
307
+ // vars
308
+ ${e.vars}
309
+
310
+ // flow
311
+ ${e.flow}
312
+
313
+ return varyings;
314
+
315
+ }
316
+ `}_getWGSLFragmentCode(e){return`${this.getSignature()}
317
+ // global
318
+ ${Vu}
319
+
320
+ // uniforms
321
+ ${e.uniforms}
322
+
323
+ // structs
324
+ ${e.structs}
325
+
326
+ // codes
327
+ ${e.codes}
328
+
329
+ @fragment
330
+ fn main( ${e.varyings} ) -> ${e.returnType} {
331
+
332
+ // vars
333
+ ${e.vars}
334
+
335
+ // flow
336
+ ${e.flow}
337
+
338
+ }
339
+ `}_getWGSLComputeCode(e,t){return`${this.getSignature()}
340
+ // directives
341
+ ${e.directives}
342
+
343
+ // system
344
+ var<private> instanceIndex : u32;
345
+
346
+ // locals
347
+ ${e.scopedArrays}
348
+
349
+ // uniforms
350
+ ${e.uniforms}
351
+
352
+ // codes
353
+ ${e.codes}
354
+
355
+ @compute @workgroup_size( ${t} )
356
+ fn main( ${e.attributes} ) {
357
+
358
+ // system
359
+ instanceIndex = id.x + id.y * numWorkgroups.x * u32(${t}) + id.z * numWorkgroups.x * numWorkgroups.y * u32(${t});
360
+
361
+ // vars
362
+ ${e.vars}
363
+
364
+ // flow
365
+ ${e.flow}
366
+
367
+ }
368
+ `}_getWGSLStruct(e,t){return`
369
+ struct ${e} {
370
+ ${t}
371
+ };`}_getWGSLStructBinding(e,t,s,n=0,r=0){const i=e+"Struct";return`${this._getWGSLStruct(i,t)}
372
+ @binding( ${n} ) @group( ${r} )
373
+ var<${s}> ${e} : ${i};`}}class $g{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}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 Bt.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return Bt.LineList;if(e.isLine)return Bt.LineStrip;if(e.isMesh)return Bt.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(){return navigator.userAgent.includes("Quest")?T.BGRA8Unorm:navigator.gpu.getPreferredCanvasFormat()}}const Wg=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),Hg=new Map([[c.Float16BufferAttribute,["float16"]]]),qg=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class Kg{constructor(e){this.backend=e}createAttribute(e,t){const s=this._getBufferAttribute(e),n=this.backend,r=n.get(s);let i=r.buffer;if(i===void 0){const u=n.device;let a=s.array;if(e.normalized===!1&&(a.constructor===Int16Array||a.constructor===Uint16Array)){const d=new Uint32Array(a.length);for(let h=0;h<a.length;h++)d[h]=a[h];a=d}if(s.array=a,(s.isStorageBufferAttribute||s.isStorageInstancedBufferAttribute)&&s.itemSize===3){a=new a.constructor(s.count*4);for(let d=0;d<s.count;d++)a.set(s.array.subarray(d*3,d*3+3),d*4);s.itemSize=4,s.array=a}const l=a.byteLength+(4-a.byteLength%4)%4;i=u.createBuffer({label:s.name,size:l,usage:t,mappedAtCreation:!0}),new a.constructor(i.getMappedRange()).set(a),i.unmap(),r.buffer=i}}updateAttribute(e){const t=this._getBufferAttribute(e),s=this.backend,n=s.device,r=s.get(t).buffer,i=t.array,u=this._isTypedArray(i),a=t.updateRanges;if(a.length===0)n.queue.writeBuffer(r,0,i,0);else{const l=u?1:i.BYTES_PER_ELEMENT;for(let d=0,h=a.length;d<h;d++){const p=a[d],f=p.start*l,g=p.count*l;n.queue.writeBuffer(r,0,i,f,g)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){const t=e.getAttributes(),s=new Map;for(let n=0;n<t.length;n++){const r=t[n],i=r.array.BYTES_PER_ELEMENT,u=this._getBufferAttribute(r);let a=s.get(u);if(a===void 0){let h,p;r.isInterleavedBufferAttribute===!0?(h=r.data.stride*i,p=r.data.isInstancedInterleavedBuffer?vs.Instance:vs.Vertex):(h=r.itemSize*i,p=r.isInstancedBufferAttribute?vs.Instance:vs.Vertex),r.normalized===!1&&(r.array.constructor===Int16Array||r.array.constructor===Uint16Array)&&(h=4),a={arrayStride:h,attributes:[],stepMode:p},s.set(u,a)}const l=this._getVertexFormat(r),d=r.isInterleavedBufferAttribute===!0?r.offset*i:0;a.attributes.push({shaderLocation:n,offset:d,format:l})}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,r=t.get(this._getBufferAttribute(e)).buffer,i=r.size,u=s.createBuffer({label:e.name,size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=s.createCommandEncoder({});a.copyBufferToBuffer(r,0,u,0,i),u.unmap();const l=a.finish();return s.queue.submit([l]),await u.mapAsync(GPUMapMode.READ),u.getMappedRange()}_getVertexFormat(e){const{itemSize:t,normalized:s}=e,n=e.array.constructor,r=e.constructor;let i;if(t==1)i=qg.get(n);else{const a=(Hg.get(r)||Wg.get(n))[s?1:0];if(a){const l=n.BYTES_PER_ELEMENT*t,h=Math.floor((l+3)/4)*4/n.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 Xg{constructor(e){this.backend=e,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(e){const s=this.backend.device,n=[];let r=0;for(const i of e.bindings){const u={binding:r++,visibility:i.visibility};if(i.isUniformBuffer||i.isStorageBuffer){const a={};i.isStorageBuffer&&(i.visibility&4&&(i.access===De.READ_WRITE||i.access===De.WRITE_ONLY)?a.type=Ln.Storage:a.type=Ln.ReadOnlyStorage),u.buffer=a}else if(i.isSampler){const a={};i.texture.isDepthTexture&&i.texture.compareFunction!==null&&(a.type="comparison"),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 l=i.access;l===De.READ_WRITE?a.access=On.ReadWrite:l===De.WRITE_ONLY?a.access=On.WriteOnly:a.access=On.ReadOnly,u.storageTexture=a}else if(i.isSampledTexture){const a={};if(i.texture.isMultisampleRenderTargetTexture===!0&&(a.multisampled=!0),i.texture.isDepthTexture)a.sampleType=Xt.Depth;else if(i.texture.isDataTexture||i.texture.isDataArrayTexture||i.texture.isData3DTexture){const l=i.texture.type;l===c.IntType?a.sampleType=Xt.SInt:l===c.UnsignedIntType?a.sampleType=Xt.UInt:l===c.FloatType&&(this.backend.hasFeature("float32-filterable")?a.sampleType=Xt.Float:a.sampleType=Xt.UnfilterableFloat)}i.isSampledCubeTexture?a.viewDimension=Ce.Cube:i.texture.isDataArrayTexture||i.texture.isCompressedArrayTexture?a.viewDimension=Ce.TwoDArray:i.isSampledTexture3D&&(a.viewDimension=Ce.ThreeD),u.texture=a}else console.error(`WebGPUBindingUtils: Unsupported binding "${i}".`);n.push(u)}return s.createBindGroupLayout({entries:n})}createBindings(e,t,s,n=0){const{backend:r,bindGroupLayoutCache:i}=this,u=r.get(e);let a=i.get(e.bindingsReference);a===void 0&&(a=this.createBindingsLayout(e),i.set(e.bindingsReference,a));let l;s>0&&(u.groups===void 0&&(u.groups=[],u.versions=[]),u.versions[s]===n&&(l=u.groups[s])),l===void 0&&(l=this.createBindGroup(e,a),s>0&&(u.groups[s]=l,u.versions[s]=n)),u.group=l,u.layout=a}updateBinding(e){const t=this.backend,s=t.device,n=e.buffer,r=t.get(e).buffer;s.queue.writeBuffer(r,0,n,0)}createBindGroup(e,t){const s=this.backend,n=s.device;let r=0;const i=[];for(const u of e.bindings){if(u.isUniformBuffer){const a=s.get(u);if(a.buffer===void 0){const l=u.byteLength,d=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,h=n.createBuffer({label:"bindingBuffer_"+u.name,size:l,usage:d});a.buffer=h}i.push({binding:r,resource:{buffer:a.buffer}})}else if(u.isStorageBuffer){const a=s.get(u);if(a.buffer===void 0){const l=u.attribute;a.buffer=s.get(l).buffer}i.push({binding:r,resource:{buffer:a.buffer}})}else if(u.isSampler){const a=s.get(u.texture);i.push({binding:r,resource:a.sampler})}else if(u.isSampledTexture){const a=s.get(u.texture);let l;if(a.externalTexture!==void 0)l=n.importExternalTexture({source:a.externalTexture});else{const d=u.store?1:a.texture.mipLevelCount,h=`view-${a.texture.width}-${a.texture.height}-${d}`;if(l=a[h],l===void 0){const p=Rg.All;let f;u.isSampledCubeTexture?f=Ce.Cube:u.isSampledTexture3D?f=Ce.ThreeD:u.texture.isDataArrayTexture||u.texture.isCompressedArrayTexture?f=Ce.TwoDArray:f=Ce.TwoD,l=a[h]=a.texture.createView({aspect:p,dimension:f,mipLevelCount:d})}}i.push({binding:r,resource:l})}r++}return n.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:i})}}class Yg{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:s,material:n,geometry:r,pipeline:i}=e,{vertexProgram:u,fragmentProgram:a}=i,l=this.backend,d=l.device,h=l.utils,p=l.get(i),f=[];for(const be of e.getBindings()){const ze=l.get(be);f.push(ze.layout)}const g=l.attributeUtils.createShaderVertexBuffers(e);let m;n.transparent===!0&&n.blending!==c.NoBlending&&(m=this._getBlending(n));let y={};n.stencilWrite===!0&&(y={compare:this._getStencilCompare(n),failOp:this._getStencilOperation(n.stencilFail),depthFailOp:this._getStencilOperation(n.stencilZFail),passOp:this._getStencilOperation(n.stencilZPass)});const S=this._getColorWriteMask(n),A=[];if(e.context.textures!==null){const be=e.context.textures;for(let ze=0;ze<be.length;ze++){const Nt=h.getTextureFormatGPU(be[ze]);A.push({format:Nt,blend:m,writeMask:S})}}else{const be=h.getCurrentColorFormat(e.context);A.push({format:be,blend:m,writeMask:S})}const E=l.get(u).module,D=l.get(a).module,w=this._getPrimitiveState(s,r,n),U=this._getDepthCompare(n),G=h.getCurrentDepthStencilFormat(e.context),P=this._getSampleCount(e.context),Q={label:`renderPipeline_${n.name||n.type}_${n.id}`,vertex:Object.assign({},E,{buffers:g}),fragment:Object.assign({},D,{targets:A}),primitive:w,multisample:{count:P,alphaToCoverageEnabled:n.alphaToCoverage&&P>1},layout:d.createPipelineLayout({bindGroupLayouts:f})},se={},X=e.context.depth,xe=e.context.stencil;if((X===!0||xe===!0)&&(X===!0&&(se.format=G,se.depthWriteEnabled=n.depthWrite,se.depthCompare=U),xe===!0&&(se.stencilFront=y,se.stencilBack={},se.stencilReadMask=n.stencilFuncMask,se.stencilWriteMask=n.stencilWriteMask),Q.depthStencil=se),t===null)p.pipeline=d.createRenderPipeline(Q);else{const be=new Promise(ze=>{d.createRenderPipelineAsync(Q).then(Nt=>{p.pipeline=Nt,ze()})});t.push(be)}}createBundleEncoder(e){const t=this.backend,{utils:s,device:n}=t,r=s.getCurrentDepthStencilFormat(e),i=s.getCurrentColorFormat(e),u=this._getSampleCount(e),a={label:"renderBundleEncoder",colorFormats:[i],depthStencilFormat:r,sampleCount:u};return n.createRenderBundleEncoder(a)}createComputePipeline(e,t){const s=this.backend,n=s.device,r=s.get(e.computeProgram).module,i=s.get(e),u=[];for(const a of t){const l=s.get(a);u.push(l.layout)}i.pipeline=n.createComputePipeline({compute:r,layout:n.createPipelineLayout({bindGroupLayouts:u})})}_getBlending(e){let t,s;const n=e.blending,r=e.blendSrc,i=e.blendDst,u=e.blendEquation;if(n===c.CustomBlending){const a=e.blendSrcAlpha!==null?e.blendSrcAlpha:r,l=e.blendDstAlpha!==null?e.blendDstAlpha:i,d=e.blendEquationAlpha!==null?e.blendEquationAlpha:u;t={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(i),operation:this._getBlendOperation(u)},s={srcFactor:this._getBlendFactor(a),dstFactor:this._getBlendFactor(l),operation:this._getBlendOperation(d)}}else{const a=e.premultipliedAlpha,l=(d,h,p,f)=>{t={srcFactor:d,dstFactor:h,operation:ut.Add},s={srcFactor:p,dstFactor:f,operation:ut.Add}};if(a)switch(n){case c.NormalBlending:l(I.One,I.OneMinusSrcAlpha,I.One,I.OneMinusSrcAlpha);break;case c.AdditiveBlending:l(I.One,I.One,I.One,I.One);break;case c.SubtractiveBlending:l(I.Zero,I.OneMinusSrc,I.Zero,I.One);break;case c.MultiplyBlending:l(I.Zero,I.Src,I.Zero,I.SrcAlpha);break}else switch(n){case c.NormalBlending:l(I.SrcAlpha,I.OneMinusSrcAlpha,I.One,I.OneMinusSrcAlpha);break;case c.AdditiveBlending:l(I.SrcAlpha,I.One,I.SrcAlpha,I.One);break;case c.SubtractiveBlending:l(I.Zero,I.OneMinusSrc,I.Zero,I.One);break;case c.MultiplyBlending:l(I.Zero,I.Src,I.Zero,I.Src);break}}if(t!==void 0&&s!==void 0)return{color:t,alpha:s};console.error("THREE.WebGPURenderer: Invalid blending: ",n)}_getBlendFactor(e){let t;switch(e){case c.ZeroFactor:t=I.Zero;break;case c.OneFactor:t=I.One;break;case c.SrcColorFactor:t=I.Src;break;case c.OneMinusSrcColorFactor:t=I.OneMinusSrc;break;case c.SrcAlphaFactor:t=I.SrcAlpha;break;case c.OneMinusSrcAlphaFactor:t=I.OneMinusSrcAlpha;break;case c.DstColorFactor:t=I.Dst;break;case c.OneMinusDstColorFactor:t=I.OneMinusDstColor;break;case c.DstAlphaFactor:t=I.DstAlpha;break;case c.OneMinusDstAlphaFactor:t=I.OneMinusDstAlpha;break;case c.SrcAlphaSaturateFactor:t=I.SrcAlphaSaturated;break;case Tp:t=I.Constant;break;case yp:t=I.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 c.NeverStencilFunc:t=he.Never;break;case c.AlwaysStencilFunc:t=he.Always;break;case c.LessStencilFunc:t=he.Less;break;case c.LessEqualStencilFunc:t=he.LessEqual;break;case c.EqualStencilFunc:t=he.Equal;break;case c.GreaterEqualStencilFunc:t=he.GreaterEqual;break;case c.GreaterStencilFunc:t=he.Greater;break;case c.NotEqualStencilFunc:t=he.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",s)}return t}_getStencilOperation(e){let t;switch(e){case c.KeepStencilOp:t=Je.Keep;break;case c.ZeroStencilOp:t=Je.Zero;break;case c.ReplaceStencilOp:t=Je.Replace;break;case c.InvertStencilOp:t=Je.Invert;break;case c.IncrementStencilOp:t=Je.IncrementClamp;break;case c.DecrementStencilOp:t=Je.DecrementClamp;break;case c.IncrementWrapStencilOp:t=Je.IncrementWrap;break;case c.DecrementWrapStencilOp:t=Je.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case c.AddEquation:t=ut.Add;break;case c.SubtractEquation:t=ut.Subtract;break;case c.ReverseSubtractEquation:t=ut.ReverseSubtract;break;case c.MinEquation:t=ut.Min;break;case c.MaxEquation:t=ut.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,s){const n={},r=this.backend.utils;switch(n.topology=r.getPrimitiveTopology(e,s),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(n.stripIndexFormat=t.index.array instanceof Uint16Array?Dt.Uint16:Dt.Uint32),s.side){case c.FrontSide:n.frontFace=Pn.CCW,n.cullMode=Dn.Back;break;case c.BackSide:n.frontFace=Pn.CCW,n.cullMode=Dn.Front;break;case c.DoubleSide:n.frontFace=Pn.CCW,n.cullMode=Dn.None;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",s.side);break}return n}_getColorWriteMask(e){return e.colorWrite===!0?Zi.All:Zi.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=he.Always;else{const s=e.depthFunc;switch(s){case c.NeverDepth:t=he.Never;break;case c.AlwaysDepth:t=he.Always;break;case c.LessDepth:t=he.Less;break;case c.LessEqualDepth:t=he.LessEqual;break;case c.EqualDepth:t=he.Equal;break;case c.GreaterEqualDepth:t=he.GreaterEqual;break;case c.GreaterDepth:t=he.Greater;break;case c.NotEqualDepth:t=he.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",s)}}return t}}class Qg extends Ou{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.trackTimestamp=e.trackTimestamp===!0,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new $g(this),this.attributeUtils=new Kg(this),this.bindingUtils=new Xg(this),this.pipelineUtils=new Yg(this),this.textureUtils=new Ug(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},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(nr),l=[];for(const h of a)u.features.has(h)&&l.push(h);const d={requiredFeatures:l,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 n=t.context!==void 0?t.context:e.domElement.getContext("webgpu");this.device=s,this.context=n;const r=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(nr.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:r}),this.updateSize()}get coordinateSystem(){return c.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 n=e.colorAttachments[0];this.renderer.samples>0?n.view=this.colorBuffer.createView():n.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}_getRenderPassDescriptor(e){const t=e.renderTarget,s=this.get(t);let n=s.descriptors;if(n===void 0||s.width!==t.width||s.height!==t.height||s.activeMipmapLevel!==t.activeMipmapLevel||s.samples!==t.samples){n={},s.descriptors=n;const u=()=>{t.removeEventListener("dispose",u),this.delete(t)};t.addEventListener("dispose",u)}const r=e.getCacheKey();let i=n[r];if(i===void 0){const u=e.textures,a=[];for(let l=0;l<u.length;l++){const d=this.get(u[l]),h=d.texture.createView({baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,dimension:Ce.TwoD});let p,f;d.msaaTexture!==void 0?(p=d.msaaTexture.createView(),f=h):(p=h,f=void 0),a.push({view:p,resolveTarget:f,loadOp:oe.Load,storeOp:pe.Store})}if(i={colorAttachments:a},e.depth){const d={view:this.get(e.depthTexture).texture.createView()};i.depthStencilAttachment=d}n[r]=i,s.width=t.width,s.height=t.height,s.samples=t.samples,s.activeMipmapLevel=t.activeMipmapLevel}return i}beginRender(e){const t=this.get(e),s=this.device,n=e.occlusionQueryCount;let r;n>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,r=s.createQuerySet({type:"occlusion",count:n,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=r,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(n),t.lastOcclusionObject=null);let i;e.textures===null?i=this._getDefaultRenderPassDescriptor():i=this._getRenderPassDescriptor(e),this.initTimestampQuery(e,i),i.occlusionQuerySet=r;const u=i.depthStencilAttachment;if(e.textures!==null){const d=i.colorAttachments;for(let h=0;h<d.length;h++){const p=d[h];e.clearColor?(p.clearValue=h===0?e.clearColorValue:{r:0,g:0,b:0,a:1},p.loadOp=oe.Clear,p.storeOp=pe.Store):(p.loadOp=oe.Load,p.storeOp=pe.Store)}}else{const d=i.colorAttachments[0];e.clearColor?(d.clearValue=e.clearColorValue,d.loadOp=oe.Clear,d.storeOp=pe.Store):(d.loadOp=oe.Load,d.storeOp=pe.Store)}e.depth&&(e.clearDepth?(u.depthClearValue=e.clearDepthValue,u.depthLoadOp=oe.Clear,u.depthStoreOp=pe.Store):(u.depthLoadOp=oe.Load,u.depthStoreOp=pe.Store)),e.stencil&&(e.clearStencil?(u.stencilClearValue=e.clearStencilValue,u.stencilLoadOp=oe.Clear,u.stencilStoreOp=pe.Store):(u.stencilLoadOp=oe.Load,u.stencilStoreOp=pe.Store));const a=s.createCommandEncoder({label:"renderContext_"+e.id}),l=a.beginRenderPass(i);if(t.descriptor=i,t.encoder=a,t.currentPass=l,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[],e.viewport&&this.updateViewport(e),e.scissor){const{x:d,y:h,width:p,height:f}=e.scissorValue;l.setScissorRect(d,h,p,f)}}finishRender(e){const t=this.get(e),s=e.occlusionQueryCount;if(t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),s>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery(),t.currentPass.end(),s>0){const n=s*8;let r=this.occludedResolveCache.get(n);r===void 0&&(r=this.device.createBuffer({size:n,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(n,r));const i=this.device.createBuffer({size:n,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,s,r,0),t.encoder.copyBufferToBuffer(r,0,i,0,n),t.occlusionQueryBuffer=i,this.resolveOccludedAsync(e)}if(this.prepareTimestampBuffer(e,t.encoder),this.device.queue.submit([t.encoder.finish()]),e.textures!==null){const n=e.textures;for(let r=0;r<n.length;r++){const i=n[r];i.generateMipmaps===!0&&this.textureUtils.generateMipmaps(i)}}}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:n}=t;if(s&&n){const r=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<n.length;a++)u[a]!==BigInt(0)&&r.add(n[a]);s.destroy(),t.occluded=r}}updateViewport(e){const{currentPass:t}=this.get(e),{x:s,y:n,width:r,height:i,minDepth:u,maxDepth:a}=e.viewportValue;t.setViewport(s,n,r,i,u,a)}clear(e,t,s,n=null){const r=this.device,i=this.renderer;let u=[],a,l,d,h;if(e){const g=this.getClearColor();if(this.renderer.alpha===!0){const m=g.a;l={r:g.r*m,g:g.g*m,b:g.b*m,a:m}}else l={r:g.r,g:g.g,b:g.b,a:g.a}}if(n===null){d=i.depth,h=i.stencil;const g=this._getDefaultRenderPassDescriptor();if(e){u=g.colorAttachments;const m=u[0];m.clearValue=l,m.loadOp=oe.Clear,m.storeOp=pe.Store}(d||h)&&(a=g.depthStencilAttachment)}else{if(d=n.depth,h=n.stencil,e)for(const g of n.textures){const m=this.get(g),y=m.texture.createView();let S,A;m.msaaTexture!==void 0?(S=m.msaaTexture.createView(),A=y):(S=y,A=void 0),u.push({view:S,resolveTarget:A,clearValue:l,loadOp:oe.Clear,storeOp:pe.Store})}(d||h)&&(a={view:this.get(n.depthTexture).texture.createView()})}d&&(t?(a.depthLoadOp=oe.Clear,a.depthClearValue=i.getClearDepth(),a.depthStoreOp=pe.Store):(a.depthLoadOp=oe.Load,a.depthStoreOp=pe.Store)),h&&(s?(a.stencilLoadOp=oe.Clear,a.stencilClearValue=i.getClearStencil(),a.stencilStoreOp=pe.Store):(a.stencilLoadOp=oe.Load,a.stencilStoreOp=pe.Store));const p=r.createCommandEncoder({});p.beginRenderPass({colorAttachments:u,depthStencilAttachment:a}).end(),r.queue.submit([p.finish()])}beginCompute(e){const t=this.get(e),s={};this.initTimestampQuery(e,s),t.cmdEncoderGPU=this.device.createCommandEncoder(),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(s)}compute(e,t,s,n){const{passEncoderGPU:r}=this.get(e),i=this.get(n).pipeline;r.setPipeline(i);for(let d=0,h=s.length;d<h;d++){const p=s[d],f=this.get(p);r.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:l}=a;t.dispatchCount>u?(l.x=Math.min(t.dispatchCount,u),l.y=Math.ceil(t.dispatchCount/u)):l.x=t.dispatchCount,r.dispatchWorkgroups(l.x,l.y,l.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.prepareTimestampBuffer(e,t.cmdEncoderGPU),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:s,context:n,pipeline:r}=e,i=e.getBindings(),u=this.get(n),a=this.get(r).pipeline,l=u.currentSets,d=u.currentPass,h=e.getDrawParameters();if(h===null)return;l.pipeline!==a&&(d.setPipeline(a),l.pipeline=a);const p=l.bindingGroups;for(let y=0,S=i.length;y<S;y++){const A=i[y],E=this.get(A);p[A.index]!==A.id&&(d.setBindGroup(A.index,E.group),p[A.index]=A.id)}const f=e.getIndex(),g=f!==null;if(g===!0&&l.index!==f){const y=this.get(f).buffer,S=f.array instanceof Uint16Array?Dt.Uint16:Dt.Uint32;d.setIndexBuffer(y,S),l.index=f}const m=e.getVertexBuffers();for(let y=0,S=m.length;y<S;y++){const A=m[y];if(l.attributes[y]!==A){const E=this.get(A).buffer;d.setVertexBuffer(y,E),l.attributes[y]=A}}if(u.occlusionQuerySet!==void 0){const y=u.lastOcclusionObject;y!==s&&(y!==null&&y.occlusionTest===!0&&(d.endOcclusionQuery(),u.occlusionQueryIndex++),s.occlusionTest===!0&&(d.beginOcclusionQuery(u.occlusionQueryIndex),u.occlusionQueryObjects[u.occlusionQueryIndex]=s),u.lastOcclusionObject=s)}if(s.isBatchedMesh===!0){const y=s._multiDrawStarts,S=s._multiDrawCounts,A=s._multiDrawCount,E=s._multiDrawInstances,D=g?f.array.BYTES_PER_ELEMENT:1;for(let w=0;w<A;w++){const U=E?E[w]:1,G=U>1?0:w;d.drawIndexed(S[w],U,y[w]/D,0,G)}}else if(g===!0){const{vertexCount:y,instanceCount:S,firstVertex:A}=h,E=e.getIndirect();if(E!==null){const D=this.get(E).buffer;d.drawIndexedIndirect(D,0)}else d.drawIndexed(y,S,A,0,0);t.update(s,y,S)}else{const{vertexCount:y,instanceCount:S,firstVertex:A}=h,E=e.getIndirect();if(E!==null){const D=this.get(E).buffer;d.drawIndirect(D,0)}else d.draw(y,S,A,0);t.update(s,y,S)}}needsRenderUpdate(e){const t=this.get(e),{object:s,material:n}=e,r=this.utils,i=r.getSampleCountRenderContext(e.context),u=r.getCurrentColorSpace(e.context),a=r.getCurrentColorFormat(e.context),l=r.getCurrentDepthStencilFormat(e.context),d=r.getPrimitiveTopology(s,n);let h=!1;return(t.material!==n||t.materialVersion!==n.version||t.transparent!==n.transparent||t.blending!==n.blending||t.premultipliedAlpha!==n.premultipliedAlpha||t.blendSrc!==n.blendSrc||t.blendDst!==n.blendDst||t.blendEquation!==n.blendEquation||t.blendSrcAlpha!==n.blendSrcAlpha||t.blendDstAlpha!==n.blendDstAlpha||t.blendEquationAlpha!==n.blendEquationAlpha||t.colorWrite!==n.colorWrite||t.depthWrite!==n.depthWrite||t.depthTest!==n.depthTest||t.depthFunc!==n.depthFunc||t.stencilWrite!==n.stencilWrite||t.stencilFunc!==n.stencilFunc||t.stencilFail!==n.stencilFail||t.stencilZFail!==n.stencilZFail||t.stencilZPass!==n.stencilZPass||t.stencilFuncMask!==n.stencilFuncMask||t.stencilWriteMask!==n.stencilWriteMask||t.side!==n.side||t.alphaToCoverage!==n.alphaToCoverage||t.sampleCount!==i||t.colorSpace!==u||t.colorFormat!==a||t.depthStencilFormat!==l||t.primitiveTopology!==d||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=n,t.materialVersion=n.version,t.transparent=n.transparent,t.blending=n.blending,t.premultipliedAlpha=n.premultipliedAlpha,t.blendSrc=n.blendSrc,t.blendDst=n.blendDst,t.blendEquation=n.blendEquation,t.blendSrcAlpha=n.blendSrcAlpha,t.blendDstAlpha=n.blendDstAlpha,t.blendEquationAlpha=n.blendEquationAlpha,t.colorWrite=n.colorWrite,t.depthWrite=n.depthWrite,t.depthTest=n.depthTest,t.depthFunc=n.depthFunc,t.stencilWrite=n.stencilWrite,t.stencilFunc=n.stencilFunc,t.stencilFail=n.stencilFail,t.stencilZFail=n.stencilZFail,t.stencilZPass=n.stencilZPass,t.stencilFuncMask=n.stencilFuncMask,t.stencilWriteMask=n.stencilWriteMask,t.side=n.side,t.alphaToCoverage=n.alphaToCoverage,t.sampleCount=i,t.colorSpace=u,t.colorFormat=a,t.depthStencilFormat=l,t.primitiveTopology=d,t.clippingContextCacheKey=e.clippingContextCacheKey,h=!0),h}getRenderCacheKey(e){const{object:t,material:s}=e,n=this.utils,r=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,n.getSampleCountRenderContext(r),n.getCurrentColorSpace(r),n.getCurrentColorFormat(r),n.getCurrentDepthStencilFormat(r),n.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)}copyTextureToBuffer(e,t,s,n,r,i){return this.textureUtils.copyTextureToBuffer(e,t,s,n,r,i)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;const s=this.get(e);if(!s.timeStampQuerySet){const n=e.isComputeNode?"compute":"render",r=this.device.createQuerySet({type:"timestamp",count:2,label:`timestamp_${n}_${e.id}`});Object.assign(t,{timestampWrites:{querySet:r,beginningOfPassWriteIndex:0,endOfPassWriteIndex:1}}),s.timeStampQuerySet=r}}prepareTimestampBuffer(e,t){if(!this.trackTimestamp)return;const s=this.get(e),n=2*BigInt64Array.BYTES_PER_ELEMENT;s.currentTimestampQueryBuffers===void 0&&(s.currentTimestampQueryBuffers={resolveBuffer:this.device.createBuffer({label:"timestamp resolve buffer",size:n,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),resultBuffer:this.device.createBuffer({label:"timestamp result buffer",size:n,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})});const{resolveBuffer:r,resultBuffer:i}=s.currentTimestampQueryBuffers;t.resolveQuerySet(s.timeStampQuerySet,0,2,r,0),i.mapState==="unmapped"&&t.copyBufferToBuffer(r,0,i,0,n)}async resolveTimestampAsync(e,t="render"){if(!this.trackTimestamp)return;const s=this.get(e);if(s.currentTimestampQueryBuffers===void 0)return;const{resultBuffer:n}=s.currentTimestampQueryBuffers;await this.device.queue.onSubmittedWorkDone(),n.mapState==="unmapped"&&n.mapAsync(GPUMapMode.READ).then(()=>{const r=new BigUint64Array(n.getMappedRange()),i=Number(r[1]-r[0])/1e6;this.renderer.info.updateTimestamp(t,i),n.unmap()})}createNodeBuilder(e,t){return new zg(e,t)}createProgram(e){const t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage}),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),r=s.currentPass.finish();this.get(t).bundleGPU=r,s.currentSets=s._currentSets,s.currentPass=s._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,s,n){this.bindingUtils.createBindings(e,t,s,n)}updateBindings(e,t,s,n){this.bindingUtils.createBindings(e,t,s,n)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}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,n=null,r=0){let i=0,u=0,a=0,l=0,d=0,h=0,p=e.image.width,f=e.image.height;s!==null&&(l=s.x,d=s.y,h=s.z||0,p=s.width,f=s.height),n!==null&&(i=n.x,u=n.y,a=n.z||0);const g=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),m=this.get(e).texture,y=this.get(t).texture;g.copyTextureToTexture({texture:m,mipLevel:r,origin:{x:l,y:d,z:h}},{texture:y,mipLevel:r,origin:{x:i,y:u,z:a}},[p,f,1]),this.device.queue.submit([g.finish()])}copyFramebufferToTexture(e,t,s){const n=this.get(t);let r=null;t.renderTarget?e.isDepthTexture?r=this.get(t.depthTexture).texture:r=this.get(t.textures[0]).texture:e.isDepthTexture?r=this.textureUtils.getDepthBuffer(t.depth,t.stencil):r=this.context.getCurrentTexture();const i=this.get(e).texture;if(r.format!==i.format){console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",r.format,i.format);return}let u;if(n.currentPass?(n.currentPass.end(),u=n.encoder):u=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),u.copyTextureToTexture({texture:r,origin:[s.x,s.y,0]},{texture:i},[s.z,s.w]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e),n.currentPass){const{descriptor:a}=n;for(let l=0;l<a.colorAttachments.length;l++)a.colorAttachments[l].loadOp=oe.Load;if(t.depth&&(a.depthStencilAttachment.depthLoadOp=oe.Load),t.stencil&&(a.depthStencilAttachment.stencilLoadOp=oe.Load),n.currentPass=u.beginRenderPass(a),n.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor){const{x:l,y:d,width:h,height:p}=t.scissorValue;n.currentPass.setScissorRect(l,d,h,p)}}else this.device.queue.submit([u.finish()])}}class ku extends c.SpotLight{constructor(e,t,s,n,r,i){super(e,t,s,n,r,i),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class jg extends Fu{constructor(){super(),this.addMaterial($a,"MeshPhongMaterial"),this.addMaterial(wr,"MeshStandardMaterial"),this.addMaterial(Za,"MeshPhysicalMaterial"),this.addMaterial(Ja,"MeshToonMaterial"),this.addMaterial(ka,"MeshBasicMaterial"),this.addMaterial(za,"MeshLambertMaterial"),this.addMaterial(Ga,"MeshNormalMaterial"),this.addMaterial(tu,"MeshMatcapMaterial"),this.addMaterial(wa,"LineBasicMaterial"),this.addMaterial(Ua,"LineDashedMaterial"),this.addMaterial(su,"PointsMaterial"),this.addMaterial(ru,"SpriteMaterial"),this.addMaterial(iu,"ShadowMaterial"),this.addLight(yu,c.PointLight),this.addLight(bu,c.DirectionalLight),this.addLight(Ru,c.RectAreaLight),this.addLight($r,c.SpotLight),this.addLight(Cu,c.AmbientLight),this.addLight(vu,c.HemisphereLight),this.addLight(Eu,c.LightProbe),this.addLight(Au,ku),this.addToneMapping($p,c.LinearToneMapping),this.addToneMapping(Wp,c.ReinhardToneMapping),this.addToneMapping(Hp,c.CineonToneMapping),this.addToneMapping(Kp,c.ACESFilmicToneMapping),this.addToneMapping(jp,c.AgXToneMapping),this.addToneMapping(Zp,c.NeutralToneMapping)}}class Zg extends ng{constructor(e={}){let t;e.forceWebGL?t=ji:(t=Qg,e.getFallback=()=>(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new ji(e)));const s=new t(e);super(s,e),this.library=new jg,this.isWebGPURenderer=!0}}exports.ACESFilmicToneMapping=c.ACESFilmicToneMapping;exports.AddEquation=c.AddEquation;exports.AddOperation=c.AddOperation;exports.AdditiveBlending=c.AdditiveBlending;exports.AgXToneMapping=c.AgXToneMapping;exports.AlphaFormat=c.AlphaFormat;exports.AlwaysCompare=c.AlwaysCompare;exports.AlwaysDepth=c.AlwaysDepth;exports.AlwaysStencilFunc=c.AlwaysStencilFunc;exports.AmbientLight=c.AmbientLight;exports.ArcCurve=c.ArcCurve;exports.ArrayCamera=c.ArrayCamera;exports.BackSide=c.BackSide;exports.BasicDepthPacking=c.BasicDepthPacking;exports.BasicShadowMap=c.BasicShadowMap;exports.Box3=c.Box3;exports.BoxGeometry=c.BoxGeometry;exports.BufferAttribute=c.BufferAttribute;exports.BufferGeometry=c.BufferGeometry;exports.ByteType=c.ByteType;exports.Cache=c.Cache;exports.Camera=c.Camera;exports.CatmullRomCurve3=c.CatmullRomCurve3;exports.CineonToneMapping=c.CineonToneMapping;exports.ClampToEdgeWrapping=c.ClampToEdgeWrapping;exports.Clock=c.Clock;exports.Color=c.Color;exports.ColorManagement=c.ColorManagement;exports.ConeGeometry=c.ConeGeometry;exports.ConstantAlphaFactor=c.ConstantAlphaFactor;exports.ConstantColorFactor=c.ConstantColorFactor;exports.Controls=c.Controls;exports.CubeCamera=c.CubeCamera;exports.CubeReflectionMapping=c.CubeReflectionMapping;exports.CubeRefractionMapping=c.CubeRefractionMapping;exports.CubeTexture=c.CubeTexture;exports.CubeUVReflectionMapping=c.CubeUVReflectionMapping;exports.CubicBezierCurve=c.CubicBezierCurve;exports.CubicBezierCurve3=c.CubicBezierCurve3;exports.CullFaceBack=c.CullFaceBack;exports.CullFaceFront=c.CullFaceFront;exports.CullFaceNone=c.CullFaceNone;exports.Curve=c.Curve;exports.CustomBlending=c.CustomBlending;exports.CustomToneMapping=c.CustomToneMapping;exports.CylinderGeometry=c.CylinderGeometry;exports.Data3DTexture=c.Data3DTexture;exports.DataArrayTexture=c.DataArrayTexture;exports.DataTexture=c.DataTexture;exports.DecrementStencilOp=c.DecrementStencilOp;exports.DecrementWrapStencilOp=c.DecrementWrapStencilOp;exports.DefaultLoadingManager=c.DefaultLoadingManager;exports.DepthFormat=c.DepthFormat;exports.DepthStencilFormat=c.DepthStencilFormat;exports.DepthTexture=c.DepthTexture;exports.DirectionalLight=c.DirectionalLight;exports.DoubleSide=c.DoubleSide;exports.DstAlphaFactor=c.DstAlphaFactor;exports.DstColorFactor=c.DstColorFactor;exports.DynamicDrawUsage=c.DynamicDrawUsage;exports.EllipseCurve=c.EllipseCurve;exports.EqualCompare=c.EqualCompare;exports.EqualDepth=c.EqualDepth;exports.EqualStencilFunc=c.EqualStencilFunc;exports.EquirectangularReflectionMapping=c.EquirectangularReflectionMapping;exports.EquirectangularRefractionMapping=c.EquirectangularRefractionMapping;exports.Euler=c.Euler;exports.EventDispatcher=c.EventDispatcher;exports.Float16BufferAttribute=c.Float16BufferAttribute;exports.Float32BufferAttribute=c.Float32BufferAttribute;exports.FloatType=c.FloatType;exports.FramebufferTexture=c.FramebufferTexture;exports.FrontSide=c.FrontSide;exports.Frustum=c.Frustum;exports.GLSL3=c.GLSL3;exports.GreaterCompare=c.GreaterCompare;exports.GreaterDepth=c.GreaterDepth;exports.GreaterEqualCompare=c.GreaterEqualCompare;exports.GreaterEqualDepth=c.GreaterEqualDepth;exports.GreaterEqualStencilFunc=c.GreaterEqualStencilFunc;exports.GreaterStencilFunc=c.GreaterStencilFunc;exports.Group=c.Group;exports.HalfFloatType=c.HalfFloatType;exports.HemisphereLight=c.HemisphereLight;exports.ImageLoader=c.ImageLoader;exports.ImageUtils=c.ImageUtils;exports.IncrementStencilOp=c.IncrementStencilOp;exports.IncrementWrapStencilOp=c.IncrementWrapStencilOp;exports.InstancedBufferAttribute=c.InstancedBufferAttribute;exports.InstancedInterleavedBuffer=c.InstancedInterleavedBuffer;exports.IntType=c.IntType;exports.InterleavedBuffer=c.InterleavedBuffer;exports.InterleavedBufferAttribute=c.InterleavedBufferAttribute;exports.InvertStencilOp=c.InvertStencilOp;exports.KeepStencilOp=c.KeepStencilOp;exports.Layers=c.Layers;exports.LessCompare=c.LessCompare;exports.LessDepth=c.LessDepth;exports.LessEqualCompare=c.LessEqualCompare;exports.LessEqualDepth=c.LessEqualDepth;exports.LessEqualStencilFunc=c.LessEqualStencilFunc;exports.LessStencilFunc=c.LessStencilFunc;exports.Light=c.Light;exports.LightProbe=c.LightProbe;exports.Line=c.Line;exports.LineBasicMaterial=c.LineBasicMaterial;exports.LineCurve=c.LineCurve;exports.LineCurve3=c.LineCurve3;exports.LineDashedMaterial=c.LineDashedMaterial;exports.LinearFilter=c.LinearFilter;exports.LinearMipmapLinearFilter=c.LinearMipmapLinearFilter;exports.LinearMipmapNearestFilter=c.LinearMipmapNearestFilter;exports.LinearSRGBColorSpace=c.LinearSRGBColorSpace;exports.LinearToneMapping=c.LinearToneMapping;exports.LinearTransfer=c.LinearTransfer;exports.Loader=c.Loader;exports.LoadingManager=c.LoadingManager;exports.LuminanceAlphaFormat=c.LuminanceAlphaFormat;exports.LuminanceFormat=c.LuminanceFormat;exports.MOUSE=c.MOUSE;exports.Material=c.Material;exports.MathUtils=c.MathUtils;exports.Matrix3=c.Matrix3;exports.Matrix4=c.Matrix4;exports.MaxEquation=c.MaxEquation;exports.Mesh=c.Mesh;exports.MeshBasicMaterial=c.MeshBasicMaterial;exports.MeshDepthMaterial=c.MeshDepthMaterial;exports.MeshDistanceMaterial=c.MeshDistanceMaterial;exports.MeshLambertMaterial=c.MeshLambertMaterial;exports.MeshMatcapMaterial=c.MeshMatcapMaterial;exports.MeshNormalMaterial=c.MeshNormalMaterial;exports.MeshPhongMaterial=c.MeshPhongMaterial;exports.MeshPhysicalMaterial=c.MeshPhysicalMaterial;exports.MeshStandardMaterial=c.MeshStandardMaterial;exports.MeshToonMaterial=c.MeshToonMaterial;exports.MinEquation=c.MinEquation;exports.MirroredRepeatWrapping=c.MirroredRepeatWrapping;exports.MixOperation=c.MixOperation;exports.MultiplyBlending=c.MultiplyBlending;exports.MultiplyOperation=c.MultiplyOperation;exports.NearestFilter=c.NearestFilter;exports.NearestMipmapLinearFilter=c.NearestMipmapLinearFilter;exports.NearestMipmapNearestFilter=c.NearestMipmapNearestFilter;exports.NeutralToneMapping=c.NeutralToneMapping;exports.NeverCompare=c.NeverCompare;exports.NeverDepth=c.NeverDepth;exports.NeverStencilFunc=c.NeverStencilFunc;exports.NoBlending=c.NoBlending;exports.NoColorSpace=c.NoColorSpace;exports.NoToneMapping=c.NoToneMapping;exports.NormalBlending=c.NormalBlending;exports.NotEqualCompare=c.NotEqualCompare;exports.NotEqualDepth=c.NotEqualDepth;exports.NotEqualStencilFunc=c.NotEqualStencilFunc;exports.Object3D=c.Object3D;exports.ObjectSpaceNormalMap=c.ObjectSpaceNormalMap;exports.OneFactor=c.OneFactor;exports.OneMinusConstantAlphaFactor=c.OneMinusConstantAlphaFactor;exports.OneMinusConstantColorFactor=c.OneMinusConstantColorFactor;exports.OneMinusDstAlphaFactor=c.OneMinusDstAlphaFactor;exports.OneMinusDstColorFactor=c.OneMinusDstColorFactor;exports.OneMinusSrcAlphaFactor=c.OneMinusSrcAlphaFactor;exports.OneMinusSrcColorFactor=c.OneMinusSrcColorFactor;exports.OrthographicCamera=c.OrthographicCamera;exports.PCFShadowMap=c.PCFShadowMap;exports.PCFSoftShadowMap=c.PCFSoftShadowMap;exports.PerspectiveCamera=c.PerspectiveCamera;exports.Plane=c.Plane;exports.PlaneGeometry=c.PlaneGeometry;exports.PointLight=c.PointLight;exports.PointsMaterial=c.PointsMaterial;exports.QuadraticBezierCurve=c.QuadraticBezierCurve;exports.QuadraticBezierCurve3=c.QuadraticBezierCurve3;exports.Quaternion=c.Quaternion;exports.RED_GREEN_RGTC2_Format=c.RED_GREEN_RGTC2_Format;exports.RED_RGTC1_Format=c.RED_RGTC1_Format;exports.REVISION=c.REVISION;exports.RGBADepthPacking=c.RGBADepthPacking;exports.RGBAFormat=c.RGBAFormat;exports.RGBAIntegerFormat=c.RGBAIntegerFormat;exports.RGBA_ASTC_10x10_Format=c.RGBA_ASTC_10x10_Format;exports.RGBA_ASTC_10x5_Format=c.RGBA_ASTC_10x5_Format;exports.RGBA_ASTC_10x6_Format=c.RGBA_ASTC_10x6_Format;exports.RGBA_ASTC_10x8_Format=c.RGBA_ASTC_10x8_Format;exports.RGBA_ASTC_12x10_Format=c.RGBA_ASTC_12x10_Format;exports.RGBA_ASTC_12x12_Format=c.RGBA_ASTC_12x12_Format;exports.RGBA_ASTC_4x4_Format=c.RGBA_ASTC_4x4_Format;exports.RGBA_ASTC_5x4_Format=c.RGBA_ASTC_5x4_Format;exports.RGBA_ASTC_5x5_Format=c.RGBA_ASTC_5x5_Format;exports.RGBA_ASTC_6x5_Format=c.RGBA_ASTC_6x5_Format;exports.RGBA_ASTC_6x6_Format=c.RGBA_ASTC_6x6_Format;exports.RGBA_ASTC_8x5_Format=c.RGBA_ASTC_8x5_Format;exports.RGBA_ASTC_8x6_Format=c.RGBA_ASTC_8x6_Format;exports.RGBA_ASTC_8x8_Format=c.RGBA_ASTC_8x8_Format;exports.RGBA_BPTC_Format=c.RGBA_BPTC_Format;exports.RGBA_ETC2_EAC_Format=c.RGBA_ETC2_EAC_Format;exports.RGBA_PVRTC_2BPPV1_Format=c.RGBA_PVRTC_2BPPV1_Format;exports.RGBA_PVRTC_4BPPV1_Format=c.RGBA_PVRTC_4BPPV1_Format;exports.RGBA_S3TC_DXT1_Format=c.RGBA_S3TC_DXT1_Format;exports.RGBA_S3TC_DXT3_Format=c.RGBA_S3TC_DXT3_Format;exports.RGBA_S3TC_DXT5_Format=c.RGBA_S3TC_DXT5_Format;exports.RGBFormat=c.RGBFormat;exports.RGBIntegerFormat=c.RGBIntegerFormat;exports.RGB_BPTC_SIGNED_Format=c.RGB_BPTC_SIGNED_Format;exports.RGB_BPTC_UNSIGNED_Format=c.RGB_BPTC_UNSIGNED_Format;exports.RGB_ETC1_Format=c.RGB_ETC1_Format;exports.RGB_ETC2_Format=c.RGB_ETC2_Format;exports.RGB_PVRTC_2BPPV1_Format=c.RGB_PVRTC_2BPPV1_Format;exports.RGB_PVRTC_4BPPV1_Format=c.RGB_PVRTC_4BPPV1_Format;exports.RGB_S3TC_DXT1_Format=c.RGB_S3TC_DXT1_Format;exports.RGFormat=c.RGFormat;exports.RGIntegerFormat=c.RGIntegerFormat;exports.Ray=c.Ray;exports.Raycaster=c.Raycaster;exports.RectAreaLight=c.RectAreaLight;exports.RedFormat=c.RedFormat;exports.RedIntegerFormat=c.RedIntegerFormat;exports.ReinhardToneMapping=c.ReinhardToneMapping;exports.RenderTarget=c.RenderTarget;exports.RepeatWrapping=c.RepeatWrapping;exports.ReplaceStencilOp=c.ReplaceStencilOp;exports.ReverseSubtractEquation=c.ReverseSubtractEquation;exports.SIGNED_RED_GREEN_RGTC2_Format=c.SIGNED_RED_GREEN_RGTC2_Format;exports.SIGNED_RED_RGTC1_Format=c.SIGNED_RED_RGTC1_Format;exports.SRGBColorSpace=c.SRGBColorSpace;exports.SRGBTransfer=c.SRGBTransfer;exports.Scene=c.Scene;exports.ShaderMaterial=c.ShaderMaterial;exports.ShadowMaterial=c.ShadowMaterial;exports.ShortType=c.ShortType;exports.Source=c.Source;exports.Sphere=c.Sphere;exports.SphereGeometry=c.SphereGeometry;exports.Spherical=c.Spherical;exports.SphericalHarmonics3=c.SphericalHarmonics3;exports.SplineCurve=c.SplineCurve;exports.SpotLight=c.SpotLight;exports.SpriteMaterial=c.SpriteMaterial;exports.SrcAlphaFactor=c.SrcAlphaFactor;exports.SrcAlphaSaturateFactor=c.SrcAlphaSaturateFactor;exports.SrcColorFactor=c.SrcColorFactor;exports.StaticDrawUsage=c.StaticDrawUsage;exports.SubtractEquation=c.SubtractEquation;exports.SubtractiveBlending=c.SubtractiveBlending;exports.TOUCH=c.TOUCH;exports.TangentSpaceNormalMap=c.TangentSpaceNormalMap;exports.Texture=c.Texture;exports.TextureLoader=c.TextureLoader;exports.Triangle=c.Triangle;exports.TubeGeometry=c.TubeGeometry;exports.UVMapping=c.UVMapping;exports.Uint16BufferAttribute=c.Uint16BufferAttribute;exports.Uint32BufferAttribute=c.Uint32BufferAttribute;exports.UnsignedByteType=c.UnsignedByteType;exports.UnsignedInt248Type=c.UnsignedInt248Type;exports.UnsignedInt5999Type=c.UnsignedInt5999Type;exports.UnsignedIntType=c.UnsignedIntType;exports.UnsignedShort4444Type=c.UnsignedShort4444Type;exports.UnsignedShort5551Type=c.UnsignedShort5551Type;exports.UnsignedShortType=c.UnsignedShortType;exports.VSMShadowMap=c.VSMShadowMap;exports.Vector2=c.Vector2;exports.Vector3=c.Vector3;exports.Vector4=c.Vector4;exports.WebGLCoordinateSystem=c.WebGLCoordinateSystem;exports.WebGLCubeRenderTarget=c.WebGLCubeRenderTarget;exports.WebGLRenderTarget=c.WebGLRenderTarget;exports.WebGPUCoordinateSystem=c.WebGPUCoordinateSystem;exports.ZeroFactor=c.ZeroFactor;exports.ZeroStencilOp=c.ZeroStencilOp;exports.createCanvasElement=c.createCanvasElement;exports.AONode=xa;exports.AmbientLightNode=Cu;exports.AnalyticLightNode=at;exports.ArrayElementNode=It;exports.AssignNode=Co;exports.AttributeNode=Qo;exports.BasicEnvironmentNode=tn;exports.BatchNode=ya;exports.BufferAttributeNode=Ho;exports.BufferNode=Ar;exports.BumpMapNode=da;exports.BypassNode=Xo;exports.CacheNode=Ko;exports.CodeNode=ae;exports.ColorSpaceNode=ds;exports.ComputeNode=qo;exports.ConstNode=Ve;exports.ContextNode=Tr;exports.ConvertNode=ir;exports.CubeTextureNode=ia;exports.DirectionalLightNode=bu;exports.EnvironmentNode=ja;exports.EquirectUVNode=Pa;exports.ExpressionNode=br;exports.FogExp2Node=pu;exports.FogNode=Pr;exports.FogRangeNode=hu;exports.FrontFacingNode=ta;exports.FunctionCallNode=vo;exports.FunctionNode=du;exports.GLSLNodeParser=Bu;exports.HemisphereLightNode=vu;exports.IESSpotLight=ku;exports.IESSpotLightNode=Au;exports.IndexNode=j;exports.InstanceNode=ma;exports.InstancedMeshNode=Ta;exports.IrradianceNode=Ra;exports.JoinNode=lo;exports.LightProbeNode=Eu;exports.Lighting=wu;exports.LightingContextNode=ba;exports.LightingModel=hs;exports.LightingNode=_t;exports.LightsNode=Ir;exports.LineBasicNodeMaterial=wa;exports.LineDashedNodeMaterial=Ua;exports.LoopNode=Sa;exports.MatcapUVNode=eu;exports.MaterialNode=N;exports.MaterialReferenceNode=aa;exports.MaxMipLevelNode=Zo;exports.MeshBasicNodeMaterial=ka;exports.MeshLambertNodeMaterial=za;exports.MeshMatcapNodeMaterial=tu;exports.MeshNormalNodeMaterial=Ga;exports.MeshPhongNodeMaterial=$a;exports.MeshPhysicalNodeMaterial=Za;exports.MeshStandardNodeMaterial=wr;exports.MeshToonNodeMaterial=Ja;exports.ModelNode=Ue;exports.ModelViewProjectionNode=fa;exports.MorphNode=Na;exports.Node=V;exports.NodeAccess=De;exports.NodeAttribute=tr;exports.NodeBuilder=zr;exports.NodeCache=Gs;exports.NodeCode=Nu;exports.NodeFrame=sr;exports.NodeFunctionInput=nn;exports.NodeMaterial=re;exports.NodeMaterialObserver=ro;exports.NodeShaderStage=Vn;exports.NodeUniform=_u;exports.NodeUpdateType=z;exports.NodeVar=Or;exports.NodeVarying=Su;exports.NormalMapNode=la;exports.Object3DNode=W;exports.PMREMGenerator=xu;exports.PMREMNode=Ya;exports.ParameterNode=cu;exports.PassNode=ps;exports.PhongLightingModel=Br;exports.PhysicalLightingModel=Fr;exports.PointLightNode=yu;exports.PointsNodeMaterial=su;exports.PropertyNode=K;exports.QuadMesh=Gr;exports.RectAreaLightNode=Ru;exports.ReferenceNode=Js;exports.RemapNode=xr;exports.RenderOutputNode=Yo;exports.RendererReferenceNode=$o;exports.RotateNode=nu;exports.SceneNode=me;exports.ScreenNode=ne;exports.SetNode=ho;exports.ShadowNode=Lr;exports.ShadowNodeMaterial=iu;exports.SkinningNode=_a;exports.SplitNode=$n;exports.SpotLightNode=$r;exports.SpriteNodeMaterial=ru;exports.StackNode=lu;exports.TempNode=ie;exports.TextureNode=Ot;exports.TextureSizeNode=jo;exports.ToneMappingNode=Wo;exports.UniformArrayNode=oa;exports.UniformGroupNode=dr;exports.UniformNode=Lt;exports.VarNode=_r;exports.VaryingNode=Vo;exports.ViewportDepthNode=ge;exports.ViewportDepthTextureNode=va;exports.ViewportTextureNode=Mr;exports.WebGPURenderer=Zg;exports.defaultBuildStages=kn;exports.defaultShaderStages=co;exports.shaderStages=zn;exports.vectorComponents=yt;