@aibee/owlly 1.0.26 → 1.0.29

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 (359) hide show
  1. package/lib/external/lines/line-geometry.d.ts +9 -0
  2. package/lib/external/lines/line-geometry.js +51 -0
  3. package/lib/external/lines/line-material.d.ts +10 -0
  4. package/lib/external/lines/line-material.js +376 -0
  5. package/lib/external/lines/line-segments-2.d.ts +7 -0
  6. package/lib/external/lines/line-segments-2.js +143 -0
  7. package/lib/external/lines/line-segments-geometry.d.ts +15 -0
  8. package/lib/external/lines/line-segments-geometry.js +140 -0
  9. package/lib/external/loaders/gltf-loader.d.ts +77 -0
  10. package/lib/external/loaders/gltf-loader.js +2318 -0
  11. package/lib/external/orbit-controls.d.ts +44 -0
  12. package/lib/external/orbit-controls.js +745 -0
  13. package/lib/external/renderers/css-2d-renderer.d.ts +16 -0
  14. package/lib/external/renderers/css-2d-renderer.js +121 -0
  15. package/lib/external/renderers/css-3d-renderer.d.ts +18 -0
  16. package/lib/external/renderers/css-3d-renderer.js +138 -0
  17. package/lib/external/transform-controls.d.ts +106 -0
  18. package/lib/external/transform-controls.js +1112 -0
  19. package/lib/owlly/controller/aerial-element-controller.d.ts +65 -0
  20. package/lib/owlly/controller/aerial-element-controller.js +235 -0
  21. package/lib/owlly/controller/basic-controller.d.ts +324 -0
  22. package/lib/owlly/controller/basic-controller.js +1238 -0
  23. package/lib/owlly/controller/camera-controller.d.ts +37 -0
  24. package/lib/owlly/controller/camera-controller.js +137 -0
  25. package/lib/owlly/controller/controller.d.ts +61 -0
  26. package/lib/owlly/controller/controller.js +23 -0
  27. package/lib/owlly/controller/index.d.ts +2 -0
  28. package/lib/owlly/controller/index.js +13 -0
  29. package/lib/owlly/controller/mouse-indicator-controller.d.ts +34 -0
  30. package/lib/owlly/controller/mouse-indicator-controller.js +118 -0
  31. package/lib/owlly/controller/orbit-control.d.ts +147 -0
  32. package/lib/owlly/controller/orbit-control.js +264 -0
  33. package/lib/owlly/controller/panorama-adjust-controller.d.ts +45 -0
  34. package/lib/owlly/controller/panorama-adjust-controller.js +157 -0
  35. package/lib/owlly/controller/panorama-controller.d.ts +441 -0
  36. package/lib/owlly/controller/panorama-controller.js +1943 -0
  37. package/lib/owlly/controller/panorama-transform-controller.d.ts +66 -0
  38. package/lib/owlly/controller/panorama-transform-controller.js +136 -0
  39. package/lib/owlly/controller/plane-controller.d.ts +43 -0
  40. package/lib/owlly/controller/plane-controller.js +173 -0
  41. package/lib/owlly/controller/texture-controller.d.ts +181 -0
  42. package/lib/owlly/controller/texture-controller.js +875 -0
  43. package/lib/owlly/controller/tile-panorama-controller.d.ts +308 -0
  44. package/lib/owlly/controller/tile-panorama-controller.js +1353 -0
  45. package/lib/owlly/controller/transform-controller.d.ts +106 -0
  46. package/lib/owlly/controller/transform-controller.js +545 -0
  47. package/lib/owlly/element/bottom-nav-element.d.ts +65 -0
  48. package/lib/owlly/element/bottom-nav-element.js +257 -0
  49. package/lib/owlly/element/camera.d.ts +82 -0
  50. package/lib/owlly/element/camera.js +283 -0
  51. package/lib/owlly/element/dom-2d-element.d.ts +35 -0
  52. package/lib/owlly/element/dom-2d-element.js +48 -0
  53. package/lib/owlly/element/dom-3d-element.d.ts +27 -0
  54. package/lib/owlly/element/dom-3d-element.js +33 -0
  55. package/lib/owlly/element/dom-label-2d.d.ts +116 -0
  56. package/lib/owlly/element/dom-label-2d.js +382 -0
  57. package/lib/owlly/element/element.d.ts +53 -0
  58. package/lib/owlly/element/element.js +75 -0
  59. package/lib/owlly/element/floor-model.d.ts +83 -0
  60. package/lib/owlly/element/floor-model.js +227 -0
  61. package/lib/owlly/element/gif-kit/Gif.d.ts +96 -0
  62. package/lib/owlly/element/gif-kit/Gif.js +432 -0
  63. package/lib/owlly/element/gif-kit/GifColor.d.ts +21 -0
  64. package/lib/owlly/element/gif-kit/GifColor.js +37 -0
  65. package/lib/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.d.ts +20 -0
  66. package/lib/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.js +50 -0
  67. package/lib/owlly/element/gif-kit/GifFrame.d.ts +31 -0
  68. package/lib/owlly/element/gif-kit/GifFrame.js +96 -0
  69. package/lib/owlly/element/gif-kit/GifImage.d.ts +23 -0
  70. package/lib/owlly/element/gif-kit/GifImage.js +7 -0
  71. package/lib/owlly/element/gif-kit/GifParser.d.ts +17 -0
  72. package/lib/owlly/element/gif-kit/GifParser.js +196 -0
  73. package/lib/owlly/element/gif-kit/GifPresenter.d.ts +20 -0
  74. package/lib/owlly/element/gif-kit/GifPresenter.js +43 -0
  75. package/lib/owlly/element/gif-kit/GifVersion.d.ts +10 -0
  76. package/lib/owlly/element/gif-kit/GifVersion.js +12 -0
  77. package/lib/owlly/element/gltf-mesh-element.d.ts +31 -0
  78. package/lib/owlly/element/gltf-mesh-element.js +136 -0
  79. package/lib/owlly/element/index.d.ts +20 -0
  80. package/lib/owlly/element/index.js +24 -0
  81. package/lib/owlly/element/map-kit/shape.d.ts +131 -0
  82. package/lib/owlly/element/map-kit/shape.js +189 -0
  83. package/lib/owlly/element/mesh-element.d.ts +22 -0
  84. package/lib/owlly/element/mesh-element.js +63 -0
  85. package/lib/owlly/element/mesh-line-2d.d.ts +82 -0
  86. package/lib/owlly/element/mesh-line-2d.js +887 -0
  87. package/lib/owlly/element/meshline-o.d.ts +64 -0
  88. package/lib/owlly/element/meshline-o.js +678 -0
  89. package/lib/owlly/element/panorama-group.d.ts +241 -0
  90. package/lib/owlly/element/panorama-group.js +966 -0
  91. package/lib/owlly/element/panorama.d.ts +132 -0
  92. package/lib/owlly/element/panorama.js +812 -0
  93. package/lib/owlly/element/path-group.d.ts +69 -0
  94. package/lib/owlly/element/path-group.js +171 -0
  95. package/lib/owlly/element/path.d.ts +99 -0
  96. package/lib/owlly/element/path.js +531 -0
  97. package/lib/owlly/element/placeable-2d.d.ts +158 -0
  98. package/lib/owlly/element/placeable-2d.js +470 -0
  99. package/lib/owlly/element/polygon-mesh.d.ts +107 -0
  100. package/lib/owlly/element/polygon-mesh.js +307 -0
  101. package/lib/owlly/element/ring-element.d.ts +79 -0
  102. package/lib/owlly/element/ring-element.js +383 -0
  103. package/lib/owlly/element/sphere-mesh.d.ts +28 -0
  104. package/lib/owlly/element/sphere-mesh.js +69 -0
  105. package/lib/owlly/element/svg-floor-model.d.ts +22 -0
  106. package/lib/owlly/element/svg-floor-model.js +184 -0
  107. package/lib/owlly/element/svg-floors.d.ts +27 -0
  108. package/lib/owlly/element/svg-floors.js +109 -0
  109. package/lib/owlly/element/tile-panorama-group.d.ts +335 -0
  110. package/lib/owlly/element/tile-panorama-group.js +1006 -0
  111. package/lib/owlly/element/tile-panorama.d.ts +161 -0
  112. package/lib/owlly/element/tile-panorama.js +509 -0
  113. package/lib/owlly/element/tile-plane.d.ts +105 -0
  114. package/lib/owlly/element/tile-plane.js +360 -0
  115. package/lib/owlly/element/video-element.d.ts +33 -0
  116. package/lib/owlly/element/video-element.js +159 -0
  117. package/lib/owlly/geometries/ExtrudeGeometry2.d.ts +15 -0
  118. package/lib/owlly/geometries/ExtrudeGeometry2.js +210 -0
  119. package/lib/owlly/index.d.ts +13 -0
  120. package/lib/owlly/index.js +16 -0
  121. package/lib/owlly/overlay/canvas-overlay.d.ts +96 -0
  122. package/lib/owlly/overlay/canvas-overlay.js +510 -0
  123. package/lib/owlly/overlay/css-2d-overlay.d.ts +14 -0
  124. package/lib/owlly/overlay/css-2d-overlay.js +35 -0
  125. package/lib/owlly/overlay/css-3d-overlay.d.ts +16 -0
  126. package/lib/owlly/overlay/css-3d-overlay.js +36 -0
  127. package/lib/owlly/overlay/index.d.ts +6 -0
  128. package/lib/owlly/overlay/index.js +11 -0
  129. package/lib/owlly/overlay/label-overlay.d.ts +62 -0
  130. package/lib/owlly/overlay/label-overlay.js +328 -0
  131. package/lib/owlly/overlay/overlay.d.ts +14 -0
  132. package/lib/owlly/overlay/overlay.js +4 -0
  133. package/lib/owlly/overlay/path-overlay.d.ts +39 -0
  134. package/lib/owlly/overlay/path-overlay.js +124 -0
  135. package/lib/owlly/overlay/path-overlay2.d.ts +35 -0
  136. package/lib/owlly/overlay/path-overlay2.js +118 -0
  137. package/lib/owlly/overlay/poi-overlay-3d.d.ts +278 -0
  138. package/lib/owlly/overlay/poi-overlay-3d.js +1432 -0
  139. package/lib/owlly/overlay/poi-overlay.d.ts +277 -0
  140. package/lib/owlly/overlay/poi-overlay.js +1411 -0
  141. package/lib/owlly/owlly-2d/index.d.ts +28 -0
  142. package/lib/owlly/owlly-2d/index.js +92 -0
  143. package/lib/owlly/screen/index.d.ts +1 -0
  144. package/lib/owlly/screen/index.js +1 -0
  145. package/lib/owlly/screen/screen.d.ts +73 -0
  146. package/lib/owlly/screen/screen.js +236 -0
  147. package/lib/owlly/stage/externals.d.ts +19 -0
  148. package/lib/owlly/stage/externals.js +24 -0
  149. package/lib/owlly/stage/index.d.ts +4 -0
  150. package/lib/owlly/stage/index.js +6 -0
  151. package/lib/owlly/stage/owlly.d.ts +38 -0
  152. package/lib/owlly/stage/owlly.js +168 -0
  153. package/lib/owlly/stage/stage.d.ts +108 -0
  154. package/lib/owlly/stage/stage.js +234 -0
  155. package/lib/owlly/utils/alignment-utils.d.ts +20 -0
  156. package/lib/owlly/utils/alignment-utils.js +63 -0
  157. package/lib/owlly/utils/basic-calc.d.ts +18 -0
  158. package/lib/owlly/utils/basic-calc.js +129 -0
  159. package/lib/owlly/utils/basic-tools.d.ts +71 -0
  160. package/lib/owlly/utils/basic-tools.js +235 -0
  161. package/lib/owlly/utils/bvh-tree.d.ts +105 -0
  162. package/lib/owlly/utils/bvh-tree.js +539 -0
  163. package/lib/owlly/utils/camera.d.ts +37 -0
  164. package/lib/owlly/utils/camera.js +50 -0
  165. package/lib/owlly/utils/cube-texture-cache.d.ts +25 -0
  166. package/lib/owlly/utils/cube-texture-cache.js +143 -0
  167. package/lib/owlly/utils/device-utils.d.ts +18 -0
  168. package/lib/owlly/utils/device-utils.js +41 -0
  169. package/lib/owlly/utils/environment-utils.d.ts +37 -0
  170. package/lib/owlly/utils/environment-utils.js +73 -0
  171. package/lib/owlly/utils/event-hub.d.ts +50 -0
  172. package/lib/owlly/utils/event-hub.js +106 -0
  173. package/lib/owlly/utils/events.d.ts +219 -0
  174. package/lib/owlly/utils/events.js +219 -0
  175. package/lib/owlly/utils/geometry-utils.d.ts +119 -0
  176. package/lib/owlly/utils/geometry-utils.js +622 -0
  177. package/lib/owlly/utils/helper.d.ts +6 -0
  178. package/lib/owlly/utils/helper.js +24 -0
  179. package/lib/owlly/utils/index.d.ts +14 -0
  180. package/lib/owlly/utils/index.js +17 -0
  181. package/lib/owlly/utils/lru-cache.d.ts +26 -0
  182. package/lib/owlly/utils/lru-cache.js +109 -0
  183. package/lib/owlly/utils/map-utils.d.ts +7 -0
  184. package/lib/owlly/utils/map-utils.js +52 -0
  185. package/lib/owlly/utils/number-utils.d.ts +8 -0
  186. package/lib/owlly/utils/number-utils.js +72 -0
  187. package/lib/owlly/utils/panorama-model-util.d.ts +46 -0
  188. package/lib/owlly/utils/panorama-model-util.js +245 -0
  189. package/lib/owlly/utils/path-utils.d.ts +80 -0
  190. package/lib/owlly/utils/path-utils.js +728 -0
  191. package/lib/owlly/utils/svgutils.d.ts +138 -0
  192. package/lib/owlly/utils/svgutils.js +561 -0
  193. package/lib/owlly/utils/texture-cache.d.ts +29 -0
  194. package/lib/owlly/utils/texture-cache.js +115 -0
  195. package/lib/owlly/utils/tile-util.d.ts +187 -0
  196. package/lib/owlly/utils/tile-util.js +456 -0
  197. package/lib/owlly/utils/time-profiler.d.ts +21 -0
  198. package/lib/owlly/utils/time-profiler.js +48 -0
  199. package/lib/owlly/view/camera-view.d.ts +35 -0
  200. package/lib/owlly/view/camera-view.js +101 -0
  201. package/lib/owlly/view/index.d.ts +3 -0
  202. package/lib/owlly/view/index.js +5 -0
  203. package/lib/owlly/view/orthographic-view.d.ts +40 -0
  204. package/lib/owlly/view/orthographic-view.js +94 -0
  205. package/lib/owlly/view/perspective-view.d.ts +40 -0
  206. package/lib/owlly/view/perspective-view.js +95 -0
  207. package/lib/owlly/view/svg-map-view.d.ts +46 -0
  208. package/lib/owlly/view/svg-map-view.js +144 -0
  209. package/lib/owlly/view/view.d.ts +146 -0
  210. package/lib/owlly/view/view.js +317 -0
  211. package/lib/prod/owlly.esm.js +93462 -0
  212. package/lib/prod/owlly.esm.js.map +1 -0
  213. package/lib/prod/owlly.esm.min.js +54 -0
  214. package/lib/prod/owlly.iife.js +93560 -0
  215. package/lib/prod/owlly.iife.js.map +1 -0
  216. package/lib/prod/owlly.iife.min.js +69 -0
  217. package/lib/prod/owlly.miniapp.js +73845 -0
  218. package/lib/prod/owlly.miniapp.js.map +1 -0
  219. package/lib/prod/owlly.miniapp.min.js +63 -0
  220. package/lib/prod/src/external/lines/line-geometry.d.ts +9 -0
  221. package/lib/prod/src/external/lines/line-material.d.ts +10 -0
  222. package/lib/prod/src/external/lines/line-segments-2.d.ts +7 -0
  223. package/lib/prod/src/external/lines/line-segments-geometry.d.ts +15 -0
  224. package/lib/prod/src/external/loaders/gltf-loader.d.ts +77 -0
  225. package/lib/prod/src/external/orbit-controls.d.ts +44 -0
  226. package/lib/prod/src/external/renderers/css-2d-renderer.d.ts +16 -0
  227. package/lib/prod/src/external/renderers/css-3d-renderer.d.ts +18 -0
  228. package/lib/prod/src/external/transform-controls.d.ts +106 -0
  229. package/lib/prod/src/external/util/buffer-geometry-utils.d.ts +45 -0
  230. package/lib/prod/src/owlly/controller/aerial-element-controller.d.ts +65 -0
  231. package/lib/prod/src/owlly/controller/basic-controller.d.ts +324 -0
  232. package/lib/prod/src/owlly/controller/camera-controller.d.ts +37 -0
  233. package/lib/prod/src/owlly/controller/controller.d.ts +61 -0
  234. package/lib/prod/src/owlly/controller/index.d.ts +2 -0
  235. package/lib/prod/src/owlly/controller/mouse-indicator-controller.d.ts +34 -0
  236. package/lib/prod/src/owlly/controller/orbit-control.d.ts +147 -0
  237. package/lib/prod/src/owlly/controller/panorama-adjust-controller.d.ts +45 -0
  238. package/lib/prod/src/owlly/controller/panorama-controller.d.ts +441 -0
  239. package/lib/prod/src/owlly/controller/panorama-transform-controller.d.ts +66 -0
  240. package/lib/prod/src/owlly/controller/plane-controller.d.ts +43 -0
  241. package/lib/prod/src/owlly/controller/texture-controller.d.ts +183 -0
  242. package/lib/prod/src/owlly/controller/tile-panorama-controller.d.ts +308 -0
  243. package/lib/prod/src/owlly/controller/transform-controller.d.ts +106 -0
  244. package/lib/prod/src/owlly/element/bottom-nav-element.d.ts +65 -0
  245. package/lib/prod/src/owlly/element/camera.d.ts +82 -0
  246. package/lib/prod/src/owlly/element/dom-2d-element.d.ts +35 -0
  247. package/lib/prod/src/owlly/element/dom-3d-element.d.ts +27 -0
  248. package/lib/prod/src/owlly/element/dom-label-2d.d.ts +116 -0
  249. package/lib/prod/src/owlly/element/element.d.ts +53 -0
  250. package/lib/prod/src/owlly/element/floor-model.d.ts +83 -0
  251. package/lib/prod/src/owlly/element/gif-kit/Gif.d.ts +96 -0
  252. package/lib/prod/src/owlly/element/gif-kit/GifColor.d.ts +21 -0
  253. package/lib/prod/src/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.d.ts +20 -0
  254. package/lib/prod/src/owlly/element/gif-kit/GifFrame.d.ts +31 -0
  255. package/lib/prod/src/owlly/element/gif-kit/GifImage.d.ts +23 -0
  256. package/lib/prod/src/owlly/element/gif-kit/GifParser.d.ts +17 -0
  257. package/lib/prod/src/owlly/element/gif-kit/GifPresenter.d.ts +20 -0
  258. package/lib/prod/src/owlly/element/gif-kit/GifVersion.d.ts +10 -0
  259. package/lib/prod/src/owlly/element/gltf-mesh-element.d.ts +31 -0
  260. package/lib/prod/src/owlly/element/index.d.ts +6 -0
  261. package/lib/prod/src/owlly/element/map-kit/area.d.ts +24 -0
  262. package/lib/prod/src/owlly/element/map-kit/block-set.d.ts +39 -0
  263. package/lib/prod/src/owlly/element/map-kit/block.d.ts +77 -0
  264. package/lib/prod/src/owlly/element/map-kit/index.d.ts +3 -0
  265. package/lib/prod/src/owlly/element/map-kit/shape.d.ts +131 -0
  266. package/lib/prod/src/owlly/element/mesh-element.d.ts +22 -0
  267. package/lib/prod/src/owlly/element/mesh-line-2d.d.ts +82 -0
  268. package/lib/prod/src/owlly/element/meshline-o.d.ts +64 -0
  269. package/lib/prod/src/owlly/element/panorama-group.d.ts +241 -0
  270. package/lib/prod/src/owlly/element/panorama.d.ts +132 -0
  271. package/lib/prod/src/owlly/element/path-group.d.ts +69 -0
  272. package/lib/prod/src/owlly/element/path.d.ts +99 -0
  273. package/lib/prod/src/owlly/element/placeable-2d.d.ts +158 -0
  274. package/lib/prod/src/owlly/element/polygon-mesh.d.ts +107 -0
  275. package/lib/prod/src/owlly/element/ring-element.d.ts +79 -0
  276. package/lib/prod/src/owlly/element/sphere-mesh.d.ts +28 -0
  277. package/lib/prod/src/owlly/element/svg-floor-model.d.ts +22 -0
  278. package/lib/prod/src/owlly/element/svg-floors.d.ts +27 -0
  279. package/lib/prod/src/owlly/element/tile-panorama-group.d.ts +335 -0
  280. package/lib/prod/src/owlly/element/tile-panorama.d.ts +162 -0
  281. package/lib/prod/src/owlly/element/tile-plane.d.ts +114 -0
  282. package/lib/prod/src/owlly/element/video-element.d.ts +33 -0
  283. package/lib/prod/src/owlly/geometries/ExtrudeGeometry2.d.ts +15 -0
  284. package/lib/prod/src/owlly/index.d.ts +13 -0
  285. package/lib/prod/src/owlly/overlay/canvas-overlay.d.ts +96 -0
  286. package/lib/prod/src/owlly/overlay/css-2d-overlay.d.ts +14 -0
  287. package/lib/prod/src/owlly/overlay/css-3d-overlay.d.ts +16 -0
  288. package/lib/prod/src/owlly/overlay/index.d.ts +5 -0
  289. package/lib/prod/src/owlly/overlay/label-overlay.d.ts +62 -0
  290. package/lib/prod/src/owlly/overlay/overlay.d.ts +14 -0
  291. package/lib/prod/src/owlly/overlay/path-overlay.d.ts +39 -0
  292. package/lib/prod/src/owlly/overlay/path-overlay2.d.ts +35 -0
  293. package/lib/prod/src/owlly/overlay/poi-overlay-3d.d.ts +278 -0
  294. package/lib/prod/src/owlly/overlay/poi-overlay.d.ts +277 -0
  295. package/lib/prod/src/owlly/owlly-2d/index.d.ts +28 -0
  296. package/lib/prod/src/owlly/screen/index.d.ts +1 -0
  297. package/lib/prod/src/owlly/screen/screen.d.ts +73 -0
  298. package/lib/prod/src/owlly/stage/__test__/stage.spec.d.ts +1 -0
  299. package/lib/prod/src/owlly/stage/externals.d.ts +19 -0
  300. package/lib/prod/src/owlly/stage/index.d.ts +3 -0
  301. package/lib/prod/src/owlly/stage/owlly.d.ts +38 -0
  302. package/lib/prod/src/owlly/stage/stage.d.ts +108 -0
  303. package/lib/prod/src/owlly/utils/alignment-utils.d.ts +20 -0
  304. package/lib/prod/src/owlly/utils/basic-calc.d.ts +18 -0
  305. package/lib/prod/src/owlly/utils/basic-tools.d.ts +71 -0
  306. package/lib/prod/src/owlly/utils/bvh-tree.d.ts +105 -0
  307. package/lib/prod/src/owlly/utils/camera.d.ts +37 -0
  308. package/lib/prod/src/owlly/utils/cube-texture-cache.d.ts +25 -0
  309. package/lib/prod/src/owlly/utils/device-utils.d.ts +18 -0
  310. package/lib/prod/src/owlly/utils/environment-utils.d.ts +37 -0
  311. package/lib/prod/src/owlly/utils/event-hub.d.ts +50 -0
  312. package/lib/prod/src/owlly/utils/events.d.ts +219 -0
  313. package/lib/prod/src/owlly/utils/geometry-utils.d.ts +119 -0
  314. package/lib/prod/src/owlly/utils/helper.d.ts +6 -0
  315. package/lib/prod/src/owlly/utils/index.d.ts +13 -0
  316. package/lib/prod/src/owlly/utils/lru-cache.d.ts +26 -0
  317. package/lib/prod/src/owlly/utils/map-utils.d.ts +7 -0
  318. package/lib/prod/src/owlly/utils/number-utils.d.ts +8 -0
  319. package/lib/prod/src/owlly/utils/panorama-model-util.d.ts +46 -0
  320. package/lib/prod/src/owlly/utils/path-utils.d.ts +80 -0
  321. package/lib/prod/src/owlly/utils/svgutils.d.ts +138 -0
  322. package/lib/prod/src/owlly/utils/texture-cache.d.ts +29 -0
  323. package/lib/prod/src/owlly/utils/tile-util.d.ts +187 -0
  324. package/lib/prod/src/owlly/utils/time-profiler.d.ts +21 -0
  325. package/lib/prod/src/owlly/view/__test__/perspective-view.spec.d.ts +0 -0
  326. package/lib/prod/src/owlly/view/camera-view.d.ts +35 -0
  327. package/lib/prod/src/owlly/view/index.d.ts +3 -0
  328. package/lib/prod/src/owlly/view/orthographic-view.d.ts +40 -0
  329. package/lib/prod/src/owlly/view/perspective-view.d.ts +40 -0
  330. package/lib/prod/src/owlly/view/svg-map-view.d.ts +46 -0
  331. package/lib/prod/src/owlly/view/view.d.ts +146 -0
  332. package/lib/src/owlly/controller/texture-controller.d.ts +3 -1
  333. package/lib/src/owlly/controller/texture-controller.js +16 -1
  334. package/lib/src/owlly/controller/texture-controller.js.map +1 -1
  335. package/lib/src/owlly/controller/tile-panorama-controller.js +4 -0
  336. package/lib/src/owlly/controller/tile-panorama-controller.js.map +1 -1
  337. package/lib/src/owlly/element/tile-panorama.d.ts +1 -0
  338. package/lib/src/owlly/element/tile-panorama.js +16 -3
  339. package/lib/src/owlly/element/tile-panorama.js.map +1 -1
  340. package/lib/src/owlly/element/tile-plane.d.ts +9 -0
  341. package/lib/src/owlly/element/tile-plane.js +27 -0
  342. package/lib/src/owlly/element/tile-plane.js.map +1 -1
  343. package/lib/src/owlly/overlay/poi-overlay-3d.js.map +1 -1
  344. package/lib/src/owlly/overlay/poi-overlay.js.map +1 -1
  345. package/lib/src/owlly/stage/owlly.js +7 -1
  346. package/lib/src/owlly/stage/owlly.js.map +1 -1
  347. package/lib/src/owlly/stage/stage.js +2 -0
  348. package/lib/src/owlly/stage/stage.js.map +1 -1
  349. package/lib/src/web/main.rpeng.mes.plane.js.map +1 -1
  350. package/package.json +16 -7
  351. package/src/owlly/controller/texture-controller.ts +18 -1
  352. package/src/owlly/controller/tile-panorama-controller.ts +3 -1
  353. package/src/owlly/element/tile-panorama.ts +14 -0
  354. package/src/owlly/element/tile-plane.ts +26 -0
  355. package/src/owlly/overlay/poi-overlay-3d.ts +0 -4
  356. package/src/owlly/overlay/poi-overlay.ts +0 -4
  357. package/src/owlly/stage/owlly.ts +6 -1
  358. package/src/owlly/stage/stage.ts +2 -0
  359. package/src/web/main.rpeng.mes.plane.ts +0 -6
@@ -0,0 +1,63 @@
1
+ /* eslint-disable */
2
+ var getOwlly = function(THREE, optionals = {}){
3
+ var Konva = optionals ? optionals.Konva : undefined;
4
+
5
+ var Owlly=function(t,e,n){"use strict";n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;var i,r={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-r.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*r.Bounce.In(2*t):.5*r.Bounce.Out(2*t-1)+.5}}},s="undefined"==typeof self&&"undefined"!=typeof process&&process.hrtime?function(){var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:"undefined"!=typeof self&&void 0!==self.performance&&void 0!==self.performance.now?self.performance.now.bind(self.performance):void 0!==Date.now?Date.now:function(){return(new Date).getTime()},o=function(){function t(){this._tweens={},this._tweensAddedDuringUpdate={}}return t.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map((function(e){return t._tweens[e]}))},t.prototype.removeAll=function(){this._tweens={}},t.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},t.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},t.prototype.update=function(t,e){void 0===t&&(t=s()),void 0===e&&(e=!1);var n=Object.keys(this._tweens);if(0===n.length)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var r=this._tweens[n[i]],o=!e;r&&!1===r.update(t,o)&&!e&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},t}(),a={Linear:function(t,e){var n=t.length-1,i=n*e,r=Math.floor(i),s=a.Utils.Linear;return e<0?s(t[0],t[1],i):e>1?s(t[n],t[n-1],n-i):s(t[r],t[r+1>n?n:r+1],i-r)},Bezier:function(t,e){for(var n=0,i=t.length-1,r=Math.pow,s=a.Utils.Bernstein,o=0;o<=i;o++)n+=r(1-e,i-o)*r(e,o)*t[o]*s(i,o);return n},CatmullRom:function(t,e){var n=t.length-1,i=n*e,r=Math.floor(i),s=a.Utils.CatmullRom;return t[0]===t[n]?(e<0&&(r=Math.floor(i=n*(1+e))),s(t[(r-1+n)%n],t[r],t[(r+1)%n],t[(r+2)%n],i-r)):e<0?t[0]-(s(t[0],t[0],t[1],t[1],-i)-t[0]):e>1?t[n]-(s(t[n],t[n],t[n-1],t[n-1],i-n)-t[n]):s(t[r?r-1:0],t[r],t[n<r+1?n:r+1],t[n<r+2?n:r+2],i-r)},Utils:{Linear:function(t,e,n){return(e-t)*n+t},Bernstein:function(t,e){var n=a.Utils.Factorial;return n(t)/n(e)/n(t-e)},Factorial:function(){var t=[1];return function(e){var n=1;if(t[e])return t[e];for(var i=e;i>1;i--)n*=i;return t[e]=n,n}}(),CatmullRom:function(t,e,n,i,r){var s=.5*(n-t),o=.5*(i-e),a=r*r;return(2*e-2*n+s+o)*(r*a)+(-3*e+3*n-2*s-o)*a+s*r+e}}},l=function(){function t(){}return t.nextId=function(){return t._nextId++},t._nextId=0,t}(),h=new o,c=function(){function t(t,e){void 0===e&&(e=h),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=r.Linear.None,this._interpolationFunction=a.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._id=l.nextId(),this._isChainStopped=!1,this._goToEnd=!1}return t.prototype.getId=function(){return this._id},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isPaused=function(){return this._isPaused},t.prototype.to=function(t,e){return this._valuesEnd=Object.create(t),void 0!==e&&(this._duration=e),this},t.prototype.duration=function(t){return this._duration=t,this},t.prototype.start=function(t){if(this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var e in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(e),this._valuesStart[e]=this._valuesStartRepeat[e];return this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=void 0!==t?"string"==typeof t?s()+parseFloat(t):t:s(),this._startTime+=this._delayTime,this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat),this},t.prototype._setupProperties=function(t,e,n,i){for(var r in n){var s=t[r],o=Array.isArray(s),a=o?"array":typeof s,l=!o&&Array.isArray(n[r]);if("undefined"!==a&&"function"!==a){if(l){var h=n[r];if(0===h.length)continue;h=h.map(this._handleRelativeValue.bind(this,s)),n[r]=[s].concat(h)}if("object"!==a&&!o||!s||l)void 0===e[r]&&(e[r]=s),o||(e[r]*=1),i[r]=l?n[r].slice().reverse():e[r]||0;else{for(var c in e[r]=o?[]:{},s)e[r][c]=s[c];i[r]=o?[]:{},this._setupProperties(s,e[r],n[r],i[r])}}}},t.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},t.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},t.prototype.pause=function(t){return void 0===t&&(t=s()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this)),this},t.prototype.resume=function(t){return void 0===t&&(t=s()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this):this},t.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},t.prototype.group=function(t){return this._group=t,this},t.prototype.delay=function(t){return this._delayTime=t,this},t.prototype.repeat=function(t){return this._initialRepeat=t,this._repeat=t,this},t.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},t.prototype.yoyo=function(t){return this._yoyo=t,this},t.prototype.easing=function(t){return this._easingFunction=t,this},t.prototype.interpolation=function(t){return this._interpolationFunction=t,this},t.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},t.prototype.onStart=function(t){return this._onStartCallback=t,this},t.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},t.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},t.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},t.prototype.onStop=function(t){return this._onStopCallback=t,this},t.prototype.update=function(t,e){if(void 0===t&&(t=s()),void 0===e&&(e=!0),this._isPaused)return!0;var n,i,r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>r)return!1;e&&this.start(t)}if(this._goToEnd=!1,t<this._startTime)return!0;!1===this._onStartCallbackFired&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),i=(t-this._startTime)/this._duration,i=0===this._duration||i>1?1:i;var o=this._easingFunction(i);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,o),this._onUpdateCallback&&this._onUpdateCallback(this._object,i),1===i){if(this._repeat>0){for(n in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[n]||(this._valuesStartRepeat[n]=this._valuesStartRepeat[n]+parseFloat(this._valuesEnd[n])),this._yoyo&&this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];return this._yoyo&&(this._reversed=!this._reversed),void 0!==this._repeatDelayTime?this._startTime=t+this._repeatDelayTime:this._startTime=t+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var a=0,l=this._chainedTweens.length;a<l;a++)this._chainedTweens[a].start(this._startTime+this._duration);return this._isPlaying=!1,!1}return!0},t.prototype._updateProperties=function(t,e,n,i){for(var r in n)if(void 0!==e[r]){var s=e[r]||0,o=n[r],a=Array.isArray(t[r]),l=Array.isArray(o);!a&&l?t[r]=this._interpolationFunction(o,i):"object"==typeof o&&o?this._updateProperties(t[r],s,o,i):"number"==typeof(o=this._handleRelativeValue(s,o))&&(t[r]=s+(o-s)*i)}},t.prototype._handleRelativeValue=function(t,e){return"string"!=typeof e?e:"+"===e.charAt(0)||"-"===e.charAt(0)?t+parseFloat(e):parseFloat(e)},t.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],n=this._valuesEnd[t];this._valuesStartRepeat[t]="string"==typeof n?this._valuesStartRepeat[t]+parseFloat(n):this._valuesEnd[t],this._valuesEnd[t]=e},t}(),u=l.nextId,d=h,p=d.getAll.bind(d),f=d.removeAll.bind(d),m=d.add.bind(d),g=d.remove.bind(d),v=d.update.bind(d),y={Easing:r,Group:o,Interpolation:a,now:s,Sequence:l,nextId:u,Tween:c,VERSION:"18.6.4",getAll:p,removeAll:f,add:m,remove:g,update:v};class x{setKonvaInstance(t){this.Konva=t}setThreeInstance(t){this.THREE=t}static getInstance(){return this.instance||(this.instance=new x),this.instance}}class b{constructor(){this.eventMap=new Map}on(t,e){this.eventMap.has(t)||this.eventMap.set(t,new Set);const n=this.eventMap.get(t);n&&(n.add(e),this.eventMap.set(t,n))}emit(t,...e){const n=this.eventMap.get(t);n&&n.forEach(t=>{t(...e)})}off(t,e){const n=this.eventMap.get(t);n&&n.delete(e)}static on(t,e){b.hub||(b.hub=new b),b.hub.on(t,e)}static emit(t,...e){b.hub||(b.hub=new b),b.hub.emit(t,...e)}static off(t,e){b.hub||(b.hub=new b),b.hub.off(t,e)}static remove(t,e){console.warn("EventHub.remove() will be removed in future releases. Use EventHub.off() instead."),b.off(t,e)}}class w{constructor(){this.eventMap=new Map}on(t,e){this.eventMap.has(t)||this.eventMap.set(t,new Set);const n=this.eventMap.get(t);n&&(n.add(e),this.eventMap.set(t,n))}emit(t,...e){const n=this.eventMap.get(t);n&&n.forEach(t=>{t(...e)}),b.emit(t,...e)}off(t,e){const n=this.eventMap.get(t);n&&n.delete(e)}}class M{}M.ELEMENT_SELECTED="element-selected",M.ELEMENT_POSITION_UPDATED="element-position-updated",M.ELEMENT_POSE_UPDATED="element-pose-updated",M.CAMERA_CHANGED="camera-changed",M.CAMERA_ZOOM="camera-zoom",M.PANORAMA_CAMERA_CHANGED="panorama-camera-changed",M.ORBIT_CAMERA_CHANGED="orbit-camera-changed",M.PANORAMA_PRESENTED="panorama-presented",M.PANORAMA_SELECTED="panorama-selected",M.PANORAMA_HOVER="panorama-hover",M.ELEMENT_LOADED="element-loaded",M.ELEMENT_LOADED_ERROR="o/element-loaded-error",M.CLICK_PANORAMA="click-panorama",M.MOVE_TO_PANORAMA="move-to-panorama",M.WILL_MOVE_TO_PANORAMA="will-move-to-panorama",M.PATH_MOVEMENT_START="path-movement-start",M.PATH_MOVEMENT_COMPLETED="path-movement-completed",M.WILL_LOAD_PANORAMA="will-load-panorama",M.DID_LOAD_PANORAMA="did-load-panorama",M.TRANSFORM_ACTIVATED="transform-activated",M.TRANSFORM_DEACTIVATED="transform-deactivated",M.FPS_UPDATED="fps-updated",M.GET_PLANE_INTERSECT="get-plane-intersect",M.POI_CLICKED="poi-clicked",M.POI_DOWN="poi-down",M.POI_UP="poi-up",M.CANVAS_VERTEX_CLICKED="canvas-vertex-clicked",M.CANVAS_VERTEX_DOWN="canvas-vertex-down",M.CANVAS_VERTEX_UP="canvas-vertex-up",M.LABEL_ICONS_POSITION_UPDATED="label-icons-position-updated",M.LABEL_DOWN="label-down",M.TICK="tick",M.VIEW_RENDERED="view-rendered";class _{}_.ELEMENT_SELECTED="o/element-selected",_.RENDERING_VIEW_CHANGED="o/rendering-view-changed",_.DISPOSE_ELEMENT="o/dispose-element",_.ELEMENT_LOADED="o/element-loaded",_.ELEMENT_POSITION_UPDATED="o/element-position-updated",_.MOUSE_DOWN="o/mouse-down",_.MOUSE_UP="o/mouse-up",_.MOUSE_MOVE="o/mouse-move",_.MOUSE_WHEEL="o/mouse-wheel",_.TOUCH_START="o/touch-start",_.TOUCH_MOVE="o/touch-move",_.TOUCH_END="o/touch-end",_.CONTEXT_MENU="o/context-menu",_.DBLCLICK="o/dblclick";class E{constructor(t=1e3){this.timingIntervalMills=t,this.frameTimeMillses=[]}reset(){this.frameTimeMillses=[],this.fps=void 0}tick(t){if(this.timingIntervalMills<=0)0===this.frameTimeMillses.length?this.frameTimeMillses.push(t,0):(this.frameTimeMillses[1]+=1,this.fps=1e3*this.frameTimeMillses[1]/(t-this.frameTimeMillses[0]));else{this.frameTimeMillses.push(t);const e=this.frameTimeMillses.length-1;if(e>0){let t=this.frameTimeMillses[this.frameTimeMillses.length-1]-this.frameTimeMillses[0];for(this.fps=1e3*e/t;t>this.timingIntervalMills;)this.frameTimeMillses.shift(),t=this.frameTimeMillses[this.frameTimeMillses.length-1]-this.frameTimeMillses[0]}}}getFPS(){return this.fps}}(i=t.Env||(t.Env={}))[i.Web=0]="Web",i[i.Miniapp=1]="Miniapp";class S{static SetEnv(t){S.ENV=t}static GetEnv(){if(void 0===S.ENV)try{wx,S.ENV=t.Env.Web}catch(t){}finally{void 0===S.ENV&&(S.ENV=t.Env.Web)}return S.ENV}static SetGlobalDPR(t){S.DPR=t}static GetGlobalDPR(){if(!S.DPR){let e;if(S.GetEnv()===t.Env.Miniapp){e=wx.getSystemInfoSync().pixelRatio}else e=window.devicePixelRatio;S.DPR=e}return S.DPR}}let T,A,P;class L{constructor(){this.stages=new Set,this.screens=new Set,this.controllers=new Set,this.timeProfiler=new E,this.selfManageTick=!0,this.listeners={windowResizeListener:()=>{this.onWindowResize()},windowUnloadListener:()=>{this.beforeWindowUnload()},onTick:this.tick.bind(this)},this.registerEvents(),S.GetEnv()===t.Env.Web&&requestAnimationFrame&&this.setRequestAnimationFrameFunction(requestAnimationFrame)}static GetSharedInstance(){return this.SHARED_INSTANCE||(this.SHARED_INSTANCE=new L),this.SHARED_INSTANCE}tick(t){this.timeProfiler.tick(t),b.emit(M.TICK);const e=Array.from(this.screens).reduce((t,e)=>e.update()||t,!1),n=Array.from(this.controllers).reduce((t,e)=>e.update()||t,!1),i=Array.from(this.stages).reduce((t,e)=>e.tick()||t,!1);(this.forceRender||e||n||i)&&this.screens.forEach(t=>{t.renderScreen()}),y.update(),this.selfManageTick&&L.RequestAnimationFrame(this.listeners.onTick)}registerEvents(){S.GetEnv()===t.Env.Web&&window.addEventListener("resize",this.listeners.windowResizeListener)}onWindowResize(){this.screens.forEach(t=>{t.container?t.resize(t.container.clientWidth,t.container.clientHeight):t.resize(window.innerWidth,window.innerHeight)}),this.forceRender=!0}beforeWindowUnload(){Array.from(this.stages).forEach(t=>{t.dispose()}),window&&window.removeEventListener("resize",this.listeners.windowResizeListener)}registerStage(t){this.stages.add(t)}unregisterStage(t){this.stages.delete(t)}registerScreen(t){this.screens.add(t)}unregisterScreen(t){this.screens.delete(t)}registerController(t){this.controllers.add(t)}unregisterController(t){this.controllers.delete(t)}setStatsEnabled(e){S.GetEnv(),t.Env.Web}setRequestAnimationFrameFunction(e){L.RequestAnimationFrame=e.bind(S.GetEnv()===t.Env.Web?window.IS_DELEGATE?window.delegateWindow:window:this),this.selfManageTick&&L.RequestAnimationFrame(this.listeners.onTick)}toggleTickSelfManagement(t){this.selfManageTick!==t&&(this.selfManageTick=t,this.selfManageTick&&L.RequestAnimationFrame(this.listeners.onTick))}renderNextFrame(){this.forceRender=!0}}class R extends w{constructor(t,e=!0){super(),this.overlays=[],this.enabled=!0,this.renderStage=e,this.renderOrder=0,this.listeners={mouseDown:this.mouseDown.bind(this),mouseMove:this.mouseMove.bind(this),mouseUp:this.mouseUp.bind(this),mouseWheel:this.mouseWheel.bind(this),touchStart:this.touchStart.bind(this),touchMove:this.touchMove.bind(this),touchEnd:this.touchEnd.bind(this),contextMenu:this.contextMenu.bind(this),dblclick:this.dblclick.bind(this)};const{THREE:n}=x.getInstance();this.rendererOffsetDefault=new n.Vector4(0,0,0,0),t&&this.bindScreen(t)}mouseDown(t){this.isInView(t.offsetX,t.offsetY)&&this.emit(_.MOUSE_DOWN,t)}mouseMove(t){this.emit(_.MOUSE_MOVE,t)}mouseUp(t){this.emit(_.MOUSE_UP,t)}mouseWheel(t){this.isInView(t.offsetX,t.offsetY)&&this.emit(_.MOUSE_WHEEL,t)}touchStart(t){this.isTouchInView(t)&&this.emit(_.TOUCH_START,t)}touchMove(t){this.emit(_.TOUCH_MOVE,t)}touchEnd(t){this.emit(_.TOUCH_END,t)}contextMenu(t){this.isInView(t.offsetX,t.offsetY)&&this.emit(_.CONTEXT_MENU,t)}dblclick(t){this.emit(_.DBLCLICK,t)}set render3D(t){this.renderStage=t}get container(){if(!this.parent)throw new Error("will be removed");return this.parent.container}get canvas(){if(!this.parent)throw new Error("will be removed");return this.parent.canvas}isInView(t,e){const{x:n,y:i,z:r,w:s}=this.rendererOffset||this.rendererOffsetDefault,o=this.parent.height-e;return t>n&&t<n+r&&o>i&&o<i+s}isTouchInView(t){let e=!1;const n=t.target;if(!t.target)return e;const i=n.getBoundingClientRect();for(let n=0;n<t.touches.length;n++)if(this.isInView(t.touches[n].clientX-i.x,t.touches[n].clientY-i.y)){e=!0;break}return e}bindScreen(t){this.parent&&this.unbindScreen(),this.parent=t,this.registerScreenEvents(),this.parent.addView(this),this.renderer=this.parent.renderer;const{THREE:e}=x.getInstance();this.rendererOffsetDefault=new e.Vector4(0,0,this.parent.width,this.parent.height)}unbindScreen(){this.parent&&(this.unregisterScreenEvents(),this.parent.removeView(this),this.parent=null,this.renderer=null)}registerScreenEvents(){this.parent&&(this.parent.on(_.MOUSE_DOWN,this.listeners.mouseDown),this.parent.on(_.MOUSE_MOVE,this.listeners.mouseMove),this.parent.on(_.MOUSE_UP,this.listeners.mouseUp),this.parent.on(_.MOUSE_WHEEL,this.listeners.mouseWheel),this.parent.on(_.TOUCH_START,this.listeners.touchStart),this.parent.on(_.TOUCH_MOVE,this.listeners.touchMove),this.parent.on(_.TOUCH_END,this.listeners.touchEnd),this.parent.on(_.CONTEXT_MENU,this.listeners.contextMenu),this.parent.on(_.DBLCLICK,this.listeners.dblclick))}unregisterScreenEvents(){this.parent&&(this.parent.off(_.MOUSE_DOWN,this.listeners.mouseDown),this.parent.off(_.MOUSE_MOVE,this.listeners.mouseMove),this.parent.off(_.MOUSE_UP,this.listeners.mouseUp),this.parent.off(_.MOUSE_WHEEL,this.listeners.mouseWheel),this.parent.off(_.TOUCH_START,this.listeners.touchStart),this.parent.off(_.TOUCH_MOVE,this.listeners.touchMove),this.parent.off(_.TOUCH_END,this.listeners.touchEnd),this.parent.off(_.CONTEXT_MENU,this.listeners.contextMenu),this.parent.off(_.DBLCLICK,this.listeners.dblclick))}dispose(){this.overlays.forEach(t=>{t.dispose()}),this.overlays=[],this.unbindScreen()}addOverlay(t){t.init(this),this.overlays.push(t)}removeOverlay(t){const e=this.overlays.indexOf(t);-1!==e&&(t.dispose(),this.overlays.splice(e,1))}resize(t,e){const{z:n,w:i}=this.rendererOffsetDefault;if(this.rendererOffsetDefault.set(0,0,t,e),this.rendererOffset){const t=this.rendererOffset.z/n,e=this.rendererOffset.w/i,{THREE:r}=x.getInstance();this.rendererOffset.multiply(new r.Vector4(t,e,t,e))}this.overlays.forEach(n=>n.resize&&n.resize(t,e))}update(){if(!this.enabled)return!1;let t=!1;return t=this.overlays.reduce((t,e)=>e.update()||t,!1),t}renderView(){this.enabled&&this.renderStage&&(this.stage.resizeElements(this.getViewWidth(),this.getViewHeight()),this.stage.renderElements(),this.renderer&&this.renderer.clearDepth(),this.render(),this.overlays.forEach(t=>{t instanceof Yp&&t.forceRenderInThisFrame(),t.render()}))}setEnabled(t){this.enabled=t}bindStage(t){this.stage=t}setViewport(t){this.rendererOffset=t,this.parent||console.warn("view.setViewport() is before bind screen")}setRendererPort(){if(!this.renderer||!this.rendererOffset)return;const t=this.renderer;t.setScissorTest(!0),t.setViewport(this.rendererOffset.x,this.rendererOffset.y,this.rendererOffset.z,this.rendererOffset.w),t.setScissor(this.rendererOffset.x,this.rendererOffset.y,this.rendererOffset.z,this.rendererOffset.w),t.setScissorTest(!1)}clearRendererPort(){if(!this.renderer||!this.rendererOffset)return;const t=this.renderer;t.setScissorTest(!0),t.setViewport(this.rendererOffsetDefault),t.setScissor(this.rendererOffsetDefault),t.setScissorTest(!1)}getViewWidth(){return this.rendererOffset?this.rendererOffset.z:this.rendererOffsetDefault.z}getViewHeight(){return this.rendererOffset?this.rendererOffset.w:this.rendererOffsetDefault.w}getViewOffset(){return this.rendererOffset?[this.rendererOffset.x,this.rendererOffset.y]:[this.rendererOffsetDefault.x,this.rendererOffsetDefault.y]}setRenderOrder(t){this.renderOrder=t||0}}class C extends w{}function I(){}function O(t,e){return Math.floor(Math.random()*(e-t+1))+t}I.maxFromBits=function(t){return Math.pow(2,t)},I.limitUI04=I.maxFromBits(4),I.limitUI06=I.maxFromBits(6),I.limitUI08=I.maxFromBits(8),I.limitUI12=I.maxFromBits(12),I.limitUI14=I.maxFromBits(14),I.limitUI16=I.maxFromBits(16),I.limitUI32=I.maxFromBits(32),I.limitUI40=I.maxFromBits(40),I.limitUI48=I.maxFromBits(48),I.randomUI04=function(){return O(0,I.limitUI04-1)},I.randomUI06=function(){return O(0,I.limitUI06-1)},I.randomUI08=function(){return O(0,I.limitUI08-1)},I.randomUI12=function(){return O(0,I.limitUI12-1)},I.randomUI14=function(){return O(0,I.limitUI14-1)},I.randomUI16=function(){return O(0,I.limitUI16-1)},I.randomUI32=function(){return O(0,I.limitUI32-1)},I.randomUI40=function(){return(0|Math.random()*(1<<30))+(0|1024*Math.random())*(1<<30)},I.randomUI48=function(){return(0|Math.random()*(1<<30))+(0|Math.random()*(1<<18))*(1<<30)},I.paddedString=function(t,e,n){n=n||"0";for(var i=e-(t=String(t)).length;i>0;i>>>=1,n+=n)1&i&&(t=n+t);return t},I.prototype.fromParts=function(t,e,n,i,r,s){return this.version=n>>12&15,this.hex=I.paddedString(t.toString(16),8)+"-"+I.paddedString(e.toString(16),4)+"-"+I.paddedString(n.toString(16),4)+"-"+I.paddedString(i.toString(16),2)+I.paddedString(r.toString(16),2)+"-"+I.paddedString(s.toString(16),12),this},I.prototype.toString=function(){return this.hex},I.prototype.toURN=function(){return"urn:uuid:"+this.hex},I.prototype.toBytes=function(){for(var t=this.hex.split("-"),e=[],n=0,i=0;i<t.length;i++)for(var r=0;r<t[i].length;r+=2)e[n++]=parseInt(t[i].substr(r,2),16);return e},I.prototype.equals=function(t){return t instanceof UUID&&this.hex===t.hex},I.getTimeFieldValues=function(t){var e=t-Date.UTC(1582,9,15),n=e/4294967296*1e4&268435455;return{low:1e4*(268435455&e)%4294967296,mid:65535&n,hi:n>>>16,timestamp:e}},I._create4=function(){return(new I).fromParts(I.randomUI32(),I.randomUI16(),16384|I.randomUI12(),128|I.randomUI06(),I.randomUI08(),I.randomUI48())},I._create1=function(){var t=(new Date).getTime(),e=I.randomUI14(),n=1099511627776*(1|I.randomUI08())+I.randomUI40(),i=I.randomUI04(),r=0;t!=r?(t<r&&e++,r=t,i=I.randomUI04()):Math.random()<1/4&&i<9984?i+=1+I.randomUI04():e++;var s=I.getTimeFieldValues(r),o=s.low+i,a=4095&s.hi|4096,l=(e&=16383)>>>8|128,h=255&e;return(new I).fromParts(o,s.mid,a,l,h,n)},I.create=function(t){return this["_create"+(t=t||4)]()},I.fromTime=function(t,e){e=e||!1;var n=I.getTimeFieldValues(t),i=n.low,r=4095&n.hi|4096;return!1===e?(new I).fromParts(i,n.mid,r,0,0,0):(new I).fromParts(i,n.mid,r,128|I.limitUI06,I.limitUI08-1,I.limitUI48-1)},I.firstFromTime=function(t){return I.fromTime(t,!1)},I.lastFromTime=function(t){return I.fromTime(t,!0)},I.fromURN=function(t){var e;return(e=/^(?:urn:uuid:|\{)?([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})(?:\})?$/i.exec(t))?(new I).fromParts(parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16),parseInt(e[4],16),parseInt(e[5],16),parseInt(e[6],16)):null},I.fromBytes=function(t){if(t.length<5)return null;for(var e="",n=0,i=[4,2,2,2,6],r=0;r<i.length;r++){for(var s=0;s<i[r];s++){var o=t[n++].toString(16);1==o.length&&(o="0"+o),e+=o}6!==i[r]&&(e+="-")}return I.fromURN(e)},I.fromBinary=function(t){for(var e=[],n=0;n<t.length;n++)if(e[n]=t.charCodeAt(n),e[n]>255||e[n]<0)throw new Error("Unexpected byte in binary data.");return I.fromBytes(e)},I.new=function(){return this.create(4)},I.newTS=function(){return this.create(1)};var D=I;function z(t,e){return t(e={exports:{}},e.exports),e.exports}var N=z((function(t){!function(){var e=Math.abs,n=Math.cos,i=Math.sin,r=Math.acos,s=Math.atan2,o=Math.sqrt,a=Math.pow,l=function(t){return t<0?-a(-t,1/3):a(t,1/3)},h=Math.PI,c=2*h,u=h/2,d=Number.MAX_SAFE_INTEGER||9007199254740991,p=Number.MIN_SAFE_INTEGER||-9007199254740991,f={x:0,y:0,z:0},m={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(t,e){var n=e(t),i=n.x*n.x+n.y*n.y;return void 0!==n.z&&(i+=n.z*n.z),o(i)},compute:function(t,e,n){if(0===t)return e[0];var i=e.length-1;if(1===t)return e[i];var r=e,s=1-t;if(0===i)return e[0];if(1===i)return d={x:s*r[0].x+t*r[1].x,y:s*r[0].y+t*r[1].y},n&&(d.z=s*r[0].z+t*r[1].z),d;if(i<4){var o,a,l,h=s*s,c=t*t,u=0;2===i?(r=[r[0],r[1],r[2],f],o=h,a=s*t*2,l=c):3===i&&(o=h*s,a=h*t*3,l=s*c*3,u=t*c);var d={x:o*r[0].x+a*r[1].x+l*r[2].x+u*r[3].x,y:o*r[0].y+a*r[1].y+l*r[2].y+u*r[3].y};return n&&(d.z=o*r[0].z+a*r[1].z+l*r[2].z+u*r[3].z),d}for(var p=JSON.parse(JSON.stringify(e));p.length>1;){for(var m=0;m<p.length-1;m++)p[m]={x:p[m].x+(p[m+1].x-p[m].x)*t,y:p[m].y+(p[m+1].y-p[m].y)*t},void 0!==p[m].z&&(p[m]=p[m].z+(p[m+1].z-p[m].z)*t);p.splice(p.length-1,1)}return p[0]},computeWithRatios:function(t,e,n,i){var r,s=1-t,o=n,a=e,l=o[0],h=o[1],c=o[2],u=o[3];return l*=s,h*=t,2===a.length?(r=l+h,{x:(l*a[0].x+h*a[1].x)/r,y:(l*a[0].y+h*a[1].y)/r,z:!!i&&(l*a[0].z+h*a[1].z)/r}):(l*=s,h*=2*s,c*=t*t,3===a.length?(r=l+h+c,{x:(l*a[0].x+h*a[1].x+c*a[2].x)/r,y:(l*a[0].y+h*a[1].y+c*a[2].y)/r,z:!!i&&(l*a[0].z+h*a[1].z+c*a[2].z)/r}):(l*=s,h*=1.5*s,c*=3*s,u*=t*t*t,4===a.length?(r=l+h+c+u,{x:(l*a[0].x+h*a[1].x+c*a[2].x+u*a[3].x)/r,y:(l*a[0].y+h*a[1].y+c*a[2].y+u*a[3].y)/r,z:!!i&&(l*a[0].z+h*a[1].z+c*a[2].z+u*a[3].z)/r}):void 0))},derive:function(t,e){for(var n=[],i=t,r=i.length,s=r-1;r>1;r--,s--){for(var o,a=[],l=0;l<s;l++)o={x:s*(i[l+1].x-i[l].x),y:s*(i[l+1].y-i[l].y)},e&&(o.z=s*(i[l+1].z-i[l].z)),a.push(o);n.push(a),i=a}return n},between:function(t,e,n){return e<=t&&t<=n||m.approximately(t,e)||m.approximately(t,n)},approximately:function(t,n,i){return e(t-n)<=(i||1e-6)},length:function(t){var e,n,i=0,r=m.Tvalues.length;for(e=0;e<r;e++)n=.5*m.Tvalues[e]+.5,i+=m.Cvalues[e]*m.arcfn(n,t);return.5*i},map:function(t,e,n,i,r){return i+(r-i)*((t-e)/(n-e))},lerp:function(t,e,n){var i={x:e.x+t*(n.x-e.x),y:e.y+t*(n.y-e.y)};return e.z&&n.z&&(i.z=e.z+t*(n.z-e.z)),i},pointToString:function(t){var e=t.x+"/"+t.y;return void 0!==t.z&&(e+="/"+t.z),e},pointsToString:function(t){return"["+t.map(m.pointToString).join(", ")+"]"},copy:function(t){return JSON.parse(JSON.stringify(t))},angle:function(t,e,n){var i=e.x-t.x,r=e.y-t.y,o=n.x-t.x,a=n.y-t.y;return s(i*a-r*o,i*o+r*a)},round:function(t,e){var n=""+t,i=n.indexOf(".");return parseFloat(n.substring(0,i+1+e))},dist:function(t,e){var n=t.x-e.x,i=t.y-e.y;return o(n*n+i*i)},closest:function(t,e){var n,i,r=a(2,63);return t.forEach((function(t,s){(i=m.dist(e,t))<r&&(r=i,n=s)})),{mdist:r,mpos:n}},abcratio:function(t,n){if(2!==n&&3!==n)return!1;if(void 0===t)t=.5;else if(0===t||1===t)return t;var i=a(t,n)+a(1-t,n);return e((i-1)/i)},projectionratio:function(t,e){if(2!==e&&3!==e)return!1;if(void 0===t)t=.5;else if(0===t||1===t)return t;var n=a(1-t,e);return n/(a(t,e)+n)},lli8:function(t,e,n,i,r,s,o,a){var l=(t-n)*(s-a)-(e-i)*(r-o);return 0!=l&&{x:((t*i-e*n)*(r-o)-(t-n)*(r*a-s*o))/l,y:((t*i-e*n)*(s-a)-(e-i)*(r*a-s*o))/l}},lli4:function(t,e,n,i){var r=t.x,s=t.y,o=e.x,a=e.y,l=n.x,h=n.y,c=i.x,u=i.y;return m.lli8(r,s,o,a,l,h,c,u)},lli:function(t,e){return m.lli4(t,t.c,e,e.c)},makeline:function(t,e){var n=H,i=t.x,r=t.y,s=e.x,o=e.y,a=(s-i)/3,l=(o-r)/3;return new n(i,r,i+a,r+l,i+2*a,r+2*l,s,o)},findbbox:function(t){var e=d,n=d,i=p,r=p;return t.forEach((function(t){var s=t.bbox();e>s.x.min&&(e=s.x.min),n>s.y.min&&(n=s.y.min),i<s.x.max&&(i=s.x.max),r<s.y.max&&(r=s.y.max)})),{x:{min:e,mid:(e+i)/2,max:i,size:i-e},y:{min:n,mid:(n+r)/2,max:r,size:r-n}}},shapeintersections:function(t,e,n,i,r){if(!m.bboxoverlap(e,i))return[];var s=[],o=[t.startcap,t.forward,t.back,t.endcap],a=[n.startcap,n.forward,n.back,n.endcap];return o.forEach((function(e){e.virtual||a.forEach((function(i){if(!i.virtual){var o=e.intersects(i,r);o.length>0&&(o.c1=e,o.c2=i,o.s1=t,o.s2=n,s.push(o))}}))})),s},makeshape:function(t,e,n){var i=e.points.length,r=t.points.length,s=m.makeline(e.points[i-1],t.points[0]),o=m.makeline(t.points[r-1],e.points[0]),a={startcap:s,forward:t,back:e,endcap:o,bbox:m.findbbox([s,t,e,o])},l=m;return a.intersections=function(t){return l.shapeintersections(a,a.bbox,t,t.bbox,n)},a},getminmax:function(t,e,n){if(!n)return{min:0,max:0};var i,r,s=d,o=p;-1===n.indexOf(0)&&(n=[0].concat(n)),-1===n.indexOf(1)&&n.push(1);for(var a=0,l=n.length;a<l;a++)i=n[a],(r=t.get(i))[e]<s&&(s=r[e]),r[e]>o&&(o=r[e]);return{min:s,mid:(s+o)/2,max:o,size:o-s}},align:function(t,e){var r=e.p1.x,o=e.p1.y,a=-s(e.p2.y-o,e.p2.x-r);return t.map((function(t){return{x:(t.x-r)*n(a)-(t.y-o)*i(a),y:(t.x-r)*i(a)+(t.y-o)*n(a)}}))},roots:function(t,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};var i=t.length-1,s=m.align(t,e),a=function(t){return 0<=t&&t<=1};if(2===i){if(0!==(g=(v=s[0].y)-2*(y=s[1].y)+(x=s[2].y))){var h=-o(y*y-v*x),u=-v+y;return[-(h+u)/g,-(-h+u)/g].filter(a)}return y!==x&&0===g?[(2*y-x)/(2*y-2*x)].filter(a):[]}var d=s[0].y,p=s[1].y,f=s[2].y,g=3*p-d-3*f+s[3].y,v=3*d-6*p+3*f,y=-3*d+3*p,x=d;if(m.approximately(g,0)){if(m.approximately(v,0))return m.approximately(y,0)?[]:[-x/y].filter(a);var b=2*v;return[((w=o(y*y-4*v*x))-y)/b,(-y-w)/b].filter(a)}var w,M,_=(s=(3*(y/=g)-(v/=g)*v)/3)/3,E=(w=(2*v*v*v-9*v*y+27*(x/=g))/27)/2,S=E*E+_*_*_;if(S<0){var T=-s/3,A=o(T*T*T),P=-w/(2*A),L=r(P<-1?-1:P>1?1:P),R=2*l(A);return[R*n(L/3)-v/3,R*n((L+c)/3)-v/3,R*n((L+2*c)/3)-v/3].filter(a)}if(0===S)return[2*(M=E<0?l(-E):-l(E))-v/3,-M-v/3].filter(a);var C=o(S);return[(M=l(-E+C))-l(E+C)-v/3].filter(a)},droots:function(t){if(3===t.length){var e=t[0],n=t[1],i=t[2],r=e-2*n+i;if(0!==r){var s=-o(n*n-e*i),a=-e+n;return[-(s+a)/r,-(-s+a)/r]}return n!==i&&0===r?[(2*n-i)/(2*(n-i))]:[]}if(2===t.length)return(e=t[0])!==(n=t[1])?[e/(e-n)]:[]},curvature:function(t,n,i,r){var s,l,h,c,u,d,p=m.derive(n),f=p[0],g=p[1],v=m.compute(t,f),y=m.compute(t,g),x=v.x*v.x+v.y*v.y;if(i?(s=o(a(v.y*y.z-y.y*v.z,2)+a(v.z*y.x-y.z*v.x,2)+a(v.x*y.y-y.x*v.y,2)),l=a(x+v.z*v.z,1.5)):(s=v.x*y.y-v.y*y.x,l=a(x,1.5)),0===s||0===l)return{k:0,r:0};if(u=s/l,d=l/s,!r){var b=m.curvature(t-.001,n,i,!0).k,w=m.curvature(t+.001,n,i,!0).k;c=(w-u+(u-b))/2,h=(e(w-u)+e(u-b))/2}return{k:u,r:d,dk:c,adk:h}},inflections:function(t){if(t.length<4)return[];var e=m.align(t,{p1:t[0],p2:t.slice(-1)[0]}),n=e[2].x*e[1].y,i=e[3].x*e[1].y,r=e[1].x*e[2].y,s=18*(-3*n+2*i+3*r-(u=e[3].x*e[2].y)),o=18*(3*n-i-3*r),a=18*(r-n);if(m.approximately(s,0)){if(!m.approximately(o,0)){var l=-a/o;if(0<=l&&l<=1)return[l]}return[]}var h=o*o-4*s*a,c=Math.sqrt(h),u=2*s;return m.approximately(u,0)?[]:[(c-o)/u,-(o+c)/u].filter((function(t){return 0<=t&&t<=1}))},bboxoverlap:function(t,n){var i,r,s,o,a,l=["x","y"],h=l.length;for(i=0;i<h;i++)if(s=t[r=l[i]].mid,o=n[r].mid,a=(t[r].size+n[r].size)/2,e(s-o)>=a)return!1;return!0},expandbox:function(t,e){e.x.min<t.x.min&&(t.x.min=e.x.min),e.y.min<t.y.min&&(t.y.min=e.y.min),e.z&&e.z.min<t.z.min&&(t.z.min=e.z.min),e.x.max>t.x.max&&(t.x.max=e.x.max),e.y.max>t.y.max&&(t.y.max=e.y.max),e.z&&e.z.max>t.z.max&&(t.z.max=e.z.max),t.x.mid=(t.x.min+t.x.max)/2,t.y.mid=(t.y.min+t.y.max)/2,t.z&&(t.z.mid=(t.z.min+t.z.max)/2),t.x.size=t.x.max-t.x.min,t.y.size=t.y.max-t.y.min,t.z&&(t.z.size=t.z.max-t.z.min)},pairiteration:function(t,e,n){var i=t.bbox(),r=e.bbox(),s=1e5,o=n||.5;if(i.x.size+i.y.size<o&&r.x.size+r.y.size<o)return[(s*(t._t1+t._t2)/2|0)/s+"/"+(s*(e._t1+e._t2)/2|0)/s];var a=t.split(.5),l=e.split(.5),h=[{left:a.left,right:l.left},{left:a.left,right:l.right},{left:a.right,right:l.right},{left:a.right,right:l.left}];h=h.filter((function(t){return m.bboxoverlap(t.left.bbox(),t.right.bbox())}));var c=[];return 0===h.length?c:(h.forEach((function(t){c=c.concat(m.pairiteration(t.left,t.right,o))})),c=c.filter((function(t,e){return c.indexOf(t)===e})))},getccenter:function(t,e,r){var o,a=e.x-t.x,l=e.y-t.y,h=r.x-e.x,d=r.y-e.y,p=a*n(u)-l*i(u),f=a*i(u)+l*n(u),g=h*n(u)-d*i(u),v=h*i(u)+d*n(u),y=(t.x+e.x)/2,x=(t.y+e.y)/2,b=(e.x+r.x)/2,w=(e.y+r.y)/2,M=y+p,_=x+f,E=b+g,S=w+v,T=m.lli8(y,x,M,_,b,w,E,S),A=m.dist(T,t),P=s(t.y-T.y,t.x-T.x),L=s(e.y-T.y,e.x-T.x),R=s(r.y-T.y,r.x-T.x);return P<R?((P>L||L>R)&&(P+=c),P>R&&(o=R,R=P,P=o)):R<L&&L<P?(o=R,R=P,P=o):R+=c,T.s=P,T.e=R,T.r=A,T},numberSort:function(t,e){return t-e}};t.exports=m}()})),U=z((function(t){var e,n;e=N,(n=function(t){this.curves=[],this._3d=!1,t&&(this.curves=t,this._3d=this.curves[0]._3d)}).prototype={valueOf:function(){return this.toString()},toString:function(){return"["+this.curves.map((function(t){return e.pointsToString(t.points)})).join(", ")+"]"},addCurve:function(t){this.curves.push(t),this._3d=this._3d||t._3d},length:function(){return this.curves.map((function(t){return t.length()})).reduce((function(t,e){return t+e}))},curve:function(t){return this.curves[t]},bbox:function(){for(var t=this.curves,n=t[0].bbox(),i=1;i<t.length;i++)e.expandbox(n,t[i].bbox());return n},offset:function(t){var e=[];return this.curves.forEach((function(n){e=e.concat(n.offset(t))})),new n(e)}},t.exports=n}));var B=function(t){var e,n,i,r,s,o,a=(t=t.replace(/,/g," ").replace(/-/g," - ").replace(/-\s+/g,"-").replace(/([a-zA-Z])/g," $1 ")).replace(/([a-zA-Z])\s?/g,"|$1").split("|"),l=a.length,h=[],c=0,u=0,d=0,p=0,f=0,m=0,g=0,v=0,y="";for(e=1;e<l;e++)if(r=(i=(n=a[e]).substring(0,1)).toLowerCase(),s=(h=(h=n.replace(i,"").trim().split(" ")).filter((function(t){return""!==t})).map(parseFloat)).length,"m"===r){if(y+="M ","m"===i?(d+=h[0],p+=h[1]):(d=h[0],p=h[1]),c=d,u=p,y+=d+" "+p+" ",s>2)for(o=0;o<s;o+=2)"m"===i?(d+=h[o],p+=h[o+1]):(d=h[o],p=h[o+1]),y+=["L",d,p,""].join(" ")}else if("l"===r)for(o=0;o<s;o+=2)"l"===i?(d+=h[o],p+=h[o+1]):(d=h[o],p=h[o+1]),y+=["L",d,p,""].join(" ");else if("h"===r)for(o=0;o<s;o++)"h"===i?d+=h[o]:d=h[o],y+=["L",d,p,""].join(" ");else if("v"===r)for(o=0;o<s;o++)"v"===i?p+=h[o]:p=h[o],y+=["L",d,p,""].join(" ");else if("q"===r)for(o=0;o<s;o+=4)"q"===i?(f=d+h[o],m=p+h[o+1],d+=h[o+2],p+=h[o+3]):(f=h[o],m=h[o+1],d=h[o+2],p=h[o+3]),y+=["Q",f,m,d,p,""].join(" ");else if("t"===r)for(o=0;o<s;o+=2)f=d+(d-f),m=p+(p-m),"t"===i?(d+=h[o],p+=h[o+1]):(d=h[o],p=h[o+1]),y+=["Q",f,m,d,p,""].join(" ");else if("c"===r)for(o=0;o<s;o+=6)"c"===i?(f=d+h[o],m=p+h[o+1],g=d+h[o+2],v=p+h[o+3],d+=h[o+4],p+=h[o+5]):(f=h[o],m=h[o+1],g=h[o+2],v=h[o+3],d=h[o+4],p=h[o+5]),y+=["C",f,m,g,v,d,p,""].join(" ");else if("s"===r)for(o=0;o<s;o+=4)f=d+(d-g),m=p+(p-v),"s"===i?(g=d+h[o],v=p+h[o+1],d+=h[o+2],p+=h[o+3]):(g=h[o],v=h[o+1],d=h[o+2],p=h[o+3]),y+=["C",f,m,g,v,d,p,""].join(" ");else"z"===r&&(y+="Z ",d=c,p=u);return y.trim()},F={x:!1,y:!1};function V(t,e,n){if("Z"!==e){if("M"!==e){var i=[!1,F.x,F.y].concat(n),r=new(t.bind.apply(t,i)),s=n.slice(-2);return F={x:s[0],y:s[1]},r}F={x:n[0],y:n[1]}}}var k=function(t,e){for(var n,i,r=B(e).split(" "),s=new RegExp("[MLCQZ]",""),o=[],a={C:6,Q:4,L:2,M:2};r.length;)n=r.splice(0,1)[0],s.test(n)&&(i=V(t,n,r.splice(0,a[n]).map(parseFloat)))&&o.push(i);return new t.PolyBezier(o)},H=z((function(t){!function(){var e=Math.abs,n=Math.min,i=Math.max,r=Math.cos,s=Math.sin,o=Math.acos,a=Math.sqrt,l=Math.PI,h={x:0,y:0,z:0},c=N,u=U,d=function(t){var n=t&&t.forEach?t:[].slice.call(arguments),i=!1;if("object"==typeof n[0]){i=n.length;var r=[];n.forEach((function(t){["x","y","z"].forEach((function(e){void 0!==t[e]&&r.push(t[e])}))})),n=r}var s=!1,o=n.length;if(i){if(i>4){if(1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");s=!0}}else if(6!==o&&8!==o&&9!==o&&12!==o&&1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");var a=!s&&(9===o||12===o)||t&&t[0]&&void 0!==t[0].z;this._3d=a;for(var l=[],h=0,u=a?3:2;h<o;h+=u){var d={x:n[h],y:n[h+1]};a&&(d.z=n[h+2]),l.push(d)}this.order=l.length-1,this.points=l;var p=["x","y"];a&&p.push("z"),this.dims=p,this.dimlen=p.length,function(t){for(var n=t.order,i=t.points,r=c.align(i,{p1:i[0],p2:i[n]}),s=0;s<r.length;s++)if(e(r[s].y)>1e-4)return void(t._linear=!1);t._linear=!0}(this),this._t1=0,this._t2=1,this.update()},p=k;function f(t,e,n,i,r){void 0===r&&(r=.5);var s=c.projectionratio(r,t),o=1-s,a={x:s*e.x+o*i.x,y:s*e.y+o*i.y},l=c.abcratio(r,t);return{A:{x:n.x+(n.x-a.x)/l,y:n.y+(n.y-a.y)/l},B:n,C:a}}d.SVGtoBeziers=function(t){return p(d,t)},d.quadraticFromPoints=function(t,e,n,i){if(void 0===i&&(i=.5),0===i)return new d(e,e,n);if(1===i)return new d(t,e,e);var r=f(2,t,e,n,i);return new d(t,r.A,n)},d.cubicFromPoints=function(t,e,n,i,r){void 0===i&&(i=.5);var s=f(3,t,e,n,i);void 0===r&&(r=c.dist(e,s.C));var o=r*(1-i)/i,a=c.dist(t,n),l=(n.x-t.x)/a,h=(n.y-t.y)/a,u=r*l,p=r*h,m=o*l,g=o*h,v=e.x-u,y=e.y-p,x=e.x+m,b=e.y+g,w=s.A,M=w.x+(v-w.x)/(1-i),_=w.y+(y-w.y)/(1-i),E=w.x+(x-w.x)/i,S=w.y+(b-w.y)/i,T={x:t.x+(M-t.x)/i,y:t.y+(_-t.y)/i},A={x:n.x+(E-n.x)/(1-i),y:n.y+(S-n.y)/(1-i)};return new d(t,T,A,n)};var m=function(){return c};d.getUtils=m,d.PolyBezier=u,d.prototype={getUtils:m,valueOf:function(){return this.toString()},toString:function(){return c.pointsToString(this.points)},toSVG:function(t){if(this._3d)return!1;for(var e=this.points,n=["M",e[0].x,e[0].y,2===this.order?"Q":"C"],i=1,r=e.length;i<r;i++)n.push(e[i].x),n.push(e[i].y);return n.join(" ")},setRatios:function(t){if(t.length!==this.points.length)throw new Error("incorrect number of ratio values");this.ratios=t,this._lut=[]},verify:function(){var t=this.coordDigest();t!==this._print&&(this._print=t,this.update())},coordDigest:function(){return this.points.map((function(t,e){return""+e+t.x+t.y+(t.z?t.z:0)})).join("")},update:function(t){this._lut=[],this.dpoints=c.derive(this.points,this._3d),this.computedirection()},computedirection:function(){var t=this.points,e=c.angle(t[0],t[this.order],t[1]);this.clockwise=e>0},length:function(){return c.length(this.derivative.bind(this))},_lut:[],getLUT:function(t){if(this.verify(),t=t||100,this._lut.length===t)return this._lut;this._lut=[],t--;for(var e=0;e<=t;e++)this._lut.push(this.compute(e/t));return this._lut},on:function(t,e){e=e||5;for(var n,i=this.getLUT(),r=[],s=0,o=0;o<i.length;o++)n=i[o],c.dist(n,t)<e&&(r.push(n),s+=o/i.length);return!!r.length&&s/r.length},project:function(t){var e,n,i,r,s=this.getLUT(),o=s.length-1,a=c.closest(s,t),l=a.mdist,h=a.mpos,u=(h+1)/o,d=.1/o;for(l+=1,e=n=(h-1)/o;n<u+d;n+=d)i=this.compute(n),(r=c.dist(t,i))<l&&(l=r,e=n);return(i=this.compute(e)).t=e,i.d=l,i},get:function(t){return this.compute(t)},point:function(t){return this.points[t]},compute:function(t){return this.ratios?c.computeWithRatios(t,this.points,this.ratios,this._3d):c.compute(t,this.points,this._3d,this.ratios)},raise:function(){for(var t,e,n=this.points,i=[n[0]],r=n.length,s=1;s<r;s++)t=n[s],e=n[s-1],i[s]={x:(r-s)/r*t.x+s/r*e.x,y:(r-s)/r*t.y+s/r*e.y};return i[r]=n[r-1],new d(i)},derivative:function(t){var e,n,i=1-t,r=0,s=this.dpoints[0];2===this.order&&(s=[s[0],s[1],h],e=i,n=t),3===this.order&&(e=i*i,n=i*t*2,r=t*t);var o={x:e*s[0].x+n*s[1].x+r*s[2].x,y:e*s[0].y+n*s[1].y+r*s[2].y};return this._3d&&(o.z=e*s[0].z+n*s[1].z+r*s[2].z),o},curvature:function(t){return c.curvature(t,this.points,this._3d)},inflections:function(){return c.inflections(this.points)},normal:function(t){return this._3d?this.__normal3(t):this.__normal2(t)},__normal2:function(t){var e=this.derivative(t),n=a(e.x*e.x+e.y*e.y);return{x:-e.y/n,y:e.x/n}},__normal3:function(t){var e=this.derivative(t),n=this.derivative(t+.01),i=a(e.x*e.x+e.y*e.y+e.z*e.z),r=a(n.x*n.x+n.y*n.y+n.z*n.z);e.x/=i,e.y/=i,e.z/=i,n.x/=r,n.y/=r,n.z/=r;var s={x:n.y*e.z-n.z*e.y,y:n.z*e.x-n.x*e.z,z:n.x*e.y-n.y*e.x},o=a(s.x*s.x+s.y*s.y+s.z*s.z);s.x/=o,s.y/=o,s.z/=o;var l=[s.x*s.x,s.x*s.y-s.z,s.x*s.z+s.y,s.x*s.y+s.z,s.y*s.y,s.y*s.z-s.x,s.x*s.z-s.y,s.y*s.z+s.x,s.z*s.z];return{x:l[0]*e.x+l[1]*e.y+l[2]*e.z,y:l[3]*e.x+l[4]*e.y+l[5]*e.z,z:l[6]*e.x+l[7]*e.y+l[8]*e.z}},hull:function(t){var e,n=this.points,i=[],r=[],s=0,o=0,a=0;for(r[s++]=n[0],r[s++]=n[1],r[s++]=n[2],3===this.order&&(r[s++]=n[3]);n.length>1;){for(i=[],o=0,a=n.length-1;o<a;o++)e=c.lerp(t,n[o],n[o+1]),r[s++]=e,i.push(e);n=i}return r},split:function(t,e){if(0===t&&e)return this.split(e).left;if(1===e)return this.split(t).right;var n=this.hull(t),i={left:2===this.order?new d([n[0],n[3],n[5]]):new d([n[0],n[4],n[7],n[9]]),right:2===this.order?new d([n[5],n[4],n[2]]):new d([n[9],n[8],n[6],n[3]]),span:n};return i.left._t1=c.map(0,0,1,this._t1,this._t2),i.left._t2=c.map(t,0,1,this._t1,this._t2),i.right._t1=c.map(t,0,1,this._t1,this._t2),i.right._t2=c.map(1,0,1,this._t1,this._t2),e?(e=c.map(e,t,1,0,1),i.right.split(e).left):i},extrema:function(){var t,e,n=this.dims,i={},r=[];return n.forEach(function(n){e=function(t){return t[n]},t=this.dpoints[0].map(e),i[n]=c.droots(t),3===this.order&&(t=this.dpoints[1].map(e),i[n]=i[n].concat(c.droots(t))),i[n]=i[n].filter((function(t){return t>=0&&t<=1})),r=r.concat(i[n].sort(c.numberSort))}.bind(this)),r=r.sort(c.numberSort).filter((function(t,e){return r.indexOf(t)===e})),i.values=r,i},bbox:function(){var t=this.extrema(),e={};return this.dims.forEach(function(n){e[n]=c.getminmax(this,n,t[n])}.bind(this)),e},overlaps:function(t){var e=this.bbox(),n=t.bbox();return c.bboxoverlap(e,n)},offset:function(t,e){if(void 0!==e){var n=this.get(t),i=this.normal(t),r={c:n,n:i,x:n.x+i.x*e,y:n.y+i.y*e};return this._3d&&(r.z=n.z+i.z*e),r}if(this._linear){var s=this.normal(0),o=this.points.map((function(e){var n={x:e.x+t*s.x,y:e.y+t*s.y};return e.z&&i.z&&(n.z=e.z+t*s.z),n}));return[new d(o)]}return this.reduce().map((function(e){return e._linear?e.offset(t)[0]:e.scale(t)}))},simple:function(){if(3===this.order){var t=c.angle(this.points[0],this.points[3],this.points[1]),n=c.angle(this.points[0],this.points[3],this.points[2]);if(t>0&&n<0||t<0&&n>0)return!1}var i=this.normal(0),r=this.normal(1),s=i.x*r.x+i.y*r.y;return this._3d&&(s+=i.z*r.z),e(o(s))<l/3},reduce:function(){var t,n,i=0,r=0,s=[],o=[],a=this.extrema().values;for(-1===a.indexOf(0)&&(a=[0].concat(a)),-1===a.indexOf(1)&&a.push(1),i=a[0],t=1;t<a.length;t++)r=a[t],(n=this.split(i,r))._t1=i,n._t2=r,s.push(n),i=r;return s.forEach((function(t){for(i=0,r=0;r<=1;)for(r=i+.01;r<=1.01;r+=.01)if(!(n=t.split(i,r)).simple()){if(e(i-(r-=.01))<.01)return[];(n=t.split(i,r))._t1=c.map(i,0,1,t._t1,t._t2),n._t2=c.map(r,0,1,t._t1,t._t2),o.push(n),i=r;break}i<1&&((n=t.split(i,1))._t1=c.map(i,0,1,t._t1,t._t2),n._t2=t._t2,o.push(n))})),o},scale:function(t){var e=this.order,n=!1;if("function"==typeof t&&(n=t),n&&2===e)return this.raise().scale(n);var i=this.clockwise,r=n?n(0):t,s=n?n(1):t,o=[this.offset(0,10),this.offset(1,10)],l=c.lli4(o[0],o[0].c,o[1],o[1].c);if(!l)throw new Error("cannot scale this curve. Try reducing it first.");var h=this.points,u=[];return[0,1].forEach(function(t){var n=u[t*e]=c.copy(h[t*e]);n.x+=(t?s:r)*o[t].n.x,n.y+=(t?s:r)*o[t].n.y}.bind(this)),n?([0,1].forEach(function(r){if(2!==this.order||!r){var s=h[r+1],o={x:s.x-l.x,y:s.y-l.y},c=n?n((r+1)/e):t;n&&!i&&(c=-c);var d=a(o.x*o.x+o.y*o.y);o.x/=d,o.y/=d,u[r+1]={x:s.x+c*o.x,y:s.y+c*o.y}}}.bind(this)),new d(u)):([0,1].forEach(function(t){if(2!==this.order||!t){var n=u[t*e],i=this.derivative(t),r={x:n.x+i.x,y:n.y+i.y};u[t+1]=c.lli4(n,r,l,h[t+1])}}.bind(this)),new d(u))},outline:function(t,e,n,i){e=void 0===e?t:e;var r,s=this.reduce(),o=s.length,a=[],l=[],h=0,d=this.length(),p=void 0!==n&&void 0!==i;function f(t,e,n,i,r){return function(s){var o=i/n,a=(i+r)/n,l=e-t;return c.map(s,0,1,t+o*l,t+a*l)}}s.forEach((function(r){M=r.length(),p?(a.push(r.scale(f(t,n,d,h,M))),l.push(r.scale(f(-e,-i,d,h,M)))):(a.push(r.scale(t)),l.push(r.scale(-e))),h+=M})),l=l.map((function(t){return(r=t.points)[3]?t.points=[r[3],r[2],r[1],r[0]]:t.points=[r[2],r[1],r[0]],t})).reverse();var m=a[0].points[0],g=a[o-1].points[a[o-1].points.length-1],v=l[o-1].points[l[o-1].points.length-1],y=l[0].points[0],x=c.makeline(v,m),b=c.makeline(g,y),w=[x].concat(a).concat([b]).concat(l),M=w.length;return new u(w)},outlineshapes:function(t,e,n){e=e||t;for(var i=this.outline(t,e).curves,r=[],s=1,o=i.length;s<o/2;s++){var a=c.makeshape(i[s],i[o-s],n);a.startcap.virtual=s>1,a.endcap.virtual=s<o/2-1,r.push(a)}return r},intersects:function(t,e){return t?t.p1&&t.p2?this.lineIntersects(t):(t instanceof d&&(t=t.reduce()),this.curveintersects(this.reduce(),t,e)):this.selfintersects(e)},lineIntersects:function(t){var e=n(t.p1.x,t.p2.x),r=n(t.p1.y,t.p2.y),s=i(t.p1.x,t.p2.x),o=i(t.p1.y,t.p2.y),a=this;return c.roots(this.points,t).filter((function(t){var n=a.get(t);return c.between(n.x,e,s)&&c.between(n.y,r,o)}))},selfintersects:function(t){var e,n,i,r,s=this.reduce(),o=s.length-2,a=[];for(e=0;e<o;e++)i=s.slice(e,e+1),r=s.slice(e+2),n=this.curveintersects(i,r,t),a=a.concat(n);return a},curveintersects:function(t,e,n){var i=[];t.forEach((function(t){e.forEach((function(e){t.overlaps(e)&&i.push({left:t,right:e})}))}));var r=[];return i.forEach((function(t){var e=c.pairiteration(t.left,t.right,n);e.length>0&&(r=r.concat(e))})),r},arcs:function(t){t=t||.5;return this._iterate(t,[])},_error:function(t,n,i,r){var s=(r-i)/4,o=this.get(i+s),a=this.get(r-s),l=c.dist(t,n),h=c.dist(t,o),u=c.dist(t,a);return e(h-l)+e(u-l)},_iterate:function(t,e){var n,i=0,o=1;do{n=0,o=1;var a,l,h,u,d,p=this.get(i),f=!1,m=!1,g=o,v=1;do{if(m=f,u=h,g=(i+o)/2,a=this.get(g),l=this.get(o),(h=c.getccenter(p,a,l)).interval={start:i,end:o},f=this._error(h,p,i,o)<=t,(d=m&&!f)||(v=o),f){if(o>=1){if(h.interval.end=v=1,u=h,o>1){var y={x:h.x+h.r*r(h.e),y:h.y+h.r*s(h.e)};h.e+=c.angle({x:h.x,y:h.y},y,this.get(1))}break}o+=(o-i)/2}else o=g}while(!d&&n++<100);if(n>=100)break;u=u||h,e.push(u),i=v}while(o<1);return e}},t.exports=d}()})),G=H,W=X,j=X;function X(t,e,n){n=n||2;var i,r,s,o,a,l,h,c=e&&e.length,u=c?e[0]*n:t.length,d=Y(t,0,u,n,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=function(t,e,n,i){var r,s,o,a,l,h=[];for(r=0,s=e.length;r<s;r++)o=e[r]*i,a=r<s-1?e[r+1]*i:t.length,(l=Y(t,o,a,i,!1))===l.next&&(l.steiner=!0),h.push(rt(l));for(h.sort(tt),r=0;r<h.length;r++)n=et(h[r],n);return n}(t,e,d,n)),t.length>80*n){i=s=t[0],r=o=t[1];for(var f=n;f<u;f+=n)(a=t[f])<i&&(i=a),(l=t[f+1])<r&&(r=l),a>s&&(s=a),l>o&&(o=l);h=0!==(h=Math.max(s-i,o-r))?32767/h:0}return Z(d,p,n,i,r,h,0),p}function Y(t,e,n,i,r){var s,o;if(r===vt(t,e,n,i)>0)for(s=e;s<n;s+=i)o=ft(s,t[s],t[s+1],o);else for(s=n-i;s>=e;s-=i)o=ft(s,t[s],t[s+1],o);return o&&lt(o,o.next)&&(mt(o),o=o.next),o}function q(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!lt(i,i.next)&&0!==at(i.prev,i,i.next))i=i.next;else{if(mt(i),(i=e=i.prev)===i.next)break;n=!0}}while(n||i!==e);return e}function Z(t,e,n,i,r,s,o){if(t){!o&&s&&function(t,e,n,i){var r=t;do{0===r.z&&(r.z=it(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,n,i,r,s,o,a,l,h=1;do{for(n=t,t=null,s=null,o=0;n;){for(o++,i=n,a=0,e=0;e<h&&(a++,i=i.nextZ);e++);for(l=h;a>0||l>0&&i;)0!==a&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;n=i}s.nextZ=null,h*=2}while(o>1)}(r)}(t,i,r,s);for(var a,l,h=t;t.prev!==t.next;)if(a=t.prev,l=t.next,s?$(t,i,r,s):J(t))e.push(a.i/n|0),e.push(t.i/n|0),e.push(l.i/n|0),mt(t),t=l.next,h=l.next;else if((t=l)===h){o?1===o?Z(t=Q(q(t),e,n),e,n,i,r,s,2):2===o&&K(t,e,n,i,r,s):Z(q(t),e,n,i,r,s,1);break}}}function J(t){var e=t.prev,n=t,i=t.next;if(at(e,n,i)>=0)return!1;for(var r=e.x,s=n.x,o=i.x,a=e.y,l=n.y,h=i.y,c=r<s?r<o?r:o:s<o?s:o,u=a<l?a<h?a:h:l<h?l:h,d=r>s?r>o?r:o:s>o?s:o,p=a>l?a>h?a:h:l>h?l:h,f=i.next;f!==e;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&st(r,a,s,l,o,h,f.x,f.y)&&at(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function $(t,e,n,i){var r=t.prev,s=t,o=t.next;if(at(r,s,o)>=0)return!1;for(var a=r.x,l=s.x,h=o.x,c=r.y,u=s.y,d=o.y,p=a<l?a<h?a:h:l<h?l:h,f=c<u?c<d?c:d:u<d?u:d,m=a>l?a>h?a:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,v=it(p,f,e,n,i),y=it(m,g,e,n,i),x=t.prevZ,b=t.nextZ;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==o&&st(a,c,l,u,h,d,x.x,x.y)&&at(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==o&&st(a,c,l,u,h,d,b.x,b.y)&&at(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==o&&st(a,c,l,u,h,d,x.x,x.y)&&at(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==o&&st(a,c,l,u,h,d,b.x,b.y)&&at(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Q(t,e,n){var i=t;do{var r=i.prev,s=i.next.next;!lt(r,s)&&ht(r,i,i.next,s)&&dt(r,s)&&dt(s,r)&&(e.push(r.i/n|0),e.push(i.i/n|0),e.push(s.i/n|0),mt(i),mt(i.next),i=t=s),i=i.next}while(i!==t);return q(i)}function K(t,e,n,i,r,s){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&ot(o,a)){var l=pt(o,a);return o=q(o,o.next),l=q(l,l.next),Z(o,e,n,i,r,s,0),void Z(l,e,n,i,r,s,0)}a=a.next}o=o.next}while(o!==t)}function tt(t,e){return t.x-e.x}function et(t,e){var n=function(t,e){var n,i=e,r=t.x,s=t.y,o=-1/0;do{if(s<=i.y&&s>=i.next.y&&i.next.y!==i.y){var a=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=r&&a>o&&(o=a,n=i.x<i.next.x?i:i.next,a===r))return n}i=i.next}while(i!==e);if(!n)return null;var l,h=n,c=n.x,u=n.y,d=1/0;i=n;do{r>=i.x&&i.x>=c&&r!==i.x&&st(s<u?r:o,s,c,u,s<u?o:r,s,i.x,i.y)&&(l=Math.abs(s-i.y)/(r-i.x),dt(i,t)&&(l<d||l===d&&(i.x>n.x||i.x===n.x&&nt(n,i)))&&(n=i,d=l)),i=i.next}while(i!==h);return n}(t,e);if(!n)return e;var i=pt(n,t);return q(i,i.next),q(n,n.next)}function nt(t,e){return at(t.prev,t,e.prev)<0&&at(e.next,t,t.next)<0}function it(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function rt(t){var e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function st(t,e,n,i,r,s,o,a){return(r-o)*(e-a)>=(t-o)*(s-a)&&(t-o)*(i-a)>=(n-o)*(e-a)&&(n-o)*(s-a)>=(r-o)*(i-a)}function ot(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&ht(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(dt(t,e)&&dt(e,t)&&function(t,e){var n=t,i=!1,r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(at(t.prev,t,e.prev)||at(t,e.prev,e))||lt(t,e)&&at(t.prev,t,t.next)>0&&at(e.prev,e,e.next)>0)}function at(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function lt(t,e){return t.x===e.x&&t.y===e.y}function ht(t,e,n,i){var r=ut(at(t,e,n)),s=ut(at(t,e,i)),o=ut(at(n,i,t)),a=ut(at(n,i,e));return r!==s&&o!==a||(!(0!==r||!ct(t,n,e))||(!(0!==s||!ct(t,i,e))||(!(0!==o||!ct(n,t,i))||!(0!==a||!ct(n,e,i)))))}function ct(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function ut(t){return t>0?1:t<0?-1:0}function dt(t,e){return at(t.prev,t,t.next)<0?at(t,e,t.next)>=0&&at(t,t.prev,e)>=0:at(t,e,t.prev)<0||at(t,t.next,e)<0}function pt(t,e){var n=new gt(t.i,t.x,t.y),i=new gt(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function ft(t,e,n,i){var r=new gt(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function mt(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function gt(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function vt(t,e,n,i){for(var r=0,s=e,o=n-i;s<n;s+=i)r+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return r}X.deviation=function(t,e,n,i){var r=e&&e.length,s=r?e[0]*n:t.length,o=Math.abs(vt(t,0,s,n));if(r)for(var a=0,l=e.length;a<l;a++){var h=e[a]*n,c=a<l-1?e[a+1]*n:t.length;o-=Math.abs(vt(t,h,c,n))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*n,p=i[a+1]*n,f=i[a+2]*n;u+=Math.abs((t[d]-t[f])*(t[p+1]-t[d+1])-(t[d]-t[p])*(t[f+1]-t[d+1]))}return 0===o&&0===u?0:Math.abs((u-o)/o)},X.flatten=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},i=0,r=0;r<t.length;r++){for(var s=0;s<t[r].length;s++)for(var o=0;o<e;o++)n.vertices.push(t[r][s][o]);r>0&&(i+=t[r-1].length,n.holes.push(i))}return n},W.default=j;class yt{constructor(t,e){this.next=null,this.key=t,this.data=e,this.left=null,this.right=null}}function xt(t,e){return t>e?1:t<e?-1:0}function bt(t,e,n){const i=new yt(null,null);let r=i,s=i;for(;;){const i=n(t,e.key);if(i<0){if(null===e.left)break;if(n(t,e.left.key)<0){const t=e.left;if(e.left=t.right,t.right=e,null===(e=t).left)break}s.left=e,s=e,e=e.left}else{if(!(i>0))break;if(null===e.right)break;if(n(t,e.right.key)>0){const t=e.right;if(e.right=t.left,t.left=e,null===(e=t).right)break}r.right=e,r=e,e=e.right}}return r.right=e.left,s.left=e.right,e.left=i.right,e.right=i.left,e}function wt(t,e,n,i){const r=new yt(t,e);if(null===n)return r.left=r.right=null,r;const s=i(t,(n=bt(t,n,i)).key);return s<0?(r.left=n.left,r.right=n,n.left=null):s>=0&&(r.right=n.right,r.left=n,n.right=null),r}function Mt(t,e,n){let i=null,r=null;if(e){const s=n((e=bt(t,e,n)).key,t);0===s?(i=e.left,r=e.right):s<0?(r=e.right,e.right=null,i=e):(i=e.left,e.left=null,r=e)}return{left:i,right:r}}class _t{constructor(t=xt){this._root=null,this._size=0,this._comparator=t}insert(t,e){return this._size++,this._root=wt(t,e,this._root,this._comparator)}add(t,e){const n=new yt(t,e);null===this._root&&(n.left=n.right=null,this._size++,this._root=n);const i=this._comparator,r=bt(t,this._root,i),s=i(t,r.key);return 0===s?this._root=r:(s<0?(n.left=r.left,n.right=r,r.left=null):s>0&&(n.right=r.right,n.left=r,r.right=null),this._size++,this._root=n),this._root}remove(t){this._root=this._remove(t,this._root,this._comparator)}_remove(t,e,n){let i;return null===e?null:0===n(t,(e=bt(t,e,n)).key)?(null===e.left?i=e.right:(i=bt(t,e.left,n),i.right=e.right),this._size--,i):e}pop(){let t=this._root;if(t){for(;t.left;)t=t.left;return this._root=bt(t.key,this._root,this._comparator),this._root=this._remove(t.key,this._root,this._comparator),{key:t.key,data:t.data}}return null}findStatic(t){let e=this._root;const n=this._comparator;for(;e;){const i=n(t,e.key);if(0===i)return e;e=i<0?e.left:e.right}return null}find(t){return this._root&&(this._root=bt(t,this._root,this._comparator),0!==this._comparator(t,this._root.key))?null:this._root}contains(t){let e=this._root;const n=this._comparator;for(;e;){const i=n(t,e.key);if(0===i)return!0;e=i<0?e.left:e.right}return!1}forEach(t,e){let n=this._root;const i=[];let r=!1;for(;!r;)null!==n?(i.push(n),n=n.left):0!==i.length?(n=i.pop(),t.call(e,n),n=n.right):r=!0;return this}range(t,e,n,i){const r=[],s=this._comparator;let o,a=this._root;for(;0!==r.length||a;)if(a)r.push(a),a=a.left;else{if(a=r.pop(),o=s(a.key,e),o>0)break;if(s(a.key,t)>=0&&n.call(i,a))return this;a=a.right}return this}keys(){const t=[];return this.forEach(({key:e})=>{t.push(e)}),t}values(){const t=[];return this.forEach(({data:e})=>{t.push(e)}),t}min(){return this._root?this.minNode(this._root).key:null}max(){return this._root?this.maxNode(this._root).key:null}minNode(t=this._root){if(t)for(;t.left;)t=t.left;return t}maxNode(t=this._root){if(t)for(;t.right;)t=t.right;return t}at(t){let e=this._root,n=!1,i=0;const r=[];for(;!n;)if(e)r.push(e),e=e.left;else if(r.length>0){if(e=r.pop(),i===t)return e;i++,e=e.right}else n=!0;return null}next(t){let e=this._root,n=null;if(t.right){for(n=t.right;n.left;)n=n.left;return n}const i=this._comparator;for(;e;){const r=i(t.key,e.key);if(0===r)break;r<0?(n=e,e=e.left):e=e.right}return n}prev(t){let e=this._root,n=null;if(null!==t.left){for(n=t.left;n.right;)n=n.right;return n}const i=this._comparator;for(;e;){const r=i(t.key,e.key);if(0===r)break;r<0?e=e.left:(n=e,e=e.right)}return n}clear(){return this._root=null,this._size=0,this}toList(){return function(t){let e=t;const n=[];let i=!1;const r=new yt(null,null);let s=r;for(;!i;)e?(n.push(e),e=e.left):n.length>0?(e=s=s.next=n.pop(),e=e.right):i=!0;return s.next=null,r.next}(this._root)}load(t,e=[],n=!1){let i=t.length;const r=this._comparator;if(n&&function t(e,n,i,r,s){if(i>=r)return;const o=e[i+r>>1];let a=i-1,l=r+1;for(;;){do{a++}while(s(e[a],o)<0);do{l--}while(s(e[l],o)>0);if(a>=l)break;let t=e[a];e[a]=e[l],e[l]=t,t=n[a],n[a]=n[l],n[l]=t}t(e,n,i,l,s),t(e,n,l+1,r,s)}(t,e,0,i-1,r),null===this._root)this._root=function t(e,n,i,r){const s=r-i;if(s>0){const o=i+Math.floor(s/2),a=e[o],l=n[o],h=new yt(a,l);return h.left=t(e,n,i,o),h.right=t(e,n,o+1,r),h}return null}(t,e,0,i),this._size=i;else{const n=function(t,e,n){const i=new yt(null,null);let r=i,s=t,o=e;for(;null!==s&&null!==o;)n(s.key,o.key)<0?(r.next=s,s=s.next):(r.next=o,o=o.next),r=r.next;return null!==s?r.next=s:null!==o&&(r.next=o),i.next}(this.toList(),function(t,e){const n=new yt(null,null);let i=n;for(let n=0;n<t.length;n++)i=i.next=new yt(t[n],e[n]);return i.next=null,n.next}(t,e),r);i=this._size+i,this._root=function t(e,n,i){const r=i-n;if(r>0){const s=n+Math.floor(r/2),o=t(e,n,s),a=e.head;return a.left=o,e.head=e.head.next,a.right=t(e,s+1,i),a}return null}({head:n},0,i)}return this}isEmpty(){return null===this._root}get size(){return this._size}get root(){return this._root}toString(t=(t=>String(t.key))){const e=[];return function t(e,n,i,r,s){if(e){r(`${n}${i?"└── ":"├── "}${s(e)}\n`);const o=n+(i?" ":"│ ");e.left&&t(e.left,o,!1,r,s),e.right&&t(e.right,o,!0,r,s)}}(this._root,"",!0,t=>e.push(t),t),e.join("")}update(t,e,n){const i=this._comparator;let{left:r,right:s}=Mt(t,this._root,i);i(t,e)<0?s=wt(e,n,s,i):r=wt(e,n,r,i),this._root=function(t,e,n){return null===e?t:(null===t||((e=bt(t.key,e,n)).left=t),e)}(r,s,i)}split(t){return Mt(t,this._root,this._comparator)}*[Symbol.iterator](){let t=this._root;const e=[];let n=!1;for(;!n;)null!==t?(e.push(t),t=t.left):0!==e.length?(t=e.pop(),yield t,t=t.right):n=!0}}function Et(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function St(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function Tt(t,e,n){return e&&St(t.prototype,e),n&&St(t,n),t}var At=function(t,e){return t.ll.x<=e.x&&e.x<=t.ur.x&&t.ll.y<=e.y&&e.y<=t.ur.y},Pt=function(t,e){if(e.ur.x<t.ll.x||t.ur.x<e.ll.x||e.ur.y<t.ll.y||t.ur.y<e.ll.y)return null;var n=t.ll.x<e.ll.x?e.ll.x:t.ll.x,i=t.ur.x<e.ur.x?t.ur.x:e.ur.x;return{ll:{x:n,y:t.ll.y<e.ll.y?e.ll.y:t.ll.y},ur:{x:i,y:t.ur.y<e.ur.y?t.ur.y:e.ur.y}}},Lt=Number.EPSILON;void 0===Lt&&(Lt=Math.pow(2,-52));var Rt=Lt*Lt,Ct=function(t,e){if(-Lt<t&&t<Lt&&-Lt<e&&e<Lt)return 0;var n=t-e;return n*n<Rt*t*e?0:t<e?-1:1},It=function(){function t(){Et(this,t),this.reset()}return Tt(t,[{key:"reset",value:function(){this.xRounder=new Ot,this.yRounder=new Ot}},{key:"round",value:function(t,e){return{x:this.xRounder.round(t),y:this.yRounder.round(e)}}}]),t}(),Ot=function(){function t(){Et(this,t),this.tree=new _t,this.round(0)}return Tt(t,[{key:"round",value:function(t){var e=this.tree.add(t),n=this.tree.prev(e);if(null!==n&&0===Ct(e.key,n.key))return this.tree.remove(t),n.key;var i=this.tree.next(e);return null!==i&&0===Ct(e.key,i.key)?(this.tree.remove(t),i.key):t}}]),t}(),Dt=new It,zt=function(t,e){return t.x*e.y-t.y*e.x},Nt=function(t,e){return t.x*e.x+t.y*e.y},Ut=function(t,e,n){var i={x:e.x-t.x,y:e.y-t.y},r={x:n.x-t.x,y:n.y-t.y},s=zt(i,r);return Ct(s,0)},Bt=function(t){return Math.sqrt(Nt(t,t))},Ft=function(t,e,n){var i={x:e.x-t.x,y:e.y-t.y},r={x:n.x-t.x,y:n.y-t.y};return Nt(r,i)/Bt(r)/Bt(i)},Vt=function(t,e,n){return 0===e.y?null:{x:t.x+e.x/e.y*(n-t.y),y:n}},kt=function(t,e,n){return 0===e.x?null:{x:n,y:t.y+e.y/e.x*(n-t.x)}},Ht=function(){function t(e,n){Et(this,t),void 0===e.events?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=n}return Tt(t,null,[{key:"compare",value:function(e,n){var i=t.comparePoints(e.point,n.point);return 0!==i?i:(e.point!==n.point&&e.link(n),e.isLeft!==n.isLeft?e.isLeft?1:-1:Wt.compare(e.segment,n.segment))}},{key:"comparePoints",value:function(t,e){return t.x<e.x?-1:t.x>e.x?1:t.y<e.y?-1:t.y>e.y?1:0}}]),Tt(t,[{key:"link",value:function(t){if(t.point===this.point)throw new Error("Tried to link already linked events");for(var e=t.point.events,n=0,i=e.length;n<i;n++){var r=e[n];this.point.events.push(r),r.point=this.point}this.checkForConsuming()}},{key:"checkForConsuming",value:function(){for(var t=this.point.events.length,e=0;e<t;e++){var n=this.point.events[e];if(void 0===n.segment.consumedBy)for(var i=e+1;i<t;i++){var r=this.point.events[i];void 0===r.consumedBy&&(n.otherSE.point.events===r.otherSE.point.events&&n.segment.consume(r.segment))}}}},{key:"getAvailableLinkedEvents",value:function(){for(var t=[],e=0,n=this.point.events.length;e<n;e++){var i=this.point.events[e];i!==this&&!i.segment.ringOut&&i.segment.isInResult()&&t.push(i)}return t}},{key:"getLeftmostComparator",value:function(t){var e=this,n=new Map,i=function(i){var r,s,o,a,l,h=i.otherSE;n.set(i,{sine:(r=e.point,s=t.point,o=h.point,a={x:s.x-r.x,y:s.y-r.y},l={x:o.x-r.x,y:o.y-r.y},zt(l,a)/Bt(l)/Bt(a)),cosine:Ft(e.point,t.point,h.point)})};return function(t,e){n.has(t)||i(t),n.has(e)||i(e);var r=n.get(t),s=r.sine,o=r.cosine,a=n.get(e),l=a.sine,h=a.cosine;return s>=0&&l>=0?o<h?1:o>h?-1:0:s<0&&l<0?o<h?-1:o>h?1:0:l<s?-1:l>s?1:0}}}]),t}(),Gt=0,Wt=function(){function t(e,n,i,r){Et(this,t),this.id=++Gt,this.leftSE=e,e.segment=this,e.otherSE=n,this.rightSE=n,n.segment=this,n.otherSE=e,this.rings=i,this.windings=r}return Tt(t,null,[{key:"compare",value:function(t,e){var n=t.leftSE.point.x,i=e.leftSE.point.x,r=t.rightSE.point.x,s=e.rightSE.point.x;if(s<n)return 1;if(r<i)return-1;var o=t.leftSE.point.y,a=e.leftSE.point.y,l=t.rightSE.point.y,h=e.rightSE.point.y;if(n<i){if(a<o&&a<l)return 1;if(a>o&&a>l)return-1;var c=t.comparePoint(e.leftSE.point);if(c<0)return 1;if(c>0)return-1;var u=e.comparePoint(t.rightSE.point);return 0!==u?u:-1}if(n>i){if(o<a&&o<h)return-1;if(o>a&&o>h)return 1;var d=e.comparePoint(t.leftSE.point);if(0!==d)return d;var p=t.comparePoint(e.rightSE.point);return p<0?1:p>0?-1:1}if(o<a)return-1;if(o>a)return 1;if(r<s){var f=e.comparePoint(t.rightSE.point);if(0!==f)return f}if(r>s){var m=t.comparePoint(e.rightSE.point);if(m<0)return 1;if(m>0)return-1}if(r!==s){var g=l-o,v=r-n,y=h-a,x=s-i;if(g>v&&y<x)return 1;if(g<v&&y>x)return-1}return r>s?1:r<s||l<h?-1:l>h?1:t.id<e.id?-1:t.id>e.id?1:0}}]),Tt(t,[{key:"replaceRightSE",value:function(t){this.rightSE=t,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}},{key:"bbox",value:function(){var t=this.leftSE.point.y,e=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:t<e?t:e},ur:{x:this.rightSE.point.x,y:t>e?t:e}}}},{key:"vector",value:function(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}},{key:"isAnEndpoint",value:function(t){return t.x===this.leftSE.point.x&&t.y===this.leftSE.point.y||t.x===this.rightSE.point.x&&t.y===this.rightSE.point.y}},{key:"comparePoint",value:function(t){if(this.isAnEndpoint(t))return 0;var e=this.leftSE.point,n=this.rightSE.point,i=this.vector();if(e.x===n.x)return t.x===e.x?0:t.x<e.x?1:-1;var r=(t.y-e.y)/i.y,s=e.x+r*i.x;if(t.x===s)return 0;var o=(t.x-e.x)/i.x,a=e.y+o*i.y;return t.y===a?0:t.y<a?-1:1}},{key:"getIntersection",value:function(t){var e=this.bbox(),n=t.bbox(),i=Pt(e,n);if(null===i)return null;var r=this.leftSE.point,s=this.rightSE.point,o=t.leftSE.point,a=t.rightSE.point,l=At(e,o)&&0===this.comparePoint(o),h=At(n,r)&&0===t.comparePoint(r),c=At(e,a)&&0===this.comparePoint(a),u=At(n,s)&&0===t.comparePoint(s);if(h&&l)return u&&!c?s:!u&&c?a:null;if(h)return c&&r.x===a.x&&r.y===a.y?null:r;if(l)return u&&s.x===o.x&&s.y===o.y?null:o;if(u&&c)return null;if(u)return s;if(c)return a;var d=function(t,e,n,i){if(0===e.x)return kt(n,i,t.x);if(0===i.x)return kt(t,e,n.x);if(0===e.y)return Vt(n,i,t.y);if(0===i.y)return Vt(t,e,n.y);var r=zt(e,i);if(0==r)return null;var s={x:n.x-t.x,y:n.y-t.y},o=zt(s,e)/r,a=zt(s,i)/r;return{x:(t.x+a*e.x+(n.x+o*i.x))/2,y:(t.y+a*e.y+(n.y+o*i.y))/2}}(r,this.vector(),o,t.vector());return null===d?null:At(i,d)?Dt.round(d.x,d.y):null}},{key:"split",value:function(e){var n=[],i=void 0!==e.events,r=new Ht(e,!0),s=new Ht(e,!1),o=this.rightSE;this.replaceRightSE(s),n.push(s),n.push(r);var a=new t(r,o,this.rings.slice(),this.windings.slice());return Ht.comparePoints(a.leftSE.point,a.rightSE.point)>0&&a.swapEvents(),Ht.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),i&&(r.checkForConsuming(),s.checkForConsuming()),n}},{key:"swapEvents",value:function(){var t=this.rightSE;this.rightSE=this.leftSE,this.leftSE=t,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(var e=0,n=this.windings.length;e<n;e++)this.windings[e]*=-1}},{key:"consume",value:function(e){for(var n=this,i=e;n.consumedBy;)n=n.consumedBy;for(;i.consumedBy;)i=i.consumedBy;var r=t.compare(n,i);if(0!==r){if(r>0){var s=n;n=i,i=s}if(n.prev===i){var o=n;n=i,i=o}for(var a=0,l=i.rings.length;a<l;a++){var h=i.rings[a],c=i.windings[a],u=n.rings.indexOf(h);-1===u?(n.rings.push(h),n.windings.push(c)):n.windings[u]+=c}i.rings=null,i.windings=null,i.consumedBy=n,i.leftSE.consumedBy=n.leftSE,i.rightSE.consumedBy=n.rightSE}}},{key:"prevInResult",value:function(){return void 0!==this._prevInResult||(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null),this._prevInResult}},{key:"beforeState",value:function(){if(void 0!==this._beforeState)return this._beforeState;if(this.prev){var t=this.prev.consumedBy||this.prev;this._beforeState=t.afterState()}else this._beforeState={rings:[],windings:[],multiPolys:[]};return this._beforeState}},{key:"afterState",value:function(){if(void 0!==this._afterState)return this._afterState;var t=this.beforeState();this._afterState={rings:t.rings.slice(0),windings:t.windings.slice(0),multiPolys:[]};for(var e=this._afterState.rings,n=this._afterState.windings,i=this._afterState.multiPolys,r=0,s=this.rings.length;r<s;r++){var o=this.rings[r],a=this.windings[r],l=e.indexOf(o);-1===l?(e.push(o),n.push(a)):n[l]+=a}for(var h=[],c=[],u=0,d=e.length;u<d;u++)if(0!==n[u]){var p=e[u],f=p.poly;if(-1===c.indexOf(f))if(p.isExterior)h.push(f);else{-1===c.indexOf(f)&&c.push(f);var m=h.indexOf(p.poly);-1!==m&&h.splice(m,1)}}for(var g=0,v=h.length;g<v;g++){var y=h[g].multiPoly;-1===i.indexOf(y)&&i.push(y)}return this._afterState}},{key:"isInResult",value:function(){if(this.consumedBy)return!1;if(void 0!==this._isInResult)return this._isInResult;var t=this.beforeState().multiPolys,e=this.afterState().multiPolys;switch(Qt.type){case"union":var n=0===t.length,i=0===e.length;this._isInResult=n!==i;break;case"intersection":var r,s;t.length<e.length?(r=t.length,s=e.length):(r=e.length,s=t.length),this._isInResult=s===Qt.numMultiPolys&&r<s;break;case"xor":var o=Math.abs(t.length-e.length);this._isInResult=o%2==1;break;case"difference":var a=function(t){return 1===t.length&&t[0].isSubject};this._isInResult=a(t)!==a(e);break;default:throw new Error("Unrecognized operation type found ".concat(Qt.type))}return this._isInResult}}],[{key:"fromRing",value:function(e,n,i){var r,s,o,a=Ht.comparePoints(e,n);if(a<0)r=e,s=n,o=1;else{if(!(a>0))throw new Error("Tried to create degenerate segment at [".concat(e.x,", ").concat(e.y,"]"));r=n,s=e,o=-1}return new t(new Ht(r,!0),new Ht(s,!1),[i],[o])}}]),t}(),jt=function(){function t(e,n,i){if(Et(this,t),!Array.isArray(e)||0===e.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=n,this.isExterior=i,this.segments=[],"number"!=typeof e[0][0]||"number"!=typeof e[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var r=Dt.round(e[0][0],e[0][1]);this.bbox={ll:{x:r.x,y:r.y},ur:{x:r.x,y:r.y}};for(var s=r,o=1,a=e.length;o<a;o++){if("number"!=typeof e[o][0]||"number"!=typeof e[o][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var l=Dt.round(e[o][0],e[o][1]);l.x===s.x&&l.y===s.y||(this.segments.push(Wt.fromRing(s,l,this)),l.x<this.bbox.ll.x&&(this.bbox.ll.x=l.x),l.y<this.bbox.ll.y&&(this.bbox.ll.y=l.y),l.x>this.bbox.ur.x&&(this.bbox.ur.x=l.x),l.y>this.bbox.ur.y&&(this.bbox.ur.y=l.y),s=l)}r.x===s.x&&r.y===s.y||this.segments.push(Wt.fromRing(s,r,this))}return Tt(t,[{key:"getSweepEvents",value:function(){for(var t=[],e=0,n=this.segments.length;e<n;e++){var i=this.segments[e];t.push(i.leftSE),t.push(i.rightSE)}return t}}]),t}(),Xt=function(){function t(e,n){if(Et(this,t),!Array.isArray(e))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new jt(e[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(var i=1,r=e.length;i<r;i++){var s=new jt(e[i],this,!1);s.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=s.bbox.ll.x),s.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=s.bbox.ll.y),s.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=s.bbox.ur.x),s.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=s.bbox.ur.y),this.interiorRings.push(s)}this.multiPoly=n}return Tt(t,[{key:"getSweepEvents",value:function(){for(var t=this.exteriorRing.getSweepEvents(),e=0,n=this.interiorRings.length;e<n;e++)for(var i=this.interiorRings[e].getSweepEvents(),r=0,s=i.length;r<s;r++)t.push(i[r]);return t}}]),t}(),Yt=function(){function t(e,n){if(Et(this,t),!Array.isArray(e))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{"number"==typeof e[0][0][0]&&(e=[e])}catch(t){}this.polys=[],this.bbox={ll:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY},ur:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY}};for(var i=0,r=e.length;i<r;i++){var s=new Xt(e[i],this);s.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=s.bbox.ll.x),s.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=s.bbox.ll.y),s.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=s.bbox.ur.x),s.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=s.bbox.ur.y),this.polys.push(s)}this.isSubject=n}return Tt(t,[{key:"getSweepEvents",value:function(){for(var t=[],e=0,n=this.polys.length;e<n;e++)for(var i=this.polys[e].getSweepEvents(),r=0,s=i.length;r<s;r++)t.push(i[r]);return t}}]),t}(),qt=function(){function t(e){Et(this,t),this.events=e;for(var n=0,i=e.length;n<i;n++)e[n].segment.ringOut=this;this.poly=null}return Tt(t,null,[{key:"factory",value:function(e){for(var n=[],i=0,r=e.length;i<r;i++){var s=e[i];if(s.isInResult()&&!s.ringOut){for(var o=null,a=s.leftSE,l=s.rightSE,h=[a],c=a.point,u=[];o=a,a=l,h.push(a),a.point!==c;)for(;;){var d=a.getAvailableLinkedEvents();if(0===d.length){var p=h[0].point,f=h[h.length-1].point;throw new Error("Unable to complete output ring starting at [".concat(p.x,",")+" ".concat(p.y,"]. Last matching segment found ends at")+" [".concat(f.x,", ").concat(f.y,"]."))}if(1===d.length){l=d[0].otherSE;break}for(var m=null,g=0,v=u.length;g<v;g++)if(u[g].point===a.point){m=g;break}if(null===m){u.push({index:h.length,point:a.point});var y=a.getLeftmostComparator(o);l=d.sort(y)[0].otherSE;break}var x=u.splice(m)[0],b=h.splice(x.index);b.unshift(b[0].otherSE),n.push(new t(b.reverse()))}n.push(new t(h))}}return n}}]),Tt(t,[{key:"getGeom",value:function(){for(var t=this.events[0].point,e=[t],n=1,i=this.events.length-1;n<i;n++){var r=this.events[n].point,s=this.events[n+1].point;0!==Ut(r,t,s)&&(e.push(r),t=r)}if(1===e.length)return null;var o=e[0],a=e[1];0===Ut(o,t,a)&&e.shift(),e.push(e[0]);for(var l=this.isExteriorRing()?1:-1,h=this.isExteriorRing()?0:e.length-1,c=this.isExteriorRing()?e.length:-1,u=[],d=h;d!=c;d+=l)u.push([e[d].x,e[d].y]);return u}},{key:"isExteriorRing",value:function(){if(void 0===this._isExteriorRing){var t=this.enclosingRing();this._isExteriorRing=!t||!t.isExteriorRing()}return this._isExteriorRing}},{key:"enclosingRing",value:function(){return void 0===this._enclosingRing&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}},{key:"_calcEnclosingRing",value:function(){for(var t=this.events[0],e=1,n=this.events.length;e<n;e++){var i=this.events[e];Ht.compare(t,i)>0&&(t=i)}for(var r=t.segment.prevInResult(),s=r?r.prevInResult():null;;){if(!r)return null;if(!s)return r.ringOut;if(s.ringOut!==r.ringOut)return s.ringOut.enclosingRing()!==r.ringOut?r.ringOut:r.ringOut.enclosingRing();r=s.prevInResult(),s=r?r.prevInResult():null}}}]),t}(),Zt=function(){function t(e){Et(this,t),this.exteriorRing=e,e.poly=this,this.interiorRings=[]}return Tt(t,[{key:"addInterior",value:function(t){this.interiorRings.push(t),t.poly=this}},{key:"getGeom",value:function(){var t=[this.exteriorRing.getGeom()];if(null===t[0])return null;for(var e=0,n=this.interiorRings.length;e<n;e++){var i=this.interiorRings[e].getGeom();null!==i&&t.push(i)}return t}}]),t}(),Jt=function(){function t(e){Et(this,t),this.rings=e,this.polys=this._composePolys(e)}return Tt(t,[{key:"getGeom",value:function(){for(var t=[],e=0,n=this.polys.length;e<n;e++){var i=this.polys[e].getGeom();null!==i&&t.push(i)}return t}},{key:"_composePolys",value:function(t){for(var e=[],n=0,i=t.length;n<i;n++){var r=t[n];if(!r.poly)if(r.isExteriorRing())e.push(new Zt(r));else{var s=r.enclosingRing();s.poly||e.push(new Zt(s)),s.poly.addInterior(r)}}return e}}]),t}(),$t=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Wt.compare;Et(this,t),this.queue=e,this.tree=new _t(n),this.segments=[]}return Tt(t,[{key:"process",value:function(t){var e=t.segment,n=[];if(t.consumedBy)return t.isLeft?this.queue.remove(t.otherSE):this.tree.remove(e),n;var i=t.isLeft?this.tree.insert(e):this.tree.find(e);if(!i)throw new Error("Unable to find segment #".concat(e.id," ")+"[".concat(e.leftSE.point.x,", ").concat(e.leftSE.point.y,"] -> ")+"[".concat(e.rightSE.point.x,", ").concat(e.rightSE.point.y,"] ")+"in SweepLine tree. Please submit a bug report.");for(var r=i,s=i,o=void 0,a=void 0;void 0===o;)null===(r=this.tree.prev(r))?o=null:void 0===r.key.consumedBy&&(o=r.key);for(;void 0===a;)null===(s=this.tree.next(s))?a=null:void 0===s.key.consumedBy&&(a=s.key);if(t.isLeft){var l=null;if(o){var h=o.getIntersection(e);if(null!==h&&(e.isAnEndpoint(h)||(l=h),!o.isAnEndpoint(h)))for(var c=this._splitSafely(o,h),u=0,d=c.length;u<d;u++)n.push(c[u])}var p=null;if(a){var f=a.getIntersection(e);if(null!==f&&(e.isAnEndpoint(f)||(p=f),!a.isAnEndpoint(f)))for(var m=this._splitSafely(a,f),g=0,v=m.length;g<v;g++)n.push(m[g])}if(null!==l||null!==p){var y=null;if(null===l)y=p;else if(null===p)y=l;else{y=Ht.comparePoints(l,p)<=0?l:p}this.queue.remove(e.rightSE),n.push(e.rightSE);for(var x=e.split(y),b=0,w=x.length;b<w;b++)n.push(x[b])}n.length>0?(this.tree.remove(e),n.push(t)):(this.segments.push(e),e.prev=o)}else{if(o&&a){var M=o.getIntersection(a);if(null!==M){if(!o.isAnEndpoint(M))for(var _=this._splitSafely(o,M),E=0,S=_.length;E<S;E++)n.push(_[E]);if(!a.isAnEndpoint(M))for(var T=this._splitSafely(a,M),A=0,P=T.length;A<P;A++)n.push(T[A])}}this.tree.remove(e)}return n}},{key:"_splitSafely",value:function(t,e){this.tree.remove(t);var n=t.rightSE;this.queue.remove(n);var i=t.split(e);return i.push(n),void 0===t.consumedBy&&this.tree.insert(t),i}}]),t}(),Qt=new(function(){function t(){Et(this,t)}return Tt(t,[{key:"run",value:function(t,e,n){Qt.type=t,Dt.reset();for(var i=[new Yt(e,!0)],r=0,s=n.length;r<s;r++)i.push(new Yt(n[r],!1));if(Qt.numMultiPolys=i.length,"difference"===Qt.type)for(var o=i[0],a=1;a<i.length;)null!==Pt(i[a].bbox,o.bbox)?a++:i.splice(a,1);if("intersection"===Qt.type)for(var l=0,h=i.length;l<h;l++)for(var c=i[l],u=l+1,d=i.length;u<d;u++)if(null===Pt(c.bbox,i[u].bbox))return[];for(var p=new _t(Ht.compare),f=0,m=i.length;f<m;f++)for(var g=i[f].getSweepEvents(),v=0,y=g.length;v<y;v++)p.insert(g[v]);for(var x=new $t(p),b=p.size,w=p.pop();w;){var M=w.key;if(p.size===b){var _=M.segment;throw new Error("Unable to pop() ".concat(M.isLeft?"left":"right"," SweepEvent ")+"[".concat(M.point.x,", ").concat(M.point.y,"] from segment #").concat(_.id," ")+"[".concat(_.leftSE.point.x,", ").concat(_.leftSE.point.y,"] -> ")+"[".concat(_.rightSE.point.x,", ").concat(_.rightSE.point.y,"] from queue. ")+"Please file a bug report.")}for(var E=x.process(M),S=0,T=E.length;S<T;S++){var A=E[S];void 0===A.consumedBy&&p.insert(A)}b=p.size,w=p.pop()}Dt.reset();var P=qt.factory(x.segments);return new Jt(P).getGeom()}}]),t}()),Kt=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return Qt.run("union",t,n)},te=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return Qt.run("intersection",t,n)},ee=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return Qt.run("xor",t,n)},ne=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return Qt.run("difference",t,n)},ie="undefined"!=typeof Float32Array?Float32Array:Array;function re(){var t=new ie(3);return ie!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function se(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function oe(t,e,n,i){return t[0]=e,t[1]=n,t[2]=i,t}var ae=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},le=function(t,e){var n=e[0]-t[0],i=e[1]-t[1],r=e[2]-t[2];return Math.sqrt(n*n+i*i+r*r)};!function(){var t=re()}();function he(){var t=new ie(2);return ie!=Float32Array&&(t[0]=0,t[1]=0),t}function ce(t,e){return t[0]=e[0],t[1]=e[1],t}function ue(t,e,n){return t[0]=e,t[1]=n,t}var de,pe=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t},fe=function(t,e){var n=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(n*n+i*i)};!function(){var t=he()}();class me{static RingPolygonArea(t,e){const n=t.length;let i=0;const r=e||!1;let s=t.map((function(t){return Array.isArray(t)?{x:t[0],y:t[1]}:t}));s[0]!==s[s.length-1]&&(s=s.concat(s[0]));for(let t=0;t<n;t++)i+=s[t].x*s[t+1].y-s[t].y*s[t+1].x;return r?i/2:Math.abs(i)/2}static Centroid(t){let e=0,n=0,i=0;for(let r=0;r<t.length;r+=1){const s=t[r],o=r===t.length-1?t[0]:t[r+1],a=.5*(s[0]*o[1]-o[0]*s[1]);e+=a,n+=a*((s[0]+o[0])/3),i+=a*((s[1]+o[1])/3)}return[n/e,i/e]}static PointToSegmentDistance(t,e,n){const i=[n[0]-e[0],n[1]-e[1]],r=[t[0]-e[0],t[1]-e[1]],s=i[0]*r[0]+i[1]*r[1],o=i[0]*i[0]+i[1]*i[1];let a=[e[0],e[1]];if(0!==o){const t=s/o;a=t>1?[n[0],n[1]]:t>0?[e[0]+i[0]*t,e[1]+i[1]*t]:[e[0],e[1]]}const l=[t[0]-a[0],t[1]-a[1]];return Math.sqrt(l[0]*l[0]+l[1]*l[1])}static PointInPolygon(t,e){let n=0;for(let i=0;i<e.length;i+=1){const r=e[i];for(let e=0;e<r.length;e+=1){const i=r[e],s=e===r.length-1?r[0]:r[e+1];i[1]>t[1]!=s[1]>t[1]&&t[0]<(s[0]-i[0])*(t[1]-i[1])/(s[1]-i[1])+i[0]&&(n+=1)}}return n%2!=0}static MinDistanceFromPointToPolygon(t,e){let n=1/0;for(let i=0;i<e.length;i+=1){const r=e[i];for(let e=0;e<r.length;e+=1){const i=r[e],s=e===r.length-1?r[0]:r[e+1];n=Math.min(n,this.PointToSegmentDistance(t,i,s))}}return n}static PointDistanceToPolygon(t,e){const n=this.MinDistanceFromPointToPolygon(t,e);return this.PointInPolygon(t,e)?n:-n}static CellOfPolygon(t,e,n,i){const r=this.PointDistanceToPolygon([t,e],i);return{x:t,y:e,h:n,d:r,max:r+n*Math.SQRT2}}static CentroidForPOI(t){if(!t||0===t.length||0===t[0].length)return[0,0];const e=t[0];let n=e[0][0],i=e[0][1],r=e[0][0],s=e[0][1];for(let t=1;t<e.length;t+=1){const[o,a]=e[t];o<n&&(n=o),a<i&&(i=a),o>r&&(r=o),a>s&&(s=a)}const o=r-n,a=s-i,l=Math.min(o,a);let h=l/2,c=[];for(let e=n;e<r;e+=l)for(let n=i;n<s;n+=l){const i=this.CellOfPolygon(e+h,n+h,h,t);c.push(i)}const[u,d]=this.Centroid(e);let p=this.CellOfPolygon(u,d,h,t);c.push(p);const f=l/1024;for(;c.length>1&&c[0].h>=f;){c=c.sort((t,e)=>e.max-t.max);for(let t=0;t<c.length;t+=1){const e=c[t];e.d>p.d&&(p=e)}for(let t=0;t<c.length;t+=1){if(c[t].max-p.d<=this.Epsilon){c=c.slice(0,t);break}}const e=[];h=c[0].h/2;for(let n=0;n<c.length;n+=1){const i=c[n];e.push(this.CellOfPolygon(i.x-h,i.y-h,h,t)),e.push(this.CellOfPolygon(i.x+h,i.y-h,h,t)),e.push(this.CellOfPolygon(i.x-h,i.y+h,h,t)),e.push(this.CellOfPolygon(i.x+h,i.y+h,h,t))}c=e}return[p.x,p.y]}static LinePlaneIntersection(t,e,n,i){const{THREE:r}=x.getInstance(),{x:s,y:o,z:a}=t,{x:l,y:h,z:c}=e,u=l-s,d=h-o,p=c-a,{x:f,y:m,z:g}=i,{x:v,y:y,z:b}=n,w=(f*(v-s)+m*(y-o)+g*(b-a))/(f*u+m*d+g*p);return new r.Vector3(s+w*u,o+w*d,a+w*p)}static SegmentPlaneIntersection(t,e,n,i){const r=this.LinePlaneIntersection(t,e,n,i);if(Number.isNaN(r.x)||!Number.isFinite(r.x))return;if(Number.isNaN(r.y)||!Number.isFinite(r.y))return;if(Number.isNaN(r.z)||!Number.isFinite(r.z))return;return r.clone().sub(t).dot(r.clone().sub(e))<=0?r:void 0}static MapPointOnPlane(t,e,n){const{THREE:i}=x.getInstance();let r=new i.Vector3(0,1,0);r.angleTo(n)<this.Epsilon&&(r=new i.Vector3(0,0,1));const s=(new i.Matrix4).lookAt(e,e.clone().add(n),r);return t.clone().applyMatrix4(s)}static ParameterToPlane(t,e,n,i){const{THREE:r}=x.getInstance(),s=Math.abs(i)/Math.sqrt(t*t+e*e+n*n);return{normal:new r.Vector3(t,e,n),constant:s}}static PlaneCutMeshPolygon(t,e,n,i){const r=[],s=[];for(let o=0;o<i.length;o+=3){const a=n[i[o]],l=n[i[o+1]],h=n[i[o+2]],c=[],u=[];u.push(this.SegmentPlaneIntersection(a,l,t,e)),u.push(this.SegmentPlaneIntersection(a,h,t,e)),u.push(this.SegmentPlaneIntersection(h,l,t,e)),u.forEach(t=>{if(!t)return;let e=!1;for(let n=0;n<c.length;n+=1)if(t.distanceTo(c[n])<=this.Epsilon){e=!0;break}e||c.push(t)}),1===c.length&&c.push(c[0]),c.length>0&&(s.push([r.length,r.length+1]),r.push(c[0],c[1]))}const o=[],a=[];for(;s.length>0;){let n=s.pop();const i=[n[0],n[1]];let l;do{const t=r[n[1]];l=void 0;for(let e=0;e<s.length;e+=1){const n=s[e],i=r[n[0]],o=r[n[1]];if(i.distanceTo(t)<=this.Epsilon){l=[n[0],n[1]],s.splice(e,1);break}if(o.distanceTo(t)<=this.Epsilon){l=[n[1],n[0]],s.splice(e,1);break}}l&&(i.push(l[1]),n=l)}while(l);o.push({loop:i.map(t=>r[t]),index:a.length});const h=i.map(n=>this.MapPointOnPlane(r[n],t,e));a.push(h.map(t=>[t.x,t.y]))}o.sort((t,e)=>{const n=a[t.index],i=a[e.index];return 0===i.length?-1:0===n.length?1:this.PointInPolygon(i[0],[n])?-1:this.PointInPolygon(n[0],[i])?1:0});const l=[],h=[],c=[];if(o.length>1)for(let t=0;t<o.length;t+=1)l.push(...o[t].loop),h.push(...a[o[t].index]),c.push(l.length);else for(let t=0;t<o.length;t+=1)l.push(...o[t].loop),h.push(...a[o[t].index]);return{vertices:l,holeIndices:c,vertices2D:h}}static TriangulatePolygon2D(t,e){const n=[];t.forEach(t=>{n.push(...t)});return W(n,e,2)}static TriangulatePolygonLoops2D(t){const e=[],n=[];t.forEach(t=>{e.push(...t),n.push(e.length)}),n.length>0&&n.splice(n.length-1,1);const i=me.TriangulatePolygon2D(e,n);return{vertices:e,triangles:i}}static LookAtMatrix(t,e,n){const{THREE:i}=x.getInstance(),r=e.clone().sub(t),s=r.clone().cross(n),o=s.clone().cross(r);r.normalize(),s.normalize(),o.normalize();const a=-s.dot(t),l=-o.dot(t),h=r.dot(t),c=new i.Matrix4;return c.set(s.x,s.y,s.z,a,o.x,o.y,o.z,l,-r.x,-r.y,-r.z,h,0,0,0,1),c}static FrustumMesh(t,e,n,i,r,s,o){const{THREE:a}=x.getInstance(),l=Math.tan(Math.PI*i/360),h=s*l,c=s*r*l,u=o*l,d=o*r*l,p=[];p.push(new a.Vector3(-c,-h,-s)),p.push(new a.Vector3(-c,h,-s)),p.push(new a.Vector3(c,h,-s)),p.push(new a.Vector3(c,-h,-s)),p.push(new a.Vector3(-d,-u,-o)),p.push(new a.Vector3(-d,u,-o)),p.push(new a.Vector3(d,u,-o)),p.push(new a.Vector3(d,-u,-o));const f=this.LookAtMatrix(t,e,n).clone().invert();return{vertices:p.map(t=>t.applyMatrix4(f)),triangles:[0,1,3,3,1,2,0,4,1,1,4,5,1,5,6,1,6,2,2,6,7,2,7,3,3,7,4,3,4,0,4,5,7,7,5,6]}}static PolygonIntersection(t,...e){return te(t,...e)}static PolygonDiff(t,...e){return ne(t,...e)}static PolygonUnion(t,...e){return Kt(t,...e)}static PolygonXOR(t,...e){return ee(t,...e)}static GetPathDistances(t){if(!t.length)return[];const e=[0];if(2===t[0].length)for(let n=1,i=t.length,r=ue(he(),t[0][0],t[0][1]),s=he();n<i;n+=1)ue(s,t[n][0],t[n][1]),e.push(e[n-1]+fe(r,s)),ce(r,s);else for(let n=1,i=t.length,r=oe(re(),t[0][0],t[0][1],t[0][2]),s=re();n<i;n+=1)oe(s,t[n][0],t[n][1],t[n][2]),e.push(e[n-1]+le(r,s)),se(r,s);return e}static GetPointOnDistance(t,e,n){let i=0,r=t.length-1,s=-1;for(;i<r-1;)if(s=Math.floor((i+r)/2),e[s]>n)r=s;else{if(!(e[s]<n)){i=s;break}i=s}if(s=i,s>-1){if(2===t[0].length){const i=ue(he(),t[s][0],t[s][1]);if(s===t.length-1||n<=0)return[i[0],i[1]];const r=e[s],o=ue(he(),t[s+1][0],t[s+1][1]),a=e[s+1]-r,l=pe(he(),o,i),h=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t}(he(),i,function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t}(he(),l,(n-r)/a));return[h[0],h[1]]}if(3===t[0].length){const i=oe(re(),t[s][0],t[s][1],t[s][2]);if(s===t.length-1||n<=0)return[i[0],i[1],i[2]];const r=e[s],o=oe(re(),t[s+1][0],t[s+1][1],t[s+1][2]),a=e[s+1]-r,l=ae(re(),o,i),h=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}(re(),i,function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}(re(),l,(n-r)/a));return[h[0],h[1],h[2]]}}throw new Error("Cannot find point on distance "+n)}static GetNearestPoint(t,e,n,i=.1,r=8){const s=n[n.length-1];let o,a,l,h,c,u,d=r,p=2===t.length?[0,0]:[0,0,0],f=0,m=1/0;for(let i,r,o=0;o<=s;o+=d)i=this.GetPointOnDistance(e,n,o),r=2===t.length?fe(ue(he(),t[0],t[1]),ue(he(),i[0],i[1])):le(oe(re(),t[0],t[1],t[2]),oe(re(),i[0],i[1],i[2])),r<m&&(p=i,f=o,m=r);for(d/=2;d>i;)l=f-d,o=this.GetPointOnDistance(e,n,l),c=2===t.length?fe(ue(he(),t[0],t[1]),ue(he(),o[0],o[1])):le(oe(re(),t[0],t[1],t[2]),oe(re(),o[0],o[1],o[2])),h=f+d,a=this.GetPointOnDistance(e,n,h),u=2===t.length?fe(ue(he(),t[0],t[1]),ue(he(),a[0],a[1])):le(oe(re(),t[0],t[1],t[2]),oe(re(),a[0],a[1],a[2])),l>=0&&c<m?(p=o,f=l,m=c):h<=s&&u<m?(p=a,f=h,m=u):d/=2;return{point:p,distance:f}}}me.Epsilon=1e-6,(de=t.PathCommand||(t.PathCommand={})).MOVE="m",de.LINE="l",de.CURVE="c";class ge{static GenerateStepsFromPath(t){const e=t.match(/([MLCmlc](?:(?:-?\d+(?:\.\d+)?(?:[eE]\d+)?)(?:,-?\d+(?:\.\d+)?(?:[eE]\d+)?)+))/g);if(!e)return[];const n=e.map(t=>{const e=t[0].toLowerCase(),n=t.slice(1).split(","),i=n.length,r=[];for(let t=0;t<i;t+=2)r.push([parseFloat(n[t]),parseFloat(n[t+1])]);return{command:e,coords:r}});for(let t=1;t<n.length;t++){const e=n[t-1],i=n[t];e.command===i.command&&e.coords[0]===i.coords[0]&&e.coords[1]===i.coords[t]&&(n.splice(t,1),t--)}return n}static GeneratePathFromSteps(t){return t.map(({command:t,coords:e})=>`${t}${e.flat(2).join(",")}`).join("")}static ParseHollows(t){const e=[],n=t.split(","),i=n.length;for(let t=0;t<i;t+=2)n[t].length&&n[t+1].length&&e.push([parseInt(n[t],10),parseInt(n[t+1],10)]);return e}static UnparseHollows(t){return t.flat(2).join(",")}static PolyonOfPathStep(e){const n=[];let i=[];return e.forEach(e=>{if(e.command===t.PathCommand.MOVE)i&&i.length>0&&(i.length>2&&i.push(i[0]),n.push(i)),i=[...e.coords];else if(e.command===t.PathCommand.LINE)i.push(...e.coords);else if(e.command===t.PathCommand.CURVE){const t=[];e.coords.forEach(e=>{t.push(...e)});new G(t).getLUT(10).forEach(t=>{i.push([t.x,t.y])})}}),i&&i.length>0&&(i.length>2&&i.push(i[0]),n.push(i)),n}static PolygonOfShape(t){const e=t.getSteps();return ge.PolyonOfPathStep(e)}}class ve{constructor(t,e=!1){this.element=t,this.needUpdate=e,this.shouldPlaceElement=!1}}class ye extends e.Object3D{constructor(){super(),this.elementListeners={onElementSelected:this.onElementSelected.bind(this)},this.eventMap=new Map,b.on(_.ELEMENT_SELECTED,this.elementListeners.onElementSelected)}onElementSelected(t){t===this&&b.emit(M.ELEMENT_SELECTED,t)}getUUID(){return this.universalId}setUUID(t){this.universalId=t}dispose(){b.off(_.ELEMENT_SELECTED,this.elementListeners.onElementSelected)}on(t,e){this.eventMap.has(t)||this.eventMap.set(t,new Set);const n=this.eventMap.get(t);n&&(n.add(e),this.eventMap.set(t,n))}emit(t,...e){const n=this.eventMap.get(t);n&&n.forEach(t=>{t(...e)}),b.emit(t,...e)}off(t,e){const n=this.eventMap.get(t);if(!n)throw Error(`Target event '${t}' not found`);n.delete(e)}}class xe{static dispose(t,e){if(e&&t.children&&t.children.length&&t.children.forEach(t=>{xe.dispose(t,e)}),t.isMesh){const e=t;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>{t.dispose()}):e.material.dispose())}}static getMouseIntersection(t,{x:e,y:n},i,r,s=-1){const{THREE:o}=x.getInstance(),a=s<0?Number.MAX_SAFE_INTEGER:s**2,l=new o.Raycaster;l.setFromCamera({x:e,y:n},i);const h=i.position.clone(),c=t.filter(t=>t.visible&&h.distanceToSquared(t.getWorldPosition(new o.Vector3))<a),u=l.intersectObjects(c,!0).filter(t=>!!t.face),d=new Set(r);for(let t=0;t<u.length;t++){let e=u[t].object;const n=[];for(;!(e instanceof ye)&&e.parent;)e=e.parent;for(;e&&(e instanceof ye&&n.push(e),e.parent);)e=e.parent;for(let e=0;e<n.length;e++)if(n[e]instanceof ye){if(!r){const i=u[t];return i.object=n[e],i}if(d.has(n[e])){const i=u[t];return i.object=n[e],i}}}return null}static getMouseIntersectionOnScreen(t,{x:e,y:n},{screenWidth:i,screenHeight:r},s,o,a,l=13,h){const{THREE:c}=x.getInstance(),u=[],d=new c.Vector2(e,n),p=new c.Frustum;p.setFromProjectionMatrix((new c.Matrix4).multiplyMatrices(o.projectionMatrix,o.matrixWorldInverse));const f=o.position.clone(),m=l<0?Number.MAX_SAFE_INTEGER:l**2;t.forEach(t=>{const e=t.position.clone().project(o),n=new c.Vector2((e.x+1)/2*i,(1-e.y)/2*r).distanceTo(d),a=this.getMesh(t);if(!a)return;let l=!1,g=!1;if(h){const n=h.get(t);if(n){l=!0;const t=new c.Vector2((e.x+1)/2*i,(1-e.y)/2*r),s=t.x-n[0]/2,o=t.x+n[0]/2,a=t.y-n[1]/2,h=t.y+n[1]/2;Math.abs(e.z)<=1&&d.x<=o&&d.x>=s&&d.y>=a&&d.y<=h&&(g=!0)}}(l?g:n<=s)&&f.distanceToSquared(a.getWorldPosition(new c.Vector3))<m&&p.intersectsObject(a)&&a.visible&&t.visible&&u.push({e:t,d:n})}),u.sort((t,e)=>t.d-e.d);const g=new Set(a);for(let t=0;t<u.length;t++){const e=u[t].e;if(!a)return e;if(g.has(e))return e}return null}static getHorizontalPlaneCoordinate({x:t,y:e},n,i){if(!i)return null;const{THREE:r}=x.getInstance(),{clientWidth:s,clientHeight:o}=n.renderer.domElement;if(s<=0||o<=0)return null;const a=t/s*2-1,l=1-e/o*2,h=new r.Vector3(a,l,0).unproject(i);return new r.Vector2(h.x,h.y)}static getHorizontalPlaneCoordinate3({x:t,y:e},n,i){if(!i)return null;const{THREE:r}=x.getInstance(),{clientWidth:s,clientHeight:o}=n.renderer.domElement;if(s<=0||o<=0)return null;const a=t/s*2-1,l=1-e/o*2;return new r.Vector3(a,l,0).unproject(i)}static projectToScreenCoordinate(t,e,n){if(!n)return null;const{clientWidth:i,clientHeight:r}=e.renderer.domElement;if(i<=0||r<=0)return null;const s=t.clone().project(n);return{x:.5*(s.x+1)*i,y:.5*(1-s.y)*r}}static getMesh(t){const{THREE:e}=x.getInstance(),n=t instanceof e.Mesh?t:null;if(!n&&t.children.length)for(let e=0;e<t.children.length;e+=1){const n=this.getMesh(t.children[e]);if(n)return n}return n}static debounce(t,e){let n;return function(i,...r){i&&t.bind(null,...r),n?(clearTimeout(n),n=setTimeout(t.bind(null,...r),e)):n=setTimeout(t.bind(null,...r),e)}}}class be{static GenerateShapeFromSteps(e){const{THREE:n}=x.getInstance(),i=[];let r=null,s=0;const o=new n.Shape;return e.forEach(({coords:e,command:a})=>{switch(a){case t.PathCommand.MOVE:if(1!==e.length)throw new Error("Parse path command error. Command: "+a);s+=1,s>1?(r=new n.Path,i.push(r),r.moveTo(e[0][0],e[0][1])):o.moveTo(e[0][0],e[0][1]);break;case t.PathCommand.LINE:if(1!==e.length)throw new Error("Parse path command error. Command: "+a);r&&s>1?r.lineTo(e[0][0],e[0][1]):o.lineTo(e[0][0],e[0][1]);break;case t.PathCommand.CURVE:if(3!==e.length)throw new Error("Parse path command error. Command: "+a);r&&s>1?r.bezierCurveTo(e[0][0],e[0][1],e[1][0],e[1][1],e[2][0],e[2][1]):o.bezierCurveTo(e[0][0],e[0][1],e[1][0],e[1][1],e[2][0],e[2][1])}}),o.holes=i,o}}var we=function(t,e){return t[0]=e[0],t[1]=e[1],t};const Me="KHR_binary_glTF",_e="KHR_draco_mesh_compression",Ee="KHR_lights_punctual",Se="KHR_materials_clearcoat",Te="KHR_materials_pbrSpecularGlossiness",Ae="KHR_materials_transmission",Pe="KHR_materials_unlit",Le="KHR_texture_basisu",Re="KHR_texture_transform",Ce="KHR_mesh_quantization",Ie="EXT_texture_webp",Oe="EXT_meshopt_compression",De=0,ze=1,Ne=2,Ue=3,Be=4,Fe=5,Ve=6,ke={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},He={9728:e.NearestFilter,9729:e.LinearFilter,9984:e.NearestMipmapNearestFilter,9985:e.LinearMipmapNearestFilter,9986:e.NearestMipmapLinearFilter,9987:e.LinearMipmapLinearFilter},Ge={33071:e.ClampToEdgeWrapping,33648:e.MirroredRepeatWrapping,10497:e.RepeatWrapping},We={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},je={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Xe={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ye={CUBICSPLINE:void 0,LINEAR:e.InterpolateLinear,STEP:e.InterpolateDiscrete},qe="OPAQUE",Ze="MASK",Je="BLEND";function $e(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}function Qe(t){const{THREE:e}=x.getInstance();return void 0===t.DefaultMaterial&&(t.DefaultMaterial=new e.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:e.FrontSide})),t.DefaultMaterial}function Ke(t,e,n){for(const i in n.extensions)void 0===t[i]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=n.extensions[i])}function tn(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function en(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let n=0,i=e.weights.length;n<i;n++)t.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const{targetNames:n}=e.extras;if(t.morphTargetInfluences.length===n.length){t.morphTargetDictionary={};for(let e=0,i=n.length;e<i;e++)t.morphTargetDictionary[n[e]]=e}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function nn(t){let e="";const n=Object.keys(t).sort();for(let i=0,r=n.length;i<r;i++)e+=`${n[i]}:${t[n[i]]};`;return e}function rn(t){const e=t.extensions&&t.extensions[_e];let n;return n=e?`draco:${e.bufferView}:${e.indices}:${nn(e.attributes)}`:`${t.indices}:${nn(t.attributes)}:${t.mode}`,n}class sn{constructor(){this.objects={}}get(t){return this.objects[t]}add(t,e){this.objects[t]=e}remove(t){delete this.objects[t]}removeAll(){this.objects={}}}class on{constructor(t){this.parser=t,this.name=Ee,this.cache={refs:{},uses:{}}}_markDefs(){const{parser:t}=this,e=this.parser.json.nodes||[];for(let n=0,i=e.length;n<i;n++){const i=e[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&t._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(t){const{parser:e}=this,n="light:"+t;let i=e.cache.get(n);if(i)return i;const{json:r}=e,s=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t];let o;const{THREE:a}=x.getInstance(),l=new a.Color(16777215);void 0!==s.color&&l.fromArray(s.color);const h=void 0!==s.range?s.range:0;switch(s.type){case"directional":o=new a.DirectionalLight(l),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new a.PointLight(l),o.distance=h;break;case"spot":o=new a.SpotLight(l),o.distance=h,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,o.angle=s.spot.outerConeAngle,o.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return o.position.set(0,0,0),o.decay=2,void 0!==s.intensity&&(o.intensity=s.intensity),o.name=e.createUniqueName(s.name||"light_"+t),i=Promise.resolve(o),e.cache.add(n,i),i}createNodeAttachment(t){const e=this,{parser:n}=this,{json:i}=n,r=i.nodes[t],s=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===s?null:this._loadLight(s).then(t=>n._getNodeRef(e.cache,s,t))}}class an{constructor(){this.name=Pe}getMaterialType(){const{THREE:t}=x.getInstance();return t.MeshBasicMaterial}extendParams(t,e,n){const i=[],{THREE:r}=x.getInstance();t.color=new r.Color(1,1,1),t.opacity=1;const s=e.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const e=s.baseColorFactor;t.color.fromArray(e),t.opacity=e[3]}void 0!==s.baseColorTexture&&i.push(n.assignTexture(t,"map",s.baseColorTexture))}return Promise.all(i)}}class ln{constructor(t){this.parser=t,this.name=Se}getMaterialType(t){const e=this.parser.json.materials[t];if(!e.extensions||!e.extensions[this.name])return null;const{THREE:n}=x.getInstance();return n.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name],{THREE:o}=x.getInstance();if(void 0!==s.clearcoatFactor&&(e.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&r.push(n.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&r.push(n.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(r.push(n.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const t=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new o.Vector2(t,-t)}return Promise.all(r)}}class hn{constructor(t){this.parser=t,this.name=Ae}getMaterialType(t){const{parser:e}=this,n=e.json.materials[t];if(!n.extensions||!n.extensions[this.name])return null;const{THREE:i}=x.getInstance();return i.MeshPhysicalMaterial}extendMaterialParams(t,e){const{parser:n}=this,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.transmissionFactor&&(e.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(n.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class cn{constructor(t){this.parser=t,this.name=Le}loadTexture(t){const{parser:e}=this,{json:n}=e,i=n.textures[t];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],s=n.images[r.source],o=e.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,s,o)}}class un{constructor(t){this.parser=t,this.name=Ie,this.isSupported=null}loadTexture(t){const{name:e}=this,{parser:n}=this,{json:i}=n,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],o=i.images[s.source];let a=n.textureLoader;if(o.uri){const t=n.options.manager.getHandler(o.uri);null!==t&&(a=t)}return this.detectSupport().then(r=>{if(r)return n.loadTextureImage(t,o,a);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(t=>{const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}})),this.isSupported}}class dn{constructor(t){this.name=Oe,this.parser=t}loadBufferView(t){const{json:e}=this.parser,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const t=n.extensions[this.name],i=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,r.ready]).then(e=>{const n=t.byteOffset||0,i=t.byteLength||0,{count:s}=t,o=t.byteStride,a=new ArrayBuffer(s*o),l=new Uint8Array(e[0],n,i);return r.decodeGltfBuffer(new Uint8Array(a),s,o,l,t.mode,t.filter),a})}return null}}const pn=1313821514,fn=5130562;class mn{constructor(t){const{THREE:e}=x.getInstance();this.name=Me,this.content=null,this.body=null;const n=new DataView(t,0,12);if(this.header={magic:e.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},"glTF"!==this.header.magic)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-12,r=new DataView(t,12);let s=0;for(;s<i;){const n=r.getUint32(s,!0);s+=4;const i=r.getUint32(s,!0);if(s+=4,i===pn){const i=new Uint8Array(t,12+s,n);this.content=e.LoaderUtils.decodeText(i)}else if(i===fn){const e=12+s;this.body=t.slice(e,e+n)}s+=n}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class gn{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=_e,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const{json:n}=this,{dracoLoader:i}=this,r=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,o={},a={},l={};for(const t in s){const e=je[t]||t.toLowerCase();o[e]=s[t]}for(const e in t.attributes){const i=je[e]||e.toLowerCase();if(void 0!==s[e]){const r=n.accessors[t.attributes[e]],s=ke[r.componentType];l[i]=s,a[i]=!0===r.normalized}}return e.getDependency("bufferView",r).then(t=>new Promise(e=>{i.decodeDracoFile(t,t=>{for(const e in t.attributes){const n=t.attributes[e],i=a[e];void 0!==i&&(n.normalized=i)}e(t)},o,l)}))}}class vn{constructor(){this.name=Re}extendTexture(t,e){return t=t.clone(),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),void 0!==e.texCoord&&console.warn(`THREE.GLTFLoader: Custom UV sets in "${this.name}" extension not yet supported.`),t.needsUpdate=!0,t}}class yn extends e.MeshStandardMaterial{constructor(t){super(t),this.isGLTFSpecularGlossinessMaterial=!0;const e=["#ifdef USE_SPECULARMAP"," uniform sampler2D specularMap;","#endif"].join("\n"),n=["#ifdef USE_GLOSSINESSMAP"," uniform sampler2D glossinessMap;","#endif"].join("\n"),i=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP"," vec4 texelSpecular = texture2D( specularMap, vUv );"," texelSpecular = sRGBToLinear( texelSpecular );"," // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture"," specularFactor *= texelSpecular.rgb;","#endif"].join("\n"),r=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP"," vec4 texelGlossiness = texture2D( glossinessMap, vUv );"," // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture"," glossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),s=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.specularRoughness += geometryRoughness;","material.specularRoughness = min( material.specularRoughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),{THREE:o}=x.getInstance(),a={specular:{value:(new o.Color).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=a,this.onBeforeCompile=function(t){for(const e in a)t.uniforms[e]=a[e];t.fragmentShader=t.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",e).replace("#include <metalnessmap_pars_fragment>",n).replace("#include <roughnessmap_fragment>",i).replace("#include <metalnessmap_fragment>",r).replace("#include <lights_physical_fragment>",s)},Object.defineProperties(this,{specular:{get:()=>a.specular.value,set(t){a.specular.value=t}},specularMap:{get:()=>a.specularMap.value,set(t){a.specularMap.value=t,t?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:()=>a.glossiness.value,set(t){a.glossiness.value=t}},glossinessMap:{get:()=>a.glossinessMap.value,set(t){a.glossinessMap.value=t,t?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(t)}copy(t){const{THREE:e}=x.getInstance();return e.MeshStandardMaterial.prototype.copy.call(this,t),this.specularMap=t.specularMap,this.specular.copy(t.specular),this.glossinessMap=t.glossinessMap,this.glossiness=t.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class xn{constructor(){this.name=Te,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"]}getMaterialType(){return yn}extendParams(t,e,n){const{THREE:i}=x.getInstance(),r=e.extensions[this.name];t.color=new i.Color(1,1,1),t.opacity=1;const s=[];if(Array.isArray(r.diffuseFactor)){const e=r.diffuseFactor;t.color.fromArray(e),t.opacity=e[3]}if(void 0!==r.diffuseTexture&&s.push(n.assignTexture(t,"map",r.diffuseTexture)),t.emissive=new i.Color(0,0,0),t.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,t.specular=new i.Color(1,1,1),Array.isArray(r.specularFactor)&&t.specular.fromArray(r.specularFactor),void 0!==r.specularGlossinessTexture){const e=r.specularGlossinessTexture;s.push(n.assignTexture(t,"glossinessMap",e)),s.push(n.assignTexture(t,"specularMap",e))}return Promise.all(s)}createMaterial(t){const{THREE:e}=x.getInstance(),n=new yn(t);return n.fog=!0,n.color=t.color,n.map=void 0===t.map?null:t.map,n.lightMap=null,n.lightMapIntensity=1,n.aoMap=void 0===t.aoMap?null:t.aoMap,n.aoMapIntensity=1,n.emissive=t.emissive,n.emissiveIntensity=1,n.emissiveMap=void 0===t.emissiveMap?null:t.emissiveMap,n.bumpMap=void 0===t.bumpMap?null:t.bumpMap,n.bumpScale=1,n.normalMap=void 0===t.normalMap?null:t.normalMap,n.normalMapType=e.TangentSpaceNormalMap,t.normalScale&&(n.normalScale=t.normalScale),n.displacementMap=null,n.displacementScale=1,n.displacementBias=0,n.specularMap=void 0===t.specularMap?null:t.specularMap,n.specular=t.specular,n.glossinessMap=void 0===t.glossinessMap?null:t.glossinessMap,n.glossiness=t.glossiness,n.alphaMap=null,n.envMap=void 0===t.envMap?null:t.envMap,n.envMapIntensity=1,n.refractionRatio=.98,n}}class bn{constructor(){this.name=Ce}}class wn extends e.Interpolant{constructor(){super(...arguments),this.beforeStart_=wn.prototype.copySampleValue_,this.afterEnd_=wn.prototype.copySampleValue_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,{valueSize:i}=this,r=t*i*3+i;for(let t=0;t!==i;t++)e[t]=n[r+t];return e}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=2*o,l=3*o,h=i-e,c=(n-e)/h,u=c*c,d=u*c,p=t*l,f=p-l,m=-2*d+3*u,g=d-u,v=1-m,y=g-u+c;for(let t=0;t!==o;t++){const e=s[f+t+o],n=s[f+t+a]*h,i=s[p+t+o],l=s[p+t]*h;r[t]=v*e+y*n+m*i+g*l}return r}}function Mn(t,e,n){const{attributes:i}=e,r=[];function s(e,i){return n.getDependency("accessor",e).then(e=>{t.setAttribute(i,e)})}for(const e in i){const n=je[e]||e.toLowerCase();n in t.attributes||r.push(s(i[e],n))}if(void 0!==e.indices&&!t.index){const i=n.getDependency("accessor",e.indices).then(e=>{t.setIndex(e)});r.push(i)}return tn(t,e),function(t,e,n){const{attributes:i}=e,{THREE:r}=x.getInstance(),s=new r.Box3;if(void 0===i.POSITION)return;{const t=n.json.accessors[i.POSITION],{min:e}=t,{max:o}=t;if(void 0===e||void 0===o)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");s.set(new r.Vector3(e[0],e[1],e[2]),new r.Vector3(o[0],o[1],o[2]))}const{targets:o}=e;if(void 0!==o){const t=new r.Vector3,e=new r.Vector3;for(let i=0,r=o.length;i<r;i++){const r=o[i];if(void 0!==r.POSITION){const i=n.json.accessors[r.POSITION],{min:s}=i,{max:o}=i;void 0!==s&&void 0!==o?(e.setX(Math.max(Math.abs(s[0]),Math.abs(o[0]))),e.setY(Math.max(Math.abs(s[1]),Math.abs(o[1]))),e.setZ(Math.max(Math.abs(s[2]),Math.abs(o[2]))),t.max(e)):console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(t)}t.boundingBox=s;const a=new r.Sphere;s.getCenter(a.center),a.radius=s.min.distanceTo(s.max)/2,t.boundingSphere=a}(t,e,n),Promise.all(r).then(()=>void 0!==e.targets?function(t,e,n){let i=!1,r=!1;for(let t=0,n=e.length;t<n;t++){const n=e[t];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(r=!0),i&&r)break}if(!i&&!r)return Promise.resolve(t);const s=[],o=[];for(let a=0,l=e.length;a<l;a++){const l=e[a];if(i){const e=void 0!==l.POSITION?n.getDependency("accessor",l.POSITION):t.attributes.position;s.push(e)}if(r){const e=void 0!==l.NORMAL?n.getDependency("accessor",l.NORMAL):t.attributes.normal;o.push(e)}}return Promise.all([Promise.all(s),Promise.all(o)]).then(e=>{const n=e[0],s=e[1];return i&&(t.morphAttributes.position=n),r&&(t.morphAttributes.normal=s),t.morphTargetsRelative=!0,t})}(t,e.targets,n):t)}function _n(t,e){let n=t.getIndex();if(null===n){const e=[],i=t.getAttribute("position");if(void 0===i)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t<i.count;t++)e.push(t);t.setIndex(e),n=t.getIndex()}const i=n.count-2,r=[],{THREE:s}=x.getInstance();if(e===s.TriangleFanDrawMode)for(let t=1;t<=i;t++)r.push(n.getX(0)),r.push(n.getX(t)),r.push(n.getX(t+1));else for(let t=0;t<i;t++)t%2==0?(r.push(n.getX(t)),r.push(n.getX(t+1)),r.push(n.getX(t+2))):(r.push(n.getX(t+2)),r.push(n.getX(t+1)),r.push(n.getX(t)));r.length/3!==i&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=t.clone();return o.setIndex(r),o}class En{constructor(t,e){this.loadScene=(()=>{function t(e,n,i,r){const{THREE:s}=x.getInstance(),o=i.nodes[e];return r.getDependency("node",e).then(t=>{if(void 0===o.skin)return t;let e;return r.getDependency("skin",o.skin).then(t=>{e=t;const n=[];for(let t=0,i=e.joints.length;t<i;t++)n.push(r.getDependency("node",e.joints[t]));return Promise.all(n)}).then(n=>(t.traverse(t=>{if(!t.isMesh)return;const i=[],r=[];for(let t=0,o=n.length;t<o;t++){const o=n[t];if(o){i.push(o);const n=new s.Matrix4;void 0!==e.inverseBindMatrices&&n.fromArray(e.inverseBindMatrices.array,16*t),r.push(n)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[t])}t.bind(new s.Skeleton(i,r),t.matrixWorld)}),t))}).then(e=>{n.add(e);const s=[];if(o.children){const n=o.children;for(let o=0,a=n.length;o<a;o++){const a=n[o];s.push(t(a,e,i,r))}}return Promise.all(s)})}const e=this;return function(n){const i=e.json,r=e.extensions,s=e.json.scenes[n],o=e,{THREE:a}=x.getInstance(),l=new a.Group;s.name&&(l.name=o.createUniqueName(s.name)),tn(l,s),s.extensions&&Ke(r,l,s);const h=s.nodes||[],c=[];for(let e=0,n=h.length;e<n;e++)c.push(t(h[e],l,i,o));return Promise.all(c).then(()=>l)}})(),this.json=t||{},this.extensions={},this.plugins={},this.options=e||{},this.cache=new sn,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.nodeNamesUsed={};const{THREE:n}=x.getInstance();"undefined"!=typeof createImageBitmap&&!1===/Firefox/.test(navigator.userAgent)?this.textureLoader=new n.ImageBitmapLoader(this.options.manager):this.textureLoader=new n.TextureLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new n.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this._invokeAll(t=>t._markDefs&&t._markDefs()),Promise.all(this._invokeAll(t=>t.beforeRoot&&t.beforeRoot())).then(()=>Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])).then(e=>{const s={scene:e[0][i.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:i.asset,parser:n,userData:{}};Ke(r,s,i),tn(s,i),Promise.all(n._invokeAll(t=>t.afterRoot&&t.afterRoot(s))).then(()=>{t(s)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=e.length;n<i;n++){const i=e[n].joints;for(let e=0,n=i.length;e<n;e++)t[i[e]].isBone=!0}for(let e=0,i=t.length;e<i;e++){const i=t[e];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,n){if(t.refs[e]<=1)return n;const i=n.clone();return i.name+="_instance_"+t.uses[e]++,i}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){const i=t(e[n]);if(i)return i}}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const n=[];for(let i=0;i<e.length;i++){const r=t(e[i]);r&&n.push(r)}return n}getDependency(t,e){const n=`${t}:${e}`;let i=this.cache.get(n);if(!i){switch(t){case"scene":i=this.loadScene(e);break;case"node":i=this.loadNode(e);break;case"mesh":i=this._invokeOne(t=>t.loadMesh&&t.loadMesh(e));break;case"accessor":i=this.loadAccessor(e);break;case"bufferView":i=this._invokeOne(t=>t.loadBufferView&&t.loadBufferView(e));break;case"buffer":i=this.loadBuffer(e);break;case"material":i=this._invokeOne(t=>t.loadMaterial&&t.loadMaterial(e));break;case"texture":i=this._invokeOne(t=>t.loadTexture&&t.loadTexture(e));break;case"skin":i=this.loadSkin(e);break;case"animation":i=this.loadAnimation(e);break;case"camera":i=this.loadCamera(e);break;default:throw new Error("Unknown type: "+t)}this.cache.add(n,i)}return i}getDependencies(t){let e=this.cache.get(t);if(!e){const n=this,i=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(i.map((e,i)=>n.getDependency(t,i))),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],n=this.fileLoader;if(e.type&&"arraybuffer"!==e.type)throw new Error(`THREE.GLTFLoader: ${e.type} buffer type is not supported.`);if(void 0===e.uri&&0===t)return Promise.resolve(this.extensions[Me].body);const i=this.options;return new Promise((t,r)=>{n.load($e(e.uri,i.path),t,void 0,()=>{r(new Error(`THREE.GLTFLoader: Failed to load buffer "${e.uri}".`))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(t=>{const n=e.byteLength||0,i=e.byteOffset||0;return t.slice(i,i+n)})}loadAccessor(t){const e=this,n=this.json,i=this.json.accessors[t],{THREE:r}=x.getInstance();if(void 0===i.bufferView&&void 0===i.sparse)return Promise.resolve(null);const s=[];return void 0!==i.bufferView?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),void 0!==i.sparse&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then(t=>{const s=t[0],o=We[i.type],a=ke[i.componentType],l=a.BYTES_PER_ELEMENT,h=l*o,c=i.byteOffset||0,u=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,d=!0===i.normalized;let p,f;if(u&&u!==h){const t=Math.floor(c/u),n=`InterleavedBuffer:${i.bufferView}:${i.componentType}:${t}:${i.count}`;let h=e.cache.get(n);h||(p=new a(s,t*u,i.count*u/l),h=new r.InterleavedBuffer(p,u/l),e.cache.add(n,h)),f=new r.InterleavedBufferAttribute(h,o,c%u/l,d)}else p=null===s?new a(i.count*o):new a(s,c,i.count*o),f=new r.BufferAttribute(p,o,d);if(void 0!==i.sparse){const e=We.SCALAR,n=ke[i.sparse.indices.componentType],l=i.sparse.indices.byteOffset||0,h=i.sparse.values.byteOffset||0,c=new n(t[1],l,i.sparse.count*e),u=new a(t[2],h,i.sparse.count*o);null!==s&&(f=new r.BufferAttribute(f.array.slice(),f.itemSize,f.normalized));for(let t=0,e=c.length;t<e;t++){const e=c[t];if(f.setX(e,u[t*o]),o>=2&&f.setY(e,u[t*o+1]),o>=3&&f.setZ(e,u[t*o+2]),o>=4&&f.setW(e,u[t*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return f})}loadTexture(t){const e=this.json,n=this.options,i=e.textures[t],r=e.images[i.source];let s=this.textureLoader;if(r.uri){const t=n.manager.getHandler(r.uri);null!==t&&(s=t)}return this.loadTextureImage(t,r,s)}loadTextureImage(e,n,i){const r=this,s=this.json,o=this.options,a=s.textures[e];let l={};l=S.GetEnv()===t.Env.Miniapp?{}:self?self.URL||self.webkitURL:{};const{THREE:h}=x.getInstance();let c=n.uri,u=!1,d=!0;if("image/jpeg"===n.mimeType&&(d=!1),void 0!==n.bufferView)c=r.getDependency("bufferView",n.bufferView).then(e=>{if("image/png"===n.mimeType){const t=new DataView(e,25,1).getUint8(0);d=6===t||4===t||3===t}u=!0;try{if(S.GetEnv()===t.Env.Miniapp)return c=wx.arrayBufferToBase64(e),"data:image/png;base64,"+c}catch{}const i=new Blob([e],{type:n.mimeType});return c=l.createObjectURL(i),c});else if(void 0===n.uri)throw new Error(`THREE.GLTFLoader: Image ${e} is missing URI and bufferView`);return Promise.resolve(c).then(t=>new Promise((e,n)=>{let r=e;!0===i.isImageBitmapLoader&&(r=function(t){e(new h.CanvasTexture(t))}),i.load($e(t,o.path),r,void 0,n)})).then(n=>{try{S.GetEnv(),t.Env.Miniapp}catch{!0===u&&l.revokeObjectURL(c)}n.flipY=!1,a.name&&(n.name=a.name),d||(n.format=h.RGBFormat);const i=(s.samplers||{})[a.sampler]||{};return n.magFilter=He[i.magFilter]||h.LinearFilter,n.minFilter=He[i.minFilter]||h.LinearMipmapLinearFilter,n.wrapS=Ge[i.wrapS]||h.RepeatWrapping,n.wrapT=Ge[i.wrapT]||h.RepeatWrapping,r.associations.set(n,{type:"textures",index:e}),n})}assignTexture(t,e,n){const i=this;return this.getDependency("texture",n.index).then(r=>{if(void 0===n.texCoord||0===n.texCoord||"aoMap"===e&&1===n.texCoord||console.warn(`THREE.GLTFLoader: Custom UV set ${n.texCoord} for texture ${e} not yet supported.`),i.extensions[Re]){const t=void 0!==n.extensions?n.extensions[Re]:void 0;if(t){const e=i.associations.get(r);r=i.extensions[Re].extendTexture(r,t),i.associations.set(r,e)}}t[e]=r})}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const i=void 0!==e.attributes.tangent,r=void 0!==e.attributes.color,s=void 0===e.attributes.normal,o=!0===t.isSkinnedMesh,a=Object.keys(e.morphAttributes).length>0,l=a&&void 0!==e.morphAttributes.normal,{THREE:h}=x.getInstance();if(t.isPoints){const t="PointsMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new h.PointsMaterial,h.Material.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,e.sizeAttenuation=!1,this.cache.add(t,e)),n=e}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new h.LineBasicMaterial,h.Material.prototype.copy.call(e,n),e.color.copy(n.color),this.cache.add(t,e)),n=e}if(i||r||s||o||a){let t=`ClonedMaterial:${n.uuid}:`;n.isGLTFSpecularGlossinessMaterial&&(t+="specular-glossiness:"),o&&(t+="skinning:"),i&&(t+="vertex-tangents:"),r&&(t+="vertex-colors:"),s&&(t+="flat-shading:"),a&&(t+="morph-targets:"),l&&(t+="morph-normals:");let e=this.cache.get(t);e||(e=n.clone(),o&&(e.skinning=!0),r&&(e.vertexColors=!0),s&&(e.flatShading=!0),a&&(e.morphTargets=!0),l&&(e.morphNormals=!0),i&&(e.vertexTangents=!0,e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(n))),n=e}n.aoMap&&void 0===e.attributes.uv2&&void 0!==e.attributes.uv&&e.setAttribute("uv2",e.attributes.uv),t.material=n}getMaterialType(){const{THREE:t}=x.getInstance();return t.MeshStandardMaterial}loadMaterial(t){const e=this,n=this.json,i=this.extensions,r=n.materials[t];let s;const o={},a=r.extensions||{},l=[],{THREE:h}=x.getInstance();if(a[Te]){const t=i[Te];s=t.getMaterialType(),l.push(t.extendParams(o,r,e))}else if(a[Pe]){const t=i[Pe];s=t.getMaterialType(),l.push(t.extendParams(o,r,e))}else{const n=r.pbrMetallicRoughness||{};if(o.color=new h.Color(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;o.color.fromArray(t),o.opacity=t[3]}void 0!==n.baseColorTexture&&l.push(e.assignTexture(o,"map",n.baseColorTexture)),o.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,o.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(e.assignTexture(o,"metalnessMap",n.metallicRoughnessTexture)),l.push(e.assignTexture(o,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne(e=>e.getMaterialType&&e.getMaterialType(t)),l.push(Promise.all(this._invokeAll(e=>e.extendMaterialParams&&e.extendMaterialParams(t,o))))}!0===r.doubleSided&&(o.side=h.DoubleSide);const c=r.alphaMode||qe;return c===Je?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,c===Ze&&(o.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==h.MeshBasicMaterial&&(l.push(e.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new h.Vector2(1,-1),void 0!==r.normalTexture.scale&&o.normalScale.set(r.normalTexture.scale,-r.normalTexture.scale)),void 0!==r.occlusionTexture&&s!==h.MeshBasicMaterial&&(l.push(e.assignTexture(o,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(o.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==h.MeshBasicMaterial&&(o.emissive=(new h.Color).fromArray(r.emissiveFactor)),void 0!==r.emissiveTexture&&s!==h.MeshBasicMaterial&&l.push(e.assignTexture(o,"emissiveMap",r.emissiveTexture)),Promise.all(l).then(()=>{let n;return n=s===yn?i[Te].createMaterial(o):new s(o),r.name&&(n.name=r.name),n.map&&(n.map.encoding=h.sRGBEncoding),n.emissiveMap&&(n.emissiveMap.encoding=h.sRGBEncoding),tn(n,r),e.associations.set(n,{type:"materials",index:t}),r.extensions&&Ke(i,n,r),n})}createUniqueName(t){const{THREE:e}=x.getInstance(),n=e.PropertyBinding.sanitizeNodeName(t||"");let i=n;for(let t=1;this.nodeNamesUsed[i];++t)i=`${n}_${t}`;return this.nodeNamesUsed[i]=!0,i}loadGeometries(t){const e=this,n=this.extensions,i=this.primitiveCache;function r(t){return n[_e].decodePrimitive(t,e).then(n=>Mn(n,t,e))}const s=[],{THREE:o}=x.getInstance();for(let n=0,a=t.length;n<a;n++){const a=t[n],l=rn(a),h=i[l];if(h)s.push(h.promise);else{let t;t=a.extensions&&a.extensions[_e]?r(a):Mn(new o.BufferGeometry,a,e),i[l]={primitive:a,promise:t},s.push(t)}}return Promise.all(s)}loadMesh(t){const e=this,n=this.json,i=this.extensions,r=n.meshes[t],s=r.primitives,o=[],{THREE:a}=x.getInstance();for(let t=0,e=s.length;t<e;t++){const e=void 0===s[t].material?Qe(this.cache):this.getDependency("material",s[t].material);o.push(e)}return o.push(e.loadGeometries(s)),Promise.all(o).then(n=>{const o=n.slice(0,n.length-1),l=n[n.length-1],h=[];for(let n=0,c=l.length;n<c;n++){const c=l[n],u=s[n];let d;const p=o[n];if(u.mode===Be||u.mode===Fe||u.mode===Ve||void 0===u.mode)d=!0===r.isSkinnedMesh?new a.SkinnedMesh(c,p):new a.Mesh(c,p),!0!==d.isSkinnedMesh||d.geometry.attributes.skinWeight.normalized||d.normalizeSkinWeights(),u.mode===Fe?d.geometry=_n(d.geometry,a.TriangleStripDrawMode):u.mode===Ve&&(d.geometry=_n(d.geometry,a.TriangleFanDrawMode));else if(u.mode===ze)d=new a.LineSegments(c,p);else if(u.mode===Ue)d=new a.Line(c,p);else if(u.mode===Ne)d=new a.LineLoop(c,p);else{if(u.mode!==De)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);d=new a.Points(c,p)}Object.keys(d.geometry.morphAttributes).length>0&&en(d,r),d.name=e.createUniqueName(r.name||"mesh_"+t),tn(d,r),u.extensions&&Ke(i,d,u),e.assignFinalMaterial(d),h.push(d)}if(1===h.length)return h[0];const c=new a.Group;for(let t=0,e=h.length;t<e;t++)c.add(h[t]);return c})}loadCamera(t){let e;const n=this.json.cameras[t],i=n[n.type],{THREE:r}=x.getInstance();if(i)return"perspective"===n.type?e=new r.PerspectiveCamera(r.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(e=new r.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),tn(e,n),Promise.resolve(e);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(t){const e=this.json.skins[t],n={joints:e.joints};return void 0===e.inverseBindMatrices?Promise.resolve(n):this.getDependency("accessor",e.inverseBindMatrices).then(t=>(n.inverseBindMatrices=t,n))}loadAnimation(t){const e=this.json.animations[t],n=[],i=[],r=[],s=[],o=[],{THREE:a}=x.getInstance();for(let t=0,a=e.channels.length;t<a;t++){const a=e.channels[t],l=e.samplers[a.sampler],h=a.target,c=void 0!==h.node?h.node:h.id,u=void 0!==e.parameters?e.parameters[l.input]:l.input,d=void 0!==e.parameters?e.parameters[l.output]:l.output;n.push(this.getDependency("node",c)),i.push(this.getDependency("accessor",u)),r.push(this.getDependency("accessor",d)),s.push(l),o.push(h)}return Promise.all([Promise.all(n),Promise.all(i),Promise.all(r),Promise.all(s),Promise.all(o)]).then(n=>{const i=n[0],r=n[1],s=n[2],o=n[3],l=n[4],h=[];for(let t=0,e=i.length;t<e;t++){const e=i[t],n=r[t],c=s[t],u=o[t],d=l[t];if(void 0===e)continue;let p;switch(e.updateMatrix(),e.matrixAutoUpdate=!0,Xe[d.path]){case Xe.weights:p=a.NumberKeyframeTrack;break;case Xe.rotation:p=a.QuaternionKeyframeTrack;break;case Xe.position:case Xe.scale:default:p=a.VectorKeyframeTrack}const f=e.name?e.name:e.uuid,m=void 0!==u.interpolation?Ye[u.interpolation]:a.InterpolateLinear,g=[];Xe[d.path]===Xe.weights?e.traverse(t=>{!0===t.isMesh&&t.morphTargetInfluences&&g.push(t.name?t.name:t.uuid)}):g.push(f);let v=c.array;if(c.normalized){let t;if(v.constructor===Int8Array)t=1/127;else if(v.constructor===Uint8Array)t=1/255;else if(v.constructor===Int16Array)t=1/32767;else{if(v.constructor!==Uint16Array)throw new Error("THREE.GLTFLoader: Unsupported output accessor component type.");t=1/65535}const e=new Float32Array(v.length);for(let n=0,i=v.length;n<i;n++)e[n]=v[n]*t;v=e}for(let t=0,e=g.length;t<e;t++){const e=new p(`${g[t]}.${Xe[d.path]}`,n.array,v,m);"CUBICSPLINE"===u.interpolation&&(e.createInterpolant=function(t){return new wn(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),h.push(e)}}const c=e.name?e.name:"animation_"+t;return new a.AnimationClip(c,void 0,h)})}loadNode(t){const e=this.json,n=this.extensions,i=this,r=e.nodes[t],s=r.name?i.createUniqueName(r.name):"",{THREE:o}=x.getInstance();return function(){const e=[];return void 0!==r.mesh&&e.push(i.getDependency("mesh",r.mesh).then(t=>{const e=i._getNodeRef(i.meshCache,r.mesh,t);return void 0!==r.weights&&e.traverse(t=>{if(t.isMesh)for(let e=0,n=r.weights.length;e<n;e++)t.morphTargetInfluences[e]=r.weights[e]}),e})),void 0!==r.camera&&e.push(i.getDependency("camera",r.camera).then(t=>i._getNodeRef(i.cameraCache,r.camera,t))),i._invokeAll(e=>e.createNodeAttachment&&e.createNodeAttachment(t)).forEach(t=>{e.push(t)}),Promise.all(e)}().then(e=>{let a;if(a=!0===r.isBone?new o.Bone:e.length>1?new o.Group:1===e.length?e[0]:new o.Object3D,a!==e[0])for(let t=0,n=e.length;t<n;t++)a.add(e[t]);if(r.name&&(a.userData.name=r.name,a.name=s),tn(a,r),r.extensions&&Ke(n,a,r),void 0!==r.matrix){const t=new o.Matrix4;t.fromArray(r.matrix),a.applyMatrix4(t)}else void 0!==r.translation&&a.position.fromArray(r.translation),void 0!==r.rotation&&a.quaternion.fromArray(r.rotation),void 0!==r.scale&&a.scale.fromArray(r.scale);return i.associations.set(a,{type:"nodes",index:t}),a})}}class Sn extends e.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(t=>new ln(t)),this.register(t=>new cn(t)),this.register(t=>new un(t)),this.register(t=>new hn(t)),this.register(t=>new on(t)),this.register(t=>new dn(t))}load(t,e,n,i){const r=this;let s;const{THREE:o}=x.getInstance();s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:o.LoaderUtils.extractUrlBase(t),this.manager.itemStart(t);const a=function(e){i?i(e):console.error(e),r.manager.itemError(t),r.manager.itemEnd(t)},l=new o.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(t,n=>{try{r.parse(n,s,n=>{e(n),r.manager.itemEnd(t)},a)}catch(t){a(t)}},n,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,n,i){let r;const s={},o={},{THREE:a}=x.getInstance();if("string"==typeof t)r=t;else{if("glTF"===a.LoaderUtils.decodeText(new Uint8Array(t,0,4))){try{s[Me]=new mn(t)}catch(t){return void(i&&i(t))}r=s[Me].content}else r=a.LoaderUtils.decodeText(new Uint8Array(t))}const l=JSON.parse(r);if(void 0===l.asset||l.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const h=new En(l,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){const e=this.pluginCallbacks[t](h);o[e.name]=e,s[e.name]=!0}if(l.extensionsUsed)for(let t=0;t<l.extensionsUsed.length;++t){const e=l.extensionsUsed[t],n=l.extensionsRequired||[];switch(e){case Pe:s[e]=new an;break;case Te:s[e]=new xn;break;case _e:s[e]=new gn(l,this.dracoLoader);break;case Re:s[e]=new vn;break;case Ce:s[e]=new bn;break;default:n.indexOf(e)>=0&&void 0===o[e]&&console.warn(`THREE.GLTFLoader: Unknown extension "${e}".`)}}h.setExtensions(s),h.setPlugins(o),h.parse(n,i)}}class Tn{constructor(t,e,n,i,r){this.extentsMin=t,this.extentsMax=e,this.startIndex=n,this.endIndex=i,this.level=r,this.node0=null,this.node1=null}elementCount(){return this.endIndex-this.startIndex}centerX(){return.5*(this.extentsMin.x+this.extentsMax.x)}centerY(){return.5*(this.extentsMin.y+this.extentsMax.y)}centerZ(){return.5*(this.extentsMin.z+this.extentsMax.z)}clearShapes(){this.startIndex=-1,this.endIndex=-1}calcBoundingSphereRadius(t,e){const n=.5*(t.x+e.x),i=.5*(t.y+e.y),r=.5*(t.z+e.z),s=(n-t.x)*(n-t.x)+(i-t.y)*(i-t.y)+(r-t.z)*(r-t.z),o=(n-e.x)*(n-e.x)+(i-e.y)*(i-e.y)+(r-e.z)*(r-e.z);return Math.sqrt(Math.max(s,o))}}class An{constructor(t,e){const n=[];n.length=9*t.length;for(let e=0;e<t.length;e+=1){const i=t[e][0],r=t[e][1],s=t[e][2];n[9*e]=i.x,n[9*e+1]=i.y,n[9*e+2]=i.z,n[9*e+3]=r.x,n[9*e+4]=r.y,n[9*e+5]=r.z,n[9*e+6]=s.x,n[9*e+7]=s.y,n[9*e+8]=s.z}this.trianglesArray=n,this.maxTrianglesPerNode=e||10,this.bboxArray=this.calcBoundingBoxes(n),this.bboxHelper=new Float32Array(this.bboxArray.length),this.bboxHelper.set(this.bboxArray);const i=n.length/9,r=this.calcExtents(0,i,An.EPSILON);for(this.rootNode=new Tn(r[0],r[1],0,i,0),this.nodesToSplit=[this.rootNode];this.nodesToSplit.length>0;){const t=this.nodesToSplit.pop();t&&this.splitNode(t)}}vector3SetFromArray(t,e,n){t.set(e[n],e[n+1],e[n+2])}intersectRay(t,e,n){const i=[this.rootNode],r=[],s=[];let o;const{THREE:a}=x.getInstance(),l=new a.Vector3(1/e.x,1/e.y,1/e.z);for(;i.length>0;){const e=i.pop();if(e&&this.intersectNodeBox(t,l,e))for(e.node0&&i.push(e.node0),e.node1&&i.push(e.node1),o=e.startIndex;o<e.endIndex;o+=1)r.push(this.bboxArray[7*o])}const h=new a.Vector3,c=new a.Vector3,u=new a.Vector3,d=new a.Vector3(t.x,t.y,t.z),p=new a.Vector3(e.x,e.y,e.z);for(o=0;o<r.length;o+=1){const t=r[o];this.vector3SetFromArray(h,this.trianglesArray,9*t),this.vector3SetFromArray(c,this.trianglesArray,9*t+3),this.vector3SetFromArray(u,this.trianglesArray,9*t+6);const e=this.intersectRayTriangle(h,c,u,d,p,n||!1);e&&s.push({triangle:[h.clone(),c.clone(),u.clone()],triangleIndex:t,intersectionPoint:e})}return s}nearestIntersection(t,e,n){const i=e.clone().normalize(),r=this.intersectRay(t,i,n);if(0===r.length)return null;let s=null,o=Number.MAX_VALUE;for(let e=0;e<r.length;e+=1){const n=r[e],a=n.intersectionPoint.clone().sub(t).dot(i);a>=0&&a<o&&(s=n,o=a)}return s}calcBoundingBoxes(t){let e,n,i,r,s,o,a,l,h,c,u,d,p,f,m;const g=t.length/9,v=new Float32Array(7*g);for(let y=0;y<g;y+=1)e=t[9*y],n=t[9*y+1],i=t[9*y+2],r=t[9*y+3],s=t[9*y+4],o=t[9*y+5],a=t[9*y+6],l=t[9*y+7],h=t[9*y+8],c=Math.min(Math.min(e,r),a),u=Math.min(Math.min(n,s),l),d=Math.min(Math.min(i,o),h),p=Math.max(Math.max(e,r),a),f=Math.max(Math.max(n,s),l),m=Math.max(Math.max(i,o),h),this.setBox(v,y,y,c,u,d,p,f,m);return v}setBox(t,e,n,i,r,s,o,a,l){t[7*e]=n,t[7*e+1]=i,t[7*e+2]=r,t[7*e+3]=s,t[7*e+4]=o,t[7*e+5]=a,t[7*e+6]=l}copyBox(t,e,n,i){n[7*i]=t[7*e],n[7*i+1]=t[7*e+1],n[7*i+2]=t[7*e+2],n[7*i+3]=t[7*e+3],n[7*i+4]=t[7*e+4],n[7*i+5]=t[7*e+5],n[7*i+6]=t[7*e+6]}calcExtents(t,e,n){const i=n||0,{THREE:r}=x.getInstance();if(t>=e)return[new r.Vector3(0,0,0),new r.Vector3(0,0,0)];let s=Number.MAX_VALUE,o=Number.MAX_VALUE,a=Number.MAX_VALUE,l=-Number.MAX_VALUE,h=-Number.MAX_VALUE,c=-Number.MAX_VALUE;for(let n=t;n<e;n+=1)s=Math.min(this.bboxArray[7*n+1],s),o=Math.min(this.bboxArray[7*n+2],o),a=Math.min(this.bboxArray[7*n+3],a),l=Math.max(this.bboxArray[7*n+4],l),h=Math.max(this.bboxArray[7*n+5],h),c=Math.max(this.bboxArray[7*n+6],c);return[new r.Vector3(s-i,o-i,a-i),new r.Vector3(l+i,h+i,c+i)]}splitNode(t){if(t.elementCount()<=this.maxTrianglesPerNode||0===t.elementCount())return;const{startIndex:e,endIndex:n}=t,i=[new Array,new Array,new Array],r=[new Array,new Array,new Array],s=[t.centerX(),t.centerY(),t.centerZ()],o=[t.extentsMax.x-t.extentsMin.x,t.extentsMax.y-t.extentsMin.y,t.extentsMax.z-t.extentsMin.z],a=[];a.length=3;for(let t=e;t<n;t+=1){a[0]=.5*(this.bboxArray[7*t+1]+this.bboxArray[7*t+4]),a[1]=.5*(this.bboxArray[7*t+2]+this.bboxArray[7*t+5]),a[2]=.5*(this.bboxArray[7*t+3]+this.bboxArray[7*t+6]);for(let e=0;e<3;e+=1)a[e]<s[e]?i[e].push(t):r[e].push(t)}const l=[];if(l.length=3,l[0]=0===i[0].length||0===r[0].length,l[1]=0===i[1].length||0===r[1].length,l[2]=0===i[2].length||0===r[2].length,l[0]&&l[1]&&l[2])return;const h=[0,1,2];let c,u;h.sort((t,e)=>o[e]-o[t]);for(let t=0;t<3;t+=1){const e=h[t];if(!l[e]){c=i[e],u=r[e];break}}const d=e,p=d+(void 0!==c?c.length:0),f=p,m=n;let g,v=t.startIndex,y=[];c&&(y=c),u&&(y=y.concat(u));for(let t=0;t<y.length;t+=1)g=y[t],this.copyBox(this.bboxArray,g,this.bboxHelper,v),v+=1;const x=this.bboxHelper.subarray(7*t.startIndex,7*t.endIndex);this.bboxArray.set(x,7*t.startIndex);const b=this.calcExtents(d,p,An.EPSILON),w=this.calcExtents(f,m,An.EPSILON),M=new Tn(b[0],b[1],d,p,t.level+1),_=new Tn(w[0],w[1],f,m,t.level+1);t.node0=M,t.node1=_,t.clearShapes(),this.nodesToSplit.push(M),this.nodesToSplit.push(_)}calcTValues(t,e,n,i){const r={min:0,max:0};return i>=0?(r.min=(t-n)*i,r.max=(e-n)*i):(r.min=(e-n)*i,r.max=(t-n)*i),r}intersectNodeBox(t,e,n){const i=this.calcTValues(n.extentsMin.x,n.extentsMax.x,t.x,e.x),r=this.calcTValues(n.extentsMin.y,n.extentsMax.y,t.y,e.y);if(i.min>r.max||r.min>i.max)return!1;(r.min>i.min||Number.isNaN(i.min))&&(i.min=r.min),(r.max<i.max||Number.isNaN(i.max))&&(i.max=r.max);const s=this.calcTValues(n.extentsMin.z,n.extentsMax.z,t.z,e.z);return!(i.min>s.max||s.min>i.max)&&((s.min>i.min||Number.isNaN(i.min))&&(i.min=s.min),(s.max<i.max||Number.isNaN(i.max))&&(i.max=s.max),!(i.max<0))}intersectRayTriangle(t,e,n,i,r,s){const{THREE:o}=x.getInstance(),a=new o.Vector3,l=new o.Vector3,h=new o.Vector3,c=new o.Vector3;l.subVectors(e,t),h.subVectors(n,t),c.crossVectors(l,h);let u,d=r.dot(c);if(d>0){if(s)return null;u=1}else{if(!(d<0))return null;u=-1,d=-d}a.subVectors(i,t);const p=u*r.dot(h.crossVectors(a,h));if(p<0)return null;const f=u*r.dot(l.cross(a));if(f<0)return null;if(p+f>d)return null;const m=-u*a.dot(c);if(m<0)return null;const g=m/d;return(new o.Vector3).copy(r).multiplyScalar(g).add(i)}static addTriangles(t,e){const{THREE:n}=x.getInstance();if(!(e instanceof n.Mesh))return;const i=e.geometry,r=i.attributes.position.array,s=i.index?i.index.array:null;let o=0;if(s){o=s.length/3;for(let e=0;e<o;e+=1)t.push([new n.Vector3(r[3*s[3*e]],r[3*s[3*e]+1],r[3*s[3*e]+2]),new n.Vector3(r[3*s[3*e+1]],r[3*s[3*e+1]+1],r[3*s[3*e+1]+2]),new n.Vector3(r[3*s[3*e+2]],r[3*s[3*e+2]+1],r[3*s[3*e+2]+2])])}else{o=r.length/9;for(let e=0;e<o;e+=1)t.push([new n.Vector3(r[9*e],r[9*e+1],r[9*e+2]),new n.Vector3(r[9*e+3],r[9*e+4],r[9*e+5]),new n.Vector3(r[9*e+6],r[9*e+7],r[9*e+8])])}}static createBVHTree(t){const e=[];t.traverse(t=>{this.addTriangles(e,t)});return new An(e,7)}}An.EPSILON=1e-6;class Pn extends ye{constructor(t,e=!0,n=1){super(),this.reloadTimes=3;const{THREE:i}=x.getInstance();this.modelInitialized=!1,this.modelLoaded=!1,this.globalScale=n,this.setGroundParameters({downDirection:new i.Vector3(0,0,-1)}),this.viewConfigurations=new Map,this.boundingBoxMesh=new i.Mesh,this.boundingBoxMesh.visible=!1,this.add(this.boundingBoxMesh),t&&this.load(t,e)}setGroundParameters(t){this.groundParams=t}load(t,e=!0,n=0){this.modelInitialized=!1,this.modelLoaded=!1;const{THREE:i}=x.getInstance();(new Sn).load(t,t=>{this.add(t.scene),this.modelLoaded=!0,t.scene.traverse(t=>{t instanceof i.Mesh&&(this.mesh=t,this.meshMaterial=t.material,t.geometry.scale(this.globalScale,this.globalScale,this.globalScale))}),e?this.bvh=An.createBVHTree(t.scene):this.raycaster=new i.Raycaster;const n=(new i.Box3).setFromObject(t.scene),{max:r,min:s}=n;this.boundingBoxMesh.geometry=new i.BoxBufferGeometry(r.x-s.x,r.y-s.y,r.z-s.z),this.boundingBoxMesh.position.copy(r.clone().add(s.clone()).multiplyScalar(.5)),this.emit(M.ELEMENT_LOADED,this)},void 0,i=>{const r=n+1;r>this.reloadTimes?this.emit(M.ELEMENT_LOADED_ERROR,this,i):this.load(t,e,r)})}isModelLoaded(){return this.modelLoaded}update(){const t=new ve(this);return!this.modelInitialized&&this.modelLoaded&&(this.modelInitialized=!0,t.needUpdate=!0),this.modelInitialized&&!this.parent&&(t.shouldPlaceElement=!0),t}render(){if(this.mesh&&this.meshMaterial!==this.mesh.material){const t=this.mesh.material;this.mesh.material=this.meshMaterial,t instanceof Array?t.forEach(t=>{t.dispose()}):t.dispose()}}addViewConfiguration(t){const e=this.viewConfigurations.get(t.targetView);!t.meshMaterial&&e&&(t.meshMaterial=e.meshMaterial),this.viewConfigurations.set(t.targetView,t)}addMeshMaterial(t){this.meshMaterial=t}dispose(){super.dispose(),xe.dispose(this,!0)}getBVHTree(){return this.bvh}intersectRay(t,e,n){if(!this.bvh)return null;return this.bvh.intersectRay(t,e,n)}static intersectWithGroundPlane(t,e){const n=e.downDirection,{THREE:i}=x.getInstance();if(e.groundPlane){const{a:r,b:s,c:o,d:a}=e.groundPlane,l=r*n.x+s*n.y+o*n.z,h=(-r*t.x-s*t.y-o*t.z-a)/l;if(!Number.isNaN(h)&&Number.isFinite(h)){const e=new i.Vector3(t.x+h*n.x,t.y+h*n.y,t.z+h*n.z);if(e.clone().sub(t).dot(n)>=0)return e}}return null}nearestIntersectionWithRaycaster(t,e){this.raycaster.set(t,e);const n=this.raycaster.intersectObject(this.children[0],!0);if(0===n.length)return null;let i=null,r=Number.MAX_VALUE;for(let t=0;t<n.length;t+=1){const e=n[t],s=e.distance;s>=0&&s<r&&(i=e.point.clone(),r=s)}return i}intersectGround(t){let e=Pn.intersectWithGroundPlane(t,this.groundParams);if(e)return e;if(this.bvh){const n=this.bvh.nearestIntersection(t,this.groundParams.downDirection);n&&(e=n.intersectionPoint)}else this.raycaster&&(e=this.nearestIntersectionWithRaycaster(t,this.groundParams.downDirection));return e}getMeshMaterial(){return this.mesh.material}}class Ln{static mergeRange(t,e=1e-4){const n=[],i=Array.from(t);i.sort((t,e)=>e[0]-t[0]);let r=i.pop();for(;r;){const t=i.pop();t&&(t[0]>=r[0]&&t[0]<=r[1]||Ln.nearlyEquals(t[0],r[0],e)||Ln.nearlyEquals(t[0],r[1],e))?r[1]=Math.max(r[1],t[1]):(n.push(r),r=t)}return n}static rangeSub(t,e,n=1e-4){const[i,r]=t,s=[];let o=[];s.push(o),o.push(i),e=Ln.mergeRange(e,n);for(let t=0;t<e.length;t++){const n=e[t],[i,a]=n;if(!(i<=r))break;if(o.push(i),o=[],s.push(o),!(a<=r))break;o.push(a)}1===o.length&&o[0]<r&&o.push(r);return s.filter(([t,e])=>void 0!==e&&!Ln.nearlyEquals(t,e))}static nearlyEquals(t,e,n=1e-4){return Math.abs(t-e)<n}static nearlyLess(t,e,n,i=1e-4){const r=Ln.nearlyEquals(t,e,i);return!!n&&r||t<e}static nearlyThan(t,e,n,i=1e-4){const r=Ln.nearlyEquals(t,e,i);return!!n&&r||t>e}}class Rn{static getAngle(t,e){const n=t.clone().normalize(),i=e.clone().normalize();return Math.acos(n.dot(i))}static simplify(t,e=!1,n=!0,i=5,r=150,s=3){const{THREE:o}=x.getInstance(),a=[];let l=!e;if(a.push(t[0]),t.length<2)return a;for(let e=0;e<t.length-2;e+=1){const n=t[e],s=t[e+1],h=t[e+2],c=new o.Vector2(n.x-s.x,n.y-s.y),u=new o.Vector2(h.x-s.x,h.y-s.y),d=Rn.getAngle(c,u)/Math.PI*180,p=c.length()+u.length();(!l||d<r&&p>.01||p>i)&&(a.push(t[e+1]),l=!0)}if(a.push(t[t.length-1]),!n)return a;const h=[];h.push(a[0]);for(let t=0;t<a.length-2;t+=1){const e=new o.Vector2(a[t].x,a[t].y),n=new o.Vector2(a[t+1].x,a[t+1].y),i=new o.Vector2(a[t+2].x,a[t+2].y),r=e.distanceTo(n)/2,l=i.distanceTo(n)/2,c=n.clone(),u=n.clone();c.add(e.clone().sub(n).normalize().multiplyScalar(r>s?s/2:r)),u.add(i.clone().sub(n).normalize().multiplyScalar(l>s?s/2:l));const d=[[c.x,c.y],[n.x,n.y],[u.x,u.y]];h.push(...Rn.smoothPath(d,s/25).map(t=>({x:t[0],y:t[1]})))}h.push(a[a.length-1]);const c=[];let u;return h.forEach(({x:t,y:e})=>{u&&t===u.x&&e===u.y||(u={x:t,y:e},c.push({x:t,y:e}))}),c}static averageStepLength(t){let e=0;return t.reduce(([t,n],[i,r])=>(e+=Math.sqrt((i-t)**2+(r-n)**2),[i,r])),e/t.length}static smoothPath(t,e=.25){if(Rn.averageStepLength(t)<e)return t;const n=function(t,e){Array.isArray(e)||(e=[]),t.length>0&&e.push(we([0,0],t[0]));for(var n=0;n<t.length-1;n++){var i=t[n],r=t[n+1],s=i[0],o=i[1],a=r[0],l=r[1],h=[.75*s+.25*a,.75*o+.25*l],c=[.25*s+.75*a,.25*o+.75*l];e.push(h),e.push(c)}return t.length>1&&e.push(we([0,0],t[t.length-1])),e}(t);return Rn.smoothPath(n,e)}static smoothPathBezier(t,e,n=10){const{THREE:i}=x.getInstance(),r=t.map(([t,e])=>new i.Vector2(t,e));Rn.mergeSamePoint2(r),Rn.mergePathSameVectorPoint2(r);const s=[];let o=[];s.push(o);const a=r.length;for(let t=1;t<a;t++){const n=r[t-t],i=r[t],l=i.clone().sub(n).normalize().multiplyScalar(e);n.distanceTo(i)>e?(o.push(n),1!==t&&o.push(n.clone().add(l)),o=[],s.push(o),t!==a-1&&o.push(i.clone().add(l.multiplyScalar(-1))),o.push(i)):o.push(n)}let l=[];return s.map(t=>{const e=t.map(t=>[t.x,t.y]);if(e.length<3)return e;const i=[];e.forEach(t=>{i.push(...t)});return new G(i).getLUT(n).map(t=>[t.x,t.y])}).forEach(t=>{l=l.concat(t)}),l}static getRenderHeight(t,e,n){const[i,r,s,o]=t;return-(i*e+r*n+o)/s+.2}static getPointHash(t,e,n,i,r=1){const s=t-n,o=e-i;return[(s-s%r)/r,(o-o%r)/r]}static generatePathMesh(t,n){const{THREE:i}=x.getInstance(),{viewDistance:r=10,gradientDistance:s=2,arrowImageRatio:o=1,arrowImageURL:a,floorModel:l,groundParams:h,color:c,dynamicPathEnabled:u,width:d=.3}=n||{},p=Rn.simplify(t,!0).map(t=>[t.x,t.y]),f=[],m=[0],g=[0];p.reduce(([t,e],[n,r],s)=>{f.push(new i.Vector2(e-r,n-t).normalize());const o=Math.sqrt((t-n)**2+(e-r)**2);return m.push(m[s-1]+o),[n,r]});for(let t=0,e=m.length;t<e;t+=1)g[t]=m[t]/m[e-1];const v=[],y=[],w=d;f.forEach((t,e)=>{if(0===e){const[e,n]=p[0];v.push([e+t.x*w,n+t.y*w]),y.push([e-t.x*w,n-t.y*w])}const[n,i]=p[e+1];v.push([n+t.x*w,i+t.y*w]),y.push([n-t.x*w,i-t.y*w])}),y.reverse();const M=new i.Shape;M.moveTo(...v[0]),v.forEach((t,e)=>{0!==e&&M.lineTo(...t)}),y.forEach(t=>{M.lineTo(...t)}),M.lineTo(...v[0]);const E=new i.ShapeBufferGeometry(M);let S=!1;u&&(S=!0);const T={arrowTexcoordScaleT:{value:o/w*.5},current:{value:0},dynamic:{value:S},full_length:{value:m[m.length-1]},view_distance:{value:r},gradient_distance:{value:s}};a&&(new i.TextureLoader).load(a,t=>{t.wrapS=i.RepeatWrapping,t.wrapT=i.RepeatWrapping,t.generateMipmaps=!0,t.minFilter=i.LinearMipMapLinearFilter,t.magFilter=i.LinearMipMapLinearFilter,t.image&&t.image.width&&t.image.height&&(T.arrowTexcoordScaleT.value=t.image.width/t.image.height/w*.5)});const A=new i.ShaderMaterial({vertexShader:"\n attribute vec3 a_color;\n attribute vec2 a_texcoord;\n attribute float progress;\n varying float vProgress;\n varying vec3 vColor;\n varying vec2 vTexcoord;\n void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n vProgress = progress;\n vColor = a_color;\n vTexcoord = a_texcoord;\n }\n ",fragmentShader:"\n precision mediump float;\n varying float vProgress;\n varying vec3 vColor;\n varying vec2 vTexcoord;\n uniform float current;\n uniform bool dynamic;\n uniform float full_length;\n uniform float view_distance;\n uniform float gradient_distance;\n // uniform sampler2D arrowTexture;\n uniform float arrowTexcoordScaleT;\n float alpha;\n float cur;\n bool dy;\n void main() {\n alpha = 0.8;\n cur = current;\n dy = dynamic;\n if (vProgress < cur) {\n alpha = 0.0;\n } else {\n if (vProgress > cur + view_distance) {\n alpha = 0.0;\n } else {\n if (vProgress > cur + gradient_distance) {\n alpha = 0.8;\n if (cur > full_length - view_distance) {\n cur = full_length - view_distance;\n }\n if (vProgress > cur + view_distance - gradient_distance) {\n alpha = abs(cur + view_distance - vProgress) / gradient_distance * 0.8;\n }\n } else {\n alpha = abs(vProgress - cur) / gradient_distance * 0.8;\n }\n }\n }\n\n // vec4 textureColor = texture2D(arrowTexture, vec2(vTexcoord.s, vTexcoord.t * arrowTexcoordScaleT));\n // gl_FragColor = vec4((1.0 - textureColor.a) * vColor + textureColor.a * textureColor.rgb, 0.8);\n if(dy) {\n gl_FragColor = vec4(vColor,alpha);\n } else {\n gl_FragColor = vec4(vColor,0.8);\n }\n\n }\n ",uniforms:T,side:i.DoubleSide,depthTest:!S});let P=Number.MAX_SAFE_INTEGER,L=Number.MAX_SAFE_INTEGER;const{array:R,count:C}=E.attributes.position;for(let t=0,e=0;t<C;t+=1,e+=3){const t=R[e],n=R[e+1];R[e]<P&&(P=t),R[e+1]<L&&(L=n)}if(h&&h.groundPlane)for(let t=0,e=0;t<C;t+=1,e+=3){const t=R[e],n=R[e+1];let r=.5;const s=Pn.intersectWithGroundPlane(new i.Vector3(t,n,r),h);s&&(r=s.z+Rn.PathMeshOffsetZ),R[e+2]=r}else{const t=()=>{if(l&&l.isModelLoaded()){for(let t=0,e=0;t<C;t+=1,e+=3){const t=R[e],n=R[e+1];let r=.5;const s=l.intersectGround(new i.Vector3(t,n,r));s&&(r=s.z+Rn.PathMeshOffsetZ),R[e+2]=r}E.attributes.position.needsUpdate=!0}};l&&l.isModelLoaded()&&t(),b.on(_.ELEMENT_LOADED,e=>{e instanceof Pn&&e===l&&t()})}E.attributes.position.needsUpdate=!0;const I=[];if(a){const t=new i.PlaneBufferGeometry(.5*w/.3,.5*w/.3),n=new i.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.8,blending:e.NormalBlending,side:e.DoubleSide,depthTest:!S}),r=(new i.TextureLoader).load(a);r.needsUpdate=!0,n.needsUpdate=!0,n.map=r;const s=new i.Mesh(t,n);for(let t=0,e=.8,r=p.length;t<r;t+=1)if(m[t]>e){e+=.8;const[o,a]=p[t],{x:c,y:u}=f[t===r-1?t-1:t],d=s.clone();if(d.position.set(o,a,-.5),h){const t=Pn.intersectWithGroundPlane(new i.Vector3(o,a,2),h);t&&(t.z+=Rn.ArrowMeshOffsetZ,d.position.copy(t))}else if(l){const t=l.intersectGround(new i.Vector3(o,a,2));t&&(t.z+=Rn.ArrowMeshOffsetZ,d.position.copy(t))}d.material=n.clone(),d.rotateZ(new i.Vector2(u,-c).angle()-.5*Math.PI),I.push({arrowMesh:d,index:t})}}const O=Math.floor(P),D=Math.floor(L),z=new Map;p.forEach(([t,e],n)=>{const[i,r]=Rn.getPointHash(t,e,O,D,25);z.has(""+i)||z.set(""+i,new Map);const s=z.get(""+i);s.has(""+r)||s.set(""+r,[]),s.get(""+r).push([n,t,e])});const N=new Float32Array(C),U=new Float32Array(3*C);let B=1,F=140/255,V=0,k=240/255,H=68/255,G=55/255;if(c){const t=[];for(let e=2;e<8;e+=2)t.push(parseInt("0x"+c.slice(e,e+2)));B=t[0]/255,F=t[1]/255,V=t[2]/255,k=t[0]/255,H=t[1]/255,G=t[2]/255}const W=k-B,j=H-F,X=G-V;for(let t=0,e=0;t<C;t+=1,e+=3){const n=R[e],i=R[e+1],[r,s]=Rn.getPointHash(n,i,O,D,25);let o=Number.MAX_SAFE_INTEGER;z.has(""+r)&&z.get(""+r).has(""+s)&&z.get(""+r).get(""+s).forEach(([e,r,s])=>{const a=(n-r)**2+(i-s)**2;if(a>o)return;o=a;const l=m[e],h=g[e];N[t]=l,U[3*t]=B+h*W,U[3*t+1]=F+h*j,U[3*t+2]=V+h*X})}E.addAttribute("progress",new i.BufferAttribute(N,1)),E.addAttribute("a_color",new i.BufferAttribute(U,3)),A.transparent=!0;return{mesh:new i.Mesh(E,A),arrowMeshes:I,newPath:p,pointMap:z,pathMinX:O,pathMinY:D,progressBuffer:N,pathDistance:m}}static nearlyEqualsV2(t,e,n=1e-4){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}static nearlyEqualsV3(t,e,n=1e-4){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n&&Math.abs(t.z-e.z)<n}static mergePathSameVectorPoint3(t,e=1e-4){for(let n=1;n<t.length-1;n++){const i=t[n].clone().sub(t[n-1]).normalize(),r=t[n+1].clone().sub(t[n]).normalize();Rn.nearlyEqualsV3(i,r,e)&&(t.splice(n,1),n--)}}static mergePathSameVectorPoint2(t,e=1e-4){for(let n=1;n<t.length-1;n++){const i=t[n].clone().sub(t[n-1]).normalize(),r=t[n+1].clone().sub(t[n]).normalize();Rn.nearlyEqualsV2(i,r,e)&&(t.splice(n,1),n--)}}static mergeSamePoint3(t,e=1e-4){for(let n=1;n<t.length;n++)Rn.nearlyEqualsV3(t[n-1],t[n],e)&&(t.splice(n,1),n--)}static mergeSamePoint2(t,e=1e-4){for(let n=1;n<t.length;n++)Rn.nearlyEqualsV2(t[n-1],t[n],e)&&(t.splice(n,1),n--)}static splitPathByPoints(t,e,n,i,r=1e-4){const s=[];let o=[];Array.isArray(i)?o=i:n.forEach(()=>{o.push(i)}),e&&(Rn.nearlyEqualsV3(t[0],t[t.length-1],r)||(t=Array.from(t)).push(t[0]));let a=!1;const l=Rn.getDistances(t),h=[],c=l[l.length-1];for(let i=0;i<n.length;i++){const s=n[i],a=o[i],u=Rn.findPointIndexByPath(t,s,r);if(u.length){const n=u[0];let i=l[n];const r=a/2;2===u.length&&(i+=s.distanceTo(t[n]));let o=i-r,d=i+r;e&&(o<0&&(h.push([c+o,c]),o=0),d>c&&(h.push([0,d-c]),d=c)),h.push([o,d])}}const u=Ln.rangeSub([l[0],l[l.length-1]],h,r);if(u.length){a=!0;let n=[];s.push(n);let i=0,o=!1,h=u[i++];const c=t.length;for(let e=0;e<c;e++){const a=t[e],d=l[e],p=t[(e+c-1)%c],f=a.clone().sub(p).normalize();if(h){const[t,l]=h;Ln.nearlyThan(d,t,!0,r)&&(o||(n.push(f.clone().multiplyScalar(t-d).add(a)),o=!0),Ln.nearlyLess(d,l,!1,r)&&n.push(a),Ln.nearlyThan(d,l,!0,r)&&(n.push(f.clone().multiplyScalar(l-d).add(a)),Rn.invalidPath(n)&&s.pop(),n=[],s.push(n),h=u[i++],e--,o=!1))}}if(Rn.invalidPath(n)&&s.pop(),e){const t=s[0],e=s[s.length-1];Rn.nearlyEqualsV3(t[0],e[e.length-1],r)&&(s.pop(),e.pop(),s[0]=e.concat(t))}}else s.push(t);return{paths:s,split:a}}static invalidPath(t){const e=Rn.getDistances(t);return!t.length||Ln.nearlyEquals(0,e[e.length-1])}static getDistances(t){const e=[];if(!t||!t.length)return e;let n=0;e.push(n);for(let i=1;i<t.length;i++)n+=t[i].distanceTo(t[i-1]),e.push(n);return e}static findPointIndexByPath(t,e,n=1e-4){for(let i=0;i<t.length;i++){const r=t[i];if(Rn.nearlyEqualsV3(r,e,n))return[i];const s=t[i-1];if(s&&Rn.pointInLine(e,s,r,n))return[i-1,i]}return[]}static pointInLine(t,e,n,i=1e-4){return Math.abs(t.distanceTo(e)+t.distanceTo(n)-e.distanceTo(n))<i}}Rn.PathMeshOffsetZ=.1,Rn.ArrowMeshOffsetZ=.2;class Cn extends e.BufferGeometry{constructor(t,n){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:n};const{THREE:i}=x.getInstance();t=Array.isArray(t)?t:[t];const r=[],s=[],o=[],a=new e.Matrix4,l=new e.Matrix4,h=Array.from(n.extrudePath);Rn.mergeSamePoint3(h),Rn.mergePathSameVectorPoint3(h);let c=n.closed;Rn.nearlyEqualsV3(h[0],h[h.length-1])&&(c=!0,h.splice(h.length-1,1));const u=h.length,d=[],p=[],f=[],m=new i.Vector3,g=new i.Vector3,v=new i.Quaternion;for(let t=0;t<u;t++){let n;if(0===t)if(c)n=h[t].clone().sub(h[u-1]).normalize(),g.copy(h[t+1]).sub(h[t]).normalize(),n.add(g).normalize(),m.copy(n).cross(g);else{n=h[t+1].clone().sub(h[t]).normalize();const i=new e.Vector3(1,0,0),r=i.clone().cross(n),s=i.angleTo(n);a.makeRotationFromQuaternion(v.setFromAxisAngle(r,s)),m.copy(new e.Vector3(0,0,-1).applyMatrix4(a))}else if(t===u-1)if(c)n=h[t].clone().sub(h[t-1]).normalize(),g.copy(h[0]).sub(h[t]).normalize(),n.add(g).normalize(),m.copy(n).cross(g);else{n=h[t].clone().sub(h[t-1]).normalize();const i=new e.Vector3(1,0,0),r=i.clone().cross(n),s=i.angleTo(n);a.makeRotationFromQuaternion(v.setFromAxisAngle(r,s)),m.copy(new e.Vector3(0,0,-1).applyMatrix4(a))}else n=h[t].clone().sub(h[t-1]).normalize(),g.copy(h[t+1]).sub(h[t]).normalize(),n.add(g).normalize(),m.copy(n).cross(g);m.normalize(),m.z>0&&m.multiplyScalar(-1),f[t]=n;const r=n.clone().cross(m).normalize();r.equals(new i.Vector3(0,0,0)),d[t]=r,p[t]=m.clone()}const y=(t,e,n)=>{const c=s.length/3,u=t.getPoints(),m=u.map(t=>new i.Vector3(t.x,t.y,0)),g=i.ShapeUtils.triangulateShape(u,[]),v=h[e],y=p[e],x=d[e],b=f[e];for(let t=0,e=u.length;t<e;t++){const e=u[t];a.makeBasis(y,x,b),a.premultiply(l.makeTranslation(v.x,v.y,v.z));const n=m[t];n.applyMatrix4(a),s.push(n.x,n.y,n.z),o.push(e.x,e.y)}for(let t=0,e=g.length;t<e;t++){const e=g[t],i=(n?e[2]:e[0])+c,s=e[1]+c,o=(n?e[0]:e[2])+c;r.push(i,s,o)}},b=t=>{const e=t.getPoints().map(t=>new i.Vector3(t.x,t.y,0)),n=e.length;for(let t=0;t<u;t++){const i=h[t],r=p[t],c=d[t],m=f[t];a.makeBasis(r,c,m),a.premultiply(l.makeTranslation(i.x,i.y,i.z));for(let i=0;i<n;i++){const r=e[i].clone().applyMatrix4(a);s.push(r.x,r.y,r.z),o.push(t/(u-1),i/(n-1))}}for(let t=0;t<u-1;t++)for(let e=0;e<n-1;e++){const i=e+t*n,s=i,o=i+n,a=i+n+1,l=i+1;r.push(s,o,l),r.push(o,a,l)}if(c){const t=u-1;for(let e=0;e<n-1;e++){const i=e+t*n,s=i,o=e,a=e+1,l=i+1;r.push(s,o,l),r.push(o,a,l)}}c||(y(t,0,!0),y(t,u-1,!1))};for(let e=0,n=t.length;e<n;e++){b(t[e])}this.setIndex(r),this.setAttribute("position",new i.Float32BufferAttribute(s,3)),this.setAttribute("uv",new i.Float32BufferAttribute(o,2)),this.computeVertexNormals()}toJSON(){const{THREE:t}=x.getInstance(),e=t.BufferGeometry.prototype.toJSON.call(this);return function(t,e,n){if(n.shapes=[],Array.isArray(t))for(let e=0,i=t.length;e<i;e++){const i=t[e];n.shapes.push(i.uuid)}else n.shapes.push(t.uuid);return void 0!==e.extrudePath&&(n.options.extrudePath=e.extrudePath),n}(this.parameters.shapes,this.parameters.options,e)}}var In,On;(In=t.StrokeType||(t.StrokeType={}))[In.all=0]="all",In[In.up=1]="up",In[In.down=2]="down";class Dn extends ye{constructor(t,e=!1,n="",i=!0,r){super(),this.needUpdate=!1,this.initialized=!1,this.loaded=!1,this.lowPerformance=e,this.tag=n,this.renderStroke=i,this.borderOptions=r,t&&this.load(t,this.lowPerformance,this.renderStroke,r)}load(e,n=!1,i=!0,r){this.initialized=!1,this.loaded=!1,this.shape=e,this.lowPerformance=n,this.renderStroke=i;const s=e.getData(),o=be.GenerateShapeFromSteps(e.getSteps()),{THREE:a}=x.getInstance(),l=`${this.tag}-${s.fill}-${s.fillOpacity}`;if(Dn.SharedResourceMap||(Dn.SharedResourceMap=new Map),this.lowPerformance&&!Dn.SharedResourceMap.has(l)){const t=new a.MeshStandardMaterial({color:s.fill,transparent:!0,opacity:s.fillOpacity,depthWrite:!1});Dn.SharedResourceMap.set(l,{count:0,material:t})}let h;if(this.lowPerformance){h=new a.ExtrudeBufferGeometry(o,{steps:1,bevelEnabled:!1,depth:s.height,curveSegments:4});const t=Dn.SharedResourceMap.get(l),e=t.count+1,n=t.material;let i;if(t.mesh){i=t.mesh;const e=class{static computeTangents(t){t.computeTangents(),console.warn("THREE.BufferGeometryUtils: .computeTangents() has been removed. Use BufferGeometry.computeTangents() instead.")}static mergeBufferGeometries(t,e){const n=null!==t[0].index,i=new Set(Object.keys(t[0].attributes)),r=new Set(Object.keys(t[0].morphAttributes)),s={},o={},{morphTargetsRelative:a}=t[0],{THREE:l}=x.getInstance(),h=new l.BufferGeometry;let c=0;for(let l=0;l<t.length;l++){const u=t[l];let d=0;if(n!==(null!==u.index))return console.error(`THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ${l}. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`),null;for(const t in u.attributes){if(!i.has(t))return console.error(`THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ${l}. All geometries must have compatible attributes; make sure "${t}" attribute exists among all geometries, or in none of them.`),null;void 0===s[t]&&(s[t]=[]),s[t].push(u.attributes[t]),d++}if(d!==i.size)return console.error(`THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ${l}. Make sure all geometries have the same number of attributes.`),null;if(a!==u.morphTargetsRelative)return console.error(`THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ${l}. .morphTargetsRelative must be consistent throughout all geometries.`),null;for(const t in u.morphAttributes){if(!r.has(t))return console.error(`THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ${l}. .morphAttributes must be consistent throughout all geometries.`),null;void 0===o[t]&&(o[t]=[]),o[t].push(u.morphAttributes[t])}if(h.userData.mergedUserData=h.userData.mergedUserData||[],h.userData.mergedUserData.push(u.userData),e){let t;if(n)t=u.index.count;else{if(void 0===u.attributes.position)return console.error(`THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ${l}. The geometry must have either an index or a position attribute`),null;t=u.attributes.position.count}h.addGroup(c,t,l),c+=t}}if(n){let e=0;const n=[];for(let i=0;i<t.length;++i){const{index:r}=t[i];for(let t=0;t<r.count;++t)n.push(r.getX(t)+e);e+=t[i].attributes.position.count}h.setIndex(n)}for(const t in s){const e=this.mergeBufferAttributes(s[t]);if(!e)return console.error(`THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ${t} attribute.`),null;h.setAttribute(t,e)}for(const t in o){const e=o[t][0].length;if(0===e)break;h.morphAttributes=h.morphAttributes||{},h.morphAttributes[t]=[];for(let n=0;n<e;++n){const e=[];for(let i=0;i<o[t].length;++i)e.push(o[t][i][n]);const i=this.mergeBufferAttributes(e);if(!i)return console.error(`THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ${t} morphAttribute.`),null;h.morphAttributes[t].push(i)}}return h}static mergeBufferAttributes(t){let e,n,i,r=0;for(let s=0;s<t.length;++s){const o=t[s];if(o.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(void 0===e&&(e=o.array.constructor),e!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===n&&(n=o.itemSize),n!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===i&&(i=o.normalized),i!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;r+=o.array.length}const s=new e(r);let o=0;for(let e=0;e<t.length;++e)s.set(t[e].array,o),o+=t[e].array.length;const{THREE:a}=x.getInstance();return new a.BufferAttribute(s,n,i)}static interleaveAttributes(t){let e,n=0,i=0;for(let r=0,s=t.length;r<s;++r){const s=t[r];if(void 0===e&&(e=s.array.constructor),e!==s.array.constructor)return console.error("AttributeBuffers of different types cannot be interleaved"),null;n+=s.array.length,i+=s.itemSize}const{THREE:r}=x.getInstance(),s=new r.InterleavedBuffer(new e(n),i);let o=0;const a=[],l=["getX","getY","getZ","getW"],h=["setX","setY","setZ","setW"];for(let e=0,n=t.length;e<n;e++){const n=t[e],{itemSize:i}=n,{count:c}=n,u=new r.InterleavedBufferAttribute(s,i,o,n.normalized);a.push(u),o+=i;for(let t=0;t<c;t++)for(let e=0;e<i;e++)u[h[e]](t,n[l[e]](t))}return a}static estimateBytesUsed(t){let e=0;for(const n in t.attributes){const i=t.getAttribute(n);e+=i.count*i.itemSize*i.array.BYTES_PER_ELEMENT}const n=t.getIndex();return e+=n?n.count*n.itemSize*n.array.BYTES_PER_ELEMENT:0,e}static mergeVertices(t,e=1e-4){e=Math.max(e,Number.EPSILON);const n={},i=t.getIndex(),r=t.getAttribute("position"),s=i?i.count:r.count;let o=0;const a=Object.keys(t.attributes),l={},h={},c=[],u=["getX","getY","getZ","getW"];for(let e=0,n=a.length;e<n;e++){const n=a[e];l[n]=[];const i=t.morphAttributes[n];i&&(h[n]=i.map(()=>[]))}const d=Math.log10(1/e),p=Math.pow(10,d);for(let e=0;e<s;e++){const r=i?i.getX(e):e;let s="";for(let e=0,n=a.length;e<n;e++){const n=a[e],i=t.getAttribute(n),{itemSize:o}=i;for(let t=0;t<o;t++)s+=~~(i[u[t]](r)*p)+","}if(s in n)c.push(n[s]);else{for(let e=0,n=a.length;e<n;e++){const n=a[e],i=t.getAttribute(n),s=t.morphAttributes[n],{itemSize:o}=i,c=l[n],d=h[n];for(let t=0;t<o;t++){const e=u[t];if(c.push(i[e](r)),s)for(let t=0,n=s.length;t<n;t++)d[t].push(s[t][e](r))}}n[s]=o,c.push(o),o++}}const{THREE:f}=x.getInstance(),m=t.clone();for(let e=0,n=a.length;e<n;e++){const n=a[e],i=t.getAttribute(n);let r=new i.array.constructor(l[n]);const s=new f.BufferAttribute(r,i.itemSize,i.normalized);if(m.setAttribute(n,s),n in h)for(let e=0;e<h[n].length;e++){const i=t.morphAttributes[n][e];r=new i.array.constructor(h[n][e]);const s=new f.BufferAttribute(r,i.itemSize,i.normalized);m.morphAttributes[n][e]=s}}return m.setIndex(c),m}static toTrianglesDrawMode(t,e){const{THREE:n}=x.getInstance();if(e===n.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(e===n.TriangleFanDrawMode||e===n.TriangleStripDrawMode){let i=t.getIndex();if(null===i){const e=[],n=t.getAttribute("position");if(void 0===n)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t<n.count;t++)e.push(t);t.setIndex(e),i=t.getIndex()}const r=i.count-2,s=[];if(e===n.TriangleFanDrawMode)for(let t=1;t<=r;t++)s.push(i.getX(0)),s.push(i.getX(t)),s.push(i.getX(t+1));else for(let t=0;t<r;t++)t%2==0?(s.push(i.getX(t)),s.push(i.getX(t+1)),s.push(i.getX(t+2))):(s.push(i.getX(t+2)),s.push(i.getX(t+1)),s.push(i.getX(t)));s.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=t.clone();return o.setIndex(s),o.clearGroups(),o}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),t}static computeMorphedAttributes(t){if(!0!==t.geometry.isBufferGeometry)return console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry."),null;const{THREE:e}=x.getInstance(),n=new e.Vector3,i=new e.Vector3,r=new e.Vector3,s=new e.Vector3,o=new e.Vector3,a=new e.Vector3,l=new e.Vector3,h=new e.Vector3,c=new e.Vector3,u=(t,e,u,d,p,f,m,g,v)=>{n.fromBufferAttribute(u,f),i.fromBufferAttribute(u,m),r.fromBufferAttribute(u,g);const y=t.morphTargetInfluences;if(e.morphTargets&&d&&y){l.set(0,0,0),h.set(0,0,0),c.set(0,0,0);for(let t=0,e=d.length;t<e;t++){const e=y[t],u=d[t];0!==e&&(s.fromBufferAttribute(u,f),o.fromBufferAttribute(u,m),a.fromBufferAttribute(u,g),p?(l.addScaledVector(s,e),h.addScaledVector(o,e),c.addScaledVector(a,e)):(l.addScaledVector(s.sub(n),e),h.addScaledVector(o.sub(i),e),c.addScaledVector(a.sub(r),e)))}n.add(l),i.add(h),r.add(c)}t.isSkinnedMesh&&(t.boneTransform(f,n),t.boneTransform(m,i),t.boneTransform(g,r)),v[3*f+0]=n.x,v[3*f+1]=n.y,v[3*f+2]=n.z,v[3*m+0]=i.x,v[3*m+1]=i.y,v[3*m+2]=i.z,v[3*g+0]=r.x,v[3*g+1]=r.y,v[3*g+2]=r.z},{geometry:d}=t,{material:p}=t;let f,m,g;const{index:v}=d,y=d.attributes.position,b=d.morphAttributes.position,{morphTargetsRelative:w}=d,M=d.attributes.normal,_=d.morphAttributes.position,{groups:E}=d,{drawRange:S}=d;let T,A,P,L,R,C,I,O;const D=new Float32Array(y.count*y.itemSize),z=new Float32Array(M.count*M.itemSize);if(null!==v)if(Array.isArray(p))for(T=0,P=E.length;T<P;T++)for(R=E[T],C=p[R.materialIndex],I=Math.max(R.start,S.start),O=Math.min(R.start+R.count,S.start+S.count),A=I,L=O;A<L;A+=3)f=v.getX(A),m=v.getX(A+1),g=v.getX(A+2),u(t,C,y,b,w,f,m,g,D),u(t,C,M,_,w,f,m,g,z);else for(I=Math.max(0,S.start),O=Math.min(v.count,S.start+S.count),T=I,P=O;T<P;T+=3)f=v.getX(T),m=v.getX(T+1),g=v.getX(T+2),u(t,p,y,b,w,f,m,g,D),u(t,p,M,_,w,f,m,g,z);else if(void 0!==y)if(Array.isArray(p))for(T=0,P=E.length;T<P;T++)for(R=E[T],C=p[R.materialIndex],I=Math.max(R.start,S.start),O=Math.min(R.start+R.count,S.start+S.count),A=I,L=O;A<L;A+=3)f=A,m=A+1,g=A+2,u(t,C,y,b,w,f,m,g,D),u(t,C,M,_,w,f,m,g,z);else for(I=Math.max(0,S.start),O=Math.min(y.count,S.start+S.count),T=I,P=O;T<P;T+=3)f=T,m=T+1,g=T+2,u(t,p,y,b,w,f,m,g,D),u(t,p,M,_,w,f,m,g,z);return{positionAttribute:y,normalAttribute:M,morphedPositionAttribute:new e.Float32BufferAttribute(D,3),morphedNormalAttribute:new e.Float32BufferAttribute(z,3)}}}.mergeBufferGeometries([i.geometry,h],!0);i.geometry=e}else i=new a.Mesh(h,n),this.add(i),this.position.set(s.x,s.y,s.zIndex);Dn.SharedResourceMap.set(l,{count:e,mesh:i,material:n})}else{h=new a.ExtrudeBufferGeometry(o,{steps:1,bevelEnabled:!1,depth:s.height,curveSegments:4});const t=new a.MeshStandardMaterial({color:s.fill,roughness:1,transparent:!0,opacity:s.fillOpacity,depthWrite:!0});let e=t;if(void 0!==s.sideColor){e=[t,new a.MeshStandardMaterial({color:s.sideColor,transparent:!0,opacity:s.sideOpacity||1})]}const n=this.shapeMesh=new a.Mesh(h,e);this.add(n),this.position.set(s.x,s.y,s.zIndex)}this.loaded=!0;try{if(S.GetEnv()===t.Env.Miniapp)return}catch(t){}if(i){Dn.StrokeType!==t.StrokeType.all&&(h=new a.ShapeBufferGeometry(o,4));const e=new a.EdgesGeometry(h);e.translate(0,0,s.height+.001||0);const n=new a.LineSegments(e,new a.LineBasicMaterial({color:new a.Color(s.stroke).getHex(),opacity:s.strokeOpacity,transparent:!0,depthWrite:!1}));this.add(n)}this.updateBorderOptions(r,o)}updateShape(t,e=!1,n=!0,i){this.disposeChildren(),this.load(t,e,n,i),this.needUpdate=!0}updateBorderOptions(t,e){if(this.borderMesh&&(xe.dispose(this.borderMesh,!0),this.remove(this.borderMesh),this.borderMesh=void 0),t){const{THREE:n}=x.getInstance(),i=this.shape.getData();e=e||be.GenerateShapeFromSteps(this.shape.getSteps());const r=null!=t.color?t.color:0,s=t.surface,o=t.splitPoints,a=t.splitWidth,l=e.getPoints().map(t=>new n.Vector3(t.x,t.y,i.zIndex)),h=[];let c=!1,u=t.closed;if(o&&a){Rn.mergeSamePoint3(l),Rn.mergePathSameVectorPoint3(l),Rn.nearlyEqualsV3(l[0],l[l.length-1])&&(u=!0,l.splice(l.length-1,1));const t=o.map(t=>new n.Vector3(t.x,t.y,i.zIndex)),e=Rn.splitPathByPoints(l,u,t,a);c=e.split,h.push(...e.paths)}else h.push(l);if(h.length){const{opacity:e=1}=t,i=new n.MeshLambertMaterial({color:r,wireframe:!1,opacity:e,transparent:!0});h.forEach(t=>{const e=new Cn(s,{closed:u&&!c,extrudePath:t}),r=this.borderMesh=new n.Mesh(e,i);this.add(r)})}}this.needUpdate=!0}resize(t,e){this.viewWidth===t&&this.viewHeight===e||this.line&&(this.line.material.resolution.set(t,e),this.viewWidth=t,this.viewHeight=e)}updateColor(t){if(this.shapeMesh){const n=this.shapeMesh.material,i=Array.isArray(n),r=i?n[0]:n;void 0!==t.fill&&(r.color=new e.Color(t.fill),r.needsUpdate=!0),void 0!==t.fillOpacity&&(r.opacity=t.fillOpacity,r.needsUpdate=!0),t.sideColor&&i&&(n[1].color=new e.Color(t.sideColor),n[1].needsUpdate=!0),t.sideOpacity&&i&&(n[1].opacity=t.sideOpacity,n[1].needsUpdate=!0)}if(this.line){const n=this.line.material;void 0!==t.stroke&&(n.color=new e.Color(t.stroke),n.needsUpdate=!0),void 0!==t.strokeOpacity&&(n.opacity=t.strokeOpacity,n.needsUpdate=!0),void 0!==t.strokeWidth&&(n.linewidth=t.strokeWidth,n.needsUpdate=!0)}if(this.borderMesh){const n=this.borderMesh.material;void 0!==t.borderColor&&(n.color=new e.Color(t.borderColor),n.needsUpdate=!0)}this.needUpdate=!0}setVisible(t){this.visible!==t&&(this.visible=t,this.needUpdate=!0)}update(){const t=new ve(this);return!this.initialized&&this.loaded&&(this.initialized=!0,t.needUpdate=!0),this.initialized&&!this.parent&&(t.shouldPlaceElement=!0),this.needUpdate&&(t.needUpdate=!0,this.needUpdate=!1),t}disposeChildren(){if(this.lowPerformance){const t=this.shape.getData(),e=`${this.tag}-${t.fill}-${t.fillOpacity}`,n=Dn.SharedResourceMap.get(e);n&&1===n.count&&n.mesh&&xe.dispose(n.mesh,!0),Dn.SharedResourceMap.delete(e)}xe.dispose(this,!0);const t=this.children;t&&this.remove(...t),this.borderMesh=void 0,this.shapeMesh=void 0}dispose(){super.dispose(),this.disposeChildren()}}Dn.StrokeType=t.StrokeType.up;class zn extends e.Object3D{constructor(t){super(),this.element=t||document.createElement("div"),this.element.style.position="absolute",this.addEventListener("removed",()=>{this.traverse(t=>{t.element instanceof Element&&null!==t.element.parentNode&&t.element.parentNode.removeChild(t.element)})})}copy(t,e){const{THREE:n}=x.getInstance();return n.Object3D.prototype.copy.call(this,t,e),this.element=t.element.cloneNode(!0),this}}class Nn{constructor(){const t=this,{THREE:e}=x.getInstance();let n,i,r,s;const o=new e.Vector3,a=new e.Matrix4,l=new e.Matrix4,h={objects:new WeakMap},c=document.createElement("div");c.style.overflow="hidden",this.domElement=c,this.getSize=function(){return{width:n,height:i}},this.setSize=function(t,e){n=t,i=e,r=n/2,s=i/2,c.style.width=t+"px",c.style.height=e+"px"};const u=function(){const t=new e.Vector3,n=new e.Vector3;return function(e,i){return t.setFromMatrixPosition(e.matrixWorld),n.setFromMatrixPosition(i.matrixWorld),t.distanceToSquared(n)}}(),d=function(t){const e=function(t){const e=[];return t.traverse(t=>{t instanceof zn&&e.push(t)}),e}(t).sort((t,e)=>h.objects.get(t).distanceToCameraSquared-h.objects.get(e).distanceToCameraSquared),n=e.length;for(let t=0,i=e.length;t<i;t++)e[t].element.style.zIndex=n-t},p=function(e,n,i){if(e instanceof zn){e.onBeforeRender(t,n,i,null,null,null),o.setFromMatrixPosition(e.matrixWorld),o.applyMatrix4(l);const{element:a}=e;/apple/i.test(navigator.vendor)?a.style.transform=`translate(-50%,-50%) translate(${Math.round(o.x*r+r)}px,${Math.round(-o.y*s+s)}px)`:a.style.transform=`translate(-50%,-50%) translate(${o.x*r+r}px,${-o.y*s+s}px)`,a.style.display=e.visible&&o.z>=-1&&o.z<=1?"":"none";const d={distanceToCameraSquared:u(i,e)};h.objects.set(e,d),a.parentNode!==c&&c.appendChild(a),e.onAfterRender(t,n,i,null,null,null)}for(let t=0,r=e.children.length;t<r;t++)p(e.children[t],n,i)};this.render=function(t,e){!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),a.copy(e.matrixWorldInverse),l.multiplyMatrices(e.projectionMatrix,a),p(t,t,e),d(t)}}}
6
+ /*!
7
+ gifken
8
+ Copyright (c) 2013 aaharu
9
+ This software is released under the MIT License.
10
+ https://raw.github.com/aaharu/gifken/master/LICENSE
11
+ */class Un{constructor(t,e,n){this.r=t,this.g=e,this.b=n}static createColorTable(t){const e=[];for(let e=1;e<=8;++e){const n=(e<<1)-t.length;for(let e=0;e<n;++e)t.push(new Un(255,255,255))}return t.forEach(t=>{e.push(t.r),e.push(t.g),e.push(t.b)}),new Uint8Array(e)}}
12
+ /*!
13
+ gifken
14
+ Copyright (c) 2013 aaharu
15
+ This software is released under the MIT License.
16
+ https://raw.github.com/aaharu/gifken/master/LICENSE
17
+
18
+ This product includes following software:
19
+ * jsgif
20
+ - Copyright (c) 2011 Shachaf Ben-Kiki
21
+ - https://github.com/shachaf/jsgif
22
+ - https://raw.github.com/shachaf/jsgif/master/LICENSE
23
+ */class Bn{static init(t,e){const n=new Bn;return n.transparentFlag=!1,n.delayCentiSeconds=0,n.transparentColorIndex=0,n.x=0,n.y=0,n.width=t||1,n.height=e||1,n.localTableSize=0,n.lzwCode=4,n.pixelData=new Uint8Array(n.width*n.height),n}decompress(){this.pixelData=this.lzwDecode(this.lzwCode,this.compressedData,this.width*this.height)}lzwDecode(t,e,n){let i=0;const r=function(t){let n=0;for(let r=0;r<t;++r)e[i>>3]&1<<(7&i)&&(n|=1<<r),++i;return n},s=new Uint8Array(n),o=1<<t,a=o+1;let l=t+1,h=[];const c=()=>{h=[],l=t+1;for(let t=0;t<o;++t)h[t]=[t];h[o]=[]};let u,d=0,p=0;for(;;)if(u=d,d=r(l),d!==o){if(d===a)break;if(d<h.length)u!==o&&h.push(h[u].concat(h[d][0]));else{if(d!==h.length)throw new Error("Invalid LZW code.");h.push(h[u].concat(h[u][0]))}s.set(h[d],p),p+=h[d].length,h.length===1<<l&&l<12&&l++}else c();return s}}
24
+ /*!
25
+ gifken
26
+ Copyright (c) 2013 aaharu
27
+ This software is released under the MIT License.
28
+ https://raw.github.com/aaharu/gifken/master/LICENSE
29
+ */!function(t){t.GIF89a="GIF89a",t.GIF87a="GIF87a"}(On||(On={}));class Fn{static readHeader(t,e){String.fromCharCode(e.getUint8(0),e.getUint8(1),e.getUint8(2),e.getUint8(3),e.getUint8(4),e.getUint8(5))==On.GIF87a?t.version=On.GIF87a:t.version=On.GIF89a,t.width=e.getUint16(6,!0),t.height=e.getUint16(8,!0);const n=e.getUint8(10),i=128&n;let r;return r=128!==i?0:1<<1+(7&n),t.colorResolution=112&n,t.sortFlag=8==(8&n),t.bgColorIndex=e.getUint8(11),t.pixelAspectRatio=e.getUint8(12),128!==i?13:(t.globalColorTable=new Uint8Array(e.buffer,13,3*r),13+3*r)}static readBlock(t,e,n){const i=e.getUint8(n);if(59===i)return-1;if(33===i){let i;const r=e.getUint8(n+1);if(249===r)return void 0===t.frames[t.frameIndex1]?(i=new Bn,n=this.readGraphicControlExtensionBlock(i,e,n),t.frames.push(i)):(i=t.frames[t.frameIndex1],n=this.readGraphicControlExtensionBlock(i,e,n)),t.frameIndex1+=1,n;if(254===r)return n=this.readCommentExtensionBlock(e,n);if(255===r)return n=this.readApplicationExtensionBlock(t,e,n);if(1===r)return n=this.readPlainTextExtensionBlock(e,n)}if(44===i){let i;return void 0===t.frames[t.frameIndex2]?(i=new Bn,n=this.readImageBlock(i,e,n),t.frames.push(i)):(i=t.frames[t.frameIndex2],n=this.readImageBlock(i,e,n)),t.frameIndex2+=1,n}return-1}static readImageBlock(t,e,n){t.x=e.getUint16(++n,!0),n+=2,t.y=e.getUint16(n,!0),n+=2,t.width=e.getUint16(n,!0),n+=2,t.height=e.getUint16(n,!0),n+=2;const i=e.getUint8(n++);128===(128&i)?(t.localTableSize=1<<1+(7&i),t.localColorTable=new Uint8Array(e.buffer,n,3*t.localTableSize),n+=3*t.localTableSize):t.localTableSize=0,t.lzwCode=e.getUint8(n++);const r=new Array;let s=0;for(;;){const t=e.getUint8(n++);if(s+=t,0===t)break;r.push(new Uint8Array(e.buffer.slice(n,n+t))),n+=t}const o=new Uint8Array(s);o.set(r[0],0);let a=r[0].byteLength;for(let t=1,e=r.length;t<e;++t)o.set(r[t],a),a+=r[t].byteLength;return t.compressedData=o,n}static readApplicationExtensionBlock(t,e,n){if(n+=2,11!==e.getUint8(n++))throw new Error("faild: _readApplicationExtensionBlock");if("NETSCAPE2.0"===String.fromCharCode(e.getUint8(n++),e.getUint8(n++),e.getUint8(n++),e.getUint8(n++),e.getUint8(n++),e.getUint8(n++),e.getUint8(n++),e.getUint8(n++),e.getUint8(n++),e.getUint8(n++),e.getUint8(n++))){if(t.isLoop=!0,3!==e.getUint8(n++))throw new Error("faild: _readApplicationExtensionBlock (NETSCAPE2.0)");++n,t.loopCount=e.getUint16(n,!0),n+=2}for(;;){const t=e.getUint8(n++);if(0===t)break;n+=t}return n}static readCommentExtensionBlock(t,e){for(e+=2;;){const n=t.getUint8(e++);if(0===n)break;e+=n}return e}static readGraphicControlExtensionBlock(t,e,n){const i=e.getUint8(n+3);return t.transparentFlag=1==(1&i),t.delayCentiSeconds=e.getUint16(n+4,!0),t.transparentColorIndex=e.getUint8(n+6),n+8}static readPlainTextExtensionBlock(t,e){for(e+=2;;){const n=t.getUint8(e++);if(0===n)break;e+=n}return e}}
30
+ /*!
31
+ gifken
32
+ Copyright (c) 2013 aaharu
33
+ This software is released under the MIT License.
34
+ https://raw.github.com/aaharu/gifken/master/LICENSE
35
+
36
+ This product includes following software:
37
+ * GifWriter.js
38
+ - Copyright (c) 2013 NOBUOKA Yu
39
+ - https://github.com/nobuoka/GifWriter.js
40
+ - https://raw.github.com/nobuoka/GifWriter.js/master/LICENSE.txt
41
+ */class Vn{constructor(){this.__out=[],this.__remNumBits=0,this.__remVal=0}push(t,e){for(;e>0;)this.__remVal=(t<<this.__remNumBits&255)+this.__remVal,e+this.__remNumBits>=8?(this.__out.push(this.__remVal),e-=8-this.__remNumBits,t>>=8-this.__remNumBits,this.__remVal=0,this.__remNumBits=0):(this.__remNumBits=e+this.__remNumBits,e=0)}flush(){this.push(0,8),this.__remNumBits=0,this.__remVal=0;const t=this.__out;return this.__out=[],t}}class kn{constructor(t){this.frameIndex1=0,this.frameIndex2=0,this.frames=[],t||(this._version=On.GIF89a,this._width=1,this._height=1,this.colorResolution=112,this.sortFlag=!1,this.bgColorIndex=1,this.pixelAspectRatio=0,this.globalColorTable=Un.createColorTable([new Un(0,0,0),new Un(255,255,255)]))}static parse(t){const e=new kn(!0),n=new DataView(t);let i=Fn.readHeader(e,n);for(;i=Fn.readBlock(e,n,i),-1!==i;);return e}versionName(){return On[this._version]}get version(){return this._version}set version(t){this._version=t}get width(){return this._width}set width(t){if((t=~~t)>65535||t<0)throw new RangeError("width range error: "+t);this._width=t}get height(){return this._height}set height(t){if((t=~~t)>65535||t<0)throw new RangeError("height range error: "+t);this._height=t}get globalColorTable(){return this._globalColorTable}set globalColorTable(t){this._globalColorTable=t,this._globalTableSize=t.byteLength/3,void 0===this.bgColorIndex&&(this.bgColorIndex=this._globalTableSize-1)}get globalTableSize(){return this._globalTableSize}get loopCount(){return this._loopCount}set loopCount(t){if((t=~~t)>65535||t<0)throw new RangeError("loopCount range error: "+t);this._loopCount=t}writeToArrayBuffer(){return kn.writeToArrayBuffer(this)}static writeToArrayBuffer(t){const e=[],n=new DataView(new ArrayBuffer(13));n.setUint8(0,71),n.setUint8(1,73),n.setUint8(2,70),n.setUint8(3,56),t.version===On.GIF89a?n.setUint8(4,57):n.setUint8(4,55),n.setUint8(5,97),n.setUint16(6,t.width,!0),n.setUint16(8,t.height,!0);let i=0,r=t.globalTableSize;if(r>0){i|=128;let t=0;do{r>>=1,++t}while(r>1);i|=t-1}if(i|=t.colorResolution,t.sortFlag&&(i|=8),n.setUint8(10,i),n.setUint8(11,t.bgColorIndex),n.setUint8(12,t.pixelAspectRatio),e.push(new Uint8Array(n.buffer)),t.globalTableSize>0&&e.push(t.globalColorTable),t.isLoop){const n=new DataView(new ArrayBuffer(19));n.setUint8(0,33),n.setUint8(1,255),n.setUint8(2,11),n.setUint8(3,78),n.setUint8(4,69),n.setUint8(5,84),n.setUint8(6,83),n.setUint8(7,67),n.setUint8(8,65),n.setUint8(9,80),n.setUint8(10,69),n.setUint8(11,50),n.setUint8(12,46),n.setUint8(13,48),n.setUint8(14,3),n.setUint8(15,1),n.setUint16(16,t.loopCount,!0),n.setUint8(18,0),e.push(new Uint8Array(n.buffer))}return t.frames.forEach(t=>{const n=new DataView(new ArrayBuffer(18));if(n.setUint8(0,33),n.setUint8(1,249),n.setUint8(2,4),t.transparentFlag?n.setUint8(3,1):n.setUint8(3,0),n.setUint16(4,t.delayCentiSeconds,!0),n.setUint8(6,t.transparentColorIndex),n.setUint8(7,0),n.setUint8(8,44),n.setUint16(9,t.x,!0),n.setUint16(11,t.y,!0),n.setUint16(13,t.width,!0),n.setUint16(15,t.height,!0),t.localTableSize>0){let e=0,i=t.localTableSize;do{i>>=1,++e}while(i>1);n.setUint8(17,128|e-1)}else n.setUint8(17,0);if(e.push(new Uint8Array(n.buffer)),t.localTableSize>0&&e.push(t.localColorTable),e.push(new Uint8Array([t.lzwCode])),void 0===t.compressedData&&void 0===t.pixelData)throw new Error("no image data");let i=0,r=t.compressedData;r=r instanceof Array?new Uint8Array(r):r||new Uint8Array(kn.compressWithLZW(t.pixelData,t.lzwCode));const s=r.length;for(;;){if(s>i+255){e.push(new Uint8Array([255])),e.push(r.subarray(i,i+255)),i+=255;continue}const t=r.subarray(i);e.push(new Uint8Array([t.byteLength])),e.push(t);break}e.push(new Uint8Array([0]))}),e.push(new Uint8Array([59])),e}writeToArray(){const t=kn.writeToArrayBuffer(this),e=[];return t.forEach(t=>{for(let n=0,i=t.byteLength;n<i;++n)e.push(t[n])}),e}split(t){const e=[];return t?this.frames.forEach((t,n)=>{const i=new kn;i.version=this._version,i.width=this._width,i.height=this._height,i.colorResolution=this.colorResolution,i.sortFlag=this.sortFlag,i.bgColorIndex=this.bgColorIndex,i.pixelAspectRatio=this.pixelAspectRatio,i.globalColorTable=this._globalColorTable,i.frames=[t],e.push(i)}):this.frames.forEach(t=>{const n=new kn;n.version=this._version,n.width=this._width,n.height=this._height,n.colorResolution=this.colorResolution,n.sortFlag=this.sortFlag,n.bgColorIndex=this.bgColorIndex,n.pixelAspectRatio=this.pixelAspectRatio,n.globalColorTable=this._globalColorTable,n.frames=[t],e.push(n)}),e}playback(t){const e=new kn;return t&&this.frames.forEach((t,e)=>{if(0!==e&&t.transparentFlag){void 0===t.pixelData&&t.decompress(),void 0===this.frames[e-1].pixelData&&this.frames[e-1].decompress();let n=!1;for(let i=0,r=t.pixelData.length;i<r;++i)t.pixelData[i]===t.transparentColorIndex&&(t.pixelData[i]=this.frames[e-1].pixelData[i],n=!0);if(n){const e=kn.compressWithLZW(t.pixelData,t.lzwCode);t.compressedData=new Uint8Array(e)}delete t.pixelData}}),e.version=this._version,e.width=this._width,e.height=this._height,e.colorResolution=this.colorResolution,e.sortFlag=this.sortFlag,e.bgColorIndex=this.bgColorIndex,e.pixelAspectRatio=this.pixelAspectRatio,e.globalColorTable=this._globalColorTable,e.frames=this.frames.reverse(),e.isLoop=this.isLoop,e.loopCount=this._loopCount,e}static compressWithLZW(t,e){const n=new Vn,i=1<<e,r=i+1;let s=r+1,o=e+1,a=Object.create(null);function l(){s=r+1,o=e+1,a=Object.create(null)}l(),n.push(i,o);let h="";for(let e=0,r=t.length;e<r;++e){const r=t[e],c=String.fromCharCode(r);c in a||(a[c]=r);const u=h;h+=c,h in a||(n.push(a[u],o),s<=4095?(a[h]=s,s===1<<o&&o++,s++):(n.push(i,o),l(),a[c]=r),h=c)}return n.push(a[h],o),n.push(r,o),n.flush()}}
42
+ /*!
43
+ gifken
44
+ Copyright (c) 2013 aaharu
45
+ This software is released under the MIT License.
46
+ https://raw.github.com/aaharu/gifken/master/LICENSE
47
+ */var Hn={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Gn=z((function(t){var e=Array.prototype.concat,n=Array.prototype.slice,i=t.exports=function(t){for(var i,r=[],s=0,o=t.length;s<o;s++){var a=t[s];(i=a)&&"string"!=typeof i&&(i instanceof Array||Array.isArray(i)||i.length>=0&&(i.splice instanceof Function||Object.getOwnPropertyDescriptor(i,i.length-1)&&"String"!==i.constructor.name))?r=e.call(r,n.call(a)):r.push(a)}return r};i.wrap=function(t){return function(){return t(i(arguments))}}})),Wn=z((function(t){var e=Object.hasOwnProperty,n=Object.create(null);for(var i in Hn)e.call(Hn,i)&&(n[Hn[i]]=i);var r=t.exports={to:{},get:{}};function s(t,e,n){return Math.min(Math.max(e,t),n)}function o(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}r.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=r.get.hsl(t),n="hsl";break;case"hwb":e=r.get.hwb(t),n="hwb";break;default:e=r.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},r.get.rgb=function(t){if(!t)return null;var n,i,r,o=[0,0,0,1];if(n=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=n[2],n=n[1],i=0;i<3;i++){var a=2*i;o[i]=parseInt(n.slice(a,a+2),16)}r&&(o[3]=parseInt(r,16)/255)}else if(n=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(n=n[1])[3],i=0;i<3;i++)o[i]=parseInt(n[i]+n[i],16);r&&(o[3]=parseInt(r+r,16)/255)}else if(n=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(i=0;i<3;i++)o[i]=parseInt(n[i+1],0);n[4]&&(n[5]?o[3]=.01*parseFloat(n[4]):o[3]=parseFloat(n[4]))}else{if(!(n=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(n=t.match(/^(\w+)$/))?"transparent"===n[1]?[0,0,0,0]:e.call(Hn,n[1])?((o=Hn[n[1]])[3]=1,o):null:null;for(i=0;i<3;i++)o[i]=Math.round(2.55*parseFloat(n[i+1]));n[4]&&(n[5]?o[3]=.01*parseFloat(n[4]):o[3]=parseFloat(n[4]))}for(i=0;i<3;i++)o[i]=s(o[i],0,255);return o[3]=s(o[3],0,1),o},r.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,s(parseFloat(e[2]),0,100),s(parseFloat(e[3]),0,100),s(isNaN(n)?1:n,0,1)]}return null},r.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,s(parseFloat(e[2]),0,100),s(parseFloat(e[3]),0,100),s(isNaN(n)?1:n,0,1)]}return null},r.to.hex=function(){var t=Gn(arguments);return"#"+o(t[0])+o(t[1])+o(t[2])+(t[3]<1?o(Math.round(255*t[3])):"")},r.to.rgb=function(){var t=Gn(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},r.to.rgb.percent=function(){var t=Gn(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),i=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+i+"%)":"rgba("+e+"%, "+n+"%, "+i+"%, "+t[3]+")"},r.to.hsl=function(){var t=Gn(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},r.to.hwb=function(){var t=Gn(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},r.to.keyword=function(t){return n[t.slice(0,3)]}})),jn=(Wn.to,Wn.get,{aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}),Xn=z((function(t){var e={};for(var n in jn)jn.hasOwnProperty(n)&&(e[jn[n]]=n);var i=t.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var r in i)if(i.hasOwnProperty(r)){if(!("channels"in i[r]))throw new Error("missing channels property: "+r);if(!("labels"in i[r]))throw new Error("missing channel labels property: "+r);if(i[r].labels.length!==i[r].channels)throw new Error("channel and label counts mismatch: "+r);var s=i[r].channels,o=i[r].labels;delete i[r].channels,delete i[r].labels,Object.defineProperty(i[r],"channels",{value:s}),Object.defineProperty(i[r],"labels",{value:o})}function a(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}i.rgb.hsl=function(t){var e,n,i=t[0]/255,r=t[1]/255,s=t[2]/255,o=Math.min(i,r,s),a=Math.max(i,r,s),l=a-o;return a===o?e=0:i===a?e=(r-s)/l:r===a?e=2+(s-i)/l:s===a&&(e=4+(i-r)/l),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?l/(a+o):l/(2-a-o)),100*n]},i.rgb.hsv=function(t){var e,n,i,r,s,o=t[0]/255,a=t[1]/255,l=t[2]/255,h=Math.max(o,a,l),c=h-Math.min(o,a,l),u=function(t){return(h-t)/6/c+.5};return 0===c?r=s=0:(s=c/h,e=u(o),n=u(a),i=u(l),o===h?r=i-n:a===h?r=1/3+e-i:l===h&&(r=2/3+n-e),r<0?r+=1:r>1&&(r-=1)),[360*r,100*s,100*h]},i.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[i.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},i.rgb.cmyk=function(t){var e,n=t[0]/255,i=t[1]/255,r=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-i,1-r)))/(1-e)||0),100*((1-i-e)/(1-e)||0),100*((1-r-e)/(1-e)||0),100*e]},i.rgb.keyword=function(t){var n=e[t];if(n)return n;var i,r=1/0;for(var s in jn)if(jn.hasOwnProperty(s)){var o=a(t,jn[s]);o<r&&(r=o,i=s)}return i},i.keyword.rgb=function(t){return jn[t]},i.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,i=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92)),100*(.2126*e+.7152*n+.0722*i),100*(.0193*e+.1192*n+.9505*i)]},i.rgb.lab=function(t){var e=i.rgb.xyz(t),n=e[0],r=e[1],s=e[2];return r/=100,s/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(s=s>.008856?Math.pow(s,1/3):7.787*s+16/116))]},i.hsl.rgb=function(t){var e,n,i,r,s,o=t[0]/360,a=t[1]/100,l=t[2]/100;if(0===a)return[s=255*l,s,s];e=2*l-(n=l<.5?l*(1+a):l+a-l*a),r=[0,0,0];for(var h=0;h<3;h++)(i=o+1/3*-(h-1))<0&&i++,i>1&&i--,s=6*i<1?e+6*(n-e)*i:2*i<1?n:3*i<2?e+(n-e)*(2/3-i)*6:e,r[h]=255*s;return r},i.hsl.hsv=function(t){var e=t[0],n=t[1]/100,i=t[2]/100,r=n,s=Math.max(i,.01);return n*=(i*=2)<=1?i:2-i,r*=s<=1?s:2-s,[e,100*(0===i?2*r/(s+r):2*n/(i+n)),100*((i+n)/2)]},i.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,i=t[2]/100,r=Math.floor(e)%6,s=e-Math.floor(e),o=255*i*(1-n),a=255*i*(1-n*s),l=255*i*(1-n*(1-s));switch(i*=255,r){case 0:return[i,l,o];case 1:return[a,i,o];case 2:return[o,i,l];case 3:return[o,a,i];case 4:return[l,o,i];case 5:return[i,o,a]}},i.hsv.hsl=function(t){var e,n,i,r=t[0],s=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return i=(2-s)*o,n=s*a,[r,100*(n=(n/=(e=(2-s)*a)<=1?e:2-e)||0),100*(i/=2)]},i.hwb.rgb=function(t){var e,n,i,r,s,o,a,l=t[0]/360,h=t[1]/100,c=t[2]/100,u=h+c;switch(u>1&&(h/=u,c/=u),i=6*l-(e=Math.floor(6*l)),0!=(1&e)&&(i=1-i),r=h+i*((n=1-c)-h),e){default:case 6:case 0:s=n,o=r,a=h;break;case 1:s=r,o=n,a=h;break;case 2:s=h,o=n,a=r;break;case 3:s=h,o=r,a=n;break;case 4:s=r,o=h,a=n;break;case 5:s=n,o=h,a=r}return[255*s,255*o,255*a]},i.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,i=t[2]/100,r=t[3]/100;return[255*(1-Math.min(1,e*(1-r)+r)),255*(1-Math.min(1,n*(1-r)+r)),255*(1-Math.min(1,i*(1-r)+r))]},i.xyz.rgb=function(t){var e,n,i,r=t[0]/100,s=t[1]/100,o=t[2]/100;return n=-.9689*r+1.8758*s+.0415*o,i=.0557*r+-.204*s+1.057*o,e=(e=3.2406*r+-1.5372*s+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:12.92*i,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(i=Math.min(Math.max(0,i),1))]},i.xyz.lab=function(t){var e=t[0],n=t[1],i=t[2];return n/=100,i/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(i=i>.008856?Math.pow(i,1/3):7.787*i+16/116))]},i.lab.xyz=function(t){var e,n,i,r=t[0];e=t[1]/500+(n=(r+16)/116),i=n-t[2]/200;var s=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(i,3);return n=s>.008856?s:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,i=a>.008856?a:(i-16/116)/7.787,[e*=95.047,n*=100,i*=108.883]},i.lab.lch=function(t){var e,n=t[0],i=t[1],r=t[2];return(e=360*Math.atan2(r,i)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(i*i+r*r),e]},i.lch.lab=function(t){var e,n=t[0],i=t[1];return e=t[2]/360*2*Math.PI,[n,i*Math.cos(e),i*Math.sin(e)]},i.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],s=1 in arguments?arguments[1]:i.rgb.hsv(t)[2];if(0===(s=Math.round(s/50)))return 30;var o=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===s&&(o+=60),o},i.hsv.ansi16=function(t){return i.rgb.ansi16(i.hsv.rgb(t),t[2])},i.rgb.ansi256=function(t){var e=t[0],n=t[1],i=t[2];return e===n&&n===i?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(i/255*5)},i.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},i.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},i.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},i.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var i=parseInt(n,16);return[i>>16&255,i>>8&255,255&i]},i.rgb.hcg=function(t){var e,n=t[0]/255,i=t[1]/255,r=t[2]/255,s=Math.max(Math.max(n,i),r),o=Math.min(Math.min(n,i),r),a=s-o;return e=a<=0?0:s===n?(i-r)/a%6:s===i?2+(r-n)/a:4+(n-i)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},i.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,i=1,r=0;return(i=n<.5?2*e*n:2*e*(1-n))<1&&(r=(n-.5*i)/(1-i)),[t[0],100*i,100*r]},i.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,i=e*n,r=0;return i<1&&(r=(n-i)/(1-i)),[t[0],100*i,100*r]},i.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,i=t[2]/100;if(0===n)return[255*i,255*i,255*i];var r,s=[0,0,0],o=e%1*6,a=o%1,l=1-a;switch(Math.floor(o)){case 0:s[0]=1,s[1]=a,s[2]=0;break;case 1:s[0]=l,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=a;break;case 3:s[0]=0,s[1]=l,s[2]=1;break;case 4:s[0]=a,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=l}return r=(1-n)*i,[255*(n*s[0]+r),255*(n*s[1]+r),255*(n*s[2]+r)]},i.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),i=0;return n>0&&(i=e/n),[t[0],100*i,100*n]},i.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,i=0;return n>0&&n<.5?i=e/(2*n):n>=.5&&n<1&&(i=e/(2*(1-n))),[t[0],100*i,100*n]},i.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},i.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,i=n-e,r=0;return i<1&&(r=(n-i)/(1-i)),[t[0],100*i,100*r]},i.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},i.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},i.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},i.gray.hsl=i.gray.hsv=function(t){return[0,0,t[0]]},i.gray.hwb=function(t){return[0,100,t[0]]},i.gray.cmyk=function(t){return[0,0,0,t[0]]},i.gray.lab=function(t){return[t[0],0,0]},i.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},i.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]}}));Xn.rgb,Xn.hsl,Xn.hsv,Xn.hwb,Xn.cmyk,Xn.xyz,Xn.lab,Xn.lch,Xn.hex,Xn.keyword,Xn.ansi16,Xn.ansi256,Xn.hcg,Xn.apple,Xn.gray;function Yn(t){var e=function(){for(var t={},e=Object.keys(Xn),n=e.length,i=0;i<n;i++)t[e[i]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var i=n.pop(),r=Object.keys(Xn[i]),s=r.length,o=0;o<s;o++){var a=r[o],l=e[a];-1===l.distance&&(l.distance=e[i].distance+1,l.parent=i,n.unshift(a))}return e}function qn(t,e){return function(n){return e(t(n))}}function Zn(t,e){for(var n=[e[t].parent,t],i=Xn[e[t].parent][t],r=e[t].parent;e[r].parent;)n.unshift(e[r].parent),i=qn(Xn[e[r].parent][r],i),r=e[r].parent;return i.conversion=n,i}var Jn={};Object.keys(Xn).forEach((function(t){Jn[t]={},Object.defineProperty(Jn[t],"channels",{value:Xn[t].channels}),Object.defineProperty(Jn[t],"labels",{value:Xn[t].labels});var e=function(t){for(var e=Yn(t),n={},i=Object.keys(e),r=i.length,s=0;s<r;s++){var o=i[s];null!==e[o].parent&&(n[o]=Zn(o,e))}return n}(t);Object.keys(e).forEach((function(n){var i=e[n];Jn[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var i=n.length,r=0;r<i;r++)n[r]=Math.round(n[r]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(i),Jn[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(i)}))}));var $n=Jn,Qn=[].slice,Kn=["keyword","gray","hex"],ti={};Object.keys($n).forEach((function(t){ti[Qn.call($n[t].labels).sort().join("")]=t}));var ei={};function ni(t,e){if(!(this instanceof ni))return new ni(t,e);if(e&&e in Kn&&(e=null),e&&!(e in $n))throw new Error("Unknown model: "+e);var n,i;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ni)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var r=Wn.get(t);if(null===r)throw new Error("Unable to parse color from string: "+t);this.model=r.model,i=$n[this.model].channels,this.color=r.value.slice(0,i),this.valpha="number"==typeof r.value[i]?r.value[i]:1}else if(t.length){this.model=e||"rgb",i=$n[this.model].channels;var s=Qn.call(t,0,i);this.color=oi(s,i),this.valpha="number"==typeof t[i]?t[i]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in ti))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=ti[a];var l=$n[this.model].labels,h=[];for(n=0;n<l.length;n++)h.push(t[l[n]]);this.color=oi(h)}if(ei[this.model])for(i=$n[this.model].channels,n=0;n<i;n++){var c=ei[this.model][n];c&&(this.color[n]=c(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ii(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(ei[t]||(ei[t]=[]))[e]=n})),t=t[0],function(i){var r;return arguments.length?(n&&(i=n(i)),(r=this[t]()).color[e]=i,r):(r=this[t]().color[e],n&&(r=n(r)),r)}}function ri(t){return function(e){return Math.max(0,Math.min(t,e))}}function si(t){return Array.isArray(t)?t:[t]}function oi(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}ni.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in Wn.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return Wn.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return Wn.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=$n[this.model].channels,n=$n[this.model].labels,i=0;i<e;i++)t[n[i]]=this.color[i];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ni(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ni(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ii("rgb",0,ri(255)),green:ii("rgb",1,ri(255)),blue:ii("rgb",2,ri(255)),hue:ii(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ii("hsl",1,ri(100)),lightness:ii("hsl",2,ri(100)),saturationv:ii("hsv",1,ri(100)),value:ii("hsv",2,ri(100)),chroma:ii("hcg",1,ri(100)),gray:ii("hcg",2,ri(100)),white:ii("hwb",1,ri(100)),wblack:ii("hwb",2,ri(100)),cyan:ii("cmyk",0,ri(100)),magenta:ii("cmyk",1,ri(100)),yellow:ii("cmyk",2,ri(100)),black:ii("cmyk",3,ri(100)),x:ii("xyz",0,ri(100)),y:ii("xyz",1,ri(100)),z:ii("xyz",2,ri(100)),l:ii("lab",0,ri(100)),a:ii("lab",1),b:ii("lab",2),keyword:function(t){return arguments.length?new ni(t):$n[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ni(t):Wn.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var i=t[n]/255;e[n]=i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ni.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),i=this.rgb(),r=void 0===e?.5:e,s=2*r-1,o=n.alpha()-i.alpha(),a=((s*o==-1?s:(s+o)/(1+s*o))+1)/2,l=1-a;return ni.rgb(a*n.red()+l*i.red(),a*n.green()+l*i.green(),a*n.blue()+l*i.blue(),n.alpha()*r+i.alpha()*(1-r))}},Object.keys($n).forEach((function(t){if(-1===Kn.indexOf(t)){var e=$n[t].channels;ni.prototype[t]=function(){if(this.model===t)return new ni(this);if(arguments.length)return new ni(arguments,t);var n="number"==typeof arguments[e]?e:this.valpha;return new ni(si($n[this.model][t].raw(this.color)).concat(n),t)},ni[t]=function(n){return"number"==typeof n&&(n=oi(Qn.call(arguments),e)),new ni(n,t)}}}));var ai=ni,li={centimeters:637100880,centimetres:637100880,degrees:6371008.8/111325,feet:20902260.511392,inches:6371008.8*39.37,kilometers:6371.0088,kilometres:6371.0088,meters:6371008.8,metres:6371008.8,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:6371008.8/1852,radians:1,yards:6371008.8*1.0936},hi={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/6371008.8,yards:1.0936133},ci={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046};function ui(t,e,n){void 0===n&&(n={});var i={type:"Feature"};return(0===n.id||n.id)&&(i.id=n.id),n.bbox&&(i.bbox=n.bbox),i.properties=e||{},i.geometry=t,i}function di(t,e,n){if(void 0===n&&(n={}),!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Mi(t[0])||!Mi(t[1]))throw new Error("coordinates must contain numbers");return ui({type:"Point",coordinates:t},e,n)}function pi(t,e,n){void 0===n&&(n={});for(var i=0,r=t;i<r.length;i++){var s=r[i];if(s.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var o=0;o<s[s.length-1].length;o++)if(s[s.length-1][o]!==s[0][o])throw new Error("First and last Position are not equivalent.")}return ui({type:"Polygon",coordinates:t},e,n)}function fi(t,e,n){if(void 0===n&&(n={}),t.length<2)throw new Error("coordinates must be an array of two or more positions");return ui({type:"LineString",coordinates:t},e,n)}function mi(t,e){void 0===e&&(e={});var n={type:"FeatureCollection"};return e.id&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.features=t,n}function gi(t,e,n){return void 0===n&&(n={}),ui({type:"MultiLineString",coordinates:t},e,n)}function vi(t,e,n){return void 0===n&&(n={}),ui({type:"MultiPoint",coordinates:t},e,n)}function yi(t,e,n){return void 0===n&&(n={}),ui({type:"MultiPolygon",coordinates:t},e,n)}function xi(t,e){void 0===e&&(e="kilometers");var n=li[e];if(!n)throw new Error(e+" units is invalid");return t*n}function bi(t,e){void 0===e&&(e="kilometers");var n=li[e];if(!n)throw new Error(e+" units is invalid");return t/n}function wi(t){return 180*(t%(2*Math.PI))/Math.PI}function Mi(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}function _i(t){return!!t&&t.constructor===Object}var Ei=Object.freeze({__proto__:null,earthRadius:6371008.8,factors:li,unitsFactors:hi,areaFactors:ci,feature:ui,geometry:function(t,e,n){switch(t){case"Point":return di(e).geometry;case"LineString":return fi(e).geometry;case"Polygon":return pi(e).geometry;case"MultiPoint":return vi(e).geometry;case"MultiLineString":return gi(e).geometry;case"MultiPolygon":return yi(e).geometry;default:throw new Error(t+" is invalid")}},point:di,points:function(t,e,n){return void 0===n&&(n={}),mi(t.map((function(t){return di(t,e)})),n)},polygon:pi,polygons:function(t,e,n){return void 0===n&&(n={}),mi(t.map((function(t){return pi(t,e)})),n)},lineString:fi,lineStrings:function(t,e,n){return void 0===n&&(n={}),mi(t.map((function(t){return fi(t,e)})),n)},featureCollection:mi,multiLineString:gi,multiPoint:vi,multiPolygon:yi,geometryCollection:function(t,e,n){return void 0===n&&(n={}),ui({type:"GeometryCollection",geometries:t},e,n)},round:function(t,e){if(void 0===e&&(e=0),e&&!(e>=0))throw new Error("precision must be a positive number");var n=Math.pow(10,e||0);return Math.round(t*n)/n},radiansToLength:xi,lengthToRadians:bi,lengthToDegrees:function(t,e){return wi(bi(t,e))},bearingToAzimuth:function(t){var e=t%360;return e<0&&(e+=360),e},radiansToDegrees:wi,degreesToRadians:function(t){return t%360*Math.PI/180},convertLength:function(t,e,n){if(void 0===e&&(e="kilometers"),void 0===n&&(n="kilometers"),!(t>=0))throw new Error("length must be a positive number");return xi(bi(t,e),n)},convertArea:function(t,e,n){if(void 0===e&&(e="meters"),void 0===n&&(n="kilometers"),!(t>=0))throw new Error("area must be a positive number");var i=ci[e];if(!i)throw new Error("invalid original units");var r=ci[n];if(!r)throw new Error("invalid final units");return t/i*r},isNumber:Mi,isObject:_i,validateBBox:function(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach((function(t){if(!Mi(t))throw new Error("bbox must only contain numbers")}))},validateId:function(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof t))throw new Error("id must be a number or a string")}});function Si(t,e,n){if(null!==t)for(var i,r,s,o,a,l,h,c,u=0,d=0,p=t.type,f="FeatureCollection"===p,m="Feature"===p,g=f?t.features.length:1,v=0;v<g;v++){a=(c=!!(h=f?t.features[v].geometry:m?t.geometry:t)&&"GeometryCollection"===h.type)?h.geometries.length:1;for(var y=0;y<a;y++){var x=0,b=0;if(null!==(o=c?h.geometries[y]:h)){l=o.coordinates;var w=o.type;switch(u=!n||"Polygon"!==w&&"MultiPolygon"!==w?0:1,w){case null:break;case"Point":if(!1===e(l,d,v,x,b))return!1;d++,x++;break;case"LineString":case"MultiPoint":for(i=0;i<l.length;i++){if(!1===e(l[i],d,v,x,b))return!1;d++,"MultiPoint"===w&&x++}"LineString"===w&&x++;break;case"Polygon":case"MultiLineString":for(i=0;i<l.length;i++){for(r=0;r<l[i].length-u;r++){if(!1===e(l[i][r],d,v,x,b))return!1;d++}"MultiLineString"===w&&x++,"Polygon"===w&&b++}"Polygon"===w&&x++;break;case"MultiPolygon":for(i=0;i<l.length;i++){for(b=0,r=0;r<l[i].length;r++){for(s=0;s<l[i][r].length-u;s++){if(!1===e(l[i][r][s],d,v,x,b))return!1;d++}b++}x++}break;case"GeometryCollection":for(i=0;i<o.geometries.length;i++)if(!1===Si(o.geometries[i],e,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Ti(t,e){var n;switch(t.type){case"FeatureCollection":for(n=0;n<t.features.length&&!1!==e(t.features[n].properties,n);n++);break;case"Feature":e(t.properties,0)}}function Ai(t,e){if("Feature"===t.type)e(t,0);else if("FeatureCollection"===t.type)for(var n=0;n<t.features.length&&!1!==e(t.features[n],n);n++);}function Pi(t,e){var n,i,r,s,o,a,l,h,c,u,d=0,p="FeatureCollection"===t.type,f="Feature"===t.type,m=p?t.features.length:1;for(n=0;n<m;n++){for(a=p?t.features[n].geometry:f?t.geometry:t,h=p?t.features[n].properties:f?t.properties:{},c=p?t.features[n].bbox:f?t.bbox:void 0,u=p?t.features[n].id:f?t.id:void 0,o=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,r=0;r<o;r++)if(null!==(s=l?a.geometries[r]:a))switch(s.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(s,d,h,c,u))return!1;break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(!1===e(s.geometries[i],d,h,c,u))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,d,h,c,u))return!1;d++}}function Li(t,e){Pi(t,(function(t,n,i,r,s){var o,a=null===t?null:t.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return!1!==e(ui(t,i,{bbox:r,id:s}),n,0)&&void 0}switch(a){case"MultiPoint":o="Point";break;case"MultiLineString":o="LineString";break;case"MultiPolygon":o="Polygon"}for(var l=0;l<t.coordinates.length;l++){var h=t.coordinates[l];if(!1===e(ui({type:o,coordinates:h},i),n,l))return!1}}))}function Ri(t,e){Li(t,(function(t,n,i){var r=0;if(t.geometry){var s=t.geometry.type;if("Point"!==s&&"MultiPoint"!==s){var o,a=0,l=0,h=0;return!1!==Si(t,(function(s,c,u,d,p){if(void 0===o||n>a||d>l||p>h)return o=s,a=n,l=d,h=p,void(r=0);var f=fi([o,s],t.properties);if(!1===e(f,n,i,p,r))return!1;r++,o=s}))&&void 0}}}))}function Ci(t,e){if(!t)throw new Error("geojson is required");Li(t,(function(t,n,i){if(null!==t.geometry){var r=t.geometry.type,s=t.geometry.coordinates;switch(r){case"LineString":if(!1===e(t,n,i,0,0))return!1;break;case"Polygon":for(var o=0;o<s.length;o++)if(!1===e(fi(s[o],t.properties),n,i,o))return!1}}}))}var Ii=Object.freeze({__proto__:null,coordAll:function(t){var e=[];return Si(t,(function(t){e.push(t)})),e},coordEach:Si,coordReduce:function(t,e,n,i){var r=n;return Si(t,(function(t,i,s,o,a){r=0===i&&void 0===n?t:e(r,t,i,s,o,a)}),i),r},featureEach:Ai,featureReduce:function(t,e,n){var i=n;return Ai(t,(function(t,r){i=0===r&&void 0===n?t:e(i,t,r)})),i},findPoint:function(t,e){if(!_i(e=e||{}))throw new Error("options is invalid");var n,i=e.featureIndex||0,r=e.multiFeatureIndex||0,s=e.geometryIndex||0,o=e.coordIndex||0,a=e.properties;switch(t.type){case"FeatureCollection":i<0&&(i=t.features.length+i),a=a||t.features[i].properties,n=t.features[i].geometry;break;case"Feature":a=a||t.properties,n=t.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":n=t;break;default:throw new Error("geojson is invalid")}if(null===n)return null;var l=n.coordinates;switch(n.type){case"Point":return di(l,a,e);case"MultiPoint":return r<0&&(r=l.length+r),di(l[r],a,e);case"LineString":return o<0&&(o=l.length+o),di(l[o],a,e);case"Polygon":return s<0&&(s=l.length+s),o<0&&(o=l[s].length+o),di(l[s][o],a,e);case"MultiLineString":return r<0&&(r=l.length+r),o<0&&(o=l[r].length+o),di(l[r][o],a,e);case"MultiPolygon":return r<0&&(r=l.length+r),s<0&&(s=l[r].length+s),o<0&&(o=l[r][s].length-o),di(l[r][s][o],a,e)}throw new Error("geojson is invalid")},findSegment:function(t,e){if(!_i(e=e||{}))throw new Error("options is invalid");var n,i=e.featureIndex||0,r=e.multiFeatureIndex||0,s=e.geometryIndex||0,o=e.segmentIndex||0,a=e.properties;switch(t.type){case"FeatureCollection":i<0&&(i=t.features.length+i),a=a||t.features[i].properties,n=t.features[i].geometry;break;case"Feature":a=a||t.properties,n=t.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":n=t;break;default:throw new Error("geojson is invalid")}if(null===n)return null;var l=n.coordinates;switch(n.type){case"Point":case"MultiPoint":return null;case"LineString":return o<0&&(o=l.length+o-1),fi([l[o],l[o+1]],a,e);case"Polygon":return s<0&&(s=l.length+s),o<0&&(o=l[s].length+o-1),fi([l[s][o],l[s][o+1]],a,e);case"MultiLineString":return r<0&&(r=l.length+r),o<0&&(o=l[r].length+o-1),fi([l[r][o],l[r][o+1]],a,e);case"MultiPolygon":return r<0&&(r=l.length+r),s<0&&(s=l[r].length+s),o<0&&(o=l[r][s].length-o-1),fi([l[r][s][o],l[r][s][o+1]],a,e)}throw new Error("geojson is invalid")},flattenEach:Li,flattenReduce:function(t,e,n){var i=n;return Li(t,(function(t,r,s){i=0===r&&0===s&&void 0===n?t:e(i,t,r,s)})),i},geomEach:Pi,geomReduce:function(t,e,n){var i=n;return Pi(t,(function(t,r,s,o,a){i=0===r&&void 0===n?t:e(i,t,r,s,o,a)})),i},lineEach:Ci,lineReduce:function(t,e,n){var i=n;return Ci(t,(function(t,r,s,o){i=0===r&&void 0===n?t:e(i,t,r,s,o)})),i},propEach:Ti,propReduce:function(t,e,n){var i=n;return Ti(t,(function(t,r){i=0===r&&void 0===n?t:e(i,t,r)})),i},segmentEach:Ri,segmentReduce:function(t,e,n){var i=n,r=!1;return Ri(t,(function(t,s,o,a,l){i=!1===r&&void 0===n?t:e(i,t,s,o,a,l),r=!0})),i}});function Oi(t){var e=[1/0,1/0,-1/0,-1/0];return Si(t,(function(t){e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]<t[0]&&(e[2]=t[0]),e[3]<t[1]&&(e[3]=t[1])})),e}function Di(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if("Feature"===t.type&&null!==t.geometry&&"Point"===t.geometry.type)return t.geometry.coordinates;if("Point"===t.type)return t.coordinates}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return t;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function zi(t){if(Array.isArray(t))return t;if("Feature"===t.type){if(null!==t.geometry)return t.geometry.coordinates}else if(t.coordinates)return t.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Ni(t){return"Feature"===t.type?t.geometry:t}function Ui(t,e,n=0,i=t.length-1,r=Fi){for(;i>n;){if(i-n>600){const s=i-n+1,o=e-n+1,a=Math.log(s),l=.5*Math.exp(2*a/3),h=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);Ui(t,e,Math.max(n,Math.floor(e-o*l/s+h)),Math.min(i,Math.floor(e+(s-o)*l/s+h)),r)}const s=t[e];let o=n,a=i;for(Bi(t,n,e),r(t[i],s)>0&&Bi(t,n,i);o<a;){for(Bi(t,o,a),o++,a--;r(t[o],s)<0;)o++;for(;r(t[a],s)>0;)a--}0===r(t[n],s)?Bi(t,n,a):(a++,Bi(t,a,i)),a<=e&&(n=a+1),e<=a&&(i=a-1)}}function Bi(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function Fi(t,e){return t<e?-1:t>e?1:0}Oi.default=Oi;class Vi{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const n=[];if(!Qi(t,e))return n;const i=this.toBBox,r=[];for(;e;){for(let s=0;s<e.children.length;s++){const o=e.children[s],a=e.leaf?i(o):o;Qi(t,a)&&(e.leaf?n.push(o):$i(t,a)?this._all(o,n):r.push(o))}e=r.pop()}return n}collides(t){let e=this.data;if(!Qi(t,e))return!1;const n=[];for(;e;){for(let i=0;i<e.children.length;i++){const r=e.children[i],s=e.leaf?this.toBBox(r):r;if(Qi(t,s)){if(e.leaf||$i(t,s))return!0;n.push(r)}}e=n.pop()}return!1}load(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(let e=0;e<t.length;e++)this.insert(t[e]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const t=this.data;this.data=e,e=t}this._insert(e,this.data.height-e.height-1,!0)}else this.data=e;return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Ki([]),this}remove(t,e){if(!t)return this;let n=this.data;const i=this.toBBox(t),r=[],s=[];let o,a,l;for(;n||r.length;){if(n||(n=r.pop(),a=r[r.length-1],o=s.pop(),l=!0),n.leaf){const i=ki(t,n.children,e);if(-1!==i)return n.children.splice(i,1),r.push(n),this._condense(r),this}l||n.leaf||!$i(n,i)?a?(o++,n=a.children[o],l=!1):n=null:(r.push(n),s.push(o),o=0,a=n,n=n.children[0])}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const n=[];for(;t;)t.leaf?e.push(...t.children):n.push(...t.children),t=n.pop();return e}_build(t,e,n,i){const r=n-e+1;let s,o=this._maxEntries;if(r<=o)return s=Ki(t.slice(e,n+1)),Hi(s,this.toBBox),s;i||(i=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,i-1))),s=Ki([]),s.leaf=!1,s.height=i;const a=Math.ceil(r/o),l=a*Math.ceil(Math.sqrt(o));tr(t,e,n,l,this.compareMinX);for(let r=e;r<=n;r+=l){const e=Math.min(r+l-1,n);tr(t,r,e,a,this.compareMinY);for(let n=r;n<=e;n+=a){const r=Math.min(n+a-1,e);s.children.push(this._build(t,n,r,i-1))}}return Hi(s,this.toBBox),s}_chooseSubtree(t,e,n,i){for(;i.push(e),!e.leaf&&i.length-1!==n;){let n,i=1/0,r=1/0;for(let s=0;s<e.children.length;s++){const o=e.children[s],a=Yi(o),l=Zi(t,o)-a;l<r?(r=l,i=a<i?a:i,n=o):l===r&&a<i&&(i=a,n=o)}e=n||e.children[0]}return e}_insert(t,e,n){const i=n?t:this.toBBox(t),r=[],s=this._chooseSubtree(i,this.data,e,r);for(s.children.push(t),Wi(s,i);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(i,r,e)}_split(t,e){const n=t[e],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);const s=this._chooseSplitIndex(n,r,i),o=Ki(n.children.splice(s,n.children.length-s));o.height=n.height,o.leaf=n.leaf,Hi(n,this.toBBox),Hi(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(n,o)}_splitRoot(t,e){this.data=Ki([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Hi(this.data,this.toBBox)}_chooseSplitIndex(t,e,n){let i,r=1/0,s=1/0;for(let o=e;o<=n-e;o++){const e=Gi(t,0,o,this.toBBox),a=Gi(t,o,n,this.toBBox),l=Ji(e,a),h=Yi(e)+Yi(a);l<r?(r=l,i=o,s=h<s?h:s):l===r&&h<s&&(s=h,i=o)}return i||n-e}_chooseSplitAxis(t,e,n){const i=t.leaf?this.compareMinX:ji,r=t.leaf?this.compareMinY:Xi;this._allDistMargin(t,e,n,i)<this._allDistMargin(t,e,n,r)&&t.children.sort(i)}_allDistMargin(t,e,n,i){t.children.sort(i);const r=this.toBBox,s=Gi(t,0,e,r),o=Gi(t,n-e,n,r);let a=qi(s)+qi(o);for(let i=e;i<n-e;i++){const e=t.children[i];Wi(s,t.leaf?r(e):e),a+=qi(s)}for(let i=n-e-1;i>=e;i--){const e=t.children[i];Wi(o,t.leaf?r(e):e),a+=qi(o)}return a}_adjustParentBBoxes(t,e,n){for(let i=n;i>=0;i--)Wi(e[i],t)}_condense(t){for(let e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children,e.splice(e.indexOf(t[n]),1)):this.clear():Hi(t[n],this.toBBox)}}function ki(t,e,n){if(!n)return e.indexOf(t);for(let i=0;i<e.length;i++)if(n(t,e[i]))return i;return-1}function Hi(t,e){Gi(t,0,t.children.length,e,t)}function Gi(t,e,n,i,r){r||(r=Ki(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let s=e;s<n;s++){const e=t.children[s];Wi(r,t.leaf?i(e):e)}return r}function Wi(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function ji(t,e){return t.minX-e.minX}function Xi(t,e){return t.minY-e.minY}function Yi(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function qi(t){return t.maxX-t.minX+(t.maxY-t.minY)}function Zi(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function Ji(t,e){const n=Math.max(t.minX,e.minX),i=Math.max(t.minY,e.minY),r=Math.min(t.maxX,e.maxX),s=Math.min(t.maxY,e.maxY);return Math.max(0,r-n)*Math.max(0,s-i)}function $i(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Qi(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Ki(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function tr(t,e,n,i,r){const s=[e,n];for(;s.length;){if((n=s.pop())-(e=s.pop())<=i)continue;const o=e+Math.ceil((n-e)/i/2)*i;Ui(t,o,e,n,r),s.push(e,o,o,n)}}class er{constructor(t=[],e=((t,e)=>t<e?-1:t>e?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,i=e[t];for(;t>0;){const r=t-1>>1,s=e[r];if(n(i,s)>=0)break;e[t]=s,t=r}e[t]=i}_down(t){const{data:e,compare:n}=this,i=this.length>>1,r=e[t];for(;t<i;){let i=1+(t<<1);const s=i+1;if(s<this.length&&n(e[s],e[i])<0&&(i=s),n(e[i],r)>=0)break;e[t]=e[i],t=i}e[t]=r}}var nr=function(t,e,n,i){var r=t[0],s=t[1],o=!1;void 0===n&&(n=0),void 0===i&&(i=e.length);for(var a=(i-n)/2,l=0,h=a-1;l<a;h=l++){var c=e[n+2*l+0],u=e[n+2*l+1],d=e[n+2*h+0],p=e[n+2*h+1];u>s!=p>s&&r<(d-c)*(s-u)/(p-u)+c&&(o=!o)}return o},ir=function(t,e,n,i){var r=t[0],s=t[1],o=!1;void 0===n&&(n=0),void 0===i&&(i=e.length);for(var a=i-n,l=0,h=a-1;l<a;h=l++){var c=e[l+n][0],u=e[l+n][1],d=e[h+n][0],p=e[h+n][1];u>s!=p>s&&r<(d-c)*(s-u)/(p-u)+c&&(o=!o)}return o},rr=function(t,e,n,i){return e.length>0&&Array.isArray(e[0])?ir(t,e,n,i):nr(t,e,n,i)},sr=nr;rr.nested=ir,rr.flat=sr;function or(t,e,n,i,r){let s,o,a,l,h=e[0],c=i[0],u=0,d=0;c>h==c>-h?(s=h,h=e[++u]):(s=c,c=i[++d]);let p=0;if(u<t&&d<n)for(c>h==c>-h?(o=h+s,a=s-(o-h),h=e[++u]):(o=c+s,a=s-(o-c),c=i[++d]),s=o,0!==a&&(r[p++]=a);u<t&&d<n;)c>h==c>-h?(o=s+h,l=o-s,a=s-(o-l)+(h-l),h=e[++u]):(o=s+c,l=o-s,a=s-(o-l)+(c-l),c=i[++d]),s=o,0!==a&&(r[p++]=a);for(;u<t;)o=s+h,l=o-s,a=s-(o-l)+(h-l),h=e[++u],s=o,0!==a&&(r[p++]=a);for(;d<n;)o=s+c,l=o-s,a=s-(o-l)+(c-l),c=i[++d],s=o,0!==a&&(r[p++]=a);return 0===s&&0!==p||(r[p++]=s),p}function ar(t){return new Float64Array(t)}const lr=ar(4),hr=ar(8),cr=ar(12),ur=ar(16),dr=ar(4);function pr(t,e,n,i,r,s){const o=(e-s)*(n-r),a=(t-r)*(i-s),l=o-a,h=Math.abs(o+a);return Math.abs(l)>=33306690738754716e-32*h?l:-function(t,e,n,i,r,s,o){let a,l,h,c,u,d,p,f,m,g,v,y,x,b,w,M,_,E;const S=t-r,T=n-r,A=e-s,P=i-s;b=S*P,d=134217729*S,p=d-(d-S),f=S-p,d=134217729*P,m=d-(d-P),g=P-m,w=f*g-(b-p*m-f*m-p*g),M=A*T,d=134217729*A,p=d-(d-A),f=A-p,d=134217729*T,m=d-(d-T),g=T-m,_=f*g-(M-p*m-f*m-p*g),v=w-_,u=w-v,lr[0]=w-(v+u)+(u-_),y=b+v,u=y-b,x=b-(y-u)+(v-u),v=x-M,u=x-v,lr[1]=x-(v+u)+(u-M),E=y+v,u=E-y,lr[2]=y-(E-u)+(v-u),lr[3]=E;let L=function(t,e){let n=e[0];for(let i=1;i<t;i++)n+=e[i];return n}(4,lr),R=22204460492503146e-32*o;if(L>=R||-L>=R)return L;if(u=t-S,a=t-(S+u)+(u-r),u=n-T,h=n-(T+u)+(u-r),u=e-A,l=e-(A+u)+(u-s),u=i-P,c=i-(P+u)+(u-s),0===a&&0===l&&0===h&&0===c)return L;if(R=11093356479670487e-47*o+33306690738754706e-32*Math.abs(L),L+=S*c+P*a-(A*h+T*l),L>=R||-L>=R)return L;b=a*P,d=134217729*a,p=d-(d-a),f=a-p,d=134217729*P,m=d-(d-P),g=P-m,w=f*g-(b-p*m-f*m-p*g),M=l*T,d=134217729*l,p=d-(d-l),f=l-p,d=134217729*T,m=d-(d-T),g=T-m,_=f*g-(M-p*m-f*m-p*g),v=w-_,u=w-v,dr[0]=w-(v+u)+(u-_),y=b+v,u=y-b,x=b-(y-u)+(v-u),v=x-M,u=x-v,dr[1]=x-(v+u)+(u-M),E=y+v,u=E-y,dr[2]=y-(E-u)+(v-u),dr[3]=E;const C=or(4,lr,4,dr,hr);b=S*c,d=134217729*S,p=d-(d-S),f=S-p,d=134217729*c,m=d-(d-c),g=c-m,w=f*g-(b-p*m-f*m-p*g),M=A*h,d=134217729*A,p=d-(d-A),f=A-p,d=134217729*h,m=d-(d-h),g=h-m,_=f*g-(M-p*m-f*m-p*g),v=w-_,u=w-v,dr[0]=w-(v+u)+(u-_),y=b+v,u=y-b,x=b-(y-u)+(v-u),v=x-M,u=x-v,dr[1]=x-(v+u)+(u-M),E=y+v,u=E-y,dr[2]=y-(E-u)+(v-u),dr[3]=E;const I=or(C,hr,4,dr,cr);b=a*c,d=134217729*a,p=d-(d-a),f=a-p,d=134217729*c,m=d-(d-c),g=c-m,w=f*g-(b-p*m-f*m-p*g),M=l*h,d=134217729*l,p=d-(d-l),f=l-p,d=134217729*h,m=d-(d-h),g=h-m,_=f*g-(M-p*m-f*m-p*g),v=w-_,u=w-v,dr[0]=w-(v+u)+(u-_),y=b+v,u=y-b,x=b-(y-u)+(v-u),v=x-M,u=x-v,dr[1]=x-(v+u)+(u-M),E=y+v,u=E-y,dr[2]=y-(E-u)+(v-u),dr[3]=E;const O=or(I,cr,4,dr,ur);return ur[O-1]}(t,e,n,i,r,s,h)}function fr(t,e,n){e=Math.max(0,void 0===e?2:e),n=n||0;const i=function(t){let e=t[0],n=t[0],i=t[0],r=t[0];for(let s=0;s<t.length;s++){const o=t[s];o[0]<e[0]&&(e=o),o[0]>i[0]&&(i=o),o[1]<n[1]&&(n=o),o[1]>r[1]&&(r=o)}const s=[e,n,i,r],o=s.slice();for(let e=0;e<t.length;e++)rr(t[e],s)||o.push(t[e]);return function(t){t.sort(Tr);const e=[];for(let n=0;n<t.length;n++){for(;e.length>=2&&br(e[e.length-2],e[e.length-1],t[n])<=0;)e.pop();e.push(t[n])}const n=[];for(let e=t.length-1;e>=0;e--){for(;n.length>=2&&br(n[n.length-2],n[n.length-1],t[e])<=0;)n.pop();n.push(t[e])}return n.pop(),e.pop(),e.concat(n)}(o)}(t),r=new Vi(16);r.toBBox=function(t){return{minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}},r.compareMinX=function(t,e){return t[0]-e[0]},r.compareMinY=function(t,e){return t[1]-e[1]},r.load(t);const s=[];let o;for(let t=0;t<i.length;t++){const e=i[t];r.remove(e),o=Mr(e,o),s.push(o)}const a=new Vi(16);for(let t=0;t<s.length;t++)a.insert(wr(s[t]));const l=e*e,h=n*n;for(;s.length;){const t=s.shift(),e=t.p,n=t.next.p,i=_r(e,n);if(i<h)continue;const o=i/l,c=mr(r,t.prev.p,e,n,t.next.next.p,o,a);c&&Math.min(_r(c,e),_r(c,n))<=o&&(s.push(t),s.push(Mr(c,t)),r.remove(c),a.remove(t),a.insert(wr(t)),a.insert(wr(t.next)))}let c=o;const u=[];do{u.push(c.p),c=c.next}while(c!==o);return u.push(c.p),u}function mr(t,e,n,i,r,s,o){const a=new er([],gr);let l=t.data;for(;l;){for(let t=0;t<l.children.length;t++){const e=l.children[t],r=l.leaf?Er(e,n,i):vr(n,i,e);r>s||a.push({node:e,dist:r})}for(;a.length&&!a.peek().node.children;){const t=a.pop(),s=t.node,l=Er(s,e,n),h=Er(s,i,r);if(t.dist<l&&t.dist<h&&xr(n,s,o)&&xr(i,s,o))return s}l=a.pop(),l&&(l=l.node)}return null}function gr(t,e){return t.dist-e.dist}function vr(t,e,n){if(yr(t,n)||yr(e,n))return 0;const i=Sr(t[0],t[1],e[0],e[1],n.minX,n.minY,n.maxX,n.minY);if(0===i)return 0;const r=Sr(t[0],t[1],e[0],e[1],n.minX,n.minY,n.minX,n.maxY);if(0===r)return 0;const s=Sr(t[0],t[1],e[0],e[1],n.maxX,n.minY,n.maxX,n.maxY);if(0===s)return 0;const o=Sr(t[0],t[1],e[0],e[1],n.minX,n.maxY,n.maxX,n.maxY);return 0===o?0:Math.min(i,r,s,o)}function yr(t,e){return t[0]>=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function xr(t,e,n){const i=Math.min(t[0],e[0]),r=Math.min(t[1],e[1]),s=Math.max(t[0],e[0]),o=Math.max(t[1],e[1]),a=n.search({minX:i,minY:r,maxX:s,maxY:o});for(let n=0;n<a.length;n++)if(l=a[n].p,h=a[n].next.p,c=t,l!==(u=e)&&h!==c&&br(l,h,c)>0!=br(l,h,u)>0&&br(c,u,l)>0!=br(c,u,h)>0)return!1;var l,h,c,u;return!0}function br(t,e,n){return pr(t[0],t[1],e[0],e[1],n[0],n[1])}function wr(t){const e=t.p,n=t.next.p;return t.minX=Math.min(e[0],n[0]),t.minY=Math.min(e[1],n[1]),t.maxX=Math.max(e[0],n[0]),t.maxY=Math.max(e[1],n[1]),t}function Mr(t,e){const n={p:t,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(n.next=e.next,n.prev=e,e.next.prev=n,e.next=n):(n.prev=n,n.next=n),n}function _r(t,e){const n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function Er(t,e,n){let i=e[0],r=e[1],s=n[0]-i,o=n[1]-r;if(0!==s||0!==o){const e=((t[0]-i)*s+(t[1]-r)*o)/(s*s+o*o);e>1?(i=n[0],r=n[1]):e>0&&(i+=s*e,r+=o*e)}return s=t[0]-i,o=t[1]-r,s*s+o*o}function Sr(t,e,n,i,r,s,o,a){const l=n-t,h=i-e,c=o-r,u=a-s,d=t-r,p=e-s,f=l*l+h*h,m=l*c+h*u,g=c*c+u*u,v=l*d+h*p,y=c*d+u*p,x=f*g-m*m;let b,w,M=x,_=x;0===x?(b=0,M=1,w=y,_=g):(b=m*y-g*v,w=f*y-m*v,b<0?(b=0,w=y,_=g):b>M&&(b=M,w=y+m,_=g)),w<0?(w=0,-v<0?b=0:-v>f?b=M:(b=-v,M=f)):w>_&&(w=_,-v+m<0?b=0:-v+m>f?b=M:(b=-v+m,M=f));const E=0===b?0:b/M,S=0===w?0:w/_,T=(1-S)*r+S*o-((1-E)*t+E*n),A=(1-S)*s+S*a-((1-E)*e+E*i);return T*T+A*A}function Tr(t,e){return t[0]===e[0]?t[1]-e[1]:t[0]-e[0]}function Ar(t,e,n){if(void 0===n&&(n={}),!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");var i=Di(t),r=Ni(e),s=r.type,o=e.bbox,a=r.coordinates;if(o&&!1===function(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1]}(i,o))return!1;"Polygon"===s&&(a=[a]);for(var l=!1,h=0;h<a.length&&!l;h++)if(Pr(i,a[h][0],n.ignoreBoundary)){for(var c=!1,u=1;u<a[h].length&&!c;)Pr(i,a[h][u],!n.ignoreBoundary)&&(c=!0),u++;c||(l=!0)}return l}function Pr(t,e,n){var i=!1;e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]&&(e=e.slice(0,e.length-1));for(var r=0,s=e.length-1;r<e.length;s=r++){var o=e[r][0],a=e[r][1],l=e[s][0],h=e[s][1];if(t[1]*(o-l)+a*(l-t[0])+h*(t[0]-o)==0&&(o-t[0])*(l-t[0])<=0&&(a-t[1])*(h-t[1])<=0)return!n;a>t[1]!=h>t[1]&&t[0]<(l-o)*(t[1]-a)/(h-a)+o&&(i=!i)}return i}function Lr(t){if(!t)throw new Error("geojson is required");var e=[];return Li(t,(function(t){!function(t,e){var n=[],i=t.geometry;if(null!==i){switch(i.type){case"Polygon":n=zi(i);break;case"LineString":n=[zi(i)]}n.forEach((function(n){(function(t,e){var n=[];return t.reduce((function(t,i){var r,s,o,a,l,h,c=fi([t,i],e);return c.bbox=(s=i,o=(r=t)[0],a=r[1],l=s[0],h=s[1],[o<l?o:l,a<h?a:h,o>l?o:l,a>h?a:h]),n.push(c),i})),n})(n,t.properties).forEach((function(t){t.id=e.length,e.push(t)}))}))}}(t,e)})),mi(e)}function Rr(t,e,n,i,r){!function t(e,n,i,r,s){for(;r>i;){if(r-i>600){var o=r-i+1,a=n-i+1,l=Math.log(o),h=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*h*(o-h)/o)*(a-o/2<0?-1:1),u=Math.max(i,Math.floor(n-a*h/o+c)),d=Math.min(r,Math.floor(n+(o-a)*h/o+c));t(e,n,u,d,s)}var p=e[n],f=i,m=r;for(Cr(e,i,n),s(e[r],p)>0&&Cr(e,i,r);f<m;){for(Cr(e,f,m),f++,m--;s(e[f],p)<0;)f++;for(;s(e[m],p)>0;)m--}0===s(e[i],p)?Cr(e,i,m):(m++,Cr(e,m,r)),m<=n&&(i=m+1),n<=m&&(r=m-1)}}(t,e,n||0,i||t.length-1,r||Ir)}function Cr(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function Ir(t,e){return t<e?-1:t>e?1:0}class Or{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const n=[];if(!jr(t,e))return n;const i=this.toBBox,r=[];for(;e;){for(let s=0;s<e.children.length;s++){const o=e.children[s],a=e.leaf?i(o):o;jr(t,a)&&(e.leaf?n.push(o):Wr(t,a)?this._all(o,n):r.push(o))}e=r.pop()}return n}collides(t){let e=this.data;if(!jr(t,e))return!1;const n=[];for(;e;){for(let i=0;i<e.children.length;i++){const r=e.children[i],s=e.leaf?this.toBBox(r):r;if(jr(t,s)){if(e.leaf||Wr(t,s))return!0;n.push(r)}}e=n.pop()}return!1}load(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(let e=0;e<t.length;e++)this.insert(t[e]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const t=this.data;this.data=e,e=t}this._insert(e,this.data.height-e.height-1,!0)}else this.data=e;return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Xr([]),this}remove(t,e){if(!t)return this;let n=this.data;const i=this.toBBox(t),r=[],s=[];let o,a,l;for(;n||r.length;){if(n||(n=r.pop(),a=r[r.length-1],o=s.pop(),l=!0),n.leaf){const i=Dr(t,n.children,e);if(-1!==i)return n.children.splice(i,1),r.push(n),this._condense(r),this}l||n.leaf||!Wr(n,i)?a?(o++,n=a.children[o],l=!1):n=null:(r.push(n),s.push(o),o=0,a=n,n=n.children[0])}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const n=[];for(;t;)t.leaf?e.push(...t.children):n.push(...t.children),t=n.pop();return e}_build(t,e,n,i){const r=n-e+1;let s,o=this._maxEntries;if(r<=o)return s=Xr(t.slice(e,n+1)),zr(s,this.toBBox),s;i||(i=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,i-1))),s=Xr([]),s.leaf=!1,s.height=i;const a=Math.ceil(r/o),l=a*Math.ceil(Math.sqrt(o));Yr(t,e,n,l,this.compareMinX);for(let r=e;r<=n;r+=l){const e=Math.min(r+l-1,n);Yr(t,r,e,a,this.compareMinY);for(let n=r;n<=e;n+=a){const r=Math.min(n+a-1,e);s.children.push(this._build(t,n,r,i-1))}}return zr(s,this.toBBox),s}_chooseSubtree(t,e,n,i){for(;i.push(e),!e.leaf&&i.length-1!==n;){let n,i=1/0,r=1/0;for(let s=0;s<e.children.length;s++){const o=e.children[s],a=Vr(o),l=Hr(t,o)-a;l<r?(r=l,i=a<i?a:i,n=o):l===r&&a<i&&(i=a,n=o)}e=n||e.children[0]}return e}_insert(t,e,n){const i=n?t:this.toBBox(t),r=[],s=this._chooseSubtree(i,this.data,e,r);for(s.children.push(t),Ur(s,i);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(i,r,e)}_split(t,e){const n=t[e],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);const s=this._chooseSplitIndex(n,r,i),o=Xr(n.children.splice(s,n.children.length-s));o.height=n.height,o.leaf=n.leaf,zr(n,this.toBBox),zr(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(n,o)}_splitRoot(t,e){this.data=Xr([t,e]),this.data.height=t.height+1,this.data.leaf=!1,zr(this.data,this.toBBox)}_chooseSplitIndex(t,e,n){let i,r=1/0,s=1/0;for(let o=e;o<=n-e;o++){const e=Nr(t,0,o,this.toBBox),a=Nr(t,o,n,this.toBBox),l=Gr(e,a),h=Vr(e)+Vr(a);l<r?(r=l,i=o,s=h<s?h:s):l===r&&h<s&&(s=h,i=o)}return i||n-e}_chooseSplitAxis(t,e,n){const i=t.leaf?this.compareMinX:Br,r=t.leaf?this.compareMinY:Fr;this._allDistMargin(t,e,n,i)<this._allDistMargin(t,e,n,r)&&t.children.sort(i)}_allDistMargin(t,e,n,i){t.children.sort(i);const r=this.toBBox,s=Nr(t,0,e,r),o=Nr(t,n-e,n,r);let a=kr(s)+kr(o);for(let i=e;i<n-e;i++){const e=t.children[i];Ur(s,t.leaf?r(e):e),a+=kr(s)}for(let i=n-e-1;i>=e;i--){const e=t.children[i];Ur(o,t.leaf?r(e):e),a+=kr(o)}return a}_adjustParentBBoxes(t,e,n){for(let i=n;i>=0;i--)Ur(e[i],t)}_condense(t){for(let e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children,e.splice(e.indexOf(t[n]),1)):this.clear():zr(t[n],this.toBBox)}}function Dr(t,e,n){if(!n)return e.indexOf(t);for(let i=0;i<e.length;i++)if(n(t,e[i]))return i;return-1}function zr(t,e){Nr(t,0,t.children.length,e,t)}function Nr(t,e,n,i,r){r||(r=Xr(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let s=e;s<n;s++){const e=t.children[s];Ur(r,t.leaf?i(e):e)}return r}function Ur(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function Br(t,e){return t.minX-e.minX}function Fr(t,e){return t.minY-e.minY}function Vr(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function kr(t){return t.maxX-t.minX+(t.maxY-t.minY)}function Hr(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function Gr(t,e){const n=Math.max(t.minX,e.minX),i=Math.max(t.minY,e.minY),r=Math.min(t.maxX,e.maxX),s=Math.min(t.maxY,e.maxY);return Math.max(0,r-n)*Math.max(0,s-i)}function Wr(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function jr(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Xr(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Yr(t,e,n,i,r){const s=[e,n];for(;s.length;){if((n=s.pop())-(e=s.pop())<=i)continue;const o=e+Math.ceil((n-e)/i/2)*i;Rr(t,o,e,n,r),s.push(e,o,o,n)}}var qr=function(t,e={}){if(null!=t.bbox&&!0!==e.recompute)return t.bbox;const n=[1/0,1/0,-1/0,-1/0];return function t(e,n,i){if(null!==e)for(var r,s,o,a,l,h,c,u,d=0,p=0,f=e.type,m="FeatureCollection"===f,g="Feature"===f,v=m?e.features.length:1,y=0;y<v;y++){l=(u=!!(c=m?e.features[y].geometry:g?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var x=0;x<l;x++){var b=0,w=0;if(null!==(a=u?c.geometries[x]:c)){h=a.coordinates;var M=a.type;switch(d=!i||"Polygon"!==M&&"MultiPolygon"!==M?0:1,M){case null:break;case"Point":if(!1===n(h,p,y,b,w))return!1;p++,b++;break;case"LineString":case"MultiPoint":for(r=0;r<h.length;r++){if(!1===n(h[r],p,y,b,w))return!1;p++,"MultiPoint"===M&&b++}"LineString"===M&&b++;break;case"Polygon":case"MultiLineString":for(r=0;r<h.length;r++){for(s=0;s<h[r].length-d;s++){if(!1===n(h[r][s],p,y,b,w))return!1;p++}"MultiLineString"===M&&b++,"Polygon"===M&&w++}"Polygon"===M&&b++;break;case"MultiPolygon":for(r=0;r<h.length;r++){for(w=0,s=0;s<h[r].length;s++){for(o=0;o<h[r][s].length-d;o++){if(!1===n(h[r][s][o],p,y,b,w))return!1;p++}w++}b++}break;case"GeometryCollection":for(r=0;r<a.geometries.length;r++)if(!1===t(a.geometries[r],n,i))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}(t,t=>{n[0]>t[0]&&(n[0]=t[0]),n[1]>t[1]&&(n[1]=t[1]),n[2]<t[0]&&(n[2]=t[0]),n[3]<t[1]&&(n[3]=t[1])}),n}.default,Zr=Ii.featureEach,Jr=(Ii.coordEach,Ei.polygon,Ei.featureCollection);function $r(t){var e=new Or(t);return e.insert=function(t){if("Feature"!==t.type)throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:qr(t),Or.prototype.insert.call(this,t)},e.load=function(t){var e=[];return Array.isArray(t)?t.forEach((function(t){if("Feature"!==t.type)throw new Error("invalid features");t.bbox=t.bbox?t.bbox:qr(t),e.push(t)})):Zr(t,(function(t){if("Feature"!==t.type)throw new Error("invalid features");t.bbox=t.bbox?t.bbox:qr(t),e.push(t)})),Or.prototype.load.call(this,e)},e.remove=function(t,e){if("Feature"!==t.type)throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:qr(t),Or.prototype.remove.call(this,t,e)},e.clear=function(){return Or.prototype.clear.call(this)},e.search=function(t){var e=Or.prototype.search.call(this,this.toBBox(t));return Jr(e)},e.collides=function(t){return Or.prototype.collides.call(this,this.toBBox(t))},e.all=function(){var t=Or.prototype.all.call(this);return Jr(t)},e.toJSON=function(){return Or.prototype.toJSON.call(this)},e.fromJSON=function(t){return Or.prototype.fromJSON.call(this,t)},e.toBBox=function(t){var e;if(t.bbox)e=t.bbox;else if(Array.isArray(t)&&4===t.length)e=t;else if(Array.isArray(t)&&6===t.length)e=[t[0],t[1],t[3],t[4]];else if("Feature"===t.type)e=qr(t);else{if("FeatureCollection"!==t.type)throw new Error("invalid geojson");e=qr(t)}return{minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]}},e}var Qr=$r,Kr=$r;function ts(t,e){var n=zi(t),i=zi(e);if(2!==n.length)throw new Error("<intersects> line1 must only contain 2 coordinates");if(2!==i.length)throw new Error("<intersects> line2 must only contain 2 coordinates");var r=n[0][0],s=n[0][1],o=n[1][0],a=n[1][1],l=i[0][0],h=i[0][1],c=i[1][0],u=i[1][1],d=(u-h)*(o-r)-(c-l)*(a-s),p=(c-l)*(s-h)-(u-h)*(r-l),f=(o-r)*(s-h)-(a-s)*(r-l);if(0===d)return null;var m=p/d,g=f/d;return m>=0&&m<=1&&g>=0&&g<=1?di([r+m*(o-r),s+m*(a-s)]):null}function es(t,e,n){void 0===n&&(n={});for(var i=Di(t),r=zi(e),s=0;s<r.length-1;s++){var o=!1;if(n.ignoreEndVertices&&(0===s&&(o="start"),s===r.length-2&&(o="end"),0===s&&s+1===r.length-1&&(o="both")),ns(r[s],r[s+1],i,o,void 0===n.epsilon?null:n.epsilon))return!0}return!1}function ns(t,e,n,i,r){var s=n[0],o=n[1],a=t[0],l=t[1],h=e[0],c=e[1],u=h-a,d=c-l,p=(n[0]-a)*d-(n[1]-l)*u;if(null!==r){if(Math.abs(p)>r)return!1}else if(0!==p)return!1;return i?"start"===i?Math.abs(u)>=Math.abs(d)?u>0?a<s&&s<=h:h<=s&&s<a:d>0?l<o&&o<=c:c<=o&&o<l:"end"===i?Math.abs(u)>=Math.abs(d)?u>0?a<=s&&s<h:h<s&&s<=a:d>0?l<=o&&o<c:c<o&&o<=l:"both"===i&&(Math.abs(u)>=Math.abs(d)?u>0?a<s&&s<h:h<s&&s<a:d>0?l<o&&o<c:c<o&&o<l):Math.abs(u)>=Math.abs(d)?u>0?a<=s&&s<=h:h<=s&&s<=a:d>0?l<=o&&o<=c:c<=o&&o<=l}function is(t,e){var n=Ni(t),i=Ni(e),r=n.type,s=i.type;switch(r){case"Point":switch(s){case"MultiPoint":return function(t,e){var n,i=!1;for(n=0;n<e.coordinates.length;n++)if(ss(e.coordinates[n],t.coordinates)){i=!0;break}return i}(n,i);case"LineString":return es(n,i,{ignoreEndVertices:!0});case"Polygon":case"MultiPolygon":return Ar(n,i,{ignoreBoundary:!0});default:throw new Error("feature2 "+s+" geometry not supported")}case"MultiPoint":switch(s){case"MultiPoint":return function(t,e){for(var n=0;n<t.coordinates.length;n++){for(var i=!1,r=0;r<e.coordinates.length;r++)ss(t.coordinates[n],e.coordinates[r])&&(i=!0);if(!i)return!1}return!0}(n,i);case"LineString":return function(t,e){for(var n=!1,i=0;i<t.coordinates.length;i++){if(!es(t.coordinates[i],e))return!1;n||(n=es(t.coordinates[i],e,{ignoreEndVertices:!0}))}return n}(n,i);case"Polygon":case"MultiPolygon":return function(t,e){for(var n=!0,i=!1,r=0;r<t.coordinates.length;r++){if(!(i=Ar(t.coordinates[1],e))){n=!1;break}i=Ar(t.coordinates[1],e,{ignoreBoundary:!0})}return n&&i}(n,i);default:throw new Error("feature2 "+s+" geometry not supported")}case"LineString":switch(s){case"LineString":return function(t,e){for(var n=0;n<t.coordinates.length;n++)if(!es(t.coordinates[n],e))return!1;return!0}(n,i);case"Polygon":case"MultiPolygon":return function(t,e){var n=Oi(e),i=Oi(t);if(!rs(n,i))return!1;for(var r=!1,s=0;s<t.coordinates.length-1;s++){if(!Ar(t.coordinates[s],e))return!1;if(r||(r=Ar(t.coordinates[s],e,{ignoreBoundary:!0})),!r){var o=(a=t.coordinates[s],l=t.coordinates[s+1],[(a[0]+l[0])/2,(a[1]+l[1])/2]);r=Ar(o,e,{ignoreBoundary:!0})}}var a,l;return r}(n,i);default:throw new Error("feature2 "+s+" geometry not supported")}case"Polygon":switch(s){case"Polygon":case"MultiPolygon":return function(t,e){var n=Oi(t);if(!rs(Oi(e),n))return!1;for(var i=0;i<t.coordinates[0].length;i++)if(!Ar(t.coordinates[0][i],e))return!1;return!0}(n,i);default:throw new Error("feature2 "+s+" geometry not supported")}default:throw new Error("feature1 "+r+" geometry not supported")}}function rs(t,e){return!(t[0]>e[0])&&(!(t[2]<e[2])&&(!(t[1]>e[1])&&!(t[3]<e[3])))}function ss(t,e){return t[0]===e[0]&&t[1]===e[1]}Qr.default=Kr;class os{static getLineCross(t,e,n,i){const r=Math.min(n.x,i.x)>Math.max(t.x,e.x),s=Math.min(n.y,i.y)>Math.max(t.y,e.y),o=Math.min(t.x,e.x)>Math.max(n.x,i.x),a=Math.min(t.y,e.y)>Math.max(n.y,i.y);if(r||s||o||a)return!1;const l=(t,e)=>t.x*e.y-t.y*e.x;return((t,e,n,i)=>{let r={x:t.x-n.x,y:n.y-t.y},s={x:e.x-n.x,y:e.y-n.y},o={x:i.x-n.x,y:i.y-n.y};const a=l(r,o)*l(s,o);return r={x:n.x-t.x,y:n.y-t.y},s={x:i.x-t.x,y:i.y-t.y},o={x:e.x-t.x,y:e.y-t.y},!!(a<=0&&l(r,o)*l(s,o)<=0)})(t,e,n,i)}static calcTurning(t,e=[2,20]){const n=t.length;if(n<2)return[];const i=[],r=(t,e)=>{const{x:n,y:i}=t,{x:r,y:s}=e,o=n*r+i*s,a=n*s-i*r,l=Math.atan2(a,o)/Math.PI*180;return Math.round(l+360)%360};let s=!1,o=0,a=[0,0],l=[0,0],h=[0,0],c=0,u=0;for(let d=1;d<n-1;d++){const n=t[d-1],p=t[d],f=t[d+1],m=r({x:f[0]-p[0],y:f[1]-p[1]},{x:p[0]-n[0],y:p[1]-n[1]}),g=m>=e[0]&&m<=e[1]||m>=360-e[1]&&m<=360-e[0];!s&&g?(s=!0,l=p,o+=m,c=d):s&&g?o+=m:s&&!g?(o+=m,u=d,h=p,a=[(l[0]+h[0])/2,(l[1]+h[1])/2],i.push({point:a,angle:o%360,startTPoint:l,endTPoint:h,startIndex:c,endIndex:u}),s=!1):s||g||(c=u=0,o=0,a=[0,0],l=[0,0],h=[0,0])}return s&&(h=t[n-1],a=[(l[0]+h[0])/2,(l[1]+h[1])/2],i.push({point:a,angle:o%360,startTPoint:l,endTPoint:h,startIndex:c,endIndex:u}),s=!1),i}static chunk(t,e){if(t.length<=0||e<=0)return t;const n=[];for(let i=0;i<t.length;i+=e)n.push(t.slice(i,i+e));return n}}let as={};function ls(){return as.textPixel||512}function hs(){return as.imgTextPixel||2048}const cs=ls(),us=hs();function ds(t,e,n){return`${t}-${e}-${n}`}const ps=[{normal:new e.Vector3(0,0,1),trans:new e.Vector3(0,0,.5),euler:new e.Euler(0,Math.PI/2,-Math.PI/2),face:0,flipX:!1,flipY:!1,revers:!1},{normal:new e.Vector3(0,0,1),trans:new e.Vector3(0,0,.5),euler:new e.Euler(0,-Math.PI/2,-Math.PI/2),face:1,flipX:!0,flipY:!0,revers:!1},{normal:new e.Vector3(0,0,1),trans:new e.Vector3(0,0,.5),face:2,flipX:!1,flipY:!1,revers:!1},{normal:new e.Vector3(0,0,1),trans:new e.Vector3(0,0,-.5),face:3,flipX:!1,flipY:!0,revers:!0},{normal:new e.Vector3(0,0,1),trans:new e.Vector3(0,0,-.5),euler:new e.Euler(Math.PI/2,0,0),face:4,flipX:!1,flipY:!0,revers:!0},{normal:new e.Vector3(0,0,1),trans:new e.Vector3(0,0,-.5),euler:new e.Euler(-Math.PI/2,0,0),face:5,flipX:!0,flipY:!1,revers:!0}];function fs(t,e,n,i,r){const{THREE:s}=x.getInstance(),o=[],a=new s.Vector3(-.5,-.5,0),l=2**t,h=1/l;let c=e%l,u=Math.floor(e/l);n||(c=l-1-c,u=l-1-u),i&&(u=l-1-u),r&&(c=l-1-c);const d=a.x+c*h,p=a.y+u*h,f=d,m=p+h,g=d+h,v=p+h,y=d+h,b=p;return o.push(new s.Vector3(d,p,0)),o.push(new s.Vector3(f,m,0)),o.push(new s.Vector3(g,v,0)),o.push(new s.Vector3(y,b,0)),o}class ms{static getXY(t,e){return{x:t%e,y:Math.floor(t/e)}}static getSegment(t){return 2**t}static getCount(t){const e=ms.getSegment(t);return e*e}static getImageInfo2(t,e,n,i){const r=ms.getSegment(n),s=hs()/r;let{x:o,y:a}=ms.getXY(e,r);o=r-1-o,a=r-1-a;return{id:`${t}-${n}-${o}-${a}`,url:`${i}?x-bce-process=image${`/crop,x_${s*o},y_${s*a},w_${s},h_${s}`}${`/resize,m_lfit,w_${ls()},h_${ls()}`}`}}static getImageInfo(t){const{pfid:e,index:n,level:i,rootUrl:r,offLineLevel:s,offLineRootUrl:o}=t,a=ms.getSegment(i),l=hs()/a;let{x:h,y:c}=ms.getXY(n,a);h=a-1-h,c=a-1-c;let u="";if(i<=s)u=`${o}_${i}_${n}.jpg`;else{const t=`/crop,x_${l*h},y_${l*c},w_${l},h_${l}`,e=`/resize,m_lfit,w_${ls()},h_${ls()}`;u=`${r}?x-bce-process=image${ms.resizeFirst?`/resize,m_lfit,w_${hs()},h_${hs()}`:""}${t}${e}`}return{id:`${e}-${i}-${h}-${c}`,url:u}}static antiShake(t,e){let n;return(...i)=>{n&&clearTimeout(n),n=setTimeout(()=>{t(...i),n=null},e)}}static throttle(t,e){let n;return(...i)=>{n||(n=setTimeout(()=>{t(...i),n=null},e))}}}ms.updateTextureMax=1,ms.levelMin=0,ms.levelMax=2,ms.resizeFirst=!1,ms.getTileInfoId=ds,ms.getVertices=fs;class gs extends ye{constructor(t,e={width:.3}){super(),this.initialized=!1,this.ready=!0,this.points=[],this.distances=[],this.currentMoveIndex=0,this.options={textureMode:"repeat",...e},e.animateSpeed||(this.options.animateSpeed=.01),"tail"===e.textureMode&&this.createTailArrow(),this.renderPixelLine=e.renderPixelLine||!1,this.init(t)}calcPoints(t,e=.3){const{THREE:n}=x.getInstance(),i=t.length;if(i<2)return[];const r=[],s=t.map(t=>[t[0],t[1]]);for(let t=0;t<i;t++){const o=new n.Vector2(...s[t]),a=0===t?null:new n.Vector2(...s[t-1]),l=t===i-1?null:new n.Vector2(...s[t+1]),h=a?(new n.Vector2).subVectors(o,a).normalize():null,c=l?(new n.Vector2).subVectors(l,o).normalize():null,u=c&&h?(new n.Vector2).addVectors(c,h).normalize():null,d=0===t?new n.Vector2(-c.y,c.x):t===i-1?new n.Vector2(-h.y,h.x):new n.Vector2(-u.y,u.x),p=(new n.Vector2).addVectors(o,d.clone().multiplyScalar(-e)),f=(new n.Vector2).addVectors(o,d.clone().multiplyScalar(e));r.push([p.x,p.y,0],[f.x,f.y,0],[d.x,d.y,0])}return r}createTailArrow(){const{THREE:t}=x.getInstance(),n=this.options.textureUrl;(new e.TextureLoader).load(n,e=>{const n=this.options.width||.3,i=this.options.strokeWidth?n+2*this.options.strokeWidth:this.options.width,r=this.options.textureSize?this.options.textureSize[0]:i,s=this.options.textureSize?this.options.textureSize[1]:r,o=new t.PlaneGeometry(r,s),a=this.options.color?this.options.color:16777215,l=new t.MeshBasicMaterial({color:a,map:e,transparent:!0,opacity:1,depthTest:!1});l.needsUpdate=!0;const h=new t.Mesh(o,l);h.renderOrder=2,this.tailArrow=h,this.tailArrow.visible=!1,this.add(this.tailArrow)})}orgPoints(t,e=.3){const n=e>1?.01:e,{THREE:i}=x.getInstance(),r=t.length,s=this.calcPoints(t,n).map(t=>new i.Vector3(...t)),o=os.chunk(s,3),a=t.map((t,e)=>({point:t,normal:[o[e][2].x,o[e][2].y],scale:1})),l=t.map(t=>[t[0],t[1]]),h=os.calcTurning(l);if(!h.length)return a;const c=h.map(e=>{const{startIndex:s,endIndex:a,angle:l}=e,h=l>180?1:0,c=o[s-1][h],u=o[s-1][h],d=(new i.Vector3).subVectors(u,c).normalize().multiplyScalar(n),p=(new i.Vector3).addVectors(u,d),f=(new i.Vector3).subVectors(c,d),m=o[a+1][h],g=r>a+2?o[a+2][h]:o[a][h],v=(new i.Vector3).subVectors(g,m).normalize().multiplyScalar(n),y=(new i.Vector3).addVectors(g,v),x=(new i.Vector3).subVectors(m,v),b=function(t,e){var n={},i=[];if("LineString"===t.type&&(t=ui(t)),"LineString"===e.type&&(e=ui(e)),"Feature"===t.type&&"Feature"===e.type&&null!==t.geometry&&null!==e.geometry&&"LineString"===t.geometry.type&&"LineString"===e.geometry.type&&2===t.geometry.coordinates.length&&2===e.geometry.coordinates.length){var r=ts(t,e);return r&&i.push(r),mi(i)}var s=Qr();return s.load(Lr(e)),Ai(Lr(t),(function(t){Ai(s.search(t),(function(e){var r=ts(t,e);if(r){var s=zi(r).join(",");n[s]||(n[s]=!0,i.push(r))}}))})),mi(i)}(fi([[f.x,f.y],[c.x,c.y],[u.x,u.y],[p.x,p.y]]),fi([[x.x,x.y],[m.x,m.y],[g.x,g.y],[y.x,y.y]]));if(!b.features[0])return null;const w=b.features[0].geometry.coordinates,M=new i.Vector2(t[a][0]-t[s-1][0],t[a][1]-t[s-1][1]).normalize().multiplyScalar(n),_=[w[0]-M.x,w[1]-M.y],E=[w[0]+M.x,w[1]+M.y],S=l>180?M.normalize().multiplyScalar(-1):M.normalize().multiplyScalar(1),T=[w[0]-S.y*n,w[1]+S.x*n],A=[w[0]+S.y*n,w[1]-S.x*n];return{hull:function(t,e){void 0===e&&(e={}),e.concavity=e.concavity||1/0;var n=[];if(Si(t,(function(t){n.push([t[0],t[1]])})),!n.length)return null;var i=fr(n,e.concavity);return i.length>3?pi([i]):null}(mi([di(_),di(A),di(E),di(T),di(_)])),intersectCrd:w,startIndex:s,endIndex:a}});let u=0,d=0,p=!1;for(;d<r&&c[u];){const[t,e]=o[d],n=c[u].hull,r=c[u].intersectCrd,s=c[u+1]?c[u+1].intersectCrd:null,l=c[u+1]?c[u+1].hull:null,h=is(di([t.x,t.y]),n),f=is(di([e.x,e.y]),n),m=h||f;if(m&&h){p=!0;const n=new i.Vector3(...r,0);let o=e;s&&l&&is(di([e.x,e.y]),l)&&(o=new i.Vector3(s[0],s[1],s[2]));const h=(new i.Vector3).subVectors(e,t).length(),c=(new i.Vector3).subVectors(o,new i.Vector3(n.x,n.y,0)).length(),u=(new i.Vector3).subVectors(o,new i.Vector3(n.x,n.y,0)).normalize();a.splice(d,1,{point:[(n.x+o.x)/2,(n.y+o.y)/2,0],scale:c/h,normal:[u.x,u.y]})}else if(m&&f){p=!0;const n=new i.Vector3(...r,0);let o=t;s&&l&&is(di([t.x,t.y]),l)&&(o=new i.Vector3(s[0],s[1],s[2]));const h=(new i.Vector3).subVectors(e,t).length(),c=(new i.Vector3).subVectors(o,new i.Vector3(n.x,n.y,0)).length(),u=(new i.Vector3).subVectors(new i.Vector3(n.x,n.y,0),o).normalize();a.splice(d,1,{point:[(n.x+o.x)/2,(n.y+o.y)/2,0],scale:c/h,normal:[u.x,u.y]})}else p&&(d--,p=!1,u++);d++}return a}init(t){const{THREE:e}=x.getInstance(),n=t,i=(this.options.strokeWidth||0)+(this.options.width?this.options.width:.3)/2,r=this.orgPoints(n,i);this.orgedPoints=r,this.points=[];if(n.length>1){const[t,i,r,s]=[n[0],n[1],n[n.length-2],n[n.length-1]],o=new e.Vector3(...t),a=new e.Vector3(...i),l=(new e.Vector3).subVectors(o,a).normalize().multiplyScalar(.05*o.distanceTo(a)),h=o.clone().add(l),c=new e.Vector3(...r),u=new e.Vector3(...s),d=(new e.Vector3).subVectors(c,u).normalize().multiplyScalar(.05*o.distanceTo(a)),p=u.clone().sub(d),f=this.orgedPoints[0],m=this.orgedPoints[this.orgedPoints.length-1];this.orgedPoints.unshift({point:[h.x,h.y,h.z],normal:f.normal,scale:1}),this.orgedPoints.push({point:[p.x,p.y,p.z],normal:m.normal,scale:1}),this.points.push([h.x,h.y,h.z]),this.points.push(...n),this.points.push([p.x,p.y,p.z])}this.distances=[-.1];for(let t=1,n=this.points.length,i=new e.Vector3(...this.points[0]),r=new e.Vector3;t<n;t+=1)r.set(...this.points[t]),this.distances.push(1===t?0:this.distances[t-1]+r.distanceTo(i)),i.copy(r);this.bufferGeometry=new e.BufferGeometry;let[s,o,a]=this.points[0],l=0;const h=[];for(let t=0;t<this.orgedPoints.length;t+=1){const[e,n,i]=this.orgedPoints[t].point,[r,c]=this.orgedPoints[t].normal,u=this.orgedPoints[t].scale;let d=e-s,p=n-o,f=i-a;const m=Math.sqrt(d*d+p*p+f*f);d/=m,p/=m,f/=m,l+=3*m,this.options.strokeWidth?(h.push(e,n,i,-2,l,this.distances[t],r,c,u),h.push(e,n,i,-1,l,this.distances[t],r,c,u),h.push(e,n,i,1,l,this.distances[t],r,c,u),h.push(e,n,i,2,l,this.distances[t],r,c,u)):(h.push(e,n,i,-1,l,this.distances[t],r,c,u),h.push(e,n,i,1,l,this.distances[t],r,c,u)),s=e,o=n,a=i}const c=new Float32Array(h),u=this.options.strokeWidth?4:2,d=new e.InterleavedBuffer(c,9),p=new e.InterleavedBufferAttribute(d,4,0,!1);this.bufferGeometry.setAttribute("last",p);const f=new e.InterleavedBufferAttribute(d,4,9*u,!1);this.bufferGeometry.setAttribute("current",f);const m=new e.InterleavedBufferAttribute(d,4,9*u*2,!1);this.bufferGeometry.setAttribute("next",m);const g=new e.InterleavedBufferAttribute(d,1,9*u+4,!1);this.bufferGeometry.setAttribute("texoff",g);const v=new e.InterleavedBufferAttribute(d,1,9*u+5,!1);this.bufferGeometry.setAttribute("progress",v);const y=new e.InterleavedBufferAttribute(d,2,9*u+6,!1);this.bufferGeometry.setAttribute("normalVec",y);const b=new e.InterleavedBufferAttribute(d,1,9*u+8,!1);this.bufferGeometry.setAttribute("normalScale",b);const w=new e.InterleavedBuffer(c.slice(9*u,h.length-9*u),9),M=new e.InterleavedBufferAttribute(w,4,0);this.bufferGeometry.setAttribute("position",M),this.bufferGeometry.computeBoundingBox(),this.bufferGeometry.computeBoundingSphere(),this.bufferGeometry.computeVertexNormals();let _=[];if(this.options.strokeWidth){const t=[0,1,4,1,4,5,1,2,5,2,5,6,2,3,6,3,6,7];for(let e=4;e<h.length/9-8;e+=4){const n=e/4-1,i=t.map(t=>t+4*n);_=[..._,...i]}}else for(let t=2;t<h.length/9-4;t+=2)_.push(t-2,t-1,t),_.push(t,t-1,t+1);this.bufferGeometry.setIndex(_);const E=new e.Vector2(1,1),S=this.options.color?new ai(this.options.color):new ai("rgb(255, 255, 255)").alpha(0),T=this.options.strokeColor?new ai(this.options.strokeColor):new ai("rgb(255, 255, 255)").alpha(0);if(this.uniforms={stripTexture:{type:"t",value:null},fillColor:{type:"v4",value:new e.Vector4(S.red()/255,S.green()/255,S.blue()/255,S.alpha())},strokeColor:{type:"v4",value:new e.Vector4(T.red()/255,T.green()/255,T.blue()/255,T.alpha())},width:{type:"f",value:this.options.width||.3},strokeWidth:{type:"f",value:this.options.strokeWidth||.1},renderPixelLine:{type:"f",value:this.renderPixelLine?1:0},fillOpacity:{type:"f",value:this.options.fillOpacity||.8},resolution:{type:"v2",value:E},currentDistance:{type:"f",value:this.options.current||0},texOffset:{type:"f",value:0},fullLength:{type:"f",value:this.distances[this.distances.length-1]},viewDistance:{type:"f",value:null===this.options.viewDistance||void 0===this.options.viewDistance?15:this.options.viewDistance},gradientDistance:{type:"f",value:this.options.gradientDistance||4},gradientEnabled:{value:this.options.gradientEnabled||!1}},this.material=new e.ShaderMaterial({fragmentShader:gs.FragmentShader,vertexShader:gs.VertexShader,uniforms:this.uniforms,depthTest:!1,side:e.DoubleSide,wireframe:!1,transparent:!0,opacity:1,blending:e.NormalBlending,blendEquation:e.AddEquation,blendSrc:e.SrcAlphaFactor,blendDst:e.OneMinusSrcAlphaFactor}),this.options.textureUrl&&"repeat"===this.options.textureMode)(new e.TextureLoader).load(this.options.textureUrl,t=>{t.wrapS=e.RepeatWrapping,t.wrapT=e.RepeatWrapping,t.generateMipmaps=!0,this.uniforms.stripTexture.value=t,this.needsUpdate=!0});else if(this.options.textureUrl&&"tail"===this.options.textureMode){const t=this.distances[this.distances.length-1];this.updateTailArrowPos(t)}this.mesh=new e.Mesh(this.bufferGeometry,this.material),this.mesh.renderOrder=1e3,this.add(this.mesh)}setContainer(e){S.GetEnv()!==t.Env.Miniapp&&this.resize(e.clientWidth,e.clientHeight)}resize(t,n){if(this.viewWidth===t&&this.viewHeight===n)return;const i=new e.Vector2(t,n);this.uniforms.resolution.value=i,this.needsUpdate=!0,this.viewWidth=t,this.viewHeight=n}getBestView(t,e,n){let i=this.getPointOnDistance(e+.2).point,r=t;const{THREE:s}=x.getInstance();let o=e+1;for(;o<e+10;o+=1){const t=this.getPointOnDistance(o),e=(new s.Vector3).subVectors(t.point,i),n=(new s.Vector3).subVectors(i,r);if(s.MathUtils.radToDeg(e.angleTo(n))>30){i=this.getPointOnDistance(o+.5).point,r=t.point;break}}let a=0;for(let t=o;t<n;t++){const n=this.getPointOnDistance(t),o=(new s.Vector3).subVectors(n.point,i),l=(new s.Vector3).subVectors(i,r),h=s.MathUtils.radToDeg(o.angleTo(l));if(h>32&&t-e>10){a=t;break}if(h>20&&t-e>15){a=t;break}}return a-e}getPointOnDistance(t){const{THREE:e}=x.getInstance();let n=0;const{distances:i,points:r}=this;let s=r.length-1,o=-1;for(;n<s-1;)if(o=Math.floor((n+s)/2),i[o]>t)s=o;else{if(!(i[o]<t)){n=o;break}n=o}if(o=n,o>-1){const n=new e.Vector3(...this.points[o]);if(o===this.points.length-1||t<=0)return{point:n,index:o+1};const i=this.distances[o],r=new e.Vector3(...this.points[o+1]),s=this.distances[o+1]-i,a=r.clone().sub(n);return{point:n.clone().add(a.multiplyScalar((t-i)/s)),index:o+1}}throw new Error("Cannot find point on distance "+t)}getNearestPoint(t,e=0){const{THREE:n}=x.getInstance(),i=this.distances[this.distances.length-1];let r,s,o,a,l,h,c=8,u=new n.Vector3,d=0,p=1/0,f=-1;for(let n,r,s=e;s<=i;s+=c)n=this.getPointOnDistance(s),r=t.distanceTo(n.point),r<p&&(u=n.point,d=s,p=r,f=n.index);for(c/=2;c>.1;)o=d-c,l=t.distanceTo(r=this.getPointOnDistance(o).point),a=d+c,h=t.distanceTo(s=this.getPointOnDistance(a).point),o>=0&&l<p?(u=r,d=o,p=l):a<=i&&h<p?(u=s,d=a,p=h):c/=2;return{point:u,distance:d,index:f}}getPathWithScope(t,e){if(t>=e){const t=this.getPointOnDistance(e).point;return[[t.x,t.y,0]]}let n=this.distances.length-1,i=0;for(;n>=0&&this.distances[n]>t;)n-=1;for(;i<this.distances.length&&this.distances[i]<e;)i+=1;const r=this.getPointOnDistance(t).point,s=this.getPointOnDistance(e).point;return[[r.x,r.y,0],...this.points.slice(n+1,i-n-1),[s.x,s.y,0]]}getPathBaseStartPoint(t){const e=this.getPointOnDistance(t).point;for(let n=0;n<this.distances.length;n+=1)if(this.distances[n]>t)return[[e.x,e.y,0],...this.points.slice(n)];return this.points.slice(this.distances.length-1)}update(){const t=new ve(this);return!this.initialized&&this.ready?(this.initialized=!0,t.needUpdate=!0):this.needsUpdate&&(t.needUpdate=!0,this.needsUpdate=!1),this.options.animateEnabled&&(this.uniforms.texOffset.value-=this.options.animateSpeed,t.needUpdate=!0),this.initialized&&!this.parent&&(t.shouldPlaceElement=!0),t}dispose(){this.parentOverlay&&this.parentOverlay.removePath(this),super.dispose(),this.remove(this.mesh),this.material.dispose(),this.bufferGeometry.dispose()}setCurrent(t){this.uniforms.currentDistance.value=t,this.needsUpdate=!0}getLength(){return this.distances[this.distances.length-1]}setCurrentIndex(t){this.currentMoveIndex=t;const e=this.distances[t+1];this.uniforms.currentDistance.value=e,this.needsUpdate=!0}getCurrent(){return this.uniforms.currentDistance.value}getCurrentIndex(){return this.currentMoveIndex}setViewDistance(t){this.uniforms.viewDistance.value=t;const e=t+this.uniforms.currentDistance.value;if(this.options.textureUrl&&"tail"===this.options.textureMode){if(!this.tailArrow)return void setTimeout(()=>{this.setViewDistance(t)},1e3);this.updateTailArrowPos(e)}}updateTailArrowPos(t){if(!this.tailArrow)return void setTimeout(()=>{this.updateTailArrowPos(t)},1e3);this.tailArrow.visible=!0;const{index:e}=this.getPointOnDistance(t),n=this.orgedPoints[e],i=n.point[0],r=n.point[1],s=n.point[2],o=[-n.normal[1],n.normal[0]],a=Math.atan2(o[1],o[0])+Math.PI/2;this.tailArrow.position.set(i,r,s),this.tailArrow.rotation.z=a,this.needsUpdate=!0}setWidth(t){this.uniforms.width.value!==t&&(this.uniforms.width.value=t,this.needsUpdate=!0)}setColor(t){if(null==t)return;const e=new ai(t),n=this.uniforms.fillColor.value,{THREE:i}=x.getInstance(),r=new i.Vector4(e.red(),e.green(),e.blue(),e.alpha());r.equals(n)||(this.uniforms.fillColor.value=r,this.needsUpdate=!0)}getViewDistance(){return this.uniforms.viewDistance.value}setParentOverlay(t){this.parentOverlay=t}}gs.VertexShader="\n attribute vec4 last, current, next;\n attribute vec2 normalVec;\n attribute float normalScale;\n attribute float texoff;\n attribute float progress;\n\n varying vec2 texcoord;\n varying float vProgress;\n varying float isBorder;\n\n uniform float width;\n uniform float texOffset;\n uniform float strokeWidth;\n uniform float renderPixelLine;\n uniform vec2 resolution;\n\n float pi = 3.141592653589793;\n float fwidth = width;\n float swidth = strokeWidth;\n\n vec4 transform(vec3 coord){\n return projectionMatrix * modelViewMatrix * vec4(coord, 1.0);\n }\n\n vec2 project(vec4 device) {\n vec3 device_normal = device.xyz / device.w;\n vec2 clip_pos = (device_normal * 0.5 + 0.5).xy;\n return clip_pos * resolution;\n }\n\n vec4 unproject(vec2 screen, float z, float w) {\n vec2 clip_pos = screen / resolution;\n vec2 device_normal = clip_pos * 2.0 - 1.0;\n return vec4(device_normal * w, z, w);\n }\n\n // 计算系数: 0,0,0 到 0,1,0 对应的屏幕坐标距离 越大, coefficient越大\n float calcCoefficient() {\n vec3 p1 = vec3(0, 0, 0);\n vec2 sp1 = project(transform(p1.xyz));\n vec3 p2 = vec3(0, 1, 0);\n vec2 sp2 = project(transform(p2.xyz));\n // 计算屏幕坐标的距离\n float dist = distance(sp1, sp2);\n return dist * 10.0 / width;\n }\n\n void main(){\n vec2 sLast; // screenLast\n vec2 sNext; // screenNext\n vec2 sCurrent; // screenCurrent\n vec2 normal1; // normal1\n vec2 normal2; // normal2\n vec2 normal; // 当前normal\n vec4 dCurrent; //\n\n float coefficient = 10.0;\n float off = 1.0;\n if (current.w < 0.0 ) {\n off = -1.0;\n }\n vec4 position = vec4(0, 0, 0, 0);\n vec3 pos;\n\n float offsetW = fwidth / 2.0 * normalScale;\n isBorder = -1.0;\n if (abs(current.w) > 1.0) {\n offsetW = swidth + (fwidth / 2.0) * normalScale;\n isBorder = 1.0;\n }\n if (renderPixelLine < 1.0) {\n // 3d 中\n vec2 dir = vec2(normalVec.x, normalVec.y)*off;\n float factor = 0.6 / fwidth * 0.2;\n pos = vec3(current.xy + dir * offsetW, 0.0);\n texcoord = vec2(off*0.5+0.5, texoff * factor + texOffset);\n vProgress = progress;\n gl_Position = transform(pos);\n } else {\n // vec2 dir = vec2(normalVec.x, normalVec.y)*off;\n // pos = vec3(current.xy + dir * offsetW, 0.0);\n // texcoord = vec2(off*0.5+0.5, texoff*0.2 + texOffset);\n // vProgress = progress;\n // gl_Position = transform(pos);\n\n coefficient = calcCoefficient();\n sLast = project(transform(last.xyz)); // last的屏幕坐标\n sNext = project(transform(next.xyz)); // next的屏幕坐标\n\n dCurrent = transform(current.xyz);\n sCurrent = project(dCurrent); // current的屏幕坐标\n\n normal1 = normalize(sLast - sCurrent);\n vec2 normal2 = normalize(sCurrent - sNext);\n normal = normalize(normal1 + normal2);\n texcoord = vec2(off*0.5+0.5, texoff* 0.03 * coefficient + texOffset);\n vProgress = progress;\n\n vec2 dir = vec2(-normal.y, normal.x) * off;\n float cosAngle = abs(dot(dir, -normal1)); // cos 45 基本 为 0.79 得到的是弧度值\n float x = 90.0 - acos(cosAngle) * 180.0 / pi; // 得到角度 90 - x 则为需要 20 / length = cos(x)\n float divideBy = cos(x / 180.0 * pi);\n if (abs(divideBy) < 0.6) {\n float positiveNum = divideBy > 0.0 ? 1.0 : -1.0;\n divideBy = 0.6 * positiveNum;\n }\n pos = vec3((sCurrent + offsetW / divideBy * dir).xy, 0.0);\n position = unproject(pos.xy, 0.0, 1.0);\n gl_Position = position;\n }\n\n // texcoord = vec2(off*0.5+0.5, texoff* 0.03 * coefficient + texOffset);\n // vProgress = progress;\n\n // vec2 dir = vec2(-normal.y, normal.x) * off;\n // float cosAngle = abs(dot(dir, -normal1)); // cos 45 基本 为 0.79 得到的是弧度值\n // float x = 90.0 - acos(cosAngle) * 180.0 / pi; // 得到角度 90 - x 则为需要 20 / length = cos(x)\n // float divideBy = cos(x / 180.0 * pi);\n\n // vec4 position = vec4(0, 0, 0, 0);\n // vec3 pos;\n\n // if (renderPixelLine < 1.0) {\n // pos = current.xyz + vec3(dir * offsetW, 0.0);\n // position = transform(pos);\n // } else {\n // // 计算 dir 和 normal1 的夹角 , 要 叠加的长度 是 offsetW * dir\n // pos = vec3((sCurrent + offsetW / divideBy * dir).xy, 0.0);\n // position = unproject(pos.xy, 0.0, 1.0);\n // }\n\n // gl_Position = position;\n }\n ",gs.FragmentShader="\n uniform sampler2D stripTexture;\n uniform float currentDistance;\n uniform float fullLength;\n uniform float viewDistance;\n uniform float gradientDistance;\n uniform vec4 fillColor;\n uniform vec4 strokeColor;\n uniform bool gradientEnabled;\n uniform float renderPixelLine;\n uniform float fillOpacity;\n\n varying vec2 texcoord;\n varying float vProgress;\n varying float isBorder;\n\n float opacity = 1.0;\n\n void main(){\n vec4 texColor = texture2D(stripTexture, texcoord);\n\n float alpha = fillOpacity;\n float cur = currentDistance;\n float grad = gradientDistance;\n float view = viewDistance;\n\n if (gradientEnabled) {\n if (vProgress < cur) {\n alpha = 0.0;\n } else {\n if (vProgress > cur + view) {\n alpha = 0.0;\n } else {\n if (fullLength <= cur + view) {\n view = fullLength - cur;\n if (view < 2.0 * grad) {\n grad = view * 0.5;\n }\n }\n\n if (vProgress > cur + grad) {\n alpha = fillOpacity;\n if (vProgress > cur + view - grad) {\n alpha = abs(cur + view - vProgress) / grad * fillOpacity;\n }\n } else {\n alpha = abs(vProgress - cur) / grad * fillOpacity;\n }\n }\n }\n } else if (renderPixelLine == 1.0) {\n if (vProgress < cur) {\n alpha = 0.0;\n }\n }\n if (isBorder > -0.99) {\n gl_FragColor = vec4(strokeColor.rgb, opacity * alpha * strokeColor.a);\n } else {\n gl_FragColor = vec4((fillColor * (1.0 - texColor.a) + texColor * texColor.a).rgb, opacity * alpha * (fillColor.a * (1.0 - texColor.a) + texColor.a));\n }\n }\n ";class vs extends C{constructor(){super(),this.pathMap=new Map,this.renderThisFrame=!0,vs.instanceId=0}init(t){const{THREE:e}=x.getInstance();this.parent=t,this.scene=new e.Scene,this.camera=this.parent.camera,this.renderer=this.parent.renderer,this.pathMap=new Map,this.enabled=!0,this.renderThisFrame=!0}update(){let t=[];Array.from(this.pathMap).forEach(([e,n])=>{t=[...t,...Array.from(n)]});const e=t.reduce((t,e)=>this.handleElementUpdate(e.update())||t,!1);return!(!this.renderThisFrame&&!e)&&(this.renderThisFrame=!1,!0)}handleElementUpdate(t){return t.needUpdate}render(){this.enabled&&(this.resize(this.parent.getViewWidth(),this.parent.getViewHeight()),this.renderer.clearDepth(),this.renderer.render(this.scene,this.camera))}resize(t,e){this.pathMap.forEach(n=>{for(let i of n)i.resize(t,e)})}setEnabled(t){this.enabled=t}createPath(t,e,n=!1){if(n&&this.clearPaths(),!this.scene)throw Error("pathOverlay need bind a view, use view.addOverlay()");const i=new Set;if(this.renderThisFrame=!0,vs.instanceId++,e.strokeWidth&&e.strokeColor){const n=new gs(t,{...e,strokeWidth:0,width:e.width+2*e.strokeWidth,color:e.strokeColor,renderPixelLine:!0}),r="border_"+vs.instanceId;n.name=r,i.add(n),this.scene.add(n)}const r=new gs(t,{...e,strokeWidth:0,renderPixelLine:!0}),s=vs.instanceId+"";return r.name=s,i.add(r),this.scene.add(r),this.pathMap.set(s,i),i}removePath(t){const e=t.name,n=this.pathMap.get(e);if(n){for(let t of n)this.scene.remove(t),t.dispose();this.pathMap.delete(e),this.renderThisFrame=!0}}clearPaths(){this.pathMap.forEach(t=>{for(let e of t)this.scene.remove(e),e.dispose()}),this.pathMap.clear(),this.renderThisFrame=!0}dispose(){this.clearPaths()}}function ys(){}Object.assign(ys.prototype,{addEventListener:function(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)},hasEventListener:function(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)},removeEventListener:function(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}},dispatchEvent:function(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,i=n.length;e<i;e++)n[e].call(this,t);t.target=null}}});const xs=[];for(let t=0;t<256;t++)xs[t]=(t<16?"0":"")+t.toString(16);let bs=1234567;const ws={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(xs[255&t]+xs[t>>8&255]+xs[t>>16&255]+xs[t>>24&255]+"-"+xs[255&e]+xs[e>>8&255]+"-"+xs[e>>16&15|64]+xs[e>>24&255]+"-"+xs[63&n|128]+xs[n>>8&255]+"-"+xs[n>>16&255]+xs[n>>24&255]+xs[255&i]+xs[i>>8&255]+xs[i>>16&255]+xs[i>>24&255]).toUpperCase()},clamp:function(t,e,n){return Math.max(e,Math.min(n,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:function(t,e,n){return(1-n)*t+n*e},damp:function(t,e,n,i){return ws.lerp(t,e,1-Math.exp(-n*i))},pingpong:function(t,e=1){return e-Math.abs(ws.euclideanModulo(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){return void 0!==t&&(bs=t%2147483647),bs=16807*bs%2147483647,(bs-1)/2147483646},degToRad:function(t){return t*ws.DEG2RAD},radToDeg:function(t){return t*ws.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,n,i,r){const s=Math.cos,o=Math.sin,a=s(n/2),l=o(n/2),h=s((e+i)/2),c=o((e+i)/2),u=s((e-i)/2),d=o((e-i)/2),p=s((i-e)/2),f=o((i-e)/2);switch(r){case"XYX":t.set(a*c,l*u,l*d,a*h);break;case"YZY":t.set(l*d,a*c,l*u,a*h);break;case"ZXZ":t.set(l*u,l*d,a*c,a*h);break;case"XZX":t.set(a*c,l*f,l*p,a*h);break;case"YXY":t.set(l*p,a*c,l*f,a*h);break;case"ZYZ":t.set(l*f,l*p,a*c,a*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}};class Ms{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*n-s*i+t.x,this.y=r*i+s*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}Ms.prototype.isVector2=!0;class _s{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(t,e,n,i,r,s,o,a,l){const h=this.elements;return h[0]=t,h[1]=i,h[2]=o,h[3]=e,h[4]=r,h[5]=a,h[6]=n,h[7]=s,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],o=n[3],a=n[6],l=n[1],h=n[4],c=n[7],u=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],y=i[4],x=i[7],b=i[2],w=i[5],M=i[8];return r[0]=s*f+o*v+a*b,r[3]=s*m+o*y+a*w,r[6]=s*g+o*x+a*M,r[1]=l*f+h*v+c*b,r[4]=l*m+h*y+c*w,r[7]=l*g+h*x+c*M,r[2]=u*f+d*v+p*b,r[5]=u*m+d*y+p*w,r[8]=u*g+d*x+p*M,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],o=t[5],a=t[6],l=t[7],h=t[8];return e*s*h-e*o*l-n*r*h+n*o*a+i*r*l-i*s*a}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],o=t[5],a=t[6],l=t[7],h=t[8],c=h*s-o*l,u=o*a-h*r,d=l*r-s*a,p=e*c+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return t[0]=c*f,t[1]=(i*l-h*n)*f,t[2]=(o*n-i*s)*f,t[3]=u*f,t[4]=(h*e-i*a)*f,t[5]=(i*r-o*e)*f,t[6]=d*f,t[7]=(n*a-l*e)*f,t[8]=(s*e-n*r)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,s,o){const a=Math.cos(r),l=Math.sin(r);return this.set(n*a,n*l,-n*(a*s+l*o)+s+t,-i*l,i*a,-i*(-l*s+a*o)+o+e,0,0,1),this}scale(t,e){const n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=e,n[4]*=e,n[7]*=e,this}rotate(t){const e=Math.cos(t),n=Math.sin(t),i=this.elements,r=i[0],s=i[3],o=i[6],a=i[1],l=i[4],h=i[7];return i[0]=e*r+n*a,i[3]=e*s+n*l,i[6]=e*o+n*h,i[1]=-n*r+e*a,i[4]=-n*s+e*l,i[7]=-n*o+e*h,this}translate(t,e){const n=this.elements;return n[0]+=t*n[2],n[3]+=t*n[5],n[6]+=t*n[8],n[1]+=e*n[2],n[4]+=e*n[5],n[7]+=e*n[8],this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}let Es;_s.prototype.isMatrix3=!0;const Ss={getDataURL:function(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===Es&&(Es=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),Es.width=t.width,Es.height=t.height;const n=Es.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Es}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}};let Ts=0;class As extends ys{constructor(t=As.DEFAULT_IMAGE,e=As.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,l=1,h=3e3){super(),Object.defineProperty(this,"id",{value:Ts++}),this.uuid=ws.generateUUID(),this.name="",this.image=t,this.mipmaps=[],this.mapping=e,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=a,this.offset=new Ms(0,0),this.repeat=new Ms(1,1),this.center=new Ms(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new _s,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=h,this.version=0,this.onUpdate=null}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const i=this.image;if(void 0===i.uuid&&(i.uuid=ws.generateUUID()),!e&&void 0===t.images[i.uuid]){let e;if(Array.isArray(i)){e=[];for(let t=0,n=i.length;t<n;t++)i[t].isDataTexture?e.push(Ps(i[t].image)):e.push(Ps(i[t]))}else e=Ps(i);t.images[i.uuid]={uuid:i.uuid,url:e}}n.image=i.uuid}return e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case 1001:t.x=t.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case 1e3:t.y=t.y-Math.floor(t.y);break;case 1001:t.y=t.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&this.version++}}function Ps(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?Ss.getDataURL(t):t.data?{data:Array.prototype.slice.call(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}As.DEFAULT_IMAGE=void 0,As.DEFAULT_MAPPING=300,As.prototype.isTexture=!0;class Ls{constructor(t=0,e=0,n=0,i=1){this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*e+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*e+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*e+s[7]*n+s[11]*i+s[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const s=t.elements,o=s[0],a=s[4],l=s[8],h=s[1],c=s[5],u=s[9],d=s[2],p=s[6],f=s[10];if(Math.abs(a-h)<.01&&Math.abs(l-d)<.01&&Math.abs(u-p)<.01){if(Math.abs(a+h)<.1&&Math.abs(l+d)<.1&&Math.abs(u+p)<.1&&Math.abs(o+c+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const t=(o+1)/2,s=(c+1)/2,m=(f+1)/2,g=(a+h)/4,v=(l+d)/4,y=(u+p)/4;return t>s&&t>m?t<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(t),i=g/n,r=v/n):s>m?s<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(s),n=g/i,r=y/i):m<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(m),n=v/r,i=y/r),this.set(n,i,r,e),this}let m=Math.sqrt((p-u)*(p-u)+(l-d)*(l-d)+(h-a)*(h-a));return Math.abs(m)<.001&&(m=1),this.x=(p-u)/m,this.y=(l-d)/m,this.z=(h-a)/m,this.w=Math.acos((o+c+f-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e,n){return void 0!==n&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}}Ls.prototype.isVector4=!0;class Rs extends ys{constructor(t,e,n){super(),this.width=t,this.height=e,this.depth=1,this.scissor=new Ls(0,0,t,e),this.scissorTest=!1,this.viewport=new Ls(0,0,t,e),n=n||{},this.texture=new As(void 0,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=1,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:1006,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0!==n.stencilBuffer&&n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null}setTexture(t){t.image={width:this.width,height:this.height,depth:this.depth},this.texture=t}setSize(t,e,n=1){this.width===t&&this.height===e&&this.depth===n||(this.width=t,this.height=e,this.depth=n,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.width=t.width,this.height=t.height,this.depth=t.depth,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}Rs.prototype.isWebGLRenderTarget=!0;(class extends Rs{constructor(t,e,n){super(t,e,n),this.samples=4}copy(t){return super.copy.call(this,t),this.samples=t.samples,this}}).prototype.isWebGLMultisampleRenderTarget=!0;class Cs{constructor(t=0,e=0,n=0,i=1){this._x=t,this._y=e,this._z=n,this._w=i}static slerp(t,e,n,i){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),n.slerpQuaternions(t,e,i)}static slerpFlat(t,e,n,i,r,s,o){let a=n[i+0],l=n[i+1],h=n[i+2],c=n[i+3];const u=r[s+0],d=r[s+1],p=r[s+2],f=r[s+3];if(0===o)return t[e+0]=a,t[e+1]=l,t[e+2]=h,void(t[e+3]=c);if(1===o)return t[e+0]=u,t[e+1]=d,t[e+2]=p,void(t[e+3]=f);if(c!==f||a!==u||l!==d||h!==p){let t=1-o;const e=a*u+l*d+h*p+c*f,n=e>=0?1:-1,i=1-e*e;if(i>Number.EPSILON){const r=Math.sqrt(i),s=Math.atan2(r,e*n);t=Math.sin(t*s)/r,o=Math.sin(o*s)/r}const r=o*n;if(a=a*t+u*r,l=l*t+d*r,h=h*t+p*r,c=c*t+f*r,t===1-o){const t=1/Math.sqrt(a*a+l*l+h*h+c*c);a*=t,l*=t,h*=t,c*=t}}t[e]=a,t[e+1]=l,t[e+2]=h,t[e+3]=c}static multiplyQuaternionsFlat(t,e,n,i,r,s){const o=n[i],a=n[i+1],l=n[i+2],h=n[i+3],c=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return t[e]=o*p+h*c+a*d-l*u,t[e+1]=a*p+h*u+l*c-o*d,t[e+2]=l*p+h*d+o*u-a*c,t[e+3]=h*p-o*c-a*u-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=t._x,i=t._y,r=t._z,s=t._order,o=Math.cos,a=Math.sin,l=o(n/2),h=o(i/2),c=o(r/2),u=a(n/2),d=a(i/2),p=a(r/2);switch(s){case"XYZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"YXZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"ZXY":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"ZYX":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"YZX":this._x=u*h*c+l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c-u*d*p;break;case"XZY":this._x=u*h*c-l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],s=e[1],o=e[5],a=e[9],l=e[2],h=e[6],c=e[10],u=n+o+c;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(h-a)*t,this._y=(r-l)*t,this._z=(s-i)*t}else if(n>o&&n>c){const t=2*Math.sqrt(1+n-o-c);this._w=(h-a)/t,this._x=.25*t,this._y=(i+s)/t,this._z=(r+l)/t}else if(o>c){const t=2*Math.sqrt(1+o-n-c);this._w=(r-l)/t,this._x=(i+s)/t,this._y=.25*t,this._z=(a+h)/t}else{const t=2*Math.sqrt(1+c-n-o);this._w=(s-i)/t,this._x=(r+l)/t,this._y=(a+h)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ws.clamp(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,s=t._w,o=e._x,a=e._y,l=e._z,h=e._w;return this._x=n*h+s*o+i*l-r*a,this._y=i*h+s*a+r*o-n*l,this._z=r*h+s*l+n*a-i*o,this._w=s*h-n*o-i*a-r*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,i=this._y,r=this._z,s=this._w;let o=s*t._w+n*t._x+i*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=s,this._x=n,this._y=i,this._z=r,this;const a=1-o*o;if(a<=Number.EPSILON){const t=1-e;return this._w=t*s+e*this._w,this._x=t*n+e*this._x,this._y=t*i+e*this._y,this._z=t*r+e*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(a),h=Math.atan2(l,o),c=Math.sin((1-e)*h)/l,u=Math.sin(e*h)/l;return this._w=s*c+this._w*u,this._x=n*c+this._x*u,this._y=i*c+this._y*u,this._z=r*c+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,n){this.copy(t).slerp(e,n)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}Cs.prototype.isQuaternion=!0;class Is{constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Ds.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ds.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,s=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,o=t.z,a=t.w,l=a*e+s*i-o*n,h=a*n+o*e-r*i,c=a*i+r*n-s*e,u=-r*e-s*n-o*i;return this.x=l*a+u*-r+h*-o-c*-s,this.y=h*a+u*-s+c*-r-l*-o,this.z=c*a+u*-o+l*-s-h*-r,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,s=e.x,o=e.y,a=e.z;return this.x=i*a-r*o,this.y=r*s-n*a,this.z=n*o-i*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Os.copy(this).projectOnVector(t),this.sub(Os)}reflect(t){return this.sub(Os.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ws.clamp(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}Is.prototype.isVector3=!0;const Os=new Is,Ds=new Cs;class zs{constructor(t=new Is(1/0,1/0,1/0),e=new Is(-1/0,-1/0,-1/0)){this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,n=1/0,i=1/0,r=-1/0,s=-1/0,o=-1/0;for(let a=0,l=t.length;a<l;a+=3){const l=t[a],h=t[a+1],c=t[a+2];l<e&&(e=l),h<n&&(n=h),c<i&&(i=c),l>r&&(r=l),h>s&&(s=h),c>o&&(o=c)}return this.min.set(e,n,i),this.max.set(r,s,o),this}setFromBufferAttribute(t){let e=1/0,n=1/0,i=1/0,r=-1/0,s=-1/0,o=-1/0;for(let a=0,l=t.count;a<l;a++){const l=t.getX(a),h=t.getY(a),c=t.getZ(a);l<e&&(e=l),h<n&&(n=h),c<i&&(i=c),l>r&&(r=l),h>s&&(s=h),c>o&&(o=c)}return this.min.set(e,n,i),this.max.set(r,s,o),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Us.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t){return this.makeEmpty(),this.expandByObject(t)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return void 0===t&&(console.warn("THREE.Box3: .getCenter() target is now required"),t=new Is),this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return void 0===t&&(console.warn("THREE.Box3: .getSize() target is now required"),t=new Is),this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t){t.updateWorldMatrix(!1,!1);const e=t.geometry;void 0!==e&&(null===e.boundingBox&&e.computeBoundingBox(),Bs.copy(e.boundingBox),Bs.applyMatrix4(t.matrixWorld),this.union(Bs));const n=t.children;for(let t=0,e=n.length;t<e;t++)this.expandByObject(n[t]);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new Is),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Us),Us.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(js),Xs.subVectors(this.max,js),Fs.subVectors(t.a,js),Vs.subVectors(t.b,js),ks.subVectors(t.c,js),Hs.subVectors(Vs,Fs),Gs.subVectors(ks,Vs),Ws.subVectors(Fs,ks);let e=[0,-Hs.z,Hs.y,0,-Gs.z,Gs.y,0,-Ws.z,Ws.y,Hs.z,0,-Hs.x,Gs.z,0,-Gs.x,Ws.z,0,-Ws.x,-Hs.y,Hs.x,0,-Gs.y,Gs.x,0,-Ws.y,Ws.x,0];return!!Zs(e,Fs,Vs,ks,Xs)&&(e=[1,0,0,0,1,0,0,0,1],!!Zs(e,Fs,Vs,ks,Xs)&&(Ys.crossVectors(Hs,Gs),e=[Ys.x,Ys.y,Ys.z],Zs(e,Fs,Vs,ks,Xs)))}clampPoint(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new Is),e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return Us.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return void 0===t&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=.5*this.getSize(Us).length(),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(Ns[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ns[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ns[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ns[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ns[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ns[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ns[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ns[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ns)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}zs.prototype.isBox3=!0;const Ns=[new Is,new Is,new Is,new Is,new Is,new Is,new Is,new Is],Us=new Is,Bs=new zs,Fs=new Is,Vs=new Is,ks=new Is,Hs=new Is,Gs=new Is,Ws=new Is,js=new Is,Xs=new Is,Ys=new Is,qs=new Is;function Zs(t,e,n,i,r){for(let s=0,o=t.length-3;s<=o;s+=3){qs.fromArray(t,s);const o=r.x*Math.abs(qs.x)+r.y*Math.abs(qs.y)+r.z*Math.abs(qs.z),a=e.dot(qs),l=n.dot(qs),h=i.dot(qs);if(Math.max(-Math.max(a,l,h),Math.min(a,l,h))>o)return!1}return!0}const Js=new zs,$s=new Is,Qs=new Is,Ks=new Is;class to{constructor(t=new Is,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):Js.setFromPoints(t).getCenter(n);let i=0;for(let e=0,r=t.length;e<r;e++)i=Math.max(i,n.distanceToSquared(t[e]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return void 0===e&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),e=new Is),e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new zs),this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){Ks.subVectors(t,this.center);const e=Ks.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.add(Ks.multiplyScalar(n/t)),this.radius+=n}return this}union(t){return Qs.subVectors(t.center,this.center).normalize().multiplyScalar(t.radius),this.expandByPoint($s.copy(t.center).add(Qs)),this.expandByPoint($s.copy(t.center).sub(Qs)),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const eo=new Is,no=new Is,io=new Is,ro=new Is,so=new Is,oo=new Is,ao=new Is;class lo{constructor(t=new Is,e=new Is(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new Is),e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,eo)),this}closestPointToPoint(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new Is),e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=eo.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(eo.copy(this.direction).multiplyScalar(e).add(this.origin),eo.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){no.copy(t).add(e).multiplyScalar(.5),io.copy(e).sub(t).normalize(),ro.copy(this.origin).sub(no);const r=.5*t.distanceTo(e),s=-this.direction.dot(io),o=ro.dot(this.direction),a=-ro.dot(io),l=ro.lengthSq(),h=Math.abs(1-s*s);let c,u,d,p;if(h>0)if(c=s*a-o,u=s*o-a,p=r*h,c>=0)if(u>=-p)if(u<=p){const t=1/h;c*=t,u*=t,d=c*(c+s*u+2*o)+u*(s*c+u+2*a)+l}else u=r,c=Math.max(0,-(s*u+o)),d=-c*c+u*(u+2*a)+l;else u=-r,c=Math.max(0,-(s*u+o)),d=-c*c+u*(u+2*a)+l;else u<=-p?(c=Math.max(0,-(-s*r+o)),u=c>0?-r:Math.min(Math.max(-r,-a),r),d=-c*c+u*(u+2*a)+l):u<=p?(c=0,u=Math.min(Math.max(-r,-a),r),d=u*(u+2*a)+l):(c=Math.max(0,-(s*r+o)),u=c>0?r:Math.min(Math.max(-r,-a),r),d=-c*c+u*(u+2*a)+l);else u=s>0?-r:r,c=Math.max(0,-(s*u+o)),d=-c*c+u*(u+2*a)+l;return n&&n.copy(this.direction).multiplyScalar(c).add(this.origin),i&&i.copy(io).multiplyScalar(u).add(no),d}intersectSphere(t,e){eo.subVectors(t.center,this.origin);const n=eo.dot(this.direction),i=eo.dot(eo)-n*n,r=t.radius*t.radius;if(i>r)return null;const s=Math.sqrt(r-i),o=n-s,a=n+s;return o<0&&a<0?null:o<0?this.at(a,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,s,o,a;const l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,u=this.origin;return l>=0?(n=(t.min.x-u.x)*l,i=(t.max.x-u.x)*l):(n=(t.max.x-u.x)*l,i=(t.min.x-u.x)*l),h>=0?(r=(t.min.y-u.y)*h,s=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,s=(t.min.y-u.y)*h),n>s||r>i?null:((r>n||n!=n)&&(n=r),(s<i||i!=i)&&(i=s),c>=0?(o=(t.min.z-u.z)*c,a=(t.max.z-u.z)*c):(o=(t.max.z-u.z)*c,a=(t.min.z-u.z)*c),n>a||o>i?null:((o>n||n!=n)&&(n=o),(a<i||i!=i)&&(i=a),i<0?null:this.at(n>=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,eo)}intersectTriangle(t,e,n,i,r){so.subVectors(e,t),oo.subVectors(n,t),ao.crossVectors(so,oo);let s,o=this.direction.dot(ao);if(o>0){if(i)return null;s=1}else{if(!(o<0))return null;s=-1,o=-o}ro.subVectors(this.origin,t);const a=s*this.direction.dot(oo.crossVectors(ro,oo));if(a<0)return null;const l=s*this.direction.dot(so.cross(ro));if(l<0)return null;if(a+l>o)return null;const h=-s*ro.dot(ao);return h<0?null:this.at(h/o,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class ho{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(t,e,n,i,r,s,o,a,l,h,c,u,d,p,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=o,g[13]=a,g[2]=l,g[6]=h,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new ho).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,i=1/co.setFromMatrixColumn(t,0).length(),r=1/co.setFromMatrixColumn(t,1).length(),s=1/co.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*s,e[9]=n[9]*s,e[10]=n[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const e=this.elements,n=t.x,i=t.y,r=t.z,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),l=Math.sin(i),h=Math.cos(r),c=Math.sin(r);if("XYZ"===t.order){const t=s*h,n=s*c,i=o*h,r=o*c;e[0]=a*h,e[4]=-a*c,e[8]=l,e[1]=n+i*l,e[5]=t-r*l,e[9]=-o*a,e[2]=r-t*l,e[6]=i+n*l,e[10]=s*a}else if("YXZ"===t.order){const t=a*h,n=a*c,i=l*h,r=l*c;e[0]=t+r*o,e[4]=i*o-n,e[8]=s*l,e[1]=s*c,e[5]=s*h,e[9]=-o,e[2]=n*o-i,e[6]=r+t*o,e[10]=s*a}else if("ZXY"===t.order){const t=a*h,n=a*c,i=l*h,r=l*c;e[0]=t-r*o,e[4]=-s*c,e[8]=i+n*o,e[1]=n+i*o,e[5]=s*h,e[9]=r-t*o,e[2]=-s*l,e[6]=o,e[10]=s*a}else if("ZYX"===t.order){const t=s*h,n=s*c,i=o*h,r=o*c;e[0]=a*h,e[4]=i*l-n,e[8]=t*l+r,e[1]=a*c,e[5]=r*l+t,e[9]=n*l-i,e[2]=-l,e[6]=o*a,e[10]=s*a}else if("YZX"===t.order){const t=s*a,n=s*l,i=o*a,r=o*l;e[0]=a*h,e[4]=r-t*c,e[8]=i*c+n,e[1]=c,e[5]=s*h,e[9]=-o*h,e[2]=-l*h,e[6]=n*c+i,e[10]=t-r*c}else if("XZY"===t.order){const t=s*a,n=s*l,i=o*a,r=o*l;e[0]=a*h,e[4]=-c,e[8]=l*h,e[1]=t*c+r,e[5]=s*h,e[9]=n*c-i,e[2]=i*c-n,e[6]=o*h,e[10]=r*c+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(po,t,fo)}lookAt(t,e,n){const i=this.elements;return vo.subVectors(t,e),0===vo.lengthSq()&&(vo.z=1),vo.normalize(),mo.crossVectors(n,vo),0===mo.lengthSq()&&(1===Math.abs(n.z)?vo.x+=1e-4:vo.z+=1e-4,vo.normalize(),mo.crossVectors(n,vo)),mo.normalize(),go.crossVectors(vo,mo),i[0]=mo.x,i[4]=go.x,i[8]=vo.x,i[1]=mo.y,i[5]=go.y,i[9]=vo.y,i[2]=mo.z,i[6]=go.z,i[10]=vo.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],o=n[4],a=n[8],l=n[12],h=n[1],c=n[5],u=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],y=n[7],x=n[11],b=n[15],w=i[0],M=i[4],_=i[8],E=i[12],S=i[1],T=i[5],A=i[9],P=i[13],L=i[2],R=i[6],C=i[10],I=i[14],O=i[3],D=i[7],z=i[11],N=i[15];return r[0]=s*w+o*S+a*L+l*O,r[4]=s*M+o*T+a*R+l*D,r[8]=s*_+o*A+a*C+l*z,r[12]=s*E+o*P+a*I+l*N,r[1]=h*w+c*S+u*L+d*O,r[5]=h*M+c*T+u*R+d*D,r[9]=h*_+c*A+u*C+d*z,r[13]=h*E+c*P+u*I+d*N,r[2]=p*w+f*S+m*L+g*O,r[6]=p*M+f*T+m*R+g*D,r[10]=p*_+f*A+m*C+g*z,r[14]=p*E+f*P+m*I+g*N,r[3]=v*w+y*S+x*L+b*O,r[7]=v*M+y*T+x*R+b*D,r[11]=v*_+y*A+x*C+b*z,r[15]=v*E+y*P+x*I+b*N,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],s=t[1],o=t[5],a=t[9],l=t[13],h=t[2],c=t[6],u=t[10],d=t[14];return t[3]*(+r*a*c-i*l*c-r*o*u+n*l*u+i*o*d-n*a*d)+t[7]*(+e*a*d-e*l*u+r*s*u-i*s*d+i*l*h-r*a*h)+t[11]*(+e*l*c-e*o*d-r*s*c+n*s*d+r*o*h-n*l*h)+t[15]*(-i*o*h-e*a*c+e*o*u+i*s*c-n*s*u+n*a*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],o=t[5],a=t[6],l=t[7],h=t[8],c=t[9],u=t[10],d=t[11],p=t[12],f=t[13],m=t[14],g=t[15],v=c*m*l-f*u*l+f*a*d-o*m*d-c*a*g+o*u*g,y=p*u*l-h*m*l-p*a*d+s*m*d+h*a*g-s*u*g,x=h*f*l-p*c*l+p*o*d-s*f*d-h*o*g+s*c*g,b=p*c*a-h*f*a-p*o*u+s*f*u+h*o*m-s*c*m,w=e*v+n*y+i*x+r*b;if(0===w)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/w;return t[0]=v*M,t[1]=(f*u*r-c*m*r-f*i*d+n*m*d+c*i*g-n*u*g)*M,t[2]=(o*m*r-f*a*r+f*i*l-n*m*l-o*i*g+n*a*g)*M,t[3]=(c*a*r-o*u*r-c*i*l+n*u*l+o*i*d-n*a*d)*M,t[4]=y*M,t[5]=(h*m*r-p*u*r+p*i*d-e*m*d-h*i*g+e*u*g)*M,t[6]=(p*a*r-s*m*r-p*i*l+e*m*l+s*i*g-e*a*g)*M,t[7]=(s*u*r-h*a*r+h*i*l-e*u*l-s*i*d+e*a*d)*M,t[8]=x*M,t[9]=(p*c*r-h*f*r-p*n*d+e*f*d+h*n*g-e*c*g)*M,t[10]=(s*f*r-p*o*r+p*n*l-e*f*l-s*n*g+e*o*g)*M,t[11]=(h*o*r-s*c*r-h*n*l+e*c*l+s*n*d-e*o*d)*M,t[12]=b*M,t[13]=(h*f*i-p*c*i+p*n*u-e*f*u-h*n*m+e*c*m)*M,t[14]=(p*o*i-s*f*i-p*n*a+e*f*a+s*n*m-e*o*m)*M,t[15]=(s*c*i-h*o*i+h*n*a-e*c*a-s*n*u+e*o*u)*M,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,s=t.x,o=t.y,a=t.z,l=r*s,h=r*o;return this.set(l*s+n,l*o-i*a,l*a+i*o,0,l*o+i*a,h*o+n,h*a-i*s,0,l*a-i*o,h*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n){return this.set(1,e,n,0,t,1,n,0,t,e,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,s=e._y,o=e._z,a=e._w,l=r+r,h=s+s,c=o+o,u=r*l,d=r*h,p=r*c,f=s*h,m=s*c,g=o*c,v=a*l,y=a*h,x=a*c,b=n.x,w=n.y,M=n.z;return i[0]=(1-(f+g))*b,i[1]=(d+x)*b,i[2]=(p-y)*b,i[3]=0,i[4]=(d-x)*w,i[5]=(1-(u+g))*w,i[6]=(m+v)*w,i[7]=0,i[8]=(p+y)*M,i[9]=(m-v)*M,i[10]=(1-(u+f))*M,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;let r=co.set(i[0],i[1],i[2]).length();const s=co.set(i[4],i[5],i[6]).length(),o=co.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],uo.copy(this);const a=1/r,l=1/s,h=1/o;return uo.elements[0]*=a,uo.elements[1]*=a,uo.elements[2]*=a,uo.elements[4]*=l,uo.elements[5]*=l,uo.elements[6]*=l,uo.elements[8]*=h,uo.elements[9]*=h,uo.elements[10]*=h,e.setFromRotationMatrix(uo),n.x=r,n.y=s,n.z=o,this}makePerspective(t,e,n,i,r,s){void 0===s&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const o=this.elements,a=2*r/(e-t),l=2*r/(n-i),h=(e+t)/(e-t),c=(n+i)/(n-i),u=-(s+r)/(s-r),d=-2*s*r/(s-r);return o[0]=a,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=l,o[9]=c,o[13]=0,o[2]=0,o[6]=0,o[10]=u,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,n,i,r,s){const o=this.elements,a=1/(e-t),l=1/(n-i),h=1/(s-r),c=(e+t)*a,u=(n+i)*l,d=(s+r)*h;return o[0]=2*a,o[4]=0,o[8]=0,o[12]=-c,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=-2*h,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}ho.prototype.isMatrix4=!0;const co=new Is,uo=new ho,po=new Is(0,0,0),fo=new Is(1,1,1),mo=new Is,go=new Is,vo=new Is,yo=new ho,xo=new Cs;class bo{constructor(t=0,e=0,n=0,i=bo.DefaultOrder){this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._order=i||this._order,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e,n){const i=ws.clamp,r=t.elements,s=r[0],o=r[4],a=r[8],l=r[1],h=r[5],c=r[9],u=r[2],d=r[6],p=r[10];switch(e=e||this._order){case"XYZ":this._y=Math.asin(i(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,h),this._z=0);break;case"YXZ":this._x=Math.asin(-i(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(l,h)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(i(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-o,h)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-i(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,h));break;case"YZX":this._z=Math.asin(i(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-i(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,h),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-c,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!1!==n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return yo.makeRotationFromQuaternion(t),this.setFromRotationMatrix(yo,e,n)}setFromVector3(t,e){return this.set(t.x,t.y,t.z,e||this._order)}reorder(t){return xo.setFromEuler(this),this.setFromQuaternion(xo,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}toVector3(t){return t?t.set(this._x,this._y,this._z):new Is(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}bo.prototype.isEuler=!0,bo.DefaultOrder="XYZ",bo.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class wo{constructor(){this.mask=1}set(t){this.mask=1<<t|0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return 0!=(this.mask&t.mask)}}let Mo=0;const _o=new Is,Eo=new Cs,So=new ho,To=new Is,Ao=new Is,Po=new Is,Lo=new Cs,Ro=new Is(1,0,0),Co=new Is(0,1,0),Io=new Is(0,0,1),Oo={type:"added"},Do={type:"removed"};function zo(){Object.defineProperty(this,"id",{value:Mo++}),this.uuid=ws.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=zo.DefaultUp.clone();const t=new Is,e=new bo,n=new Cs,i=new Is(1,1,1);e._onChange((function(){n.setFromEuler(e,!1)})),n._onChange((function(){e.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new ho},normalMatrix:{value:new _s}}),this.matrix=new ho,this.matrixWorld=new ho,this.matrixAutoUpdate=zo.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new wo,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}zo.DefaultUp=new Is(0,1,0),zo.DefaultMatrixAutoUpdate=!0,zo.prototype=Object.assign(Object.create(ys.prototype),{constructor:zo,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(t){return this.quaternion.premultiply(t),this},setRotationFromAxisAngle:function(t,e){this.quaternion.setFromAxisAngle(t,e)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:function(t,e){return Eo.setFromAxisAngle(t,e),this.quaternion.multiply(Eo),this},rotateOnWorldAxis:function(t,e){return Eo.setFromAxisAngle(t,e),this.quaternion.premultiply(Eo),this},rotateX:function(t){return this.rotateOnAxis(Ro,t)},rotateY:function(t){return this.rotateOnAxis(Co,t)},rotateZ:function(t){return this.rotateOnAxis(Io,t)},translateOnAxis:function(t,e){return _o.copy(t).applyQuaternion(this.quaternion),this.position.add(_o.multiplyScalar(e)),this},translateX:function(t){return this.translateOnAxis(Ro,t)},translateY:function(t){return this.translateOnAxis(Co,t)},translateZ:function(t){return this.translateOnAxis(Io,t)},localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:function(t){return t.applyMatrix4(So.copy(this.matrixWorld).invert())},lookAt:function(t,e,n){t.isVector3?To.copy(t):To.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Ao.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?So.lookAt(Ao,To,this.up):So.lookAt(To,Ao,this.up),this.quaternion.setFromRotationMatrix(So),i&&(So.extractRotation(i.matrixWorld),Eo.setFromRotationMatrix(So),this.quaternion.premultiply(Eo.invert()))},add:function(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(Oo)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)},remove:function(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Do)),this},clear:function(){for(let t=0;t<this.children.length;t++){const e=this.children[t];e.parent=null,e.dispatchEvent(Do)}return this.children.length=0,this},attach:function(t){return this.updateWorldMatrix(!0,!1),So.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),So.multiply(t.parent.matrixWorld)),t.applyMatrix4(So),this.add(t),t.updateWorldMatrix(!1,!0),this},getObjectById:function(t){return this.getObjectByProperty("id",t)},getObjectByName:function(t){return this.getObjectByProperty("name",t)},getObjectByProperty:function(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(t,e);if(void 0!==i)return i}},getWorldPosition:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),t=new Is),this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),t=new Cs),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ao,t,Po),t},getWorldScale:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),t=new Is),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ao,Lo,t),t},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),t=new Is),this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()},raycast:function(){},traverse:function(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)},traverseVisible:function(t){if(!1===this.visible)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)},traverseAncestors:function(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)},updateWorldMatrix:function(t,e){const n=this.parent;if(!0===t&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===e){const t=this.children;for(let e=0,n=t.length;e<n;e++)t[e].updateWorldMatrix(!1,!0)}},toJSON:function(t){const e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const i={};function r(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e<i;e++){const i=n[e];r(t.shapes,i)}else r(t.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let n=0,i=this.material.length;n<i;n++)e.push(r(t.materials,this.material[n]));i.material=e}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let e=0;e<this.children.length;e++)i.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let e=0;e<this.animations.length;e++){const n=this.animations[e];i.animations.push(r(t.animations,n))}}if(e){const e=s(t.geometries),i=s(t.materials),r=s(t.textures),o=s(t.images),a=s(t.shapes),l=s(t.skeletons),h=s(t.animations);e.length>0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),o.length>0&&(n.images=o),a.length>0&&(n.shapes=a),l.length>0&&(n.skeletons=l),h.length>0&&(n.animations=h)}return n.object=i,n;function s(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const n=t.children[e];this.add(n.clone())}return this}});const No=new Is,Uo=new Is,Bo=new _s;class Fo{constructor(t=new Is(1,0,0),e=0){this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=No.subVectors(n,e).cross(Uo.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return void 0===e&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new Is),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,e){void 0===e&&(console.warn("THREE.Plane: .intersectLine() target is now required"),e=new Is);const n=t.delta(No),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(n).multiplyScalar(r).add(t.start)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new Is),t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Bo.getNormalMatrix(t),i=this.coplanarPoint(No).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}Fo.prototype.isPlane=!0;const Vo=new Is,ko=new Is,Ho=new Is,Go=new Is,Wo=new Is,jo=new Is,Xo=new Is,Yo=new Is,qo=new Is,Zo=new Is;class Jo{constructor(t=new Is,e=new Is,n=new Is){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){void 0===i&&(console.warn("THREE.Triangle: .getNormal() target is now required"),i=new Is),i.subVectors(n,e),Vo.subVectors(t,e),i.cross(Vo);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){Vo.subVectors(i,e),ko.subVectors(n,e),Ho.subVectors(t,e);const s=Vo.dot(Vo),o=Vo.dot(ko),a=Vo.dot(Ho),l=ko.dot(ko),h=ko.dot(Ho),c=s*l-o*o;if(void 0===r&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),r=new Is),0===c)return r.set(-2,-1,-1);const u=1/c,d=(l*a-o*h)*u,p=(s*h-o*a)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,Go),Go.x>=0&&Go.y>=0&&Go.x+Go.y<=1}static getUV(t,e,n,i,r,s,o,a){return this.getBarycoord(t,e,n,i,Go),a.set(0,0),a.addScaledVector(r,Go.x),a.addScaledVector(s,Go.y),a.addScaledVector(o,Go.z),a}static isFrontFacing(t,e,n,i){return Vo.subVectors(n,e),ko.subVectors(t,e),Vo.cross(ko).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Vo.subVectors(this.c,this.b),ko.subVectors(this.a,this.b),.5*Vo.cross(ko).length()}getMidpoint(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new Is),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Jo.getNormal(this.a,this.b,this.c,t)}getPlane(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new Fo),t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Jo.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,n,i,r){return Jo.getUV(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return Jo.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Jo.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){void 0===e&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),e=new Is);const n=this.a,i=this.b,r=this.c;let s,o;Wo.subVectors(i,n),jo.subVectors(r,n),Yo.subVectors(t,n);const a=Wo.dot(Yo),l=jo.dot(Yo);if(a<=0&&l<=0)return e.copy(n);qo.subVectors(t,i);const h=Wo.dot(qo),c=jo.dot(qo);if(h>=0&&c<=h)return e.copy(i);const u=a*c-h*l;if(u<=0&&a>=0&&h<=0)return s=a/(a-h),e.copy(n).addScaledVector(Wo,s);Zo.subVectors(t,r);const d=Wo.dot(Zo),p=jo.dot(Zo);if(p>=0&&d<=p)return e.copy(r);const f=d*l-a*p;if(f<=0&&l>=0&&p<=0)return o=l/(l-p),e.copy(n).addScaledVector(jo,o);const m=h*p-d*c;if(m<=0&&c-h>=0&&d-p>=0)return Xo.subVectors(r,i),o=(c-h)/(c-h+(d-p)),e.copy(i).addScaledVector(Xo,o);const g=1/(m+f+u);return s=f*g,o=u*g,e.copy(n).addScaledVector(Wo,s).addScaledVector(jo,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let $o=0;function Qo(){Object.defineProperty(this,"id",{value:$o++}),this.uuid=ws.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}Qo.prototype=Object.assign(Object.create(ys.prototype),{constructor:Qo,isMaterial:!0,onBeforeCompile:function(){},customProgramCacheKey:function(){return this.onBeforeCompile.toString()},setValues:function(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}if("shading"===e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===n;continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}},toJSON:function(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,n.reflectivity=this.reflectivity,n.refractionRatio=this.refractionRatio,void 0!==this.combine&&(n.combine=this.combine),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(n.morphTargets=!0),!0===this.morphNormals&&(n.morphNormals=!0),!0===this.skinning&&(n.skinning=!0),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),e){const e=i(t.textures),r=i(t.images);e.length>0&&(n.textures=e),r.length>0&&(n.images=r)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(Qo.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}});const Ko={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ta={h:0,s:0,l:0},ea={h:0,s:0,l:0};function na(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}function ia(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function ra(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class sa{constructor(t,e,n){return void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}set(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this}setRGB(t,e,n){return this.r=t,this.g=e,this.b=n,this}setHSL(t,e,n){if(t=ws.euclideanModulo(t,1),e=ws.clamp(e,0,1),n=ws.clamp(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=na(r,i,t+1/3),this.g=na(r,i,t),this.b=na(r,i,t-1/3)}return this}setStyle(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let t;const i=n[1],r=n[2];switch(i){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,e(t[4]),this;if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,e(t[4]),this;break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const n=parseFloat(t[1])/360,i=parseInt(t[2],10)/100,r=parseInt(t[3],10)/100;return e(t[4]),this.setHSL(n,i,r)}}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=n[1],e=t.length;if(3===e)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,this;if(6===e)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this}setColorName(t){const e=Ko[t];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copyGammaToLinear(t,e=2){return this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this}copyLinearToGamma(t,e=2){const n=e>0?1/e:1;return this.r=Math.pow(t.r,n),this.g=Math.pow(t.g,n),this.b=Math.pow(t.b,n),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.r=ia(t.r),this.g=ia(t.g),this.b=ia(t.b),this}copyLinearToSRGB(t){return this.r=ra(t.r),this.g=ra(t.g),this.b=ra(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});const e=this.r,n=this.g,i=this.b,r=Math.max(e,n,i),s=Math.min(e,n,i);let o,a;const l=(s+r)/2;if(s===r)o=0,a=0;else{const t=r-s;switch(a=l<=.5?t/(r+s):t/(2-r-s),r){case e:o=(n-i)/t+(n<i?6:0);break;case n:o=(i-e)/t+2;break;case i:o=(e-n)/t+4}o/=6}return t.h=o,t.s=a,t.l=l,t}getStyle(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"}offsetHSL(t,e,n){return this.getHSL(ta),ta.h+=t,ta.s+=e,ta.l+=n,this.setHSL(ta.h,ta.s,ta.l),this}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(ta),t.getHSL(ea);const n=ws.lerp(ta.h,ea.h,e),i=ws.lerp(ta.s,ea.s,e),r=ws.lerp(ta.l,ea.l,e);return this.setHSL(n,i,r),this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),!0===t.normalized&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}}sa.NAMES=Ko,sa.prototype.isColor=!0,sa.prototype.r=1,sa.prototype.g=1,sa.prototype.b=1;class oa extends Qo{constructor(t){super(),this.type="MeshBasicMaterial",this.color=new sa(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this}}oa.prototype.isMeshBasicMaterial=!0;const aa=new Is,la=new Ms;function ha(t,e,n){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===n,this.usage=35044,this.updateRange={offset:0,count:-1},this.version=0}function ca(t,e,n){ha.call(this,new Int8Array(t),e,n)}function ua(t,e,n){ha.call(this,new Uint8Array(t),e,n)}function da(t,e,n){ha.call(this,new Uint8ClampedArray(t),e,n)}function pa(t,e,n){ha.call(this,new Int16Array(t),e,n)}function fa(t,e,n){ha.call(this,new Uint16Array(t),e,n)}function ma(t,e,n){ha.call(this,new Int32Array(t),e,n)}function ga(t,e,n){ha.call(this,new Uint32Array(t),e,n)}function va(t,e,n){ha.call(this,new Uint16Array(t),e,n)}function ya(t,e,n){ha.call(this,new Float32Array(t),e,n)}function xa(t,e,n){ha.call(this,new Float64Array(t),e,n)}function ba(t){if(0===t.length)return-1/0;let e=t[0];for(let n=1,i=t.length;n<i;++n)t[n]>e&&(e=t[n]);return e}Object.defineProperty(ha.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(ha.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this},copyArray:function(t){return this.array.set(t),this},copyColorsArray:function(t){const e=this.array;let n=0;for(let i=0,r=t.length;i<r;i++){let r=t[i];void 0===r&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",i),r=new sa),e[n++]=r.r,e[n++]=r.g,e[n++]=r.b}return this},copyVector2sArray:function(t){const e=this.array;let n=0;for(let i=0,r=t.length;i<r;i++){let r=t[i];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",i),r=new Ms),e[n++]=r.x,e[n++]=r.y}return this},copyVector3sArray:function(t){const e=this.array;let n=0;for(let i=0,r=t.length;i<r;i++){let r=t[i];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",i),r=new Is),e[n++]=r.x,e[n++]=r.y,e[n++]=r.z}return this},copyVector4sArray:function(t){const e=this.array;let n=0;for(let i=0,r=t.length;i<r;i++){let r=t[i];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",i),r=new Ls),e[n++]=r.x,e[n++]=r.y,e[n++]=r.z,e[n++]=r.w}return this},applyMatrix3:function(t){if(2===this.itemSize)for(let e=0,n=this.count;e<n;e++)la.fromBufferAttribute(this,e),la.applyMatrix3(t),this.setXY(e,la.x,la.y);else if(3===this.itemSize)for(let e=0,n=this.count;e<n;e++)aa.fromBufferAttribute(this,e),aa.applyMatrix3(t),this.setXYZ(e,aa.x,aa.y,aa.z);return this},applyMatrix4:function(t){for(let e=0,n=this.count;e<n;e++)aa.x=this.getX(e),aa.y=this.getY(e),aa.z=this.getZ(e),aa.applyMatrix4(t),this.setXYZ(e,aa.x,aa.y,aa.z);return this},applyNormalMatrix:function(t){for(let e=0,n=this.count;e<n;e++)aa.x=this.getX(e),aa.y=this.getY(e),aa.z=this.getZ(e),aa.applyNormalMatrix(t),this.setXYZ(e,aa.x,aa.y,aa.z);return this},transformDirection:function(t){for(let e=0,n=this.count;e<n;e++)aa.x=this.getX(e),aa.y=this.getY(e),aa.z=this.getZ(e),aa.transformDirection(t),this.setXYZ(e,aa.x,aa.y,aa.z);return this},set:function(t,e=0){return this.array.set(t,e),this},getX:function(t){return this.array[t*this.itemSize]},setX:function(t,e){return this.array[t*this.itemSize]=e,this},getY:function(t){return this.array[t*this.itemSize+1]},setY:function(t,e){return this.array[t*this.itemSize+1]=e,this},getZ:function(t){return this.array[t*this.itemSize+2]},setZ:function(t,e){return this.array[t*this.itemSize+2]=e,this},getW:function(t){return this.array[t*this.itemSize+3]},setW:function(t,e){return this.array[t*this.itemSize+3]=e,this},setXY:function(t,e,n){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this},setXYZ:function(t,e,n,i){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this},setXYZW:function(t,e,n,i,r){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this},onUpload:function(t){return this.onUploadCallback=t,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)},toJSON:function(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),35044!==this.usage&&(t.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(t.updateRange=this.updateRange),t}}),ca.prototype=Object.create(ha.prototype),ca.prototype.constructor=ca,ua.prototype=Object.create(ha.prototype),ua.prototype.constructor=ua,da.prototype=Object.create(ha.prototype),da.prototype.constructor=da,pa.prototype=Object.create(ha.prototype),pa.prototype.constructor=pa,fa.prototype=Object.create(ha.prototype),fa.prototype.constructor=fa,ma.prototype=Object.create(ha.prototype),ma.prototype.constructor=ma,ga.prototype=Object.create(ha.prototype),ga.prototype.constructor=ga,va.prototype=Object.create(ha.prototype),va.prototype.constructor=va,va.prototype.isFloat16BufferAttribute=!0,ya.prototype=Object.create(ha.prototype),ya.prototype.constructor=ya,xa.prototype=Object.create(ha.prototype),xa.prototype.constructor=xa;let wa=0;const Ma=new ho,_a=new zo,Ea=new Is,Sa=new zs,Ta=new zs,Aa=new Is;function Pa(){Object.defineProperty(this,"id",{value:wa++}),this.uuid=ws.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}Pa.prototype=Object.assign(Object.create(ys.prototype),{constructor:Pa,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(t){return Array.isArray(t)?this.index=new(ba(t)>65535?ga:fa)(t,1):this.index=t,this},getAttribute:function(t){return this.attributes[t]},setAttribute:function(t,e){return this.attributes[t]=e,this},deleteAttribute:function(t){return delete this.attributes[t],this},hasAttribute:function(t){return void 0!==this.attributes[t]},addGroup:function(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix4:function(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new _s).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(t),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(t){return Ma.makeRotationX(t),this.applyMatrix4(Ma),this},rotateY:function(t){return Ma.makeRotationY(t),this.applyMatrix4(Ma),this},rotateZ:function(t){return Ma.makeRotationZ(t),this.applyMatrix4(Ma),this},translate:function(t,e,n){return Ma.makeTranslation(t,e,n),this.applyMatrix4(Ma),this},scale:function(t,e,n){return Ma.makeScale(t,e,n),this.applyMatrix4(Ma),this},lookAt:function(t){return _a.lookAt(t),_a.updateMatrix(),this.applyMatrix4(_a.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ea).negate(),this.translate(Ea.x,Ea.y,Ea.z),this},setFromPoints:function(t){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n];e.push(i.x,i.y,i.z||0)}return this.setAttribute("position",new ya(e,3)),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new zs);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new Is(-1/0,-1/0,-1/0),new Is(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];Sa.setFromBufferAttribute(n),this.morphTargetsRelative?(Aa.addVectors(this.boundingBox.min,Sa.min),this.boundingBox.expandByPoint(Aa),Aa.addVectors(this.boundingBox.max,Sa.max),this.boundingBox.expandByPoint(Aa)):(this.boundingBox.expandByPoint(Sa.min),this.boundingBox.expandByPoint(Sa.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new to);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new Is,1/0);if(t){const n=this.boundingSphere.center;if(Sa.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];Ta.setFromBufferAttribute(n),this.morphTargetsRelative?(Aa.addVectors(Sa.min,Ta.min),Sa.expandByPoint(Aa),Aa.addVectors(Sa.max,Ta.max),Sa.expandByPoint(Aa)):(Sa.expandByPoint(Ta.min),Sa.expandByPoint(Ta.max))}Sa.getCenter(n);let i=0;for(let e=0,r=t.count;e<r;e++)Aa.fromBufferAttribute(t,e),i=Math.max(i,n.distanceToSquared(Aa));if(e)for(let r=0,s=e.length;r<s;r++){const s=e[r],o=this.morphTargetsRelative;for(let e=0,r=s.count;e<r;e++)Aa.fromBufferAttribute(s,e),o&&(Ea.fromBufferAttribute(t,e),Aa.add(Ea)),i=Math.max(i,n.distanceToSquared(Aa))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeTangents:function(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=t.array,i=e.position.array,r=e.normal.array,s=e.uv.array,o=i.length/3;void 0===e.tangent&&this.setAttribute("tangent",new ha(new Float32Array(4*o),4));const a=e.tangent.array,l=[],h=[];for(let t=0;t<o;t++)l[t]=new Is,h[t]=new Is;const c=new Is,u=new Is,d=new Is,p=new Ms,f=new Ms,m=new Ms,g=new Is,v=new Is;function y(t,e,n){c.fromArray(i,3*t),u.fromArray(i,3*e),d.fromArray(i,3*n),p.fromArray(s,2*t),f.fromArray(s,2*e),m.fromArray(s,2*n),u.sub(c),d.sub(c),f.sub(p),m.sub(p);const r=1/(f.x*m.y-m.x*f.y);isFinite(r)&&(g.copy(u).multiplyScalar(m.y).addScaledVector(d,-f.y).multiplyScalar(r),v.copy(d).multiplyScalar(f.x).addScaledVector(u,-m.x).multiplyScalar(r),l[t].add(g),l[e].add(g),l[n].add(g),h[t].add(v),h[e].add(v),h[n].add(v))}let x=this.groups;0===x.length&&(x=[{start:0,count:n.length}]);for(let t=0,e=x.length;t<e;++t){const e=x[t],i=e.start;for(let t=i,r=i+e.count;t<r;t+=3)y(n[t+0],n[t+1],n[t+2])}const b=new Is,w=new Is,M=new Is,_=new Is;function E(t){M.fromArray(r,3*t),_.copy(M);const e=l[t];b.copy(e),b.sub(M.multiplyScalar(M.dot(e))).normalize(),w.crossVectors(_,e);const n=w.dot(h[t])<0?-1:1;a[4*t]=b.x,a[4*t+1]=b.y,a[4*t+2]=b.z,a[4*t+3]=n}for(let t=0,e=x.length;t<e;++t){const e=x[t],i=e.start;for(let t=i,r=i+e.count;t<r;t+=3)E(n[t+0]),E(n[t+1]),E(n[t+2])}},computeVertexNormals:function(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let n=this.getAttribute("normal");if(void 0===n)n=new ha(new Float32Array(3*e.count),3),this.setAttribute("normal",n);else for(let t=0,e=n.count;t<e;t++)n.setXYZ(t,0,0,0);const i=new Is,r=new Is,s=new Is,o=new Is,a=new Is,l=new Is,h=new Is,c=new Is;if(t)for(let u=0,d=t.count;u<d;u+=3){const d=t.getX(u+0),p=t.getX(u+1),f=t.getX(u+2);i.fromBufferAttribute(e,d),r.fromBufferAttribute(e,p),s.fromBufferAttribute(e,f),h.subVectors(s,r),c.subVectors(i,r),h.cross(c),o.fromBufferAttribute(n,d),a.fromBufferAttribute(n,p),l.fromBufferAttribute(n,f),o.add(h),a.add(h),l.add(h),n.setXYZ(d,o.x,o.y,o.z),n.setXYZ(p,a.x,a.y,a.z),n.setXYZ(f,l.x,l.y,l.z)}else for(let t=0,o=e.count;t<o;t+=3)i.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),s.fromBufferAttribute(e,t+2),h.subVectors(s,r),c.subVectors(i,r),h.cross(c),n.setXYZ(t+0,h.x,h.y,h.z),n.setXYZ(t+1,h.x,h.y,h.z),n.setXYZ(t+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}},merge:function(t,e){if(!t||!t.isBufferGeometry)return void console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",t);void 0===e&&(e=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));const n=this.attributes;for(const i in n){if(void 0===t.attributes[i])continue;const r=n[i].array,s=t.attributes[i],o=s.array,a=s.itemSize*e,l=Math.min(o.length,r.length-a);for(let t=0,e=a;t<l;t++,e++)r[e]=o[t]}return this},normalizeNormals:function(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Aa.fromBufferAttribute(t,e),Aa.normalize(),t.setXYZ(e,Aa.x,Aa.y,Aa.z)},toNonIndexed:function(){function t(t,e){const n=t.array,i=t.itemSize,r=t.normalized,s=new n.constructor(e.length*i);let o=0,a=0;for(let t=0,r=e.length;t<r;t++){o=e[t]*i;for(let t=0;t<i;t++)s[a++]=n[o++]}return new ha(s,i,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Pa,n=this.index.array,i=this.attributes;for(const r in i){const s=t(i[r],n);e.setAttribute(r,s)}const r=this.morphAttributes;for(const i in r){const s=[],o=r[i];for(let e=0,i=o.length;e<i;e++){const i=t(o[e],n);s.push(i)}e.morphAttributes[i]=s}e.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let t=0,n=s.length;t<n;t++){const n=s[t];e.addGroup(n.start,n.count,n.materialIndex)}return e},toJSON:function(){const t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const i=n[e];t.data.attributes[e]=i.toJSON(t.data)}const i={};let r=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],s=[];for(let e=0,i=n.length;e<i;e++){const i=n[e];s.push(i.toJSON(t.data))}s.length>0&&(i[e]=s,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return null!==o&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t},clone:function(){return(new Pa).copy(this)},copy:function(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const i=t.attributes;for(const t in i){const n=i[t];this.setAttribute(t,n.clone(e))}const r=t.morphAttributes;for(const t in r){const n=[],i=r[t];for(let t=0,r=i.length;t<r;t++)n.push(i[t].clone(e));this.morphAttributes[t]=n}this.morphTargetsRelative=t.morphTargetsRelative;const s=t.groups;for(let t=0,e=s.length;t<e;t++){const e=s[t];this.addGroup(e.start,e.count,e.materialIndex)}const o=t.boundingBox;null!==o&&(this.boundingBox=o.clone());const a=t.boundingSphere;return null!==a&&(this.boundingSphere=a.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});const La=new ho,Ra=new lo,Ca=new to,Ia=new Is,Oa=new Is,Da=new Is,za=new Is,Na=new Is,Ua=new Is,Ba=new Is,Fa=new Is,Va=new Is,ka=new Ms,Ha=new Ms,Ga=new Ms,Wa=new Is,ja=new Is;function Xa(t=new Pa,e=new oa){zo.call(this),this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}function Ya(t,e,n,i,r,s,o,a,l,h,c,u){Ia.fromBufferAttribute(r,h),Oa.fromBufferAttribute(r,c),Da.fromBufferAttribute(r,u);const d=t.morphTargetInfluences;if(e.morphTargets&&s&&d){Ba.set(0,0,0),Fa.set(0,0,0),Va.set(0,0,0);for(let t=0,e=s.length;t<e;t++){const e=d[t],n=s[t];0!==e&&(za.fromBufferAttribute(n,h),Na.fromBufferAttribute(n,c),Ua.fromBufferAttribute(n,u),o?(Ba.addScaledVector(za,e),Fa.addScaledVector(Na,e),Va.addScaledVector(Ua,e)):(Ba.addScaledVector(za.sub(Ia),e),Fa.addScaledVector(Na.sub(Oa),e),Va.addScaledVector(Ua.sub(Da),e)))}Ia.add(Ba),Oa.add(Fa),Da.add(Va)}t.isSkinnedMesh&&e.skinning&&(t.boneTransform(h,Ia),t.boneTransform(c,Oa),t.boneTransform(u,Da));const p=function(t,e,n,i,r,s,o,a){let l;if(l=1===e.side?i.intersectTriangle(o,s,r,!0,a):i.intersectTriangle(r,s,o,2!==e.side,a),null===l)return null;ja.copy(a),ja.applyMatrix4(t.matrixWorld);const h=n.ray.origin.distanceTo(ja);return h<n.near||h>n.far?null:{distance:h,point:ja.clone(),object:t}}(t,e,n,i,Ia,Oa,Da,Wa);if(p){a&&(ka.fromBufferAttribute(a,h),Ha.fromBufferAttribute(a,c),Ga.fromBufferAttribute(a,u),p.uv=Jo.getUV(Wa,Ia,Oa,Da,ka,Ha,Ga,new Ms)),l&&(ka.fromBufferAttribute(l,h),Ha.fromBufferAttribute(l,c),Ga.fromBufferAttribute(l,u),p.uv2=Jo.getUV(Wa,Ia,Oa,Da,ka,Ha,Ga,new Ms));const t={a:h,b:c,c:u,normal:new Is,materialIndex:0};Jo.getNormal(Ia,Oa,Da,t.normal),p.face=t}return p}Xa.prototype=Object.assign(Object.create(zo.prototype),{constructor:Xa,isMesh:!0,copy:function(t){return zo.prototype.copy.call(this,t),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=t.material,this.geometry=t.geometry,this},updateMorphTargets:function(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,n=Object.keys(e);if(n.length>0){const t=e[n[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,n=t.length;e<n;e++){const n=t[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=e}}}}else{const e=t.morphTargets;void 0!==e&&e.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(t,e){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0===i)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),Ca.copy(n.boundingSphere),Ca.applyMatrix4(r),!1===t.ray.intersectsSphere(Ca))return;if(La.copy(r).invert(),Ra.copy(t.ray).applyMatrix4(La),null!==n.boundingBox&&!1===Ra.intersectsBox(n.boundingBox))return;let s;if(n.isBufferGeometry){const r=n.index,o=n.attributes.position,a=n.morphAttributes.position,l=n.morphTargetsRelative,h=n.attributes.uv,c=n.attributes.uv2,u=n.groups,d=n.drawRange;if(null!==r)if(Array.isArray(i))for(let n=0,p=u.length;n<p;n++){const p=u[n],f=i[p.materialIndex];for(let n=Math.max(p.start,d.start),i=Math.min(p.start+p.count,d.start+d.count);n<i;n+=3){const i=r.getX(n),u=r.getX(n+1),d=r.getX(n+2);s=Ya(this,f,t,Ra,o,a,l,h,c,i,u,d),s&&(s.faceIndex=Math.floor(n/3),s.face.materialIndex=p.materialIndex,e.push(s))}}else{for(let n=Math.max(0,d.start),u=Math.min(r.count,d.start+d.count);n<u;n+=3){const u=r.getX(n),d=r.getX(n+1),p=r.getX(n+2);s=Ya(this,i,t,Ra,o,a,l,h,c,u,d,p),s&&(s.faceIndex=Math.floor(n/3),e.push(s))}}else if(void 0!==o)if(Array.isArray(i))for(let n=0,r=u.length;n<r;n++){const r=u[n],p=i[r.materialIndex];for(let n=Math.max(r.start,d.start),i=Math.min(r.start+r.count,d.start+d.count);n<i;n+=3){s=Ya(this,p,t,Ra,o,a,l,h,c,n,n+1,n+2),s&&(s.faceIndex=Math.floor(n/3),s.face.materialIndex=r.materialIndex,e.push(s))}}else{for(let n=Math.max(0,d.start),r=Math.min(o.count,d.start+d.count);n<r;n+=3){s=Ya(this,i,t,Ra,o,a,l,h,c,n,n+1,n+2),s&&(s.faceIndex=Math.floor(n/3),e.push(s))}}}else n.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}});class qa extends Pa{constructor(t=1,e=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const a=[],l=[],h=[],c=[];let u=0,d=0;function p(t,e,n,i,r,s,p,f,m,g,v){const y=s/m,x=p/g,b=s/2,w=p/2,M=f/2,_=m+1,E=g+1;let S=0,T=0;const A=new Is;for(let s=0;s<E;s++){const o=s*x-w;for(let a=0;a<_;a++){const u=a*y-b;A[t]=u*i,A[e]=o*r,A[n]=M,l.push(A.x,A.y,A.z),A[t]=0,A[e]=0,A[n]=f>0?1:-1,h.push(A.x,A.y,A.z),c.push(a/m),c.push(1-s/g),S+=1}}for(let t=0;t<g;t++)for(let e=0;e<m;e++){const n=u+e+_*t,i=u+e+_*(t+1),r=u+(e+1)+_*(t+1),s=u+(e+1)+_*t;a.push(n,i,s),a.push(i,r,s),T+=6}o.addGroup(d,T,v),d+=T,u+=S}p("z","y","x",-1,-1,n,e,t,s,r,0),p("z","y","x",1,-1,n,e,-t,s,r,1),p("x","z","y",1,1,t,n,e,i,s,2),p("x","z","y",1,-1,t,n,-e,i,s,3),p("x","y","z",1,-1,t,e,n,i,r,4),p("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new ya(l,3)),this.setAttribute("normal",new ya(h,3)),this.setAttribute("uv",new ya(c,2))}}function Za(t){const e={};for(const n in t){e[n]={};for(const i in t[n]){const r=t[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?e[n][i]=r.clone():Array.isArray(r)?e[n][i]=r.slice():e[n][i]=r}}return e}function Ja(t){const e={};for(let n=0;n<t.length;n++){const i=Za(t[n]);for(const t in i)e[t]=i[t]}return e}const $a={clone:Za,merge:Ja};function Qa(t){Qo.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function Ka(){zo.call(this),this.type="Camera",this.matrixWorldInverse=new ho,this.projectionMatrix=new ho,this.projectionMatrixInverse=new ho}function tl(t=50,e=1,n=.1,i=2e3){Ka.call(this),this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}Qa.prototype=Object.create(Qo.prototype),Qa.prototype.constructor=Qa,Qa.prototype.isShaderMaterial=!0,Qa.prototype.copy=function(t){return Qo.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Za(t.uniforms),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this},Qa.prototype.toJSON=function(t){const e=Qo.prototype.toJSON.call(this,t);e.glslVersion=this.glslVersion,e.uniforms={};for(const n in this.uniforms){const i=this.uniforms[n].value;i&&i.isTexture?e.uniforms[n]={type:"t",value:i.toJSON(t).uuid}:i&&i.isColor?e.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?e.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?e.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?e.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?e.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?e.uniforms[n]={type:"m4",value:i.toArray()}:e.uniforms[n]={value:i}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e},Ka.prototype=Object.assign(Object.create(zo.prototype),{constructor:Ka,isCamera:!0,copy:function(t,e){return zo.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new Is),this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()},updateMatrixWorld:function(t){zo.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()},updateWorldMatrix:function(t,e){zo.prototype.updateWorldMatrix.call(this,t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()},clone:function(){return(new this.constructor).copy(this)}}),tl.prototype=Object.assign(Object.create(Ka.prototype),{constructor:tl,isPerspectiveCamera:!0,copy:function(t,e){return Ka.prototype.copy.call(this,t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this},setFocalLength:function(t){const e=.5*this.getFilmHeight()/t;this.fov=2*ws.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){const t=Math.tan(.5*ws.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*ws.RAD2DEG*Math.atan(Math.tan(.5*ws.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(t,e,n,i,r,s){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){const t=this.near;let e=t*Math.tan(.5*ws.DEG2RAD*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,o=s.fullHeight;r+=s.offsetX*i/t,e-=s.offsetY*n/o,i*=s.width/t,n*=s.height/o}const o=this.filmOffset;0!==o&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()},toJSON:function(t){const e=zo.prototype.toJSON.call(this,t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}});class el extends zo{constructor(t,e,n){if(super(),this.type="CubeCamera",!0!==n.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=n;const i=new tl(90,1,t,e);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new Is(1,0,0)),this.add(i);const r=new tl(90,1,t,e);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Is(-1,0,0)),this.add(r);const s=new tl(90,1,t,e);s.layers=this.layers,s.up.set(0,0,1),s.lookAt(new Is(0,1,0)),this.add(s);const o=new tl(90,1,t,e);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new Is(0,-1,0)),this.add(o);const a=new tl(90,1,t,e);a.layers=this.layers,a.up.set(0,-1,0),a.lookAt(new Is(0,0,1)),this.add(a);const l=new tl(90,1,t,e);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new Is(0,0,-1)),this.add(l)}update(t,e){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[i,r,s,o,a,l]=this.children,h=t.xr.enabled,c=t.getRenderTarget();t.xr.enabled=!1;const u=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0),t.render(e,i),t.setRenderTarget(n,1),t.render(e,r),t.setRenderTarget(n,2),t.render(e,s),t.setRenderTarget(n,3),t.render(e,o),t.setRenderTarget(n,4),t.render(e,a),n.texture.generateMipmaps=u,t.setRenderTarget(n,5),t.render(e,l),t.setRenderTarget(c),t.xr.enabled=h}}class nl extends As{constructor(t,e,n,i,r,s,o,a,l,h){super(t=void 0!==t?t:[],e=void 0!==e?e:301,n,i,r,s,o=void 0!==o?o:1022,a,l,h),this._needsFlipEnvMap=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}nl.prototype.isCubeTexture=!0;class il extends Rs{constructor(t,e,n){Number.isInteger(e)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),e=n),super(t,t,e),e=e||{},this.texture=new nl(void 0,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:1006,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.format=1023,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new qa(5,5,5),r=new Qa({name:"CubemapFromEquirect",uniforms:Za(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;const s=new Xa(i,r),o=e.minFilter;1008===e.minFilter&&(e.minFilter=1006);return new el(1,10,this).update(t,s),e.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(t,e,n,i){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,n,i);t.setRenderTarget(r)}}il.prototype.isWebGLCubeRenderTarget=!0;class rl extends As{constructor(t,e,n,i,r,s,o,a,l,h,c,u){super(null,s,o,a,l,h,i,r,c,u),this.image={data:t||null,width:e||1,height:n||1},this.magFilter=void 0!==l?l:1003,this.minFilter=void 0!==h?h:1003,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}rl.prototype.isDataTexture=!0;const sl=new to,ol=new Is;class al{constructor(t=new Fo,e=new Fo,n=new Fo,i=new Fo,r=new Fo,s=new Fo){this.planes=[t,e,n,i,r,s]}set(t,e,n,i,r,s){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t){const e=this.planes,n=t.elements,i=n[0],r=n[1],s=n[2],o=n[3],a=n[4],l=n[5],h=n[6],c=n[7],u=n[8],d=n[9],p=n[10],f=n[11],m=n[12],g=n[13],v=n[14],y=n[15];return e[0].setComponents(o-i,c-a,f-u,y-m).normalize(),e[1].setComponents(o+i,c+a,f+u,y+m).normalize(),e[2].setComponents(o+r,c+l,f+d,y+g).normalize(),e[3].setComponents(o-r,c-l,f-d,y-g).normalize(),e[4].setComponents(o-s,c-h,f-p,y-v).normalize(),e[5].setComponents(o+s,c+h,f+p,y+v).normalize(),this}intersectsObject(t){const e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),sl.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(sl)}intersectsSprite(t){return sl.center.set(0,0,0),sl.radius=.7071067811865476,sl.applyMatrix4(t.matrixWorld),this.intersectsSphere(sl)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(n)<i)return!1}return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(ol.x=i.normal.x>0?t.max.x:t.min.x,ol.y=i.normal.y>0?t.max.y:t.min.y,ol.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(ol)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function ll(){let t=null,e=!1,n=null,i=null;function r(e,s){n(e,s),i=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==n&&(i=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function hl(t,e){const n=e.isWebGL2,i=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),i.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const n=i.get(e);n&&(t.deleteBuffer(n.buffer),i.delete(e))},update:function(e,r){if(e.isGLBufferAttribute){const t=i.get(e);return void((!t||t.version<e.version)&&i.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version}))}e.isInterleavedBufferAttribute&&(e=e.data);const s=i.get(e);void 0===s?i.set(e,function(e,i){const r=e.array,s=e.usage,o=t.createBuffer();t.bindBuffer(i,o),t.bufferData(i,r,s),e.onUploadCallback();let a=5126;return r instanceof Float32Array?a=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?e.isFloat16BufferAttribute?n?a=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):a=5123:r instanceof Int16Array?a=5122:r instanceof Uint32Array?a=5125:r instanceof Int32Array?a=5124:r instanceof Int8Array?a=5120:r instanceof Uint8Array&&(a=5121),{buffer:o,type:a,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}(e,r)):s.version<e.version&&(!function(e,i,r){const s=i.array,o=i.updateRange;t.bindBuffer(r,e),-1===o.count?t.bufferSubData(r,0,s):(n?t.bufferSubData(r,o.offset*s.BYTES_PER_ELEMENT,s,o.offset,o.count):t.bufferSubData(r,o.offset*s.BYTES_PER_ELEMENT,s.subarray(o.offset,o.offset+o.count)),o.count=-1)}(s.buffer,e,r),s.version=e.version)}}}class cl extends Pa{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const r=t/2,s=e/2,o=Math.floor(n),a=Math.floor(i),l=o+1,h=a+1,c=t/o,u=e/a,d=[],p=[],f=[],m=[];for(let t=0;t<h;t++){const e=t*u-s;for(let n=0;n<l;n++){const i=n*c-r;p.push(i,-e,0),f.push(0,0,1),m.push(n/o),m.push(1-t/a)}}for(let t=0;t<a;t++)for(let e=0;e<o;e++){const n=e+l*t,i=e+l*(t+1),r=e+1+l*(t+1),s=e+1+l*t;d.push(n,i,s),d.push(i,r,s)}this.setIndex(d),this.setAttribute("position",new ya(p,3)),this.setAttribute("normal",new ya(f,3)),this.setAttribute("uv",new ya(m,2))}}const ul={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat specularRoughness;\n\tvec3 specularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\t\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\t\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmissionmap_fragment:"#ifdef USE_TRANSMISSIONMAP\n\ttotalTransmission *= texture2D( transmissionMap, vUv ).r;\n#endif",transmissionmap_pars_fragment:"#ifdef USE_TRANSMISSIONMAP\n\tuniform sampler2D transmissionMap;\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSMISSION\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSMISSION\n\tuniform float transmission;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <transmissionmap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#ifdef TRANSMISSION\n\t\tfloat totalTransmission = transmission;\n\t#endif\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <transmissionmap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSMISSION\n\t\tdiffuseColor.a *= mix( saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ), 1.0, metalness );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}"},dl={common:{diffuse:{value:new sa(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new _s},uv2Transform:{value:new _s},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new Ms(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new sa(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new sa(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new _s}},sprite:{diffuse:{value:new sa(15658734)},opacity:{value:1},center:{value:new Ms(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new _s}}},pl={basic:{uniforms:Ja([dl.common,dl.specularmap,dl.envmap,dl.aomap,dl.lightmap,dl.fog]),vertexShader:ul.meshbasic_vert,fragmentShader:ul.meshbasic_frag},lambert:{uniforms:Ja([dl.common,dl.specularmap,dl.envmap,dl.aomap,dl.lightmap,dl.emissivemap,dl.fog,dl.lights,{emissive:{value:new sa(0)}}]),vertexShader:ul.meshlambert_vert,fragmentShader:ul.meshlambert_frag},phong:{uniforms:Ja([dl.common,dl.specularmap,dl.envmap,dl.aomap,dl.lightmap,dl.emissivemap,dl.bumpmap,dl.normalmap,dl.displacementmap,dl.fog,dl.lights,{emissive:{value:new sa(0)},specular:{value:new sa(1118481)},shininess:{value:30}}]),vertexShader:ul.meshphong_vert,fragmentShader:ul.meshphong_frag},standard:{uniforms:Ja([dl.common,dl.envmap,dl.aomap,dl.lightmap,dl.emissivemap,dl.bumpmap,dl.normalmap,dl.displacementmap,dl.roughnessmap,dl.metalnessmap,dl.fog,dl.lights,{emissive:{value:new sa(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ul.meshphysical_vert,fragmentShader:ul.meshphysical_frag},toon:{uniforms:Ja([dl.common,dl.aomap,dl.lightmap,dl.emissivemap,dl.bumpmap,dl.normalmap,dl.displacementmap,dl.gradientmap,dl.fog,dl.lights,{emissive:{value:new sa(0)}}]),vertexShader:ul.meshtoon_vert,fragmentShader:ul.meshtoon_frag},matcap:{uniforms:Ja([dl.common,dl.bumpmap,dl.normalmap,dl.displacementmap,dl.fog,{matcap:{value:null}}]),vertexShader:ul.meshmatcap_vert,fragmentShader:ul.meshmatcap_frag},points:{uniforms:Ja([dl.points,dl.fog]),vertexShader:ul.points_vert,fragmentShader:ul.points_frag},dashed:{uniforms:Ja([dl.common,dl.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ul.linedashed_vert,fragmentShader:ul.linedashed_frag},depth:{uniforms:Ja([dl.common,dl.displacementmap]),vertexShader:ul.depth_vert,fragmentShader:ul.depth_frag},normal:{uniforms:Ja([dl.common,dl.bumpmap,dl.normalmap,dl.displacementmap,{opacity:{value:1}}]),vertexShader:ul.normal_vert,fragmentShader:ul.normal_frag},sprite:{uniforms:Ja([dl.sprite,dl.fog]),vertexShader:ul.sprite_vert,fragmentShader:ul.sprite_frag},background:{uniforms:{uvTransform:{value:new _s},t2D:{value:null}},vertexShader:ul.background_vert,fragmentShader:ul.background_frag},cube:{uniforms:Ja([dl.envmap,{opacity:{value:1}}]),vertexShader:ul.cube_vert,fragmentShader:ul.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ul.equirect_vert,fragmentShader:ul.equirect_frag},distanceRGBA:{uniforms:Ja([dl.common,dl.displacementmap,{referencePosition:{value:new Is},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ul.distanceRGBA_vert,fragmentShader:ul.distanceRGBA_frag},shadow:{uniforms:Ja([dl.lights,dl.fog,{color:{value:new sa(0)},opacity:{value:1}}]),vertexShader:ul.shadow_vert,fragmentShader:ul.shadow_frag}};function fl(t,e,n,i,r){const s=new sa(0);let o,a,l=0,h=null,c=0,u=null;function d(t,e){n.buffers.color.setClear(t.r,t.g,t.b,e,r)}return{getClearColor:function(){return s},setClearColor:function(t,e=1){s.set(t),l=e,d(s,l)},getClearAlpha:function(){return l},setClearAlpha:function(t){l=t,d(s,l)},render:function(n,r,p,f){let m=!0===r.isScene?r.background:null;m&&m.isTexture&&(m=e.get(m));const g=t.xr,v=g.getSession&&g.getSession();v&&"additive"===v.environmentBlendMode&&(m=null),null===m?d(s,l):m&&m.isColor&&(d(m,1),f=!0),(t.autoClear||f)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),m&&(m.isCubeTexture||306===m.mapping)?(void 0===a&&(a=new Xa(new qa(1,1,1),new Qa({name:"BackgroundCubeMaterial",uniforms:Za(pl.cube.uniforms),vertexShader:pl.cube.vertexShader,fragmentShader:pl.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),a.geometry.deleteAttribute("normal"),a.geometry.deleteAttribute("uv"),a.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(a.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(a)),a.material.uniforms.envMap.value=m,a.material.uniforms.flipEnvMap.value=m.isCubeTexture&&m._needsFlipEnvMap?-1:1,h===m&&c===m.version&&u===t.toneMapping||(a.material.needsUpdate=!0,h=m,c=m.version,u=t.toneMapping),n.unshift(a,a.geometry,a.material,0,0,null)):m&&m.isTexture&&(void 0===o&&(o=new Xa(new cl(2,2),new Qa({name:"BackgroundMaterial",uniforms:Za(pl.background.uniforms),vertexShader:pl.background.vertexShader,fragmentShader:pl.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),o.geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(o)),o.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),o.material.uniforms.uvTransform.value.copy(m.matrix),h===m&&c===m.version&&u===t.toneMapping||(o.material.needsUpdate=!0,h=m,c=m.version,u=t.toneMapping),n.unshift(o,o.geometry,o.material,0,0,null))}}}function ml(t,e,n,i){const r=t.getParameter(34921),s=i.isWebGL2?null:e.get("OES_vertex_array_object"),o=i.isWebGL2||null!==s,a={},l=d(null);let h=l;function c(e){return i.isWebGL2?t.bindVertexArray(e):s.bindVertexArrayOES(e)}function u(e){return i.isWebGL2?t.deleteVertexArray(e):s.deleteVertexArrayOES(e)}function d(t){const e=[],n=[],i=[];for(let t=0;t<r;t++)e[t]=0,n[t]=0,i[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:n,attributeDivisors:i,object:t,attributes:{},index:null}}function p(){const t=h.newAttributes;for(let e=0,n=t.length;e<n;e++)t[e]=0}function f(t){m(t,0)}function m(n,r){const s=h.newAttributes,o=h.enabledAttributes,a=h.attributeDivisors;if(s[n]=1,0===o[n]&&(t.enableVertexAttribArray(n),o[n]=1),a[n]!==r){(i.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,r),a[n]=r}}function g(){const e=h.newAttributes,n=h.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==e[i]&&(t.disableVertexAttribArray(i),n[i]=0)}function v(e,n,r,s,o,a){!0!==i.isWebGL2||5124!==r&&5125!==r?t.vertexAttribPointer(e,n,r,s,o,a):t.vertexAttribIPointer(e,n,r,o,a)}function y(){x(),h!==l&&(h=l,c(h.object))}function x(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function(r,l,u,y,x){let b=!1;if(o){const e=function(e,n,r){const o=!0===r.wireframe;let l=a[e.id];void 0===l&&(l={},a[e.id]=l);let h=l[n.id];void 0===h&&(h={},l[n.id]=h);let c=h[o];void 0===c&&(c=d(i.isWebGL2?t.createVertexArray():s.createVertexArrayOES()),h[o]=c);return c}(y,u,l);h!==e&&(h=e,c(h.object)),b=function(t,e){const n=h.attributes,i=t.attributes;let r=0;for(const t in i){const e=n[t],s=i[t];if(void 0===e)return!0;if(e.attribute!==s)return!0;if(e.data!==s.data)return!0;r++}return h.attributesNum!==r||h.index!==e}(y,x),b&&function(t,e){const n={},i=t.attributes;let r=0;for(const t in i){const e=i[t],s={};s.attribute=e,e.data&&(s.data=e.data),n[t]=s,r++}h.attributes=n,h.attributesNum=r,h.index=e}(y,x)}else{const t=!0===l.wireframe;h.geometry===y.id&&h.program===u.id&&h.wireframe===t||(h.geometry=y.id,h.program=u.id,h.wireframe=t,b=!0)}!0===r.isInstancedMesh&&(b=!0),null!==x&&n.update(x,34963),b&&(!function(r,s,o,a){if(!1===i.isWebGL2&&(r.isInstancedMesh||a.isInstancedBufferGeometry)&&null===e.get("ANGLE_instanced_arrays"))return;p();const l=a.attributes,h=o.getAttributes(),c=s.defaultAttributeValues;for(const e in h){const i=h[e];if(i>=0){const s=l[e];if(void 0!==s){const e=s.normalized,r=s.itemSize,o=n.get(s);if(void 0===o)continue;const l=o.buffer,h=o.type,c=o.bytesPerElement;if(s.isInterleavedBufferAttribute){const n=s.data,o=n.stride,u=s.offset;n&&n.isInstancedInterleavedBuffer?(m(i,n.meshPerAttribute),void 0===a._maxInstanceCount&&(a._maxInstanceCount=n.meshPerAttribute*n.count)):f(i),t.bindBuffer(34962,l),v(i,r,h,e,o*c,u*c)}else s.isInstancedBufferAttribute?(m(i,s.meshPerAttribute),void 0===a._maxInstanceCount&&(a._maxInstanceCount=s.meshPerAttribute*s.count)):f(i),t.bindBuffer(34962,l),v(i,r,h,e,0,0)}else if("instanceMatrix"===e){const e=n.get(r.instanceMatrix);if(void 0===e)continue;const s=e.buffer,o=e.type;m(i+0,1),m(i+1,1),m(i+2,1),m(i+3,1),t.bindBuffer(34962,s),t.vertexAttribPointer(i+0,4,o,!1,64,0),t.vertexAttribPointer(i+1,4,o,!1,64,16),t.vertexAttribPointer(i+2,4,o,!1,64,32),t.vertexAttribPointer(i+3,4,o,!1,64,48)}else if("instanceColor"===e){const e=n.get(r.instanceColor);if(void 0===e)continue;const s=e.buffer,o=e.type;m(i,1),t.bindBuffer(34962,s),t.vertexAttribPointer(i,3,o,!1,12,0)}else if(void 0!==c){const n=c[e];if(void 0!==n)switch(n.length){case 2:t.vertexAttrib2fv(i,n);break;case 3:t.vertexAttrib3fv(i,n);break;case 4:t.vertexAttrib4fv(i,n);break;default:t.vertexAttrib1fv(i,n)}}}}g()}(r,l,u,y),null!==x&&t.bindBuffer(34963,n.get(x).buffer))},reset:y,resetDefaultState:x,dispose:function(){y();for(const t in a){const e=a[t];for(const t in e){const n=e[t];for(const t in n)u(n[t].object),delete n[t];delete e[t]}delete a[t]}},releaseStatesOfGeometry:function(t){if(void 0===a[t.id])return;const e=a[t.id];for(const t in e){const n=e[t];for(const t in n)u(n[t].object),delete n[t];delete e[t]}delete a[t.id]},releaseStatesOfProgram:function(t){for(const e in a){const n=a[e];if(void 0===n[t.id])continue;const i=n[t.id];for(const t in i)u(i[t].object),delete i[t];delete n[t.id]}},initAttributes:p,enableAttribute:f,disableUnusedAttributes:g}}function gl(t,e,n,i){const r=i.isWebGL2;let s;this.setMode=function(t){s=t},this.render=function(e,i){t.drawArrays(s,e,i),n.update(i,s,1)},this.renderInstances=function(i,o,a){if(0===a)return;let l,h;if(r)l=t,h="drawArraysInstanced";else if(l=e.get("ANGLE_instanced_arrays"),h="drawArraysInstancedANGLE",null===l)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[h](s,i,o,a),n.update(o,s,a)}}function vl(t,e,n){let i;function r(e){if("highp"===e){if(t.getShaderPrecisionFormat(35633,36338).precision>0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const s="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext;let o=void 0!==n.precision?n.precision:"highp";const a=r(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);const l=!0===n.logarithmicDepthBuffer,h=t.getParameter(34930),c=t.getParameter(35660),u=t.getParameter(3379),d=t.getParameter(34076),p=t.getParameter(34921),f=t.getParameter(36347),m=t.getParameter(36348),g=t.getParameter(36349),v=c>0,y=s||e.has("OES_texture_float");return{isWebGL2:s,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:l,maxTextures:h,maxVertexTextures:c,maxTextureSize:u,maxCubemapSize:d,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y,maxSamples:s?t.getParameter(36183):0}}function yl(t){const e=this;let n=null,i=0,r=!1,s=!1;const o=new Fo,a=new _s,l={value:null,needsUpdate:!1};function h(){l.value!==n&&(l.value=n,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function c(t,n,i,r){const s=null!==t?t.length:0;let h=null;if(0!==s){if(h=l.value,!0!==r||null===h){const e=i+4*s,r=n.matrixWorldInverse;a.getNormalMatrix(r),(null===h||h.length<e)&&(h=new Float32Array(e));for(let e=0,n=i;e!==s;++e,n+=4)o.copy(t[e]).applyMatrix4(r,a),o.normal.toArray(h,n),h[n+3]=o.constant}l.value=h,l.needsUpdate=!0}return e.numPlanes=s,e.numIntersection=0,h}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e,s){const o=0!==t.length||e||0!==i||r;return r=e,n=c(t,s,0),i=t.length,o},this.beginShadows=function(){s=!0,c(null)},this.endShadows=function(){s=!1,h()},this.setState=function(e,o,a){const u=e.clippingPlanes,d=e.clipIntersection,p=e.clipShadows,f=t.get(e);if(!r||null===u||0===u.length||s&&!p)s?c(null):h();else{const t=s?0:i,e=4*t;let r=f.clippingState||null;l.value=r,r=c(u,o,e,a);for(let t=0;t!==e;++t)r[t]=n[t];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}function xl(t){let e=new WeakMap;function n(t,e){return 303===e?t.mapping=301:304===e&&(t.mapping=302),t}function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping;if(303===s||304===s){if(e.has(r)){return n(e.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const o=t.getRenderTarget(),a=new il(s.height/2);return a.fromEquirectangularTexture(t,r),e.set(r,a),t.setRenderTarget(o),r.addEventListener("dispose",i),n(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}function bl(t){const e={};function n(n){if(void 0!==e[n])return e[n];let i;switch(n){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=t.getExtension(n)}return e[n]=i,i}return{has:function(t){return null!==n(t)},init:function(t){t.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float")},get:function(t){const e=n(t);return null===e&&console.warn("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function wl(t,e,n,i){const r={},s=new WeakMap;function o(t){const a=t.target;null!==a.index&&e.remove(a.index);for(const t in a.attributes)e.remove(a.attributes[t]);a.removeEventListener("dispose",o),delete r[a.id];const l=s.get(a);l&&(e.remove(l),s.delete(a)),i.releaseStatesOfGeometry(a),!0===a.isInstancedBufferGeometry&&delete a._maxInstanceCount,n.memory.geometries--}function a(t){const n=[],i=t.index,r=t.attributes.position;let o=0;if(null!==i){const t=i.array;o=i.version;for(let e=0,i=t.length;e<i;e+=3){const i=t[e+0],r=t[e+1],s=t[e+2];n.push(i,r,r,s,s,i)}}else{const t=r.array;o=r.version;for(let e=0,i=t.length/3-1;e<i;e+=3){const t=e+0,i=e+1,r=e+2;n.push(t,i,i,r,r,t)}}const a=new(ba(n)>65535?ga:fa)(n,1);a.version=o;const l=s.get(t);l&&e.remove(l),s.set(t,a)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",o),r[e.id]=!0,n.memory.geometries++),e},update:function(t){const n=t.attributes;for(const t in n)e.update(n[t],34962);const i=t.morphAttributes;for(const t in i){const n=i[t];for(let t=0,i=n.length;t<i;t++)e.update(n[t],34962)}},getWireframeAttribute:function(t){const e=s.get(t);if(e){const n=t.index;null!==n&&e.version<n.version&&a(t)}else a(t);return s.get(t)}}}function Ml(t,e,n,i){const r=i.isWebGL2;let s,o,a;this.setMode=function(t){s=t},this.setIndex=function(t){o=t.type,a=t.bytesPerElement},this.render=function(e,i){t.drawElements(s,i,o,e*a),n.update(i,s,1)},this.renderInstances=function(i,l,h){if(0===h)return;let c,u;if(r)c=t,u="drawElementsInstanced";else if(c=e.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===c)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");c[u](s,l,o,i*a,h),n.update(l,s,h)}}function _l(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.frame++,e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(t,n,i){switch(e.calls++,n){case 4:e.triangles+=i*(t/3);break;case 1:e.lines+=i*(t/2);break;case 3:e.lines+=i*(t-1);break;case 2:e.lines+=i*t;break;case 0:e.points+=i*t;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}function El(t,e){return t[0]-e[0]}function Sl(t,e){return Math.abs(e[1])-Math.abs(t[1])}function Tl(t){const e={},n=new Float32Array(8),i=[];for(let t=0;t<8;t++)i[t]=[t,0];return{update:function(r,s,o,a){const l=r.morphTargetInfluences,h=void 0===l?0:l.length;let c=e[s.id];if(void 0===c){c=[];for(let t=0;t<h;t++)c[t]=[t,0];e[s.id]=c}for(let t=0;t<h;t++){const e=c[t];e[0]=t,e[1]=l[t]}c.sort(Sl);for(let t=0;t<8;t++)t<h&&c[t][1]?(i[t][0]=c[t][0],i[t][1]=c[t][1]):(i[t][0]=Number.MAX_SAFE_INTEGER,i[t][1]=0);i.sort(El);const u=o.morphTargets&&s.morphAttributes.position,d=o.morphNormals&&s.morphAttributes.normal;let p=0;for(let t=0;t<8;t++){const e=i[t],r=e[0],o=e[1];r!==Number.MAX_SAFE_INTEGER&&o?(u&&s.getAttribute("morphTarget"+t)!==u[r]&&s.setAttribute("morphTarget"+t,u[r]),d&&s.getAttribute("morphNormal"+t)!==d[r]&&s.setAttribute("morphNormal"+t,d[r]),n[t]=o,p+=o):(u&&!0===s.hasAttribute("morphTarget"+t)&&s.deleteAttribute("morphTarget"+t),d&&!0===s.hasAttribute("morphNormal"+t)&&s.deleteAttribute("morphNormal"+t),n[t]=0)}const f=s.morphTargetsRelative?1:1-p;a.getUniforms().setValue(t,"morphTargetBaseInfluence",f),a.getUniforms().setValue(t,"morphTargetInfluences",n)}}}function Al(t,e,n,i){let r=new WeakMap;function s(t){const e=t.target;e.removeEventListener("dispose",s),n.remove(e.instanceMatrix),null!==e.instanceColor&&n.remove(e.instanceColor)}return{update:function(t){const o=i.render.frame,a=t.geometry,l=e.get(t,a);return r.get(l)!==o&&(e.update(l),r.set(l,o)),t.isInstancedMesh&&(!1===t.hasEventListener("dispose",s)&&t.addEventListener("dispose",s),n.update(t.instanceMatrix,34962),null!==t.instanceColor&&n.update(t.instanceColor,34962)),l},dispose:function(){r=new WeakMap}}}pl.physical={uniforms:Ja([pl.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new Ms(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new sa(0)},transmission:{value:0},transmissionMap:{value:null}}]),vertexShader:ul.meshphysical_vert,fragmentShader:ul.meshphysical_frag};class Pl extends As{constructor(t=null,e=1,n=1,i=1){super(null),this.image={data:t,width:e,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}}Pl.prototype.isDataTexture2DArray=!0;class Ll extends As{constructor(t=null,e=1,n=1,i=1){super(null),this.image={data:t,width:e,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}}Ll.prototype.isDataTexture3D=!0;const Rl=new As,Cl=new Pl,Il=new Ll,Ol=new nl,Dl=[],zl=[],Nl=new Float32Array(16),Ul=new Float32Array(9),Bl=new Float32Array(4);function Fl(t,e,n){const i=t[0];if(i<=0||i>0)return t;const r=e*n;let s=Dl[r];if(void 0===s&&(s=new Float32Array(r),Dl[r]=s),0!==e){i.toArray(s,0);for(let i=1,r=0;i!==e;++i)r+=n,t[i].toArray(s,r)}return s}function Vl(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n<i;n++)if(t[n]!==e[n])return!1;return!0}function kl(t,e){for(let n=0,i=e.length;n<i;n++)t[n]=e[n]}function Hl(t,e){let n=zl[e];void 0===n&&(n=new Int32Array(e),zl[e]=n);for(let i=0;i!==e;++i)n[i]=t.allocateTextureUnit();return n}function Gl(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function Wl(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Vl(n,e))return;t.uniform2fv(this.addr,e),kl(n,e)}}function jl(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(void 0!==e.r)n[0]===e.r&&n[1]===e.g&&n[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(Vl(n,e))return;t.uniform3fv(this.addr,e),kl(n,e)}}function Xl(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Vl(n,e))return;t.uniform4fv(this.addr,e),kl(n,e)}}function Yl(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(Vl(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),kl(n,e)}else{if(Vl(n,i))return;Bl.set(i),t.uniformMatrix2fv(this.addr,!1,Bl),kl(n,i)}}function ql(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(Vl(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),kl(n,e)}else{if(Vl(n,i))return;Ul.set(i),t.uniformMatrix3fv(this.addr,!1,Ul),kl(n,i)}}function Zl(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(Vl(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),kl(n,e)}else{if(Vl(n,i))return;Nl.set(i),t.uniformMatrix4fv(this.addr,!1,Nl),kl(n,i)}}function Jl(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function $l(t,e){const n=this.cache;Vl(n,e)||(t.uniform2iv(this.addr,e),kl(n,e))}function Ql(t,e){const n=this.cache;Vl(n,e)||(t.uniform3iv(this.addr,e),kl(n,e))}function Kl(t,e){const n=this.cache;Vl(n,e)||(t.uniform4iv(this.addr,e),kl(n,e))}function th(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function eh(t,e){const n=this.cache;Vl(n,e)||(t.uniform2uiv(this.addr,e),kl(n,e))}function nh(t,e){const n=this.cache;Vl(n,e)||(t.uniform3uiv(this.addr,e),kl(n,e))}function ih(t,e){const n=this.cache;Vl(n,e)||(t.uniform4uiv(this.addr,e),kl(n,e))}function rh(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.safeSetTexture2D(e||Rl,r)}function sh(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(e||Il,r)}function oh(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.safeSetTextureCube(e||Ol,r)}function ah(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(e||Cl,r)}function lh(t,e){t.uniform1fv(this.addr,e)}function hh(t,e){const n=Fl(e,this.size,2);t.uniform2fv(this.addr,n)}function ch(t,e){const n=Fl(e,this.size,3);t.uniform3fv(this.addr,n)}function uh(t,e){const n=Fl(e,this.size,4);t.uniform4fv(this.addr,n)}function dh(t,e){const n=Fl(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function ph(t,e){const n=Fl(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function fh(t,e){const n=Fl(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function mh(t,e){t.uniform1iv(this.addr,e)}function gh(t,e){t.uniform2iv(this.addr,e)}function vh(t,e){t.uniform3iv(this.addr,e)}function yh(t,e){t.uniform4iv(this.addr,e)}function xh(t,e){t.uniform1uiv(this.addr,e)}function bh(t,e){t.uniform2uiv(this.addr,e)}function wh(t,e){t.uniform3uiv(this.addr,e)}function Mh(t,e){t.uniform4uiv(this.addr,e)}function _h(t,e,n){const i=e.length,r=Hl(n,i);t.uniform1iv(this.addr,r);for(let t=0;t!==i;++t)n.safeSetTexture2D(e[t]||Rl,r[t])}function Eh(t,e,n){const i=e.length,r=Hl(n,i);t.uniform1iv(this.addr,r);for(let t=0;t!==i;++t)n.safeSetTextureCube(e[t]||Ol,r[t])}function Sh(t,e,n){this.id=t,this.addr=n,this.cache=[],this.setValue=function(t){switch(t){case 5126:return Gl;case 35664:return Wl;case 35665:return jl;case 35666:return Xl;case 35674:return Yl;case 35675:return ql;case 35676:return Zl;case 5124:case 35670:return Jl;case 35667:case 35671:return $l;case 35668:case 35672:return Ql;case 35669:case 35673:return Kl;case 5125:return th;case 36294:return eh;case 36295:return nh;case 36296:return ih;case 35678:case 36198:case 36298:case 36306:case 35682:return rh;case 35679:case 36299:case 36307:return sh;case 35680:case 36300:case 36308:case 36293:return oh;case 36289:case 36303:case 36311:case 36292:return ah}}(e.type)}function Th(t,e,n){this.id=t,this.addr=n,this.cache=[],this.size=e.size,this.setValue=function(t){switch(t){case 5126:return lh;case 35664:return hh;case 35665:return ch;case 35666:return uh;case 35674:return dh;case 35675:return ph;case 35676:return fh;case 5124:case 35670:return mh;case 35667:case 35671:return gh;case 35668:case 35672:return vh;case 35669:case 35673:return yh;case 5125:return xh;case 36294:return bh;case 36295:return wh;case 36296:return Mh;case 35678:case 36198:case 36298:case 36306:case 35682:return _h;case 35680:case 36300:case 36308:case 36293:return Eh}}(e.type)}function Ah(t){this.id=t,this.seq=[],this.map={}}Th.prototype.updateCache=function(t){const e=this.cache;t instanceof Float32Array&&e.length!==t.length&&(this.cache=new Float32Array(t.length)),kl(e,t)},Ah.prototype.setValue=function(t,e,n){const i=this.seq;for(let r=0,s=i.length;r!==s;++r){const s=i[r];s.setValue(t,e[s.id],n)}};const Ph=/(\w+)(\])?(\[|\.)?/g;function Lh(t,e){t.seq.push(e),t.map[e.id]=e}function Rh(t,e,n){const i=t.name,r=i.length;for(Ph.lastIndex=0;;){const s=Ph.exec(i),o=Ph.lastIndex;let a=s[1];const l="]"===s[2],h=s[3];if(l&&(a|=0),void 0===h||"["===h&&o+2===r){Lh(n,void 0===h?new Sh(a,t,e):new Th(a,t,e));break}{let t=n.map[a];void 0===t&&(t=new Ah(a),Lh(n,t)),n=t}}}function Ch(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,35718);for(let i=0;i<n;++i){const n=t.getActiveUniform(e,i);Rh(n,t.getUniformLocation(e,n.name),this)}}function Ih(t,e,n){const i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),i}Ch.prototype.setValue=function(t,e,n,i){const r=this.map[e];void 0!==r&&r.setValue(t,n,i)},Ch.prototype.setOptional=function(t,e,n){const i=e[n];void 0!==i&&this.setValue(t,n,i)},Ch.upload=function(t,e,n,i){for(let r=0,s=e.length;r!==s;++r){const s=e[r],o=n[s.id];!1!==o.needsUpdate&&s.setValue(t,o.value,i)}},Ch.seqWithValue=function(t,e){const n=[];for(let i=0,r=t.length;i!==r;++i){const r=t[i];r.id in e&&n.push(r)}return n};let Oh=0;function Dh(t){switch(t){case 3e3:return["Linear","( value )"];case 3001:return["sRGB","( value )"];case 3002:return["RGBE","( value )"];case 3004:return["RGBM","( value, 7.0 )"];case 3005:return["RGBM","( value, 16.0 )"];case 3006:return["RGBD","( value, 256.0 )"];case 3007:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case 3003:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",t),["Linear","( value )"]}}function zh(t,e,n){const i=t.getShaderParameter(e,35713),r=t.getShaderInfoLog(e).trim();if(i&&""===r)return"";return"THREE.WebGLShader: gl.getShaderInfoLog() "+n+"\n"+r+function(t){const e=t.split("\n");for(let t=0;t<e.length;t++)e[t]=t+1+": "+e[t];return e.join("\n")}(t.getShaderSource(e))}function Nh(t,e){const n=Dh(e);return"vec4 "+t+"( vec4 value ) { return "+n[0]+"ToLinear"+n[1]+"; }"}function Uh(t,e){const n=Dh(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function Bh(t,e){let n;switch(e){case 1:n="Linear";break;case 2:n="Reinhard";break;case 3:n="OptimizedCineon";break;case 4:n="ACESFilmic";break;case 5:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Fh(t){return""!==t}function Vh(t,e){return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function kh(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Hh=/^[ \t]*#include +<([\w\d./]+)>/gm;function Gh(t){return t.replace(Hh,Wh)}function Wh(t,e){const n=ul[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return Gh(n)}const jh=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,Xh=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Yh(t){return t.replace(Xh,Zh).replace(jh,qh)}function qh(t,e,n,i){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),Zh(t,e,n,i)}function Zh(t,e,n,i){let r="";for(let t=parseInt(e);t<parseInt(n);t++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function Jh(t){let e="precision "+t.precision+" float;\nprecision "+t.precision+" int;";return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function $h(t,e,n,i){const r=t.getContext(),s=n.defines;let o=n.vertexShader,a=n.fragmentShader;const l=function(t){let e="SHADOWMAP_TYPE_BASIC";return 1===t.shadowMapType?e="SHADOWMAP_TYPE_PCF":2===t.shadowMapType?e="SHADOWMAP_TYPE_PCF_SOFT":3===t.shadowMapType&&(e="SHADOWMAP_TYPE_VSM"),e}(n),h=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case 301:case 302:e="ENVMAP_TYPE_CUBE";break;case 306:case 307:e="ENVMAP_TYPE_CUBE_UV"}return e}(n),c=function(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case 302:case 307:e="ENVMAP_MODE_REFRACTION"}return e}(n),u=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD"}return e}(n),d=t.gammaFactor>0?t.gammaFactor:1,p=n.isWebGL2?"":function(t){return[t.extensionDerivatives||t.envMapCubeUV||t.bumpMap||t.tangentSpaceNormalMap||t.clearcoatNormalMap||t.flatShading||"physical"===t.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Fh).join("\n")}(n),f=function(t){const e=[];for(const n in t){const i=t[n];!1!==i&&e.push("#define "+n+" "+i)}return e.join("\n")}(s),m=r.createProgram();let g,v,y=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(g=[f].filter(Fh).join("\n"),g.length>0&&(g+="\n"),v=[p,f].filter(Fh).join("\n"),v.length>0&&(v+="\n")):(g=[Jh(n),"#define SHADER_NAME "+n.shaderName,f,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+d,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Fh).join("\n"),v=[p,Jh(n),"#define SHADER_NAME "+n.shaderName,f,n.alphaTest?"#define ALPHATEST "+n.alphaTest+(n.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+d,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.sheen?"#define USE_SHEEN":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?ul.tonemapping_pars_fragment:"",0!==n.toneMapping?Bh("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",ul.encodings_pars_fragment,n.map?Nh("mapTexelToLinear",n.mapEncoding):"",n.matcap?Nh("matcapTexelToLinear",n.matcapEncoding):"",n.envMap?Nh("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMap?Nh("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.lightMap?Nh("lightMapTexelToLinear",n.lightMapEncoding):"",Uh("linearToOutputTexel",n.outputEncoding),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Fh).join("\n")),o=Gh(o),o=Vh(o,n),o=kh(o,n),a=Gh(a),a=Vh(a,n),a=kh(a,n),o=Yh(o),a=Yh(a),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",g=["#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in","300 es"===n.glslVersion?"":"out highp vec4 pc_fragColor;","300 es"===n.glslVersion?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v);const x=y+v+a,b=Ih(r,35633,y+g+o),w=Ih(r,35632,x);if(r.attachShader(m,b),r.attachShader(m,w),void 0!==n.index0AttributeName?r.bindAttribLocation(m,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(m,0,"position"),r.linkProgram(m),t.debug.checkShaderErrors){const t=r.getProgramInfoLog(m).trim(),e=r.getShaderInfoLog(b).trim(),n=r.getShaderInfoLog(w).trim();let i=!0,s=!0;if(!1===r.getProgramParameter(m,35714)){i=!1;const e=zh(r,b,"vertex"),n=zh(r,w,"fragment");console.error("THREE.WebGLProgram: shader error: ",r.getError(),"35715",r.getProgramParameter(m,35715),"gl.getProgramInfoLog",t,e,n)}else""!==t?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",t):""!==e&&""!==n||(s=!1);s&&(this.diagnostics={runnable:i,programLog:t,vertexShader:{log:e,prefix:g},fragmentShader:{log:n,prefix:v}})}let M,_;return r.deleteShader(b),r.deleteShader(w),this.getUniforms=function(){return void 0===M&&(M=new Ch(r,m)),M},this.getAttributes=function(){return void 0===_&&(_=function(t,e){const n={},i=t.getProgramParameter(e,35721);for(let r=0;r<i;r++){const i=t.getActiveAttrib(e,r).name;n[i]=t.getAttribLocation(e,i)}return n}(r,m)),_},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.name=n.shaderName,this.id=Oh++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=b,this.fragmentShader=w,this}function Qh(t,e,n,i,r,s){const o=[],a=i.isWebGL2,l=i.logarithmicDepthBuffer,h=i.floatVertexTextures,c=i.maxVertexUniforms,u=i.vertexTextures;let d=i.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},f=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexAlphas","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen","transmissionMap"];function m(t){let e;return t&&t.isTexture?e=t.encoding:t&&t.isWebGLRenderTarget?(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),e=t.texture.encoding):e=3e3,e}return{getParameters:function(r,o,f,g,v){const y=g.fog,x=r.isMeshStandardMaterial?g.environment:null,b=e.get(r.envMap||x),w=p[r.type],M=v.isSkinnedMesh?function(t){const e=t.skeleton.bones;if(h)return 1024;{const t=c,n=Math.floor((t-20)/4),i=Math.min(n,e.length);return i<e.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+e.length+" bones. This GPU supports "+i+"."),0):i}}(v):0;let _,E;if(null!==r.precision&&(d=i.getMaxPrecision(r.precision),d!==r.precision&&console.warn("THREE.WebGLProgram.getParameters:",r.precision,"not supported, using",d,"instead.")),w){const t=pl[w];_=t.vertexShader,E=t.fragmentShader}else _=r.vertexShader,E=r.fragmentShader;const S=t.getRenderTarget();return{isWebGL2:a,shaderID:w,shaderName:r.type,vertexShader:_,fragmentShader:E,defines:r.defines,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:d,instancing:!0===v.isInstancedMesh,instancingColor:!0===v.isInstancedMesh&&null!==v.instanceColor,supportsVertexTextures:u,outputEncoding:null!==S?m(S.texture):t.outputEncoding,map:!!r.map,mapEncoding:m(r.map),matcap:!!r.matcap,matcapEncoding:m(r.matcap),envMap:!!b,envMapMode:b&&b.mapping,envMapEncoding:m(b),envMapCubeUV:!!b&&(306===b.mapping||307===b.mapping),lightMap:!!r.lightMap,lightMapEncoding:m(r.lightMap),aoMap:!!r.aoMap,emissiveMap:!!r.emissiveMap,emissiveMapEncoding:m(r.emissiveMap),bumpMap:!!r.bumpMap,normalMap:!!r.normalMap,objectSpaceNormalMap:1===r.normalMapType,tangentSpaceNormalMap:0===r.normalMapType,clearcoatMap:!!r.clearcoatMap,clearcoatRoughnessMap:!!r.clearcoatRoughnessMap,clearcoatNormalMap:!!r.clearcoatNormalMap,displacementMap:!!r.displacementMap,roughnessMap:!!r.roughnessMap,metalnessMap:!!r.metalnessMap,specularMap:!!r.specularMap,alphaMap:!!r.alphaMap,gradientMap:!!r.gradientMap,sheen:!!r.sheen,transmissionMap:!!r.transmissionMap,combine:r.combine,vertexTangents:r.normalMap&&r.vertexTangents,vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&v.geometry.attributes.color&&4===v.geometry.attributes.color.itemSize,vertexUvs:!!(r.map||r.bumpMap||r.normalMap||r.specularMap||r.alphaMap||r.emissiveMap||r.roughnessMap||r.metalnessMap||r.clearcoatMap||r.clearcoatRoughnessMap||r.clearcoatNormalMap||r.displacementMap||r.transmissionMap),uvsVertexOnly:!(r.map||r.bumpMap||r.normalMap||r.specularMap||r.alphaMap||r.emissiveMap||r.roughnessMap||r.metalnessMap||r.clearcoatNormalMap||r.transmissionMap||!r.displacementMap),fog:!!y,useFog:r.fog,fogExp2:y&&y.isFogExp2,flatShading:!!r.flatShading,sizeAttenuation:r.sizeAttenuation,logarithmicDepthBuffer:l,skinning:r.skinning&&M>0,maxBones:M,useVertexTexture:h,morphTargets:r.morphTargets,morphNormals:r.morphNormals,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:r.dithering,shadowMapEnabled:t.shadowMap.enabled&&f.length>0,shadowMapType:t.shadowMap.type,toneMapping:r.toneMapped?t.toneMapping:0,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:r.premultipliedAlpha,alphaTest:r.alphaTest,doubleSided:2===r.side,flipSided:1===r.side,depthPacking:void 0!==r.depthPacking&&r.depthPacking,index0AttributeName:r.index0AttributeName,extensionDerivatives:r.extensions&&r.extensions.derivatives,extensionFragDepth:r.extensions&&r.extensions.fragDepth,extensionDrawBuffers:r.extensions&&r.extensions.drawBuffers,extensionShaderTextureLOD:r.extensions&&r.extensions.shaderTextureLOD,rendererExtensionFragDepth:a||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:a||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:a||n.has("EXT_shader_texture_lod"),customProgramCacheKey:r.customProgramCacheKey()}},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.fragmentShader),n.push(e.vertexShader)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.push(e.defines[t]);if(!1===e.isRawShaderMaterial){for(let t=0;t<f.length;t++)n.push(e[f[t]]);n.push(t.outputEncoding),n.push(t.gammaFactor)}return n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){const e=p[t.type];let n;if(e){const t=pl[e];n=$a.clone(t.uniforms)}else n=t.uniforms;return n},acquireProgram:function(e,n){let i;for(let t=0,e=o.length;t<e;t++){const e=o[t];if(e.cacheKey===n){i=e,++i.usedTimes;break}}return void 0===i&&(i=new $h(t,n,e,r),o.push(i)),i},releaseProgram:function(t){if(0==--t.usedTimes){const e=o.indexOf(t);o[e]=o[o.length-1],o.pop(),t.destroy()}},programs:o}}function Kh(){let t=new WeakMap;return{get:function(e){let n=t.get(e);return void 0===n&&(n={},t.set(e,n)),n},remove:function(e){t.delete(e)},update:function(e,n,i){t.get(e)[n]=i},dispose:function(){t=new WeakMap}}}function tc(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.program!==e.program?t.program.id-e.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function ec(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function nc(t){const e=[];let n=0;const i=[],r=[],s={id:-1};function o(i,r,o,a,l,h){let c=e[n];const u=t.get(o);return void 0===c?(c={id:i.id,object:i,geometry:r,material:o,program:u.program||s,groupOrder:a,renderOrder:i.renderOrder,z:l,group:h},e[n]=c):(c.id=i.id,c.object=i,c.geometry=r,c.material=o,c.program=u.program||s,c.groupOrder=a,c.renderOrder=i.renderOrder,c.z=l,c.group=h),n++,c}return{opaque:i,transparent:r,init:function(){n=0,i.length=0,r.length=0},push:function(t,e,n,s,a,l){const h=o(t,e,n,s,a,l);(!0===n.transparent?r:i).push(h)},unshift:function(t,e,n,s,a,l){const h=o(t,e,n,s,a,l);(!0===n.transparent?r:i).unshift(h)},finish:function(){for(let t=n,i=e.length;t<i;t++){const n=e[t];if(null===n.id)break;n.id=null,n.object=null,n.geometry=null,n.material=null,n.program=null,n.group=null}},sort:function(t,e){i.length>1&&i.sort(t||tc),r.length>1&&r.sort(e||ec)}}}function ic(t){let e=new WeakMap;return{get:function(n,i){let r;return!1===e.has(n)?(r=new nc(t),e.set(n,[r])):i>=e.get(n).length?(r=new nc(t),e.get(n).push(r)):r=e.get(n)[i],r},dispose:function(){e=new WeakMap}}}function rc(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Is,color:new sa};break;case"SpotLight":n={position:new Is,direction:new Is,color:new sa,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Is,color:new sa,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Is,skyColor:new sa,groundColor:new sa};break;case"RectAreaLight":n={color:new sa,position:new Is,halfWidth:new Is,halfHeight:new Is}}return t[e.id]=n,n}}}let sc=0;function oc(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function ac(t,e){const n=new rc,i=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ms};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ms,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let t=0;t<9;t++)r.probe.push(new Is);const s=new Is,o=new ho,a=new ho;return{setup:function(s){let o=0,a=0,l=0;for(let t=0;t<9;t++)r.probe[t].set(0,0,0);let h=0,c=0,u=0,d=0,p=0,f=0,m=0,g=0;s.sort(oc);for(let t=0,e=s.length;t<e;t++){const e=s[t],v=e.color,y=e.intensity,x=e.distance,b=e.shadow&&e.shadow.map?e.shadow.map.texture:null;if(e.isAmbientLight)o+=v.r*y,a+=v.g*y,l+=v.b*y;else if(e.isLightProbe)for(let t=0;t<9;t++)r.probe[t].addScaledVector(e.sh.coefficients[t],y);else if(e.isDirectionalLight){const t=n.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity),e.castShadow){const t=e.shadow,n=i.get(e);n.shadowBias=t.bias,n.shadowNormalBias=t.normalBias,n.shadowRadius=t.radius,n.shadowMapSize=t.mapSize,r.directionalShadow[h]=n,r.directionalShadowMap[h]=b,r.directionalShadowMatrix[h]=e.shadow.matrix,f++}r.directional[h]=t,h++}else if(e.isSpotLight){const t=n.get(e);if(t.position.setFromMatrixPosition(e.matrixWorld),t.color.copy(v).multiplyScalar(y),t.distance=x,t.coneCos=Math.cos(e.angle),t.penumbraCos=Math.cos(e.angle*(1-e.penumbra)),t.decay=e.decay,e.castShadow){const t=e.shadow,n=i.get(e);n.shadowBias=t.bias,n.shadowNormalBias=t.normalBias,n.shadowRadius=t.radius,n.shadowMapSize=t.mapSize,r.spotShadow[u]=n,r.spotShadowMap[u]=b,r.spotShadowMatrix[u]=e.shadow.matrix,g++}r.spot[u]=t,u++}else if(e.isRectAreaLight){const t=n.get(e);t.color.copy(v).multiplyScalar(y),t.halfWidth.set(.5*e.width,0,0),t.halfHeight.set(0,.5*e.height,0),r.rectArea[d]=t,d++}else if(e.isPointLight){const t=n.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity),t.distance=e.distance,t.decay=e.decay,e.castShadow){const t=e.shadow,n=i.get(e);n.shadowBias=t.bias,n.shadowNormalBias=t.normalBias,n.shadowRadius=t.radius,n.shadowMapSize=t.mapSize,n.shadowCameraNear=t.camera.near,n.shadowCameraFar=t.camera.far,r.pointShadow[c]=n,r.pointShadowMap[c]=b,r.pointShadowMatrix[c]=e.shadow.matrix,m++}r.point[c]=t,c++}else if(e.isHemisphereLight){const t=n.get(e);t.skyColor.copy(e.color).multiplyScalar(y),t.groundColor.copy(e.groundColor).multiplyScalar(y),r.hemi[p]=t,p++}}d>0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(r.rectAreaLTC1=dl.LTC_FLOAT_1,r.rectAreaLTC2=dl.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=dl.LTC_HALF_1,r.rectAreaLTC2=dl.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=a,r.ambient[2]=l;const v=r.hash;v.directionalLength===h&&v.pointLength===c&&v.spotLength===u&&v.rectAreaLength===d&&v.hemiLength===p&&v.numDirectionalShadows===f&&v.numPointShadows===m&&v.numSpotShadows===g||(r.directional.length=h,r.spot.length=u,r.rectArea.length=d,r.point.length=c,r.hemi.length=p,r.directionalShadow.length=f,r.directionalShadowMap.length=f,r.pointShadow.length=m,r.pointShadowMap.length=m,r.spotShadow.length=g,r.spotShadowMap.length=g,r.directionalShadowMatrix.length=f,r.pointShadowMatrix.length=m,r.spotShadowMatrix.length=g,v.directionalLength=h,v.pointLength=c,v.spotLength=u,v.rectAreaLength=d,v.hemiLength=p,v.numDirectionalShadows=f,v.numPointShadows=m,v.numSpotShadows=g,r.version=sc++)},setupView:function(t,e){let n=0,i=0,l=0,h=0,c=0;const u=e.matrixWorldInverse;for(let e=0,d=t.length;e<d;e++){const d=t[e];if(d.isDirectionalLight){const t=r.directional[n];t.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(s),t.direction.transformDirection(u),n++}else if(d.isSpotLight){const t=r.spot[l];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),t.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(s),t.direction.transformDirection(u),l++}else if(d.isRectAreaLight){const t=r.rectArea[h];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),a.identity(),o.copy(d.matrixWorld),o.premultiply(u),a.extractRotation(o),t.halfWidth.set(.5*d.width,0,0),t.halfHeight.set(0,.5*d.height,0),t.halfWidth.applyMatrix4(a),t.halfHeight.applyMatrix4(a),h++}else if(d.isPointLight){const t=r.point[i];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),i++}else if(d.isHemisphereLight){const t=r.hemi[c];t.direction.setFromMatrixPosition(d.matrixWorld),t.direction.transformDirection(u),t.direction.normalize(),c++}}},state:r}}function lc(t,e){const n=new ac(t,e),i=[],r=[];return{init:function(){i.length=0,r.length=0},state:{lightsArray:i,shadowsArray:r,lights:n},setupLights:function(){n.setup(i)},setupLightsView:function(t){n.setupView(i,t)},pushLight:function(t){i.push(t)},pushShadow:function(t){r.push(t)}}}function hc(t,e){let n=new WeakMap;return{get:function(i,r=0){let s;return!1===n.has(i)?(s=new lc(t,e),n.set(i,[s])):r>=n.get(i).length?(s=new lc(t,e),n.get(i).push(s)):s=n.get(i)[r],s},dispose:function(){n=new WeakMap}}}class cc extends Qo{constructor(t){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}cc.prototype.isMeshDepthMaterial=!0;class uc extends Qo{constructor(t){super(),this.type="MeshDistanceMaterial",this.referencePosition=new Is,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(t)}copy(t){return super.copy(t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}uc.prototype.isMeshDistanceMaterial=!0;function dc(t,e,n){let i=new al;const r=new Ms,s=new Ms,o=new Ls,a=[],l=[],h={},c=n.maxTextureSize,u={0:1,1:0,2:2},d=new Qa({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ms},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n\tfor ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean * HALF_SAMPLE_RATE;\n\tsquared_mean = squared_mean * HALF_SAMPLE_RATE;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const f=new Pa;f.setAttribute("position",new ha(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Xa(f,d),g=this;function v(n,i){const r=e.update(m);d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(i,null,r,d,m,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(i,null,r,p,m,null)}function y(t,e,n){const i=t<<0|e<<1|n<<2;let r=a[i];return void 0===r&&(r=new cc({depthPacking:3201,morphTargets:t,skinning:e}),a[i]=r),r}function x(t,e,n){const i=t<<0|e<<1|n<<2;let r=l[i];return void 0===r&&(r=new uc({morphTargets:t,skinning:e}),l[i]=r),r}function b(e,n,i,r,s,o,a){let l=null,c=y,d=e.customDepthMaterial;if(!0===r.isPointLight&&(c=x,d=e.customDistanceMaterial),void 0===d){let t=!1;!0===i.morphTargets&&(t=n.morphAttributes&&n.morphAttributes.position&&n.morphAttributes.position.length>0);let r=!1;!0===e.isSkinnedMesh&&(!0===i.skinning?r=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e));l=c(t,r,!0===e.isInstancedMesh)}else l=d;if(t.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length){const t=l.uuid,e=i.uuid;let n=h[t];void 0===n&&(n={},h[t]=n);let r=n[e];void 0===r&&(r=l.clone(),n[e]=r),l=r}return l.visible=i.visible,l.wireframe=i.wireframe,l.side=3===a?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:u[i.side],l.clipShadows=i.clipShadows,l.clippingPlanes=i.clippingPlanes,l.clipIntersection=i.clipIntersection,l.wireframeLinewidth=i.wireframeLinewidth,l.linewidth=i.linewidth,!0===r.isPointLight&&!0===l.isMeshDistanceMaterial&&(l.referencePosition.setFromMatrixPosition(r.matrixWorld),l.nearDistance=s,l.farDistance=o),l}function w(n,r,s,o,a){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===a)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const i=e.update(n),r=n.material;if(Array.isArray(r)){const e=i.groups;for(let l=0,h=e.length;l<h;l++){const h=e[l],c=r[h.materialIndex];if(c&&c.visible){const e=b(n,i,c,o,s.near,s.far,a);t.renderBufferDirect(s,null,i,e,n,h)}}}else if(r.visible){const e=b(n,i,r,o,s.near,s.far,a);t.renderBufferDirect(s,null,i,e,n,null)}}const l=n.children;for(let t=0,e=l.length;t<e;t++)w(l[t],r,s,o,a)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1,this.render=function(e,n,a){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===e.length)return;const l=t.getRenderTarget(),h=t.getActiveCubeFace(),u=t.getActiveMipmapLevel(),d=t.state;d.setBlending(0),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);for(let l=0,h=e.length;l<h;l++){const h=e[l],u=h.shadow;if(void 0===u){console.warn("THREE.WebGLShadowMap:",h,"has no shadow.");continue}if(!1===u.autoUpdate&&!1===u.needsUpdate)continue;r.copy(u.mapSize);const p=u.getFrameExtents();if(r.multiply(p),s.copy(u.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(s.x=Math.floor(c/p.x),r.x=s.x*p.x,u.mapSize.x=s.x),r.y>c&&(s.y=Math.floor(c/p.y),r.y=s.y*p.y,u.mapSize.y=s.y)),null===u.map&&!u.isPointLightShadow&&3===this.type){const t={minFilter:1006,magFilter:1006,format:1023};u.map=new Rs(r.x,r.y,t),u.map.texture.name=h.name+".shadowMap",u.mapPass=new Rs(r.x,r.y,t),u.camera.updateProjectionMatrix()}if(null===u.map){const t={minFilter:1003,magFilter:1003,format:1023};u.map=new Rs(r.x,r.y,t),u.map.texture.name=h.name+".shadowMap",u.camera.updateProjectionMatrix()}t.setRenderTarget(u.map),t.clear();const f=u.getViewportCount();for(let t=0;t<f;t++){const e=u.getViewport(t);o.set(s.x*e.x,s.y*e.y,s.x*e.z,s.y*e.w),d.viewport(o),u.updateMatrices(h,t),i=u.getFrustum(),w(n,a,u.camera,h,this.type)}u.isPointLightShadow||3!==this.type||v(u,a),u.needsUpdate=!1}g.needsUpdate=!1,t.setRenderTarget(l,h,u)}}function pc(t,e,n){const i=n.isWebGL2;const r=new function(){let e=!1;const n=new Ls;let i=null;const r=new Ls(0,0,0,0);return{setMask:function(n){i===n||e||(t.colorMask(n,n,n,n),i=n)},setLocked:function(t){e=t},setClear:function(e,i,s,o,a){!0===a&&(e*=o,i*=o,s*=o),n.set(e,i,s,o),!1===r.equals(n)&&(t.clearColor(e,i,s,o),r.copy(n))},reset:function(){e=!1,i=null,r.set(-1,0,0,0)}}},s=new function(){let e=!1,n=null,i=null,r=null;return{setTest:function(t){t?z(2929):N(2929)},setMask:function(i){n===i||e||(t.depthMask(i),n=i)},setFunc:function(e){if(i!==e){if(e)switch(e){case 0:t.depthFunc(512);break;case 1:t.depthFunc(519);break;case 2:t.depthFunc(513);break;case 3:t.depthFunc(515);break;case 4:t.depthFunc(514);break;case 5:t.depthFunc(518);break;case 6:t.depthFunc(516);break;case 7:t.depthFunc(517);break;default:t.depthFunc(515)}else t.depthFunc(515);i=e}},setLocked:function(t){e=t},setClear:function(e){r!==e&&(t.clearDepth(e),r=e)},reset:function(){e=!1,n=null,i=null,r=null}}},o=new function(){let e=!1,n=null,i=null,r=null,s=null,o=null,a=null,l=null,h=null;return{setTest:function(t){e||(t?z(2960):N(2960))},setMask:function(i){n===i||e||(t.stencilMask(i),n=i)},setFunc:function(e,n,o){i===e&&r===n&&s===o||(t.stencilFunc(e,n,o),i=e,r=n,s=o)},setOp:function(e,n,i){o===e&&a===n&&l===i||(t.stencilOp(e,n,i),o=e,a=n,l=i)},setLocked:function(t){e=t},setClear:function(e){h!==e&&(t.clearStencil(e),h=e)},reset:function(){e=!1,n=null,i=null,r=null,s=null,o=null,a=null,l=null,h=null}}};let a={},l=null,h={},c=null,u=!1,d=null,p=null,f=null,m=null,g=null,v=null,y=null,x=!1,b=null,w=null,M=null,_=null,E=null;const S=t.getParameter(35661);let T=!1,A=0;const P=t.getParameter(7938);-1!==P.indexOf("WebGL")?(A=parseFloat(/^WebGL (\d)/.exec(P)[1]),T=A>=1):-1!==P.indexOf("OpenGL ES")&&(A=parseFloat(/^OpenGL ES (\d)/.exec(P)[1]),T=A>=2);let L=null,R={};const C=new Ls(0,0,t.canvas.width,t.canvas.height),I=new Ls(0,0,t.canvas.width,t.canvas.height);function O(e,n,i){const r=new Uint8Array(4),s=t.createTexture();t.bindTexture(e,s),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(let e=0;e<i;e++)t.texImage2D(n+e,0,6408,1,1,0,6408,5121,r);return s}const D={};function z(e){!0!==a[e]&&(t.enable(e),a[e]=!0)}function N(e){!1!==a[e]&&(t.disable(e),a[e]=!1)}D[3553]=O(3553,3553,1),D[34067]=O(34067,34069,6),r.setClear(0,0,0,1),s.setClear(1),o.setClear(0),z(2929),s.setFunc(3),V(!1),k(1),z(2884),F(0);const U={100:32774,101:32778,102:32779};if(i)U[103]=32775,U[104]=32776;else{const t=e.get("EXT_blend_minmax");null!==t&&(U[103]=t.MIN_EXT,U[104]=t.MAX_EXT)}const B={200:0,201:1,202:768,204:770,210:776,208:774,206:772,203:769,205:771,209:775,207:773};function F(e,n,i,r,s,o,a,l){if(0!==e){if(!1===u&&(z(3042),u=!0),5===e)s=s||n,o=o||i,a=a||r,n===p&&s===g||(t.blendEquationSeparate(U[n],U[s]),p=n,g=s),i===f&&r===m&&o===v&&a===y||(t.blendFuncSeparate(B[i],B[r],B[o],B[a]),f=i,m=r,v=o,y=a),d=e,x=null;else if(e!==d||l!==x){if(100===p&&100===g||(t.blendEquation(32774),p=100,g=100),l)switch(e){case 1:t.blendFuncSeparate(1,771,1,771);break;case 2:t.blendFunc(1,1);break;case 3:t.blendFuncSeparate(0,0,769,771);break;case 4:t.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(770,771,1,771);break;case 2:t.blendFunc(770,1);break;case 3:t.blendFunc(0,769);break;case 4:t.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}f=null,m=null,v=null,y=null,d=e,x=l}}else!0===u&&(N(3042),u=!1)}function V(e){b!==e&&(e?t.frontFace(2304):t.frontFace(2305),b=e)}function k(e){0!==e?(z(2884),e!==w&&(1===e?t.cullFace(1029):2===e?t.cullFace(1028):t.cullFace(1032))):N(2884),w=e}function H(e,n,i){e?(z(32823),_===n&&E===i||(t.polygonOffset(n,i),_=n,E=i)):N(32823)}function G(e){void 0===e&&(e=33984+S-1),L!==e&&(t.activeTexture(e),L=e)}return{buffers:{color:r,depth:s,stencil:o},enable:z,disable:N,bindFramebuffer:function(e,n){null===n&&null!==l&&(n=l),h[e]!==n&&(t.bindFramebuffer(e,n),h[e]=n)},bindXRFramebuffer:function(e){e!==l&&(t.bindFramebuffer(36160,e),l=e)},useProgram:function(e){return c!==e&&(t.useProgram(e),c=e,!0)},setBlending:F,setMaterial:function(t,e){2===t.side?N(2884):z(2884);let n=1===t.side;e&&(n=!n),V(n),1===t.blending&&!1===t.transparent?F(0):F(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),s.setFunc(t.depthFunc),s.setTest(t.depthTest),s.setMask(t.depthWrite),r.setMask(t.colorWrite);const i=t.stencilWrite;o.setTest(i),i&&(o.setMask(t.stencilWriteMask),o.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),o.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),H(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?z(32926):N(32926)},setFlipSided:V,setCullFace:k,setLineWidth:function(e){e!==M&&(T&&t.lineWidth(e),M=e)},setPolygonOffset:H,setScissorTest:function(t){t?z(3089):N(3089)},activeTexture:G,bindTexture:function(e,n){null===L&&G();let i=R[L];void 0===i&&(i={type:void 0,texture:void 0},R[L]=i),i.type===e&&i.texture===n||(t.bindTexture(e,n||D[e]),i.type=e,i.texture=n)},unbindTexture:function(){const e=R[L];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===C.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),C.copy(e))},viewport:function(e){!1===I.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),I.copy(e))},reset:function(){t.disable(3042),t.disable(2884),t.disable(2929),t.disable(32823),t.disable(3089),t.disable(2960),t.disable(32926),t.blendEquation(32774),t.blendFunc(1,0),t.blendFuncSeparate(1,0,1,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(513),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(519,0,4294967295),t.stencilOp(7680,7680,7680),t.clearStencil(0),t.cullFace(1029),t.frontFace(2305),t.polygonOffset(0,0),t.activeTexture(33984),t.bindFramebuffer(36160,null),!0===i&&(t.bindFramebuffer(36009,null),t.bindFramebuffer(36008,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),a={},L=null,R={},l=null,h={},c=null,u=!1,d=null,p=null,f=null,m=null,g=null,v=null,y=null,x=!1,b=null,w=null,M=null,_=null,E=null,C.set(0,0,t.canvas.width,t.canvas.height),I.set(0,0,t.canvas.width,t.canvas.height),r.reset(),s.reset(),o.reset()}}}function fc(t,e,n,i,r,s,o){const a=r.isWebGL2,l=r.maxTextures,h=r.maxCubemapSize,c=r.maxTextureSize,u=r.maxSamples,d=new WeakMap;let p,f=!1;try{f="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function m(t,e){return f?new OffscreenCanvas(t,e):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function g(t,e,n,i){let r=1;if((t.width>i||t.height>i)&&(r=i/Math.max(t.width,t.height)),r<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const i=e?ws.floorPowerOfTwo:Math.floor,s=i(r*t.width),o=i(r*t.height);void 0===p&&(p=m(s,o));const a=n?m(s,o):p;a.width=s,a.height=o;return a.getContext("2d").drawImage(t,0,0,s,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+s+"x"+o+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function v(t){return ws.isPowerOfTwo(t.width)&&ws.isPowerOfTwo(t.height)}function y(t,e){return t.generateMipmaps&&e&&1003!==t.minFilter&&1006!==t.minFilter}function x(e,n,r,s){t.generateMipmap(e);i.get(n).__maxMipLevel=Math.log2(Math.max(r,s))}function b(n,i,r){if(!1===a)return i;if(null!==n){if(void 0!==t[n])return t[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let s=i;return 6403===i&&(5126===r&&(s=33326),5131===r&&(s=33325),5121===r&&(s=33321)),6407===i&&(5126===r&&(s=34837),5131===r&&(s=34843),5121===r&&(s=32849)),6408===i&&(5126===r&&(s=34836),5131===r&&(s=34842),5121===r&&(s=32856)),33325!==s&&33326!==s&&34842!==s&&34836!==s||e.get("EXT_color_buffer_float"),s}function w(t){return 1003===t||1004===t||1005===t?9728:9729}function M(e){const n=e.target;n.removeEventListener("dispose",M),function(e){const n=i.get(e);if(void 0===n.__webglInit)return;t.deleteTexture(n.__webglTexture),i.remove(e)}(n),n.isVideoTexture&&d.delete(n),o.memory.textures--}function _(e){const n=e.target;n.removeEventListener("dispose",_),function(e){const n=e.texture,r=i.get(e),s=i.get(n);if(!e)return;void 0!==s.__webglTexture&&t.deleteTexture(s.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)t.deleteFramebuffer(r.__webglFramebuffer[e]),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer[e]);else t.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&t.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer&&t.deleteRenderbuffer(r.__webglColorRenderbuffer),r.__webglDepthRenderbuffer&&t.deleteRenderbuffer(r.__webglDepthRenderbuffer);i.remove(n),i.remove(e)}(n),o.memory.textures--}let E=0;function S(t,e){const r=i.get(t);if(t.isVideoTexture&&function(t){const e=o.render.frame;d.get(t)!==e&&(d.set(t,e),t.update())}(t),t.version>0&&r.__version!==t.version){const n=t.image;if(void 0===n)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==n.complete)return void C(r,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+e),n.bindTexture(3553,r.__webglTexture)}function T(e,r){const o=i.get(e);e.version>0&&o.__version!==e.version?function(e,i,r){if(6!==i.image.length)return;R(e,i),n.activeTexture(33984+r),n.bindTexture(34067,e.__webglTexture),t.pixelStorei(37440,i.flipY),t.pixelStorei(37441,i.premultiplyAlpha),t.pixelStorei(3317,i.unpackAlignment),t.pixelStorei(37443,0);const o=i&&(i.isCompressedTexture||i.image[0].isCompressedTexture),l=i.image[0]&&i.image[0].isDataTexture,c=[];for(let t=0;t<6;t++)c[t]=o||l?l?i.image[t].image:i.image[t]:g(i.image[t],!1,!0,h);const u=c[0],d=v(u)||a,p=s.convert(i.format),f=s.convert(i.type),m=b(i.internalFormat,p,f);let w;if(L(34067,i,d),o){for(let t=0;t<6;t++){w=c[t].mipmaps;for(let e=0;e<w.length;e++){const r=w[e];1023!==i.format&&1022!==i.format?null!==p?n.compressedTexImage2D(34069+t,e,m,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(34069+t,e,m,r.width,r.height,0,p,f,r.data)}}e.__maxMipLevel=w.length-1}else{w=i.mipmaps;for(let t=0;t<6;t++)if(l){n.texImage2D(34069+t,0,m,c[t].width,c[t].height,0,p,f,c[t].data);for(let e=0;e<w.length;e++){const i=w[e].image[t].image;n.texImage2D(34069+t,e+1,m,i.width,i.height,0,p,f,i.data)}}else{n.texImage2D(34069+t,0,m,p,f,c[t]);for(let e=0;e<w.length;e++){const i=w[e];n.texImage2D(34069+t,e+1,m,p,f,i.image[t])}}e.__maxMipLevel=w.length}y(i,d)&&x(34067,i,u.width,u.height);e.__version=i.version,i.onUpdate&&i.onUpdate(i)}(o,e,r):(n.activeTexture(33984+r),n.bindTexture(34067,o.__webglTexture))}const A={1e3:10497,1001:33071,1002:33648},P={1003:9728,1004:9984,1005:9986,1006:9729,1007:9985,1008:9987};function L(n,s,o){if(o?(t.texParameteri(n,10242,A[s.wrapS]),t.texParameteri(n,10243,A[s.wrapT]),32879!==n&&35866!==n||t.texParameteri(n,32882,A[s.wrapR]),t.texParameteri(n,10240,P[s.magFilter]),t.texParameteri(n,10241,P[s.minFilter])):(t.texParameteri(n,10242,33071),t.texParameteri(n,10243,33071),32879!==n&&35866!==n||t.texParameteri(n,32882,33071),1001===s.wrapS&&1001===s.wrapT||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(n,10240,w(s.magFilter)),t.texParameteri(n,10241,w(s.minFilter)),1003!==s.minFilter&&1006!==s.minFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===e.has("EXT_texture_filter_anisotropic")){const o=e.get("EXT_texture_filter_anisotropic");if(1015===s.type&&!1===e.has("OES_texture_float_linear"))return;if(!1===a&&1016===s.type&&!1===e.has("OES_texture_half_float_linear"))return;(s.anisotropy>1||i.get(s).__currentAnisotropy)&&(t.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),i.get(s).__currentAnisotropy=s.anisotropy)}}function R(e,n){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",M),e.__webglTexture=t.createTexture(),o.memory.textures++)}function C(e,i,r){let o=3553;i.isDataTexture2DArray&&(o=35866),i.isDataTexture3D&&(o=32879),R(e,i),n.activeTexture(33984+r),n.bindTexture(o,e.__webglTexture),t.pixelStorei(37440,i.flipY),t.pixelStorei(37441,i.premultiplyAlpha),t.pixelStorei(3317,i.unpackAlignment),t.pixelStorei(37443,0);const l=function(t){return!a&&(1001!==t.wrapS||1001!==t.wrapT||1003!==t.minFilter&&1006!==t.minFilter)}(i)&&!1===v(i.image),h=g(i.image,l,!1,c),u=v(h)||a,d=s.convert(i.format);let p,f=s.convert(i.type),m=b(i.internalFormat,d,f);L(o,i,u);const w=i.mipmaps;if(i.isDepthTexture)m=6402,a?m=1015===i.type?36012:1014===i.type?33190:1020===i.type?35056:33189:1015===i.type&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),1026===i.format&&6402===m&&1012!==i.type&&1014!==i.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=1012,f=s.convert(i.type)),1027===i.format&&6402===m&&(m=34041,1020!==i.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=1020,f=s.convert(i.type))),n.texImage2D(3553,0,m,h.width,h.height,0,d,f,null);else if(i.isDataTexture)if(w.length>0&&u){for(let t=0,e=w.length;t<e;t++)p=w[t],n.texImage2D(3553,t,m,p.width,p.height,0,d,f,p.data);i.generateMipmaps=!1,e.__maxMipLevel=w.length-1}else n.texImage2D(3553,0,m,h.width,h.height,0,d,f,h.data),e.__maxMipLevel=0;else if(i.isCompressedTexture){for(let t=0,e=w.length;t<e;t++)p=w[t],1023!==i.format&&1022!==i.format?null!==d?n.compressedTexImage2D(3553,t,m,p.width,p.height,0,p.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(3553,t,m,p.width,p.height,0,d,f,p.data);e.__maxMipLevel=w.length-1}else if(i.isDataTexture2DArray)n.texImage3D(35866,0,m,h.width,h.height,h.depth,0,d,f,h.data),e.__maxMipLevel=0;else if(i.isDataTexture3D)n.texImage3D(32879,0,m,h.width,h.height,h.depth,0,d,f,h.data),e.__maxMipLevel=0;else if(w.length>0&&u){for(let t=0,e=w.length;t<e;t++)p=w[t],n.texImage2D(3553,t,m,d,f,p);i.generateMipmaps=!1,e.__maxMipLevel=w.length-1}else n.texImage2D(3553,0,m,d,f,h),e.__maxMipLevel=0;y(i,u)&&x(o,i,h.width,h.height),e.__version=i.version,i.onUpdate&&i.onUpdate(i)}function I(e,r,o,a){const l=r.texture,h=s.convert(l.format),c=s.convert(l.type),u=b(l.internalFormat,h,c);32879===a||35866===a?n.texImage3D(a,0,u,r.width,r.height,r.depth,0,h,c,null):n.texImage2D(a,0,u,r.width,r.height,0,h,c,null),n.bindFramebuffer(36160,e),t.framebufferTexture2D(36160,o,a,i.get(l).__webglTexture,0),n.bindFramebuffer(36160,null)}function O(e,n,i){if(t.bindRenderbuffer(36161,e),n.depthBuffer&&!n.stencilBuffer){let r=33189;if(i){const e=n.depthTexture;e&&e.isDepthTexture&&(1015===e.type?r=36012:1014===e.type&&(r=33190));const i=z(n);t.renderbufferStorageMultisample(36161,i,r,n.width,n.height)}else t.renderbufferStorage(36161,r,n.width,n.height);t.framebufferRenderbuffer(36160,36096,36161,e)}else if(n.depthBuffer&&n.stencilBuffer){if(i){const e=z(n);t.renderbufferStorageMultisample(36161,e,35056,n.width,n.height)}else t.renderbufferStorage(36161,34041,n.width,n.height);t.framebufferRenderbuffer(36160,33306,36161,e)}else{const e=n.texture,r=s.convert(e.format),o=s.convert(e.type),a=b(e.internalFormat,r,o);if(i){const e=z(n);t.renderbufferStorageMultisample(36161,e,a,n.width,n.height)}else t.renderbufferStorage(36161,a,n.width,n.height)}t.bindRenderbuffer(36161,null)}function D(e){const r=i.get(e),s=!0===e.isWebGLCubeRenderTarget;if(e.depthTexture){if(s)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(36160,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");i.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),S(r.depthTexture,0);const s=i.get(r.depthTexture).__webglTexture;if(1026===r.depthTexture.format)t.framebufferTexture2D(36160,36096,3553,s,0);else{if(1027!==r.depthTexture.format)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(36160,33306,3553,s,0)}}(r.__webglFramebuffer,e)}else if(s){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)n.bindFramebuffer(36160,r.__webglFramebuffer[i]),r.__webglDepthbuffer[i]=t.createRenderbuffer(),O(r.__webglDepthbuffer[i],e,!1)}else n.bindFramebuffer(36160,r.__webglFramebuffer),r.__webglDepthbuffer=t.createRenderbuffer(),O(r.__webglDepthbuffer,e,!1);n.bindFramebuffer(36160,null)}function z(t){return a&&t.isWebGLMultisampleRenderTarget?Math.min(u,t.samples):0}let N=!1,U=!1;this.allocateTextureUnit=function(){const t=E;return t>=l&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+l),E+=1,t},this.resetTextureUnits=function(){E=0},this.setTexture2D=S,this.setTexture2DArray=function(t,e){const r=i.get(t);t.version>0&&r.__version!==t.version?C(r,t,e):(n.activeTexture(33984+e),n.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(t,e){const r=i.get(t);t.version>0&&r.__version!==t.version?C(r,t,e):(n.activeTexture(33984+e),n.bindTexture(32879,r.__webglTexture))},this.setTextureCube=T,this.setupRenderTarget=function(e){const r=e.texture,l=i.get(e),h=i.get(r);e.addEventListener("dispose",_),h.__webglTexture=t.createTexture(),h.__version=r.version,o.memory.textures++;const c=!0===e.isWebGLCubeRenderTarget,u=!0===e.isWebGLMultisampleRenderTarget,d=r.isDataTexture3D||r.isDataTexture2DArray,p=v(e)||a;if(!a||1022!==r.format||1015!==r.type&&1016!==r.type||(r.format=1023,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),c){l.__webglFramebuffer=[];for(let e=0;e<6;e++)l.__webglFramebuffer[e]=t.createFramebuffer()}else if(l.__webglFramebuffer=t.createFramebuffer(),u)if(a){l.__webglMultisampledFramebuffer=t.createFramebuffer(),l.__webglColorRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,l.__webglColorRenderbuffer);const i=s.convert(r.format),o=s.convert(r.type),a=b(r.internalFormat,i,o),h=z(e);t.renderbufferStorageMultisample(36161,h,a,e.width,e.height),n.bindFramebuffer(36160,l.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064,36161,l.__webglColorRenderbuffer),t.bindRenderbuffer(36161,null),e.depthBuffer&&(l.__webglDepthRenderbuffer=t.createRenderbuffer(),O(l.__webglDepthRenderbuffer,e,!0)),n.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(c){n.bindTexture(34067,h.__webglTexture),L(34067,r,p);for(let t=0;t<6;t++)I(l.__webglFramebuffer[t],e,36064,34069+t);y(r,p)&&x(34067,r,e.width,e.height),n.bindTexture(34067,null)}else{let t=3553;if(d)if(a){t=r.isDataTexture3D?32879:35866}else console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.");n.bindTexture(t,h.__webglTexture),L(t,r,p),I(l.__webglFramebuffer,e,36064,t),y(r,p)&&x(3553,r,e.width,e.height),n.bindTexture(3553,null)}e.depthBuffer&&D(e)},this.updateRenderTargetMipmap=function(t){const e=t.texture;if(y(e,v(t)||a)){const r=t.isWebGLCubeRenderTarget?34067:3553,s=i.get(e).__webglTexture;n.bindTexture(r,s),x(r,e,t.width,t.height),n.bindTexture(r,null)}},this.updateMultisampleRenderTarget=function(e){if(e.isWebGLMultisampleRenderTarget)if(a){const r=i.get(e);n.bindFramebuffer(36008,r.__webglMultisampledFramebuffer),n.bindFramebuffer(36009,r.__webglFramebuffer);const s=e.width,o=e.height;let a=16384;e.depthBuffer&&(a|=256),e.stencilBuffer&&(a|=1024),t.blitFramebuffer(0,0,s,o,0,0,s,o,a,9728),n.bindFramebuffer(36160,r.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(t,e){t&&t.isWebGLRenderTarget&&(!1===N&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),N=!0),t=t.texture),S(t,e)},this.safeSetTextureCube=function(t,e){t&&t.isWebGLCubeRenderTarget&&(!1===U&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),U=!0),t=t.texture),T(t,e)}}function mc(t,e,n){const i=n.isWebGL2;return{convert:function(t){let n;if(1009===t)return 5121;if(1017===t)return 32819;if(1018===t)return 32820;if(1019===t)return 33635;if(1010===t)return 5120;if(1011===t)return 5122;if(1012===t)return 5123;if(1013===t)return 5124;if(1014===t)return 5125;if(1015===t)return 5126;if(1016===t)return i?5131:(n=e.get("OES_texture_half_float"),null!==n?n.HALF_FLOAT_OES:null);if(1021===t)return 6406;if(1022===t)return 6407;if(1023===t)return 6408;if(1024===t)return 6409;if(1025===t)return 6410;if(1026===t)return 6402;if(1027===t)return 34041;if(1028===t)return 6403;if(1029===t)return 36244;if(1030===t)return 33319;if(1031===t)return 33320;if(1032===t)return 36248;if(1033===t)return 36249;if(33776===t||33777===t||33778===t||33779===t){if(n=e.get("WEBGL_compressed_texture_s3tc"),null===n)return null;if(33776===t)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===t)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===t)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===t)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===t||35841===t||35842===t||35843===t){if(n=e.get("WEBGL_compressed_texture_pvrtc"),null===n)return null;if(35840===t)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===t)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===t)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===t)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===t)return n=e.get("WEBGL_compressed_texture_etc1"),null!==n?n.COMPRESSED_RGB_ETC1_WEBGL:null;if((37492===t||37496===t)&&(n=e.get("WEBGL_compressed_texture_etc"),null!==n)){if(37492===t)return n.COMPRESSED_RGB8_ETC2;if(37496===t)return n.COMPRESSED_RGBA8_ETC2_EAC}return 37808===t||37809===t||37810===t||37811===t||37812===t||37813===t||37814===t||37815===t||37816===t||37817===t||37818===t||37819===t||37820===t||37821===t||37840===t||37841===t||37842===t||37843===t||37844===t||37845===t||37846===t||37847===t||37848===t||37849===t||37850===t||37851===t||37852===t||37853===t?(n=e.get("WEBGL_compressed_texture_astc"),null!==n?t:null):36492===t?(n=e.get("EXT_texture_compression_bptc"),null!==n?t:null):1020===t?i?34042:(n=e.get("WEBGL_depth_texture"),null!==n?n.UNSIGNED_INT_24_8_WEBGL:null):void 0}}}class gc extends tl{constructor(t=[]){super(),this.cameras=t}}gc.prototype.isArrayCamera=!0;class vc extends zo{constructor(){super(),this.type="Group"}}function yc(){this._targetRay=null,this._grip=null,this._hand=null}function xc(t,e){const n=this,i=t.state;let r=null,s=1,o=null,a="local-floor",l=null;const h=[],c=new Map,u=new tl;u.layers.enable(1),u.viewport=new Ls;const d=new tl;d.layers.enable(2),d.viewport=new Ls;const p=[u,d],f=new gc;f.layers.enable(1),f.layers.enable(2);let m=null,g=null;function v(t){const e=c.get(t.inputSource);e&&e.dispatchEvent({type:t.type,data:t.inputSource})}function y(){c.forEach((function(t,e){t.disconnect(e)})),c.clear(),m=null,g=null,i.bindXRFramebuffer(null),t.setRenderTarget(t.getRenderTarget()),E.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function x(t){const e=r.inputSources;for(let t=0;t<h.length;t++)c.set(e[t],h[t]);for(let e=0;e<t.removed.length;e++){const n=t.removed[e],i=c.get(n);i&&(i.dispatchEvent({type:"disconnected",data:n}),c.delete(n))}for(let e=0;e<t.added.length;e++){const n=t.added[e],i=c.get(n);i&&i.dispatchEvent({type:"connected",data:n})}}this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=h[t];return void 0===e&&(e=new yc,h[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=h[t];return void 0===e&&(e=new yc,h[t]=e),e.getGripSpace()},this.getHand=function(t){let e=h[t];return void 0===e&&(e=new yc,h[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){s=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return o},this.getSession=function(){return r},this.setSession=async function(t){if(r=t,null!==r){r.addEventListener("select",v),r.addEventListener("selectstart",v),r.addEventListener("selectend",v),r.addEventListener("squeeze",v),r.addEventListener("squeezestart",v),r.addEventListener("squeezeend",v),r.addEventListener("end",y),r.addEventListener("inputsourceschange",x);const t=e.getContextAttributes();!0!==t.xrCompatible&&await e.makeXRCompatible();const i={antialias:t.antialias,alpha:t.alpha,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:s},l=new XRWebGLLayer(r,e,i);r.updateRenderState({baseLayer:l}),o=await r.requestReferenceSpace(a),E.setContext(r),E.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};const b=new Is,w=new Is;function M(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.getCamera=function(t){f.near=d.near=u.near=t.near,f.far=d.far=u.far=t.far,m===f.near&&g===f.far||(r.updateRenderState({depthNear:f.near,depthFar:f.far}),m=f.near,g=f.far);const e=t.parent,n=f.cameras;M(f,e);for(let t=0;t<n.length;t++)M(n[t],e);t.matrixWorld.copy(f.matrixWorld),t.matrix.copy(f.matrix),t.matrix.decompose(t.position,t.quaternion,t.scale);const i=t.children;for(let t=0,e=i.length;t<e;t++)i[t].updateMatrixWorld(!0);return 2===n.length?function(t,e,n){b.setFromMatrixPosition(e.matrixWorld),w.setFromMatrixPosition(n.matrixWorld);const i=b.distanceTo(w),r=e.projectionMatrix.elements,s=n.projectionMatrix.elements,o=r[14]/(r[10]-1),a=r[14]/(r[10]+1),l=(r[9]+1)/r[5],h=(r[9]-1)/r[5],c=(r[8]-1)/r[0],u=(s[8]+1)/s[0],d=o*c,p=o*u,f=i/(-c+u),m=f*-c;e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(m),t.translateZ(f),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert();const g=o+f,v=a+f,y=d-m,x=p+(i-m),M=l*a/v*g,_=h*a/v*g;t.projectionMatrix.makePerspective(y,x,M,_,g,v)}(f,u,d):f.projectionMatrix.copy(u.projectionMatrix),f};let _=null;const E=new ll;E.setAnimationLoop((function(t,e){if(l=e.getViewerPose(o),null!==l){const t=l.views,e=r.renderState.baseLayer;i.bindXRFramebuffer(e.framebuffer);let n=!1;t.length!==f.cameras.length&&(f.cameras.length=0,n=!0);for(let i=0;i<t.length;i++){const r=t[i],s=e.getViewport(r),o=p[i];o.matrix.fromArray(r.transform.matrix),o.projectionMatrix.fromArray(r.projectionMatrix),o.viewport.set(s.x,s.y,s.width,s.height),0===i&&f.matrix.copy(o.matrix),!0===n&&f.cameras.push(o)}}const n=r.inputSources;for(let t=0;t<h.length;t++){const i=h[t],r=n[t];i.update(r,e,o)}_&&_(t,e)})),this.setAnimationLoop=function(t){_=t},this.dispose=function(){}}function bc(t){function e(e,n){e.opacity.value=n.opacity,n.color&&e.diffuse.value.copy(n.color),n.emissive&&e.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(e.map.value=n.map),n.alphaMap&&(e.alphaMap.value=n.alphaMap),n.specularMap&&(e.specularMap.value=n.specularMap);const i=t.get(n).envMap;if(i){e.envMap.value=i,e.flipEnvMap.value=i.isCubeTexture&&i._needsFlipEnvMap?-1:1,e.reflectivity.value=n.reflectivity,e.refractionRatio.value=n.refractionRatio;const r=t.get(i).__maxMipLevel;void 0!==r&&(e.maxMipLevel.value=r)}let r,s;n.lightMap&&(e.lightMap.value=n.lightMap,e.lightMapIntensity.value=n.lightMapIntensity),n.aoMap&&(e.aoMap.value=n.aoMap,e.aoMapIntensity.value=n.aoMapIntensity),n.map?r=n.map:n.specularMap?r=n.specularMap:n.displacementMap?r=n.displacementMap:n.normalMap?r=n.normalMap:n.bumpMap?r=n.bumpMap:n.roughnessMap?r=n.roughnessMap:n.metalnessMap?r=n.metalnessMap:n.alphaMap?r=n.alphaMap:n.emissiveMap?r=n.emissiveMap:n.clearcoatMap?r=n.clearcoatMap:n.clearcoatNormalMap?r=n.clearcoatNormalMap:n.clearcoatRoughnessMap&&(r=n.clearcoatRoughnessMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix)),n.aoMap?s=n.aoMap:n.lightMap&&(s=n.lightMap),void 0!==s&&(s.isWebGLRenderTarget&&(s=s.texture),!0===s.matrixAutoUpdate&&s.updateMatrix(),e.uv2Transform.value.copy(s.matrix))}function n(e,n){e.roughness.value=n.roughness,e.metalness.value=n.metalness,n.roughnessMap&&(e.roughnessMap.value=n.roughnessMap),n.metalnessMap&&(e.metalnessMap.value=n.metalnessMap),n.emissiveMap&&(e.emissiveMap.value=n.emissiveMap),n.bumpMap&&(e.bumpMap.value=n.bumpMap,e.bumpScale.value=n.bumpScale,1===n.side&&(e.bumpScale.value*=-1)),n.normalMap&&(e.normalMap.value=n.normalMap,e.normalScale.value.copy(n.normalScale),1===n.side&&e.normalScale.value.negate()),n.displacementMap&&(e.displacementMap.value=n.displacementMap,e.displacementScale.value=n.displacementScale,e.displacementBias.value=n.displacementBias);t.get(n).envMap&&(e.envMapIntensity.value=n.envMapIntensity)}return{refreshFogUniforms:function(t,e){t.fogColor.value.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)},refreshMaterialUniforms:function(t,i,r,s){i.isMeshBasicMaterial?e(t,i):i.isMeshLambertMaterial?(e(t,i),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(t,i)):i.isMeshToonMaterial?(e(t,i),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap);e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,i)):i.isMeshPhongMaterial?(e(t,i),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,i)):i.isMeshStandardMaterial?(e(t,i),i.isMeshPhysicalMaterial?function(t,e){n(t,e),t.reflectivity.value=e.reflectivity,t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.sheen&&t.sheen.value.copy(e.sheen);e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap);e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap);e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,1===e.side&&t.clearcoatNormalScale.value.negate());t.transmission.value=e.transmission,e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap)}(t,i):n(t,i)):i.isMeshMatcapMaterial?(e(t,i),function(t,e){e.matcap&&(t.matcap.value=e.matcap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,i)):i.isMeshDepthMaterial?(e(t,i),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,i)):i.isMeshDistanceMaterial?(e(t,i),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias);t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(t,i)):i.isMeshNormalMaterial?(e(t,i),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,i)):i.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(t,i),i.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,i)):i.isPointsMaterial?function(t,e,n,i){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*i,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);let r;e.map?r=e.map:e.alphaMap&&(r=e.alphaMap);void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uvTransform.value.copy(r.matrix))}(t,i,r,s):i.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);let n;e.map?n=e.map:e.alphaMap&&(n=e.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(t,i):i.isShadowMaterial?(t.color.value.copy(i.color),t.opacity.value=i.opacity):i.isShaderMaterial&&(i.uniformsNeedUpdate=!1)}}}function wc(t){const e=void 0!==(t=t||{}).canvas?t.canvas:function(){const t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return t.style.display="block",t}(),n=void 0!==t.context?t.context:null,i=void 0!==t.alpha&&t.alpha,r=void 0===t.depth||t.depth,s=void 0===t.stencil||t.stencil,o=void 0!==t.antialias&&t.antialias,a=void 0===t.premultipliedAlpha||t.premultipliedAlpha,l=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,h=void 0!==t.powerPreference?t.powerPreference:"default",c=void 0!==t.failIfMajorPerformanceCaveat&&t.failIfMajorPerformanceCaveat;let u=null,d=null;const p=[],f=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=3e3,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const m=this;let g=!1,v=0,y=0,x=null,b=-1,w=null;const M=new Ls,_=new Ls;let E=null,S=e.width,T=e.height,A=1,P=null,L=null;const R=new Ls(0,0,S,T),C=new Ls(0,0,S,T);let I=!1;const O=new al;let D=!1,z=!1;const N=new ho,U=new Is,B={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function F(){return null===x?A:1}let V,k,H,G,W,j,X,Y,q,Z,J,$,Q,K,tt,et,nt,it,rt,st,ot,at,lt=n;function ht(t,n){for(let i=0;i<t.length;i++){const r=t[i],s=e.getContext(r,n);if(null!==s)return s}return null}try{const t={alpha:i,depth:r,stencil:s,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:c};if(e.addEventListener("webglcontextlost",dt,!1),e.addEventListener("webglcontextrestored",pt,!1),null===lt){const e=["webgl2","webgl","experimental-webgl"];if(!0===m.isWebGL1Renderer&&e.shift(),lt=ht(e,t),null===lt)throw ht(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===lt.getShaderPrecisionFormat&&(lt.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function ct(){V=new bl(lt),k=new vl(lt,V,t),V.init(k),ot=new mc(lt,V,k),H=new pc(lt,V,k),G=new _l(lt),W=new Kh,j=new fc(lt,V,H,W,k,ot,G),X=new xl(m),Y=new hl(lt,k),at=new ml(lt,V,Y,k),q=new wl(lt,Y,G,at),Z=new Al(lt,q,Y,G),it=new Tl(lt),tt=new yl(W),J=new Qh(m,X,V,k,at,tt),$=new bc(W),Q=new ic(W),K=new hc(V,k),nt=new fl(m,X,H,Z,a),et=new dc(m,Z,k),rt=new gl(lt,V,G,k),st=new Ml(lt,V,G,k),G.programs=J.programs,m.capabilities=k,m.extensions=V,m.properties=W,m.renderLists=Q,m.shadowMap=et,m.state=H,m.info=G}ct();const ut=new xc(m,lt);function dt(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function pt(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;const t=G.autoReset,e=et.enabled,n=et.autoUpdate,i=et.needsUpdate,r=et.type;ct(),G.autoReset=t,et.enabled=e,et.autoUpdate=n,et.needsUpdate=i,et.type=r}function ft(t){const e=t.target;e.removeEventListener("dispose",ft),function(t){(function(t){const e=W.get(t).programs;void 0!==e&&e.forEach((function(t){J.releaseProgram(t)}))})(t),W.remove(t)}(e)}this.xr=ut,this.getContext=function(){return lt},this.getContextAttributes=function(){return lt.getContextAttributes()},this.forceContextLoss=function(){const t=V.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=V.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return A},this.setPixelRatio=function(t){void 0!==t&&(A=t,this.setSize(S,T,!1))},this.getSize=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),t=new Ms),t.set(S,T)},this.setSize=function(t,n,i){ut.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(S=t,T=n,e.width=Math.floor(t*A),e.height=Math.floor(n*A),!1!==i&&(e.style.width=t+"px",e.style.height=n+"px"),this.setViewport(0,0,t,n))},this.getDrawingBufferSize=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),t=new Ms),t.set(S*A,T*A).floor()},this.setDrawingBufferSize=function(t,n,i){S=t,T=n,A=i,e.width=Math.floor(t*i),e.height=Math.floor(n*i),this.setViewport(0,0,t,n)},this.getCurrentViewport=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),t=new Ls),t.copy(M)},this.getViewport=function(t){return t.copy(R)},this.setViewport=function(t,e,n,i){t.isVector4?R.set(t.x,t.y,t.z,t.w):R.set(t,e,n,i),H.viewport(M.copy(R).multiplyScalar(A).floor())},this.getScissor=function(t){return t.copy(C)},this.setScissor=function(t,e,n,i){t.isVector4?C.set(t.x,t.y,t.z,t.w):C.set(t,e,n,i),H.scissor(_.copy(C).multiplyScalar(A).floor())},this.getScissorTest=function(){return I},this.setScissorTest=function(t){H.setScissorTest(I=t)},this.setOpaqueSort=function(t){P=t},this.setTransparentSort=function(t){L=t},this.getClearColor=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getClearColor() now requires a Color as an argument"),t=new sa),t.copy(nt.getClearColor())},this.setClearColor=function(){nt.setClearColor.apply(nt,arguments)},this.getClearAlpha=function(){return nt.getClearAlpha()},this.setClearAlpha=function(){nt.setClearAlpha.apply(nt,arguments)},this.clear=function(t,e,n){let i=0;(void 0===t||t)&&(i|=16384),(void 0===e||e)&&(i|=256),(void 0===n||n)&&(i|=1024),lt.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",dt,!1),e.removeEventListener("webglcontextrestored",pt,!1),Q.dispose(),K.dispose(),W.dispose(),X.dispose(),Z.dispose(),at.dispose(),ut.dispose(),ut.removeEventListener("sessionstart",gt),ut.removeEventListener("sessionend",vt),yt.stop()},this.renderBufferImmediate=function(t,e){at.initAttributes();const n=W.get(t);t.hasPositions&&!n.position&&(n.position=lt.createBuffer()),t.hasNormals&&!n.normal&&(n.normal=lt.createBuffer()),t.hasUvs&&!n.uv&&(n.uv=lt.createBuffer()),t.hasColors&&!n.color&&(n.color=lt.createBuffer());const i=e.getAttributes();t.hasPositions&&(lt.bindBuffer(34962,n.position),lt.bufferData(34962,t.positionArray,35048),at.enableAttribute(i.position),lt.vertexAttribPointer(i.position,3,5126,!1,0,0)),t.hasNormals&&(lt.bindBuffer(34962,n.normal),lt.bufferData(34962,t.normalArray,35048),at.enableAttribute(i.normal),lt.vertexAttribPointer(i.normal,3,5126,!1,0,0)),t.hasUvs&&(lt.bindBuffer(34962,n.uv),lt.bufferData(34962,t.uvArray,35048),at.enableAttribute(i.uv),lt.vertexAttribPointer(i.uv,2,5126,!1,0,0)),t.hasColors&&(lt.bindBuffer(34962,n.color),lt.bufferData(34962,t.colorArray,35048),at.enableAttribute(i.color),lt.vertexAttribPointer(i.color,3,5126,!1,0,0)),at.disableUnusedAttributes(),lt.drawArrays(4,0,t.count),t.count=0},this.renderBufferDirect=function(t,e,n,i,r,s){null===e&&(e=B);const o=r.isMesh&&r.matrixWorld.determinant()<0,a=Et(t,e,i,r);H.setMaterial(i,o);let l=n.index;const h=n.attributes.position;if(null===l){if(void 0===h||0===h.count)return}else if(0===l.count)return;let c,u=1;!0===i.wireframe&&(l=q.getWireframeAttribute(n),u=2),(i.morphTargets||i.morphNormals)&&it.update(r,n,i,a),at.setup(r,i,a,n,l);let d=rt;null!==l&&(c=Y.get(l),d=st,d.setIndex(c));const p=null!==l?l.count:h.count,f=n.drawRange.start*u,m=n.drawRange.count*u,g=null!==s?s.start*u:0,v=null!==s?s.count*u:1/0,y=Math.max(f,g),x=Math.min(p,f+m,g+v)-1,b=Math.max(0,x-y+1);if(0!==b){if(r.isMesh)!0===i.wireframe?(H.setLineWidth(i.wireframeLinewidth*F()),d.setMode(1)):d.setMode(4);else if(r.isLine){let t=i.linewidth;void 0===t&&(t=1),H.setLineWidth(t*F()),r.isLineSegments?d.setMode(1):r.isLineLoop?d.setMode(2):d.setMode(3)}else r.isPoints?d.setMode(0):r.isSprite&&d.setMode(4);if(r.isInstancedMesh)d.renderInstances(y,b,r.count);else if(n.isInstancedBufferGeometry){const t=Math.min(n.instanceCount,n._maxInstanceCount);d.renderInstances(y,b,t)}else d.render(y,b)}},this.compile=function(t,e){d=K.get(t),d.init(),t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(d.pushLight(t),t.castShadow&&d.pushShadow(t))})),d.setupLights(),t.traverse((function(e){const n=e.material;if(n)if(Array.isArray(n))for(let i=0;i<n.length;i++){Mt(n[i],t,e)}else Mt(n,t,e)}))};let mt=null;function gt(){yt.stop()}function vt(){yt.start()}const yt=new ll;function xt(t,e,n,i){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)n=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)d.pushLight(t),t.castShadow&&d.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||O.intersectsSprite(t)){i&&U.setFromMatrixPosition(t.matrixWorld).applyMatrix4(N);const e=Z.update(t),r=t.material;r.visible&&u.push(t,e,r,n,U.z,null)}}else if(t.isImmediateRenderObject)i&&U.setFromMatrixPosition(t.matrixWorld).applyMatrix4(N),u.push(t,null,t.material,n,U.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.frame!==G.render.frame&&(t.skeleton.update(),t.skeleton.frame=G.render.frame),!t.frustumCulled||O.intersectsObject(t))){i&&U.setFromMatrixPosition(t.matrixWorld).applyMatrix4(N);const e=Z.update(t),r=t.material;if(Array.isArray(r)){const i=e.groups;for(let s=0,o=i.length;s<o;s++){const o=i[s],a=r[o.materialIndex];a&&a.visible&&u.push(t,e,a,n,U.z,o)}}else r.visible&&u.push(t,e,r,n,U.z,null)}const r=t.children;for(let t=0,s=r.length;t<s;t++)xt(r[t],e,n,i)}function bt(t,e,n){const i=!0===e.isScene?e.overrideMaterial:null;for(let r=0,s=t.length;r<s;r++){const s=t[r],o=s.object,a=s.geometry,l=null===i?s.material:i,h=s.group;if(n.isArrayCamera){const t=n.cameras;for(let n=0,i=t.length;n<i;n++){const i=t[n];o.layers.test(i.layers)&&(H.viewport(M.copy(i.viewport)),d.setupLightsView(i),wt(o,e,i,a,l,h))}}else wt(o,e,n,a,l,h)}}function wt(t,e,n,i,r,s){if(t.onBeforeRender(m,e,n,i,r,s),t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),t.isImmediateRenderObject){const i=Et(n,e,r,t);H.setMaterial(r),at.reset(),function(t,e){t.render((function(t){m.renderBufferImmediate(t,e)}))}(t,i)}else m.renderBufferDirect(n,e,i,r,t,s);t.onAfterRender(m,e,n,i,r,s)}function Mt(t,e,n){!0!==e.isScene&&(e=B);const i=W.get(t),r=d.state.lights,s=d.state.shadowsArray,o=r.state.version,a=J.getParameters(t,r.state,s,e,n),l=J.getProgramCacheKey(a);let h=i.programs;i.environment=t.isMeshStandardMaterial?e.environment:null,i.fog=e.fog,i.envMap=X.get(t.envMap||i.environment),void 0===h&&(t.addEventListener("dispose",ft),h=new Map,i.programs=h);let c=h.get(l);if(void 0!==c){if(i.currentProgram===c&&i.lightsStateVersion===o)return _t(t,a),c}else a.uniforms=J.getUniforms(t),t.onBeforeCompile(a,m),c=J.acquireProgram(a,l),h.set(l,c),i.uniforms=a.uniforms;const u=i.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(u.clippingPlanes=tt.uniform),_t(t,a),i.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),i.lightsStateVersion=o,i.needsLights&&(u.ambientLightColor.value=r.state.ambient,u.lightProbe.value=r.state.probe,u.directionalLights.value=r.state.directional,u.directionalLightShadows.value=r.state.directionalShadow,u.spotLights.value=r.state.spot,u.spotLightShadows.value=r.state.spotShadow,u.rectAreaLights.value=r.state.rectArea,u.ltc_1.value=r.state.rectAreaLTC1,u.ltc_2.value=r.state.rectAreaLTC2,u.pointLights.value=r.state.point,u.pointLightShadows.value=r.state.pointShadow,u.hemisphereLights.value=r.state.hemi,u.directionalShadowMap.value=r.state.directionalShadowMap,u.directionalShadowMatrix.value=r.state.directionalShadowMatrix,u.spotShadowMap.value=r.state.spotShadowMap,u.spotShadowMatrix.value=r.state.spotShadowMatrix,u.pointShadowMap.value=r.state.pointShadowMap,u.pointShadowMatrix.value=r.state.pointShadowMatrix);const p=c.getUniforms(),f=Ch.seqWithValue(p.seq,u);return i.currentProgram=c,i.uniformsList=f,c}function _t(t,e){const n=W.get(t);n.outputEncoding=e.outputEncoding,n.instancing=e.instancing,n.numClippingPlanes=e.numClippingPlanes,n.numIntersection=e.numClipIntersection,n.vertexAlphas=e.vertexAlphas}function Et(t,e,n,i){!0!==e.isScene&&(e=B),j.resetTextureUnits();const r=e.fog,s=n.isMeshStandardMaterial?e.environment:null,o=null===x?m.outputEncoding:x.texture.encoding,a=X.get(n.envMap||s),l=!0===n.vertexColors&&i.geometry.attributes.color&&4===i.geometry.attributes.color.itemSize,h=W.get(n),c=d.state.lights;if(!0===D&&(!0===z||t!==w)){const e=t===w&&n.id===b;tt.setState(n,t,e)}let u=!1;n.version===h.__version?h.needsLights&&h.lightsStateVersion!==c.state.version||h.outputEncoding!==o||i.isInstancedMesh&&!1===h.instancing?u=!0:i.isInstancedMesh||!0!==h.instancing?h.envMap!==a||n.fog&&h.fog!==r?u=!0:void 0===h.numClippingPlanes||h.numClippingPlanes===tt.numPlanes&&h.numIntersection===tt.numIntersection?h.vertexAlphas!==l&&(u=!0):u=!0:u=!0:(u=!0,h.__version=n.version);let p=h.currentProgram;!0===u&&(p=Mt(n,e,i));let f=!1,g=!1,v=!1;const y=p.getUniforms(),M=h.uniforms;if(H.useProgram(p.program)&&(f=!0,g=!0,v=!0),n.id!==b&&(b=n.id,g=!0),f||w!==t){if(y.setValue(lt,"projectionMatrix",t.projectionMatrix),k.logarithmicDepthBuffer&&y.setValue(lt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),w!==t&&(w=t,g=!0,v=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshStandardMaterial||n.envMap){const e=y.map.cameraPosition;void 0!==e&&e.setValue(lt,U.setFromMatrixPosition(t.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&y.setValue(lt,"isOrthographic",!0===t.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.isShadowMaterial||n.skinning)&&y.setValue(lt,"viewMatrix",t.matrixWorldInverse)}if(n.skinning){y.setOptional(lt,i,"bindMatrix"),y.setOptional(lt,i,"bindMatrixInverse");const t=i.skeleton;if(t){const e=t.bones;if(k.floatVertexTextures){if(null===t.boneTexture){let n=Math.sqrt(4*e.length);n=ws.ceilPowerOfTwo(n),n=Math.max(n,4);const i=new Float32Array(n*n*4);i.set(t.boneMatrices);const r=new rl(i,n,n,1023,1015);t.boneMatrices=i,t.boneTexture=r,t.boneTextureSize=n}y.setValue(lt,"boneTexture",t.boneTexture,j),y.setValue(lt,"boneTextureSize",t.boneTextureSize)}else y.setOptional(lt,t,"boneMatrices")}}var _,E;return(g||h.receiveShadow!==i.receiveShadow)&&(h.receiveShadow=i.receiveShadow,y.setValue(lt,"receiveShadow",i.receiveShadow)),g&&(y.setValue(lt,"toneMappingExposure",m.toneMappingExposure),h.needsLights&&(E=v,(_=M).ambientLightColor.needsUpdate=E,_.lightProbe.needsUpdate=E,_.directionalLights.needsUpdate=E,_.directionalLightShadows.needsUpdate=E,_.pointLights.needsUpdate=E,_.pointLightShadows.needsUpdate=E,_.spotLights.needsUpdate=E,_.spotLightShadows.needsUpdate=E,_.rectAreaLights.needsUpdate=E,_.hemisphereLights.needsUpdate=E),r&&n.fog&&$.refreshFogUniforms(M,r),$.refreshMaterialUniforms(M,n,A,T),Ch.upload(lt,h.uniformsList,M,j)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(Ch.upload(lt,h.uniformsList,M,j),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&y.setValue(lt,"center",i.center),y.setValue(lt,"modelViewMatrix",i.modelViewMatrix),y.setValue(lt,"normalMatrix",i.normalMatrix),y.setValue(lt,"modelMatrix",i.matrixWorld),p}yt.setAnimationLoop((function(t){mt&&mt(t)})),"undefined"!=typeof window&&yt.setContext(window),this.setAnimationLoop=function(t){mt=t,ut.setAnimationLoop(t),null===t?yt.stop():yt.start()},ut.addEventListener("sessionstart",gt),ut.addEventListener("sessionend",vt),this.render=function(t,e){let n,i;if(void 0!==arguments[2]&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),n=arguments[2]),void 0!==arguments[3]&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),i=arguments[3]),void 0!==e&&!0!==e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===g)return;!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),!0===ut.enabled&&!0===ut.isPresenting&&(e=ut.getCamera(e)),!0===t.isScene&&t.onBeforeRender(m,t,e,n||x),d=K.get(t,f.length),d.init(),f.push(d),N.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),O.setFromProjectionMatrix(N),z=this.localClippingEnabled,D=tt.init(this.clippingPlanes,z,e),u=Q.get(t,p.length),u.init(),p.push(u),xt(t,e,0,m.sortObjects),u.finish(),!0===m.sortObjects&&u.sort(P,L),!0===D&&tt.beginShadows();const r=d.state.shadowsArray;et.render(r,t,e),d.setupLights(),d.setupLightsView(e),!0===D&&tt.endShadows(),!0===this.info.autoReset&&this.info.reset(),void 0!==n&&this.setRenderTarget(n),nt.render(u,t,e,i);const s=u.opaque,o=u.transparent;s.length>0&&bt(s,t,e),o.length>0&&bt(o,t,e),null!==x&&(j.updateRenderTargetMipmap(x),j.updateMultisampleRenderTarget(x)),!0===t.isScene&&t.onAfterRender(m,t,e),H.buffers.depth.setTest(!0),H.buffers.depth.setMask(!0),H.buffers.color.setMask(!0),H.setPolygonOffset(!1),at.resetDefaultState(),b=-1,w=null,f.pop(),d=f.length>0?f[f.length-1]:null,p.pop(),u=p.length>0?p[p.length-1]:null},this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return x},this.setRenderTarget=function(t,e=0,n=0){x=t,v=e,y=n,t&&void 0===W.get(t).__webglFramebuffer&&j.setupRenderTarget(t);let i=null,r=!1,s=!1;if(t){const n=t.texture;(n.isDataTexture3D||n.isDataTexture2DArray)&&(s=!0);const o=W.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(i=o[e],r=!0):i=t.isWebGLMultisampleRenderTarget?W.get(t).__webglMultisampledFramebuffer:o,M.copy(t.viewport),_.copy(t.scissor),E=t.scissorTest}else M.copy(R).multiplyScalar(A).floor(),_.copy(C).multiplyScalar(A).floor(),E=I;if(H.bindFramebuffer(36160,i),H.viewport(M),H.scissor(_),H.setScissorTest(E),r){const i=W.get(t.texture);lt.framebufferTexture2D(36160,36064,34069+e,i.__webglTexture,n)}else if(s){const i=W.get(t.texture),r=e||0;lt.framebufferTextureLayer(36160,36064,i.__webglTexture,n||0,r)}},this.readRenderTargetPixels=function(t,e,n,i,r,s,o){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let a=W.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==o&&(a=a[o]),a){H.bindFramebuffer(36160,a);try{const o=t.texture,a=o.format,l=o.type;if(1023!==a&&ot.convert(a)!==lt.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const h=1016===l&&(V.has("EXT_color_buffer_half_float")||k.isWebGL2&&V.has("EXT_color_buffer_float"));if(!(1009===l||ot.convert(l)===lt.getParameter(35738)||1015===l&&(k.isWebGL2||V.has("OES_texture_float")||V.has("WEBGL_color_buffer_float"))||h))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===lt.checkFramebufferStatus(36160)?e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r&&lt.readPixels(e,n,i,r,ot.convert(a),ot.convert(l),s):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const t=null!==x?W.get(x).__webglFramebuffer:null;H.bindFramebuffer(36160,t)}}},this.copyFramebufferToTexture=function(t,e,n=0){const i=Math.pow(2,-n),r=Math.floor(e.image.width*i),s=Math.floor(e.image.height*i),o=ot.convert(e.format);j.setTexture2D(e,0),lt.copyTexImage2D(3553,n,o,t.x,t.y,r,s,0),H.unbindTexture()},this.copyTextureToTexture=function(t,e,n,i=0){const r=e.image.width,s=e.image.height,o=ot.convert(n.format),a=ot.convert(n.type);j.setTexture2D(n,0),lt.pixelStorei(37440,n.flipY),lt.pixelStorei(37441,n.premultiplyAlpha),lt.pixelStorei(3317,n.unpackAlignment),e.isDataTexture?lt.texSubImage2D(3553,i,t.x,t.y,r,s,o,a,e.image.data):e.isCompressedTexture?lt.compressedTexSubImage2D(3553,i,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,o,e.mipmaps[0].data):lt.texSubImage2D(3553,i,t.x,t.y,o,a,e.image),0===i&&n.generateMipmaps&&lt.generateMipmap(3553),H.unbindTexture()},this.copyTextureToTexture3D=function(t,e,n,i,r=0){if(m.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const{width:s,height:o,data:a}=n.image,l=ot.convert(i.format),h=ot.convert(i.type);let c;if(i.isDataTexture3D)j.setTexture3D(i,0),c=32879;else{if(!i.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");j.setTexture2DArray(i,0),c=35866}lt.pixelStorei(37440,i.flipY),lt.pixelStorei(37441,i.premultiplyAlpha),lt.pixelStorei(3317,i.unpackAlignment);const u=lt.getParameter(3314),d=lt.getParameter(32878),p=lt.getParameter(3316),f=lt.getParameter(3315),g=lt.getParameter(32877);lt.pixelStorei(3314,s),lt.pixelStorei(32878,o),lt.pixelStorei(3316,t.min.x),lt.pixelStorei(3315,t.min.y),lt.pixelStorei(32877,t.min.z),lt.texSubImage3D(c,r,e.x,e.y,e.z,t.max.x-t.min.x+1,t.max.y-t.min.y+1,t.max.z-t.min.z+1,l,h,a),lt.pixelStorei(3314,u),lt.pixelStorei(32878,d),lt.pixelStorei(3316,p),lt.pixelStorei(3315,f),lt.pixelStorei(32877,g),0===r&&i.generateMipmaps&&lt.generateMipmap(c),H.unbindTexture()},this.initTexture=function(t){j.setTexture2D(t,0),H.unbindTexture()},this.resetState=function(){v=0,y=0,x=null,H.reset(),at.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}vc.prototype.isGroup=!0,Object.assign(yc.prototype,{constructor:yc,getHandSpace:function(){return null===this._hand&&(this._hand=new vc,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand},getTargetRaySpace:function(){return null===this._targetRay&&(this._targetRay=new vc,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return null===this._grip&&(this._grip=new vc,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1),this._grip},dispatchEvent:function(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this},disconnect:function(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this},update:function(t,e,n){let i=null,r=null,s=null;const o=this._targetRay,a=this._grip,l=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState)if(null!==o&&(i=e.getPose(t.targetRaySpace,n),null!==i&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale))),l&&t.hand){s=!0;for(const i of t.hand.values()){const t=e.getJointPose(i,n);if(void 0===l.joints[i.jointName]){const t=new vc;t.matrixAutoUpdate=!1,t.visible=!1,l.joints[i.jointName]=t,l.add(t)}const r=l.joints[i.jointName];null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.jointRadius=t.radius),r.visible=null!==t}const i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],o=i.position.distanceTo(r.position),a=.02,h=.005;l.inputState.pinching&&o>a+h?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&o<=a-h&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==a&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),null!==r&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale)));return null!==o&&(o.visible=null!==i),null!==a&&(a.visible=null!==r),null!==l&&(l.visible=null!==s),this}}),Object.assign(xc.prototype,ys.prototype);(class extends wc{}).prototype.isWebGL1Renderer=!0;class Mc{constructor(t,e=25e-5){this.name="",this.color=new sa(t),this.density=e}clone(){return new Mc(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}Mc.prototype.isFogExp2=!0;class _c{constructor(t,e=1,n=1e3){this.name="",this.color=new sa(t),this.near=e,this.far=n}clone(){return new _c(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}_c.prototype.isFog=!0;class Ec extends zo{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.background&&(e.object.background=this.background.toJSON(t)),null!==this.environment&&(e.object.environment=this.environment.toJSON(t)),null!==this.fog&&(e.object.fog=this.fog.toJSON()),e}}function Sc(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=35044,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=ws.generateUUID()}Ec.prototype.isScene=!0,Object.defineProperty(Sc.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Sc.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this},set:function(t,e=0){return this.array.set(t,e),this},clone:function(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=ws.generateUUID()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new Sc(new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),this.stride);return e.setUsage(this.usage),e},onUpload:function(t){return this.onUploadCallback=t,this},toJSON:function(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=ws.generateUUID()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}});const Tc=new Is;function Ac(t,e,n,i){this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=!0===i}Object.defineProperties(Ac.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}},needsUpdate:{set:function(t){this.data.needsUpdate=t}}}),Object.assign(Ac.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(t){for(let e=0,n=this.data.count;e<n;e++)Tc.x=this.getX(e),Tc.y=this.getY(e),Tc.z=this.getZ(e),Tc.applyMatrix4(t),this.setXYZ(e,Tc.x,Tc.y,Tc.z);return this},applyNormalMatrix:function(t){for(let e=0,n=this.count;e<n;e++)Tc.x=this.getX(e),Tc.y=this.getY(e),Tc.z=this.getZ(e),Tc.applyNormalMatrix(t),this.setXYZ(e,Tc.x,Tc.y,Tc.z);return this},transformDirection:function(t){for(let e=0,n=this.count;e<n;e++)Tc.x=this.getX(e),Tc.y=this.getY(e),Tc.z=this.getZ(e),Tc.transformDirection(t),this.setXYZ(e,Tc.x,Tc.y,Tc.z);return this},setX:function(t,e){return this.data.array[t*this.data.stride+this.offset]=e,this},setY:function(t,e){return this.data.array[t*this.data.stride+this.offset+1]=e,this},setZ:function(t,e){return this.data.array[t*this.data.stride+this.offset+2]=e,this},setW:function(t,e){return this.data.array[t*this.data.stride+this.offset+3]=e,this},getX:function(t){return this.data.array[t*this.data.stride+this.offset]},getY:function(t){return this.data.array[t*this.data.stride+this.offset+1]},getZ:function(t){return this.data.array[t*this.data.stride+this.offset+2]},getW:function(t){return this.data.array[t*this.data.stride+this.offset+3]},setXY:function(t,e,n){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this},setXYZ:function(t,e,n,i){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this},setXYZW:function(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this},clone:function(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return new ha(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Ac(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)},toJSON:function(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}});class Pc extends Qo{constructor(t){super(),this.type="SpriteMaterial",this.color=new sa(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this}}let Lc;Pc.prototype.isSpriteMaterial=!0;const Rc=new Is,Cc=new Is,Ic=new Is,Oc=new Ms,Dc=new Ms,zc=new ho,Nc=new Is,Uc=new Is,Bc=new Is,Fc=new Ms,Vc=new Ms,kc=new Ms;function Hc(t,e,n,i,r,s){Oc.subVectors(t,n).addScalar(.5).multiply(i),void 0!==r?(Dc.x=s*Oc.x-r*Oc.y,Dc.y=r*Oc.x+s*Oc.y):Dc.copy(Oc),t.copy(e),t.x+=Dc.x,t.y+=Dc.y,t.applyMatrix4(zc)}(class extends zo{constructor(t){if(super(),this.type="Sprite",void 0===Lc){Lc=new Pa;const t=new Sc(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);Lc.setIndex([0,1,2,0,2,3]),Lc.setAttribute("position",new Ac(t,3,0,!1)),Lc.setAttribute("uv",new Ac(t,2,3,!1))}this.geometry=Lc,this.material=void 0!==t?t:new Pc,this.center=new Ms(.5,.5)}raycast(t,e){null===t.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Cc.setFromMatrixScale(this.matrixWorld),zc.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Ic.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Cc.multiplyScalar(-Ic.z);const n=this.material.rotation;let i,r;0!==n&&(r=Math.cos(n),i=Math.sin(n));const s=this.center;Hc(Nc.set(-.5,-.5,0),Ic,s,Cc,i,r),Hc(Uc.set(.5,-.5,0),Ic,s,Cc,i,r),Hc(Bc.set(.5,.5,0),Ic,s,Cc,i,r),Fc.set(0,0),Vc.set(1,0),kc.set(1,1);let o=t.ray.intersectTriangle(Nc,Uc,Bc,!1,Rc);if(null===o&&(Hc(Uc.set(-.5,.5,0),Ic,s,Cc,i,r),Vc.set(0,1),o=t.ray.intersectTriangle(Nc,Bc,Uc,!1,Rc),null===o))return;const a=t.ray.origin.distanceTo(Rc);a<t.near||a>t.far||e.push({distance:a,point:Rc.clone(),uv:Jo.getUV(Rc,Nc,Uc,Bc,Fc,Vc,kc,new Ms),face:null,object:this})}copy(t){return super.copy(t),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}).prototype.isSprite=!0;const Gc=new Is,Wc=new Ls,jc=new Ls,Xc=new Is,Yc=new ho;function qc(t,e){Xa.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new ho,this.bindMatrixInverse=new ho}function Zc(){zo.call(this),this.type="Bone"}qc.prototype=Object.assign(Object.create(Xa.prototype),{constructor:qc,isSkinnedMesh:!0,copy:function(t){return Xa.prototype.copy.call(this,t),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,this},bind:function(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){const t=new Ls,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.x=e.getX(n),t.y=e.getY(n),t.z=e.getZ(n),t.w=e.getW(n);const i=1/t.manhattanLength();i!==1/0?t.multiplyScalar(i):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}},updateMatrixWorld:function(t){Xa.prototype.updateMatrixWorld.call(this,t),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},boneTransform:function(t,e){const n=this.skeleton,i=this.geometry;Wc.fromBufferAttribute(i.attributes.skinIndex,t),jc.fromBufferAttribute(i.attributes.skinWeight,t),Gc.fromBufferAttribute(i.attributes.position,t).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let t=0;t<4;t++){const i=jc.getComponent(t);if(0!==i){const r=Wc.getComponent(t);Yc.multiplyMatrices(n.bones[r].matrixWorld,n.boneInverses[r]),e.addScaledVector(Xc.copy(Gc).applyMatrix4(Yc),i)}}return e.applyMatrix4(this.bindMatrixInverse)}}),Zc.prototype=Object.assign(Object.create(zo.prototype),{constructor:Zc,isBone:!0});const Jc=new ho,$c=new ho,Qc=[],Kc=new Xa;function tu(t,e,n){Xa.call(this,t,e),this.instanceMatrix=new ha(new Float32Array(16*n),16),this.instanceColor=null,this.count=n,this.frustumCulled=!1}tu.prototype=Object.assign(Object.create(Xa.prototype),{constructor:tu,isInstancedMesh:!0,copy:function(t){return Xa.prototype.copy.call(this,t),this.instanceMatrix.copy(t.instanceMatrix),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,this},getColorAt:function(t,e){e.fromArray(this.instanceColor.array,3*t)},getMatrixAt:function(t,e){e.fromArray(this.instanceMatrix.array,16*t)},raycast:function(t,e){const n=this.matrixWorld,i=this.count;if(Kc.geometry=this.geometry,Kc.material=this.material,void 0!==Kc.material)for(let r=0;r<i;r++){this.getMatrixAt(r,Jc),$c.multiplyMatrices(n,Jc),Kc.matrixWorld=$c,Kc.raycast(t,Qc);for(let t=0,n=Qc.length;t<n;t++){const n=Qc[t];n.instanceId=r,n.object=this,e.push(n)}Qc.length=0}},setColorAt:function(t,e){null===this.instanceColor&&(this.instanceColor=new ha(new Float32Array(3*this.count),3)),e.toArray(this.instanceColor.array,3*t)},setMatrixAt:function(t,e){e.toArray(this.instanceMatrix.array,16*t)},updateMorphTargets:function(){},dispose:function(){this.dispatchEvent({type:"dispose"})}});class eu extends Qo{constructor(t){super(),this.type="LineBasicMaterial",this.color=new sa(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.morphTargets=!1,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.morphTargets=t.morphTargets,this}}eu.prototype.isLineBasicMaterial=!0;const nu=new Is,iu=new Is,ru=new ho,su=new lo,ou=new to;function au(t=new Pa,e=new eu){zo.call(this),this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}au.prototype=Object.assign(Object.create(zo.prototype),{constructor:au,isLine:!0,copy:function(t){return zo.prototype.copy.call(this,t),this.material=t.material,this.geometry=t.geometry,this},computeLineDistances:function(){const t=this.geometry;if(t.isBufferGeometry)if(null===t.index){const e=t.attributes.position,n=[0];for(let t=1,i=e.count;t<i;t++)nu.fromBufferAttribute(e,t-1),iu.fromBufferAttribute(e,t),n[t]=n[t-1],n[t]+=nu.distanceTo(iu);t.setAttribute("lineDistance",new ya(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else t.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this},raycast:function(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,s=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),ou.copy(n.boundingSphere),ou.applyMatrix4(i),ou.radius+=r,!1===t.ray.intersectsSphere(ou))return;ru.copy(i).invert(),su.copy(t.ray).applyMatrix4(ru);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,l=new Is,h=new Is,c=new Is,u=new Is,d=this.isLineSegments?2:1;if(n.isBufferGeometry){const i=n.index,r=n.attributes.position;if(null!==i){for(let n=Math.max(0,s.start),o=Math.min(i.count,s.start+s.count)-1;n<o;n+=d){const s=i.getX(n),o=i.getX(n+1);l.fromBufferAttribute(r,s),h.fromBufferAttribute(r,o);if(su.distanceSqToSegment(l,h,u,c)>a)continue;u.applyMatrix4(this.matrixWorld);const d=t.ray.origin.distanceTo(u);d<t.near||d>t.far||e.push({distance:d,point:c.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else{for(let n=Math.max(0,s.start),i=Math.min(r.count,s.start+s.count)-1;n<i;n+=d){l.fromBufferAttribute(r,n),h.fromBufferAttribute(r,n+1);if(su.distanceSqToSegment(l,h,u,c)>a)continue;u.applyMatrix4(this.matrixWorld);const i=t.ray.origin.distanceTo(u);i<t.near||i>t.far||e.push({distance:i,point:c.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}}else n.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},updateMorphTargets:function(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,n=Object.keys(e);if(n.length>0){const t=e[n[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,n=t.length;e<n;e++){const n=t[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=e}}}}else{const e=t.morphTargets;void 0!==e&&e.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});const lu=new Is,hu=new Is;function cu(t,e){au.call(this,t,e),this.type="LineSegments"}cu.prototype=Object.assign(Object.create(au.prototype),{constructor:cu,isLineSegments:!0,computeLineDistances:function(){const t=this.geometry;if(t.isBufferGeometry)if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,i=e.count;t<i;t+=2)lu.fromBufferAttribute(e,t),hu.fromBufferAttribute(e,t+1),n[t]=0===t?0:n[t-1],n[t+1]=n[t]+lu.distanceTo(hu);t.setAttribute("lineDistance",new ya(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else t.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}});(class extends au{constructor(t,e){super(t,e),this.type="LineLoop"}}).prototype.isLineLoop=!0;class uu extends Qo{constructor(t){super(),this.type="PointsMaterial",this.color=new sa(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.morphTargets=t.morphTargets,this}}uu.prototype.isPointsMaterial=!0;const du=new ho,pu=new lo,fu=new to,mu=new Is;function gu(t=new Pa,e=new uu){zo.call(this),this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}function vu(t,e,n,i,r,s,o){const a=pu.distanceSqToPoint(t);if(a<n){const n=new Is;pu.closestPointToPoint(t,n),n.applyMatrix4(i);const l=r.ray.origin.distanceTo(n);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:n,index:e,face:null,object:o})}}gu.prototype=Object.assign(Object.create(zo.prototype),{constructor:gu,isPoints:!0,copy:function(t){return zo.prototype.copy.call(this,t),this.material=t.material,this.geometry=t.geometry,this},raycast:function(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,s=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),fu.copy(n.boundingSphere),fu.applyMatrix4(i),fu.radius+=r,!1===t.ray.intersectsSphere(fu))return;du.copy(i).invert(),pu.copy(t.ray).applyMatrix4(du);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o;if(n.isBufferGeometry){const r=n.index,o=n.attributes.position;if(null!==r){for(let n=Math.max(0,s.start),l=Math.min(r.count,s.start+s.count);n<l;n++){const s=r.getX(n);mu.fromBufferAttribute(o,s),vu(mu,s,a,i,t,e,this)}}else{for(let n=Math.max(0,s.start),r=Math.min(o.count,s.start+s.count);n<r;n++)mu.fromBufferAttribute(o,n),vu(mu,n,a,i,t,e,this)}}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},updateMorphTargets:function(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,n=Object.keys(e);if(n.length>0){const t=e[n[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,n=t.length;e<n;e++){const n=t[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=e}}}}else{const e=t.morphTargets;void 0!==e&&e.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});(class extends As{constructor(t,e,n,i,r,s,o,a,l){super(t,e,n,i,r,s,o,a,l),this.format=void 0!==o?o:1022,this.minFilter=void 0!==s?s:1006,this.magFilter=void 0!==r?r:1006,this.generateMipmaps=!1;const h=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){h.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1==="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}).prototype.isVideoTexture=!0;class yu extends As{constructor(t,e,n,i,r,s,o,a,l,h,c,u){super(null,s,o,a,l,h,i,r,c,u),this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}yu.prototype.isCompressedTexture=!0;(class extends As{constructor(t,e,n,i,r,s,o,a,l){super(t,e,n,i,r,s,o,a,l),this.needsUpdate=!0}}).prototype.isCanvasTexture=!0;(class extends As{constructor(t,e,n,i,r,s,o,a,l,h){if(1026!==(h=void 0!==h?h:1026)&&1027!==h)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&1026===h&&(n=1012),void 0===n&&1027===h&&(n=1020),super(null,i,r,s,o,a,h,n,l),this.image={width:t,height:e},this.magFilter=void 0!==o?o:1003,this.minFilter=void 0!==a?a:1003,this.flipY=!1,this.generateMipmaps=!1}}).prototype.isDepthTexture=!0;const xu=function(t,e,n){n=n||2;const i=e&&e.length,r=i?e[0]*n:t.length;let s=bu(t,0,r,n,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,h,c,u,d,p;if(i&&(s=function(t,e,n,i){const r=[];let s,o,a,l,h;for(s=0,o=e.length;s<o;s++)a=e[s]*i,l=s<o-1?e[s+1]*i:t.length,h=bu(t,a,l,i,!1),h===h.next&&(h.steiner=!0),r.push(Cu(h));for(r.sort(Au),s=0;s<r.length;s++)Pu(r[s],n),n=wu(n,n.next);return n}(t,e,s,n)),t.length>80*n){a=h=t[0],l=c=t[1];for(let e=n;e<r;e+=n)u=t[e],d=t[e+1],u<a&&(a=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);p=Math.max(h-a,c-l),p=0!==p?1/p:0}return Mu(s,o,n,a,l,p),o};function bu(t,e,n,i,r){let s,o;if(r===function(t,e,n,i){let r=0;for(let s=e,o=n-i;s<n;s+=i)r+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return r}(t,e,n,i)>0)for(s=e;s<n;s+=i)o=ku(s,t[s],t[s+1],o);else for(s=n-i;s>=e;s-=i)o=ku(s,t[s],t[s+1],o);return o&&zu(o,o.next)&&(Hu(o),o=o.next),o}function wu(t,e){if(!t)return t;e||(e=t);let n,i=t;do{if(n=!1,i.steiner||!zu(i,i.next)&&0!==Du(i.prev,i,i.next))i=i.next;else{if(Hu(i),i=e=i.prev,i===i.next)break;n=!0}}while(n||i!==e);return e}function Mu(t,e,n,i,r,s,o){if(!t)return;!o&&s&&function(t,e,n,i){let r=t;do{null===r.z&&(r.z=Ru(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,n,i,r,s,o,a,l,h=1;do{for(n=t,t=null,s=null,o=0;n;){for(o++,i=n,a=0,e=0;e<h&&(a++,i=i.nextZ,i);e++);for(l=h;a>0||l>0&&i;)0!==a&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;n=i}s.nextZ=null,h*=2}while(o>1)}(r)}(t,i,r,s);let a,l,h=t;for(;t.prev!==t.next;)if(a=t.prev,l=t.next,s?Eu(t,i,r,s):_u(t))e.push(a.i/n),e.push(t.i/n),e.push(l.i/n),Hu(t),t=l.next,h=l.next;else if((t=l)===h){o?1===o?Mu(t=Su(wu(t),e,n),e,n,i,r,s,2):2===o&&Tu(t,e,n,i,r,s):Mu(wu(t),e,n,i,r,s,1);break}}function _u(t){const e=t.prev,n=t,i=t.next;if(Du(e,n,i)>=0)return!1;let r=t.next.next;for(;r!==t.prev;){if(Iu(e.x,e.y,n.x,n.y,i.x,i.y,r.x,r.y)&&Du(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Eu(t,e,n,i){const r=t.prev,s=t,o=t.next;if(Du(r,s,o)>=0)return!1;const a=r.x<s.x?r.x<o.x?r.x:o.x:s.x<o.x?s.x:o.x,l=r.y<s.y?r.y<o.y?r.y:o.y:s.y<o.y?s.y:o.y,h=r.x>s.x?r.x>o.x?r.x:o.x:s.x>o.x?s.x:o.x,c=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,u=Ru(a,l,e,n,i),d=Ru(h,c,e,n,i);let p=t.prevZ,f=t.nextZ;for(;p&&p.z>=u&&f&&f.z<=d;){if(p!==t.prev&&p!==t.next&&Iu(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&Du(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==t.prev&&f!==t.next&&Iu(r.x,r.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Du(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=u;){if(p!==t.prev&&p!==t.next&&Iu(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&Du(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==t.prev&&f!==t.next&&Iu(r.x,r.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Du(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function Su(t,e,n){let i=t;do{const r=i.prev,s=i.next.next;!zu(r,s)&&Nu(r,i,i.next,s)&&Fu(r,s)&&Fu(s,r)&&(e.push(r.i/n),e.push(i.i/n),e.push(s.i/n),Hu(i),Hu(i.next),i=t=s),i=i.next}while(i!==t);return wu(i)}function Tu(t,e,n,i,r,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&Ou(o,t)){let a=Vu(o,t);return o=wu(o,o.next),a=wu(a,a.next),Mu(o,e,n,i,r,s),void Mu(a,e,n,i,r,s)}t=t.next}o=o.next}while(o!==t)}function Au(t,e){return t.x-e.x}function Pu(t,e){if(e=function(t,e){let n=e;const i=t.x,r=t.y;let s,o=-1/0;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const t=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=i&&t>o){if(o=t,t===i){if(r===n.y)return n;if(r===n.next.y)return n.next}s=n.x<n.next.x?n:n.next}}n=n.next}while(n!==e);if(!s)return null;if(i===o)return s;const a=s,l=s.x,h=s.y;let c,u=1/0;n=s;do{i>=n.x&&n.x>=l&&i!==n.x&&Iu(r<h?i:o,r,l,h,r<h?o:i,r,n.x,n.y)&&(c=Math.abs(r-n.y)/(i-n.x),Fu(n,t)&&(c<u||c===u&&(n.x>s.x||n.x===s.x&&Lu(s,n)))&&(s=n,u=c)),n=n.next}while(n!==a);return s}(t,e)){const n=Vu(e,t);wu(e,e.next),wu(n,n.next)}}function Lu(t,e){return Du(t.prev,t,e.prev)<0&&Du(e.next,t,t.next)<0}function Ru(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Cu(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function Iu(t,e,n,i,r,s,o,a){return(r-o)*(e-a)-(t-o)*(s-a)>=0&&(t-o)*(i-a)-(n-o)*(e-a)>=0&&(n-o)*(s-a)-(r-o)*(i-a)>=0}function Ou(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Nu(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(Fu(t,e)&&Fu(e,t)&&function(t,e){let n=t,i=!1;const r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(Du(t.prev,t,e.prev)||Du(t,e.prev,e))||zu(t,e)&&Du(t.prev,t,t.next)>0&&Du(e.prev,e,e.next)>0)}function Du(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function zu(t,e){return t.x===e.x&&t.y===e.y}function Nu(t,e,n,i){const r=Bu(Du(t,e,n)),s=Bu(Du(t,e,i)),o=Bu(Du(n,i,t)),a=Bu(Du(n,i,e));return r!==s&&o!==a||(!(0!==r||!Uu(t,n,e))||(!(0!==s||!Uu(t,i,e))||(!(0!==o||!Uu(n,t,i))||!(0!==a||!Uu(n,e,i)))))}function Uu(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Bu(t){return t>0?1:t<0?-1:0}function Fu(t,e){return Du(t.prev,t,t.next)<0?Du(t,e,t.next)>=0&&Du(t,t.prev,e)>=0:Du(t,e,t.prev)<0||Du(t,t.next,e)<0}function Vu(t,e){const n=new Gu(t.i,t.x,t.y),i=new Gu(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function ku(t,e,n,i){const r=new Gu(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Hu(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Gu(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}const Wu={area:function(t){const e=t.length;let n=0;for(let i=e-1,r=0;r<e;i=r++)n+=t[i].x*t[r].y-t[r].x*t[i].y;return.5*n},isClockWise:function(t){return Wu.area(t)<0},triangulateShape:function(t,e){const n=[],i=[],r=[];ju(t),Xu(n,t);let s=t.length;e.forEach(ju);for(let t=0;t<e.length;t++)i.push(s),s+=e[t].length,Xu(n,e[t]);const o=xu(n,i);for(let t=0;t<o.length;t+=3)r.push(o.slice(t,t+3));return r}};function ju(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function Xu(t,e){for(let n=0;n<e.length;n++)t.push(e[n].x),t.push(e[n].y)}class Yu extends Pa{constructor(t,e){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const n=this,i=[],r=[];for(let e=0,n=t.length;e<n;e++){s(t[e])}function s(t){const s=[],o=void 0!==e.curveSegments?e.curveSegments:12,a=void 0!==e.steps?e.steps:1;let l=void 0!==e.depth?e.depth:100,h=void 0===e.bevelEnabled||e.bevelEnabled,c=void 0!==e.bevelThickness?e.bevelThickness:6,u=void 0!==e.bevelSize?e.bevelSize:c-2,d=void 0!==e.bevelOffset?e.bevelOffset:0,p=void 0!==e.bevelSegments?e.bevelSegments:3;const f=e.extrudePath,m=void 0!==e.UVGenerator?e.UVGenerator:qu;void 0!==e.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),l=e.amount);let g,v,y,x,b,w=!1;f&&(g=f.getSpacedPoints(a),w=!0,h=!1,v=f.computeFrenetFrames(a,!1),y=new Is,x=new Is,b=new Is),h||(p=0,c=0,u=0,d=0);const M=t.extractPoints(o);let _=M.shape;const E=M.holes;if(!Wu.isClockWise(_)){_=_.reverse();for(let t=0,e=E.length;t<e;t++){const e=E[t];Wu.isClockWise(e)&&(E[t]=e.reverse())}}const S=Wu.triangulateShape(_,E),T=_;for(let t=0,e=E.length;t<e;t++){const e=E[t];_=_.concat(e)}function A(t,e,n){return e||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().multiplyScalar(n).add(t)}const P=_.length,L=S.length;function R(t,e,n){let i,r,s;const o=t.x-e.x,a=t.y-e.y,l=n.x-t.x,h=n.y-t.y,c=o*o+a*a,u=o*h-a*l;if(Math.abs(u)>Number.EPSILON){const u=Math.sqrt(c),d=Math.sqrt(l*l+h*h),p=e.x-a/u,f=e.y+o/u,m=((n.x-h/d-p)*h-(n.y+l/d-f)*l)/(o*h-a*l);i=p+o*m-t.x,r=f+a*m-t.y;const g=i*i+r*r;if(g<=2)return new Ms(i,r);s=Math.sqrt(g/2)}else{let t=!1;o>Number.EPSILON?l>Number.EPSILON&&(t=!0):o<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(a)===Math.sign(h)&&(t=!0),t?(i=-a,r=o,s=Math.sqrt(c)):(i=o,r=a,s=Math.sqrt(c/2))}return new Ms(i/s,r/s)}const C=[];for(let t=0,e=T.length,n=e-1,i=t+1;t<e;t++,n++,i++)n===e&&(n=0),i===e&&(i=0),C[t]=R(T[t],T[n],T[i]);const I=[];let O,D=C.concat();for(let t=0,e=E.length;t<e;t++){const e=E[t];O=[];for(let t=0,n=e.length,i=n-1,r=t+1;t<n;t++,i++,r++)i===n&&(i=0),r===n&&(r=0),O[t]=R(e[t],e[i],e[r]);I.push(O),D=D.concat(O)}for(let t=0;t<p;t++){const e=t/p,n=c*Math.cos(e*Math.PI/2),i=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=T.length;t<e;t++){const e=A(T[t],C[t],i);U(e.x,e.y,-n)}for(let t=0,e=E.length;t<e;t++){const e=E[t];O=I[t];for(let t=0,r=e.length;t<r;t++){const r=A(e[t],O[t],i);U(r.x,r.y,-n)}}}const z=u+d;for(let t=0;t<P;t++){const e=h?A(_[t],D[t],z):_[t];w?(x.copy(v.normals[0]).multiplyScalar(e.x),y.copy(v.binormals[0]).multiplyScalar(e.y),b.copy(g[0]).add(x).add(y),U(b.x,b.y,b.z)):U(e.x,e.y,0)}for(let t=1;t<=a;t++)for(let e=0;e<P;e++){const n=h?A(_[e],D[e],z):_[e];w?(x.copy(v.normals[t]).multiplyScalar(n.x),y.copy(v.binormals[t]).multiplyScalar(n.y),b.copy(g[t]).add(x).add(y),U(b.x,b.y,b.z)):U(n.x,n.y,l/a*t)}for(let t=p-1;t>=0;t--){const e=t/p,n=c*Math.cos(e*Math.PI/2),i=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=T.length;t<e;t++){const e=A(T[t],C[t],i);U(e.x,e.y,l+n)}for(let t=0,e=E.length;t<e;t++){const e=E[t];O=I[t];for(let t=0,r=e.length;t<r;t++){const r=A(e[t],O[t],i);w?U(r.x,r.y+g[a-1].y,g[a-1].x+n):U(r.x,r.y,l+n)}}}function N(t,e){let n=t.length;for(;--n>=0;){const i=n;let r=n-1;r<0&&(r=t.length-1);for(let t=0,n=a+2*p;t<n;t++){const n=P*t,s=P*(t+1);F(e+i+n,e+r+n,e+r+s,e+i+s)}}}function U(t,e,n){s.push(t),s.push(e),s.push(n)}function B(t,e,r){V(t),V(e),V(r);const s=i.length/3,o=m.generateTopUV(n,i,s-3,s-2,s-1);k(o[0]),k(o[1]),k(o[2])}function F(t,e,r,s){V(t),V(e),V(s),V(e),V(r),V(s);const o=i.length/3,a=m.generateSideWallUV(n,i,o-6,o-3,o-2,o-1);k(a[0]),k(a[1]),k(a[3]),k(a[1]),k(a[2]),k(a[3])}function V(t){i.push(s[3*t+0]),i.push(s[3*t+1]),i.push(s[3*t+2])}function k(t){r.push(t.x),r.push(t.y)}!function(){const t=i.length/3;if(h){let t=0,e=P*t;for(let t=0;t<L;t++){const n=S[t];B(n[2]+e,n[1]+e,n[0]+e)}t=a+2*p,e=P*t;for(let t=0;t<L;t++){const n=S[t];B(n[0]+e,n[1]+e,n[2]+e)}}else{for(let t=0;t<L;t++){const e=S[t];B(e[2],e[1],e[0])}for(let t=0;t<L;t++){const e=S[t];B(e[0]+P*a,e[1]+P*a,e[2]+P*a)}}n.addGroup(t,i.length/3-t,0)}(),function(){const t=i.length/3;let e=0;N(T,e),e+=T.length;for(let t=0,n=E.length;t<n;t++){const n=E[t];N(n,e),e+=n.length}n.addGroup(t,i.length/3-t,1)}()}this.setAttribute("position",new ya(i,3)),this.setAttribute("uv",new ya(r,2)),this.computeVertexNormals()}toJSON(){const t=Pa.prototype.toJSON.call(this);return function(t,e,n){if(n.shapes=[],Array.isArray(t))for(let e=0,i=t.length;e<i;e++){const i=t[e];n.shapes.push(i.uuid)}else n.shapes.push(t.uuid);void 0!==e.extrudePath&&(n.options.extrudePath=e.extrudePath.toJSON());return n}(this.parameters.shapes,this.parameters.options,t)}}const qu={generateTopUV:function(t,e,n,i,r){const s=e[3*n],o=e[3*n+1],a=e[3*i],l=e[3*i+1],h=e[3*r],c=e[3*r+1];return[new Ms(s,o),new Ms(a,l),new Ms(h,c)]},generateSideWallUV:function(t,e,n,i,r,s){const o=e[3*n],a=e[3*n+1],l=e[3*n+2],h=e[3*i],c=e[3*i+1],u=e[3*i+2],d=e[3*r],p=e[3*r+1],f=e[3*r+2],m=e[3*s],g=e[3*s+1],v=e[3*s+2];return Math.abs(a-c)<.01?[new Ms(o,1-l),new Ms(h,1-u),new Ms(d,1-f),new Ms(m,1-v)]:[new Ms(a,1-l),new Ms(c,1-u),new Ms(p,1-f),new Ms(g,1-v)]}};function Zu(t,e,n){Pa.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:n};const i=[],r=[],s=[],o=[],a=1e-5,l=new Is,h=new Is,c=new Is,u=new Is,d=new Is;t.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");const p=e+1;for(let i=0;i<=n;i++){const p=i/n;for(let n=0;n<=e;n++){const i=n/e;t(i,p,h),r.push(h.x,h.y,h.z),i-a>=0?(t(i-a,p,c),u.subVectors(h,c)):(t(i+a,p,c),u.subVectors(c,h)),p-a>=0?(t(i,p-a,c),d.subVectors(h,c)):(t(i,p+a,c),d.subVectors(c,h)),l.crossVectors(u,d).normalize(),s.push(l.x,l.y,l.z),o.push(i,p)}}for(let t=0;t<n;t++)for(let n=0;n<e;n++){const e=t*p+n,r=t*p+n+1,s=(t+1)*p+n+1,o=(t+1)*p+n;i.push(e,r,o),i.push(r,s,o)}this.setIndex(i),this.setAttribute("position",new ya(r,3)),this.setAttribute("normal",new ya(s,3)),this.setAttribute("uv",new ya(o,2))}Zu.prototype=Object.create(Pa.prototype),Zu.prototype.constructor=Zu;class Ju extends Pa{constructor(t,e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const n=[],i=[],r=[],s=[];let o=0,a=0;if(!1===Array.isArray(t))l(t);else for(let e=0;e<t.length;e++)l(t[e]),this.addGroup(o,a,e),o+=a,a=0;function l(t){const o=i.length/3,l=t.extractPoints(e);let h=l.shape;const c=l.holes;!1===Wu.isClockWise(h)&&(h=h.reverse());for(let t=0,e=c.length;t<e;t++){const e=c[t];!0===Wu.isClockWise(e)&&(c[t]=e.reverse())}const u=Wu.triangulateShape(h,c);for(let t=0,e=c.length;t<e;t++){const e=c[t];h=h.concat(e)}for(let t=0,e=h.length;t<e;t++){const e=h[t];i.push(e.x,e.y,0),r.push(0,0,1),s.push(e.x,e.y)}for(let t=0,e=u.length;t<e;t++){const e=u[t],i=e[0]+o,r=e[1]+o,s=e[2]+o;n.push(i,r,s),a+=3}}this.setIndex(n),this.setAttribute("position",new ya(i,3)),this.setAttribute("normal",new ya(r,3)),this.setAttribute("uv",new ya(s,2))}toJSON(){const t=Pa.prototype.toJSON.call(this);return function(t,e){if(e.shapes=[],Array.isArray(t))for(let n=0,i=t.length;n<i;n++){const i=t[n];e.shapes.push(i.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)}}(class extends Qo{constructor(t){super(),this.type="ShadowMaterial",this.color=new sa(0),this.transparent=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this}}).prototype.isShadowMaterial=!0;function $u(t){Qo.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new sa(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new sa(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ms(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.vertexTangents=!1,this.setValues(t)}function Qu(t){$u.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ms(1,1),this.clearcoatNormalMap=null,this.reflectivity=.5,Object.defineProperty(this,"ior",{get:function(){return(1+.4*this.reflectivity)/(1-.4*this.reflectivity)},set:function(t){this.reflectivity=ws.clamp(2.5*(t-1)/(t+1),0,1)}}),this.sheen=null,this.transmission=0,this.transmissionMap=null,this.setValues(t)}(class extends Qa{constructor(t){super(t),this.type="RawShaderMaterial"}}).prototype.isRawShaderMaterial=!0,$u.prototype=Object.create(Qo.prototype),$u.prototype.constructor=$u,$u.prototype.isMeshStandardMaterial=!0,$u.prototype.copy=function(t){return Qo.prototype.copy.call(this,t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.flatShading=t.flatShading,this.vertexTangents=t.vertexTangents,this},Qu.prototype=Object.create($u.prototype),Qu.prototype.constructor=Qu,Qu.prototype.isMeshPhysicalMaterial=!0,Qu.prototype.copy=function(t){return $u.prototype.copy.call(this,t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.reflectivity=t.reflectivity,t.sheen?this.sheen=(this.sheen||new sa).copy(t.sheen):this.sheen=null,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this};(class extends Qo{constructor(t){super(),this.type="MeshPhongMaterial",this.color=new sa(16777215),this.specular=new sa(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new sa(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ms(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.flatShading=t.flatShading,this}}).prototype.isMeshPhongMaterial=!0;(class extends Qo{constructor(t){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new sa(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new sa(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ms(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this}}).prototype.isMeshToonMaterial=!0;(class extends Qo{constructor(t){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ms(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.flatShading=t.flatShading,this}}).prototype.isMeshNormalMaterial=!0;(class extends Qo{constructor(t){super(),this.type="MeshLambertMaterial",this.color=new sa(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new sa(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this}}).prototype.isMeshLambertMaterial=!0;(class extends Qo{constructor(t){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new sa(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ms(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.flatShading=t.flatShading,this}}).prototype.isMeshMatcapMaterial=!0;(class extends eu{constructor(t){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}).prototype.isLineDashedMaterial=!0;const Ku={arraySlice:function(t,e,n){return Ku.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==n?n:t.length)):t.slice(e,n)},convertArray:function(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){const e=t.length,n=new Array(e);for(let t=0;t!==e;++t)n[t]=t;return n.sort((function(e,n){return t[e]-t[n]})),n},sortedArray:function(t,e,n){const i=t.length,r=new t.constructor(i);for(let s=0,o=0;o!==i;++s){const i=n[s]*e;for(let n=0;n!==e;++n)r[o++]=t[i+n]}return r},flattenJSON:function(t,e,n,i){let r=1,s=t[0];for(;void 0!==s&&void 0===s[i];)s=t[r++];if(void 0===s)return;let o=s[i];if(void 0!==o)if(Array.isArray(o))do{o=s[i],void 0!==o&&(e.push(s.time),n.push.apply(n,o)),s=t[r++]}while(void 0!==s);else if(void 0!==o.toArray)do{o=s[i],void 0!==o&&(e.push(s.time),o.toArray(n,n.length)),s=t[r++]}while(void 0!==s);else do{o=s[i],void 0!==o&&(e.push(s.time),n.push(o)),s=t[r++]}while(void 0!==s)},subclip:function(t,e,n,i,r=30){const s=t.clone();s.name=e;const o=[];for(let t=0;t<s.tracks.length;++t){const e=s.tracks[t],a=e.getValueSize(),l=[],h=[];for(let t=0;t<e.times.length;++t){const s=e.times[t]*r;if(!(s<n||s>=i)){l.push(e.times[t]);for(let n=0;n<a;++n)h.push(e.values[t*a+n])}}0!==l.length&&(e.times=Ku.convertArray(l,e.times.constructor),e.values=Ku.convertArray(h,e.values.constructor),o.push(e))}s.tracks=o;let a=1/0;for(let t=0;t<s.tracks.length;++t)a>s.tracks[t].times[0]&&(a=s.tracks[t].times[0]);for(let t=0;t<s.tracks.length;++t)s.tracks[t].shift(-1*a);return s.resetDuration(),s},makeClipAdditive:function(t,e=0,n=t,i=30){i<=0&&(i=30);const r=n.tracks.length,s=e/i;for(let e=0;e<r;++e){const i=n.tracks[e],r=i.ValueTypeName;if("bool"===r||"string"===r)continue;const o=t.tracks.find((function(t){return t.name===i.name&&t.ValueTypeName===r}));if(void 0===o)continue;let a=0;const l=i.getValueSize();i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(a=l/3);let h=0;const c=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=c/3);const u=i.times.length-1;let d;if(s<=i.times[0]){const t=a,e=l-a;d=Ku.arraySlice(i.values,t,e)}else if(s>=i.times[u]){const t=u*l+a,e=t+l-a;d=Ku.arraySlice(i.values,t,e)}else{const t=i.createInterpolant(),e=a,n=l-a;t.evaluate(s),d=Ku.arraySlice(t.resultBuffer,e,n)}if("quaternion"===r){(new Cs).fromArray(d).normalize().conjugate().toArray(d)}const p=o.times.length;for(let t=0;t<p;++t){const e=t*c+h;if("quaternion"===r)Cs.multiplyQuaternionsFlat(o.values,e,d,0,o.values,e);else{const t=c-2*h;for(let n=0;n<t;++n)o.values[e+n]-=d[n]}}}return t.blendMode=2501,t}};function td(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n}function ed(t,e,n,i){td.call(this,t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function nd(t,e,n,i){td.call(this,t,e,n,i)}function id(t,e,n,i){td.call(this,t,e,n,i)}Object.assign(td.prototype,{evaluate:function(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],r=e[n-1];t:{e:{let s;n:{i:if(!(t<i)){for(let s=n+2;;){if(void 0===i){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.afterEnd_(n-1,t,r)}if(n===s)break;if(r=i,i=e[++n],t<i)break e}s=e.length;break n}if(t>=r)break t;{const o=e[1];t<o&&(n=2,r=o);for(let s=n-2;;){if(void 0===r)return this._cachedIndex=0,this.beforeStart_(0,t,i);if(n===s)break;if(i=r,r=e[--n-1],t>=r)break e}s=n,n=0}}for(;n<s;){const i=n+s>>>1;t<e[i]?s=i:n=i+1}if(i=e[n],r=e[n-1],void 0===r)return this._cachedIndex=0,this.beforeStart_(0,t,i);if(void 0===i)return n=e.length,this._cachedIndex=n,this.afterEnd_(n-1,r,t)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let t=0;t!==i;++t)e[t]=n[r+t];return e},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}}),Object.assign(td.prototype,{beforeStart_:td.prototype.copySampleValue_,afterEnd_:td.prototype.copySampleValue_}),ed.prototype=Object.assign(Object.create(td.prototype),{constructor:ed,DefaultSettings_:{endingStart:2400,endingEnd:2400},intervalChanged_:function(t,e,n){const i=this.parameterPositions;let r=t-2,s=t+1,o=i[r],a=i[s];if(void 0===o)switch(this.getSettings_().endingStart){case 2401:r=t,o=2*e-n;break;case 2402:r=i.length-2,o=e+i[r]-i[r+1];break;default:r=t,o=n}if(void 0===a)switch(this.getSettings_().endingEnd){case 2401:s=t,a=2*n-e;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=t-1,a=e}const l=.5*(n-e),h=this.valueSize;this._weightPrev=l/(e-o),this._weightNext=l/(a-n),this._offsetPrev=r*h,this._offsetNext=s*h},interpolate_:function(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=t*o,l=a-o,h=this._offsetPrev,c=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(n-e)/(i-e),f=p*p,m=f*p,g=-u*m+2*u*f-u*p,v=(1+u)*m+(-1.5-2*u)*f+(-.5+u)*p+1,y=(-1-d)*m+(1.5+d)*f+.5*p,x=d*m-d*f;for(let t=0;t!==o;++t)r[t]=g*s[h+t]+v*s[l+t]+y*s[a+t]+x*s[c+t];return r}}),nd.prototype=Object.assign(Object.create(td.prototype),{constructor:nd,interpolate_:function(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=t*o,l=a-o,h=(n-e)/(i-e),c=1-h;for(let t=0;t!==o;++t)r[t]=s[l+t]*c+s[a+t]*h;return r}}),id.prototype=Object.assign(Object.create(td.prototype),{constructor:id,interpolate_:function(t){return this.copySampleValue_(t-1)}});class rd{constructor(t,e,n,i){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Ku.convertArray(e,this.TimeBufferType),this.values=Ku.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:Ku.convertArray(t.times,Array),values:Ku.convertArray(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(n.interpolation=e)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new id(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new nd(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new ed(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case 2300:e=this.InterpolantFactoryMethodDiscrete;break;case 2301:e=this.InterpolantFactoryMethodLinear;break;case 2302:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",e),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(1!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){const n=this.times,i=n.length;let r=0,s=i-1;for(;r!==i&&n[r]<t;)++r;for(;-1!==s&&n[s]>e;)--s;if(++s,0!==r||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);const t=this.getValueSize();this.times=Ku.arraySlice(n,r,s),this.values=Ku.arraySlice(this.values,r*t,s*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let e=0;e!==r;e++){const i=n[e];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,i),t=!1;break}if(null!==s&&s>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,i,s),t=!1;break}s=i}if(void 0!==i&&Ku.isTypedArray(i))for(let e=0,n=i.length;e!==n;++e){const n=i[e];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,n),t=!1;break}}return t}optimize(){const t=Ku.arraySlice(this.times),e=Ku.arraySlice(this.values),n=this.getValueSize(),i=2302===this.getInterpolation(),r=t.length-1;let s=1;for(let o=1;o<r;++o){let r=!1;const a=t[o];if(a!==t[o+1]&&(1!==o||a!==t[0]))if(i)r=!0;else{const t=o*n,i=t-n,s=t+n;for(let o=0;o!==n;++o){const n=e[t+o];if(n!==e[i+o]||n!==e[s+o]){r=!0;break}}}if(r){if(o!==s){t[s]=t[o];const i=o*n,r=s*n;for(let t=0;t!==n;++t)e[r+t]=e[i+t]}++s}}if(r>0){t[s]=t[r];for(let t=r*n,i=s*n,o=0;o!==n;++o)e[i+o]=e[t+o];++s}return s!==t.length?(this.times=Ku.arraySlice(t,0,s),this.values=Ku.arraySlice(e,0,s*n)):(this.times=t,this.values=e),this}clone(){const t=Ku.arraySlice(this.times,0),e=Ku.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}rd.prototype.TimeBufferType=Float32Array,rd.prototype.ValueBufferType=Float32Array,rd.prototype.DefaultInterpolation=2301;class sd extends rd{}sd.prototype.ValueTypeName="bool",sd.prototype.ValueBufferType=Array,sd.prototype.DefaultInterpolation=2300,sd.prototype.InterpolantFactoryMethodLinear=void 0,sd.prototype.InterpolantFactoryMethodSmooth=void 0;class od extends rd{}od.prototype.ValueTypeName="color";class ad extends rd{}function ld(t,e,n,i){td.call(this,t,e,n,i)}ad.prototype.ValueTypeName="number",ld.prototype=Object.assign(Object.create(td.prototype),{constructor:ld,interpolate_:function(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(n-e)/(i-e);let l=t*o;for(let t=l+o;l!==t;l+=4)Cs.slerpFlat(r,0,s,l-o,s,l,a);return r}});class hd extends rd{InterpolantFactoryMethodLinear(t){return new ld(this.times,this.values,this.getValueSize(),t)}}hd.prototype.ValueTypeName="quaternion",hd.prototype.DefaultInterpolation=2301,hd.prototype.InterpolantFactoryMethodSmooth=void 0;class cd extends rd{}cd.prototype.ValueTypeName="string",cd.prototype.ValueBufferType=Array,cd.prototype.DefaultInterpolation=2300,cd.prototype.InterpolantFactoryMethodLinear=void 0,cd.prototype.InterpolantFactoryMethodSmooth=void 0;class ud extends rd{}ud.prototype.ValueTypeName="vector";class dd{constructor(t,e=-1,n,i=2500){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=ws.generateUUID(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let t=0,r=n.length;t!==r;++t)e.push(pd(n[t]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,i=n.length;t!==i;++t)e.push(rd.toJSON(n[t]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.length,s=[];for(let t=0;t<r;t++){let o=[],a=[];o.push((t+r-1)%r,t,(t+1)%r),a.push(0,1,0);const l=Ku.getKeyframeOrder(o);o=Ku.sortedArray(o,1,l),a=Ku.sortedArray(a,1,l),i||0!==o[0]||(o.push(r),a.push(a[0])),s.push(new ad(".morphTargetInfluences["+e[t].name+"]",o,a).scale(1/n))}return new this(t,-1,s)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const e=t;n=e.geometry&&e.geometry.animations||e.animations}for(let t=0;t<n.length;t++)if(n[t].name===e)return n[t];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let e=0,n=t.length;e<n;e++){const n=t[e],s=n.name.match(r);if(s&&s.length>1){const t=s[1];let e=i[t];e||(i[t]=e=[]),e.push(n)}}const s=[];for(const t in i)s.push(this.CreateFromMorphTargetSequence(t,i[t],e,n));return s}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(t,e,n,i,r){if(0!==n.length){const s=[],o=[];Ku.flattenJSON(n,s,o,i),0!==s.length&&r.push(new t(e,s,o))}},i=[],r=t.name||"default",s=t.fps||30,o=t.blendMode;let a=t.length||-1;const l=t.hierarchy||[];for(let t=0;t<l.length;t++){const r=l[t].keys;if(r&&0!==r.length)if(r[0].morphTargets){const t={};let e;for(e=0;e<r.length;e++)if(r[e].morphTargets)for(let n=0;n<r[e].morphTargets.length;n++)t[r[e].morphTargets[n]]=-1;for(const n in t){const t=[],s=[];for(let i=0;i!==r[e].morphTargets.length;++i){const i=r[e];t.push(i.time),s.push(i.morphTarget===n?1:0)}i.push(new ad(".morphTargetInfluence["+n+"]",t,s))}a=t.length*(s||1)}else{const s=".bones["+e[t].name+"]";n(ud,s+".position",r,"pos",i),n(hd,s+".quaternion",r,"rot",i),n(ud,s+".scale",r,"scl",i)}}if(0===i.length)return null;return new this(r,a,i,o)}resetDuration(){let t=0;for(let e=0,n=this.tracks.length;e!==n;++e){const n=this.tracks[e];t=Math.max(t,n.times[n.times.length-1])}return this.duration=t,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function pd(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ad;case"vector":case"vector2":case"vector3":case"vector4":return ud;case"color":return od;case"quaternion":return hd;case"bool":case"boolean":return sd;case"string":return cd}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],n=[];Ku.flattenJSON(t.keys,e,n,"value"),t.times=e,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const fd={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};const md=new function(t,e,n){const i=this;let r=!1,s=0,o=0,a=void 0;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(t){o++,!1===r&&void 0!==i.onStart&&i.onStart(t,s,o),r=!0},this.itemEnd=function(t){s++,void 0!==i.onProgress&&i.onProgress(t,s,o),s===o&&(r=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(t){void 0!==i.onError&&i.onError(t)},this.resolveURL=function(t){return a?a(t):t},this.setURLModifier=function(t){return a=t,this},this.addHandler=function(t,e){return l.push(t,e),this},this.removeHandler=function(t){const e=l.indexOf(t);return-1!==e&&l.splice(e,2),this},this.getHandler=function(t){for(let e=0,n=l.length;e<n;e+=2){const n=l[e],i=l[e+1];if(n.global&&(n.lastIndex=0),n.test(t))return i}return null}};function gd(t){this.manager=void 0!==t?t:md,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}Object.assign(gd.prototype,{load:function(){},loadAsync:function(t,e){const n=this;return new Promise((function(i,r){n.load(t,i,e,r)}))},parse:function(){},setCrossOrigin:function(t){return this.crossOrigin=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setPath:function(t){return this.path=t,this},setResourcePath:function(t){return this.resourcePath=t,this},setRequestHeader:function(t){return this.requestHeader=t,this}});const vd={};function yd(t){gd.call(this,t)}function xd(t){gd.call(this,t)}yd.prototype=Object.assign(Object.create(gd.prototype),{constructor:yd,load:function(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=fd.get(t);if(void 0!==s)return r.manager.itemStart(t),setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s;if(void 0!==vd[t])return void vd[t].push({onLoad:e,onProgress:n,onError:i});const o=t.match(/^data:(.*?)(;base64)?,(.*)$/);let a;if(o){const n=o[1],s=!!o[2];let a=o[3];a=decodeURIComponent(a),s&&(a=atob(a));try{let i;const s=(this.responseType||"").toLowerCase();switch(s){case"arraybuffer":case"blob":const t=new Uint8Array(a.length);for(let e=0;e<a.length;e++)t[e]=a.charCodeAt(e);i="blob"===s?new Blob([t.buffer],{type:n}):t.buffer;break;case"document":const e=new DOMParser;i=e.parseFromString(a,n);break;case"json":i=JSON.parse(a);break;default:i=a}setTimeout((function(){e&&e(i),r.manager.itemEnd(t)}),0)}catch(e){setTimeout((function(){i&&i(e),r.manager.itemError(t),r.manager.itemEnd(t)}),0)}}else{vd[t]=[],vd[t].push({onLoad:e,onProgress:n,onError:i}),a=new XMLHttpRequest,a.open("GET",t,!0),a.addEventListener("load",(function(e){const n=this.response,i=vd[t];if(delete vd[t],200===this.status||0===this.status){0===this.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),fd.add(t,n);for(let t=0,e=i.length;t<e;t++){const e=i[t];e.onLoad&&e.onLoad(n)}r.manager.itemEnd(t)}else{for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onError&&n.onError(e)}r.manager.itemError(t),r.manager.itemEnd(t)}}),!1),a.addEventListener("progress",(function(e){const n=vd[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onProgress&&i.onProgress(e)}}),!1),a.addEventListener("error",(function(e){const n=vd[t];delete vd[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onError&&i.onError(e)}r.manager.itemError(t),r.manager.itemEnd(t)}),!1),a.addEventListener("abort",(function(e){const n=vd[t];delete vd[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onError&&i.onError(e)}r.manager.itemError(t),r.manager.itemEnd(t)}),!1),void 0!==this.responseType&&(a.responseType=this.responseType),void 0!==this.withCredentials&&(a.withCredentials=this.withCredentials),a.overrideMimeType&&a.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain");for(const t in this.requestHeader)a.setRequestHeader(t,this.requestHeader[t]);a.send(null)}return r.manager.itemStart(t),a},setResponseType:function(t){return this.responseType=t,this},setMimeType:function(t){return this.mimeType=t,this}}),xd.prototype=Object.assign(Object.create(gd.prototype),{constructor:xd,load:function(t,e,n,i){const r=this,s=[],o=new yu,a=new yd(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(r.withCredentials);let l=0;function h(h){a.load(t[h],(function(t){const n=r.parse(t,!0);s[h]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},l+=1,6===l&&(1===n.mipmapCount&&(o.minFilter=1006),o.image=s,o.format=n.format,o.needsUpdate=!0,e&&e(o))}),n,i)}if(Array.isArray(t))for(let e=0,n=t.length;e<n;++e)h(e);else a.load(t,(function(t){const n=r.parse(t,!0);if(n.isCubemap){const t=n.mipmaps.length/n.mipmapCount;for(let e=0;e<t;e++){s[e]={mipmaps:[]};for(let t=0;t<n.mipmapCount;t++)s[e].mipmaps.push(n.mipmaps[e*n.mipmapCount+t]),s[e].format=n.format,s[e].width=n.width,s[e].height=n.height}o.image=s}else o.image.width=n.width,o.image.height=n.height,o.mipmaps=n.mipmaps;1===n.mipmapCount&&(o.minFilter=1006),o.format=n.format,o.needsUpdate=!0,e&&e(o)}),n,i);return o}});class bd extends gd{constructor(t){super(t)}load(t,e,n,i){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=fd.get(t);if(void 0!==s)return r.manager.itemStart(t),setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s;const o=document.createElementNS("http://www.w3.org/1999/xhtml","img");function a(){o.removeEventListener("load",a,!1),o.removeEventListener("error",l,!1),fd.add(t,this),e&&e(this),r.manager.itemEnd(t)}function l(e){o.removeEventListener("load",a,!1),o.removeEventListener("error",l,!1),i&&i(e),r.manager.itemError(t),r.manager.itemEnd(t)}return o.addEventListener("load",a,!1),o.addEventListener("error",l,!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),r.manager.itemStart(t),o.src=t,o}}class wd extends gd{constructor(t){super(t)}load(t,e,n,i){const r=new nl,s=new bd(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let o=0;function a(n){s.load(t[n],(function(t){r.images[n]=t,o++,6===o&&(r.needsUpdate=!0,e&&e(r))}),void 0,i)}for(let e=0;e<t.length;++e)a(e);return r}}function Md(t){gd.call(this,t)}function _d(t){gd.call(this,t)}function Ed(){this.type="Curve",this.arcLengthDivisions=200}Md.prototype=Object.assign(Object.create(gd.prototype),{constructor:Md,load:function(t,e,n,i){const r=this,s=new rl,o=new yd(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(r.withCredentials),o.load(t,(function(t){const n=r.parse(t);n&&(void 0!==n.image?s.image=n.image:void 0!==n.data&&(s.image.width=n.width,s.image.height=n.height,s.image.data=n.data),s.wrapS=void 0!==n.wrapS?n.wrapS:1001,s.wrapT=void 0!==n.wrapT?n.wrapT:1001,s.magFilter=void 0!==n.magFilter?n.magFilter:1006,s.minFilter=void 0!==n.minFilter?n.minFilter:1006,s.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.encoding&&(s.encoding=n.encoding),void 0!==n.flipY&&(s.flipY=n.flipY),void 0!==n.format&&(s.format=n.format),void 0!==n.type&&(s.type=n.type),void 0!==n.mipmaps&&(s.mipmaps=n.mipmaps,s.minFilter=1008),1===n.mipmapCount&&(s.minFilter=1006),void 0!==n.generateMipmaps&&(s.generateMipmaps=n.generateMipmaps),s.needsUpdate=!0,e&&e(s,n))}),n,i),s}}),_d.prototype=Object.assign(Object.create(gd.prototype),{constructor:_d,load:function(t,e,n,i){const r=new As,s=new bd(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(t,(function(n){r.image=n;const i=t.search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/);r.format=i?1022:1023,r.needsUpdate=!0,void 0!==e&&e(r)}),n,i),r}}),Object.assign(Ed.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)},getPoints:function(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e},getSpacedPoints:function(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e},getLength:function(){const t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,i=this.getPoint(0),r=0;e.push(0);for(let s=1;s<=t;s++)n=this.getPoint(s/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){const n=this.getLengths();let i=0;const r=n.length;let s;s=e||t*n[r-1];let o,a=0,l=r-1;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),o=n[i]-s,o<0)a=i+1;else{if(!(o>0)){l=i;break}l=i-1}if(i=l,n[i]===s)return i/(r-1);const h=n[i];return(i+(s-h)/(n[i+1]-h))/(r-1)},getTangent:function(t,e){let n=t-1e-4,i=t+1e-4;n<0&&(n=0),i>1&&(i=1);const r=this.getPoint(n),s=this.getPoint(i),o=e||(r.isVector2?new Ms:new Is);return o.copy(s).sub(r).normalize(),o},getTangentAt:function(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)},computeFrenetFrames:function(t,e){const n=new Is,i=[],r=[],s=[],o=new Is,a=new ho;for(let e=0;e<=t;e++){const n=e/t;i[e]=this.getTangentAt(n,new Is),i[e].normalize()}r[0]=new Is,s[0]=new Is;let l=Number.MAX_VALUE;const h=Math.abs(i[0].x),c=Math.abs(i[0].y),u=Math.abs(i[0].z);h<=l&&(l=h,n.set(1,0,0)),c<=l&&(l=c,n.set(0,1,0)),u<=l&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],o),s[0].crossVectors(i[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),s[e]=s[e-1].clone(),o.crossVectors(i[e-1],i[e]),o.length()>Number.EPSILON){o.normalize();const t=Math.acos(ws.clamp(i[e-1].dot(i[e]),-1,1));r[e].applyMatrix4(a.makeRotationAxis(o,t))}s[e].crossVectors(i[e],r[e])}if(!0===e){let e=Math.acos(ws.clamp(r[0].dot(r[t]),-1,1));e/=t,i[0].dot(o.crossVectors(r[0],r[t]))>0&&(e=-e);for(let n=1;n<=t;n++)r[n].applyMatrix4(a.makeRotationAxis(i[n],e*n)),s[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:s}},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this},toJSON:function(){const t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t},fromJSON:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}});class Sd extends Ed{constructor(t=0,e=0,n=1,i=1,r=0,s=2*Math.PI,o=!1,a=0){super(),this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=o,this.aRotation=a}getPoint(t,e){const n=e||new Ms,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(r=s?0:i),!0!==this.aClockwise||s||(r===i?r=-i:r-=i);const o=this.aStartAngle+t*r;let a=this.aX+this.xRadius*Math.cos(o),l=this.aY+this.yRadius*Math.sin(o);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),n=a-this.aX,i=l-this.aY;a=n*t-i*e+this.aX,l=n*e+i*t+this.aY}return n.set(a,l)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}Sd.prototype.isEllipseCurve=!0;class Td extends Sd{constructor(t,e,n,i,r,s){super(t,e,n,n,i,r,s),this.type="ArcCurve"}}function Ad(){let t=0,e=0,n=0,i=0;function r(r,s,o,a){t=r,e=o,n=-3*r+3*s-2*o-a,i=2*r-2*s+o+a}return{initCatmullRom:function(t,e,n,i,s){r(e,n,s*(n-t),s*(i-e))},initNonuniformCatmullRom:function(t,e,n,i,s,o,a){let l=(e-t)/s-(n-t)/(s+o)+(n-e)/o,h=(n-e)/o-(i-e)/(o+a)+(i-n)/a;l*=o,h*=o,r(e,n,l,h)},calc:function(r){const s=r*r;return t+e*r+n*s+i*(s*r)}}}Td.prototype.isArcCurve=!0;const Pd=new Is,Ld=new Ad,Rd=new Ad,Cd=new Ad;class Id extends Ed{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new Is){const n=e,i=this.points,r=i.length,s=(r-(this.closed?0:1))*t;let o,a,l=Math.floor(s),h=s-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===h&&l===r-1&&(l=r-2,h=1),this.closed||l>0?o=i[(l-1)%r]:(Pd.subVectors(i[0],i[1]).add(i[0]),o=Pd);const c=i[l%r],u=i[(l+1)%r];if(this.closed||l+2<r?a=i[(l+2)%r]:(Pd.subVectors(i[r-1],i[r-2]).add(i[r-1]),a=Pd),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(o.distanceToSquared(c),t),n=Math.pow(c.distanceToSquared(u),t),i=Math.pow(u.distanceToSquared(a),t);n<1e-4&&(n=1),e<1e-4&&(e=n),i<1e-4&&(i=n),Ld.initNonuniformCatmullRom(o.x,c.x,u.x,a.x,e,n,i),Rd.initNonuniformCatmullRom(o.y,c.y,u.y,a.y,e,n,i),Cd.initNonuniformCatmullRom(o.z,c.z,u.z,a.z,e,n,i)}else"catmullrom"===this.curveType&&(Ld.initCatmullRom(o.x,c.x,u.x,a.x,this.tension),Rd.initCatmullRom(o.y,c.y,u.y,a.y,this.tension),Cd.initCatmullRom(o.z,c.z,u.z,a.z,this.tension));return n.set(Ld.calc(h),Rd.calc(h),Cd.calc(h)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push(n.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const n=this.points[e];t.points.push(n.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new Is).fromArray(n))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function Od(t,e,n,i,r){const s=.5*(i-e),o=.5*(r-n),a=t*t;return(2*n-2*i+s+o)*(t*a)+(-3*n+3*i-2*s-o)*a+s*t+n}function Dd(t,e,n,i){return function(t,e){const n=1-t;return n*n*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,n)+function(t,e){return t*t*e}(t,i)}function zd(t,e,n,i,r){return function(t,e){const n=1-t;return n*n*n*e}(t,e)+function(t,e){const n=1-t;return 3*n*n*t*e}(t,n)+function(t,e){return 3*(1-t)*t*t*e}(t,i)+function(t,e){return t*t*t*e}(t,r)}Id.prototype.isCatmullRomCurve3=!0;class Nd extends Ed{constructor(t=new Ms,e=new Ms,n=new Ms,i=new Ms){super(),this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new Ms){const n=e,i=this.v0,r=this.v1,s=this.v2,o=this.v3;return n.set(zd(t,i.x,r.x,s.x,o.x),zd(t,i.y,r.y,s.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}Nd.prototype.isCubicBezierCurve=!0;class Ud extends Ed{constructor(t=new Is,e=new Is,n=new Is,i=new Is){super(),this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new Is){const n=e,i=this.v0,r=this.v1,s=this.v2,o=this.v3;return n.set(zd(t,i.x,r.x,s.x,o.x),zd(t,i.y,r.y,s.y,o.y),zd(t,i.z,r.z,s.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}Ud.prototype.isCubicBezierCurve3=!0;class Bd extends Ed{constructor(t=new Ms,e=new Ms){super(),this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new Ms){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){const n=e||new Ms;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}Bd.prototype.isLineCurve=!0;class Fd extends Ed{constructor(t=new Ms,e=new Ms,n=new Ms){super(),this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new Ms){const n=e,i=this.v0,r=this.v1,s=this.v2;return n.set(Dd(t,i.x,r.x,s.x),Dd(t,i.y,r.y,s.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}Fd.prototype.isQuadraticBezierCurve=!0;class Vd extends Ed{constructor(t=new Is,e=new Is,n=new Is){super(),this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new Is){const n=e,i=this.v0,r=this.v1,s=this.v2;return n.set(Dd(t,i.x,r.x,s.x),Dd(t,i.y,r.y,s.y),Dd(t,i.z,r.z,s.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}Vd.prototype.isQuadraticBezierCurve3=!0;class kd extends Ed{constructor(t=[]){super(),this.type="SplineCurve",this.points=t}getPoint(t,e=new Ms){const n=e,i=this.points,r=(i.length-1)*t,s=Math.floor(r),o=r-s,a=i[0===s?s:s-1],l=i[s],h=i[s>i.length-2?i.length-1:s+1],c=i[s>i.length-3?i.length-1:s+2];return n.set(Od(o,a.x,l.x,h.x,c.x),Od(o,a.y,l.y,h.y,c.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push(n.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const n=this.points[e];t.points.push(n.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new Ms).fromArray(n))}return this}}kd.prototype.isSplineCurve=!0;var Hd=Object.freeze({__proto__:null,ArcCurve:Td,CatmullRomCurve3:Id,CubicBezierCurve:Nd,CubicBezierCurve3:Ud,EllipseCurve:Sd,LineCurve:Bd,LineCurve3:class extends Ed{constructor(t=new Is,e=new Is){super(),this.type="LineCurve3",this.isLineCurve3=!0,this.v1=t,this.v2=e}getPoint(t,e=new Is){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},QuadraticBezierCurve:Fd,QuadraticBezierCurve3:Vd,SplineCurve:kd});class Gd extends Ed{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Bd(e,t))}getPoint(t){const e=t*this.getLength(),n=this.getCurveLengths();let i=0;for(;i<n.length;){if(n[i]>=e){const t=n[i]-e,r=this.curves[i],s=r.getLength(),o=0===s?0:1-t/s;return r.getPointAt(o)}i++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let i=0,r=this.curves;i<r.length;i++){const s=r[i],o=s&&s.isEllipseCurve?2*t:s&&(s.isLineCurve||s.isLineCurve3)?1:s&&s.isSplineCurve?t*s.points.length:t,a=s.getPoints(o);for(let t=0;t<a.length;t++){const i=a[t];n&&n.equals(i)||(e.push(i),n=i)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push(n.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){const n=this.curves[e];t.curves.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push((new Hd[n.type]).fromJSON(n))}return this}}class Wd extends Gd{constructor(t){super(),this.type="Path",this.currentPoint=new Ms,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new Bd(this.currentPoint.clone(),new Ms(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){const r=new Fd(this.currentPoint.clone(),new Ms(t,e),new Ms(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,r,s){const o=new Nd(this.currentPoint.clone(),new Ms(t,e),new Ms(n,i),new Ms(r,s));return this.curves.push(o),this.currentPoint.set(r,s),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new kd(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,r,s){const o=this.currentPoint.x,a=this.currentPoint.y;return this.absarc(t+o,e+a,n,i,r,s),this}absarc(t,e,n,i,r,s){return this.absellipse(t,e,n,n,i,r,s),this}ellipse(t,e,n,i,r,s,o,a){const l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+l,e+h,n,i,r,s,o,a),this}absellipse(t,e,n,i,r,s,o,a){const l=new Sd(t,e,n,i,r,s,o,a);if(this.curves.length>0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class jd extends Wd{constructor(t){super(t),this.uuid=ws.generateUUID(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push(n.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){const n=this.holes[e];t.holes.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push((new Wd).fromJSON(n))}return this}}class Xd extends zo{constructor(t,e=1){super(),this.type="Light",this.color=new sa(t),this.intensity=e}copy(t){return super.copy(t),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}Xd.prototype.isLight=!0;(class extends Xd{constructor(t,e,n){super(t,n),this.type="HemisphereLight",this.position.copy(zo.DefaultUp),this.updateMatrix(),this.groundColor=new sa(e)}copy(t){return Xd.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}).prototype.isHemisphereLight=!0;const Yd=new ho,qd=new Is,Zd=new Is;class Jd{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new Ms(512,512),this.map=null,this.mapPass=null,this.matrix=new ho,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new al,this._frameExtents=new Ms(1,1),this._viewportCount=1,this._viewports=[new Ls(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;qd.setFromMatrixPosition(t.matrixWorld),e.position.copy(qd),Zd.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Zd),e.updateMatrixWorld(),Yd.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Yd),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(e.projectionMatrix),n.multiply(e.matrixWorldInverse)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class $d extends Jd{constructor(){super(new tl(50,1,.5,500)),this.focus=1}updateMatrices(t){const e=this.camera,n=2*ws.RAD2DEG*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=t.distance||e.far;n===e.fov&&i===e.aspect&&r===e.far||(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}$d.prototype.isSpotLightShadow=!0;(class extends Xd{constructor(t,e,n=0,i=Math.PI/3,r=0,s=1){super(t,e),this.type="SpotLight",this.position.copy(zo.DefaultUp),this.updateMatrix(),this.target=new zo,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.shadow=new $d}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}copy(t){return super.copy(t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}).prototype.isSpotLight=!0;const Qd=new ho,Kd=new Is,tp=new Is;class ep extends Jd{constructor(){super(new tl(90,1,.5,500)),this._frameExtents=new Ms(4,2),this._viewportCount=6,this._viewports=[new Ls(2,1,1,1),new Ls(0,1,1,1),new Ls(3,1,1,1),new Ls(1,1,1,1),new Ls(3,0,1,1),new Ls(1,0,1,1)],this._cubeDirections=[new Is(1,0,0),new Is(-1,0,0),new Is(0,0,1),new Is(0,0,-1),new Is(0,1,0),new Is(0,-1,0)],this._cubeUps=[new Is(0,1,0),new Is(0,1,0),new Is(0,1,0),new Is(0,1,0),new Is(0,0,1),new Is(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,i=this.matrix,r=t.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Kd.setFromMatrixPosition(t.matrixWorld),n.position.copy(Kd),tp.copy(n.position),tp.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(tp),n.updateMatrixWorld(),i.makeTranslation(-Kd.x,-Kd.y,-Kd.z),Qd.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Qd)}}ep.prototype.isPointLightShadow=!0;(class extends Xd{constructor(t,e,n=0,i=1){super(t,e),this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new ep}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}copy(t){return super.copy(t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}).prototype.isPointLight=!0;class np extends Ka{constructor(t=-1,e=1,n=1,i=-1,r=.1,s=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-t,s=n+t,o=i+e,a=i-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,s=r+t*this.view.width,o-=e*this.view.offsetY,a=o-e*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=zo.prototype.toJSON.call(this,t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}np.prototype.isOrthographicCamera=!0;class ip extends Jd{constructor(){super(new np(-5,5,5,-5,.5,500))}}ip.prototype.isDirectionalLightShadow=!0;(class extends Xd{constructor(t,e){super(t,e),this.type="DirectionalLight",this.position.copy(zo.DefaultUp),this.updateMatrix(),this.target=new zo,this.shadow=new ip}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}).prototype.isDirectionalLight=!0;(class extends Xd{constructor(t,e){super(t,e),this.type="AmbientLight"}}).prototype.isAmbientLight=!0;(class extends Xd{constructor(t,e,n=10,i=10){super(t,e),this.type="RectAreaLight",this.width=n,this.height=i}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}).prototype.isRectAreaLight=!0;class rp{constructor(){this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new Is)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const n=t.x,i=t.y,r=t.z,s=this.coefficients;return e.copy(s[0]).multiplyScalar(.282095),e.addScaledVector(s[1],.488603*i),e.addScaledVector(s[2],.488603*r),e.addScaledVector(s[3],.488603*n),e.addScaledVector(s[4],n*i*1.092548),e.addScaledVector(s[5],i*r*1.092548),e.addScaledVector(s[6],.315392*(3*r*r-1)),e.addScaledVector(s[7],n*r*1.092548),e.addScaledVector(s[8],.546274*(n*n-i*i)),e}getIrradianceAt(t,e){const n=t.x,i=t.y,r=t.z,s=this.coefficients;return e.copy(s[0]).multiplyScalar(.886227),e.addScaledVector(s[1],1.023328*i),e.addScaledVector(s[2],1.023328*r),e.addScaledVector(s[3],1.023328*n),e.addScaledVector(s[4],.858086*n*i),e.addScaledVector(s[5],.858086*i*r),e.addScaledVector(s[6],.743125*r*r-.247708),e.addScaledVector(s[7],.858086*n*r),e.addScaledVector(s[8],.429043*(n*n-i*i)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(t,e+3*i);return this}toArray(t=[],e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(t,e+3*i);return t}static getBasisAt(t,e){const n=t.x,i=t.y,r=t.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*r,e[3]=.488603*n,e[4]=1.092548*n*i,e[5]=1.092548*i*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*n*r,e[8]=.546274*(n*n-i*i)}}rp.prototype.isSphericalHarmonics3=!0;class sp extends Xd{constructor(t=new rp,e=1){super(void 0,e),this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}fromJSON(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}sp.prototype.isLightProbe=!0;const op=function(t){const e=t.lastIndexOf("/");return-1===e?"./":t.substr(0,e+1)};function ap(){Pa.call(this),this.type="InstancedBufferGeometry",this.instanceCount=1/0}function lp(t,e,n,i){"number"==typeof n&&(i=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),ha.call(this,t,e,n),this.meshPerAttribute=i||1}function hp(t){"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),gd.call(this,t),this.options={premultiplyAlpha:"none"}}ap.prototype=Object.assign(Object.create(Pa.prototype),{constructor:ap,isInstancedBufferGeometry:!0,copy:function(t){return Pa.prototype.copy.call(this,t),this.instanceCount=t.instanceCount,this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){const t=Pa.prototype.toJSON.call(this);return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}),lp.prototype=Object.assign(Object.create(ha.prototype),{constructor:lp,isInstancedBufferAttribute:!0,copy:function(t){return ha.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},toJSON:function(){const t=ha.prototype.toJSON.call(this);return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}),hp.prototype=Object.assign(Object.create(gd.prototype),{constructor:hp,isImageBitmapLoader:!0,setOptions:function(t){return this.options=t,this},load:function(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=fd.get(t);if(void 0!==s)return r.manager.itemStart(t),setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s;const o={};o.credentials="anonymous"===this.crossOrigin?"same-origin":"include",o.headers=this.requestHeader,fetch(t,o).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(n){fd.add(t,n),e&&e(n),r.manager.itemEnd(t)})).catch((function(e){i&&i(e),r.manager.itemError(t),r.manager.itemEnd(t)})),r.manager.itemStart(t)}});class cp{constructor(){this.type="ShapePath",this.color=new sa,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Wd,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,r,s){return this.currentPath.bezierCurveTo(t,e,n,i,r,s),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t,e){function n(t){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n],r=new jd;r.curves=i.curves,e.push(r)}return e}function i(t,e){const n=e.length;let i=!1;for(let r=n-1,s=0;s<n;r=s++){let n=e[r],o=e[s],a=o.x-n.x,l=o.y-n.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(n=e[s],a=-a,o=e[r],l=-l),t.y<n.y||t.y>o.y)continue;if(t.y===n.y){if(t.x===n.x)return!0}else{const e=l*(t.x-n.x)-a*(t.y-n.y);if(0===e)return!0;if(e<0)continue;i=!i}}else{if(t.y!==n.y)continue;if(o.x<=t.x&&t.x<=n.x||n.x<=t.x&&t.x<=o.x)return!0}}return i}const r=Wu.isClockWise,s=this.subPaths;if(0===s.length)return[];if(!0===e)return n(s);let o,a,l;const h=[];if(1===s.length)return a=s[0],l=new jd,l.curves=a.curves,h.push(l),h;let c=!r(s[0].getPoints());c=t?!c:c;const u=[],d=[];let p,f,m=[],g=0;d[g]=void 0,m[g]=[];for(let e=0,n=s.length;e<n;e++)a=s[e],p=a.getPoints(),o=r(p),o=t?!o:o,o?(!c&&d[g]&&g++,d[g]={s:new jd,p:p},d[g].s.curves=a.curves,c&&g++,m[g]=[]):m[g].push({h:a,p:p[0]});if(!d[0])return n(s);if(d.length>1){let t=!1;const e=[];for(let t=0,e=d.length;t<e;t++)u[t]=[];for(let n=0,r=d.length;n<r;n++){const r=m[n];for(let s=0;s<r.length;s++){const o=r[s];let a=!0;for(let r=0;r<d.length;r++)i(o.p,d[r].p)&&(n!==r&&e.push({froms:n,tos:r,hole:s}),a?(a=!1,u[r].push(o)):t=!0);a&&u[n].push(o)}}e.length>0&&(t||(m=u))}for(let t=0,e=d.length;t<e;t++){l=d[t].s,h.push(l),f=m[t];for(let t=0,e=f.length;t<e;t++)l.holes.push(f[t].h)}return h}}function up(t,e,n,i,r){const s=r.glyphs[t]||r.glyphs["?"];if(!s)return void console.error('THREE.Font: character "'+t+'" does not exists in font family '+r.familyName+".");const o=new cp;let a,l,h,c,u,d,p,f;if(s.o){const t=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let r=0,s=t.length;r<s;){switch(t[r++]){case"m":a=t[r++]*e+n,l=t[r++]*e+i,o.moveTo(a,l);break;case"l":a=t[r++]*e+n,l=t[r++]*e+i,o.lineTo(a,l);break;case"q":h=t[r++]*e+n,c=t[r++]*e+i,u=t[r++]*e+n,d=t[r++]*e+i,o.quadraticCurveTo(u,d,h,c);break;case"b":h=t[r++]*e+n,c=t[r++]*e+i,u=t[r++]*e+n,d=t[r++]*e+i,p=t[r++]*e+n,f=t[r++]*e+i,o.bezierCurveTo(u,d,p,f,h,c)}}}return{offsetX:s.ha*e,path:o}}let dp;(class{constructor(t){this.type="Font",this.data=t}generateShapes(t,e=100){const n=[],i=function(t,e,n){const i=Array.from(t),r=e/n.resolution,s=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*r,o=[];let a=0,l=0;for(let t=0;t<i.length;t++){const e=i[t];if("\n"===e)a=0,l-=s;else{const t=up(e,r,a,l,n);a+=t.offsetX,o.push(t.path)}}return o}(t,e,this.data);for(let t=0,e=i.length;t<e;t++)Array.prototype.push.apply(n,i[t].toShapes());return n}}).prototype.isFont=!0;const pp=function(){return void 0===dp&&(dp=new(window.AudioContext||window.webkitAudioContext)),dp};class fp extends gd{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new yd(this.manager);s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(n){try{const t=n.slice(0);pp().decodeAudioData(t,(function(t){e(t)}))}catch(e){i?i(e):console.error(e),r.manager.itemError(t)}}),n,i)}}(class extends sp{constructor(t,e,n=1){super(void 0,n);const i=(new sa).set(t),r=(new sa).set(e),s=new Is(i.r,i.g,i.b),o=new Is(r.r,r.g,r.b),a=Math.sqrt(Math.PI),l=a*Math.sqrt(.75);this.sh.coefficients[0].copy(s).add(o).multiplyScalar(a),this.sh.coefficients[1].copy(s).sub(o).multiplyScalar(l)}}).prototype.isHemisphereLightProbe=!0;(class extends sp{constructor(t,e=1){super(void 0,e);const n=(new sa).set(t);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}}).prototype.isAmbientLightProbe=!0;new ho,new ho;class mp{constructor(t,e,n){let i,r,s;switch(this.binding=t,this.valueSize=n,e){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const n=this.buffer,i=this.valueSize,r=t*i+i;let s=this.cumulativeWeight;if(0===s){for(let t=0;t!==i;++t)n[r+t]=n[t];s=e}else{s+=e;const t=e/s;this._mixBufferRegion(n,r,0,t,i)}this.cumulativeWeight=s}accumulateAdditive(t){const e=this.buffer,n=this.valueSize,i=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,n=this.buffer,i=t*e+e,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const t=e*this._origIndex;this._mixBufferRegion(n,i,t,1-r,e)}s>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(n[t]!==n[t+e]){o.setValue(n,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let t=n,r=i;t!==r;++t)e[t]=e[i+t%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,i,r){if(i>=.5)for(let i=0;i!==r;++i)t[e+i]=t[n+i]}_slerp(t,e,n,i){Cs.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){const s=this._workIndex*r;Cs.multiplyQuaternionsFlat(t,s,t,e,t,n),Cs.slerpFlat(t,e,t,e,t,s,i)}_lerp(t,e,n,i,r){const s=1-i;for(let o=0;o!==r;++o){const r=e+o;t[r]=t[r]*s+t[n+o]*i}}_lerpAdditive(t,e,n,i,r){for(let s=0;s!==r;++s){const r=e+s;t[r]=t[r]+t[n+s]*i}}}const gp=new RegExp("[\\[\\]\\.:\\/]","g"),vp="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",yp=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]"),xp=/(WCOD+)?/.source.replace("WCOD",vp),bp=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),wp=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Mp=new RegExp("^"+yp+xp+bp+wp+"$"),_p=["material","materials","bones"];function Ep(t,e,n){const i=n||Sp.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}function Sp(t,e,n){this.path=e,this.parsedPath=n||Sp.parseTrackName(e),this.node=Sp.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}Object.assign(Ep.prototype,{getValue:function(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(t,e)},setValue:function(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)},bind:function(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()},unbind:function(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}),Object.assign(Sp,{Composite:Ep,create:function(t,e,n){return t&&t.isAnimationObjectGroup?new Sp.Composite(t,e,n):new Sp(t,e,n)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(gp,"")},parseTrackName:function(t){const e=Mp.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const t=n.nodeName.substring(i+1);-1!==_p.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n},findNode:function(t,e){if(!e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t){for(let i=0;i<t.length;i++){const r=t[i];if(r.name===e||r.uuid===e)return r;const s=n(r.children);if(s)return s}return null},i=n(t.children);if(i)return i}return null}}),Object.assign(Sp.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(t,e){t[e]=this.node[this.propertyName]},function(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]},function(t,e){t[e]=this.resolvedProperty[this.propertyIndex]},function(t,e){this.resolvedProperty.toArray(t,e)}],SetterByBindingTypeAndVersioning:[[function(t,e){this.targetObject[this.propertyName]=t[e]},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]},function(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0},function(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty[this.propertyIndex]=t[e]},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty.fromArray(t,e)},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(t,e){this.bind(),this.getValue(t,e)},setValue:function(t,e){this.bind(),this.setValue(t,e)},bind:function(){let t=this.node;const e=this.parsedPath,n=e.objectName,i=e.propertyName;let r=e.propertyIndex;if(t||(t=Sp.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(n){let i=e.objectIndex;switch(n){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===i){i=e;break}break;default:if(void 0===t[n])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[n]}if(void 0!==i){if(void 0===t[i])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[i]}}const s=t[i];if(void 0===s){const n=e.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+n+"."+i+" but it wasn't found.",t)}let o=this.Versioning.None;this.targetObject=t,void 0!==t.needsUpdate?o=this.Versioning.NeedsUpdate:void 0!==t.matrixWorldNeedsUpdate&&(o=this.Versioning.MatrixWorldNeedsUpdate);let a=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===i){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.isBufferGeometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[r]&&(r=t.morphTargetDictionary[r])}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else void 0!==s.fromArray&&void 0!==s.toArray?(a=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(a=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(Sp.prototype,{_getValue_unbound:Sp.prototype.getValue,_setValue_unbound:Sp.prototype.setValue});(class{constructor(){this.uuid=ws.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,n=arguments.length;e!==n;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,n=this._paths,i=this._parsedPaths,r=this._bindings,s=r.length;let o=void 0,a=t.length,l=this.nCachedObjects_;for(let h=0,c=arguments.length;h!==c;++h){const c=arguments[h],u=c.uuid;let d=e[u];if(void 0===d){d=a++,e[u]=d,t.push(c);for(let t=0,e=s;t!==e;++t)r[t].push(new Sp(c,n[t],i[t]))}else if(d<l){o=t[d];const a=--l,h=t[a];e[h.uuid]=d,t[d]=h,e[u]=a,t[a]=c;for(let t=0,e=s;t!==e;++t){const e=r[t],s=e[a];let o=e[d];e[d]=s,void 0===o&&(o=new Sp(c,n[t],i[t])),e[a]=o}}else t[d]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_;for(let s=0,o=arguments.length;s!==o;++s){const o=arguments[s],a=o.uuid,l=e[a];if(void 0!==l&&l>=r){const s=r++,h=t[s];e[h.uuid]=l,t[l]=h,e[a]=s,t[s]=o;for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[s],r=e[l];e[l]=i,e[s]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,s=t.length;for(let o=0,a=arguments.length;o!==a;++o){const a=arguments[o].uuid,l=e[a];if(void 0!==l)if(delete e[a],l<r){const o=--r,a=t[o],h=--s,c=t[h];e[a.uuid]=l,t[l]=a,e[c.uuid]=o,t[o]=c,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[o],r=e[h];e[l]=i,e[o]=r,e.pop()}}else{const r=--s,o=t[r];r>0&&(e[o.uuid]=l),t[l]=o,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t];e[l]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const n=this._bindingsIndicesByPath;let i=n[t];const r=this._bindings;if(void 0!==i)return r[i];const s=this._paths,o=this._parsedPaths,a=this._objects,l=a.length,h=this.nCachedObjects_,c=new Array(l);i=r.length,n[t]=i,s.push(t),o.push(e),r.push(c);for(let n=h,i=a.length;n!==i;++n){const i=a[n];c[n]=new Sp(i,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(void 0!==n){const i=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length-1,a=s[o];e[t[o]]=n,s[n]=a,s.pop(),r[n]=r[o],r.pop(),i[n]=i[o],i.pop()}}}).prototype.isAnimationObjectGroup=!0;class Tp{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;const r=e.tracks,s=r.length,o=new Array(s),a={endingStart:2400,endingEnd:2400};for(let t=0;t!==s;++t){const e=r[t].createInterpolant(null);o[t]=e,e.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){const n=this._clip.duration,i=t._clip.duration,r=i/n,s=n/i;t.warp(1,r,e),this.warp(s,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const i=this._mixer,r=i.time,s=this.timeScale;let o=this._timeScaleInterpolant;null===o&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=r,a[1]=r+n,l[0]=t/s,l[1]=e/s,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const i=(t-r)*n;if(i<0||0===n)return;this._startTime=null,e=n*i}e*=this._updateTimeScale(t);const s=this._updateTime(e),o=this._updateWeight(t);if(o>0){const t=this._interpolants,e=this._propertyBindings;switch(this.blendMode){case 2501:for(let n=0,i=t.length;n!==i;++n)t[n].evaluate(s),e[n].accumulateAdditive(o);break;case 2500:default:for(let n=0,r=t.length;n!==r;++n)t[n].evaluate(s),e[n].accumulate(i,o)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;if(null!==n){e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,r=this._loopCount;const s=2202===n;if(0===t)return-1===r?i:s&&1==(1&r)?e-i:i;if(2200===n){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else{if(!(i<0)){this.time=i;break t}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),i>=e||i<0){const n=Math.floor(i/e);i-=e*n,r+=Math.abs(n);const o=this.repetitions-r;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===o){const e=t<0;this._setEndings(e,!e,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(s&&1==(1&r))return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=2401,i.endingEnd=2401):(i.endingStart=t?this.zeroSlopeAtStart?2401:2400:2402,i.endingEnd=e?this.zeroSlopeAtEnd?2401:2400:2402)}_scheduleFading(t,e,n){const i=this._mixer,r=i.time;let s=this._weightInterpolant;null===s&&(s=i._lendControlInterpolant(),this._weightInterpolant=s);const o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=e,o[1]=r+t,a[1]=n,this}}(class extends ys{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,s=t._propertyBindings,o=t._interpolants,a=n.uuid,l=this._bindingsByRootAndName;let h=l[a];void 0===h&&(h={},l[a]=h);for(let t=0;t!==r;++t){const r=i[t],l=r.name;let c=h[l];if(void 0!==c)s[t]=c;else{if(c=s[t],void 0!==c){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,a,l));continue}const i=e&&e._propertyBindings[t].binding.parsedPath;c=new mp(Sp.create(n,l,i),r.ValueTypeName,r.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,a,l),s[t]=c}o[t].resultBuffer=c.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,n=t._clip.uuid,i=this._actionsByClip[n];this._bindAction(t,i&&i.knownActions[0]),this._addInactiveAction(t,n,e)}const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,n){const i=this._actions,r=this._actionsByClip;let s=r[e];if(void 0===s)s={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=s;else{const e=s.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=i.length,i.push(t),s.actionByRoot[n]=t}_removeInactiveAction(t){const e=this._actions,n=e[e.length-1],i=t._cacheIndex;n._cacheIndex=i,e[i]=n,e.pop(),t._cacheIndex=null;const r=t._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,l=a[a.length-1],h=t._byClipCacheIndex;l._byClipCacheIndex=h,a[h]=l,a.pop(),t._byClipCacheIndex=null;delete o.actionByRoot[(t._localRoot||this._root).uuid],0===a.length&&delete s[r],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==--n.referenceCount&&this._removeInactiveBinding(n)}}_lendAction(t){const e=this._actions,n=t._cacheIndex,i=this._nActiveActions++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_takeBackAction(t){const e=this._actions,n=t._cacheIndex,i=--this._nActiveActions,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_addInactiveBinding(t,e,n){const i=this._bindingsByRootAndName,r=this._bindings;let s=i[e];void 0===s&&(s={},i[e]=s),s[n]=t,t._cacheIndex=r.length,r.push(t)}_removeInactiveBinding(t){const e=this._bindings,n=t.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=e[e.length-1],l=t._cacheIndex;a._cacheIndex=l,e[l]=a,e.pop(),delete o[r],0===Object.keys(o).length&&delete s[i]}_lendBinding(t){const e=this._bindings,n=t._cacheIndex,i=this._nActiveBindings++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_takeBackBinding(t){const e=this._bindings,n=t._cacheIndex,i=--this._nActiveBindings,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let n=t[e];return void 0===n&&(n=new nd(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){const e=this._controlInterpolants,n=t.__cacheIndex,i=--this._nActiveControlInterpolants,r=e[i];t.__cacheIndex=i,e[i]=t,r.__cacheIndex=n,e[n]=r}clipAction(t,e,n){const i=e||this._root,r=i.uuid;let s="string"==typeof t?dd.findByName(i,t):t;const o=null!==s?s.uuid:t,a=this._actionsByClip[o];let l=null;if(void 0===n&&(n=null!==s?s.blendMode:2500),void 0!==a){const t=a.actionByRoot[r];if(void 0!==t&&t.blendMode===n)return t;l=a.knownActions[0],null===s&&(s=l._clip)}if(null===s)return null;const h=new Tp(this,s,e,n);return this._bindAction(h,l),this._addInactiveAction(h,o,r),h}existingAction(t,e){const n=e||this._root,i=n.uuid,r="string"==typeof t?dd.findByName(n,t):t,s=r?r.uuid:t,o=this._actionsByClip[s];return void 0!==o&&o.actionByRoot[i]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),s=this._accuIndex^=1;for(let o=0;o!==n;++o){e[o]._update(i,t,r,s)}const o=this._bindings,a=this._nActiveBindings;for(let t=0;t!==a;++t)o[t].apply(s);return this}setTime(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,n=t.uuid,i=this._actionsByClip,r=i[n];if(void 0!==r){const t=r.knownActions;for(let n=0,i=t.length;n!==i;++n){const i=t[n];this._deactivateAction(i);const r=i._cacheIndex,s=e[e.length-1];i._cacheIndex=null,i._byClipCacheIndex=null,s._cacheIndex=r,e[r]=s,e.pop(),this._removeInactiveBindingsForAction(i)}delete i[n]}}uncacheRoot(t){const e=t.uuid,n=this._actionsByClip;for(const t in n){const i=n[t].actionByRoot[e];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}const i=this._bindingsByRootAndName[e];if(void 0!==i)for(const t in i){const e=i[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(t,e){const n=this.existingAction(t,e);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}).prototype._controlInterpolantsResultBuffer=new Float32Array(1);class Ap{constructor(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}clone(){return new Ap(void 0===this.value.clone?this.value:this.value.clone())}}function Pp(t,e,n){Sc.call(this,t,e),this.meshPerAttribute=n||1}function Lp(t,e,n,i,r){this.buffer=t,this.type=e,this.itemSize=n,this.elementSize=i,this.count=r,this.version=0}function Rp(t,e,n=0,i=1/0){this.ray=new lo(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new wo,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function Cp(t,e){return t.distance-e.distance}function Ip(t,e,n,i){if(t.layers.test(e.layers)&&t.raycast(e,n),!0===i){const i=t.children;for(let t=0,r=i.length;t<r;t++)Ip(i[t],e,n,!0)}}Pp.prototype=Object.assign(Object.create(Sc.prototype),{constructor:Pp,isInstancedInterleavedBuffer:!0,copy:function(t){return Sc.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},clone:function(t){const e=Sc.prototype.clone.call(this,t);return e.meshPerAttribute=this.meshPerAttribute,e},toJSON:function(t){const e=Sc.prototype.toJSON.call(this,t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}),Object.defineProperty(Lp.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Lp.prototype,{isGLBufferAttribute:!0,setBuffer:function(t){return this.buffer=t,this},setType:function(t,e){return this.type=t,this.elementSize=e,this},setItemSize:function(t){return this.itemSize=t,this},setCount:function(t){return this.count=t,this}}),Object.assign(Rp.prototype,{set:function(t,e){this.ray.set(t,e)},setFromCamera:function(t,e){e&&e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e&&e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)},intersectObject:function(t,e=!1,n=[]){return Ip(t,this,n,e),n.sort(Cp),n},intersectObjects:function(t,e=!1,n=[]){for(let i=0,r=t.length;i<r;i++)Ip(t[i],this,n,e);return n.sort(Cp),n}});const Op=new Ms;class Dp{constructor(t=new Ms(1/0,1/0),e=new Ms(-1/0,-1/0)){this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Op.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return void 0===t&&(console.warn("THREE.Box2: .getCenter() target is now required"),t=new Ms),this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return void 0===t&&(console.warn("THREE.Box2: .getSize() target is now required"),t=new Ms),this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return void 0===e&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new Ms),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return void 0===e&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new Ms),e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return Op.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}Dp.prototype.isBox2=!0;const zp=new Is,Np=new Is;function Up(t){zo.call(this),this.material=t,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}Up.prototype=Object.create(zo.prototype),Up.prototype.constructor=Up,Up.prototype.isImmediateRenderObject=!0;const Bp=new Is,Fp=new ho,Vp=new ho;const kp=new oa({side:1,depthWrite:!1,depthTest:!1});new Xa(new qa,kp);Ed.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(Ed.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Wd.prototype.fromPoints=function(t){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(t)},class extends cu{constructor(t=10,e=10,n=4473924,i=8947848){n=new sa(n),i=new sa(i);const r=e/2,s=t/e,o=t/2,a=[],l=[];for(let t=0,h=0,c=-o;t<=e;t++,c+=s){a.push(-o,0,c,o,0,c),a.push(c,0,-o,c,0,o);const e=t===r?n:i;e.toArray(l,h),h+=3,e.toArray(l,h),h+=3,e.toArray(l,h),h+=3,e.toArray(l,h),h+=3}const h=new Pa;h.setAttribute("position",new ya(a,3)),h.setAttribute("color",new ya(l,3));super(h,new eu({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}}.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},class extends cu{constructor(t){const e=function t(e){const n=[];e&&e.isBone&&n.push(e);for(let i=0;i<e.children.length;i++)n.push.apply(n,t(e.children[i]));return n}(t),n=new Pa,i=[],r=[],s=new sa(0,0,1),o=new sa(0,1,0);for(let t=0;t<e.length;t++){const n=e[t];n.parent&&n.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(s.r,s.g,s.b),r.push(o.r,o.g,o.b))}n.setAttribute("position",new ya(i,3)),n.setAttribute("color",new ya(r,3));super(n,new eu({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(t){const e=this.bones,n=this.geometry,i=n.getAttribute("position");Vp.copy(this.root.matrixWorld).invert();for(let t=0,n=0;t<e.length;t++){const r=e[t];r.parent&&r.parent.isBone&&(Fp.multiplyMatrices(Vp,r.matrixWorld),Bp.setFromMatrixPosition(Fp),i.setXYZ(n,Bp.x,Bp.y,Bp.z),Fp.multiplyMatrices(Vp,r.parent.matrixWorld),Bp.setFromMatrixPosition(Fp),i.setXYZ(n+1,Bp.x,Bp.y,Bp.z),n+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}}.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},gd.prototype.extractUrlBase=function(t){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),op(t)},gd.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Dp.prototype.center=function(t){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(t)},Dp.prototype.empty=function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Dp.prototype.isIntersectionBox=function(t){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},Dp.prototype.size=function(t){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(t)},zs.prototype.center=function(t){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(t)},zs.prototype.empty=function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},zs.prototype.isIntersectionBox=function(t){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},zs.prototype.isIntersectionSphere=function(t){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},zs.prototype.size=function(t){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(t)},to.prototype.empty=function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()},al.prototype.setFromMatrix=function(t){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(t)},class{constructor(t=new Is,e=new Is){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return void 0===t&&(console.warn("THREE.Line3: .getCenter() target is now required"),t=new Is),t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return void 0===t&&(console.warn("THREE.Line3: .delta() target is now required"),t=new Is),t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return void 0===e&&(console.warn("THREE.Line3: .at() target is now required"),e=new Is),this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){zp.subVectors(t,this.start),Np.subVectors(this.end,this.start);const n=Np.dot(Np);let i=Np.dot(zp)/n;return e&&(i=ws.clamp(i,0,1)),i}closestPointToPoint(t,e,n){const i=this.closestPointToPointParameter(t,e);return void 0===n&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),n=new Is),this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}.prototype.center=function(t){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(t)},ws.random16=function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},ws.nearestPowerOfTwo=function(t){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),ws.floorPowerOfTwo(t)},ws.nextPowerOfTwo=function(t){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),ws.ceilPowerOfTwo(t)},_s.prototype.flattenToArrayOffset=function(t,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},_s.prototype.multiplyVector3=function(t){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},_s.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},_s.prototype.applyToBufferAttribute=function(t){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},_s.prototype.applyToVector3Array=function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")},_s.prototype.getInverse=function(t){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(t).invert()},ho.prototype.extractPosition=function(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)},ho.prototype.flattenToArrayOffset=function(t,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},ho.prototype.getPosition=function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new Is).setFromMatrixColumn(this,3)},ho.prototype.setRotationFromQuaternion=function(t){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(t)},ho.prototype.multiplyToArray=function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},ho.prototype.multiplyVector3=function(t){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},ho.prototype.multiplyVector4=function(t){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},ho.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},ho.prototype.rotateAxis=function(t){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),t.transformDirection(this)},ho.prototype.crossVector=function(t){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},ho.prototype.translate=function(){console.error("THREE.Matrix4: .translate() has been removed.")},ho.prototype.rotateX=function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},ho.prototype.rotateY=function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},ho.prototype.rotateZ=function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},ho.prototype.rotateByAxis=function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},ho.prototype.applyToBufferAttribute=function(t){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},ho.prototype.applyToVector3Array=function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},ho.prototype.makeFrustum=function(t,e,n,i,r,s){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(t,e,i,n,r,s)},ho.prototype.getInverse=function(t){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(t).invert()},Fo.prototype.isIntersectionLine=function(t){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(t)},Cs.prototype.multiplyVector3=function(t){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),t.applyQuaternion(this)},Cs.prototype.inverse=function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()},lo.prototype.isIntersectionBox=function(t){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},lo.prototype.isIntersectionPlane=function(t){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(t)},lo.prototype.isIntersectionSphere=function(t){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},Jo.prototype.area=function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},Jo.prototype.barycoordFromPoint=function(t,e){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(t,e)},Jo.prototype.midpoint=function(t){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(t)},Jo.prototypenormal=function(t){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(t)},Jo.prototype.plane=function(t){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(t)},Jo.barycoordFromPoint=function(t,e,n,i,r){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),Jo.getBarycoord(t,e,n,i,r)},Jo.normal=function(t,e,n,i){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),Jo.getNormal(t,e,n,i)},jd.prototype.extractAllPoints=function(t){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(t)},jd.prototype.extrude=function(t){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new Yu(this,t)},jd.prototype.makeGeometry=function(t){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new Ju(this,t)},Ms.prototype.fromAttribute=function(t,e,n){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},Ms.prototype.distanceToManhattan=function(t){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},Ms.prototype.lengthManhattan=function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Is.prototype.setEulerFromRotationMatrix=function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},Is.prototype.setEulerFromQuaternion=function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},Is.prototype.getPositionFromMatrix=function(t){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(t)},Is.prototype.getScaleFromMatrix=function(t){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(t)},Is.prototype.getColumnFromMatrix=function(t,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},Is.prototype.applyProjection=function(t){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(t)},Is.prototype.fromAttribute=function(t,e,n){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},Is.prototype.distanceToManhattan=function(t){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},Is.prototype.lengthManhattan=function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Ls.prototype.fromAttribute=function(t,e,n){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},Ls.prototype.lengthManhattan=function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},zo.prototype.getChildByName=function(t){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(t)},zo.prototype.renderDepth=function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},zo.prototype.translate=function(t,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,t)},zo.prototype.getWorldRotation=function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},zo.prototype.applyMatrix=function(t){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)},Object.defineProperties(zo.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(t){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=t}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Xa.prototype.setDrawMode=function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")},Object.defineProperties(Xa.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),0},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),qc.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},Object.defineProperty(Ed.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(t){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=t}}),tl.prototype.setLens=function(t,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==e&&(this.filmGauge=e),this.setFocalLength(t)},Object.defineProperties(Xd.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(t){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=t}},shadowCameraLeft:{set:function(t){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=t}},shadowCameraRight:{set:function(t){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=t}},shadowCameraTop:{set:function(t){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=t}},shadowCameraBottom:{set:function(t){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=t}},shadowCameraNear:{set:function(t){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=t}},shadowCameraFar:{set:function(t){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=t}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(t){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=t}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(t){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=t}},shadowMapHeight:{set:function(t){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=t}}}),Object.defineProperties(ha.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),35048===this.usage},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(35048)}}}),ha.prototype.setDynamic=function(t){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===t?35048:35044),this},ha.prototype.copyIndicesArray=function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},ha.prototype.setArray=function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},Pa.prototype.addIndex=function(t){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(t)},Pa.prototype.addAttribute=function(t,e){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute?"index"===t?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(e),this):this.setAttribute(t,e):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(t,new ha(arguments[1],arguments[2])))},Pa.prototype.addDrawCall=function(t,e,n){void 0!==n&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(t,e)},Pa.prototype.clearDrawCalls=function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},Pa.prototype.computeOffsets=function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},Pa.prototype.removeAttribute=function(t){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(t)},Pa.prototype.applyMatrix=function(t){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)},Object.defineProperties(Pa.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(ap.prototype,{maxInstancedCount:{get:function(){return console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount},set:function(t){console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount=t}}}),Object.defineProperties(Rp.prototype,{linePrecision:{get:function(){return console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold},set:function(t){console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold=t}}}),Object.defineProperties(Sc.prototype,{dynamic:{get:function(){return console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),35048===this.usage},set:function(t){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(t)}}}),Sc.prototype.setDynamic=function(t){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===t?35048:35044),this},Sc.prototype.setArray=function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},Yu.prototype.getArrays=function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")},Yu.prototype.addShapeList=function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")},Yu.prototype.addShape=function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")},Ec.prototype.dispose=function(){console.error("THREE.Scene: .dispose() has been removed.")},Ap.prototype.onUpdate=function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this},Object.defineProperties(Qo.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new sa}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===t}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(t){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=t}}}),Object.defineProperties(Qu.prototype,{transparency:{get:function(){return console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission},set:function(t){console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission=t}}}),Object.defineProperties(Qa.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(t){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=t}}}),wc.prototype.clearTarget=function(t,e,n,i){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(t),this.clear(e,n,i)},wc.prototype.animate=function(t){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(t)},wc.prototype.getCurrentRenderTarget=function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},wc.prototype.getMaxAnisotropy=function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},wc.prototype.getPrecision=function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},wc.prototype.resetGLState=function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},wc.prototype.supportsFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},wc.prototype.supportsHalfFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},wc.prototype.supportsStandardDerivatives=function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},wc.prototype.supportsCompressedTextureS3TC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},wc.prototype.supportsCompressedTexturePVRTC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},wc.prototype.supportsBlendMinMax=function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},wc.prototype.supportsVertexTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},wc.prototype.supportsInstancedArrays=function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},wc.prototype.enableScissorTest=function(t){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(t)},wc.prototype.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},wc.prototype.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},wc.prototype.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},wc.prototype.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},wc.prototype.setFaceCulling=function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},wc.prototype.allocTextureUnit=function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},wc.prototype.setTexture=function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},wc.prototype.setTexture2D=function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},wc.prototype.setTextureCube=function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},wc.prototype.getActiveMipMapLevel=function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()},Object.defineProperties(wc.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=t}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=t}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(t){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===t?3001:3e3}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}}),Object.defineProperties(dc.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(Rs.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=t}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=t}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=t}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=t}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(t){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=t}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(t){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=t}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(t){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=t}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(t){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=t}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(t){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=t}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(t){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=t}}}),class extends zo{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(t){return t||(t=[]),!0===this._connected?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){if(this.detune=t,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}}.prototype.load=function(t){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");const e=this;return(new fp).load(t,(function(t){e.setBuffer(t)})),this},class{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}}.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},el.prototype.updateCubeMap=function(t,e){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(t,e)},el.prototype.clear=function(t,e,n,i){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(t,e,n,i)},Ss.crossOrigin=void 0,Ss.loadTexture=function(t,e,n,i){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");const r=new _d;r.setCrossOrigin(this.crossOrigin);const s=r.load(t,n,void 0,i);return e&&(s.mapping=e),s},Ss.loadTextureCube=function(t,e,n,i){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");const r=new wd;r.setCrossOrigin(this.crossOrigin);const s=r.load(t,n,void 0,i);return e&&(s.mapping=e),s},Ss.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},Ss.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"127"}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="127");var Hp,Gp,Wp,jp,Xp=function(t,e){for(var n=new vc,i=0,r=e.length;i<r;i++)n.add(new Xa(t,e[i]));return n};!function(t){t[t.IDLE=0]="IDLE",t[t.DOWN=1]="DOWN",t[t.MOVE=2]="MOVE"}(Hp||(Hp={}));class Yp extends C{constructor(e){if(super(),this.needRender=!1,S.GetEnv()===t.Env.Miniapp){if(!e)throw Error("poi-overlay need a offscreenCanvas");Yp.canvas=e}else Yp.canvas||(Yp.canvas=document.createElement("canvas"));const n=S.GetGlobalDPR();Yp.canvas.width=500*n,Yp.canvas.height=500*n,Yp.ctx=Yp.canvas.getContext("2d")}init(t){const{THREE:n}=x.getInstance();this.rectMap=new Map,this.parent=t,this.scene=new n.Scene;const i=t.getViewWidth(),r=t.getViewHeight();this.renderCamera=new e.OrthographicCamera(-i/2,i/2,r/2,-r/2,.1,1e3),this.renderCamera.up.set(0,1,0),this.renderCamera.position.set(0,0,50),this.renderCamera.lookAt(0,0,0),this.camera=this.parent.camera,this.renderer=this.parent.renderer,this.pois=new Set,this.enabled=!0,this.orderPois=xe.debounce(this.orderPoisByLevel.bind(this),50),this.listeners={pointerDown:t=>{this.onPointerDown(t)},pointerUp:t=>{this.onPointerUp(t)},touchStart:t=>{this.onTouchStart(t)},touchEnd:t=>{this.onTouchEnd(t)}},this.mouseState=Hp.IDLE,this.mousePositionBuffer=new n.Vector2,this.parent.on(_.MOUSE_DOWN,this.listeners.pointerDown),this.parent.on(_.MOUSE_UP,this.listeners.pointerUp),this.parent.on(_.TOUCH_START,this.listeners.touchStart),this.parent.on(_.TOUCH_END,this.listeners.touchEnd)}update(){return!(!this.renderThisFrame&&!Array.from(this.pois).reduce((t,e)=>e.update()||t,!1))&&(this.renderThisFrame=!1,this.needRender=!0,!0)}forceRenderInThisFrame(){this.renderThisFrame=!0}render(){if(!this.enabled)return;const{THREE:t}=x.getInstance(),e=new t.Frustum;e.setFromProjectionMatrix((new t.Matrix4).multiplyMatrices(this.parent.camera.projectionMatrix,this.parent.camera.matrixWorldInverse));const n=this.parent.getViewWidth(),i=this.parent.getViewHeight();if((new t.Euler).setFromQuaternion(this.parent.camera.quaternion,"ZYX"),this.checkUpdate(),this.needRender||this.renderThisFrame){this.rectMap.clear();const t=[];this.pois.forEach(r=>{r.draw();const{isInFrustum:s}=r.calcPosAndSize(e,n/2,i/2);s&&t.push(r)}),this.recalculateVisibilities(t),Array.from(this.pois).forEach((t,e)=>{t.updatePosition(n/2,i/2,e)}),this.renderer.clearDepth(),this.renderer.render(this.scene,this.renderCamera)}this.renderThisFrame=!1,this.needRender=!1}orderPoisByLevel(){const t=Array.from(this.pois);t.sort((t,e)=>t.getLevel()-e.getLevel()),this.pois=new Set(t),this.renderThisFrame=!0}recalculateVisibilities(t){const e=[];let n=!0;Array.from(t).sort((t,e)=>e.collision?-1:e.getLevel()-t.getLevel()).forEach(t=>{const{xMin:i,yMin:r,xMax:s,yMax:o}=t.getBoundingRect();if(!t.collision)return t.setHidden(!1),e.push([i,s,r,o]),void(n=!1);const{xMin:a,yMin:l,xMax:h,yMax:c}=t.getOuterRect();if(n)return e.push([i,s,r,o]),n=!1,void t.setHidden(!1);if(!e.some(([t,e,n,a])=>!(s<t||i>e)&&!(o<n||r>a)))e.push([i,s,r,o]),t.setHidden(!1);else if("outer"===t.collisionMode)t.setHidden(!0);else if("icon"===t.collisionMode||"label"===t.collisionMode){!e.some(([t,e,n,i])=>!(h<t||a>e)&&!(c<n||l>i))?(e.push([i,s,r,o]),t.setHidden(!0,!0)):t.setHidden(!0)}})}checkUpdate(){const{THREE:t}=x.getInstance();if(this.renderThisFrame)return;if(Array.from(this.pois).some(t=>t.update()))return void(this.renderThisFrame=!0);const{camera:e}=this.parent,{quaternion:n,position:i,zoom:r,up:s}=e,o=i.clone(),a=n.clone(),l=r;if(!this.prevPosition)return this.prevPosition=o.clone(),this.prevQuaternion=a.clone(),this.prevZoom=l,void(this.renderThisFrame=!0);const h=(new t.Quaternion).setFromUnitVectors(s,new t.Vector3(0,1,0)),c=new t.Vector3(0,0,-1).applyQuaternion(this.prevQuaternion);c.applyQuaternion(h);const u=new t.Spherical;u.setFromVector3(c);const d=(new t.Quaternion).setFromUnitVectors(s,new t.Vector3(0,1,0)),p=new t.Vector3(0,0,-1).applyQuaternion(a);p.applyQuaternion(d);const f=new t.Spherical;if(f.setFromVector3(p),Math.abs(u.phi*(180/Math.PI)-f.phi*(180/Math.PI))+Math.abs(u.theta*(180/Math.PI)-f.theta*(180/Math.PI))>1e-4)return this.prevPosition=o.clone(),this.prevQuaternion=a.clone(),this.prevZoom=l,void(this.renderThisFrame=!0);const m=this.parent.getViewWidth(),g=this.parent.getViewHeight(),v=o.clone().project(e),y=(v.x-1)/2*m,b=(1-v.y)/2*g;v.set(y,b,0);const w=this.prevPosition.clone().project(e),M=(w.x-1)/2*m,_=(1-w.y)/2*g;return w.set(M,_,0),v.distanceTo(w)>1e-4||this.prevZoom!==l&&Math.abs((l-this.prevZoom)/l)>1e-4||Math.abs((this.prevZoom-l)/this.prevZoom)>1e-4?(this.prevPosition=o.clone(),this.prevQuaternion=a.clone(),this.prevZoom=l,void(this.renderThisFrame=!0)):void(this.renderThisFrame=!1)}dispose(){this.parent.off(_.MOUSE_DOWN,this.listeners.pointerDown),this.parent.off(_.MOUSE_UP,this.listeners.pointerUp),this.parent.off(_.TOUCH_START,this.listeners.touchStart),this.parent.off(_.TOUCH_END,this.listeners.touchEnd),this.clearPoi(),Yp.canvas&&(Yp.canvas.remove(),Yp.canvas=null),Yp.ctx&&(Yp.ctx=null)}onPointerDown(t){const{clientX:n,clientY:i}=t,[r,s]=this.parent.getViewOffset(),o=n-r,a=i-s;let l=null;Array.from(this.rectMap).some(([t,n])=>{const{xMin:i,yMin:r,xMax:s,yMax:h}=t;return!!new e.Box2(new e.Vector2(i,r),new e.Vector2(s,h)).containsPoint(new e.Vector2(o,a))&&(l=n,!0)}),l&&this.onNodePointerDown(l,o,a,t.button)}onPointerUp(t){const{THREE:e}=x.getInstance(),{clientX:n,clientY:i}=t,[r,s]=this.parent.getViewOffset(),o=n-r,a=i-s,l=new e.Vector2(o,a).distanceToSquared(this.mousePositionBuffer);this.emit(M.POI_UP,this.eventTarget,t.button),this.mouseState===Hp.DOWN&&l<100&&this.emit(M.POI_CLICKED,this.eventTarget,t.button),this.mouseState=Hp.IDLE}onTouchStart(t){const{clientX:n,clientY:i}=t.touches[0],[r,s]=this.parent.getViewOffset(),o=n-r,a=i-s;let l=null;Array.from(this.rectMap).some(([t,n])=>{const{xMin:i,yMin:r,xMax:s,yMax:h}=t;return!!new e.Box2(new e.Vector2(i,r),new e.Vector2(s,h)).containsPoint(new e.Vector2(o,a))&&(l=n,!0)}),l&&this.onNodePointerDown(l,o,a,0)}onTouchEnd(t){const{THREE:e}=x.getInstance(),{clientX:n,clientY:i}=t.changedTouches[0],[r,s]=this.parent.getViewOffset(),o=n-r,a=i-s,l=new e.Vector2(o,a).distanceToSquared(this.mousePositionBuffer);this.emit(M.POI_UP,this.eventTarget,0),this.mouseState===Hp.DOWN&&l<100&&this.emit(M.POI_CLICKED,this.eventTarget,0),this.mouseState=Hp.IDLE}onNodePointerDown(t,e,n,i=0){this.mouseState===Hp.IDLE&&(this.mouseState=Hp.DOWN,this.mousePositionBuffer.set(e,n),this.eventTarget=t,this.emit(M.POI_DOWN,t,i))}createPoi(t){const e=new qp;if(e.setParent(this),this.renderThisFrame=!0,e.setPosition(t),!this.pois)throw Error("poiOverlay need bind a view, use view.addOverlay()");return this.pois.add(e),this.scene.add(e.group),e}setRectMap(t,e){this.rectMap.set(t,e)}removePoi(t){this.pois.delete(t),this.scene.remove(t.group),t.dispose(),this.renderThisFrame=!0}clearPoi(){Array.from(this.pois).forEach(t=>{this.scene.remove(t.group)}),this.pois.clear(),this.renderThisFrame=!0}setVisibility(t){this.visible=t,this.enabled=t}setEnabled(t){this.enabled=t}resize(t,e){this.updateCameraAspect(t,e),this.renderThisFrame=!0}updateCameraAspect(t,e){const n=t,i=e;this.renderCamera.left=-n/2,this.renderCamera.right=n/2,this.renderCamera.top=i/2,this.renderCamera.bottom=-i/2,this.renderCamera.updateProjectionMatrix()}}Yp.canvas=document.createElement("canvas"),Yp.ctx=Yp.canvas.getContext("2d");class qp{constructor(t){this._renderThisFrame=!1;const{THREE:n}=x.getInstance();this.dpr=S.GetGlobalDPR(),this.isFlipY=!1,this.position=t||new n.Vector3,this.group=new e.Group,this.textVisibility=!0,this.iconVisibility=!0,this.iconInCircle=!1,this.iconCircleOptions={width:0,color:"#ffffff"},this.textPosInfo={anchor:"center",offsetX:0,offsetY:0,anchorOffsetX:0,anchorOffsetY:0},this.iconPosInfo={anchor:"center",offsetX:0,offsetY:0,anchorOffsetX:0,anchorOffsetY:0},this.level=1,this.isInFrustum=!1,this.animationEnabled=!1,this.text=null,this.icon=null,this.rect=null,this.boundingBox=null,this.overlapArea={x:0,y:0},this.visible=!0,this.hide=!1,this.subHide=!1,this.rotation=0,this.autoRotation=!1,this.collision=!0,this.collisionMode="outer",this.iconRect={xMin:0,yMin:0,xMax:0,yMax:0},this.textRect={xMin:0,yMin:0,xMax:0,yMax:0},this.boundingRect={xMin:0,yMin:0,xMax:0,yMax:0},this.outerRect={xMin:0,yMin:0,xMax:0,yMax:0},this.visibilityAnimation={anim:null,from:1,to:1,current:1},this.text=null,this.textWidth=0,this.textHeight=0,this.icon=null,this.iconOptions={size:[20,20],src:null},this.labelOptions={fontSize:12,padding:0,content:null},this.rectOptions={width:0,height:0,fill:16711680,opacity:.5,offsetX:0,offsetY:0},this.visiblePartWhenCollision="none",this.subAreaOpacity=1,this.abandonedAreaOpacity=1,this.screenPosition={x:0,y:0},this.labelOpacity=1,this.iconOpacity=1}set renderThisFrame(t){this._renderThisFrame=t}get renderThisFrame(){return this._renderThisFrame}dispose(){this.group&&xe.dispose(this.group,!0),this.parent=null,this.iconCircleMaterial=null,this.iconMaterial=null,this.textMaterial=null,this.icon=null,this.rect=null,this.boundingBox=null,this.group=null}setParent(t){this.parent=t}setPosition(t,e=1e-4){t.distanceTo(this.position)<e||(this.position.copy(t),this.renderThisFrame=!0)}setOpacity(t=this.labelOpacity,e=this.iconOpacity){this.labelOpacity=t,this.iconOpacity=e}setRotation(t,e=1e-4){Math.abs(t-this.rotation)<e||(this.group.rotateZ(t-this.rotation),this.rotation=t,this.renderThisFrame=!0)}setCollision(t){this.collision=t,this.renderThisFrame=!0}setCollisionMode(t){this.collisionMode=t,this.renderThisFrame=!0}setLabelVisibility(t){this.textVisibility=t,this.renderThisFrame=!0}setIconVisiblity(t){this.iconVisibility=t,this.renderThisFrame=!0}setHideModeWhenCollision(t){"all"===t?this.setVisiblePartWhenCollision("none"):"none"===t?this.setVisiblePartWhenCollision("all"):this.setVisiblePartWhenCollision(t)}setVisiblePartWhenCollision(t){this.visiblePartWhenCollision=t}setCollisionOverlap(t,e){this.overlapArea={x:t,y:e},this.renderThisFrame=!0}setLevel(t,e=!1){this.level=t,this.renderThisFrame=!0,this.parent.orderPois(e)}getLevel(){return this.level}setVisibility(t){this.visible!==t&&(this.renderThisFrame=!0),this.visible=t}setHidden(t,e=!1){if(this.animationEnabled){const n=t?e?.5:0:1;if(this.visibilityAnimation.anim&&n===this.visibilityAnimation.to)return;if(!this.visibilityAnimation.anim&&t===this.hide&&e===this.subHide)return;this.visibilityAnimation.anim&&(this.visibilityAnimation.anim.stop(),this.visibilityAnimation.anim=null);const i={subAreaOpacity:this.subAreaOpacity,abandonedAreaOpacity:this.abandonedAreaOpacity},r={subAreaOpacity:0,abandonedAreaOpacity:0};t?e?(r.subAreaOpacity=1,r.abandonedAreaOpacity=0):(r.subAreaOpacity=0,r.abandonedAreaOpacity=0):(r.subAreaOpacity=1,r.abandonedAreaOpacity=1);let s=[];const o=[];switch(this.visiblePartWhenCollision){case"all":this.text&&s.push(this.textMaterial),this.icon&&(s.push(this.iconMaterial),this.iconCircleMaterial&&this.iconCircleMaterial.visible&&s.push(this.iconCircleMaterial));break;case"none":this.text&&o.push(this.textMaterial),this.icon&&(o.push(this.iconMaterial),this.iconCircleMaterial&&this.iconCircleMaterial.visible&&o.push(this.iconCircleMaterial));break;case"label":s=[this.textMaterial,this.rectMaterial],this.text&&s.push(this.textMaterial),this.icon&&(o.push(this.iconMaterial),this.iconCircleMaterial&&this.iconCircleMaterial.visible&&o.push(this.iconCircleMaterial));break;case"icon":this.text&&o.push(this.textMaterial),this.icon&&(s.push(this.iconMaterial),this.iconCircleMaterial&&this.iconCircleMaterial.visible&&s.push(this.iconCircleMaterial))}this.visibilityAnimation.from=this.visibilityAnimation.current,this.visibilityAnimation.to=t?e?.5:0:1;const a=300;this.visibilityAnimation.anim=new y.Tween(i).to(r,a).onUpdate(t=>{this.subAreaOpacity=t.subAreaOpacity,this.abandonedAreaOpacity=t.abandonedAreaOpacity,s.forEach(e=>{e.opacity=t.subAreaOpacity}),o.forEach(e=>{e.opacity=t.abandonedAreaOpacity})}).start().onComplete(()=>{this.visibilityAnimation.anim=null,this.visibilityAnimation.from=null,this.visibilityAnimation.current=null,this.visibilityAnimation.to=null,this.hide=t,this.subHide=e})}else this.hide===t&&this.subHide===e||(this.hide=t,this.subHide=e,this.renderThisFrame=!0)}setRect(t){this.withRect=t,this.renderThisFrame=!0}setRectDefSize(t,e){this.rectOptions.width=t,this.rectOptions.height=e,this.renderThisFrame=!0}setRectFill(t){this.rectOptions.fill=t,this.renderThisFrame=!0}setRectOffset(t=0,e=0){this.rectOptions.offsetX=t,this.rectOptions.offsetY=e,this.renderThisFrame=!0}setIconImage(t){this.iconOptions&&this.iconOptions.src===t||(this.iconOptions.src=t,this.clearIcon(),this.renderThisFrame=!0)}setIconSize(t,e){this.iconSize=[t,e],this.iconOptions.size=[t,e],this.renderThisFrame=!0}setIconShowInCircle(t,e){this.iconInCircle=!0,this.iconCircleOptions={width:t,color:e}}drawIcon(){const{src:t,size:n}=this.iconOptions;if(t&&(!this.icon||!this.group.getObjectByName("poi_icon")||!!this.iconInCircle!=!!this.iconCircleMaterial))if(qp.ImageMaterialMap.has(t))if("dealing"===qp.ImageMaterialMap.get(t))this.renderThisFrame=!0;else{this.icon&&this.group.remove(this.icon),this.iconMaterial=qp.ImageMaterialMap.get(t).clone(),this.iconMaterial.opacity=this.iconOpacity;const{width:i,color:r}=this.iconCircleOptions,s=i&&this.iconInCircle;s&&(this.iconCircleMaterial=new e.MeshBasicMaterial({color:r,transparent:!0,opacity:this.iconOpacity}));const o=s?[this.iconCircleMaterial,this.iconMaterial]:[this.iconMaterial],a=s?new e.CircleGeometry(n[0]/2,30):new e.PlaneGeometry(n[0],n[1]),l=Xp(a,o);this.icon=l,this.icon&&(this.icon.children.length>1&&this.icon.children[1].scale.set(n[0]/(i+n[0]),n[0]/(i+n[0]),1),this.icon.renderOrder=3,this.icon.name="poi_icon",this.group.add(this.icon),this.renderThisFrame=!0)}else{qp.ImageMaterialMap.set(t,"dealing");(new e.TextureLoader).load(t,n=>{n.needsUpdate=!0,n.magFilter=e.LinearFilter,n.minFilter=e.NearestFilter,n.flipY=this.isFlipY;const i=new e.MeshBasicMaterial({map:n,transparent:!0,opacity:this.iconOpacity});i.needsUpdate=!0,i.visible=!0,qp.ImageMaterialMap.set(t,i)})}}clearIcon(){this.icon&&(this.group&&this.group.remove(this.icon),this.icon.children.forEach(t=>{t.geometry&&t.geometry.dispose()}),this.iconMaterial&&(this.iconMaterial.dispose(),this.iconMaterial=null),this.iconCircleMaterial&&(this.iconCircleMaterial.dispose(),this.iconCircleMaterial=null),this.icon=null)}setIconAnchor(t){this.iconPosInfo.anchor=t,this.renderThisFrame=!0}setIconFlipY(t){this.isFlipY=t}setIconOffset(t,e){this.iconPosInfo.anchorOffsetX=t,this.iconPosInfo.anchorOffsetY=e,this.renderThisFrame=!0}setFontSize(t){this.labelOptions.fontSize=t,this.renderThisFrame=!0}setFontPadding(t){this.labelOptions.padding=t,this.renderThisFrame=!0}setLabelText(t){this.labelOptions.content=t,this.renderThisFrame=!0}drawText(){if(!this.labelOptions.content)return;if(this.group.getObjectByName("poi_text"))return;const t=this.dpr,{fontSize:n,padding:i,content:r}=this.labelOptions;Yp.ctx.font=n*t+"px sans-serif",Yp.ctx.fillStyle="black";const s=Yp.ctx.measureText(r),o=Math.ceil(s.width)+10+2*i,a=(n+5+2*i)*t;this.textWidth=o/t,this.textHeight=a/t,this.setRectDefSize(this.textWidth,this.textHeight),Yp.ctx.clearRect(0,0,o,a),Yp.ctx.fillText(r,i*t,(n+i)*t);const l=Yp.ctx.getImageData(0,0,o,a);this.textMaterial=new e.MeshBasicMaterial({transparent:!0,map:new e.DataTexture(Uint8Array.from(l.data),o,a,e.RGBAFormat),side:e.DoubleSide,opacity:this.labelOpacity}),this.text=new e.Mesh(new e.PlaneGeometry(this.textWidth,this.textHeight),this.textMaterial),this.text.material.map.flipY=!0,this.text.material.map.flipX=!0,this.text.material.map.needsUpdate=!0,this.text.material.map.magFilter=e.LinearFilter,this.text.material.visible=!0,this.text.name="poi_text",this.text.renderOrder=4;const{offsetX:h,offsetY:c}=this.recalcOffset(this.textWidth,this.textHeight,this.textPosInfo.anchor,this.textPosInfo.anchorOffsetX,this.textPosInfo.anchorOffsetY);this.textPosInfo.offsetX=h,this.textPosInfo.offsetY=c,this.group.add(this.text)}recalcOffset(t,e,n,i,r){let s=0,o=0;switch(n){case"center":s=i,o=r;break;case"left":s=t/2+i,o=r;break;case"right":s=-t/2+i,o=r;break;case"top":s=i,o=-e/2+r;break;case"bottom":s=i,o=e/2+r;break;case"topleft":s=t/2+i,o=-e/2+r;break;case"topright":s=-t/2+i,o=-e/2+r;break;case"bottomleft":s=t/2+i,o=e/2+r;break;case"bottomright":s=-t/2+i,o=e/2+r}return{offsetX:s,offsetY:o}}setLabelAnchor(t){this.textPosInfo.anchor=t,this.renderThisFrame=!0}setLabelOffset(t,e){this.textPosInfo.anchorOffsetX=t,this.textPosInfo.anchorOffsetY=e,this.renderThisFrame=!0}getLabelAnchor(){return this.textPosInfo.anchor}getLabelOffset(){const{anchorOffsetX:t,anchorOffsetY:e}=this.textPosInfo;return{x:t,y:e}}calcBoundingSize(){const t=this.screenPosition,e=this.textPosInfo.offsetX,n=this.textPosInfo.offsetY,i=this.iconPosInfo.offsetX,r=this.iconPosInfo.offsetY,s={xMin:this.text?t.x-this.textWidth/2+e:t.x,xMax:this.text?t.x+this.textWidth/2+e:t.x,yMin:this.text?t.y-this.textHeight/2-n:t.y,yMax:this.text?t.y+this.textHeight/2-n:t.y},o={xMin:this.icon?t.x-this.iconOptions.size[0]/2+i:t.x,xMax:this.icon?t.x+this.iconOptions.size[0]/2+i:t.x,yMin:this.icon?t.y-this.iconOptions.size[1]/2-r:t.y,yMax:this.icon?t.y+this.iconOptions.size[1]/2-r:t.y};let a=Math.max(o.xMax,s.xMax),l=Math.min(o.xMin,s.xMin),h=Math.max(o.yMax,s.yMax),c=Math.min(o.yMin,s.yMin);this.iconRect={xMin:this.icon?t.x-this.iconOptions.size[0]/2+i:t.x,xMax:this.icon?t.x+this.iconOptions.size[0]/2+i:t.x,yMin:this.icon?t.y-this.iconOptions.size[1]/2-r:t.y,yMax:this.icon?t.y+this.iconOptions.size[1]/2-r:t.y},this.textRect={xMin:this.text?t.x-this.textWidth/2+e:t.x,xMax:this.text?t.x+this.textWidth/2+e:t.x,yMin:this.text?t.y-this.textHeight/2-n:t.y,yMax:this.text?t.y+this.textHeight/2-n:t.y},this.outerRect={xMax:a,xMin:l,yMax:h,yMin:c},"icon"===this.collisionMode?(a=o.xMax,l=o.xMin,h=o.yMax,c=o.yMin):"label"===this.collisionMode&&(a=s.xMax,l=s.xMin,h=s.yMax,c=s.yMin),this.boundingRect.xMax=a,this.boundingRect.yMax=h,this.boundingRect.xMin=l,this.boundingRect.yMin=c}drawRect(){if(!this.withRect||!this.labelOptions.content)return;if(this.rect&&this.group.getObjectByName("poi_rect"))return;this.rect=new e.Group;const t=this.rectOptions.width||this.textWidth,n=this.rectOptions.height||this.textHeight,i=[0+t/2-10,0+n/2],r=[0+t/2,0+n/2-10],s=[0+t/2,0-n/2+10],o=[0+t/2-10,0-n/2],a=[0-t/2+10,0-n/2],l=[0-t/2,0-n/2+10],h=[0-t/2,0+n/2-10],c=[0-t/2+10,0+n/2],u=new e.Shape;u.moveTo(i[0],i[1]),u.bezierCurveTo(i[0],i[1],0+t/2,0+n/2,r[0],r[1]),u.moveTo(s[0],s[1]),u.bezierCurveTo(s[0],s[1],0+t/2,0-n/2,o[0],o[1]),u.moveTo(a[0],a[1]),u.bezierCurveTo(a[0],a[1],0-t/2,0-n/2,l[0],l[1]),u.moveTo(h[0],h[1]),u.bezierCurveTo(h[0],h[1],0-t/2,0+n/2,c[0],c[1]),u.moveTo(i[0],i[1]);const d=new e.ShapeGeometry(u),p=new e.MeshBasicMaterial({color:255,transparent:!0,opacity:.5});this.rectMaterial=p;const f=new e.Mesh(d,p);u.autoClose=!0;const m=u.getPoints(),g=(new e.BufferGeometry).setFromPoints(m),v=new e.Line(g,new e.LineBasicMaterial({color:16711680}));v.position.set(0,0,0),this.rect.add(f),this.rect.add(v),this.rect.renderOrder=2,this.rect.name="poi_rect",this.group.add(this.rect)}drawBoundingBox(){if(!this.withBoundingBox)return;if(this.group.getObjectByName("poi_bounding_rect"))return;if(0===this.outerRect.xMin&&0===this.outerRect.xMax)return;const{xMax:t,yMax:n,xMin:i,yMin:r}=this.outerRect;this.boundingBox=new e.Group;const s=t-i,o=n-r,a=[0+s/2-10,0+o/2],l=[0+s/2,0+o/2-10],h=[0+s/2,0-o/2+10],c=[0+s/2-10,0-o/2],u=[0-s/2+10,0-o/2],d=[0-s/2,0-o/2+10],p=[0-s/2,0+o/2-10],f=[0-s/2+10,0+o/2],m=new e.Shape;m.moveTo(a[0],a[1]),m.bezierCurveTo(a[0],a[1],0+s/2,0+o/2,l[0],l[1]),m.moveTo(h[0],h[1]),m.bezierCurveTo(h[0],h[1],0+s/2,0-o/2,c[0],c[1]),m.moveTo(u[0],u[1]),m.bezierCurveTo(u[0],u[1],0-s/2,0-o/2,d[0],d[1]),m.moveTo(p[0],p[1]),m.bezierCurveTo(p[0],p[1],0-s/2,0+o/2,f[0],f[1]),m.moveTo(a[0],a[1]);const g=new e.ShapeGeometry(m),v=new e.MeshBasicMaterial({color:16711680,transparent:!0,opacity:.5}),y=new e.Mesh(g,v);m.autoClose=!0;const x=m.getPoints(),b=(new e.BufferGeometry).setFromPoints(x),w=new e.Line(b,new e.LineBasicMaterial({color:16711680,linewidth:2}));w.position.set(0,0,0),this.boundingBox.name="poi_bounding_rect",this.boundingBox.add(y),this.boundingBox.add(w),this.boundingBox.renderOrder=0,this.group.add(this.boundingBox)}setBoundingBox(){this.withBoundingBox=!0}getBoundingRect(){const{x:t,y:e}=this.overlapArea,{xMin:n,yMin:i,xMax:r,yMax:s}=this.boundingRect;return{xMin:n+t,yMin:i+e,xMax:r-t,yMax:s-e}}getOuterRect(){const{x:t,y:e}=this.overlapArea,{xMin:n,yMin:i,xMax:r,yMax:s}=this.outerRect;return{xMin:n+t,yMin:i+e,xMax:r-t,yMax:s-e}}setAnimationEnabled(t){this.animationEnabled=t}calcPoiRotation(t){return this.autoRotation?t+this.rotation:this.rotation}getVisibility(){return this.visible}calcPosAndSize(t,e,n){if(!this.parent)return{isInFrustum:this.isInFrustum};let i=this.visible&&t.containsPoint(this.position);if(i){const t=this.position.clone().project(this.parent.camera);this.screenPosition={x:(t.x+1)*e,y:(1-t.y)*n},this.calcBoundingSize(),(this.outerRect.xMin<0||this.outerRect.xMax>2*e||this.outerRect.yMin<0||this.outerRect.yMax>2*n)&&(i=!1)}return this.isInFrustum=i,{isInFrustum:this.isInFrustum}}draw(){this.drawText(),this.drawIcon(),this.drawRect(),this.drawBoundingBox()}updatePosition(t,n,i){if(!this.group)return;if(!this.isInFrustum)return this.hide=!0,this.subHide=!1,void(this.group.visible=!1);if(this.group.visible=this.visible,!this.visible)return;const r=this.textPosInfo.offsetX,s=this.textPosInfo.offsetY,o=this.iconPosInfo.offsetX,a=this.iconPosInfo.offsetY,l=1e-4*i;if(this.group.position.set(this.screenPosition.x-t,n-this.screenPosition.y,l),this.text&&this.text.position.set(r,s,0),this.rect&&this.rect.position.set(r,s,0),this.icon&&this.icon.position.set(o,a,0),this.boundingBox){const t=(this.outerRect.xMax+this.outerRect.xMin)/2,e=(this.outerRect.yMax+this.outerRect.yMin)/2;this.boundingBox.position.set(t-this.screenPosition.x,this.screenPosition.y-e,0)}const h=this.visibilityAnimation.anim,c=!!h||!h&&(!this.hide||this.subHide);if(this.group.visible=c,c&&(!h||!this.animationEnabled)){let t=[],n=[];switch(this.visiblePartWhenCollision){case"all":t=[this.group],n=[];break;case"none":t=[],n=[this.group];break;case"label":t=[],this.text&&t.push(this.text),this.rect&&t.push(this.rect),this.icon&&n.push(this.icon);break;case"icon":this.icon&&t.push(this.icon),this.text&&n.push(this.text),this.rect&&n.push(this.rect);break;default:t=[],n=[this.group]}this.subHide?(t.forEach(t=>{t.visible=!0,t instanceof e.Group&&t.children.forEach(t=>{t.visible=!0})}),n.forEach(t=>{t.visible=!1,t instanceof e.Group&&t.children.forEach(t=>{t.visible=!1})})):this.hide||(t.forEach(t=>{t.visible=!0,t instanceof e.Group&&t.children.forEach(t=>{t.visible=!0})}),n.forEach(t=>{t.visible=!0,t instanceof e.Group&&t.children.forEach(t=>{t.visible=!0})})),this.icon&&!this.iconVisibility&&(this.icon.visible=!1),this.text&&!this.textVisibility&&(this.text.visible=!1)}c&&(this.subHide?this.parent&&("icon"===this.visiblePartWhenCollision?this.parent.setRectMap(this.iconRect,this):this.parent.setRectMap(this.textRect,this)):this.parent&&(this.parent.setRectMap(this.textRect,this),this.parent.setRectMap(this.iconRect,this)))}update(){const t=this.renderThisFrame||this.isInFrustum&&!!this.iconOptions.src&&!this.icon;return this.renderThisFrame=!1,t}setPoiId(t){this.poiId=t}}qp.ImageMaterialMap=new Map,qp.ImageMaterialMap=new Map;class Zp{constructor(t){const{Konva:e}=x.getInstance();this.konvaContainer=document.createElement("div"),this.konvaContainer.style.cssText="\n pointer-events: none;\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n ",t.appendChild(this.konvaContainer),this.stage=new e.Stage({container:this.konvaContainer});const{clientWidth:n,clientHeight:i}=t;this.resize(n,i)}static getInstance(t){return this.containerMap||(this.containerMap=new Map),this.containerMap.has(t)||this.containerMap.set(t,new Zp(t)),this.containerMap.get(t)}static get initialized(){return this.containerMap&&!!this.containerMap.size}static resize(){this.containerMap.forEach((t,e)=>{if(!t)return;const{clientHeight:n,clientWidth:i}=e;t.resize(i,n)})}static dispose(){this.containerMap&&(this.containerMap.forEach((t,e)=>{t.stage.destroy(),e.removeChild(t.konvaContainer)}),this.containerMap.clear())}static disposeStage(t){if(this.containerMap&&this.containerMap.has(t)){const e=this.containerMap.get(t);e.stage.destroy(),t.removeChild(e.konvaContainer),this.containerMap.delete(t)}}resize(t,e){this.stage.size({width:t,height:e})}addLayer(){const{Konva:t}=x.getInstance(),e=new t.Layer;return this.stage.add(e),e}openInteraction(){this.konvaContainer.style.pointerEvents="auto"}closeInteraction(){this.konvaContainer.style.pointerEvents="none"}}class Jp{constructor(t,e,n,i=[]){this.shape=t,this.rawShape=e,this.baseZoom=n,this.zIndices=i,this.points=[],this.lineJointsStyle="joints",this.vertexOptions={radius:0,fill:"#fff",shadowColor:"#000",shadowBlur:3,shadowOffset:{x:1,y:2},shadowOpacity:.3,shadowEnabled:!1}}}!function(t){t[t.IDLE=0]="IDLE",t[t.DOWN=1]="DOWN",t[t.MOVE=2]="MOVE"}(Gp||(Gp={}));!function(t){t[t.IDLE=0]="IDLE",t[t.DOWN=1]="DOWN",t[t.MOVE=2]="MOVE"}(Wp||(Wp={}));class $p extends C{constructor(e){if(super(),this.needRender=!1,S.GetEnv()===t.Env.Miniapp){if(!e)throw Error("poi-overlay need a offscreenCanvas");$p.canvas=e}else $p.canvas||($p.canvas=document.createElement("canvas"));const n=S.GetGlobalDPR();$p.canvas.width=500*n,$p.canvas.height=500*n,$p.ctx=$p.canvas.getContext("2d")}init(t){const{THREE:n}=x.getInstance();this.rectMap=new Map,this.parent=t,this.scene=t.stage.scene;const i=t.getViewWidth(),r=t.getViewHeight();this.renderCamera=new e.OrthographicCamera(-i/2,i/2,r/2,-r/2,.1,1e3),this.renderCamera.up.set(0,1,0),this.renderCamera.position.set(0,0,50),this.renderCamera.lookAt(0,0,0),this.camera=this.parent.camera,this.renderer=this.parent.renderer,this.pois=new Set,this.enabled=!0,this.orderPois=xe.debounce(this.orderPoisByLevel.bind(this),50),this.listeners={pointerDown:t=>{this.onPointerDown(t)},pointerUp:t=>{this.onPointerUp(t)},touchStart:t=>{this.onTouchStart(t)},touchEnd:t=>{this.onTouchEnd(t)}},this.mouseState=Wp.IDLE,this.mousePositionBuffer=new n.Vector2,this.parent.on(_.MOUSE_DOWN,this.listeners.pointerDown),this.parent.on(_.MOUSE_UP,this.listeners.pointerUp),this.parent.on(_.TOUCH_START,this.listeners.touchStart),this.parent.on(_.TOUCH_END,this.listeners.touchEnd)}update(){return!(!this.renderThisFrame&&!Array.from(this.pois).reduce((t,e)=>e.update()||t,!1))&&(this.renderThisFrame=!1,this.needRender=!0,!0)}forceRenderInThisFrame(){this.renderThisFrame=!0}render(){if(!this.enabled)return;const{THREE:t}=x.getInstance(),e=new t.Frustum;e.setFromProjectionMatrix((new t.Matrix4).multiplyMatrices(this.parent.camera.projectionMatrix,this.parent.camera.matrixWorldInverse));const n=this.parent.getViewWidth(),i=this.parent.getViewHeight(),r=new t.Euler;if(r.setFromQuaternion(this.parent.camera.quaternion,"ZYX"),this.checkUpdate(),this.needRender||this.renderThisFrame){this.rectMap.clear();const t=[];this.pois.forEach(r=>{r.draw();const{isInFrustum:s}=r.calcPosAndSize(e,n/2,i/2);s&&t.push(r)}),this.recalculateVisibilities(t),Array.from(this.pois).forEach(t=>{t.updatePosition(r,this.parent.camera.zoom)})}this.renderThisFrame=!1,this.needRender=!1}orderPoisByLevel(){const t=Array.from(this.pois);t.sort((t,e)=>t.getLevel()-e.getLevel()),this.pois=new Set(t),this.renderThisFrame=!0}recalculateVisibilities(t){const e=[];let n=!0;Array.from(t).sort((t,e)=>e.collision?-1:e.getLevel()-t.getLevel()).forEach(t=>{const{xMin:i,yMin:r,xMax:s,yMax:o}=t.getBoundingRect();if(!t.collision)return t.setHidden(!1),e.push([i,s,r,o]),void(n=!1);const{xMin:a,yMin:l,xMax:h,yMax:c}=t.getOuterRect();if(n)return e.push([i,s,r,o]),n=!1,void t.setHidden(!1);if(!e.some(([t,e,n,a])=>!(s<t||i>e)&&!(o<n||r>a)))e.push([i,s,r,o]),t.setHidden(!1);else if("outer"===t.collisionMode)t.setHidden(!0);else if("icon"===t.collisionMode||"label"===t.collisionMode){!e.some(([t,e,n,i])=>!(h<t||a>e)&&!(c<n||l>i))?(e.push([i,s,r,o]),t.setHidden(!0,!0)):t.setHidden(!0)}})}checkUpdate(){const{THREE:t}=x.getInstance();if(this.renderThisFrame)return;if(Array.from(this.pois).some(t=>t.update()))return void(this.renderThisFrame=!0);const{camera:e}=this.parent,{quaternion:n,position:i,zoom:r,up:s}=e,o=i.clone(),a=n.clone(),l=r;if(!this.prevPosition)return this.prevPosition=o.clone(),this.prevQuaternion=a.clone(),this.prevZoom=l,void(this.renderThisFrame=!0);const h=(new t.Quaternion).setFromUnitVectors(s,new t.Vector3(0,1,0)),c=new t.Vector3(0,0,-1).applyQuaternion(this.prevQuaternion);c.applyQuaternion(h);const u=new t.Spherical;u.setFromVector3(c);const d=(new t.Quaternion).setFromUnitVectors(s,new t.Vector3(0,1,0)),p=new t.Vector3(0,0,-1).applyQuaternion(a);p.applyQuaternion(d);const f=new t.Spherical;if(f.setFromVector3(p),Math.abs(u.phi*(180/Math.PI)-f.phi*(180/Math.PI))+Math.abs(u.theta*(180/Math.PI)-f.theta*(180/Math.PI))>1e-4)return this.prevPosition=o.clone(),this.prevQuaternion=a.clone(),this.prevZoom=l,void(this.renderThisFrame=!0);const m=this.parent.getViewWidth(),g=this.parent.getViewHeight(),v=o.clone().project(e),y=(v.x-1)/2*m,b=(1-v.y)/2*g;v.set(y,b,0);const w=this.prevPosition.clone().project(e),M=(w.x-1)/2*m,_=(1-w.y)/2*g;return w.set(M,_,0),v.distanceTo(w)>1e-4||this.prevZoom!==l&&Math.abs((l-this.prevZoom)/l)>1e-4||Math.abs((this.prevZoom-l)/this.prevZoom)>1e-4?(this.prevPosition=o.clone(),this.prevQuaternion=a.clone(),this.prevZoom=l,void(this.renderThisFrame=!0)):void(this.renderThisFrame=!1)}dispose(){this.parent.off(_.MOUSE_DOWN,this.listeners.pointerDown),this.parent.off(_.MOUSE_UP,this.listeners.pointerUp),this.parent.off(_.TOUCH_START,this.listeners.touchStart),this.parent.off(_.TOUCH_END,this.listeners.touchEnd),this.clearPoi(),$p.canvas&&($p.canvas.remove(),$p.canvas=null),$p.ctx&&($p.ctx=null)}onPointerDown(t){const{clientX:n,clientY:i}=t,[r,s]=this.parent.getViewOffset(),o=n-r,a=i-s;let l=null;Array.from(this.rectMap).some(([t,n])=>{const{xMin:i,yMin:r,xMax:s,yMax:h}=t;return!!new e.Box2(new e.Vector2(i,r),new e.Vector2(s,h)).containsPoint(new e.Vector2(o,a))&&(l=n,!0)}),l&&this.onNodePointerDown(l,o,a,t.button)}onPointerUp(t){const{THREE:e}=x.getInstance(),{clientX:n,clientY:i}=t,[r,s]=this.parent.getViewOffset(),o=n-r,a=i-s,l=new e.Vector2(o,a).distanceToSquared(this.mousePositionBuffer);this.emit(M.POI_UP,this.eventTarget,t.button),this.mouseState===Wp.DOWN&&l<100&&this.emit(M.POI_CLICKED,this.eventTarget,t.button),this.mouseState=Wp.IDLE}onTouchStart(t){const{clientX:n,clientY:i}=t.touches[0],[r,s]=this.parent.getViewOffset(),o=n-r,a=i-s;let l=null;Array.from(this.rectMap).some(([t,n])=>{const{xMin:i,yMin:r,xMax:s,yMax:h}=t;return!!new e.Box2(new e.Vector2(i,r),new e.Vector2(s,h)).containsPoint(new e.Vector2(o,a))&&(l=n,!0)}),l&&this.onNodePointerDown(l,o,a,0)}onTouchEnd(t){const{THREE:e}=x.getInstance(),{clientX:n,clientY:i}=t.changedTouches[0],[r,s]=this.parent.getViewOffset(),o=n-r,a=i-s,l=new e.Vector2(o,a).distanceToSquared(this.mousePositionBuffer);this.emit(M.POI_UP,this.eventTarget,0),this.mouseState===Wp.DOWN&&l<100&&this.emit(M.POI_CLICKED,this.eventTarget,0),this.mouseState=Wp.IDLE}onNodePointerDown(t,e,n,i=0){this.mouseState===Wp.IDLE&&(this.mouseState=Wp.DOWN,this.mousePositionBuffer.set(e,n),this.eventTarget=t,this.emit(M.POI_DOWN,t,i))}createPoi(t){const e=new Qp;if(e.setParent(this),this.renderThisFrame=!0,e.setPosition(t),!this.pois)throw Error("poiOverlay need bind a view, use view.addOverlay()");return this.pois.add(e),this.scene.add(e.group),e}setRectMap(t,e){this.rectMap.set(t,e)}removePoi(t){this.pois.delete(t),this.scene.remove(t.group),t.dispose(),this.renderThisFrame=!0}clearPoi(){Array.from(this.pois).forEach(t=>{this.scene.remove(t.group)}),this.pois.clear(),this.renderThisFrame=!0}setVisibility(t){this.visible=t,this.enabled=t}setEnabled(t){this.enabled=t}resize(t,e){this.updateCameraAspect(t,e),this.renderThisFrame=!0}updateCameraAspect(t,e){const n=t,i=e;this.renderCamera.left=-n/2,this.renderCamera.right=n/2,this.renderCamera.top=i/2,this.renderCamera.bottom=-i/2,this.renderCamera.updateProjectionMatrix()}}class Qp{constructor(t){this._renderThisFrame=!1;const{THREE:n}=x.getInstance();this.dpr=S.GetGlobalDPR(),this.isFlipY=!1,this.position=t||new n.Vector3,this.group=new e.Group,this.textVisibility=!0,this.iconVisibility=!0,this.iconInCircle=!1,this.iconCircleOptions={width:0,color:"#ffffff"},this.textPosInfo={anchor:"center",offsetX:0,offsetY:0,anchorOffsetX:0,anchorOffsetY:0},this.iconPosInfo={anchor:"center",offsetX:0,offsetY:0,anchorOffsetX:0,anchorOffsetY:0},this.level=1,this.isInFrustum=!1,this.animationEnabled=!1,this.text=null,this.icon=null,this.rect=null,this.boundingBox=null,this.overlapArea={x:0,y:0},this.visible=!0,this.hide=!1,this.subHide=!1,this.rotation=0,this.autoRotation=!1,this.collision=!0,this.collisionMode="outer",this.iconRect={xMin:0,yMin:0,xMax:0,yMax:0},this.textRect={xMin:0,yMin:0,xMax:0,yMax:0},this.boundingRect={xMin:0,yMin:0,xMax:0,yMax:0},this.outerRect={xMin:0,yMin:0,xMax:0,yMax:0},this.visibilityAnimation={anim:null,from:1,to:1,current:1},this.text=null,this.textWidth=0,this.textHeight=0,this.icon=null,this.iconOptions={size:[20,20],src:null},this.labelOptions={fontSize:12,padding:0,content:null},this.rectOptions={width:0,height:0,fill:16711680,opacity:.5,offsetX:0,offsetY:0},this.visiblePartWhenCollision="none",this.subAreaOpacity=1,this.abandonedAreaOpacity=1,this.screenPosition={x:0,y:0},this.labelOpacity=1,this.iconOpacity=1}set renderThisFrame(t){this._renderThisFrame=t}get renderThisFrame(){return this._renderThisFrame}dispose(){this.group&&xe.dispose(this.group,!0),this.parent=null,this.iconCircleMaterial=null,this.iconMaterial=null,this.textMaterial=null,this.icon=null,this.rect=null,this.boundingBox=null,this.group=null}setParent(t){this.parent=t}setPosition(t,e=1e-4){t.distanceTo(this.position)<e||(this.position.copy(t),this.group&&this.group.position.copy(t),this.renderThisFrame=!0)}setOpacity(t=this.labelOpacity,e=this.iconOpacity){this.labelOpacity=t,this.iconOpacity=e,this.textMaterial&&(this.textMaterial.opacity=t),this.iconMaterial&&(this.iconMaterial.opacity=e),this.renderThisFrame=!0}setRotation(t,e=1e-4){Math.abs(t-this.rotation)<e||(this.group.rotateZ(t-this.rotation),this.rotation=t,this.renderThisFrame=!0)}setCollision(t){this.collision=t,this.renderThisFrame=!0}setCollisionMode(t){this.collisionMode=t,this.renderThisFrame=!0}setLabelVisibility(t){this.textVisibility=t,this.renderThisFrame=!0}setIconVisiblity(t){this.iconVisibility=t,this.renderThisFrame=!0}setHideModeWhenCollision(t){"all"===t?this.setVisiblePartWhenCollision("none"):"none"===t?this.setVisiblePartWhenCollision("all"):this.setVisiblePartWhenCollision(t)}setVisiblePartWhenCollision(t){this.visiblePartWhenCollision=t}setCollisionOverlap(t,e){this.overlapArea={x:t,y:e},this.renderThisFrame=!0}setLevel(t,e=!1){this.level=t,this.renderThisFrame=!0,this.parent.orderPois(e)}getLevel(){return this.level}setVisibility(t){this.visible!==t&&(this.renderThisFrame=!0),this.visible=t}setHidden(t,e=!1){if(this.animationEnabled){const n=t?e?.5:0:1;if(this.visibilityAnimation.anim&&n===this.visibilityAnimation.to)return;if(!this.visibilityAnimation.anim&&t===this.hide&&e===this.subHide)return;this.visibilityAnimation.anim&&(this.visibilityAnimation.anim.stop(),this.visibilityAnimation.anim=null);const i={subAreaOpacity:this.subAreaOpacity,abandonedAreaOpacity:this.abandonedAreaOpacity},r={subAreaOpacity:0,abandonedAreaOpacity:0};t?e?(r.subAreaOpacity=1,r.abandonedAreaOpacity=0):(r.subAreaOpacity=0,r.abandonedAreaOpacity=0):(r.subAreaOpacity=1,r.abandonedAreaOpacity=1);let s=[];const o=[];switch(this.visiblePartWhenCollision){case"all":this.text&&s.push(this.textMaterial),this.icon&&(s.push(this.iconMaterial),this.iconCircleMaterial&&this.iconCircleMaterial.visible&&s.push(this.iconCircleMaterial));break;case"none":this.text&&o.push(this.textMaterial),this.icon&&(o.push(this.iconMaterial),this.iconCircleMaterial&&this.iconCircleMaterial.visible&&o.push(this.iconCircleMaterial));break;case"label":s=[this.textMaterial,this.rectMaterial],this.text&&s.push(this.textMaterial),this.icon&&(o.push(this.iconMaterial),this.iconCircleMaterial&&this.iconCircleMaterial.visible&&o.push(this.iconCircleMaterial));break;case"icon":this.text&&o.push(this.textMaterial),this.icon&&(s.push(this.iconMaterial),this.iconCircleMaterial&&this.iconCircleMaterial.visible&&s.push(this.iconCircleMaterial))}this.visibilityAnimation.from=this.visibilityAnimation.current,this.visibilityAnimation.to=t?e?.5:0:1;const a=300;this.visibilityAnimation.anim=new y.Tween(i).to(r,a).onUpdate(t=>{this.subAreaOpacity=t.subAreaOpacity,this.abandonedAreaOpacity=t.abandonedAreaOpacity,s.forEach(e=>{e.opacity=t.subAreaOpacity}),o.forEach(e=>{e.opacity=t.abandonedAreaOpacity})}).start().onComplete(()=>{this.visibilityAnimation.anim=null,this.visibilityAnimation.from=null,this.visibilityAnimation.current=null,this.visibilityAnimation.to=null,this.hide=t,this.subHide=e})}else this.hide===t&&this.subHide===e||(this.hide=t,this.subHide=e,this.renderThisFrame=!0)}setRect(t){this.withRect=t,this.renderThisFrame=!0}setRectDefSize(t,e){this.rectOptions.width=t,this.rectOptions.height=e,this.renderThisFrame=!0}setRectFill(t){this.rectOptions.fill=t,this.renderThisFrame=!0}setRectOffset(t=0,e=0){this.rectOptions.offsetX=t,this.rectOptions.offsetY=e,this.renderThisFrame=!0}setIconImage(t){this.iconOptions&&this.iconOptions.src===t||(this.iconOptions.src=t,this.clearIcon(),this.renderThisFrame=!0)}setIconSize(t,e){this.iconSize=[t,e],this.iconOptions.size=[t,e],this.renderThisFrame=!0}setIconShowInCircle(t,e){this.iconInCircle=!0,this.iconCircleOptions={width:t,color:e}}drawIcon(){const{src:t,size:n}=this.iconOptions;if(t&&(!this.icon||!this.group.getObjectByName("poi_icon")||!!this.iconInCircle!=!!this.iconCircleMaterial))if(Qp.ImageMaterialMap.has(t))if("dealing"===Qp.ImageMaterialMap.get(t))this.renderThisFrame=!0;else{this.icon&&this.group.remove(this.icon),this.iconMaterial=Qp.ImageMaterialMap.get(t).clone(),this.iconMaterial.opacity=this.iconOpacity;const{width:i,color:r}=this.iconCircleOptions,s=i&&this.iconInCircle;s&&(this.iconCircleMaterial=new e.MeshBasicMaterial({color:r,transparent:!0,opacity:this.iconOpacity}));const o=s?[this.iconCircleMaterial,this.iconMaterial]:[this.iconMaterial],a=s?new e.CircleGeometry(n[0]/2,30):new e.PlaneGeometry(n[0],n[1]),l=Xp(a,o);this.icon=l,this.icon&&(this.icon.children.length>1&&this.icon.children[1].scale.set(n[0]/(i+n[0]),n[0]/(i+n[0]),1),this.icon.renderOrder=3,this.icon.name="poi_icon",this.group.add(this.icon),this.renderThisFrame=!0)}else{Qp.ImageMaterialMap.set(t,"dealing");(new e.TextureLoader).load(t,n=>{n.needsUpdate=!0,n.magFilter=e.LinearFilter,n.flipY=this.isFlipY;const i=new e.MeshBasicMaterial({map:n,transparent:!0,opacity:this.iconOpacity});i.needsUpdate=!0,i.visible=!0,Qp.ImageMaterialMap.set(t,i)})}}clearIcon(){this.icon&&(this.group&&this.group.remove(this.icon),this.icon.children.forEach(t=>{t.geometry&&t.geometry.dispose()}),this.iconMaterial&&(this.iconMaterial.dispose(),this.iconMaterial=null),this.iconCircleMaterial&&(this.iconCircleMaterial.dispose(),this.iconCircleMaterial=null),this.icon=null)}setIconAnchor(t){this.iconPosInfo.anchor=t,this.renderThisFrame=!0}setIconFlipY(t){this.isFlipY=t}setIconOffset(t,e){this.iconPosInfo.anchorOffsetX=t,this.iconPosInfo.anchorOffsetY=e,this.renderThisFrame=!0}setFontSize(t){this.labelOptions.fontSize=t,this.renderThisFrame=!0}setFontPadding(t){this.labelOptions.padding=t,this.renderThisFrame=!0}setLabelText(t){this.labelOptions.content=t,this.renderThisFrame=!0}drawText(){if(!this.labelOptions.content)return;if(this.group.getObjectByName("poi_text"))return;const t=this.dpr,{fontSize:n,padding:i,content:r}=this.labelOptions;$p.ctx.font=n*t+"px sans-serif",$p.ctx.fillStyle="black";const s=$p.ctx.measureText(r),o=Math.ceil(s.width)+10+2*i,a=(n+5+2*i)*t;this.textWidth=o/t,this.textHeight=a/t,this.setRectDefSize(this.textWidth,this.textHeight),$p.ctx.clearRect(0,0,o,a),$p.ctx.fillText(r,i*t,(n+i)*t);const l=$p.ctx.getImageData(0,0,o,a);this.textMaterial=new e.MeshBasicMaterial({transparent:!0,map:new e.DataTexture(Uint8Array.from(l.data),o,a,e.RGBAFormat),side:e.DoubleSide,opacity:this.labelOpacity}),this.text=new e.Mesh(new e.PlaneGeometry(this.textWidth,this.textHeight),this.textMaterial),this.text.material.map.flipY=!0,this.text.material.map.flipX=!0,this.text.material.map.needsUpdate=!0,this.text.material.map.magFilter=e.LinearFilter,this.text.material.visible=!0,this.text.name="poi_text",this.text.renderOrder=4;const{offsetX:h,offsetY:c}=this.recalcOffset(this.textWidth,this.textHeight,this.textPosInfo.anchor,this.textPosInfo.anchorOffsetX,this.textPosInfo.anchorOffsetY);this.textPosInfo.offsetX=h,this.textPosInfo.offsetY=c,this.group.add(this.text)}recalcOffset(t,e,n,i,r){let s=0,o=0;switch(n){case"center":s=i,o=r;break;case"left":s=t/2+i,o=r;break;case"right":s=-t/2+i,o=r;break;case"top":s=i,o=-e/2+r;break;case"bottom":s=i,o=e/2+r;break;case"topleft":s=t/2+i,o=-e/2+r;break;case"topright":s=-t/2+i,o=-e/2+r;break;case"bottomleft":s=t/2+i,o=e/2+r;break;case"bottomright":s=-t/2+i,o=e/2+r}return{offsetX:s,offsetY:o}}setLabelAnchor(t){this.textPosInfo.anchor=t,this.renderThisFrame=!0}setLabelOffset(t,e){this.textPosInfo.anchorOffsetX=t,this.textPosInfo.anchorOffsetY=e,this.renderThisFrame=!0}getLabelAnchor(){return this.textPosInfo.anchor}getLabelOffset(){const{anchorOffsetX:t,anchorOffsetY:e}=this.textPosInfo;return{x:t,y:e}}calcBoundingSize(){const t=this.screenPosition,e=this.textPosInfo.offsetX,n=this.textPosInfo.offsetY,i=this.iconPosInfo.offsetX,r=this.iconPosInfo.offsetY,s={xMin:this.text?t.x-this.textWidth/2+e:t.x,xMax:this.text?t.x+this.textWidth/2+e:t.x,yMin:this.text?t.y-this.textHeight/2-n:t.y,yMax:this.text?t.y+this.textHeight/2-n:t.y},o={xMin:this.icon?t.x-this.iconOptions.size[0]/2+i:t.x,xMax:this.icon?t.x+this.iconOptions.size[0]/2+i:t.x,yMin:this.icon?t.y-this.iconOptions.size[1]/2-r:t.y,yMax:this.icon?t.y+this.iconOptions.size[1]/2-r:t.y};let a=Math.max(o.xMax,s.xMax),l=Math.min(o.xMin,s.xMin),h=Math.max(o.yMax,s.yMax),c=Math.min(o.yMin,s.yMin);this.iconRect={xMin:this.icon?t.x-this.iconOptions.size[0]/2+i:t.x,xMax:this.icon?t.x+this.iconOptions.size[0]/2+i:t.x,yMin:this.icon?t.y-this.iconOptions.size[1]/2-r:t.y,yMax:this.icon?t.y+this.iconOptions.size[1]/2-r:t.y},this.textRect={xMin:this.text?t.x-this.textWidth/2+e:t.x,xMax:this.text?t.x+this.textWidth/2+e:t.x,yMin:this.text?t.y-this.textHeight/2-n:t.y,yMax:this.text?t.y+this.textHeight/2-n:t.y},this.outerRect={xMax:a,xMin:l,yMax:h,yMin:c},"icon"===this.collisionMode?(a=o.xMax,l=o.xMin,h=o.yMax,c=o.yMin):"label"===this.collisionMode&&(a=s.xMax,l=s.xMin,h=s.yMax,c=s.yMin),this.boundingRect.xMax=a,this.boundingRect.yMax=h,this.boundingRect.xMin=l,this.boundingRect.yMin=c}drawRect(){if(!this.withRect||!this.labelOptions.content)return;if(this.rect&&this.group.getObjectByName("poi_rect"))return;this.rect=new e.Group;const t=this.rectOptions.width||this.textWidth,n=this.rectOptions.height||this.textHeight,i=[0+t/2-10,0+n/2],r=[0+t/2,0+n/2-10],s=[0+t/2,0-n/2+10],o=[0+t/2-10,0-n/2],a=[0-t/2+10,0-n/2],l=[0-t/2,0-n/2+10],h=[0-t/2,0+n/2-10],c=[0-t/2+10,0+n/2],u=new e.Shape;u.moveTo(i[0],i[1]),u.bezierCurveTo(i[0],i[1],0+t/2,0+n/2,r[0],r[1]),u.moveTo(s[0],s[1]),u.bezierCurveTo(s[0],s[1],0+t/2,0-n/2,o[0],o[1]),u.moveTo(a[0],a[1]),u.bezierCurveTo(a[0],a[1],0-t/2,0-n/2,l[0],l[1]),u.moveTo(h[0],h[1]),u.bezierCurveTo(h[0],h[1],0-t/2,0+n/2,c[0],c[1]),u.moveTo(i[0],i[1]);const d=new e.ShapeGeometry(u),p=new e.MeshBasicMaterial({color:255,transparent:!0,opacity:.5});this.rectMaterial=p;const f=new e.Mesh(d,p);u.autoClose=!0;const m=u.getPoints(),g=(new e.BufferGeometry).setFromPoints(m),v=new e.Line(g,new e.LineBasicMaterial({color:16711680}));v.position.set(0,0,0),this.rect.add(f),this.rect.add(v),this.rect.renderOrder=2,this.rect.name="poi_rect",this.group.add(this.rect)}drawBoundingBox(){if(!this.withBoundingBox)return;if(this.group.getObjectByName("poi_bounding_rect"))return;if(0===this.outerRect.xMin&&0===this.outerRect.xMax)return;const{xMax:t,yMax:n,xMin:i,yMin:r}=this.outerRect;this.boundingBox=new e.Group;const s=t-i,o=n-r,a=[0+s/2-10,0+o/2],l=[0+s/2,0+o/2-10],h=[0+s/2,0-o/2+10],c=[0+s/2-10,0-o/2],u=[0-s/2+10,0-o/2],d=[0-s/2,0-o/2+10],p=[0-s/2,0+o/2-10],f=[0-s/2+10,0+o/2],m=new e.Shape;m.moveTo(a[0],a[1]),m.bezierCurveTo(a[0],a[1],0+s/2,0+o/2,l[0],l[1]),m.moveTo(h[0],h[1]),m.bezierCurveTo(h[0],h[1],0+s/2,0-o/2,c[0],c[1]),m.moveTo(u[0],u[1]),m.bezierCurveTo(u[0],u[1],0-s/2,0-o/2,d[0],d[1]),m.moveTo(p[0],p[1]),m.bezierCurveTo(p[0],p[1],0-s/2,0+o/2,f[0],f[1]),m.moveTo(a[0],a[1]);const g=new e.ShapeGeometry(m),v=new e.MeshBasicMaterial({color:16711680,transparent:!0,opacity:.5}),y=new e.Mesh(g,v);m.autoClose=!0;const x=m.getPoints(),b=(new e.BufferGeometry).setFromPoints(x),w=new e.Line(b,new e.LineBasicMaterial({color:16711680,linewidth:2}));w.position.set(0,0,0),this.boundingBox.name="poi_bounding_rect",this.boundingBox.add(y),this.boundingBox.add(w),this.boundingBox.renderOrder=0,this.group.add(this.boundingBox)}setBoundingBox(){this.withBoundingBox=!0}getBoundingRect(){const{x:t,y:e}=this.overlapArea,{xMin:n,yMin:i,xMax:r,yMax:s}=this.boundingRect;return{xMin:n+t,yMin:i+e,xMax:r-t,yMax:s-e}}getOuterRect(){const{x:t,y:e}=this.overlapArea,{xMin:n,yMin:i,xMax:r,yMax:s}=this.outerRect;return{xMin:n+t,yMin:i+e,xMax:r-t,yMax:s-e}}setAnimationEnabled(t){this.animationEnabled=t}calcPoiRotation(t){return this.autoRotation?t+this.rotation:this.rotation}getVisibility(){return this.visible}calcPosAndSize(t,e,n){if(!this.parent)return{isInFrustum:this.isInFrustum};let i=this.visible&&t.containsPoint(this.position);if(i){const t=this.position.clone().project(this.parent.camera);this.screenPosition={x:(t.x+1)*e,y:(1-t.y)*n},this.calcBoundingSize(),(this.outerRect.xMin<0||this.outerRect.xMax>2*e||this.outerRect.yMin<0||this.outerRect.yMax>2*n)&&(i=!1)}return this.isInFrustum=i,{isInFrustum:this.isInFrustum}}draw(){this.drawText(),this.drawIcon(),this.drawRect(),this.drawBoundingBox()}updatePosition(t,n){if(!this.group)return;if(!this.isInFrustum)return this.hide=!0,this.subHide=!1,void(this.group.visible=!1);if(this.group.visible=this.visible,!this.visible)return;const i=this.textPosInfo.offsetX,r=this.textPosInfo.offsetY,s=this.iconPosInfo.offsetX,o=this.iconPosInfo.offsetY,a=(new e.Vector3).copy(this.position);if(a.z+=this.iconSize[1]/2,this.group.position.copy(a),this.group.rotation.copy(t),this.group.scale.copy(new e.Vector3(1/n,1/n,1)),n<1?a.z+=this.iconSize[1]*(1-n)/2:a.z-=this.iconSize[1]*(1-1/n)/2,this.group.position.copy(a),this.text&&this.text.position.set(i,r,0),this.rect&&this.rect.position.set(i,r,0),this.icon&&this.icon.position.set(s,o,0),this.boundingBox){const t=(this.outerRect.xMax+this.outerRect.xMin)/2,e=(this.outerRect.yMax+this.outerRect.yMin)/2;this.boundingBox.position.set(t-this.screenPosition.x,this.screenPosition.y-e,0)}const l=this.visibilityAnimation.anim,h=!!l||!l&&(!this.hide||this.subHide);if(this.group.visible=h,h&&(!l||!this.animationEnabled)){let t=[],n=[];switch(this.visiblePartWhenCollision){case"all":t=[this.group],n=[];break;case"none":t=[],n=[this.group];break;case"label":t=[],this.text&&t.push(this.text),this.rect&&t.push(this.rect),this.icon&&n.push(this.icon);break;case"icon":this.icon&&t.push(this.icon),this.text&&n.push(this.text),this.rect&&n.push(this.rect);break;default:t=[],n=[this.group]}this.subHide?(t.forEach(t=>{t.visible=!0,t instanceof e.Group&&t.children.forEach(t=>{t.visible=!0})}),n.forEach(t=>{t.visible=!1,t instanceof e.Group&&t.children.forEach(t=>{t.visible=!1})})):this.hide||(t.forEach(t=>{t.visible=!0,t instanceof e.Group&&t.children.forEach(t=>{t.visible=!0})}),n.forEach(t=>{t.visible=!0,t instanceof e.Group&&t.children.forEach(t=>{t.visible=!0})})),this.icon&&!this.iconVisibility&&(this.icon.visible=!1),this.text&&!this.textVisibility&&(this.text.visible=!1)}h&&(this.subHide?this.parent&&("icon"===this.visiblePartWhenCollision?this.parent.setRectMap(this.iconRect,this):this.parent.setRectMap(this.textRect,this)):this.parent&&(this.parent.setRectMap(this.textRect,this),this.parent.setRectMap(this.iconRect,this)))}update(){const t=this.renderThisFrame||this.isInFrustum&&!!this.iconOptions.src&&!this.icon;return this.renderThisFrame=!1,t}setPoiId(t){this.poiId=t}}Qp.ImageMaterialMap=new Map,Qp.ImageMaterialMap=new Map;class Kp extends w{constructor(){super(),L.GetSharedInstance().registerController(this)}unbind(){this.dispose()}dispose(){this.eventMap.clear(),L.GetSharedInstance().unregisterController(this)}}!function(t){t[t.IDLE=0]="IDLE",t[t.ROTATE=1]="ROTATE",t[t.ORBIT=2]="ORBIT",t[t.PAN=3]="PAN",t[t.DOLLY=4]="DOLLY",t[t.TOUCH_ROTATE=5]="TOUCH_ROTATE",t[t.TOUCH_ORBIT=6]="TOUCH_ORBIT",t[t.TOUCH_PAN=7]="TOUCH_PAN",t[t.TOUCH_DOLLY_ROTATE=8]="TOUCH_DOLLY_ROTATE",t[t.TOUCH_DOLLY_PAN=9]="TOUCH_DOLLY_PAN",t[t.TOUCH_MAP=10]="TOUCH_MAP"}(jp||(jp={}));class tf extends e.InstancedBufferGeometry{constructor(){super();const{THREE:t}=x.getInstance();this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new t.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new t.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2));const e=this;this.computeBoundingBox=function(){const n=new t.Box3;return function(){null===e.boundingBox&&(e.boundingBox=new t.Box3);const i=e.attributes.instanceStart,r=e.attributes.instanceEnd;void 0!==i&&void 0!==r&&(e.boundingBox.setFromBufferAttribute(i),n.setFromBufferAttribute(r),e.boundingBox.union(n))}}(),this.computeBoundingSphere=function(){const n=new t.Vector3;return function(){null===e.boundingSphere&&(e.boundingSphere=new t.Sphere),null===e.boundingBox&&e.computeBoundingBox();const i=e.attributes.instanceStart,r=e.attributes.instanceEnd;if(void 0!==i&&void 0!==r){const{center:t}=e.boundingSphere;e.boundingBox.getCenter(t);let s=0;for(let e=0,o=i.count;e<o;e++)n.fromBufferAttribute(i,e),s=Math.max(s,t.distanceToSquared(n)),n.fromBufferAttribute(r,e),s=Math.max(s,t.distanceToSquared(n));e.boundingSphere.radius=Math.sqrt(s),Number.isNaN(e.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",e)}}}()}applyMatrix4(t){const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),n.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const{THREE:n}=x.getInstance(),i=new n.InstancedInterleavedBuffer(e,6,1);return this.setAttribute("instanceStart",new n.InterleavedBufferAttribute(i,3,0)),this.setAttribute("instanceEnd",new n.InterleavedBufferAttribute(i,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const{THREE:n}=x.getInstance(),i=new n.InstancedInterleavedBuffer(e,6,1);return this.setAttribute("instanceColorStart",new n.InterleavedBufferAttribute(i,3,0)),this.setAttribute("instanceColorEnd",new n.InterleavedBufferAttribute(i,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){const{THREE:e}=x.getInstance();return this.fromWireframeGeometry(new e.WireframeGeometry(t.geometry)),this}fromLineSegments(t){const{geometry:e}=t;if(!e.isGeometry)return e.isBufferGeometry&&this.setPositions(e.attributes.position.array),this;console.error("THREE.LineSegmentsGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.")}toJSON(){}applyMatrix(t){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(t)}}function ef(){const{THREE:t}=x.getInstance();return{linewidth:{value:1},resolution:{value:new t.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},dashOffset:{value:0},gapSize:{value:1},opacity:{value:1}}}class nf extends e.ShaderMaterial{constructor(t){super((()=>{const{THREE:t}=x.getInstance(),e=function(){const{THREE:t}=x.getInstance();return{uniforms:t.UniformsUtils.merge([t.UniformsLib.common,t.UniformsLib.fog,ef()]),vertexShader:"\n #include <common>\n #include <color_pars_vertex>\n #include <fog_pars_vertex>\n #include <logdepthbuf_pars_vertex>\n #include <clipping_planes_pars_vertex>\n\n uniform float linewidth;\n uniform vec2 resolution;\n\n attribute vec3 instanceStart;\n attribute vec3 instanceEnd;\n\n attribute vec3 instanceColorStart;\n attribute vec3 instanceColorEnd;\n\n varying vec2 vUv;\n\n #ifdef USE_DASH\n\n uniform float dashScale;\n attribute float instanceDistanceStart;\n attribute float instanceDistanceEnd;\n varying float vLineDistance;\n\n #endif\n\n void trimSegment( const in vec4 start, inout vec4 end ) {\n\n // trim end segment so it terminates between the camera plane and the near plane\n\n // conservative estimate of the near plane\n float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n float nearEstimate = - 0.5 * b / a;\n\n float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n end.xyz = mix( start.xyz, end.xyz, alpha );\n\n }\n\n void main() {\n\n #ifdef USE_COLOR\n\n vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n #endif\n\n #ifdef USE_DASH\n\n vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n #endif\n\n float aspect = resolution.x / resolution.y;\n\n vUv = uv;\n\n // camera space\n vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n // special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n // but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n // perhaps there is a more elegant solution -- WestLangley\n\n bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n if ( perspective ) {\n\n if ( start.z < 0.0 && end.z >= 0.0 ) {\n\n trimSegment( start, end );\n\n } else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n trimSegment( end, start );\n\n }\n\n }\n\n // clip space\n vec4 clipStart = projectionMatrix * start;\n vec4 clipEnd = projectionMatrix * end;\n\n // ndc space\n vec2 ndcStart = clipStart.xy / clipStart.w;\n vec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n // direction\n vec2 dir = ndcEnd - ndcStart;\n\n // account for clip-space aspect ratio\n dir.x *= aspect;\n dir = normalize( dir );\n\n // perpendicular to dir\n vec2 offset = vec2( dir.y, - dir.x );\n\n // undo aspect ratio adjustment\n dir.x /= aspect;\n offset.x /= aspect;\n\n // sign flip\n if ( position.x < 0.0 ) offset *= - 1.0;\n\n // endcaps\n if ( position.y < 0.0 ) {\n\n offset += - dir;\n\n } else if ( position.y > 1.0 ) {\n\n offset += dir;\n\n }\n\n // adjust for linewidth\n offset *= linewidth;\n\n // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n offset /= resolution.y;\n\n // select end\n vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n // back to clip space\n offset *= clip.w;\n\n clip.xy += offset;\n\n gl_Position = clip;\n\n vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n\n }\n ",fragmentShader:"\n uniform vec3 diffuse;\n uniform float opacity;\n\n #ifdef USE_DASH\n\n uniform float dashSize;\n uniform float dashOffset;\n uniform float gapSize;\n\n #endif\n\n varying float vLineDistance;\n\n #include <common>\n #include <color_pars_fragment>\n #include <fog_pars_fragment>\n #include <logdepthbuf_pars_fragment>\n #include <clipping_planes_pars_fragment>\n\n varying vec2 vUv;\n\n void main() {\n\n #include <clipping_planes_fragment>\n\n #ifdef USE_DASH\n\n if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n #endif\n\n float alpha = opacity;\n\n #ifdef ALPHA_TO_COVERAGE\n\n // artifacts appear on some hardware if a derivative is taken within a conditional\n float a = vUv.x;\n float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n float len2 = a * a + b * b;\n float dlen = fwidth( len2 );\n\n if ( abs( vUv.y ) > 1.0 ) {\n\n alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n }\n\n #else\n\n if ( abs( vUv.y ) > 1.0 ) {\n\n float a = vUv.x;\n float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n float len2 = a * a + b * b;\n\n if ( len2 > 1.0 ) discard;\n\n }\n\n #endif\n\n vec4 diffuseColor = vec4( diffuse, alpha );\n\n #include <logdepthbuf_fragment>\n #include <color_fragment>\n\n gl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n\n }\n "}}();return{type:"LineMaterial",uniforms:t.UniformsUtils.clone(e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,clipping:!0}})()),this.isLineMaterial=!0,this.dashed=!1,Object.defineProperties(this,{color:{enumerable:!0,get(){return this.uniforms.diffuse.value},set(t){this.uniforms.diffuse.value=t}},linewidth:{enumerable:!0,get(){return this.uniforms.linewidth.value},set(t){this.uniforms.linewidth.value=t}},dashed:{enumerable:!0,get(){return Boolean("USE_DASH"in this.defines)},set(t){Boolean(t)!==Boolean("USE_DASH"in this.defines)&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get(){return this.uniforms.dashScale.value},set(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get(){return this.uniforms.dashSize.value},set(t){this.uniforms.dashSize.value=t}},dashOffset:{enumerable:!0,get(){return this.uniforms.dashOffset.value},set(t){this.uniforms.dashOffset.value=t}},gapSize:{enumerable:!0,get(){return this.uniforms.gapSize.value},set(t){this.uniforms.gapSize.value=t}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(t){this.uniforms.resolution.value.copy(t)}},alphaToCoverage:{enumerable:!0,get(){return Boolean("ALPHA_TO_COVERAGE"in this.defines)},set(t){Boolean(t)!==Boolean("ALPHA_TO_COVERAGE"in this.defines)&&(this.needsUpdate=!0),t?(this.defines.ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(t)}}class rf extends e.Mesh{constructor(t,e){super(t||new tf,e||new nf({color:16777215*Math.random()})),this.isLineSegments2=!0;const{THREE:n}=x.getInstance();this.type="LineSegments2";const i=this;this.computeLineDistances=function(){const t=new n.Vector3,e=new n.Vector3;return function(){const{geometry:r}=i,{instanceStart:s}=r.attributes,{instanceEnd:o}=r.attributes,a=new Float32Array(2*s.count);for(let n=0,i=0,r=s.count;n<r;n+=1,i+=2)t.fromBufferAttribute(s,n),e.fromBufferAttribute(o,n),a[i]=0===i?0:a[i-1],a[i+1]=a[i]+t.distanceTo(e);const l=new n.InstancedInterleavedBuffer(a,2,1);return r.setAttribute("instanceDistanceStart",new n.InterleavedBufferAttribute(l,1,0)),r.setAttribute("instanceDistanceEnd",new n.InterleavedBufferAttribute(l,1,1)),i}}(),this.raycast=function(){const t=new n.Vector4,e=new n.Vector4,r=new n.Vector4,s=new n.Vector3,o=new n.Matrix4,a=new n.Line3,l=new n.Vector3;return function(h,c){null===h.camera&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.');const u=void 0!==h.params.Line2&&h.params.Line2.threshold||0,{ray:d}=h,{camera:p}=h,{projectionMatrix:f}=p,{geometry:m}=i,{material:g}=i,{resolution:v}=g,y=g.linewidth+u,{instanceStart:x}=m.attributes,{instanceEnd:b}=m.attributes,w=-p.near;d.at(1,r),r.w=1,r.applyMatrix4(p.matrixWorldInverse),r.applyMatrix4(f),r.multiplyScalar(1/r.w),r.x*=v.x/2,r.y*=v.y/2,r.z=0,s.copy(new n.Vector3(r.x,r.y,r.z));const{matrixWorld:M}=i;o.multiplyMatrices(p.matrixWorldInverse,M);for(let r=0,h=x.count;r<h;r++){t.fromBufferAttribute(x,r),e.fromBufferAttribute(b,r),t.w=1,e.w=1,t.applyMatrix4(o),e.applyMatrix4(o);if(t.z>w&&e.z>w)continue;if(t.z>w){const n=t.z-e.z,i=(t.z-w)/n;t.lerp(e,i)}else if(e.z>w){const n=e.z-t.z,i=(e.z-w)/n;e.lerp(t,i)}t.applyMatrix4(f),e.applyMatrix4(f),t.multiplyScalar(1/t.w),e.multiplyScalar(1/e.w),t.x*=v.x/2,t.y*=v.y/2,e.x*=v.x/2,e.y*=v.y/2,a.start.set(t.x,t.y,a.start.z),a.start.z=0,a.end.set(e.x,e.y,a.end.z),a.end.z=0;const h=a.closestPointToPointParameter(s,!0);a.at(h,l);const u=n.MathUtils.lerp(t.z,e.z,h),p=u>=-1&&u<=1,m=s.distanceTo(l)<.5*y;if(p&&m){a.start.fromBufferAttribute(x,r),a.end.fromBufferAttribute(b,r),a.start.applyMatrix4(M),a.end.applyMatrix4(M);const t=new n.Vector3,e=new n.Vector3;d.distanceSqToSegment(a.start,a.end,e,t),c.push({point:e,pointOnLine:t,distance:d.origin.distanceTo(e),object:i,face:null,faceIndex:r,uv:null,uv2:null})}}}}()}}return t.AlignmentUtils=class{static getTransformMatrices(t,e,n,i){if(!t.camera||!t.renderer)throw new Error("Cannot find Camera or Renderer object in view");const r=t.camera,s=t.renderer,{THREE:o}=x.getInstance(),a=new o.Raycaster;a.setFromCamera({x:-1,y:-1},r);const l=a.ray.origin.clone().x;a.setFromCamera({x:1,y:1},r);const h=a.ray.origin.clone().x,c=Math.abs(h-l)/s.domElement.clientWidth*e,u=new o.Camera,d=(new o.Euler).setFromQuaternion(r.quaternion.clone()).z,p=c*(n[0]*Math.cos(d)+n[1]*Math.sin(d)),f=c*(-n[0]*Math.sin(d)+n[1]*Math.cos(d));u.copy(r),u.position.add(new o.Vector3(p,-f,0)),u.updateMatrixWorld();const m=new o.Matrix4,g=new Array(16).fill(0);g[0]=1/e,g[5]=1/e,g[10]=1,g[15]=1,m.fromArray(g);const v=new o.Matrix4,y=new Array(16).fill(0);y[0]=i[0]/2,y[5]=-i[1]/2,y[10]=1,y[12]=i[0]/2,y[13]=i[1]/2,y[15]=1,v.fromArray(y);const b=u.projectionMatrix.clone().multiply(m).multiply(u.matrixWorldInverse),w=b.clone().invert(),M=v.clone().multiply(b),_=M.clone().invert(),E=u.matrixWorld.elements.slice();return{upTransOrigin:w.elements.slice(),downTransOrigin:b.elements.slice(),upTrans:_.elements.slice(),downTrans:M.elements.slice(),matrixWorld:E}}},t.BVHNode=Tn,t.BVHTree=An,t.BasicCalcTool=os,t.BasicController=class extends Kp{constructor(t){super();const{THREE:e}=x.getInstance();this.eventListeners={onMouseDown:t=>{this.onMouseDown(t)},onMouseMove:t=>{this.onMouseMove(t)},onMouseUp:t=>{this.onMouseUp(t)},onMouseWheel:t=>{this.onMouseWheel(t)},onTouchStart:t=>{this.onTouchStart(t)},onTouchMove:t=>{this.onTouchMove(t)},onTouchEnd:t=>{this.onTouchEnd(t)},onContextMenu:t=>{this.onContextMenu(t)}},this.state=jp.IDLE,this.enabled=!0,this.target=new e.Vector3,this.lastTick=Date.now(),this.enableDamping=!1,this.dampingFactor=0,this.mouseButtons={LEFT:e.MOUSE.ROTATE,MIDDLE:e.MOUSE.DOLLY,RIGHT:e.MOUSE.PAN},this.touches={ONE:e.TOUCH.ROTATE,TWO:e.TOUCH.DOLLY_PAN},this.boundaryEnabled=!1,this.boundary=new e.Box3(new e.Vector3(-1/0,-1/0,-1/0),new e.Vector3(1/0,1/0,1/0)),this.touchCenter=new e.Vector2,this.inertiaFactor=1,this.enableRotate=!0,this.rotateMode="self",this.rotateSpeed=1,this.rotateStart=new e.Vector2,this.rotateEnd=new e.Vector2,this.rotateDelta=new e.Vector2,this.rotateLineStart=new e.Vector2,this.rotateLineEnd=new e.Vector2,this.rotateInertiaDirection=new e.Vector2,this.rotateInertiaEnabled=!0,this.rotateInertiaBase=0,this.rotateInertia=0,this.rotateInertiaType="normal",this.spherical=new e.Spherical,this.sphericalDelta=new e.Spherical,this.maxSpherical=new e.Spherical(1,1/0,1/0),this.minSpherical=new e.Spherical(1,-1/0,-1/0),this.lastQuaternion=new e.Quaternion,this.enableZoom=!0,this.dollyStart=new e.Vector2,this.dollyEnd=new e.Vector2,this.zoomMode="zoom",this.zoomDelta=0,this.zoomRange={min:1,max:10},this.fovRange={min:60,max:90},this.zoomInertiaEnabled=!0,this.zoomInertiaBase=0,this.zoomInertia=0,this.zoomScale=1,this.enablePan=!0,this.panStart=new e.Vector2,this.panDelta=new e.Vector2,this.panEnd=new e.Vector2,this.panOffset=new e.Vector3,this.panSpeed=1,this.screenSpacePanning=!0,this.lastPosition=new e.Vector3,this.panInertiaDirection=new e.Vector2,this.panInertiaEnabled=!0,this.panInertiaBase=0,this.panInertia=0,this.mouseXY=new e.Vector2,this.bindView(t)}registerEvents(){this.bindingView&&(this.bindingView.on(_.MOUSE_DOWN,this.eventListeners.onMouseDown),this.bindingView.on(_.MOUSE_MOVE,this.eventListeners.onMouseMove),this.bindingView.on(_.MOUSE_UP,this.eventListeners.onMouseUp),this.bindingView.on(_.MOUSE_WHEEL,this.eventListeners.onMouseWheel),this.bindingView.on(_.TOUCH_START,this.eventListeners.onTouchStart),this.bindingView.on(_.TOUCH_MOVE,this.eventListeners.onTouchMove),this.bindingView.on(_.TOUCH_END,this.eventListeners.onTouchEnd),this.bindingView.on(_.CONTEXT_MENU,this.eventListeners.onContextMenu))}unregisterEvents(){this.bindingView&&(this.bindingView.off(_.MOUSE_DOWN,this.eventListeners.onMouseDown),this.bindingView.off(_.MOUSE_MOVE,this.eventListeners.onMouseMove),this.bindingView.off(_.MOUSE_UP,this.eventListeners.onMouseUp),this.bindingView.off(_.MOUSE_WHEEL,this.eventListeners.onMouseWheel),this.bindingView.off(_.TOUCH_START,this.eventListeners.onTouchStart),this.bindingView.off(_.TOUCH_MOVE,this.eventListeners.onTouchMove),this.bindingView.off(_.TOUCH_END,this.eventListeners.onTouchEnd),this.bindingView.off(_.CONTEXT_MENU,this.eventListeners.onContextMenu))}onMouseDown(t){let n;switch(t.preventDefault(),t.button){case 0:n=this.mouseButtons.LEFT;break;case 1:n=this.mouseButtons.MIDDLE;break;case 2:n=this.mouseButtons.RIGHT}switch(n){case e.MOUSE.ROTATE:this.enableRotate&&(this.state=jp.ROTATE);break;case e.MOUSE.PAN:this.enablePan&&(this.state=jp.PAN);break;case e.MOUSE.DOLLY:this.enableZoom&&(this.state=jp.DOLLY);break;default:this.state=jp.IDLE}switch(this.state){case jp.ROTATE:this.handleMouseDownRotate(t);break;case jp.PAN:this.handleMouseDownPan(t);break;case jp.DOLLY:this.handleMouseDownDolly(t)}this.state!==jp.IDLE&&(this.bindingView&&(this.bindingView.on(_.MOUSE_MOVE,this.eventListeners.onMouseMove),this.bindingView.on(_.MOUSE_UP,this.eventListeners.onMouseUp)),this.panInertiaBase=0,this.rotateInertiaBase=0,this.zoomInertiaBase=0)}onMouseMove(t){switch(t.preventDefault(),this.state){case jp.ROTATE:this.handleMouseMoveSelfRotate(t);break;case jp.PAN:this.handleMouseMovePan(t);break;case jp.DOLLY:this.handleMouseMoveDolly(t)}}onMouseUp(t){switch(t.preventDefault(),this.bindingView&&(this.bindingView.off(_.MOUSE_MOVE,this.eventListeners.onMouseMove),this.bindingView.off(_.MOUSE_UP,this.eventListeners.onMouseUp)),this.state){case jp.ROTATE:this.handleUpRotate();break;case jp.PAN:this.handleUpPan()}this.state=jp.IDLE}onMouseWheel(t){!this.enableZoom||this.state!==jp.IDLE&&this.state!==jp.ROTATE||(t.preventDefault(),t.stopPropagation(),this.handleMouseWheel(t))}onContextMenu(t){t.preventDefault()}onTouchStart(n){switch(S.GetEnv()!==t.Env.Miniapp&&n.preventDefault(),this.timeStart=n.timeStamp,n.touches.length){case 1:switch(this.touches.ONE){case e.TOUCH.PAN:this.enablePan&&(this.state=jp.TOUCH_PAN);break;case e.TOUCH.ROTATE:this.enableRotate&&(this.state=jp.TOUCH_ROTATE);break;default:this.state=jp.IDLE}break;case 2:switch(this.touchCenter.set((n.touches[0].clientX+n.touches[1].clientX)/2,(n.touches[0].clientY+n.touches[1].clientY)/2),this.touches.TWO){case e.TOUCH.DOLLY_PAN:this.state=jp.TOUCH_DOLLY_PAN;break;case e.TOUCH.DOLLY_ROTATE:this.state=jp.TOUCH_DOLLY_ROTATE;break;case"map":this.state=jp.TOUCH_MAP;break;default:this.state=jp.IDLE}break;default:this.state=jp.IDLE}switch(this.state){case jp.TOUCH_PAN:this.handleTouchStartPan(n);break;case jp.TOUCH_ROTATE:this.handleTouchStartRotate(n);break;case jp.TOUCH_DOLLY_ROTATE:this.handleTouchStartDollyRotate(n);break;case jp.TOUCH_DOLLY_PAN:this.handleTouchStartDollyPan(n);break;case jp.TOUCH_MAP:this.handleTouchStartMap(n)}this.state!==jp.IDLE&&(this.bindingView&&(this.bindingView.on(_.MOUSE_MOVE,this.eventListeners.onMouseMove),this.bindingView.on(_.MOUSE_UP,this.eventListeners.onMouseUp)),this.panInertiaBase=0,this.rotateInertiaBase=0,this.zoomInertiaBase=0)}onTouchMove(e){switch(S.GetEnv()!==t.Env.Miniapp&&e.preventDefault(),2===e.touches.length&&this.touchCenter.set((e.touches[0].clientX+e.touches[1].clientX)/2,(e.touches[0].clientY+e.touches[1].clientY)/2),this.state){case jp.TOUCH_PAN:this.handleTouchMovePan(e);break;case jp.TOUCH_ROTATE:this.handleTouchMoveSelfRotate(e);break;case jp.TOUCH_DOLLY_ROTATE:this.handleTouchMoveDollyRotate(e);break;case jp.TOUCH_DOLLY_PAN:this.handleTouchMoveDollyPan(e);break;case jp.TOUCH_MAP:this.handleTouchMoveAll(e)}this.timeEnd=this.timeStart,this.timeStart=e.timeStamp}onTouchEnd(e){switch(S.GetEnv()!==t.Env.Miniapp&&e.preventDefault(),this.state){case jp.TOUCH_ROTATE:case jp.TOUCH_DOLLY_ROTATE:this.handleUpRotate();break;case jp.TOUCH_PAN:case jp.TOUCH_DOLLY_PAN:this.handleUpPan();break;case jp.TOUCH_MAP:this.handleUpAll()}this.state=jp.IDLE}handleMouseDownRotate(t){this.handleDownRotate(t.offsetX,t.offsetY)}handleMouseMoveSelfRotate(t){this.handleMoveRotate(t.offsetX,t.offsetY)}handleTouchStartRotate(t){if(1===t.touches.length)this.handleDownRotate(t.touches[0].clientX,t.touches[0].clientY);else if(this.state===jp.TOUCH_MAP){const e=(t.touches[1].clientY-t.touches[0].clientY)/(t.touches[1].clientX-t.touches[0].clientX),n=t.touches[0].clientY-e*t.touches[0].clientX;this.rotateLineStart.set(e,n)}else{const e=.5*(t.touches[0].clientX+t.touches[1].clientX),n=.5*(t.touches[0].clientY+t.touches[1].clientY);this.handleDownRotate(e,n)}}handleTouchMoveSelfRotate(t){if(this.bindingView)if(1===t.touches.length)this.handleMoveRotate(t.touches[0].clientX,t.touches[0].clientY);else if(this.state===jp.TOUCH_MAP){const e=(t.touches[1].clientY-t.touches[0].clientY)/(t.touches[1].clientX-t.touches[0].clientX),n=t.touches[0].clientY-e*t.touches[0].clientX;if(this.rotateLineEnd.set(e,n),Number.isFinite(this.rotateLineEnd.x)&&Number.isFinite(this.rotateLineStart.x)){const t=(this.rotateLineStart.y-this.rotateLineEnd.y)/(this.rotateLineEnd.x-this.rotateLineStart.x),i=e*t+n;if(Number.isFinite(t)&&Number.isFinite(i)){let e=Math.atan(this.rotateLineEnd.x)-Math.atan(this.rotateLineStart.x);if(Math.PI-Math.abs(e)<.5&&(e=-Math.sign(e)*(Math.PI-Math.abs(e))),Math.abs(e)>.01){const n=this.rotateLineStart.clone().set(this.bindingView.getViewWidth()/2,this.bindingView.getViewHeight()/2),r=this.rotateLineStart.clone().set(t,i),s=n.clone().rotateAround(r,e).sub(n);this.handlePanDelta(s.x,s.y),this.rotateDelta.set(e,0),this.handleRotateSphericalDelta(this.rotateDelta.x,this.rotateDelta.y)}}}this.rotateLineStart.copy(this.rotateLineEnd)}else{const e=.5*(t.touches[0].clientX+t.touches[1].clientX),n=.5*(t.touches[0].clientY+t.touches[1].clientY);this.handleMoveRotate(e,n)}}handleDownRotate(t,e){this.rotateStart.set(t,e)}handleMoveRotate(t,e){this.rotateEnd.set(t,e),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed),this.handleRotateDelta(this.rotateDelta.x,this.rotateDelta.y),this.rotateStart.copy(this.rotateEnd)}handleRotateDelta(t,e){if(!this.bindingView)return;const n=this.bindingView.getViewHeight(),i="self"===this.rotateMode?-1:1;let r=1;if(this.camera.isPerspectiveCamera){const t=this.camera;r*=t.fov/t.zoom/360}this.handleRotateSphericalDelta(2*-i*Math.PI*t/n*r,-2*Math.PI*e/n*r)}handleRotateSphericalDelta(t,e){this.sphericalDelta.theta+=t,this.sphericalDelta.phi+=e}handleUpRotate(){if(!this.rotateInertiaEnabled||!this.bindingView)return;const t=this.timeStart-this.timeEnd;if(this.state===jp.TOUCH_MAP){this.rotateInertiaType="map";const e=this.rotateDelta.x/t;Number.isFinite(e)&&e>.001&&(this.rotateInertiaBase=this.rotateDelta.x/10,this.rotateInertiaDuration=0,this.rotateInertia=this.rotateInertiaBase)}else{this.rotateInertiaType="normal";const e=this.rotateDelta.length()*this.rotateSpeed/t,n=1e3*e/this.bindingView.getViewWidth()*.6;if(0===t||!Number.isFinite(e))return;Number.isFinite(e)&&e>.3&&(this.rotateInertiaBase=e*n*this.inertiaFactor,this.rotateInertiaDuration=0,this.rotateInertiaDirection=this.rotateDelta.clone().normalize(),this.rotateInertia=this.rotateInertiaBase)}}handleMouseDownPan(t){this.handleDownPan(t.offsetX,t.offsetY)}handleMouseMovePan(t){this.handleMovePan(t.offsetX,t.offsetY)}handleTouchStartPan(t){if(1===t.touches.length)this.handleDownPan(t.touches[0].clientX,t.touches[0].clientY);else{const e=.5*(t.touches[0].clientX+t.touches[1].clientX),n=.5*(t.touches[0].clientY+t.touches[1].clientY);this.handleDownPan(e,n)}}handleTouchMovePan(t){if(1===t.touches.length)this.handleMovePan(t.touches[0].clientX,t.touches[0].clientY);else{const e=.5*(t.touches[0].clientX+t.touches[1].clientX),n=.5*(t.touches[0].clientY+t.touches[1].clientY);this.handleMovePan(e,n)}}handleDownPan(t,e){this.panStart.set(t,e)}handleMovePan(t,e){this.panEnd.set(t,e),this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.handlePanDelta(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handlePanDelta(t,e){if(!this.bindingView)return;const{THREE:n}=x.getInstance(),i=new n.Vector3,r=this.bindingView.getViewWidth(),s=this.bindingView.getViewHeight();let o=0,a=0;if(this.camera.isPerspectiveCamera){const n=this.camera;i.subVectors(this.target,this.camera.position);let r=i.length();r*=Math.tan(n.fov/2*Math.PI/180),o=2*t*r/s,a=2*e*r/s}else{const n=this.camera;o=t*(n.right-n.left)/n.zoom/r,a=e*(n.top-n.bottom)/n.zoom/s}i.setFromMatrixColumn(this.camera.matrix,0),i.multiplyScalar(-o),this.panOffset.add(i),this.screenSpacePanning?i.setFromMatrixColumn(this.camera.matrix,1):(i.setFromMatrixColumn(this.camera.matrix,0),i.crossVectors(this.camera.up,i)),i.multiplyScalar(a),this.panOffset.add(i)}handleUpPan(){if(!this.panInertiaEnabled)return;const t=this.timeStart-this.timeEnd,e=10*this.panDelta.length()*this.panSpeed/t;0!==t&&Number.isFinite(e)&&Number.isFinite(e)&&e>1&&(this.panInertiaBase=e*this.inertiaFactor,this.panInertiaDuration=0,this.panInertiaDirection=this.panDelta.clone().normalize(),this.panInertia=this.panInertiaBase)}handleMouseWheel(t){this.zoomDelta=t.deltaY/67,this.mouseXY.set(t.offsetX,t.offsetY)}handleZoom(t){if(Math.abs(t)<1e-4)return;let e=0,n=null;if(this.followMouse&&(n=xe.getHorizontalPlaneCoordinate3({x:this.mouseXY.x,y:this.mouseXY.y},this.bindingView,this.camera)),t*=this.zoomScale,"zoom"===this.zoomMode){const n=Math.min(Math.max(this.camera.zoom*(1+t),this.zoomRange.min),this.zoomRange.max);e=n-this.camera.zoom,this.camera.zoom=n}else if(this.camera.isPerspectiveCamera){const e=this.camera;e.fov=Math.min(Math.max(e.fov+66.67*t,this.fovRange.min),this.fovRange.max)}if(this.camera.updateProjectionMatrix(),this.needUpdate=!0,this.emit(M.CAMERA_ZOOM,this.zoomMode,"zoom"===this.zoomMode?this.camera.zoom:this.camera.fov,this),this.followMouse&&e&&this.bindingView){const t=xe.getHorizontalPlaneCoordinate3({x:this.mouseXY.x,y:this.mouseXY.y},this.bindingView,this.camera);if(n&&t){const e=t.clone().sub(n);this.setCameraPosition(this.camera.position.clone().sub(e),!0)}}}handleUpZoom(){if(!this.zoomInertiaEnabled)return;const t=this.timeStart-this.timeEnd,e=this.zoomDelta/t;0!==t&&Number.isFinite(e)&&Math.abs(e)>.001&&(this.zoomInertiaBase=e*this.inertiaFactor*2,this.zoomInertiaDuration=0,this.zoomInertia=this.zoomInertiaBase)}handleMouseDownDolly(t){this.dollyStart.set(t.offsetX,t.offsetY)}handleMouseMoveDolly(t){this.dollyEnd.set(t.offsetX,t.offsetY);const e=-Math.sign(this.dollyEnd.y-this.dollyStart.y),n=this.dollyStart.distanceTo(this.dollyEnd),i=this.bindingView.getViewWidth(),r=this.bindingView.getViewHeight(),s=Math.sqrt(i**2+r**2),o=n/s;this.zoomDelta=e*Math.floor(o*s)*S.GetGlobalDPR(),this.dollyStart.copy(this.dollyEnd)}handleTouchStartDolly(t){const e=t.touches[0].clientX-t.touches[1].clientX,n=t.touches[0].clientY-t.touches[1].clientY,i=Math.sqrt(e*e+n*n);this.dollyStart.set(0,i)}handleTouchMoveDolly(t){if(!this.bindingView)return;const e=t.touches[0].clientX-t.touches[1].clientX,n=t.touches[0].clientY-t.touches[1].clientY,i=Math.sqrt(e*e+n*n);this.dollyEnd.set(0,i);const r=this.bindingView.canvas.clientWidth,s=this.bindingView.canvas.clientHeight,o=Math.sqrt(r**2+s**2),a=(i-this.dollyStart.y)/o;this.zoomDelta=-a;let l=1+Math.abs(this.zoomDelta);this.zoomDelta>0&&(l=1/l),this.zoomDelta=l-1,this.zoomDelta*=2;const h=this.touchCenter.clone().set(this.bindingView.getViewWidth()/2,this.bindingView.getViewHeight()/2),c=this.touchCenter.clone().sub(h).multiplyScalar(-this.zoomDelta);this.mouseXY.set(this.touchCenter.x,this.touchCenter.y),this.zoomDelta*=S.GetGlobalDPR(),this.handlePanDelta(c.x,c.y),this.dollyStart.copy(this.dollyEnd)}handleTouchStartDollyRotate(t){this.enableZoom&&this.handleTouchStartDolly(t),this.enableRotate&&this.handleTouchStartRotate(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveSelfRotate(t)}handleTouchStartDollyPan(t){this.enableZoom&&this.handleTouchStartDolly(t),this.enablePan&&this.handleTouchStartPan(t)}handleTouchMoveDollyPan(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchStartMap(t){this.enableZoom&&this.handleTouchStartDolly(t),this.enablePan&&this.handleTouchStartPan(t),this.enableRotate&&this.handleTouchStartRotate(t)}handleTouchMoveAll(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t),this.enableRotate&&this.handleTouchMoveSelfRotate(t)}handleUpAll(){this.handleUpZoom(),this.handleUpPan(),this.handleUpRotate()}resetVectors(){this.panInertiaBase=0,this.panInertia=0,this.panDelta.set(0,0),this.rotateInertiaBase=0,this.rotateInertia=0,this.rotateDelta.set(0,0)}async moveCameraTo(t,e=1e3,n){return new Promise(i=>{const{THREE:r}=x.getInstance(),s=this.camera.position.clone(),o=new r.Vector3,a=n||{};new y.Tween({progress:0}).to({progress:1},e).easing(y.Easing.Quadratic.InOut).onUpdate(({progress:e})=>{o.lerpVectors(s,t,e),this.camera.position.copy(o),a.onUpdate&&a.onUpdate(e),this.needUpdate=!0}).onComplete(()=>{i()}).start()})}setCameraPosition(t,e=!0){const{THREE:n}=x.getInstance(),i=(new n.Vector3).subVectors(this.target,this.camera.position);this.camera.position.copy(t),e&&this.target.copy(t.clone().add(i)),this.needUpdate=!0}getCameraPosition(){return this.camera.position.clone()}setCameraLookAt(t,e=!1){const{THREE:n}=x.getInstance(),i=(new n.Vector3).subVectors(this.camera.position,this.target);this.target.copy(t),e&&this.camera.position.copy(t.clone().add(i)),this.camera.lookAt(t),this.needUpdate=!0}getCameraTarget(){return this.target.clone()}setCameraLookAtVector(t,e=1){this.setCameraLookAt(this.camera.position.clone().add(t.normalize().multiplyScalar(e)))}setDampingEnabled(t){this.enableDamping=t}setDampingFactor(t){this.dampingFactor=t}getDampingFactor(){return this.dampingFactor}setZoomEnabled(t){this.enableZoom=t}setZoomMode(t){if(this.camera.isOrthographicCamera&&"fov"===t)throw new Error("[BasicController] Cannot use fov zoom mode for OrthographicCamera");this.zoomMode=t}setFovRange(t,e){if(this.fovRange.min=t,this.fovRange.max=e,!this.camera.isPerspectiveCamera)return;const n=this.camera;n.fov=Math.min(Math.max(n.fov,this.fovRange.min),this.fovRange.max),n.updateProjectionMatrix(),this.needUpdate=!0}setFov(t){if(!this.camera.isPerspectiveCamera)return;const e=this.camera;e.fov=Math.min(Math.max(t,this.fovRange.min),this.fovRange.max),e.updateProjectionMatrix(),this.needUpdate=!0}getFov(){return this.camera.isPerspectiveCamera?this.camera.fov:null}setZoomRange(t,e){this.zoomRange.min=t,this.zoomRange.max=e,this.camera.zoom=Math.min(Math.max(this.camera.zoom,this.zoomRange.min),this.zoomRange.max),this.camera.updateProjectionMatrix(),this.needUpdate=!0}setZoom(t){this.camera.zoom=Math.min(Math.max(t,this.zoomRange.min),this.zoomRange.max),this.camera.updateProjectionMatrix(),this.needUpdate=!0}getZoom(){return this.camera.zoom}setZoomInertiaEnabled(t){this.zoomInertiaEnabled=t}setRotateEnabled(t){this.enableRotate=t}setRotateMode(t){this.rotateMode=t}setRotateSpeed(t){this.rotateSpeed=t}getRotateSpeed(){return this.rotateSpeed}setRotateInertiaEnabled(t){this.rotateInertiaEnabled=t}setAzimuthAngle(t){const{THREE:e}=x.getInstance(),n=(new e.Quaternion).setFromUnitVectors(this.camera.up,new e.Vector3(0,1,0)),i=n.clone().invert(),r=(new e.Vector3).subVectors(this.target,this.camera.position);"orbit"===this.rotateMode&&r.multiplyScalar(-1),r.applyQuaternion(n),this.spherical.setFromVector3(r),this.spherical.theta=t,this.spherical.makeSafe(),r.setFromSpherical(this.spherical),r.applyQuaternion(i),"self"===this.rotateMode?this.target.copy(this.camera.position.clone().add(r)):this.camera.position.copy(this.target.clone().add(r)),this.camera.lookAt(this.target),this.needUpdate=!0}getAzimuthAngle(){return this.spherical.theta}setPolarAngle(t){const{THREE:e}=x.getInstance(),n=(new e.Quaternion).setFromUnitVectors(this.camera.up,new e.Vector3(0,1,0)),i=n.clone().invert(),r=(new e.Vector3).subVectors(this.target,this.camera.position);"orbit"===this.rotateMode&&r.multiplyScalar(-1),r.applyQuaternion(n),this.spherical.setFromVector3(r),this.spherical.phi=t,this.spherical.makeSafe(),r.setFromSpherical(this.spherical),r.applyQuaternion(i),"self"===this.rotateMode?this.target.copy(this.camera.position.clone().add(r)):this.camera.position.copy(this.target.clone().add(r)),this.camera.lookAt(this.target),this.needUpdate=!0}getPolarAngle(){return this.spherical.phi}setAzimuthRange(t,e){this.minSpherical.theta=t,this.maxSpherical.theta=e}setPolarRange(t,e){this.minSpherical.phi=t,this.maxSpherical.phi=e}setPanInertiaEnabled(t){this.panInertiaEnabled=t}setInertiaFactor(t){this.inertiaFactor=t}setPanEnabled(t){this.enablePan=t}setScreenSpacePanning(t){this.screenSpacePanning=t}setMouseButtons(t){this.mouseButtons=t}setTouches(t){this.touches=t}setBoundaryEnabled(t){this.boundaryEnabled=t}setBoundary(t,e){this.boundary.set(t,e)}setEnabled(t){t!==this.enabled&&(this.enabled=t,t?this.registerEvents():(this.unregisterEvents(),this.resetVectors()))}getEnabled(){return this.enabled}bindView(t){if(this.unbindView(),!t.container&&!t.canvas)throw new Error("View needed initialized with an HTML container or Canvas");if(!t.camera)throw new Error("[BasicController] View for basic controller should have a camera.");if(!t.camera.isPerspectiveCamera&&!t.camera.isOrthographicCamera)throw new Error("[BasicController] Only supports PerspectiveCamera or OrthographicCamera.");const{THREE:e}=x.getInstance();this.camera=t.camera,this.bindingView=t,this.target=new e.Vector3(0,0,-1).applyQuaternion(this.camera.quaternion),this.registerEvents()}update(){const t=Date.now(),e=t-this.lastTick;this.lastTick=t;const{THREE:n}=x.getInstance(),i=(new n.Quaternion).setFromUnitVectors(this.camera.up,new n.Vector3(0,1,0)),r=i.clone().invert(),s=(new n.Vector3).subVectors(this.target,this.camera.position);if("orbit"===this.rotateMode&&s.multiplyScalar(-1),Math.abs(this.zoomInertiaBase)>0&&this.zoomInertiaDuration<600){this.handleZoom(this.zoomInertia);const t=this.zoomInertiaDuration/600;this.zoomInertia=this.zoomInertiaBase*(1-t)**2,this.zoomInertia=Math.max(0,Math.abs(this.zoomInertia))*Math.sign(this.zoomInertia),this.zoomInertiaDuration+=e}if(this.panInertiaBase>0&&this.panInertiaDuration<600){const{x:t,y:n}=this.panInertiaDirection;this.handlePanDelta(t*this.panInertia,n*this.panInertia);const i=this.panInertiaDuration/600;this.panInertia=this.panInertiaBase*(1-i)**2,this.panInertia=Math.max(0,this.panInertia),this.panInertiaDuration+=e}if(this.rotateInertiaBase>0&&this.rotateInertiaDuration<600){if("normal"===this.rotateInertiaType){const{x:t,y:e}=this.rotateInertiaDirection;this.handleRotateDelta(t*this.rotateInertia,e*this.rotateInertia)}else this.handleRotateSphericalDelta(this.rotateInertia,0);const t=this.rotateInertiaDuration/600;this.rotateInertia=this.rotateInertiaBase*(1-t)**2,this.rotateInertia=Math.max(0,this.rotateInertia),this.rotateInertiaDuration+=e}s.applyQuaternion(i),this.spherical.setFromVector3(s);const o=this.sphericalDelta.clone();let{zoomDelta:a}=this;this.enableDamping&&(o.theta*=this.dampingFactor,o.phi*=this.dampingFactor,a*=this.dampingFactor),this.spherical.theta+=o.theta,this.spherical.phi+=o.phi;let{theta:l}=this.minSpherical,{theta:h}=this.maxSpherical;const c=2*Math.PI;return Number.isFinite(l)&&Number.isFinite(h)&&(l<-Math.PI?l+=c:l>Math.PI&&(l-=c),h<-Math.PI?h+=c:h>Math.PI&&(h-=c),this.spherical.theta=l<h?Math.max(l,Math.min(h,this.spherical.theta)):this.spherical.theta>(l+h)/2?Math.max(l,this.spherical.theta):Math.min(h,this.spherical.theta)),this.spherical.phi=Math.max(this.minSpherical.phi,Math.min(this.maxSpherical.phi,this.spherical.phi)),this.spherical.makeSafe(),s.setFromSpherical(this.spherical),s.applyQuaternion(r),this.handleZoom(a),this.enableDamping?"self"===this.rotateMode?this.camera.position.addScaledVector(this.panOffset,this.dampingFactor):this.target.addScaledVector(this.panOffset,this.dampingFactor):"self"===this.rotateMode?this.camera.position.add(this.panOffset):this.target.add(this.panOffset),this.boundaryEnabled&&("self"===this.rotateMode?(this.camera.position.x=Math.min(this.boundary.max.x,Math.max(this.boundary.min.x,this.camera.position.x)),this.camera.position.y=Math.min(this.boundary.max.y,Math.max(this.boundary.min.y,this.camera.position.y)),this.camera.position.z=Math.min(this.boundary.max.z,Math.max(this.boundary.min.z,this.camera.position.z))):(this.target.x=Math.min(this.boundary.max.x,Math.max(this.boundary.min.x,this.target.x)),this.target.y=Math.min(this.boundary.max.y,Math.max(this.boundary.min.y,this.target.y)),this.target.z=Math.min(this.boundary.max.z,Math.max(this.boundary.min.z,this.target.z)))),"self"===this.rotateMode?this.target.copy(this.camera.position.clone().add(s)):this.camera.position.copy(this.target.clone().add(s)),this.camera.lookAt(this.target),this.enableDamping?(this.sphericalDelta.theta*=1-this.dampingFactor,this.sphericalDelta.phi*=1-this.dampingFactor,this.panOffset.multiplyScalar(1-this.dampingFactor),this.zoomDelta*=1-this.dampingFactor):(this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),this.zoomDelta=0),!!(this.needUpdate||this.lastPosition.distanceToSquared(this.camera.position)>1e-6||8*(1-this.lastQuaternion.dot(this.camera.quaternion))>1e-6)&&(this.lastPosition.copy(this.camera.position),this.lastQuaternion.copy(this.camera.quaternion),this.needUpdate=!1,this.emit(M.CAMERA_CHANGED,this.camera.position.clone(),this.camera.quaternion.clone(),this),!0)}unbind(){this.dispose(),this.unbindView()}unbindView(){this.unregisterEvents(),this.bindingView=null}},t.BasicTools=xe,t.Block=Dn,t.BlockSet=class extends ye{constructor(t,e=!1,n="",i=!0){super(),this.initialized=!1,this.loaded=!1,this.blocks=[],this.lowPerformance=e,this.tag=n,this.renderStroke=i,t&&this.load(t,this.lowPerformance,this.renderStroke)}async load(t,e=!1,n=!0){this.initialized=!1,this.loaded=!1,this.lowPerformance=e,this.renderStroke=n,t.forEach(t=>{const e=new Dn(t,this.lowPerformance,this.tag,n);this.blocks.push(e),this.add(e)}),this.loaded=!0}update(){const t=new ve(this);return!this.initialized&&this.loaded&&(this.initialized=!0,t.needUpdate=!0),this.initialized&&!this.parent&&(t.shouldPlaceElement=!0,this.emit(M.ELEMENT_LOADED,this)),t}dispose(){super.dispose(),this.blocks.forEach(t=>{this.remove(t),t.dispose()}),xe.dispose(this,!0)}resize(t,e){this.viewWidth===t&&this.viewHeight===e||(this.blocks.forEach(n=>{n.resize(t,e)}),this.viewWidth=t,this.viewHeight=e)}},t.BottomNavElement=class extends ye{constructor(t){super();const{centerArrowMesh:e,textMeshMap:n,maxLeftAngle:i,maxRightAngle:r,bottomWidth:s,bottomRadius:o}=t;this.enabled=!0,this.bottomWidth=s,this.bottomRadius=o,this.textMeshMap=n,this.textValuePre=0,this.maxLeftAngle=i||0,this.maxRightAngle=r||0,this.centerArrowMesh=e.clone(),this.createBottomNav(),this.setRing(0,"定位中","center"),this.initialized=!1,this.needUpdate=!0,this.directionPre="center"}createBottomNav(){const t=new e.MeshBasicMaterial({color:16777215,wireframe:!1,transparent:!0,blending:e.CustomBlending,blendSrc:e.OneFactor});t.needsUpdate=!0,t.visible=!0,t.opacity=1;const n=this.bottomWidth,i=this.bottomRadius,r=[];for(let t=0;t<128;t++){const s=i*Math.sin(2*Math.PI*t/128),o=i*Math.cos(2*Math.PI*t/128);t>64?r.push(new e.Vector2(s-n/2,o)):r.push(new e.Vector2(s+n/2,o))}const s=new e.Shape(r),o=new e.ShapeGeometry(s);this.torus=new e.Mesh(o,t),this.torus.position.set(0,0,1),this.torus.lookAt(0,0,1),this.add(this.torus)}updateText(t,e){this.leftMeshGroup&&(this.leftMeshGroup.visible=!1),this.rightMeshGroup&&(this.rightMeshGroup.visible=!1);const n=[];n.push(...e.toString());let i=!1;this.textValuePre!==e&&(i=!0),this.directionPre!==this.direction&&(i=!0),this.textValuePre=e,this.directionPre=this.direction,"left"===this.direction||"right"===this.direction?i&&(this.textMeshGroup&&this.torus.remove(this.textMeshGroup),this.textMeshGroup=this.renderText(n,0),this.textMeshGroup.position.set(-this.textMeshGroup.groupOffsetAngle/2,0,0),this.torus.add(this.textMeshGroup)):"center"===this.direction?(this.centerMeshGroup||(this.centerMeshGroup=this.centerArrowMesh,this.centerMeshGroup.position.set(0,this.bottomRadius+11,3),this.torus.add(this.centerMeshGroup)),this.centerMeshGroup.visible=!0,i&&(this.textMeshGroup&&this.torus.remove(this.textMeshGroup),this.textMeshGroup=this.renderText(n,0),this.textMeshGroup.position.set(-this.textMeshGroup.groupOffsetAngle/2,0,0),this.torus.add(this.textMeshGroup))):"stop"===this.direction&&i&&(this.textMeshGroup&&this.torus.remove(this.textMeshGroup),this.textMeshGroup=this.renderText(n,0),this.textMeshGroup.position.set(-this.textMeshGroup.groupOffsetAngle/2,0,0),this.torus.add(this.textMeshGroup))}renderText(t,n=0,i=!1){const r=i?t.reverse():t;let s=0;s=i?-n:n;const o=new e.Group;let a=0,l=0;return r.forEach((t,e)=>{const n=this.textMeshMap.get(t);if(!n)return;const h=n.mesh.clone(),c=n.textWidth;if(0===e&&(a=c),e===r.length-1&&(l=c),s+=c/2,n.spacingLeft){const t=n.spacingLeft/2;s+=t}if(h.position.set(s,0,15),i?s-=c/2:s+=c/2,n.spacing){const t=n.spacing;i?s-=t:s+=t}o.add(h)}),o.groupOffsetAngle=Math.abs(s),o.lastAngle=l,o.firstAngle=a,o}setDirection(t){this.direction=t}setAngle(t){this.angle=t}setText(t){this.text=t}setRing(t,e,n="center"){this.setAngle(t),this.setText(e),this.setDirection(n)}setToursPosition(t,e,n){this.torus.position.set(t,e,n)}setOpacity(t){this.torus.traverse(n=>{const i=n;i.isMesh&&!Array.isArray(i.material)&&(i.material.blending=e.CustomBlending,i.material.blendSrc=e.SrcAlphaFactor,i.material.transparent=!0,i.material.opacity=t)})}setEnabled(t){this.enabled=t}play(){this.isStop=!1}resize(t,e){this.viewWidth===t&&this.viewHeight===e||(this.viewWidth=t,this.viewHeight=e)}update(){const t=new ve(this);return t.needUpdate=this.needUpdate,!this.initialized&&this.torus&&(t.shouldPlaceElement=!0,this.initialized=!0),this.enabled&&this.updateText(-this.angle,this.text),t}dispose(){this.torus.remove(),this.textMeshMap.clear()}},t.CSS2DOverlay=class extends C{init(t,e=t.container){this.container=e,this.parent=t;const{clientWidth:n,clientHeight:i}=this.container;this.renderer=new Nn,this.renderer.setSize(n,i),this.renderer.domElement.style.position="absolute",this.renderer.domElement.style.top="0",this.renderer.domElement.style.userSelect="none",this.container.appendChild(this.renderer.domElement)}resize(t,e){this.renderer.setSize(t,e)}setRenderOrder(t){this.renderer.domElement.style.setProperty("z-index",""+t)}update(){return!1}render(){this.parent.camera&&this.renderer.render(this.parent.stage.scene,this.parent.camera)}dispose(){this.container.removeChild(this.renderer.domElement),this.renderer=null,this.container=null}}
48
+ /**
49
+ * @license
50
+ * Copyright 2010-2021 Three.js Authors
51
+ * SPDX-License-Identifier: MIT
52
+ */,t.CanvasOverlay=class extends C{init(t,e=new HTMLElement){const{THREE:n}=x.getInstance();this.container=e,this.parent=t,this.owlly2D=Zp.getInstance(e),this.layer=this.owlly2D.addLayer(),this.shapes=[],this.renderThisFrame=!0,this.layer.zIndex(0),this.enabled=!0,this.mouseState=Gp.IDLE,this.mousePositionBuffer=new n.Vector2,this.listeners={pointerDown:t=>{this.onPointerDown(t)},pointerUp:t=>{this.onPointerUp(t)},touchStart:t=>{this.onTouchStart(t)},touchEnd:t=>{this.onTouchEnd(t)},nodePointerDown:t=>{this.onNodePointerDown(t)},nodePointerUp:()=>{this.onNodePointerUp()}},this.container.addEventListener("pointerdown",this.listeners.pointerDown,!0),this.container.addEventListener("pointerup",this.listeners.pointerUp,!0),this.container.addEventListener("touchstart",this.listeners.touchStart,!0),this.container.addEventListener("touchend",this.listeners.touchEnd,!0)}openInteraction(){this.owlly2D.openInteraction()}closeInteraction(){this.owlly2D.closeInteraction()}update(){return!!this.renderThisFrame&&(this.renderThisFrame=!1,!0)}render(){if(this.enabled){if(this.parent.camera){const{camera:t}=this.parent,{clientHeight:e,clientWidth:n}=this.container,i=n/2,r=e/2;this.shapes.forEach(({shape:e,rawShape:n,zIndices:s,points:o,vertexOptions:a,lineJointsStyle:l})=>{this.updateShapeDataToKonvaShape(e,n,t,i,r,o,a,s,l)})}this.layer.draw()}}setRenderOrder(t){this.layer.zIndex(t)}dispose(){this.shapes.forEach(t=>{t.shape.destroy(),0===t.shape.children.length&&(t.shape.destroy(),t.points.forEach(t=>{t.off("mousedown touchdown"),t.destroy()})),t&&t.shape&&delete t.shape}),this.renderThisFrame=!0,this.container.removeEventListener("pointerdown",this.listeners.pointerDown,!0),this.container.removeEventListener("pointerup",this.listeners.pointerUp,!0),this.container.removeEventListener("touchstart",this.listeners.touchStart,!0),this.container.removeEventListener("touchend",this.listeners.touchEnd,!0),this.layer.destroy()}onPointerDown(t){this.owlly2D.stage._mousedown(t)}onPointerUp(t){const{THREE:e}=x.getInstance();this.owlly2D.stage._mouseup(t);const{clientX:n,clientY:i}=t,{left:r,top:s}=this.container.getBoundingClientRect(),o=n-r,a=i-s,l=new e.Vector2(o,a).distanceToSquared(this.mousePositionBuffer);this.emit(M.CANVAS_VERTEX_UP,this.eventTarget,t.button),this.mouseState===Gp.DOWN&&l<100&&this.emit(M.CANVAS_VERTEX_CLICKED,this.eventTarget,t.button),this.mouseState=Gp.IDLE}onTouchStart(t){this.owlly2D.stage._touchstart(t)}onTouchEnd(t){const{THREE:e}=x.getInstance();this.owlly2D.stage._touchend(t);const{clientX:n,clientY:i}=t.changedTouches[0],{left:r,top:s}=this.container.getBoundingClientRect(),o=n-r,a=i-s,l=new e.Vector2(o,a).distanceToSquared(this.mousePositionBuffer);this.emit(M.CANVAS_VERTEX_UP,this.eventTarget,0),this.mouseState===Gp.DOWN&&l<100&&this.emit(M.CANVAS_VERTEX_CLICKED,this.eventTarget,0),this.mouseState=Gp.IDLE}onNodePointerDown(t){if(this.mouseState!==Gp.IDLE)return;let e=-1;const n=this.shapes.find(n=>{const i=n.points.indexOf(t.currentTarget);return i>=0&&(e=i),i>=0});if(!n)return;this.mouseState=Gp.DOWN;const{clientX:i,clientY:r}=t.evt instanceof MouseEvent?t.evt:t.evt.touches[0],{left:s,top:o}=this.container.getBoundingClientRect(),a=i-s,l=r-o;this.mousePositionBuffer.set(a,l),this.eventTarget=n,this.emit(M.CANVAS_VERTEX_DOWN,n,e,t.evt instanceof MouseEvent?t.evt.button:0)}onNodePointerUp(){}clearShapes(){this.shapes.forEach(t=>{t.shape.destroy(),t.points.forEach(t=>{t.destroy()}),delete t.shape}),this.shapes=[],this.renderThisFrame=!0}removeShape(t){if(t)for(let e=0;e<this.shapes.length;e++)if(this.shapes[e].rawShape===t||this.shapes[e].shape===t){this.shapes[e].shape.destroy();const t=this.shapes[e];0===this.shapes[e].shape.children.length&&(this.shapes[e].shape.destroy(),this.shapes[e].points.forEach(t=>{t.off("mousedown touchdown"),t.destroy()}),this.shapes.splice(e,1)),t===this.shapes[e]&&this.shapes[e].shape&&delete this.shapes[e].shape,this.renderThisFrame=!0}}updateShape(t,e=[]){if(!t)return null;const{Konva:n}=x.getInstance();for(let i=0;i<this.shapes.length;i++)if(this.shapes[i].rawShape===t||this.shapes[i].shape===t){const t=this.shapes[i].shape;if(this.shapes[i].zIndices=e,t instanceof n.Shape){const e=this.transformShapeDataToKonvaShape(this.shapes[i].rawShape.getData());e&&t.setAttrs(e.attrs),this.shapes[i].points.forEach(t=>{t.setAttrs(this.shapes[i].vertexOptions)})}return this.renderThisFrame=!0,this.shapes[i].shape}return null}setVertexConfig(t,e){if(!t)return null;for(let n=0;n<this.shapes.length;n++)if(this.shapes[n].rawShape===t||this.shapes[n].shape===t){const t=Object.assign(this.shapes[n].vertexOptions,e);return this.shapes[n].points.forEach(e=>{e.setAttrs(t)}),this.renderThisFrame=!0,this.shapes[n].shape}return null}transformShapeDataToKonvaShape(t){const{shapeType:e}=t,{Konva:n}=x.getInstance();if("point"===e){return new n.Circle({radius:t.radius,id:t.id,x:t.x,y:t.y,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill})}if("line"===e){return new n.Path({id:t.id,x:t.x,y:t.y,data:""+t.path.toUpperCase(),stroke:t.stroke,strokeWidth:t.strokeWidth,lineJoin:"round",lineCap:"round"})}if("shape"===e){return new n.Path({id:t.id,x:t.x,y:t.y,data:t.path.toUpperCase()+"z",stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,lineJoin:"round",lineCap:"round"})}return null}updateShapeDataToKonvaShape(t,e,n,i,r,s,o,a=[],l="joints"){const{THREE:h,Konva:c}=x.getInstance(),u=e.getData(),{shapeType:d}=u,p=new h.Frustum;if(p.setFromProjectionMatrix((new h.Matrix4).multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse)),"point"===d){const e=t,s=new h.Vector3(u.x,u.y,u.zIndex).project(n),o=(s.x+1)*i,a=(1-s.y)*r;e.x(o),e.y(a)}else if(n instanceof h.OrthographicCamera){const s=t,o=e.getSteps(),l=u.zIndex;let c=o.map((t,e)=>{let s=l;e<a.length&&(s=a[e]);const o=t.coords.map(([t,e])=>{const o=new h.Vector3(t,e,s).project(n);return`${(o.x+1)*i},${(1-o.y)*r}`}).join(",");return`${t.command}${o}`}).join("").toUpperCase();"shape"===d&&(c+="z"),s.data(c)}else{const f=t,m=e.getSteps(),g=u.zIndex;new h.Vector3(0,0,-1).applyQuaternion(n.quaternion);let v=!1,y=!1;const x=new h.Vector3;let b=m.map((t,e)=>{let u=g;e<a.length&&(u=a[e]);const[d,m]=t.coords[t.coords.length-1],b=new h.Vector3(d,m,u);let w="";if(y=p.containsPoint(b),e>0){const t=new h.Line3(x.clone(),b.clone());if(!(v&&y)){const e=p.planes.map(e=>{const n=e.intersectLine(t,new h.Vector3);if(!n)return null;return!p.planes.filter(t=>t!==e).some(t=>t.distanceToPoint(n)<0)?n:null}).filter(t=>t);e.length&&(e.sort((t,e)=>t.distanceToSquared(x)-e.distanceToSquared(x)),w=e.map((t,e)=>{const s=t.project(n),o=s.z>1?-1:1,a=(s.x+1)*i*o,l=(1-s.y)*r*o;return 0===e?`${v?"l":"m"}${a},${l}`:`l${a},${l}`}).join(""))}}x.copy(b);const M=b.project(n),_=M.z>1?-1:1,E=(M.x+1)*i*_,S=(1-M.y)*r*_,T="joints"===l||"endpoints"===l&&(0===e||e===a.length-1);if(e<s.length){const t=s[e];t.x(E),t.y(S),t.visible(T&&y&&f.visible()),t.setAttrs(o)}else{const t=new c.Circle({radius:0,x:E,y:S,stroke:"transparent",strokeWidth:0});t.visible(T&&y&&f.visible()),t.setAttrs(o),t.on("mousedown touchdown",this.listeners.nodePointerDown),this.layer.add(t),s.push(t)}return v=y,`${w}${y?"l":"m"}${E},${S}`}).join("").toUpperCase();for(;s.length>m.length;){const t=s.pop();t.off("mousedown touchdown"),t.destroy()}"shape"===d&&(b+="z"),f.data(b)}}addShape(t,e={x:1,y:1},n=[]){const i=[],r=Array.isArray(t)?t:[t],s=n.length&&Array.isArray(n[0])?n:[n];return r.forEach((t,n)=>{const r=t.getData(),o=this.transformShapeDataToKonvaShape(r);if(null!==o){i.push(o),this.layer.add(o);const r=new Jp(o,t,e,s[n]);r.points.forEach(t=>{t.setAttrs(r.vertexOptions)}),this.shapes.push(r)}}),this.renderThisFrame=!0,Array.isArray(t)?i:i.length>0?i[0]:null}getShapeGroup(t){return this.shapes.find(e=>e.rawShape===t||e.shape===t)}forceRender(){this.renderThisFrame=!0}getMiddlePoint(t){const e=this.getShapeGroup(t);if(!e)return null;const n=e.rawShape.getSteps(),{zIndices:i}=e,{THREE:r}=x.getInstance();if(!n.length)return null;const s=[0];let o=0;const a=new r.Vector3(n[0].coords[n[0].coords.length-1][0],n[0].coords[n[0].coords.length-1][1],i.length>0?i[0]:0),l=new r.Vector3,h=(new r.Vector3).copy(a);for(let t=1;t<n.length;t+=1){const[e,r]=n[t].coords[n[t].coords.length-1],h=i[t];l.set(e,r,h);o+=l.distanceTo(a),s.push(o),a.copy(l)}const c=o/2;let u=0;for(;u+1<s.length&&s[u+1]<c;)u+=1;if(h.set(n[u].coords[n[u].coords.length-1][0],n[u].coords[n[u].coords.length-1][1],i.length>u?i[u]:0),u+1<s.length){const t=s[u+1]-s[u],e=(c-s[u])/t,o=new r.Vector3(n[u+1].coords[n[u+1].coords.length-1][0],n[u+1].coords[n[u+1].coords.length-1][1],i.length>u+1?i[u+1]:0);h.add(o.sub(h).multiplyScalar(e))}return h}setEnabled(t){this.enabled=t}resize(t,e){this.owlly2D.resize(t,e)}},t.Controller=Kp,t.CubeFaceConfig=ps,t.DeviceUtils=class{static GetVersion(t,e){let n=window.navigator.userAgent.match(t);return n=n?n[1].split(e):[],{major:parseInt(n[0],10)||0,minor:parseInt(n[1],10)||0,patch:parseInt(n[2],10)||0}}static DetectWeChat(){const t=window.navigator.userAgent.toLowerCase();return!!t&&"micromessenger"===t.toString()}static DetectIOS(){return this.DetectIPhone()||this.DetectIPad()||this.DetectIPod()}static DetectIPad(){const{userAgent:t}=window.navigator;return/iPad/.test(t)}static DetectIPod(){const{userAgent:t}=window.navigator;return/iPod/.test(t)}static DetectIPhone(){const{userAgent:t}=window.navigator;return/iPhone/.test(t)}static DetectAndroid(){return-1!==window.navigator.userAgent.indexOf("Android")}static DetectAndroidMobile(){const{userAgent:t}=window.navigator;return this.DetectAndroid()&&-1!==t.indexOf("Mobile")}},t.Element=ye,t.ElementFrameContext=ve,t.EnvironmentUtils=S,t.EventHub=b,t.EventHubClassic=w,t.Events=M,t.Externals=x,t.FragmentShader="\n uniform sampler2D mTexture0;\n uniform sampler2D mTexture1;\n uniform sampler2D mTexture2;\n uniform sampler2D mTexture3;\n uniform sampler2D mTexture4;\n uniform sampler2D mTexture5;\n uniform sampler2D mTexture6;\n uniform sampler2D mTexture7;\n uniform sampler2D mTexture8;\n uniform sampler2D mTexture9;\n uniform sampler2D mTexture10;\n uniform sampler2D mTexture11;\n uniform sampler2D mTexture12;\n uniform sampler2D mTexture13;\n uniform sampler2D mTexture14;\n uniform sampler2D mTexture15;\n\n uniform int uvMax;\n varying vec3 vUv;\n uniform bool black;\n\n int modi(int x, int y) {\n int result = x - ((x / y) * y);\n return result < 0 ? result + y : result;\n }\n\n float modf(float x, float y){\n float result = x - y * floor(x/y);\n return result < 0.0 ? result + y : result;\n }\n\n int getInt(float value) {\n // 添加边界检查\n if (value < 0.0) return 0;\n if (value > float(0x7FFFFFFF)) return 0x7FFFFFFF;\n\n float m = modf(value, 1.0);\n return m < 1.0 && m > 0.6 ? int(value) + 1 : int(value);\n }\n\n vec4 getSample(int index, vec2 uv) {\n if (index == 0) return texture2D(mTexture0, uv);\n if (index == 1) return texture2D(mTexture1, uv);\n if (index == 2) return texture2D(mTexture2, uv);\n if (index == 3) return texture2D(mTexture3, uv);\n if (index == 4) return texture2D(mTexture4, uv);\n if (index == 5) return texture2D(mTexture5, uv);\n if (index == 6) return texture2D(mTexture6, uv);\n if (index == 7) return texture2D(mTexture7, uv);\n if (index == 8) return texture2D(mTexture8, uv);\n if (index == 9) return texture2D(mTexture9, uv);\n if (index == 10) return texture2D(mTexture10, uv);\n if (index == 11) return texture2D(mTexture11, uv);\n if (index == 12) return texture2D(mTexture12, uv);\n if (index == 13) return texture2D(mTexture13, uv);\n if (index == 14) return texture2D(mTexture14, uv);\n if (index == 15) return texture2D(mTexture15, uv);\n return vec4(0.0, 0.0, 0.0, 1.0); // 默认返回透明黑色\n }\n\n vec2 getUv(vec2 uvs, int pos){\n // 严格的边界保护\n float min2 = 1.0 / 4096.0;\n float max2 = 1.0 - min2;\n vec2 clampedUvs = clamp(uvs, vec2(min2), vec2(max2));\n\n vec2 tuv = clampedUvs / 4.0;\n int x = modi(pos, 4);\n int y = pos / 4;\n\n float segment = 1.0 / 4.0;\n vec2 base = vec2(float(x) * segment, float(y) * segment);\n\n // 添加额外的边界检查\n return clamp(tuv + base, vec2(0.0), vec2(1.0));\n }\n\n void main(){\n vec2 tuv = vUv.xy;\n int indexPos = getInt(vUv.z);\n int index = indexPos / 100;\n int pos = modi(indexPos, 100);\n tuv = getUv(tuv, pos);\n gl_FragColor = getSample(index, tuv);\n }",t.GLTFLoader=Sn,t.GeometryUtils=me,t.Helper=class{static createLine(t,n="0000ff",i=10){const r=t.map(t=>new e.Vector3(...t)),s=(new e.BufferGeometry).setFromPoints(r),o=new e.LineBasicMaterial({color:n,side:e.DoubleSide,depthTest:!1}),a=new e.Line(s,o);return o.needsUpdate=!0,a.renderOrder=i,a}static createAxes(t,n=10,i=10){const r=new e.AxesHelper(n);return r.visible=!0,r.position.set(...t),r.renderOrder=i,r}},t.IMG_TEXT_PIXEL=us,t.LineGeometry=class extends tf{constructor(){super(),this.type="LineGeometry"}setPositions(t){const e=t.length-3,n=new Float32Array(2*e);for(let i=0;i<e;i+=3)n[2*i]=t[i],n[2*i+1]=t[i+1],n[2*i+2]=t[i+2],n[2*i+3]=t[i+3],n[2*i+4]=t[i+4],n[2*i+5]=t[i+5];return super.setPositions(n),this}setColors(t){const e=t.length-3,n=new Float32Array(2*e);for(let i=0;i<e;i+=3)n[2*i]=t[i],n[2*i+1]=t[i+1],n[2*i+2]=t[i+2],n[2*i+3]=t[i+3],n[2*i+4]=t[i+4],n[2*i+5]=t[i+5];return super.setColors(n),this}fromLine(t){const{geometry:e}=t;if(!e.isGeometry)return e.isBufferGeometry&&this.setPositions(e.attributes.position.array),this;console.error("THREE.LineGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.")}},t.LineMaterial=nf,t.LineSegments2=rf,t.MapUtils=be,t.MeshLine2D=gs,t.OrthographicView=class extends R{createCamera(){if(this.camera)return;const{THREE:t}=x.getInstance(),e=this.getViewWidth(),n=this.getViewHeight();this.camera=new t.OrthographicCamera(-e/2,e/2,n/2,-n/2,.1,5e3),this.camera.up.set(0,0,1),this.camera.position.set(0,0,100),this.camera.lookAt(0,0,0)}resize(t,e){super.resize(t,e);const{z:n,w:i}=this.rendererOffset||this.rendererOffsetDefault;this.updateCameraAspect(),this.renderer.setSize(n,i)}bindScreen(t){super.bindScreen(t),this.createCamera()}unbindScreen(){super.unbindScreen()}render(){this.enabled&&this.renderer&&this.renderer.render(this.stage.scene,this.camera)}dispose(){super.dispose()}setViewport(t){super.setViewport(t),this.updateCameraAspect()}updateCameraAspect(){const t=this.getViewWidth(),e=this.getViewHeight();this.camera.left=-t/2,this.camera.right=t/2,this.camera.top=e/2,this.camera.bottom=-e/2,this.camera.updateProjectionMatrix()}setCameraWorldMatrix(t){const{THREE:e}=x.getInstance();this.camera.matrixAutoUpdate=!1;const n=new e.Vector3,i=new e.Vector3,r=new e.Quaternion;(new e.Matrix4).fromArray(t).decompose(n,r,i),this.camera.position.copy(n),this.camera.quaternion.copy(r),this.camera.scale.copy(i),this.camera.updateMatrixWorld(!0),this.camera.matrixAutoUpdate=!0}setCameraViewPort(t,e,n,i,r,s){this.camera?(this.camera.setViewOffset(t,e,n,i,r,s),this.updateCameraAspect()):console.warn("view.setCameraViewPort() is before bind screen")}},t.OwllyEvents=_,t.PathOverlay2=vs,t.PathUtils=Rn,t.PerspectiveView=class extends R{createCamera(){if(this.camera)return;const{THREE:t}=x.getInstance();this.camera=new t.PerspectiveCamera(60,1,.01,2e3),this.camera.up.set(0,0,1),this.camera.position.set(0,0,100),this.camera.lookAt(0,0,0)}resize(t,e){super.resize(t,e);const{z:n,w:i}=this.rendererOffset||this.rendererOffsetDefault;this.updateCameraAspect(),this.renderer.setSize(n,i)}bindScreen(t){super.bindScreen(t),this.createCamera(),this.resize(t.width,t.height)}unbindScreen(){super.unbindScreen()}render(){this.enabled&&this.renderer&&this.renderer.render(this.stage.scene,this.camera)}dispose(){super.dispose()}setViewport(t){super.setViewport(t),this.updateCameraAspect()}updateCameraAspect(){const{z:t,w:e}=this.rendererOffset||this.rendererOffsetDefault;this.camera.aspect=t/e,this.camera.updateProjectionMatrix()}setCameraWorldMatrix(t){const{THREE:e}=x.getInstance();this.camera.matrixAutoUpdate=!1;const n=new e.Vector3,i=new e.Vector3,r=new e.Quaternion;(new e.Matrix4).fromArray(t).decompose(n,r,i),this.camera.position.copy(n),this.camera.quaternion.copy(r),this.camera.scale.copy(i),this.camera.updateMatrixWorld(!0),this.camera.matrixAutoUpdate=!0}setCameraViewPort(t,e,n,i,r,s){this.camera?(this.camera.setViewOffset(t,e,n,i,r,s),this.updateCameraAspect()):console.warn("view.setCameraViewPort() is before bind screen")}},t.Placeable2D=class extends ye{constructor(t,e,n){super(),this.frames=[],this.labelID=t,this.initialized=!1,this.needUpdate=!1,this.isEditingInView=new Map,this.currentPID=-1,this.movedToNewPanorama=!0,this.outOfRange=!0,this.currentDisplayTime=0,this.frameIndex=0,this.tileDispDuration=60,this.hidden=!1;const{THREE:i}=x.getInstance(),{width:r,height:s,depthTest:o}=n||{};this.width=r||.1,this.height=s||.1,this.depthTest=o||!1;const a=new i.PlaneBufferGeometry(this.width,this.height);this.uniforms={map:{type:"t",value:null},blendColor:{type:"v4",value:new i.Vector4(0,0,0,0)},opacity:{value:1}},this.material=new i.ShaderMaterial({transparent:!0,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D map;\n uniform vec4 blendColor;\n uniform float opacity;\n varying vec2 vUv;\n void main(){\n vec4 texColor = texture2D(map, vUv);\n gl_FragColor = vec4((texColor * (1.0 - blendColor.a) + blendColor * blendColor.a).rgb, texColor.a) * vec4(1, 1, 1, opacity);\n }",uniforms:this.uniforms,depthTest:this.depthTest,depthWrite:!1,name:"placeable2DMaterial",side:i.DoubleSide}),this.labelMesh=new i.Mesh(a,this.material),this.labelMesh.renderOrder=400,this.add(this.labelMesh),this.imgElement=document.createElement("div"),this.imgElement.style.pointerEvents="none",this.imgElement.innerHTML=`<div><img width=50px height=50px src="${e}"></div>`,this.cssObject=new zn(this.imgElement),this.add(this.cssObject),this.viewConfigurations=new Map,this.eventListeners={onMoveToPanorama:(t,e)=>{this.updateCurrentBindingPanorama(t,e)},onPositionChanged:(t,e,n)=>{if(e!==this)return;const{visible:i}=this.getViewConfigurationByPanoramaId(n,this.currentPID);this.updateViewConfigurationByPanoramaId(n,this.currentPID,{visible:i,position:t})}},b.on(M.MOVE_TO_PANORAMA,this.eventListeners.onMoveToPanorama),b.on(_.ELEMENT_POSITION_UPDATED,this.eventListeners.onPositionChanged),e&&this.load(e)}async load(t){this.initialized=!1;const e=t.search(/\.gif$/),{THREE:n}=x.getInstance();if(e>0){const e=new XMLHttpRequest;e.open("GET",t,!0),e.responseType="arraybuffer",e.onload=async()=>{let t;t=e.response,this.gif=kn.parse(t),t.toString().indexOf("ArrayBuffer")>0&&(t=new Uint8Array(t)),this.gif.split(!0).forEach(async t=>{const e=new Image,i=class{static writeToBlob(t){if("function"==typeof Blob)return new Blob(t,{type:"image/gif"});throw new Error("writeToBlob is browser-only function")}static writeToDataUrl(t){let e="";return t.forEach(t=>{const n=[];for(let e=0,i=t.byteLength;e<i;++e)n.push(t[e]);e+=String.fromCharCode.apply(null,n)}),"data:image/gif;base64,"+btoa(e)}}.writeToBlob(t.writeToArrayBuffer());e.src=URL.createObjectURL(i),e.onload=async()=>{if(this.frames.push(e),this.gif.frames.length===this.frames.length){this.frameIndex=0,this.currentDisplayTime=(new Date).getTime();const t=new n.PlaneBufferGeometry(this.width,this.height);this.gifCanvas=document.createElement("canvas"),this.gifCanvas.width=this.gif.width,this.gifCanvas.height=this.gif.height,this.gifContext=this.gifCanvas.getContext("2d"),this.gifContext&&this.gifContext.drawImage(this.frames[this.frameIndex],0,0,this.gif.width,this.gif.height),this.giftexture=new n.Texture(this.gifCanvas),this.giftexture.needsUpdate=!0,this.gifMaterial=new n.MeshBasicMaterial({map:this.giftexture,transparent:!0,side:n.DoubleSide}),this.gifLabelMesh=new n.Mesh(t,this.gifMaterial),this.add(this.gifLabelMesh),this.needUpdate=!0,this.emit(M.ELEMENT_LOADED,this)}}})},e.send()}else(new n.TextureLoader).load(t,t=>{this.uniforms.map.value=t,this.needUpdate=!0,this.emit(M.ELEMENT_LOADED,this)})}drawCanvas(){this.gifContext&&(this.gifContext.clearRect(0,0,this.gif.width,this.gif.height),this.gifContext.drawImage(this.frames[this.frameIndex],0,0,this.gif.width,this.gif.height),this.giftexture.needsUpdate=!0,this.needUpdate=!0)}update(){const t=new ve(this);if(this.initialized||(this.initialized=!0,t.needUpdate=!0),this.needUpdate&&(t.needUpdate=!0,this.needUpdate=!1),null!==this.gifLabelMesh){const t=(new Date).getTime();t-this.currentDisplayTime>=this.tileDispDuration&&(this.currentDisplayTime=t,this.frameIndex+=1,this.frameIndex>=this.frames.length&&(this.frameIndex=0),this.drawCanvas())}return this.initialized&&!this.parent&&(t.shouldPlaceElement=!0),t}dispose(){const t=this.uniforms.map.value;t&&t.dispose(),b.off(M.MOVE_TO_PANORAMA,this.eventListeners.onMoveToPanorama),b.off(_.ELEMENT_POSITION_UPDATED,this.eventListeners.onPositionChanged),this.imgElement=null,this.cssObject.dispatchEvent({type:"remove"}),this.remove(this.cssObject),this.cssObject=null,super.dispose()}addViewConfiguration(t){const e={targetView:t.targetView,faceToCamera:t.faceToCamera,keepZOnFaceToCamera:t.keepZOnFaceToCamera,showDom:!1,showMesh:!0,visibleScope:5},n=this.viewConfigurations.get(t.targetView);n&&(e.visibilities=n.visibilities,e.positions=n.positions,void 0===e.faceToCamera&&(e.faceToCamera=n.faceToCamera),void 0===e.keepZOnFaceToCamera&&(e.keepZOnFaceToCamera=n.keepZOnFaceToCamera),e.showDom=n.showDom,e.showMesh=n.showMesh,e.visibleScope=n.visibleScope),void 0!==t.showDom&&(e.showDom=t.showDom),void 0!==t.showMesh&&(e.showMesh=t.showMesh),void 0!==t.visibleScope&&(e.visibleScope=t.visibleScope),t.visibilities&&(e.visibilities||(e.visibilities=new Map),t.visibilities.forEach(t=>{e.visibilities.set(t.pid,t.visible)})),t.positions&&(e.positions||(e.positions=new Map),t.positions.forEach(t=>{e.positions.set(t.pid,t.position)})),this.viewConfigurations.set(e.targetView,e)}setEditingMode(t,e){this.isEditingInView.set(t,e),this.needUpdate=!0}isEditing(t){return!!this.isEditingInView.get(t)}setSize(t,e){const{THREE:n}=x.getInstance();this.width=t,this.height=e;const i=new n.PlaneBufferGeometry(t,e);this.labelMesh.geometry=i}getSize(){return[this.width,this.height]}setDomCSS(t,e,n){if(this.imgElement){const i=this.imgElement.getElementsByTagName("img")[0];let r;r=n?`${n};width:${t.toString()}px;height:${e.toString()}px;`:`width:${t.toString()}px;height:${e.toString()}px;`,i.style.cssText=r,this.width=t,this.height=e,this.isDomElement=!0}}getViewConfigurationByPanoramaId(t,e){const n=this.viewConfigurations.get(t);if(!n)throw new Error("Cannot find view configuration");const i=n.positions.has(e)?n.positions.get(e):n.positions.get(-1);return{visible:n.visibilities.has(e)?n.visibilities.get(e):n.visibilities.get(-1),position:i}}updateViewConfigurationByPanoramaId(t,e,{visible:n,position:i}){const r=this.viewConfigurations.get(t);if(!r)throw new Error("Cannot find view configuration");void 0!==i&&r.positions.set(e,i),void 0!==n&&r.visibilities.set(e,n),this.needUpdate=!0}updateCurrentBindingPanorama(t,e){this.currentPID=t,this.movedToNewPanorama=!0,this.currentPanoramaPosition=e?e.clone():null}setHidden(t){this.hidden=t}},t.Poi=qp,t.Poi3D=Qp,t.Poi3DOverlay=$p,t.PoiOverlay=Yp,t.RingElement=class extends ye{constructor(t){super();const{innerRadius:n,outerRadius:i,tubeRadius:r,textArrowMesh:s,signMesh:o,textMeshMap:a,maxLeftAngle:l,maxRightAngle:h,downMesh:c}=t,u=new e.RingGeometry(n,i,540,1),d=new e.MeshBasicMaterial({color:16777215,wireframe:!1,blending:e.CustomBlending,blendSrc:e.OneFactor});d.needsUpdate=!0,d.visible=!0,d.opacity=1,this.torus=new e.Mesh(u,d),this.torus.position.set(0,0,1),this.torus.lookAt(0,0,1),this.add(this.torus),this.enabled=!0,this.textArrowMesh=s,this.textArrowMesh.visible=!1,this.signMesh=o,this.signMesh.visible=!1,this.downMesh=c,this.downMesh.visible=!0,this.torus.add(this.textArrowMesh),this.textMeshMap=a,this.textValuePre=0,this.tubeRadius=r||0,this.maxLeftAngle=l||0,this.maxRightAngle=h||0,this.setRing(0,"123米","center");const p=n,f=i-n;this.innerRadius=n,this.outerRadius=i,this.navRadius=p+f/2,this.createMask(n,i),this.createSign(n,f),this.createDown(n),this.initialized=!1,this.needUpdate=!0,this.directionPre="center"}createSign(t,e){for(let n=0;n<2*Math.PI;n+=Math.PI/180){const i=Math.cos(n)*(t+e/2),r={x:Math.sin(n)*(t+e/2),y:i},s=this.signMesh.clone();s.position.set(r.x,r.y,2),s.lookAt(0,0,1),n<Math.PI?s.rotateY(Math.PI/2):s.rotateY(-Math.PI/2),s.visible=!0,this.torus.add(s)}}createDown(t){const e=this.downMesh.clone();e.position.set(0,t-10,10),this.downArrow=e,this.add(e)}createMask(t,n){const i=new e.MeshBasicMaterial({transparent:!0,blending:e.CustomBlending,blendSrc:e.OneFactor,color:16777215}),r=new e.RingGeometry(t+n/2,t-n/2,540,1,Math.PI/2,Math.PI/18);this.maskCenterMesh=new e.Mesh(r,i),this.maskCenterMesh.position.set(0,0,3),this.torus.add(this.maskCenterMesh)}updateText(t,n){let i=t;this.isStop&&(i=0,this.direction="center"),"left"===this.direction&&(i=-this.maxLeftAngle),"right"===this.direction&&(i=-this.maxRightAngle),this.leftMeshGroup&&(this.leftMeshGroup.visible=!1),this.centerMeshGroup&&(this.centerMeshGroup.visible=!1),this.rightMeshGroup&&(this.rightMeshGroup.visible=!1),this.textArrowMesh&&(this.textArrowMesh.visible=!1);const r=[];r.push(...n.toString());let s=!1;if(this.textValuePre!==n&&(s=!0),this.directionPre!==this.direction&&(s=!0),this.textValuePre=n,this.directionPre=this.direction,"left"===this.direction){if(this.leftMeshGroup||(this.leftMeshGroup=this.renderText("ls".split("")),this.torus.add(this.leftMeshGroup)),s&&(this.leftTextMeshGroup&&this.leftMeshGroup.remove(this.leftTextMeshGroup),this.leftTextMeshGroup=this.renderText(r,this.leftMeshGroup.groupOffsetAngle),this.leftMeshGroup.add(this.leftTextMeshGroup),this.maskCenterMesh&&s)){const t=this.maskCenterMesh.geometry,n=new e.RingGeometry(this.innerRadius,this.outerRadius,60,1,0,this.leftTextMeshGroup.groupOffsetAngle-this.leftTextMeshGroup.lastAngle/2);this.maskCenterMesh.geometry=n,setTimeout(()=>{t.dispose()})}this.maskCenterMesh&&(this.maskCenterMesh.rotation.z=Math.PI/2-this.leftTextMeshGroup.groupOffsetAngle+this.leftTextMeshGroup.lastAngle/2),this.leftMeshGroup.visible=!0}else if("right"===this.direction){if(this.rightMeshGroup||(this.rightMeshGroup=this.renderText("sr".split(""),0,!0),this.torus.add(this.rightMeshGroup)),s&&(this.rightTextMeshGroup&&this.rightMeshGroup.remove(this.rightTextMeshGroup),this.rightTextMeshGroup=this.renderText(r,this.rightMeshGroup.groupOffsetAngle,!0),this.rightMeshGroup.add(this.rightTextMeshGroup)),this.rightMeshGroup.visible=!0,this.maskCenterMesh&&s){const t=this.maskCenterMesh.geometry,n=new e.RingGeometry(this.innerRadius,this.outerRadius,60,1,0,this.rightTextMeshGroup.groupOffsetAngle-this.rightTextMeshGroup.firstAngle/2);this.maskCenterMesh.geometry=n,this.maskCenterMesh.rotation.z=Math.PI/2,setTimeout(()=>{t.dispose()})}}else if("center"===this.direction&&(s&&(this.centerMeshGroup&&this.torus.remove(this.centerMeshGroup),this.centerMeshGroup=this.renderText(r),this.torus.add(this.centerMeshGroup),this.centerMeshGroup.rotateZ(this.centerMeshGroup.groupOffsetAngle/2)),this.centerMeshGroup.visible=!0,this.isStop||!this.showTopArrow?this.textArrowMesh.visible=!1:(this.textArrowMesh.visible=!0,this.textArrowMesh.position.set(0,this.innerRadius+this.tubeRadius,5)),this.maskCenterMesh&&s)){const t=this.maskCenterMesh.geometry,n=new e.RingGeometry(this.innerRadius,this.outerRadius,60,1,0,this.centerMeshGroup.groupOffsetAngle-this.centerMeshGroup.firstAngle/2-this.centerMeshGroup.lastAngle/2);this.maskCenterMesh.geometry=n,this.maskCenterMesh.rotation.z=Math.PI/2-this.centerMeshGroup.groupOffsetAngle/2+this.centerMeshGroup.lastAngle/2,setTimeout(()=>{t.dispose()})}this.isStop?this.torus.rotation.z=0:this.torus.rotation.z=-i}renderText(t,n=0,i=!1){const r=i?t.reverse():t;let s=0;s=i?-n:n;const o=new e.Group;let a=0,l=0;return r.forEach((t,e)=>{const n=this.textMeshMap.get(t);if(!n)return;const h=n.mesh.clone(),c=2*Math.asin(n.textWidth/2/this.navRadius);if(0===e&&(a=c),e===r.length-1&&(l=c),i?s-=c/2:s+=c/2,n.spacingLeft){const t=2*Math.asin(n.spacingLeft/2/this.navRadius);i?s-=t:s+=t}const u=this.navRadius,d=u*Math.sin(s),p=u*Math.cos(s);if(h.position.set(d,p,15),h.rotateZ(-s),i?s-=c/2:s+=c/2,n.spacing){const t=2*Math.asin(n.spacing/2/this.navRadius);i?s-=t:s+=t}o.add(h)}),o.groupOffsetAngle=Math.abs(s),o.lastAngle=l,o.firstAngle=a,o}setDirection(t){this.direction=t}setAngle(t){this.angle=t}setText(t){this.text=t}setRing(t,e,n="center"){this.setAngle(t),this.setText(e),this.setDirection(n)}setToursPosition(t,e,n){this.torus.position.set(t,e,n)}setTopArrowVisible(t){this.showTopArrow=t}setEnabled(t){this.enabled=t}play(){this.isStop=!1}stop(){this.isStop=!0}resize(t,e){this.viewWidth===t&&this.viewHeight===e||(this.viewWidth=t,this.viewHeight=e)}update(){const t=new ve(this);return t.needUpdate=this.needUpdate,!this.initialized&&this.torus&&(t.shouldPlaceElement=!0,this.initialized=!0),this.enabled&&this.updateText(-this.angle,this.text),t}dispose(){this.torus.remove(),this.textMeshMap.clear()}},t.Screen=class extends w{constructor(t,e={}){super(),this.eventEnable=!1,this.createRenderer(t,e),this.enabled=!0,this.views=new Set,this.eventOnContainer=!!e.eventOnContainer,this.listeners={mouseDown:this.mouseDown.bind(this),mouseMove:this.mouseMove.bind(this),mouseUp:this.mouseUp.bind(this),mouseWheel:this.mouseWheel.bind(this),touchStart:this.touchStart.bind(this),touchMove:this.touchMove.bind(this),touchEnd:this.touchEnd.bind(this),contextMenu:this.contextMenu.bind(this),dblclick:this.dblclick.bind(this)},this.setEventEnable(!0),L.GetSharedInstance().registerScreen(this)}createRenderer(e,n={}){const{THREE:i}=x.getInstance(),r=this.getRenderParams(e,n);if(this.renderer=i.WebGL1Renderer?new i.WebGL1Renderer(r):new i.WebGLRenderer(r),this.renderer.setPixelRatio(S.GetGlobalDPR()),this.renderer.autoClear=!1,this.container)this.renderer.setSize(this.container.clientWidth,this.container.clientHeight),this.container.appendChild(this.renderer.domElement),this.width=this.container.clientWidth,this.height=this.container.clientHeight,this.canvas=this.renderer.domElement;else{const e=n.width,i=n.height;if(!(S.GetEnv()!==t.Env.Miniapp||e&&i))throw new Error("[Owlly] Cannot initialize View without canvas dimensions in miniapp.");this.renderer.setSize(e,i),this.width=e,this.height=i}}setClearColor(t,e=1){if(!this.renderer)return;const{THREE:n}=x.getInstance();this.renderer.setClearColor(new n.Color(t),e)}getRenderParams(e,n={}){const i={alpha:!0,antialias:!0,precision:"highp",preserveDrawingBuffer:n&&n.preserveDrawingBuffer,logarithmicDepthBuffer:n&&n.logarithmicDepthBuffer},r=n&&n.isCanvas;if(S.GetEnv()===t.Env.Miniapp&&!r)throw new Error("[Owlly] Cannot initialize View without canvas in miniapp.");return r?(this.canvas=e,Object.assign(i,{canvas:this.canvas})):this.container=e,i}setEventOnContainer(t){this.eventOnContainer!==t&&(this.setEventEnable(!1),this.eventOnContainer=t,this.setEventEnable(!0))}setEventEnable(t){this.eventEnable!==t&&(this.eventEnable=t,t?this.registerEvents():this.unregisterEvents())}registerEvents(){const t=this.eventOnContainer?this.container:this.canvas;t.addEventListener("mousedown",this.listeners.mouseDown,!1),t.addEventListener("mousemove",this.listeners.mouseMove,!1),t.addEventListener("mouseup",this.listeners.mouseUp,!1),t.addEventListener("mousewheel",this.listeners.mouseWheel,!1),t.addEventListener("touchstart",this.listeners.touchStart,!1),t.addEventListener("touchmove",this.listeners.touchMove,!1),t.addEventListener("touchend",this.listeners.touchEnd,!1),t.addEventListener("contextmenu",this.listeners.contextMenu,!1),t.addEventListener("dblclick",this.listeners.dblclick,!1)}unregisterEvents(){const t=this.eventOnContainer?this.container:this.canvas;t.removeEventListener("mousedown",this.listeners.mouseDown,!1),t.removeEventListener("mousemove",this.listeners.mouseMove,!1),t.removeEventListener("mouseup",this.listeners.mouseUp,!1),t.removeEventListener("mousewheel",this.listeners.mouseWheel,!1),t.removeEventListener("touchstart",this.listeners.touchStart,!1),t.removeEventListener("touchmove",this.listeners.touchMove,!1),t.removeEventListener("touchend",this.listeners.touchEnd,!1),t.removeEventListener("contextmenu",this.listeners.contextMenu,!1),t.removeEventListener("dblclick",this.listeners.dblclick,!1)}mouseDown(t){this.emit(_.MOUSE_DOWN,t)}mouseMove(t){this.emit(_.MOUSE_MOVE,t)}mouseUp(t){this.emit(_.MOUSE_UP,t)}mouseWheel(t){this.emit(_.MOUSE_WHEEL,t)}touchStart(t){this.emit(_.TOUCH_START,t)}touchMove(t){this.emit(_.TOUCH_MOVE,t)}touchEnd(t){this.emit(_.TOUCH_END,t)}contextMenu(t){this.emit(_.CONTEXT_MENU,t)}dblclick(t){this.emit(_.DBLCLICK,t)}dispose(){this.unregisterEvents(),this.views.forEach(t=>{t.dispose()}),this.views.clear(),this.container&&this.container.removeChild(this.renderer.domElement),this.renderer.dispose(),L.GetSharedInstance().unregisterScreen(this),this.container=null,this.canvas=null,this.renderer.domElement=null,this.renderer.state=null,this.renderer=null}resize(t,e){let n,i;if(this.container)n=t||this.container.clientWidth,i=e||this.container.clientHeight;else{if(!t||!e)throw new Error("[Owlly] Width and Height must be passed in when using canvas mode");n=t,i=e}this.renderer.setSize(n,i),this.views.forEach(t=>{t.resize(n,i)}),this.width=n,this.height=i}addView(t){this.views.add(t)}removeView(t){this.views.delete(t)}update(){return!!this.enabled&&Array.from(this.views).reduce((t,e)=>e.update()||t,!1)}renderScreen(){if(!this.enabled)return;this.renderer.clear();const t=Array.from(this.views);t.sort((t,e)=>t.renderOrder-e.renderOrder>0?1:-1),t.forEach(t=>{t.setRendererPort(),t.renderView(),t.clearRendererPort()})}setEnabled(t){this.enabled=t}},t.SetExternal=function(t,e={}){x.getInstance().setThreeInstance(t),e&&e.konva&&x.getInstance().setKonvaInstance(e.konva)},t.Shape=class{constructor(t,e=!0){this.data={id:D.create().toString(),x:0,y:0,radius:0,zIndex:0,centroid:[0,0],height:1,shapeType:"point",path:"",hollows:"",fill:"#ffffff",stroke:"#444444",strokeWidth:1,opacity:1,fillOpacity:1,strokeOpacity:.2,scale:[0,0,0],rotation:[0,0,0,1],tag:"",parentName:""},t&&this.updateData(t,e)}updateData(t,e=!1){if(Object.assign(this.data,t),this.steps=ge.GenerateStepsFromPath(this.data.path),"shape"===this.data.shapeType&&(this.hollows=ge.ParseHollows(this.data.hollows)),this.steps.length<=2||!e)return;const n=ge.PolygonOfShape(this);n&&n.length>2&&(this.data.centroid=me.CentroidForPOI(n))}updatePathFromSelfSteps(){"point"!==this.data.shapeType&&(this.data.path=this.steps.map(t=>`${t.command}${t.coords.join(",")}`).join(""))}getData(){return this.data}getHollows(){return this.hollows}getSteps(){return this.steps}getShapeType(){return this.data.shapeType}},t.ShapeGroup=Jp,t.ShapeUtils=ge,t.Stage=class{constructor(){const{THREE:t}=x.getInstance();this.scene=new t.Scene,this.elements=new Set,this.lights=new t.Group,this.initLights(),this.scene.add(this.lights),this.axesHelper=new t.AxesHelper(10),this.axesHelper.visible=!1,this.scene.add(this.axesHelper),this.disposed=!1,this.stageListeners={onDisposeElement:t=>{Array.isArray(t)?t.forEach(t=>{this.stageListeners.onDisposeElement(t)}):this.disposeElement(t)},onElementLoaded:t=>{b.emit(M.ELEMENT_LOADED,t)}},this.registerEvents(),L.GetSharedInstance().registerStage(this)}registerEvents(){b.on(_.DISPOSE_ELEMENT,this.stageListeners.onDisposeElement),b.on(_.ELEMENT_LOADED,this.stageListeners.onElementLoaded)}initLights(){const{THREE:t}=x.getInstance(),e=new t.HemisphereLight(16777215,16777215,.75);e.position.set(0,50,0),this.lights.add(e);const n=new t.DirectionalLight(16777215,.23);n.color.setHSL(.1,1,.95),n.position.set(-.5,1,.75),n.position.multiplyScalar(50),this.lights.add(n),this.lights.add(n.target),n.target.updateMatrixWorld();const i=new t.DirectionalLight(16777215,.23);i.color.setHSL(.1,1,.95),i.position.set(.5,-1,.75),i.position.multiplyScalar(50),this.lights.add(i),this.lights.add(i.target),i.target.updateMatrixWorld()}tick(){return this.update()}update(){if(this.disposed)return!1;return Array.from(this.elements).reduce((t,e)=>this.handleElementUpdate(e.update())||t,!1)}handleElementUpdate(t){return t.shouldPlaceElement&&this.scene.add(t.element),t.needUpdate}bindView(t){t.bindStage(this)}disposeView(t){t.dispose()}bindController(t){t.initWithScene&&t.initWithScene(this.scene)}async disposeController(t){}bindElement(t){this.elements.add(t)}disposeElement(t){this.unbindElement(t),t&&t.dispose()}unbindElement(t){this.elements.has(t)&&(this.scene.remove(t),this.elements.delete(t))}setStatsEnabled(t){L.GetSharedInstance().setStatsEnabled(t)}setAxesEnabled(t){this.axesHelper.visible=t}render(){throw new Error("[Owlly] This function is no longer being used. Use forceRender() exported from Owlly directly instead.")}dispose(){Array.from(this.elements).forEach(t=>{this.elements.delete(t),t.dispose()}),b.off(_.DISPOSE_ELEMENT,this.stageListeners.onDisposeElement),b.off(_.ELEMENT_LOADED,this.stageListeners.onElementLoaded),this.disposed=!0,L.GetSharedInstance().unregisterStage(this)}resizeElements(t,e){this.elements.forEach(n=>{n.resize&&n.resize(t,e)})}renderElements(){this.elements.forEach(t=>{t.render&&t.render()})}forceResize(){throw new Error("[Owlly] This function is no longer being used. Use Screen.resize() instead.")}setBackgroundColor(t){const{THREE:e}=x.getInstance();this.scene.background=new e.Color(t)}setFrameTickFunction(t){L.GetSharedInstance().setRequestAnimationFrameFunction(t)}toggleTickSelfManagement(t){L.GetSharedInstance().toggleTickSelfManagement(t)}},t.TEXT_MAX=16,t.TEXT_PIXEL=cs,t.TEXT_SEGMENT=4,t.TWEEN=y,t.TileTextureInfo=class{constructor(t,e,n,i,r,s,o){this.offLineLevel=-1,this.pfid=t,this.textureIndex=e,this.level=n,this.index=i,this.isInCamera=!1,this.rootUrl=r||"",this.offLineLevel=null==s?-1:s,this.offLineRootUrl=o||""}get id(){return ds(this.pfid,this.level,this.index)}get originVertices(){let t=this._originVertices;if(!t){const e=10*this.pfid%10-1,n=ps[e],{revers:i,flipX:r,flipY:s}=n;t=this._originVertices=fs(this.level,this.index,i,r,s)}return t}inCamera(t,e){const{THREE:n}=x.getInstance(),i=this.originVertices,r=new n.Vector3(0,0,0);r.applyMatrix4(t),r.project(e),this.centerDis=r.length();for(let n=0;n<i.length;n++){const r=i[n].clone();if(r.applyMatrix4(t),r.project(e),r.x>-1&&r.x<1&&r.y>-1&&r.y<1&&r.z>-1&&r.z<1)return!0}return!1}get targetTid(){return Math.floor(this.pfid)}},t.TileUtil=ms,t.USE_CANVAS=!1,t.USE_TEXTURE_BLACK=!1,t.VertexShader="\n attribute vec3 uvi;\n varying vec3 vUv;\n uniform bool flipX;\n uniform bool flipY;\n\n void main(){\n vUv = uvi;\n bool useCanvas = false;\n if(flipX){\n vUv.x = 1.0-vUv.x;\n }\n if(flipY){\n vUv.y = 1.0-vUv.y;\n }\n if(useCanvas){\n vUv.y = 1.0-vUv.y;\n }\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",t.View=R,t.getImgTextPixel=hs,t.getTextPixel=ls,t.setTileConfig=function(t){as={...as,...t}},t.updateTick=function(){const t=L.GetSharedInstance();A||(T=0,A=Date.now()),P=Date.now(),T+=P-A,t.tick(T),A=P},t}({},THREE,Konva);
53
+
54
+ /* eslint-disable */
55
+ Owlly.SetExternal(THREE, optionals);
56
+ THREE.GLTFLoader = Owlly.GLTFLoader;
57
+ THREE.LineGeometry = Owlly.LineGeometry;
58
+ THREE.LineSegments2 = Owlly.LineSegments2;
59
+ THREE.LineMaterial = Owlly.LineMaterial;
60
+ return Owlly;
61
+ };
62
+
63
+ exports.default = getOwlly;