@aibee/owlly 1.0.25 → 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,69 @@
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),v=d.remove.bind(d),y=d.update.bind(d),x={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:v,update:y};class b{setKonvaInstance(t){this.Konva=t}setThreeInstance(t){this.THREE=t}static getInstance(){return this.instance||(this.instance=new b),this.instance}}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)})}off(t,e){const n=this.eventMap.get(t);n&&n.delete(e)}static on(t,e){w.hub||(w.hub=new w),w.hub.on(t,e)}static emit(t,...e){w.hub||(w.hub=new w),w.hub.emit(t,...e)}static off(t,e){w.hub||(w.hub=new w),w.hub.off(t,e)}static remove(t,e){console.warn("EventHub.remove() will be removed in future releases. Use EventHub.off() instead."),w.off(t,e)}}class M{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)}),w.emit(t,...e)}off(t,e){const n=this.eventMap.get(t);n&&n.delete(e)}}class _{}_.ELEMENT_SELECTED="element-selected",_.ELEMENT_POSITION_UPDATED="element-position-updated",_.ELEMENT_POSE_UPDATED="element-pose-updated",_.CAMERA_CHANGED="camera-changed",_.CAMERA_ZOOM="camera-zoom",_.PANORAMA_CAMERA_CHANGED="panorama-camera-changed",_.ORBIT_CAMERA_CHANGED="orbit-camera-changed",_.PANORAMA_PRESENTED="panorama-presented",_.PANORAMA_SELECTED="panorama-selected",_.PANORAMA_HOVER="panorama-hover",_.ELEMENT_LOADED="element-loaded",_.ELEMENT_LOADED_ERROR="o/element-loaded-error",_.CLICK_PANORAMA="click-panorama",_.MOVE_TO_PANORAMA="move-to-panorama",_.WILL_MOVE_TO_PANORAMA="will-move-to-panorama",_.PATH_MOVEMENT_START="path-movement-start",_.PATH_MOVEMENT_COMPLETED="path-movement-completed",_.WILL_LOAD_PANORAMA="will-load-panorama",_.DID_LOAD_PANORAMA="did-load-panorama",_.TRANSFORM_ACTIVATED="transform-activated",_.TRANSFORM_DEACTIVATED="transform-deactivated",_.FPS_UPDATED="fps-updated",_.GET_PLANE_INTERSECT="get-plane-intersect",_.POI_CLICKED="poi-clicked",_.POI_DOWN="poi-down",_.POI_UP="poi-up",_.CANVAS_VERTEX_CLICKED="canvas-vertex-clicked",_.CANVAS_VERTEX_DOWN="canvas-vertex-down",_.CANVAS_VERTEX_UP="canvas-vertex-up",_.LABEL_ICONS_POSITION_UPDATED="label-icons-position-updated",_.LABEL_DOWN="label-down",_.TICK="tick",_.VIEW_RENDERED="view-rendered";class E{}E.ELEMENT_SELECTED="o/element-selected",E.RENDERING_VIEW_CHANGED="o/rendering-view-changed",E.DISPOSE_ELEMENT="o/dispose-element",E.ELEMENT_LOADED="o/element-loaded",E.ELEMENT_POSITION_UPDATED="o/element-position-updated",E.MOUSE_DOWN="o/mouse-down",E.MOUSE_UP="o/mouse-up",E.MOUSE_MOVE="o/mouse-move",E.MOUSE_WHEEL="o/mouse-wheel",E.TOUCH_START="o/touch-start",E.TOUCH_MOVE="o/touch-move",E.TOUCH_END="o/touch-end",E.CONTEXT_MENU="o/context-menu",E.DBLCLICK="o/dblclick";class T{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}}class S{constructor(t){const{Konva:e}=b.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 S(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}=b.getInstance(),e=new t.Layer;return this.stage.add(e),e}openInteraction(){this.konvaContainer.style.pointerEvents="auto"}closeInteraction(){this.konvaContainer.style.pointerEvents="none"}}(i=t.Env||(t.Env={}))[i.Web=0]="Web",i[i.Miniapp=1]="Miniapp";class A{static SetEnv(t){A.ENV=t}static GetEnv(){if(void 0===A.ENV)try{wx,A.ENV=t.Env.Web}catch(t){}finally{void 0===A.ENV&&(A.ENV=t.Env.Web)}return A.ENV}static SetGlobalDPR(t){A.DPR=t}static GetGlobalDPR(){if(!A.DPR){let e;if(A.GetEnv()===t.Env.Miniapp){e=wx.getSystemInfoSync().pixelRatio}else e=window.devicePixelRatio;A.DPR=e}return A.DPR}}let P,C,L;class R{constructor(){this.stages=new Set,this.screens=new Set,this.controllers=new Set,this.timeProfiler=new T,this.selfManageTick=!0,this.listeners={windowResizeListener:()=>{this.onWindowResize()},windowUnloadListener:()=>{this.beforeWindowUnload()},onTick:this.tick.bind(this)},this.registerEvents(),A.GetEnv()===t.Env.Web&&requestAnimationFrame&&this.setRequestAnimationFrameFunction(requestAnimationFrame)}static GetSharedInstance(){return this.SHARED_INSTANCE||(this.SHARED_INSTANCE=new R),this.SHARED_INSTANCE}tick(t){this.timeProfiler.tick(t),w.emit(_.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()}),x.update(),this.selfManageTick&&R.RequestAnimationFrame(this.listeners.onTick)}registerEvents(){A.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,S.initialized&&S.resize()}beforeWindowUnload(){Array.from(this.stages).forEach(t=>{t.dispose()}),window&&window.removeEventListener("resize",this.listeners.windowResizeListener),S.initialized&&S.dispose()}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){A.GetEnv()===t.Env.Web&&(this.statsEnabled=e)}setRequestAnimationFrameFunction(e){R.RequestAnimationFrame=e.bind(A.GetEnv()===t.Env.Web?window.IS_DELEGATE?window.delegateWindow:window:this),this.selfManageTick&&R.RequestAnimationFrame(this.listeners.onTick)}toggleTickSelfManagement(t){this.selfManageTick!==t&&(this.selfManageTick=t,this.selfManageTick&&R.RequestAnimationFrame(this.listeners.onTick))}renderNextFrame(){this.forceRender=!0}}class I extends M{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}=b.getInstance();this.rendererOffsetDefault=new n.Vector4(0,0,0,0),t&&this.bindScreen(t)}mouseDown(t){this.isInView(t.offsetX,t.offsetY)&&this.emit(E.MOUSE_DOWN,t)}mouseMove(t){this.emit(E.MOUSE_MOVE,t)}mouseUp(t){this.emit(E.MOUSE_UP,t)}mouseWheel(t){this.isInView(t.offsetX,t.offsetY)&&this.emit(E.MOUSE_WHEEL,t)}touchStart(t){this.isTouchInView(t)&&this.emit(E.TOUCH_START,t)}touchMove(t){this.emit(E.TOUCH_MOVE,t)}touchEnd(t){this.emit(E.TOUCH_END,t)}contextMenu(t){this.isInView(t.offsetX,t.offsetY)&&this.emit(E.CONTEXT_MENU,t)}dblclick(t){this.emit(E.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}=b.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(E.MOUSE_DOWN,this.listeners.mouseDown),this.parent.on(E.MOUSE_MOVE,this.listeners.mouseMove),this.parent.on(E.MOUSE_UP,this.listeners.mouseUp),this.parent.on(E.MOUSE_WHEEL,this.listeners.mouseWheel),this.parent.on(E.TOUCH_START,this.listeners.touchStart),this.parent.on(E.TOUCH_MOVE,this.listeners.touchMove),this.parent.on(E.TOUCH_END,this.listeners.touchEnd),this.parent.on(E.CONTEXT_MENU,this.listeners.contextMenu),this.parent.on(E.DBLCLICK,this.listeners.dblclick))}unregisterScreenEvents(){this.parent&&(this.parent.off(E.MOUSE_DOWN,this.listeners.mouseDown),this.parent.off(E.MOUSE_MOVE,this.listeners.mouseMove),this.parent.off(E.MOUSE_UP,this.listeners.mouseUp),this.parent.off(E.MOUSE_WHEEL,this.listeners.mouseWheel),this.parent.off(E.TOUCH_START,this.listeners.touchStart),this.parent.off(E.TOUCH_MOVE,this.listeners.touchMove),this.parent.off(E.TOUCH_END,this.listeners.touchEnd),this.parent.off(E.CONTEXT_MENU,this.listeners.contextMenu),this.parent.off(E.DBLCLICK,this.listeners.dblclick))}dispose(){this.overlays.forEach(t=>{t.dispose()}),this.overlays=[],this.container&&S.disposeStage(this.container),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}=b.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 gm&&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 D extends M{}
6
+ /*!
7
+ * isobject <https://github.com/jonschlinkert/isobject>
8
+ *
9
+ * Copyright (c) 2014-2017, Jon Schlinkert.
10
+ * Released under the MIT License.
11
+ */var O=function(t){return null!=t&&"object"==typeof t&&!1===Array.isArray(t)};function F(t){return!0===O(t)&&"[object Object]"===Object.prototype.toString.call(t)}var B={}.toString,N=Array.isArray||function(t){return"[object Array]"==B.call(t)},z=function(t,e){if(null==t)return!1;if("boolean"==typeof t)return!0;if("number"==typeof t)return 0!==t||!0!==e;if(void 0!==t.length)return 0!==t.length;for(var n in t)if(t.hasOwnProperty(n))return!0;return!1};function U(t){return t?Array.isArray(t)?t.join("."):t:""}var k=function(t,e,n){return null!=(i=t)&&"object"==typeof i&&!1===N(i)?z(function(t,e,n,i,r){if(null===(s=t)||"object"!=typeof s&&"function"!=typeof s||!e)return t;var s;if(e=U(e),n&&(e+="."+U(n)),i&&(e+="."+U(i)),r&&(e+="."+U(r)),e in t)return t[e];for(var o=e.split("."),a=o.length,l=-1;t&&++l<a;){for(var h=o[l];"\\"===h[h.length-1];)h=h.slice(0,-1)+"."+o[++l];t=t[h]}return t}(t,e),n):z(t,e);var i},V=function(t,e){if(!O(t))throw new TypeError("expected an object.");if(t.hasOwnProperty(e))return delete t[e],!0;if(k(t,e)){for(var n=e.split("."),i=n.pop();n.length&&"\\"===n[n.length-1].slice(-1);)i=n.pop().slice(0,-1)+"."+i;for(;n.length;)t=t[e=n.shift()];return delete t[i]}return!0},H=function t(e,n){if(void 0===e)return{};if(Array.isArray(e)){for(var i=0;i<e.length;i++)e[i]=t(e[i],n);return e}if(!1===F(r=e)||"function"!=typeof(s=r.constructor)||!1===F(o=s.prototype)||!1===o.hasOwnProperty("isPrototypeOf"))return e;var r,s,o;if("string"==typeof n&&(n=[n]),!Array.isArray(n))return e;for(var a=0;a<n.length;a++)V(e,n[a]);for(var l in e)e.hasOwnProperty(l)&&(e[l]=t(e[l],n));return e},G=function(t){return null!=t&&(W(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&W(t.slice(0,0))}(t)||!!t._isBuffer)};function W(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var j=Object.prototype.toString,X=function(t){if(void 0===t)return"undefined";if(null===t)return"null";if(!0===t||!1===t||t instanceof Boolean)return"boolean";if("string"==typeof t||t instanceof String)return"string";if("number"==typeof t||t instanceof Number)return"number";if("function"==typeof t||t instanceof Function)return"function";if(void 0!==Array.isArray&&Array.isArray(t))return"array";if(t instanceof RegExp)return"regexp";if(t instanceof Date)return"date";var e=j.call(t);return"[object RegExp]"===e?"regexp":"[object Date]"===e?"date":"[object Arguments]"===e?"arguments":"[object Error]"===e?"error":G(t)?"buffer":"[object Set]"===e?"set":"[object WeakSet]"===e?"weakset":"[object Map]"===e?"map":"[object WeakMap]"===e?"weakmap":"[object Symbol]"===e?"symbol":"[object Int8Array]"===e?"int8array":"[object Uint8Array]"===e?"uint8array":"[object Uint8ClampedArray]"===e?"uint8clampedarray":"[object Int16Array]"===e?"int16array":"[object Uint16Array]"===e?"uint16array":"[object Int32Array]"===e?"int32array":"[object Uint32Array]"===e?"uint32array":"[object Float32Array]"===e?"float32array":"[object Float64Array]"===e?"float64array":"object"},q="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Y(t,e){return t(e={exports:{}},e.exports),e.exports}var Z=Y((function(t){!function(){function e(t,e){if("function"!=typeof e)return t;var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[e(i,t[i])||i]=t[i]);return n}t.exports?t.exports=e:window.rename=e}()})),J=Y((function(t){var e=Object.prototype.hasOwnProperty,n="~";function i(){}function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function s(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),s.prototype.eventNames=function(){var t,i,r=[];if(0===this._eventsCount)return r;for(i in t=this._events)e.call(t,i)&&r.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},s.prototype.listeners=function(t,e){var i=n?n+t:t,r=this._events[i];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var s=0,o=r.length,a=new Array(o);s<o;s++)a[s]=r[s].fn;return a},s.prototype.emit=function(t,e,i,r,s,o){var a=n?n+t:t;if(!this._events[a])return!1;var l,h,c=this._events[a],u=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,i),!0;case 4:return c.fn.call(c.context,e,i,r),!0;case 5:return c.fn.call(c.context,e,i,r,s),!0;case 6:return c.fn.call(c.context,e,i,r,s,o),!0}for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];c.fn.apply(c.context,l)}else{var d,p=c.length;for(h=0;h<p;h++)switch(c[h].once&&this.removeListener(t,c[h].fn,void 0,!0),u){case 1:c[h].fn.call(c[h].context);break;case 2:c[h].fn.call(c[h].context,e);break;case 3:c[h].fn.call(c[h].context,e,i);break;case 4:c[h].fn.call(c[h].context,e,i,r);break;default:if(!l)for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];c[h].fn.apply(c[h].context,l)}}return!0},s.prototype.on=function(t,e,i){var s=new r(e,i||this),o=n?n+t:t;return this._events[o]?this._events[o].fn?this._events[o]=[this._events[o],s]:this._events[o].push(s):(this._events[o]=s,this._eventsCount++),this},s.prototype.once=function(t,e,i){var s=new r(e,i||this,!0),o=n?n+t:t;return this._events[o]?this._events[o].fn?this._events[o]=[this._events[o],s]:this._events[o].push(s):(this._events[o]=s,this._eventsCount++),this},s.prototype.removeListener=function(t,e,r,s){var o=n?n+t:t;if(!this._events[o])return this;if(!e)return 0==--this._eventsCount?this._events=new i:delete this._events[o],this;var a=this._events[o];if(a.fn)a.fn!==e||s&&!a.once||r&&a.context!==r||(0==--this._eventsCount?this._events=new i:delete this._events[o]);else{for(var l=0,h=[],c=a.length;l<c;l++)(a[l].fn!==e||s&&!a[l].once||r&&a[l].context!==r)&&h.push(a[l]);h.length?this._events[o]=1===h.length?h[0]:h:0==--this._eventsCount?this._events=new i:delete this._events[o]}return this},s.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&(0==--this._eventsCount?this._events=new i:delete this._events[e])):(this._events=new i,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prototype.setMaxListeners=function(){return this},s.prefixed=n,s.EventEmitter=s,t.exports=s}));function $(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Q=function(){},K={data:"state-data",cdata:"state-cdata",tagBegin:"state-tag-begin",tagName:"state-tag-name",tagEnd:"state-tag-end",attributeNameStart:"state-attribute-name-start",attributeName:"state-attribute-name",attributeNameEnd:"state-attribute-name-end",attributeValueBegin:"state-attribute-value-begin",attributeValue:"state-attribute-value"},tt={lt:"action-lt",gt:"action-gt",space:"action-space",equal:"action-equal",quote:"action-quote",slash:"action-slash",char:"action-char",error:"action-error"},et={text:"text",openTag:"open-tag",closeTag:"close-tag",attributeName:"attribute-name",attributeValue:"attribute-value"},nt={" ":tt.space,"\t":tt.space,"\n":tt.space,"\r":tt.space,"<":tt.lt,">":tt.gt,'"':tt.quote,"'":tt.quote,"=":tt.equal,"/":tt.slash},it=function(t){var e,n,i,r,s,o,a,l,h,c;t=Object.assign({debug:!1},t);var u=new J,d=K.data,p="",f="",m="",g="",v="",y="",x=function(e,n){if("?"!==f[0]&&"!"!==f[0]){var i={type:e,value:n};t.debug&&console.log("emit:",i),u.emit("data",i)}};u.stateMachine=($(c={},K.data,($(e={},tt.lt,(function(){p.trim()&&x(et.text,p),f="",v=!1,d=K.tagBegin})),$(e,tt.char,(function(t){p+=t})),e)),$(c,K.cdata,$({},tt.char,(function(t){"]]>"===(p+=t).substr(-3)&&(x(et.text,p.slice(0,-3)),p="",d=K.data)}))),$(c,K.tagBegin,($(n={},tt.space,Q),$(n,tt.char,(function(t){f=t,d=K.tagName})),$(n,tt.slash,(function(){f="",v=!0})),n)),$(c,K.tagName,($(i={},tt.space,(function(){v?d=K.tagEnd:(d=K.attributeNameStart,x(et.openTag,f))})),$(i,tt.gt,(function(){x(v?et.closeTag:et.openTag,f),p="",d=K.data})),$(i,tt.slash,(function(){d=K.tagEnd,x(et.openTag,f)})),$(i,tt.char,(function(t){"![CDATA["===(f+=t)&&(d=K.cdata,p="",f="")})),i)),$(c,K.tagEnd,($(r={},tt.gt,(function(){x(et.closeTag,f),p="",d=K.data})),$(r,tt.char,Q),r)),$(c,K.attributeNameStart,($(s={},tt.char,(function(t){m=t,d=K.attributeName})),$(s,tt.gt,(function(){p="",d=K.data})),$(s,tt.space,Q),$(s,tt.slash,(function(){v=!0,d=K.tagEnd})),s)),$(c,K.attributeName,($(o={},tt.space,(function(){d=K.attributeNameEnd})),$(o,tt.equal,(function(){x(et.attributeName,m),d=K.attributeValueBegin})),$(o,tt.gt,(function(){g="",x(et.attributeName,m),x(et.attributeValue,g),p="",d=K.data})),$(o,tt.slash,(function(){v=!0,g="",x(et.attributeName,m),x(et.attributeValue,g),d=K.tagEnd})),$(o,tt.char,(function(t){m+=t})),o)),$(c,K.attributeNameEnd,($(a={},tt.space,Q),$(a,tt.equal,(function(){x(et.attributeName,m),d=K.attributeValueBegin})),$(a,tt.gt,(function(){g="",x(et.attributeName,m),x(et.attributeValue,g),p="",d=K.data})),$(a,tt.char,(function(t){g="",x(et.attributeName,m),x(et.attributeValue,g),m=t,d=K.attributeName})),a)),$(c,K.attributeValueBegin,($(l={},tt.space,Q),$(l,tt.quote,(function(t){y=t,g="",d=K.attributeValue})),$(l,tt.gt,(function(){x(et.attributeValue,g=""),p="",d=K.data})),$(l,tt.char,(function(t){y="",g=t,d=K.attributeValue})),l)),$(c,K.attributeValue,($(h={},tt.space,(function(t){y?g+=t:(x(et.attributeValue,g),d=K.attributeNameStart)})),$(h,tt.quote,(function(t){y===t?(x(et.attributeValue,g),d=K.attributeNameStart):g+=t})),$(h,tt.gt,(function(t){y?g+=t:(x(et.attributeValue,g),p="",d=K.data)})),$(h,tt.slash,(function(t){y?g+=t:(x(et.attributeValue,g),v=!0,d=K.tagEnd)})),$(h,tt.char,(function(t){g+=t})),h)),c);var b=function(e){t.debug&&console.log(d,e);var n=u.stateMachine[d];(n[function(t){return nt[t]||tt.char}(e)]||n[tt.error]||n[tt.char])(e)};return u.write=function(t){for(var e=t.length,n=0;n<e;n++)b(t[n])},u},rt=et,st={element:"element",text:"text"},ot=function(t){return Object.assign({name:"",type:st.element,value:"",parent:null,attributes:{},children:[]},t)},at=function(t){t=Object.assign({stream:!1,parentNodes:!0,doneEvent:"done",tagPrefix:"tag:",emitTopLevelOnly:!1,debug:!1},t);var e=void 0,n=void 0,i=void 0,r=void 0,s=new J,o=function(o){switch(o.type){case rt.openTag:if(null===i)(i=n).name=o.value;else{var a=ot({name:o.value,parent:i});i.children.push(a),i=a}break;case rt.closeTag:var l=i.parent;if(t.parentNodes||(i.parent=null),i.name!==o.value)break;t.stream&&l===n&&(n.children=[],i.parent=null),t.emitTopLevelOnly&&l!==n||(s.emit(t.tagPrefix+i.name,i),s.emit("tag",i.name,i)),i===n&&(e.removeAllListeners("data"),s.emit(t.doneEvent,i),n=null),i=l;break;case rt.text:i&&i.children.push(ot({type:st.text,value:o.value,parent:t.parentNodes?i:null}));break;case rt.attributeName:r=o.value,i.attributes[r]="";break;case rt.attributeValue:i.attributes[r]=o.value}};return s.reset=function(){(e=it({debug:t.debug})).on("data",o),n=ot(),i=null,r="",s.parse=e.write},s.reset(),s},lt=function(t,e){e=Object.assign({},e,{stream:!1,tagPrefix:":"});var n=at(e),i=void 0;return n.on("done",(function(t){i=t})),n.parse(t),i},ht=lt;function ct(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ut(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function dt(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ut(Object(n),!0).forEach((function(e){ct(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ut(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var pt=function(t){var e=ht(t,{parentNodes:!1}),n="root"===e.name&&e.children.length>1;if(n?e.children.reduce((function(t,e){var n=e.name;return!!t||"svg"===n}),!1):"svg"===e.children[0].name)return n?e:e.children[0];throw Error("nothing to parse")},ft=function(t){return t.replace(/<[\/]{0,1}(\!?DOCTYPE|\??xml)[^><]*>/gi,"")},mt=function(t){return"<root>".concat(t,"</root>")},gt=function(t){return H(t,["parent"])},vt=function(t){return function t(e,n){var i=X(e);if("object"!==i&&"array"!==i)throw new Error("expected an object");var r=[];for(var s in"object"===i&&(e=Z(e,n),r={}),e)if(e.hasOwnProperty(s)){var o=e[s];"object"===X(o)||"array"===X(o)?r[s]=t(o,n):r[s]=o}return r}(t,(function(t){return xt(t)?t:yt(t)}))},yt=function(t){return t.replace(/[-|:]([a-z])/gi,(function(t,e){return e.toUpperCase()}))},xt=function(t){return/^(data|aria)(-\w+)/.test(t)},bt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.transformNode,i=void 0===n?function(t){return t}:n,r=e.camelcase,s=void 0!==r&&r,o=function(t){var e=ft(t);return mt(e)},a=function(t){return"root"===t.name?t.children:t},l=function(t){var e;return e=function t(e){var n=e.children;return"root"===e.name?n.map(t):dt(dt({},i(e)),n&&n.length>0?{children:n.map(t)}:{})}(e=gt(t)),s&&(e=vt(e)),e};return a(l(pt(o(t))))};function wt(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new Promise((function(t,n){try{t(bt.apply(void 0,e))}catch(t){n(t)}}))}var Mt={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]},_t=Y((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))}}})),Et=Y((function(t){var e=Object.hasOwnProperty,n=Object.create(null);for(var i in Mt)e.call(Mt,i)&&(n[Mt[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(Mt,n[1])?((o=Mt[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=_t(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=_t(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=_t(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=_t(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=_t(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)]}})),Tt=(Et.to,Et.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]}),St=Y((function(t){var e={};for(var n in Tt)Tt.hasOwnProperty(n)&&(e[Tt[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 Tt)if(Tt.hasOwnProperty(s)){var o=a(t,Tt[s]);o<r&&(r=o,i=s)}return i},i.keyword.rgb=function(t){return Tt[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]}}));St.rgb,St.hsl,St.hsv,St.hwb,St.cmyk,St.xyz,St.lab,St.lch,St.hex,St.keyword,St.ansi16,St.ansi256,St.hcg,St.apple,St.gray;function At(t){var e=function(){for(var t={},e=Object.keys(St),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(St[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 Pt(t,e){return function(n){return e(t(n))}}function Ct(t,e){for(var n=[e[t].parent,t],i=St[e[t].parent][t],r=e[t].parent;e[r].parent;)n.unshift(e[r].parent),i=Pt(St[e[r].parent][r],i),r=e[r].parent;return i.conversion=n,i}var Lt={};Object.keys(St).forEach((function(t){Lt[t]={},Object.defineProperty(Lt[t],"channels",{value:St[t].channels}),Object.defineProperty(Lt[t],"labels",{value:St[t].labels});var e=function(t){for(var e=At(t),n={},i=Object.keys(e),r=i.length,s=0;s<r;s++){var o=i[s];null!==e[o].parent&&(n[o]=Ct(o,e))}return n}(t);Object.keys(e).forEach((function(n){var i=e[n];Lt[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),Lt[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 Rt=Lt,It=[].slice,Dt=["keyword","gray","hex"],Ot={};Object.keys(Rt).forEach((function(t){Ot[It.call(Rt[t].labels).sort().join("")]=t}));var Ft={};function Bt(t,e){if(!(this instanceof Bt))return new Bt(t,e);if(e&&e in Dt&&(e=null),e&&!(e in Rt))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 Bt)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var r=Et.get(t);if(null===r)throw new Error("Unable to parse color from string: "+t);this.model=r.model,i=Rt[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=Rt[this.model].channels;var s=It.call(t,0,i);this.color=kt(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 Ot))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=Ot[a];var l=Rt[this.model].labels,h=[];for(n=0;n<l.length;n++)h.push(t[l[n]]);this.color=kt(h)}if(Ft[this.model])for(i=Rt[this.model].channels,n=0;n<i;n++){var c=Ft[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 Nt(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(Ft[t]||(Ft[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 zt(t){return function(e){return Math.max(0,Math.min(t,e))}}function Ut(t){return Array.isArray(t)?t:[t]}function kt(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}Bt.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in Et.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return Et.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 Et.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=Rt[this.model].channels,n=Rt[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 Bt(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 Bt(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:Nt("rgb",0,zt(255)),green:Nt("rgb",1,zt(255)),blue:Nt("rgb",2,zt(255)),hue:Nt(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:Nt("hsl",1,zt(100)),lightness:Nt("hsl",2,zt(100)),saturationv:Nt("hsv",1,zt(100)),value:Nt("hsv",2,zt(100)),chroma:Nt("hcg",1,zt(100)),gray:Nt("hcg",2,zt(100)),white:Nt("hwb",1,zt(100)),wblack:Nt("hwb",2,zt(100)),cyan:Nt("cmyk",0,zt(100)),magenta:Nt("cmyk",1,zt(100)),yellow:Nt("cmyk",2,zt(100)),black:Nt("cmyk",3,zt(100)),x:Nt("xyz",0,zt(100)),y:Nt("xyz",1,zt(100)),z:Nt("xyz",2,zt(100)),l:Nt("lab",0,zt(100)),a:Nt("lab",1),b:Nt("lab",2),keyword:function(t){return arguments.length?new Bt(t):Rt[this.model].keyword(this.color)},hex:function(t){return arguments.length?new Bt(t):Et.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 Bt.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 Bt.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(Rt).forEach((function(t){if(-1===Dt.indexOf(t)){var e=Rt[t].channels;Bt.prototype[t]=function(){if(this.model===t)return new Bt(this);if(arguments.length)return new Bt(arguments,t);var n="number"==typeof arguments[e]?e:this.valpha;return new Bt(Ut(Rt[this.model][t].raw(this.color)).concat(n),t)},Bt[t]=function(n){return"number"==typeof n&&(n=kt(It.call(arguments),e)),new Bt(n,t)}}}));var Vt=Bt;class Ht{constructor(t,e=!1){this.element=t,this.needUpdate=e,this.shouldPlaceElement=!1}}class Gt extends e.Object3D{constructor(){super(),this.elementListeners={onElementSelected:this.onElementSelected.bind(this)},this.eventMap=new Map,w.on(E.ELEMENT_SELECTED,this.elementListeners.onElementSelected)}onElementSelected(t){t===this&&w.emit(_.ELEMENT_SELECTED,t)}getUUID(){return this.universalId}setUUID(t){this.universalId=t}dispose(){w.off(E.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)}),w.emit(t,...e)}off(t,e){const n=this.eventMap.get(t);if(!n)throw Error(`Target event '${t}' not found`);n.delete(e)}}var Wt="undefined"!=typeof Float32Array?Float32Array:Array;function jt(){var t=new Wt(3);return Wt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Xt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function qt(t,e,n,i){return t[0]=e,t[1]=n,t[2]=i,t}var Yt=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},Zt=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=jt()}();function Jt(){var t=new Wt(4);return Wt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}!function(){var t=Jt()}();function $t(){var t=new Wt(2);return Wt!=Float32Array&&(t[0]=0,t[1]=0),t}function Qt(t,e){return t[0]=e[0],t[1]=e[1],t}function Kt(t,e,n){return t[0]=e,t[1]=n,t}var te=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t},ee=function(t,e){var n=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(n*n+i*i)},ne=(function(){var t=$t()}(),Y((function(t){!function(e){var n,i,r="hasOwnProperty",s=/[\.\/]/,o=/\s*,\s*/,a=function(t,e){return t-e},l={n:{}},h=function(){for(var t=0,e=this.length;t<e;t++)if(void 0!==this[t])return this[t]},c=function(){for(var t=this.length;--t;)if(void 0!==this[t])return this[t]},u=Object.prototype.toString,d=String,p=Array.isArray||function(t){return t instanceof Array||"[object Array]"==u.call(t)},f=function(t,e){var r,s=i,o=Array.prototype.slice.call(arguments,2),l=f.listeners(t),u=0,d=[],p={},m=[],g=n;m.firstDefined=h,m.lastDefined=c,n=t,i=0;for(var v=0,y=l.length;v<y;v++)"zIndex"in l[v]&&(d.push(l[v].zIndex),l[v].zIndex<0&&(p[l[v].zIndex]=l[v]));for(d.sort(a);d[u]<0;)if(r=p[d[u++]],m.push(r.apply(e,o)),i)return i=s,m;for(v=0;v<y;v++)if("zIndex"in(r=l[v]))if(r.zIndex==d[u]){if(m.push(r.apply(e,o)),i)break;do{if((r=p[d[++u]])&&m.push(r.apply(e,o)),i)break}while(r)}else p[r.zIndex]=r;else if(m.push(r.apply(e,o)),i)break;return i=s,n=g,m};f._events=l,f.listeners=function(t){var e,n,i,r,o,a,h,c,u=p(t)?t:t.split(s),d=l,f=[d],m=[];for(r=0,o=u.length;r<o;r++){for(c=[],a=0,h=f.length;a<h;a++)for(n=[(d=f[a].n)[u[r]],d["*"]],i=2;i--;)(e=n[i])&&(c.push(e),m=m.concat(e.f||[]));f=c}return m},f.separator=function(t){t?(t="["+(t=d(t).replace(/(?=[\.\^\]\[\-])/g,"\\"))+"]",s=new RegExp(t)):s=/[\.\/]/},f.on=function(t,e){if("function"!=typeof e)return function(){};for(var n=p(t)?p(t[0])?t:[t]:d(t).split(o),i=0,r=n.length;i<r;i++)!function(t){for(var n,i=p(t)?t:d(t).split(s),r=l,o=0,a=i.length;o<a;o++)r=(r=r.n).hasOwnProperty(i[o])&&r[i[o]]||(r[i[o]]={n:{}});for(r.f=r.f||[],o=0,a=r.f.length;o<a;o++)if(r.f[o]==e){n=!0;break}!n&&r.f.push(e)}(n[i]);return function(t){+t==+t&&(e.zIndex=+t)}},f.f=function(t){var e=[].slice.call(arguments,1);return function(){f.apply(null,[t,null].concat(e).concat([].slice.call(arguments,0)))}},f.stop=function(){i=1},f.nt=function(t){var e=p(n)?n.join("."):n;return t?new RegExp("(?:\\.|\\/|^)"+t+"(?:\\.|\\/|$)").test(e):e},f.nts=function(){return p(n)?n:n.split(s)},f.off=f.unbind=function(t,e){if(t){var n=p(t)?p(t[0])?t:[t]:d(t).split(o);if(n.length>1)for(var i=0,a=n.length;i<a;i++)f.off(n[i],e);else{n=p(t)?t:d(t).split(s);var h,c,u,m,g,v=[l],y=[];for(i=0,a=n.length;i<a;i++)for(m=0;m<v.length;m+=u.length-2){if(u=[m,1],h=v[m].n,"*"!=n[i])h[n[i]]&&(u.push(h[n[i]]),y.unshift({n:h,name:n[i]}));else for(c in h)h[r](c)&&(u.push(h[c]),y.unshift({n:h,name:c}));v.splice.apply(v,u)}for(i=0,a=v.length;i<a;i++)for(h=v[i];h.n;){if(e){if(h.f){for(m=0,g=h.f.length;m<g;m++)if(h.f[m]==e){h.f.splice(m,1);break}!h.f.length&&delete h.f}for(c in h.n)if(h.n[r](c)&&h.n[c].f){var x=h.n[c].f;for(m=0,g=x.length;m<g;m++)if(x[m]==e){x.splice(m,1);break}!x.length&&delete h.n[c].f}}else for(c in delete h.f,h.n)h.n[r](c)&&h.n[c].f&&delete h.n[c].f;h=h.n}t:for(i=0,a=y.length;i<a;i++){for(c in(h=y[i]).n[h.name].f)continue t;for(c in h.n[h.name].n)continue t;delete h.n[h.name]}}}else f._events=l={n:{}}},f.once=function(t,e){var n=function(){return f.off(t,n),e.apply(this,arguments)};return f.on(t,n)},f.version="0.5.4",f.toString=function(){return"You are running Eve 0.5.4"},e.eve=f,t.exports?t.exports=f:e.eve=f}("undefined"!=typeof window?window:q)}))),ie=Y((function(t,e){var n,i;!function(e){var n,i,r="hasOwnProperty",s=/[\.\/]/,o=/\s*,\s*/,a=function(t,e){return t-e},l={n:{}},h=function(){for(var t=0,e=this.length;t<e;t++)if(void 0!==this[t])return this[t]},c=function(){for(var t=this.length;--t;)if(void 0!==this[t])return this[t]},u=Object.prototype.toString,d=String,p=Array.isArray||function(t){return t instanceof Array||"[object Array]"==u.call(t)},f=function(t,e){var r,s=i,o=Array.prototype.slice.call(arguments,2),l=f.listeners(t),u=0,d=[],p={},m=[],g=n;m.firstDefined=h,m.lastDefined=c,n=t,i=0;for(var v=0,y=l.length;v<y;v++)"zIndex"in l[v]&&(d.push(l[v].zIndex),l[v].zIndex<0&&(p[l[v].zIndex]=l[v]));for(d.sort(a);d[u]<0;)if(r=p[d[u++]],m.push(r.apply(e,o)),i)return i=s,m;for(v=0;v<y;v++)if("zIndex"in(r=l[v]))if(r.zIndex==d[u]){if(m.push(r.apply(e,o)),i)break;do{if((r=p[d[++u]])&&m.push(r.apply(e,o)),i)break}while(r)}else p[r.zIndex]=r;else if(m.push(r.apply(e,o)),i)break;return i=s,n=g,m};f._events=l,f.listeners=function(t){var e,n,i,r,o,a,h,c,u=p(t)?t:t.split(s),d=l,f=[d],m=[];for(r=0,o=u.length;r<o;r++){for(c=[],a=0,h=f.length;a<h;a++)for(n=[(d=f[a].n)[u[r]],d["*"]],i=2;i--;)(e=n[i])&&(c.push(e),m=m.concat(e.f||[]));f=c}return m},f.separator=function(t){t?(t="["+(t=d(t).replace(/(?=[\.\^\]\[\-])/g,"\\"))+"]",s=new RegExp(t)):s=/[\.\/]/},f.on=function(t,e){if("function"!=typeof e)return function(){};for(var n=p(t)?p(t[0])?t:[t]:d(t).split(o),i=0,r=n.length;i<r;i++)!function(t){for(var n,i=p(t)?t:d(t).split(s),r=l,o=0,a=i.length;o<a;o++)r=(r=r.n).hasOwnProperty(i[o])&&r[i[o]]||(r[i[o]]={n:{}});for(r.f=r.f||[],o=0,a=r.f.length;o<a;o++)if(r.f[o]==e){n=!0;break}!n&&r.f.push(e)}(n[i]);return function(t){+t==+t&&(e.zIndex=+t)}},f.f=function(t){var e=[].slice.call(arguments,1);return function(){f.apply(null,[t,null].concat(e).concat([].slice.call(arguments,0)))}},f.stop=function(){i=1},f.nt=function(t){var e=p(n)?n.join("."):n;return t?new RegExp("(?:\\.|\\/|^)"+t+"(?:\\.|\\/|$)").test(e):e},f.nts=function(){return p(n)?n:n.split(s)},f.off=f.unbind=function(t,e){if(t){var n=p(t)?p(t[0])?t:[t]:d(t).split(o);if(n.length>1)for(var i=0,a=n.length;i<a;i++)f.off(n[i],e);else{n=p(t)?t:d(t).split(s);var h,c,u,m,g,v=[l],y=[];for(i=0,a=n.length;i<a;i++)for(m=0;m<v.length;m+=u.length-2){if(u=[m,1],h=v[m].n,"*"!=n[i])h[n[i]]&&(u.push(h[n[i]]),y.unshift({n:h,name:n[i]}));else for(c in h)h[r](c)&&(u.push(h[c]),y.unshift({n:h,name:c}));v.splice.apply(v,u)}for(i=0,a=v.length;i<a;i++)for(h=v[i];h.n;){if(e){if(h.f){for(m=0,g=h.f.length;m<g;m++)if(h.f[m]==e){h.f.splice(m,1);break}!h.f.length&&delete h.f}for(c in h.n)if(h.n[r](c)&&h.n[c].f){var x=h.n[c].f;for(m=0,g=x.length;m<g;m++)if(x[m]==e){x.splice(m,1);break}!x.length&&delete h.n[c].f}}else for(c in delete h.f,h.n)h.n[r](c)&&h.n[c].f&&delete h.n[c].f;h=h.n}t:for(i=0,a=y.length;i<a;i++){for(c in(h=y[i]).n[h.name].f)continue t;for(c in h.n[h.name].n)continue t;delete h.n[h.name]}}}else f._events=l={n:{}}},f.once=function(t,e){var n=function(){return f.off(t,n),e.apply(this,arguments)};return f.on(t,n)},f.version="0.5.4",f.toString=function(){return"You are running Eve 0.5.4"},e.eve=f,t.exports?t.exports=f:e.eve=f}("undefined"!=typeof window?window:q),n=window||q,i=ne,t.exports=function(t,e){var n=function(e){var n,i={},r=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(t){return setTimeout(t,16,(new Date).getTime()),!0},s=Array.isArray||function(t){return t instanceof Array||"[object Array]"==Object.prototype.toString.call(t)},o=0,a="M"+(+new Date).toString(36),l=Date.now||function(){return+new Date},h=function(t){var e=this;if(null==t)return e.s;var n=e.s-t;e.b+=e.dur*n,e.B+=e.dur*n,e.s=t},c=function(t){if(null==t)return this.spd;this.spd=t},u=function(t){var e=this;if(null==t)return e.dur;e.s=e.s*t/e.dur,e.dur=t},d=function(){var t=this;delete i[t.id],t.update(),e("mina.stop."+t.id,t)},p=function(){var t=this;t.pdif||(delete i[t.id],t.update(),t.pdif=t.get()-t.b)},f=function(){var t=this;t.pdif&&(t.b=t.get()-t.pdif,delete t.pdif,i[t.id]=t,g())},m=function(){var t,e=this;if(s(e.start)){t=[];for(var n=0,i=e.start.length;n<i;n++)t[n]=+e.start[n]+(e.end[n]-e.start[n])*e.easing(e.s)}else t=+e.start+(e.end-e.start)*e.easing(e.s);e.set(t)},g=function(t){if(t){var s=0;for(var o in i)if(i.hasOwnProperty(o)){var a=i[o],l=a.get();s++,a.s=(l-a.b)/(a.dur/a.spd),a.s>=1&&(delete i[o],a.s=1,s--,function(t){setTimeout((function(){e("mina.finish."+t.id,t)}))}(a)),a.update()}n=!!s&&r(g)}else n||(n=r(g))},v=function(t,e,n,r,s,l,y){var x={id:a+(o++).toString(36),start:t,end:e,b:n,s:0,dur:r-n,spd:1,get:s,set:l,easing:y||v.linear,status:h,speed:c,duration:u,stop:d,pause:p,resume:f,update:m};i[x.id]=x;var b,w=0;for(b in i)if(i.hasOwnProperty(b)&&2==++w)break;return 1==w&&g(),x};return v.time=l,v.getById=function(t){return i[t]||null},v.linear=function(t){return t},v.easeout=function(t){return Math.pow(t,1.7)},v.easein=function(t){return Math.pow(t,.48)},v.easeinout=function(t){if(1==t)return 1;if(0==t)return 0;var e=.48-t/1.04,n=Math.sqrt(.1734+e*e),i=n-e,r=-n-e,s=Math.pow(Math.abs(i),1/3)*(i<0?-1:1)+Math.pow(Math.abs(r),1/3)*(r<0?-1:1)+.5;return 3*(1-s)*s*s+s*s*s},v.backin=function(t){if(1==t)return 1;var e=1.70158;return t*t*((e+1)*t-e)},v.backout=function(t){if(0==t)return 0;var e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},v.elastic=function(t){return t==!!t?t:Math.pow(2,-10*t)*Math.sin((t-.075)*(2*Math.PI)/.3)+1},v.bounce=function(t){var e=7.5625,n=2.75;return t<1/n?e*t*t:t<2/n?e*(t-=1.5/n)*t+.75:t<2.5/n?e*(t-=2.25/n)*t+.9375:e*(t-=2.625/n)*t+.984375},t.mina=v,v}(void 0===e?function(){}:e),i=function(t){function n(t,e){if(t){if(t.nodeType)return q(t);if(L(t,"array")&&n.set)return n.set.apply(n,t);if(t instanceof G)return t;if(null==e)try{return q(t=i.doc.querySelector(String(t)))}catch(t){return null}}return new X(t=null==t?"100%":t,e=null==e?"100%":e)}n.version="0.5.1",n.toString=function(){return"Snap v"+this.version},n._={};var i={win:t.window,doc:t.window.document};n._.glob=i;var r,s,o="hasOwnProperty",a=String,l=parseFloat,h=parseInt,c=Math,u=c.max,d=c.min,p=c.abs,f=c.PI,m=Object.prototype.toString,v=/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?%?)\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?%?)\s*\))\s*$/i,y=(n._.separator=/[,\s]+/,/[\s]*,[\s]*/),x={hs:1,rg:1},b=/([a-z])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\s]*,?[\s]*)+)/gi,w=/([rstm])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\s]*,?[\s]*)+)/gi,M=/(-?\d*\.?\d*(?:e[\-+]?\d+)?)[\s]*,?[\s]*/gi,_=0,E="S"+(+new Date).toString(36),T=function(t){return(t&&t.type?t.type:"")+E+(_++).toString(36)},S="http://www.w3.org/1999/xlink",A="http://www.w3.org/2000/svg",P={};function C(t,e){if(e){if("#text"==t&&(t=i.doc.createTextNode(e.text||e["#text"]||"")),"#comment"==t&&(t=i.doc.createComment(e.text||e["#text"]||"")),"string"==typeof t&&(t=C(t)),"string"==typeof e)return 1==t.nodeType?"xlink:"==e.substring(0,6)?t.getAttributeNS(S,e.substring(6)):"xml:"==e.substring(0,4)?t.getAttributeNS(A,e.substring(4)):t.getAttribute(e):"text"==e?t.nodeValue:null;if(1==t.nodeType){for(var n in e)if(e[o](n)){var r=a(e[n]);r?"xlink:"==n.substring(0,6)?t.setAttributeNS(S,n.substring(6),r):"xml:"==n.substring(0,4)?t.setAttributeNS(A,n.substring(4),r):t.setAttribute(n,r):t.removeAttribute(n)}}else"text"in e&&(t.nodeValue=e.text)}else t=i.doc.createElementNS(A,t);return t}function L(t,e){return"finite"==(e=a.prototype.toLowerCase.call(e))?isFinite(t):!("array"!=e||!(t instanceof Array||Array.isArray&&Array.isArray(t)))||"null"==e&&null===t||e==typeof t&&null!==t||"object"==e&&t===Object(t)||m.call(t).slice(8,-1).toLowerCase()==e}function R(t,e){for(var n=0,i=t.length;n<i;n++)if(t[n]===e)return t.push(t.splice(n,1)[0])}function I(t,e,n){return function i(){var r=Array.prototype.slice.call(arguments,0),s=r.join("␀"),a=i.cache=i.cache||{},l=i.count=i.count||[];return a[o](s)?(R(l,s),n?n(a[s]):a[s]):(l.length>=1e3&&delete a[l.shift()],l.push(s),a[s]=t.apply(e,r),n?n(a[s]):a[s])}}function D(t){return t%360*f/180}n.url=function(t){return"url('#"+t+"')"},n._.$=C,n._.id=T,n.format=(r=/\{([^\}]+)\}/g,s=/(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g,function(t,e){return a(t).replace(r,(function(t,n){return function(t,e,n){var i=n;return e.replace(s,(function(t,e,n,r,s){e=e||r,i&&(e in i&&(i=i[e]),"function"==typeof i&&s&&(i=i()))})),i=(null==i||i==n?t:i)+""}(t,n,e)}))}),n._.clone=function t(e){if("function"==typeof e||Object(e)!==e)return e;var n=new e.constructor;for(var i in e)e[o](i)&&(n[i]=t(e[i]));return n},n._.cacher=I,n.rad=D,n.deg=function(t){return 180*t/f%360},n.sin=function(t){return c.sin(n.rad(t))},n.tan=function(t){return c.tan(n.rad(t))},n.cos=function(t){return c.cos(n.rad(t))},n.asin=function(t){return n.deg(c.asin(t))},n.acos=function(t){return n.deg(c.acos(t))},n.atan=function(t){return n.deg(c.atan(t))},n.atan2=function(t){return n.deg(c.atan2(t))},n.angle=function t(e,n,i,r,s,o){if(null==s){var a=e-i,l=n-r;return a||l?(180+180*c.atan2(-l,-a)/f+360)%360:0}return t(e,n,s,o)-t(i,r,s,o)},n.len=function(t,e,i,r){return Math.sqrt(n.len2(t,e,i,r))},n.len2=function(t,e,n,i){return(t-n)*(t-n)+(e-i)*(e-i)},n.closestPoint=function(t,e,n){function i(t){var i=t.x-e,r=t.y-n;return i*i+r*r}for(var r,s,o,a,l=t.node,h=l.getTotalLength(),c=h/l.pathSegList.numberOfItems*.125,u=1/0,d=0;d<=h;d+=c)(a=i(o=l.getPointAtLength(d)))<u&&(r=o,s=d,u=a);for(c*=.5;c>.5;){var p,f,m,g,v,y;(m=s-c)>=0&&(v=i(p=l.getPointAtLength(m)))<u?(r=p,s=m,u=v):(g=s+c)<=h&&(y=i(f=l.getPointAtLength(g)))<u?(r=f,s=g,u=y):c*=.5}return r={x:r.x,y:r.y,length:s,distance:Math.sqrt(u)}},n.is=L,n.snapTo=function(t,e,n){if(n=L(n,"finite")?n:10,L(t,"array")){for(var i=t.length;i--;)if(p(t[i]-e)<=n)return t[i]}else{var r=e%(t=+t);if(r<n)return e-r;if(r>t-n)return e-r+t}return e},n.getRGB=I((function(t){if(!t||(t=a(t)).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:N};if("none"==t)return{r:-1,g:-1,b:-1,hex:"none",toString:N};if(!x[o](t.toLowerCase().substring(0,2))&&"#"!=t.charAt()&&(t=O(t)),!t)return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:N};var e,i,r,s,p,f,m=t.match(v);return m?(m[2]&&(r=h(m[2].substring(5),16),i=h(m[2].substring(3,5),16),e=h(m[2].substring(1,3),16)),m[3]&&(r=h((p=m[3].charAt(3))+p,16),i=h((p=m[3].charAt(2))+p,16),e=h((p=m[3].charAt(1))+p,16)),m[4]&&(f=m[4].split(y),e=l(f[0]),"%"==f[0].slice(-1)&&(e*=2.55),i=l(f[1]),"%"==f[1].slice(-1)&&(i*=2.55),r=l(f[2]),"%"==f[2].slice(-1)&&(r*=2.55),"rgba"==m[1].toLowerCase().slice(0,4)&&(s=l(f[3])),f[3]&&"%"==f[3].slice(-1)&&(s/=100)),m[5]?(f=m[5].split(y),e=l(f[0]),"%"==f[0].slice(-1)&&(e/=100),i=l(f[1]),"%"==f[1].slice(-1)&&(i/=100),r=l(f[2]),"%"==f[2].slice(-1)&&(r/=100),("deg"==f[0].slice(-3)||"°"==f[0].slice(-1))&&(e/=360),"hsba"==m[1].toLowerCase().slice(0,4)&&(s=l(f[3])),f[3]&&"%"==f[3].slice(-1)&&(s/=100),n.hsb2rgb(e,i,r,s)):m[6]?(f=m[6].split(y),e=l(f[0]),"%"==f[0].slice(-1)&&(e/=100),i=l(f[1]),"%"==f[1].slice(-1)&&(i/=100),r=l(f[2]),"%"==f[2].slice(-1)&&(r/=100),("deg"==f[0].slice(-3)||"°"==f[0].slice(-1))&&(e/=360),"hsla"==m[1].toLowerCase().slice(0,4)&&(s=l(f[3])),f[3]&&"%"==f[3].slice(-1)&&(s/=100),n.hsl2rgb(e,i,r,s)):(e=d(c.round(e),255),i=d(c.round(i),255),r=d(c.round(r),255),s=d(u(s,0),1),(m={r:e,g:i,b:r,toString:N}).hex="#"+(16777216|r|i<<8|e<<16).toString(16).slice(1),m.opacity=L(s,"finite")?s:1,m)):{r:-1,g:-1,b:-1,hex:"none",error:1,toString:N}}),n),n.hsb=I((function(t,e,i){return n.hsb2rgb(t,e,i).hex})),n.hsl=I((function(t,e,i){return n.hsl2rgb(t,e,i).hex})),n.rgb=I((function(t,e,n,i){if(L(i,"finite")){var r=c.round;return"rgba("+[r(t),r(e),r(n),+i.toFixed(2)]+")"}return"#"+(16777216|n|e<<8|t<<16).toString(16).slice(1)}));var O=function(t){var e=i.doc.getElementsByTagName("head")[0]||i.doc.getElementsByTagName("svg")[0],n="rgb(255, 0, 0)";return(O=I((function(t){if("red"==t.toLowerCase())return n;e.style.color=n,e.style.color=t;var r=i.doc.defaultView.getComputedStyle(e,"").getPropertyValue("color");return r==n?null:r})))(t)},F=function(){return"hsb("+[this.h,this.s,this.b]+")"},B=function(){return"hsl("+[this.h,this.s,this.l]+")"},N=function(){return 1==this.opacity||null==this.opacity?this.hex:"rgba("+[this.r,this.g,this.b,this.opacity]+")"},z=function(t,e,i){if(null==e&&L(t,"object")&&"r"in t&&"g"in t&&"b"in t&&(i=t.b,e=t.g,t=t.r),null==e&&L(t,string)){var r=n.getRGB(t);t=r.r,e=r.g,i=r.b}return(t>1||e>1||i>1)&&(t/=255,e/=255,i/=255),[t,e,i]},U=function(t,e,i,r){var s={r:t=c.round(255*t),g:e=c.round(255*e),b:i=c.round(255*i),opacity:L(r,"finite")?r:1,hex:n.rgb(t,e,i),toString:N};return L(r,"finite")&&(s.opacity=r),s};n.color=function(t){var e;return L(t,"object")&&"h"in t&&"s"in t&&"b"in t?(e=n.hsb2rgb(t),t.r=e.r,t.g=e.g,t.b=e.b,t.opacity=1,t.hex=e.hex):L(t,"object")&&"h"in t&&"s"in t&&"l"in t?(e=n.hsl2rgb(t),t.r=e.r,t.g=e.g,t.b=e.b,t.opacity=1,t.hex=e.hex):(L(t,"string")&&(t=n.getRGB(t)),L(t,"object")&&"r"in t&&"g"in t&&"b"in t&&!("error"in t)?(e=n.rgb2hsl(t),t.h=e.h,t.s=e.s,t.l=e.l,e=n.rgb2hsb(t),t.v=e.b):((t={hex:"none"}).r=t.g=t.b=t.h=t.s=t.v=t.l=-1,t.error=1)),t.toString=N,t},n.hsb2rgb=function(t,e,n,i){var r,s,o,a,l;return L(t,"object")&&"h"in t&&"s"in t&&"b"in t&&(n=t.b,e=t.s,i=t.o,t=t.h),a=(l=n*e)*(1-p((t=(t*=360)%360/60)%2-1)),r=s=o=n-l,U(r+=[l,a,0,0,a,l][t=~~t],s+=[a,l,l,a,0,0][t],o+=[0,0,a,l,l,a][t],i)},n.hsl2rgb=function(t,e,n,i){var r,s,o,a,l;return L(t,"object")&&"h"in t&&"s"in t&&"l"in t&&(n=t.l,e=t.s,t=t.h),(t>1||e>1||n>1)&&(t/=360,e/=100,n/=100),a=(l=2*e*(n<.5?n:1-n))*(1-p((t=(t*=360)%360/60)%2-1)),r=s=o=n-l/2,U(r+=[l,a,0,0,a,l][t=~~t],s+=[a,l,l,a,0,0][t],o+=[0,0,a,l,l,a][t],i)},n.rgb2hsb=function(t,e,n){var i,r;return t=(n=z(t,e,n))[0],e=n[1],n=n[2],{h:((0==(r=(i=u(t,e,n))-d(t,e,n))?null:i==t?(e-n)/r:i==e?(n-t)/r+2:(t-e)/r+4)+360)%6*60/360,s:0==r?0:r/i,b:i,toString:F}},n.rgb2hsl=function(t,e,n){var i,r,s,o;return t=(n=z(t,e,n))[0],e=n[1],n=n[2],i=((r=u(t,e,n))+(s=d(t,e,n)))/2,{h:((0==(o=r-s)?null:r==t?(e-n)/o:r==e?(n-t)/o+2:(t-e)/o+4)+360)%6*60/360,s:0==o?0:i<.5?o/(2*i):o/(2-2*i),l:i,toString:B}},n.parsePathString=function(t){if(!t)return null;var e=n.path(t);if(e.arr)return n.path.clone(e.arr);var i={a:7,c:6,o:2,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,u:3,z:0},r=[];return L(t,"array")&&L(t[0],"array")&&(r=n.path.clone(t)),r.length||a(t).replace(b,(function(t,e,n){var s=[],o=e.toLowerCase();if(n.replace(M,(function(t,e){e&&s.push(+e)})),"m"==o&&s.length>2&&(r.push([e].concat(s.splice(0,2))),o="l",e="m"==e?"l":"L"),"o"==o&&1==s.length&&r.push([e,s[0]]),"r"==o)r.push([e].concat(s));else for(;s.length>=i[o]&&(r.push([e].concat(s.splice(0,i[o]))),i[o]););})),r.toString=n.path.toString,e.arr=n.path.clone(r),r};var k=n.parseTransformString=function(t){if(!t)return null;var e=[];return L(t,"array")&&L(t[0],"array")&&(e=n.path.clone(t)),e.length||a(t).replace(w,(function(t,n,i){var r=[];n.toLowerCase(),i.replace(M,(function(t,e){e&&r.push(+e)})),e.push([n].concat(r))})),e.toString=n.path.toString,e};function V(t){return t.node.ownerSVGElement&&q(t.node.ownerSVGElement)||n.select("svg")}function H(t){L(t,"array")||(t=Array.prototype.slice.call(arguments,0));for(var e=0,n=0,i=this.node;this[e];)delete this[e++];for(e=0;e<t.length;e++)"set"==t[e].type?t[e].forEach((function(t){i.appendChild(t.node)})):i.appendChild(t[e].node);var r=i.childNodes;for(e=0;e<r.length;e++)this[n++]=q(r[e]);return this}function G(t){if(t.snap in P)return P[t.snap];var e;try{e=t.ownerSVGElement}catch(t){}this.node=t,e&&(this.paper=new X(e)),this.type=t.tagName||t.nodeName;var n=this.id=T(this);if(this.anims={},this._={transform:[]},t.snap=n,P[n]=this,"g"==this.type&&(this.add=H),this.type in{g:1,mask:1,pattern:1,symbol:1})for(var i in X.prototype)X.prototype[o](i)&&(this[i]=X.prototype[i])}function W(t){this.node=t}function j(t,e){var n=C(t);return e.appendChild(n),q(n)}function X(t,e){var n,r,s,a=X.prototype;if(t&&t.tagName&&"svg"==t.tagName.toLowerCase()){if(t.snap in P)return P[t.snap];var l=t.ownerDocument;for(var h in n=new G(t),r=t.getElementsByTagName("desc")[0],s=t.getElementsByTagName("defs")[0],r||((r=C("desc")).appendChild(l.createTextNode("Created with Snap")),n.node.appendChild(r)),s||(s=C("defs"),n.node.appendChild(s)),n.defs=s,a)a[o](h)&&(n[h]=a[h]);n.paper=n.root=n}else C((n=j("svg",i.doc.body)).node,{height:e,version:1.1,width:t,xmlns:A});return n}function q(t){return t?t instanceof G||t instanceof W?t:t.tagName&&"svg"==t.tagName.toLowerCase()?new X(t):t.tagName&&"object"==t.tagName.toLowerCase()&&"image/svg+xml"==t.type?new X(t.contentDocument.getElementsByTagName("svg")[0]):new G(t):t}n._.svgTransform2string=function(t){var e=[];return t=t.replace(/(?:^|\s)(\w+)\(([^)]+)\)/g,(function(t,n,i){return i=i.split(/\s*,\s*|\s+/),"rotate"==n&&1==i.length&&i.push(0,0),"scale"==n&&(i.length>2?i=i.slice(0,2):2==i.length&&i.push(0,0),1==i.length&&i.push(i[0],0,0)),"skewX"==n?e.push(["m",1,0,c.tan(D(i[0])),1,0,0]):"skewY"==n?e.push(["m",1,c.tan(D(i[0])),0,1,0,0]):e.push([n.charAt(0)].concat(i)),t})),e},n._.rgTransform=/^[a-z][\s]*-?\.?\d/i,n._.transform2matrix=function(t,e){var i=k(t),r=new n.Matrix;if(i)for(var s=0,o=i.length;s<o;s++){var l,h,c,u,d,p=i[s],f=p.length,m=a(p[0]).toLowerCase(),g=p[0]!=m,v=g?r.invert():0;"t"==m&&2==f?r.translate(p[1],0):"t"==m&&3==f?g?(l=v.x(0,0),h=v.y(0,0),c=v.x(p[1],p[2]),u=v.y(p[1],p[2]),r.translate(c-l,u-h)):r.translate(p[1],p[2]):"r"==m?2==f?(d=d||e,r.rotate(p[1],d.x+d.width/2,d.y+d.height/2)):4==f&&(g?(c=v.x(p[2],p[3]),u=v.y(p[2],p[3]),r.rotate(p[1],c,u)):r.rotate(p[1],p[2],p[3])):"s"==m?2==f||3==f?(d=d||e,r.scale(p[1],p[f-1],d.x+d.width/2,d.y+d.height/2)):4==f?g?(c=v.x(p[2],p[3]),u=v.y(p[2],p[3]),r.scale(p[1],p[1],c,u)):r.scale(p[1],p[1],p[2],p[3]):5==f&&(g?(c=v.x(p[3],p[4]),u=v.y(p[3],p[4]),r.scale(p[1],p[2],c,u)):r.scale(p[1],p[2],p[3],p[4])):"m"==m&&7==f&&r.add(p[1],p[2],p[3],p[4],p[5],p[6])}return r},n._unit2px=function(t,e,n){var i=V(t).node,r={},s=i.querySelector(".svg---mgr");function o(t){if(null==t)return"";if(t==+t)return t;C(s,{width:t});try{return s.getBBox().width}catch(t){return 0}}function a(t){if(null==t)return"";if(t==+t)return t;C(s,{height:t});try{return s.getBBox().height}catch(t){return 0}}function l(i,s){null==e?r[i]=s(t.attr(i)||0):i==e&&(r=s(null==n?t.attr(i)||0:n))}switch(s||(s=C("rect"),C(s,{x:-9e9,y:-9e9,width:10,height:10,class:"svg---mgr",fill:"none"}),i.appendChild(s)),t.type){case"rect":l("rx",o),l("ry",a);case"image":l("width",o),l("height",a);case"text":l("x",o),l("y",a);break;case"circle":l("cx",o),l("cy",a),l("r",o);break;case"ellipse":l("cx",o),l("cy",a),l("rx",o),l("ry",a);break;case"line":l("x1",o),l("x2",o),l("y1",a),l("y2",a);break;case"marker":l("refX",o),l("markerWidth",o),l("refY",a),l("markerHeight",a);break;case"radialGradient":l("fx",o),l("fy",a);break;case"tspan":l("dx",o),l("dy",a);break;default:l(e,o)}return i.removeChild(s),r},i.doc.contains||i.doc.compareDocumentPosition,n._.getSomeDefs=function(t){var e=t.node.ownerSVGElement&&q(t.node.ownerSVGElement)||t.node.parentNode&&q(t.node.parentNode)||n.select("svg")||n(0,0),i=e.select("defs"),r=null!=i&&i.node;return r||(r=j("defs",e.node).node),r},n._.getSomeSVG=V,n.select=function(t){return t=a(t).replace(/([^\\]):/g,"$1\\:"),q(i.doc.querySelector(t))},n.selectAll=function(t){for(var e=i.doc.querySelectorAll(t),r=(n.set||Array)(),s=0;s<e.length;s++)r.push(q(e[s]));return r},setInterval((function(){for(var t in P)if(P[o](t)){var e=P[t],n=e.node;("svg"!=e.type&&!n.ownerSVGElement||"svg"==e.type&&(!n.parentNode||"ownerSVGElement"in n.parentNode&&!n.ownerSVGElement))&&delete P[t]}}),1e4),G.prototype.attr=function(t,n){var i=this,r=i.node;if(!t){if(1!=r.nodeType)return{text:r.nodeValue};for(var s=r.attributes,a={},l=0,h=s.length;l<h;l++)a[s[l].nodeName]=s[l].nodeValue;return a}if(L(t,"string")){if(!(arguments.length>1))return e("snap.util.getattr."+t,i).firstDefined();var c={};c[t]=n,t=c}for(var u in t)t[o](u)&&e("snap.util.attr."+u,i,t[u]);return i},n.parse=function(t){var e=i.doc.createDocumentFragment(),n=!0,r=i.doc.createElement("div");if((t=a(t)).match(/^\s*<\s*svg(?:\s|>)/)||(t="<svg>"+t+"</svg>",n=!1),r.innerHTML=t,t=r.getElementsByTagName("svg")[0])if(n)e=t;else for(;t.firstChild;)e.appendChild(t.firstChild);return new W(e)},n.fragment=function(){for(var t=Array.prototype.slice.call(arguments,0),e=i.doc.createDocumentFragment(),r=0,s=t.length;r<s;r++){var o=t[r];o.node&&o.node.nodeType&&e.appendChild(o.node),o.nodeType&&e.appendChild(o),"string"==typeof o&&e.appendChild(n.parse(o).node)}return new W(e)},n._.make=j,n._.wrap=q,X.prototype.el=function(t,e){var n=j(t,this.node);return e&&n.attr(e),n},G.prototype.children=function(){for(var t=[],e=this.node.childNodes,i=0,r=e.length;i<r;i++)t[i]=n(e[i]);return t},G.prototype.toJSON=function(){var t=[];return function t(e,n){for(var i=0,r=e.length;i<r;i++){var s={type:e[i].type,attr:e[i].attr()},o=e[i].children();n.push(s),o.length&&t(o,s.childNodes=[])}}([this],t),t[0]},e.on("snap.util.getattr",(function(){var t=e.nt(),n=(t=t.substring(t.lastIndexOf(".")+1)).replace(/[A-Z]/g,(function(t){return"-"+t.toLowerCase()}));return Y[o](n)?this.node.ownerDocument.defaultView.getComputedStyle(this.node,null).getPropertyValue(n):C(this.node,t)}));var Y={"alignment-baseline":0,"baseline-shift":0,clip:0,"clip-path":0,"clip-rule":0,color:0,"color-interpolation":0,"color-interpolation-filters":0,"color-profile":0,"color-rendering":0,cursor:0,direction:0,display:0,"dominant-baseline":0,"enable-background":0,fill:0,"fill-opacity":0,"fill-rule":0,filter:0,"flood-color":0,"flood-opacity":0,font:0,"font-family":0,"font-size":0,"font-size-adjust":0,"font-stretch":0,"font-style":0,"font-variant":0,"font-weight":0,"glyph-orientation-horizontal":0,"glyph-orientation-vertical":0,"image-rendering":0,kerning:0,"letter-spacing":0,"lighting-color":0,marker:0,"marker-end":0,"marker-mid":0,"marker-start":0,mask:0,opacity:0,overflow:0,"pointer-events":0,"shape-rendering":0,"stop-color":0,"stop-opacity":0,stroke:0,"stroke-dasharray":0,"stroke-dashoffset":0,"stroke-linecap":0,"stroke-linejoin":0,"stroke-miterlimit":0,"stroke-opacity":0,"stroke-width":0,"text-anchor":0,"text-decoration":0,"text-rendering":0,"unicode-bidi":0,visibility:0,"word-spacing":0,"writing-mode":0};return e.on("snap.util.attr",(function(t){var n=e.nt(),i={};i[n=n.substring(n.lastIndexOf(".")+1)]=t;var r=n.replace(/-(\w)/gi,(function(t,e){return e.toUpperCase()})),s=n.replace(/[A-Z]/g,(function(t){return"-"+t.toLowerCase()}));Y[o](s)?this.node.style[r]=null==t?"":t:C(this.node,i)})),n.ajax=function(t,n,i,r){var s=new XMLHttpRequest,o=T();if(s){if(L(n,"function"))r=i,i=n,n=null;else if(L(n,"object")){var a=[];for(var l in n)n.hasOwnProperty(l)&&a.push(encodeURIComponent(l)+"="+encodeURIComponent(n[l]));n=a.join("&")}return s.open(n?"POST":"GET",t,!0),n&&(s.setRequestHeader("X-Requested-With","XMLHttpRequest"),s.setRequestHeader("Content-type","application/x-www-form-urlencoded")),i&&(e.once("snap.ajax."+o+".0",i),e.once("snap.ajax."+o+".200",i),e.once("snap.ajax."+o+".304",i)),s.onreadystatechange=function(){4==s.readyState&&(e("snap.ajax."+o+"."+s.status,r,s),e.off("snap.ajax."+o+".0"),e.off("snap.ajax."+o+".200"),e.off("snap.ajax."+o+".304"))},4==s.readyState||s.send(n),s}},n.load=function(t,e,i){n.ajax(t,(function(t){var r=n.parse(t.responseText);i?e.call(i,r):e(r)}))},n.getElementByPoint=function(t,e){this.canvas;var n,r,s,o,a,l,h,c=i.doc.elementFromPoint(t,e);if(i.win.opera&&"svg"==c.tagName){var u=(r=(n=c).getBoundingClientRect(),s=n.ownerDocument,o=s.body,a=s.documentElement,l=a.clientTop||o.clientTop||0,h=a.clientLeft||o.clientLeft||0,{y:r.top+(g.win.pageYOffset||a.scrollTop||o.scrollTop)-l,x:r.left+(g.win.pageXOffset||a.scrollLeft||o.scrollLeft)-h}),d=c.createSVGRect();d.x=t-u.x,d.y=e-u.y,d.width=d.height=1;var p=c.getIntersectionList(d,null);p.length&&(c=p[p.length-1])}return c?q(c):null},n.plugin=function(t){t(n,G,X,i,W)},i.win.Snap=n,n}(t||this);return i.plugin((function(n,i,r,s,o){var a=i.prototype,l=n.is,h=String,c=n._unit2px,u=n._.$,d=n._.make,p=n._.getSomeDefs,f="hasOwnProperty",m=n._.wrap;a.getBBox=function(t){if("tspan"==this.type)return n._.box(this.node.getClientRects().item(0));if(!n.Matrix||!n.path)return this.node.getBBox();var e=this,i=new n.Matrix;if(e.removed)return n._.box();for(;"use"==e.type;)if(t||(i=i.add(e.transform().localMatrix.translate(e.attr("x")||0,e.attr("y")||0))),e.original)e=e.original;else{var r=e.attr("xlink:href");e=e.original=e.node.ownerDocument.getElementById(r.substring(r.indexOf("#")+1))}var s=e._,o=n.path.get[e.type]||n.path.get.deflt;try{return t?(s.bboxwt=o?n.path.getBBox(e.realPath=o(e)):n._.box(e.node.getBBox()),n._.box(s.bboxwt)):(e.realPath=o(e),e.matrix=e.transform().localMatrix,s.bbox=n.path.getBBox(n.path.map(e.realPath,i.add(e.matrix))),n._.box(s.bbox))}catch(t){return n._.box()}};var g=function(){return this.string};function v(t,e){if(null==e){var i=!0;if(!(e="linearGradient"==t.type||"radialGradient"==t.type?t.node.getAttribute("gradientTransform"):"pattern"==t.type?t.node.getAttribute("patternTransform"):t.node.getAttribute("transform")))return new n.Matrix;e=n._.svgTransform2string(e)}else e=n._.rgTransform.test(e)?h(e).replace(/\.{3}|\u2026/g,t._.transform||""):n._.svgTransform2string(e),l(e,"array")&&(e=n.path?n.path.toString.call(e):h(e)),t._.transform=e;var r=n._.transform2matrix(e,t.getBBox(1));if(i)return r;t.matrix=r}a.transform=function(t){var e=this._;if(null==t){for(var i,r=this,s=new n.Matrix(this.node.getCTM()),o=v(this),a=[o],l=new n.Matrix,c=o.toTransformString(),d=h(o)==h(this.matrix)?h(e.transform):c;"svg"!=r.type&&(r=r.parent());)a.push(v(r));for(i=a.length;i--;)l.add(a[i]);return{string:d,globalMatrix:s,totalMatrix:l,localMatrix:o,diffMatrix:s.clone().add(o.invert()),global:s.toTransformString(),total:l.toTransformString(),local:c,toString:g}}return t instanceof n.Matrix?(this.matrix=t,this._.transform=t.toTransformString()):v(this,t),this.node&&("linearGradient"==this.type||"radialGradient"==this.type?u(this.node,{gradientTransform:this.matrix}):"pattern"==this.type?u(this.node,{patternTransform:this.matrix}):u(this.node,{transform:this.matrix})),this},a.parent=function(){return m(this.node.parentNode)},a.append=a.add=function(t){if(t){if("set"==t.type){var e=this;return t.forEach((function(t){e.add(t)})),this}t=m(t),this.node.appendChild(t.node),t.paper=this.paper}return this},a.appendTo=function(t){return t&&(t=m(t)).append(this),this},a.prepend=function(t){if(t){if("set"==t.type){var e,n=this;return t.forEach((function(t){e?e.after(t):n.prepend(t),e=t})),this}var i=(t=m(t)).parent();this.node.insertBefore(t.node,this.node.firstChild),this.add&&this.add(),t.paper=this.paper,this.parent()&&this.parent().add(),i&&i.add()}return this},a.prependTo=function(t){return(t=m(t)).prepend(this),this},a.before=function(t){if("set"==t.type){var e=this;return t.forEach((function(t){var n=t.parent();e.node.parentNode.insertBefore(t.node,e.node),n&&n.add()})),this.parent().add(),this}var n=(t=m(t)).parent();return this.node.parentNode.insertBefore(t.node,this.node),this.parent()&&this.parent().add(),n&&n.add(),t.paper=this.paper,this},a.after=function(t){var e=(t=m(t)).parent();return this.node.nextSibling?this.node.parentNode.insertBefore(t.node,this.node.nextSibling):this.node.parentNode.appendChild(t.node),this.parent()&&this.parent().add(),e&&e.add(),t.paper=this.paper,this},a.insertBefore=function(t){t=m(t);var e=this.parent();return t.node.parentNode.insertBefore(this.node,t.node),this.paper=t.paper,e&&e.add(),t.parent()&&t.parent().add(),this},a.insertAfter=function(t){t=m(t);var e=this.parent();return t.node.parentNode.insertBefore(this.node,t.node.nextSibling),this.paper=t.paper,e&&e.add(),t.parent()&&t.parent().add(),this},a.remove=function(){var t=this.parent();return this.node.parentNode&&this.node.parentNode.removeChild(this.node),delete this.paper,this.removed=!0,t&&t.add(),this},a.select=function(t){return m(this.node.querySelector(t))},a.selectAll=function(t){for(var e=this.node.querySelectorAll(t),i=(n.set||Array)(),r=0;r<e.length;r++)i.push(m(e[r]));return i},a.asPX=function(t,e){return null==e&&(e=this.attr(t)),+c(this,t,e)},a.use=function(){var t,e=this.node.id;return e||(e=this.id,u(this.node,{id:e})),t="linearGradient"==this.type||"radialGradient"==this.type||"pattern"==this.type?d(this.type,this.node.parentNode):d("use",this.node.parentNode),u(t.node,{"xlink:href":"#"+e}),t.original=this,t},a.clone=function(){var t=m(this.node.cloneNode(!0));return u(t.node,"id")&&u(t.node,{id:t.id}),function(t){var e,i=t.selectAll("*"),r=/^\s*url\(("|'|)(.*)\1\)\s*$/,s=[],o={};function a(t,e){var i=u(t.node,e);(i=(i=i&&i.match(r))&&i[2])&&"#"==i.charAt()&&(i=i.substring(1))&&(o[i]=(o[i]||[]).concat((function(i){var r={};r[e]=n.url(i),u(t.node,r)})))}function l(t){var e=u(t.node,"xlink:href");e&&"#"==e.charAt()&&(e=e.substring(1))&&(o[e]=(o[e]||[]).concat((function(e){t.attr("xlink:href","#"+e)})))}for(var h=0,c=i.length;h<c;h++){a(e=i[h],"fill"),a(e,"stroke"),a(e,"filter"),a(e,"mask"),a(e,"clip-path"),l(e);var d=u(e.node,"id");d&&(u(e.node,{id:e.id}),s.push({old:d,id:e.id}))}for(h=0,c=s.length;h<c;h++){var p=o[s[h].old];if(p)for(var f=0,m=p.length;f<m;f++)p[f](s[h].id)}}(t),t.insertAfter(this),t},a.toDefs=function(){return p(this).appendChild(this.node),this},a.pattern=a.toPattern=function(t,e,n,i){var r=d("pattern",p(this));return null==t&&(t=this.getBBox()),l(t,"object")&&"x"in t&&(e=t.y,n=t.width,i=t.height,t=t.x),u(r.node,{x:t,y:e,width:n,height:i,patternUnits:"userSpaceOnUse",id:r.id,viewBox:[t,e,n,i].join(" ")}),r.node.appendChild(this.node),r},a.marker=function(t,e,n,i,r,s){var o=d("marker",p(this));return null==t&&(t=this.getBBox()),l(t,"object")&&"x"in t&&(e=t.y,n=t.width,i=t.height,r=t.refX||t.cx,s=t.refY||t.cy,t=t.x),u(o.node,{viewBox:[t,e,n,i].join(" "),markerWidth:n,markerHeight:i,orient:"auto",refX:r||0,refY:s||0,id:o.id}),o.node.appendChild(this.node),o};var y={};function x(t){return function(){var e=t?"<"+this.type:"",n=this.node.attributes,i=this.node.childNodes;if(t)for(var r=0,s=n.length;r<s;r++)e+=" "+n[r].name+'="'+n[r].value.replace(/"/g,'\\"')+'"';if(i.length){for(t&&(e+=">"),r=0,s=i.length;r<s;r++)3==i[r].nodeType?e+=i[r].nodeValue:1==i[r].nodeType&&(e+=m(i[r]).toString());t&&(e+="</"+this.type+">")}else t&&(e+="/>");return e}}a.data=function(t,i){var r=y[this.id]=y[this.id]||{};if(0==arguments.length)return e("snap.data.get."+this.id,this,r,null),r;if(1==arguments.length){if(n.is(t,"object")){for(var s in t)t[f](s)&&this.data(s,t[s]);return this}return e("snap.data.get."+this.id,this,r[t],t),r[t]}return r[t]=i,e("snap.data.set."+this.id,this,i,t),this},a.removeData=function(t){return null==t?y[this.id]={}:y[this.id]&&delete y[this.id][t],this},a.outerSVG=a.toString=x(1),a.innerSVG=x(),a.toDataURL=function(){if(t&&t.btoa){var e=this.getBBox(),i=n.format('<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="{width}" height="{height}" viewBox="{x} {y} {width} {height}">{contents}</svg>',{x:+e.x.toFixed(3),y:+e.y.toFixed(3),width:+e.width.toFixed(3),height:+e.height.toFixed(3),contents:this.outerSVG()});return"data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(i)))}},o.prototype.select=a.select,o.prototype.selectAll=a.selectAll})),i.plugin((function(t,i,r,s,o){var a=i.prototype,l=t.is,h=String,c="hasOwnProperty";function u(t,e,n){return function(i){var r=i.slice(t,e);return 1==r.length&&(r=r[0]),n?n(r):r}}var d=function(t,e,i,r){"function"!=typeof i||i.length||(r=i,i=n.linear),this.attr=t,this.dur=e,i&&(this.easing=i),r&&(this.callback=r)};t._.Animation=d,t.animation=function(t,e,n,i){return new d(t,e,n,i)},a.inAnim=function(){var t=[];for(var e in this.anims)this.anims[c](e)&&function(e){t.push({anim:new d(e._attrs,e.dur,e.easing,e._callback),mina:e,curStatus:e.status(),status:function(t){return e.status(t)},stop:function(){e.stop()}})}(this.anims[e]);return t},t.animate=function(t,i,r,s,o,a){"function"!=typeof o||o.length||(a=o,o=n.linear);var l=n.time(),h=n(t,i,l,l+s,n.time,r,o);return a&&e.once("mina.finish."+h.id,a),h},a.stop=function(){for(var t=this.inAnim(),e=0,n=t.length;e<n;e++)t[e].stop();return this},a.animate=function(t,i,r,s){"function"!=typeof r||r.length||(s=r,r=n.linear),t instanceof d&&(s=t.callback,r=t.easing,i=t.dur,t=t.attr);var o,a,p,f,m=[],g=[],v={},y=this;for(var x in t)if(t[c](x)){y.equal?(o=(f=y.equal(x,h(t[x]))).from,a=f.to,p=f.f):(o=+y.attr(x),a=+t[x]);var b=l(o,"array")?o.length:1;v[x]=u(m.length,m.length+b,p),m=m.concat(o),g=g.concat(a)}var w=n.time(),M=n(m,g,w,w+i,n.time,(function(t){var e={};for(var n in v)v[c](n)&&(e[n]=v[n](t));y.attr(e)}),r);return y.anims[M.id]=M,M._attrs=t,M._callback=s,e("snap.animcreated."+y.id,M),e.once("mina.finish."+M.id,(function(){e.off("mina.*."+M.id),delete y.anims[M.id],s&&s.call(y)})),e.once("mina.stop."+M.id,(function(){e.off("mina.*."+M.id),delete y.anims[M.id]})),y}})),i.plugin((function(t,e,n,i,r){var s=Object.prototype.toString,o=String,a=Math;function l(t,e,n,i,r,o){if(null==e&&"[object SVGMatrix]"==s.call(t))return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.e=t.e,void(this.f=t.f);null!=t?(this.a=+t,this.b=+e,this.c=+n,this.d=+i,this.e=+r,this.f=+o):(this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0)}!function(e){function n(t){return t[0]*t[0]+t[1]*t[1]}function i(t){var e=a.sqrt(n(t));t[0]&&(t[0]/=e),t[1]&&(t[1]/=e)}e.add=function(t,e,n,i,r,s){if(t&&t instanceof l)return this.add(t.a,t.b,t.c,t.d,t.e,t.f);var o=t*this.a+e*this.c,a=t*this.b+e*this.d;return this.e+=r*this.a+s*this.c,this.f+=r*this.b+s*this.d,this.c=n*this.a+i*this.c,this.d=n*this.b+i*this.d,this.a=o,this.b=a,this},l.prototype.multLeft=function(t,e,n,i,r,s){if(t&&t instanceof l)return this.multLeft(t.a,t.b,t.c,t.d,t.e,t.f);var o=t*this.a+n*this.b,a=t*this.c+n*this.d,h=t*this.e+n*this.f+r;return this.b=e*this.a+i*this.b,this.d=e*this.c+i*this.d,this.f=e*this.e+i*this.f+s,this.a=o,this.c=a,this.e=h,this},e.invert=function(){var t=this,e=t.a*t.d-t.b*t.c;return new l(t.d/e,-t.b/e,-t.c/e,t.a/e,(t.c*t.f-t.d*t.e)/e,(t.b*t.e-t.a*t.f)/e)},e.clone=function(){return new l(this.a,this.b,this.c,this.d,this.e,this.f)},e.translate=function(t,e){return this.e+=t*this.a+e*this.c,this.f+=t*this.b+e*this.d,this},e.scale=function(t,e,n,i){return null==e&&(e=t),(n||i)&&this.translate(n,i),this.a*=t,this.b*=t,this.c*=e,this.d*=e,(n||i)&&this.translate(-n,-i),this},e.rotate=function(e,n,i){e=t.rad(e),n=n||0,i=i||0;var r=+a.cos(e).toFixed(9),s=+a.sin(e).toFixed(9);return this.add(r,s,-s,r,n,i),this.add(1,0,0,1,-n,-i)},e.skewX=function(t){return this.skew(t,0)},e.skewY=function(t){return this.skew(0,t)},e.skew=function(e,n){e=e||0,n=n||0,e=t.rad(e),n=t.rad(n);var i=a.tan(e).toFixed(9),r=a.tan(n).toFixed(9);return this.add(1,r,i,1,0,0)},e.x=function(t,e){return t*this.a+e*this.c+this.e},e.y=function(t,e){return t*this.b+e*this.d+this.f},e.get=function(t){return+this[o.fromCharCode(97+t)].toFixed(4)},e.toString=function(){return"matrix("+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)].join()+")"},e.offset=function(){return[this.e.toFixed(4),this.f.toFixed(4)]},e.determinant=function(){return this.a*this.d-this.b*this.c},e.split=function(){var e={};e.dx=this.e,e.dy=this.f;var r=[[this.a,this.b],[this.c,this.d]];e.scalex=a.sqrt(n(r[0])),i(r[0]),e.shear=r[0][0]*r[1][0]+r[0][1]*r[1][1],r[1]=[r[1][0]-r[0][0]*e.shear,r[1][1]-r[0][1]*e.shear],e.scaley=a.sqrt(n(r[1])),i(r[1]),e.shear/=e.scaley,this.determinant()<0&&(e.scalex=-e.scalex);var s=r[0][1],o=r[1][1];return o<0?(e.rotate=t.deg(a.acos(o)),s<0&&(e.rotate=360-e.rotate)):e.rotate=t.deg(a.asin(s)),e.isSimple=!(+e.shear.toFixed(9)||e.scalex.toFixed(9)!=e.scaley.toFixed(9)&&e.rotate),e.isSuperSimple=!+e.shear.toFixed(9)&&e.scalex.toFixed(9)==e.scaley.toFixed(9)&&!e.rotate,e.noRotation=!+e.shear.toFixed(9)&&!e.rotate,e},e.toTransformString=function(t){var e=t||this.split();return+e.shear.toFixed(9)?"m"+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)]:(e.scalex=+e.scalex.toFixed(4),e.scaley=+e.scaley.toFixed(4),e.rotate=+e.rotate.toFixed(4),(e.dx||e.dy?"t"+[+e.dx.toFixed(4),+e.dy.toFixed(4)]:"")+(e.rotate?"r"+[+e.rotate.toFixed(4),0,0]:"")+(1!=e.scalex||1!=e.scaley?"s"+[e.scalex,e.scaley,0,0]:""))}}(l.prototype),t.Matrix=l,t.matrix=function(t,e,n,i,r,s){return new l(t,e,n,i,r,s)}})),i.plugin((function(t,n,i,r,s){var o,a=t._.make,l=t._.wrap,h=t.is,c=t._.getSomeDefs,u=/^url\((['"]?)([^)]+)\1\)$/,d=t._.$,p=t.url,f=String,m=t._.separator;function g(i){return function(r){if(e.stop(),r instanceof s&&1==r.node.childNodes.length&&("radialGradient"==r.node.firstChild.tagName||"linearGradient"==r.node.firstChild.tagName||"pattern"==r.node.firstChild.tagName)&&(r=r.node.firstChild,c(this).appendChild(r),r=l(r)),r instanceof n)if("radialGradient"==r.type||"linearGradient"==r.type||"pattern"==r.type){r.node.id||d(r.node,{id:r.id});var o=p(r.node.id)}else o=r.attr(i);else if((o=t.color(r)).error){var a=t(c(this).ownerSVGElement).gradient(r);a?(a.node.id||d(a.node,{id:a.id}),o=p(a.node.id)):o=r}else o=f(o);var h={};h[i]=o,d(this.node,h),this.node.style[i]=""}}t.deurl=function(t){var e=String(t).match(u);return e?e[2]:t},e.on("snap.util.attr.mask",(function(t){if(t instanceof n||t instanceof s){if(e.stop(),t instanceof s&&1==t.node.childNodes.length&&(t=t.node.firstChild,c(this).appendChild(t),t=l(t)),"mask"==t.type)var i=t;else(i=a("mask",c(this))).node.appendChild(t.node);!i.node.id&&d(i.node,{id:i.id}),d(this.node,{mask:p(i.id)})}})),o=function(t){if(t instanceof n||t instanceof s){e.stop();for(var i,r=t.node;r;){if("clipPath"===r.nodeName){i=new n(r);break}if("svg"===r.nodeName){i=void 0;break}r=r.parentNode}i||((i=a("clipPath",c(this))).node.appendChild(t.node),!i.node.id&&d(i.node,{id:i.id})),d(this.node,{"clip-path":p(i.node.id||i.id)})}},e.on("snap.util.attr.clip",o),e.on("snap.util.attr.clip-path",o),e.on("snap.util.attr.clipPath",o),e.on("snap.util.attr.fill",g("fill")),e.on("snap.util.attr.stroke",g("stroke"));var v=/^([lr])(?:\(([^)]*)\))?(.*)$/i;function y(t){e.stop(),t==+t&&(t+="px"),this.node.style.fontSize=t}function x(){return e.stop(),this.node.style.fontSize}e.on("snap.util.grad.parse",(function(t){var e=(t=f(t)).match(v);if(!e)return null;var n=e[1],i=e[2],r=e[3];1==(i=i.split(/\s*,\s*/).map((function(t){return+t==t?+t:t}))).length&&0==i[0]&&(i=[]);var s=(r=(r=r.split("-")).map((function(t){var e={color:(t=t.split(":"))[0]};return t[1]&&(e.offset=parseFloat(t[1])),e}))).length,o=0,a=0;function l(t,e){for(var n=(e-o)/(t-a),i=a;i<t;i++)r[i].offset=+(+o+n*(i-a)).toFixed(2);a=t,o=e}s--;for(var h=0;h<s;h++)"offset"in r[h]&&l(h,r[h].offset);return r[s].offset=r[s].offset||100,l(s,r[s].offset),{type:n,params:i,stops:r}})),e.on("snap.util.attr.d",(function(n){e.stop(),h(n,"array")&&h(n[0],"array")&&(n=t.path.toString.call(n)),(n=f(n)).match(/[ruo]/i)&&(n=t.path.toAbsolute(n)),d(this.node,{d:n})}))(-1),e.on("snap.util.attr.#text",(function(t){e.stop(),t=f(t);for(var n=r.doc.createTextNode(t);this.node.firstChild;)this.node.removeChild(this.node.firstChild);this.node.appendChild(n)}))(-1),e.on("snap.util.attr.path",(function(t){e.stop(),this.attr({d:t})}))(-1),e.on("snap.util.attr.class",(function(t){e.stop(),this.node.className.baseVal=t}))(-1),e.on("snap.util.attr.viewBox",(function(t){var n;n=h(t,"object")&&"x"in t?[t.x,t.y,t.width,t.height].join(" "):h(t,"array")?t.join(" "):t,d(this.node,{viewBox:n}),e.stop()}))(-1),e.on("snap.util.attr.transform",(function(t){this.transform(t),e.stop()}))(-1),e.on("snap.util.attr.r",(function(t){"rect"==this.type&&(e.stop(),d(this.node,{rx:t,ry:t}))}))(-1),e.on("snap.util.attr.textpath",(function(t){if(e.stop(),"text"==this.type){var i,r,s;if(!t&&this.textPath){for(r=this.textPath;r.node.firstChild;)this.node.appendChild(r.node.firstChild);return r.remove(),void delete this.textPath}if(h(t,"string")){var o=c(this),a=l(o.parentNode).path(t);o.appendChild(a.node),i=a.id,a.attr({id:i})}else(t=l(t))instanceof n&&((i=t.attr("id"))||(i=t.id,t.attr({id:i})));if(i)if(r=this.textPath,s=this.node,r)r.attr({"xlink:href":"#"+i});else{for(r=d("textPath",{"xlink:href":"#"+i});s.firstChild;)r.appendChild(s.firstChild);s.appendChild(r),this.textPath=l(r)}}}))(-1),e.on("snap.util.attr.text",(function(t){if("text"==this.type){for(var n=this.node,i=function(t){var e=d("tspan");if(h(t,"array"))for(var n=0;n<t.length;n++)e.appendChild(i(t[n]));else e.appendChild(r.doc.createTextNode(t));return e.normalize&&e.normalize(),e};n.firstChild;)n.removeChild(n.firstChild);for(var s=i(t);s.firstChild;)n.appendChild(s.firstChild)}e.stop()}))(-1),e.on("snap.util.attr.fontSize",y)(-1),e.on("snap.util.attr.font-size",y)(-1),e.on("snap.util.getattr.transform",(function(){return e.stop(),this.transform()}))(-1),e.on("snap.util.getattr.textpath",(function(){return e.stop(),this.textPath}))(-1),function(){function n(n){return function(){e.stop();var i=r.doc.defaultView.getComputedStyle(this.node,null).getPropertyValue("marker-"+n);return"none"==i?i:t(r.doc.getElementById(i.match(u)[1]))}}function i(t){return function(n){e.stop();var i="marker"+t.charAt(0).toUpperCase()+t.substring(1);if(""!=n&&n){if("marker"==n.type){var r=n.node.id;return r||d(n.node,{id:n.id}),void(this.node.style[i]=p(r))}}else this.node.style[i]="none"}}e.on("snap.util.getattr.marker-end",n("end"))(-1),e.on("snap.util.getattr.markerEnd",n("end"))(-1),e.on("snap.util.getattr.marker-start",n("start"))(-1),e.on("snap.util.getattr.markerStart",n("start"))(-1),e.on("snap.util.getattr.marker-mid",n("mid"))(-1),e.on("snap.util.getattr.markerMid",n("mid"))(-1),e.on("snap.util.attr.marker-end",i("end"))(-1),e.on("snap.util.attr.markerEnd",i("end"))(-1),e.on("snap.util.attr.marker-start",i("start"))(-1),e.on("snap.util.attr.markerStart",i("start"))(-1),e.on("snap.util.attr.marker-mid",i("mid"))(-1),e.on("snap.util.attr.markerMid",i("mid"))(-1)}(),e.on("snap.util.getattr.r",(function(){if("rect"==this.type&&d(this.node,"rx")==d(this.node,"ry"))return e.stop(),d(this.node,"rx")}))(-1),e.on("snap.util.getattr.text",(function(){if("text"==this.type||"tspan"==this.type){e.stop();var t=function t(e){for(var n=[],i=e.childNodes,r=0,s=i.length;r<s;r++){var o=i[r];3==o.nodeType&&n.push(o.nodeValue),"tspan"==o.tagName&&(1==o.childNodes.length&&3==o.firstChild.nodeType?n.push(o.firstChild.nodeValue):n.push(t(o)))}return n}(this.node);return 1==t.length?t[0]:t}}))(-1),e.on("snap.util.getattr.#text",(function(){return this.node.textContent}))(-1),e.on("snap.util.getattr.fill",(function(n){if(!n){e.stop();var i=e("snap.util.getattr.fill",this,!0).firstDefined();return t(t.deurl(i))||i}}))(-1),e.on("snap.util.getattr.stroke",(function(n){if(!n){e.stop();var i=e("snap.util.getattr.stroke",this,!0).firstDefined();return t(t.deurl(i))||i}}))(-1),e.on("snap.util.getattr.viewBox",(function(){e.stop();var n=d(this.node,"viewBox");return n?(n=n.split(m),t._.box(+n[0],+n[1],+n[2],+n[3])):void 0}))(-1),e.on("snap.util.getattr.points",(function(){var t=d(this.node,"points");return e.stop(),t?t.split(m):void 0}))(-1),e.on("snap.util.getattr.path",(function(){var t=d(this.node,"d");return e.stop(),t}))(-1),e.on("snap.util.getattr.class",(function(){return this.node.className.baseVal}))(-1),e.on("snap.util.getattr.fontSize",x)(-1),e.on("snap.util.getattr.font-size",x)(-1)})),i.plugin((function(t,e,n,i,r){var s=/\S+/g,o=String,a=e.prototype;a.addClass=function(t){var e,n,i,r=o(t||"").match(s)||[],a=this.node,l=a.className.baseVal,h=l.match(s)||[];if(r.length){for(e=0;n=r[e++];)~h.indexOf(n)||h.push(n);l!=(i=h.join(" "))&&(a.className.baseVal=i)}return this},a.removeClass=function(t){var e,n,i,r,a=o(t||"").match(s)||[],l=this.node,h=l.className.baseVal,c=h.match(s)||[];if(c.length){for(e=0;i=a[e++];)~(n=c.indexOf(i))&&c.splice(n,1);h!=(r=c.join(" "))&&(l.className.baseVal=r)}return this},a.hasClass=function(t){return!!~(this.node.className.baseVal.match(s)||[]).indexOf(t)},a.toggleClass=function(t,e){if(null!=e)return e?this.addClass(t):this.removeClass(t);var n,i,r,o,a=(t||"").match(s)||[],l=this.node,h=l.className.baseVal,c=h.match(s)||[];for(n=0;r=a[n++];)~(i=c.indexOf(r))?c.splice(i,1):c.push(r);return h!=(o=c.join(" "))&&(l.className.baseVal=o),this}})),i.plugin((function(t,n,i,r,s){var o={"+":function(t,e){return t+e},"-":function(t,e){return t-e},"/":function(t,e){return t/e},"*":function(t,e){return t*e}},a=String,l=/[a-z]+$/i,h=/^\s*([+\-\/*])\s*=\s*([\d.eE+\-]+)\s*([^\d\s]+)?\s*$/;function c(t){return t}function u(t){return function(e){return+e.toFixed(3)+t}}e.on("snap.util.attr",(function(t){var n=a(t).match(h);if(n){var i=e.nt(),r=i.substring(i.lastIndexOf(".")+1),s=this.attr(r),c={};e.stop();var u=n[3]||"",d=s.match(l),p=o[n[1]];if(d&&d==u?t=p(parseFloat(s),+n[2]):(s=this.asPX(r),t=p(this.asPX(r),this.asPX(r,n[2]+u))),isNaN(s)||isNaN(t))return;c[r]=t,this.attr(c)}}))(-10),e.on("snap.util.equal",(function(t,n){var i=a(this.attr(t)||""),r=a(n).match(h);if(r){e.stop();var s=r[3]||"",d=i.match(l),p=o[r[1]];return d&&d==s?{from:parseFloat(i),to:p(parseFloat(i),+r[2]),f:u(d)}:{from:i=this.asPX(t),to:p(i,this.asPX(t,r[2]+s)),f:c}}}))(-10)})),i.plugin((function(n,i,r,s,o){var a=r.prototype,l=n.is;a.rect=function(t,e,n,i,r,s){var o;return null==s&&(s=r),l(t,"object")&&"[object Object]"==t?o=t:null!=t&&(o={x:t,y:e,width:n,height:i},null!=r&&(o.rx=r,o.ry=s)),this.el("rect",o)},a.circle=function(t,e,n){var i;return l(t,"object")&&"[object Object]"==t?i=t:null!=t&&(i={cx:t,cy:e,r:n}),this.el("circle",i)};var h=function(){function t(){this.parentNode.removeChild(this)}return function(e,n){var i=s.doc.createElement("img"),r=s.doc.body;i.style.cssText="position:absolute;left:-9999em;top:-9999em",i.onload=function(){n.call(i),i.onload=i.onerror=null,r.removeChild(i)},i.onerror=t,r.appendChild(i),i.src=e}}();a.image=function(t,e,i,r,s){var o=this.el("image");if(l(t,"object")&&"src"in t)o.attr(t);else if(null!=t){var a={"xlink:href":t,preserveAspectRatio:"none"};null!=e&&null!=i&&(a.x=e,a.y=i),null!=r&&null!=s?(a.width=r,a.height=s):h(t,(function(){n._.$(o.node,{width:this.offsetWidth,height:this.offsetHeight})})),n._.$(o.node,a)}return o},a.ellipse=function(t,e,n,i){var r;return l(t,"object")&&"[object Object]"==t?r=t:null!=t&&(r={cx:t,cy:e,rx:n,ry:i}),this.el("ellipse",r)},a.path=function(t){var e;return l(t,"object")&&!l(t,"array")?e=t:t&&(e={d:t}),this.el("path",e)},a.group=a.g=function(t){var e=this.el("g");return 1==arguments.length&&t&&!t.type?e.attr(t):arguments.length&&e.add(Array.prototype.slice.call(arguments,0)),e},a.svg=function(t,e,n,i,r,s,o,a){var h={};return l(t,"object")&&null==e?h=t:(null!=t&&(h.x=t),null!=e&&(h.y=e),null!=n&&(h.width=n),null!=i&&(h.height=i),null!=r&&null!=s&&null!=o&&null!=a&&(h.viewBox=[r,s,o,a])),this.el("svg",h)},a.mask=function(t){var e=this.el("mask");return 1==arguments.length&&t&&!t.type?e.attr(t):arguments.length&&e.add(Array.prototype.slice.call(arguments,0)),e},a.ptrn=function(t,e,n,i,r,s,o,a){if(l(t,"object"))var h=t;else h={patternUnits:"userSpaceOnUse"},t&&(h.x=t),e&&(h.y=e),null!=n&&(h.width=n),null!=i&&(h.height=i),h.viewBox=null!=r&&null!=s&&null!=o&&null!=a?[r,s,o,a]:[t||0,e||0,n||0,i||0];return this.el("pattern",h)},a.use=function(t){return null!=t?(t instanceof i&&(t.attr("id")||t.attr({id:n._.id(t)}),t=t.attr("id")),"#"==String(t).charAt()&&(t=t.substring(1)),this.el("use",{"xlink:href":"#"+t})):i.prototype.use.call(this)},a.symbol=function(t,e,n,i){var r={};return null!=t&&null!=e&&null!=n&&null!=i&&(r.viewBox=[t,e,n,i]),this.el("symbol",r)},a.text=function(t,e,n){var i={};return l(t,"object")?i=t:null!=t&&(i={x:t,y:e,text:n||""}),this.el("text",i)},a.line=function(t,e,n,i){var r={};return l(t,"object")?r=t:null!=t&&(r={x1:t,x2:n,y1:e,y2:i}),this.el("line",r)},a.polyline=function(t){arguments.length>1&&(t=Array.prototype.slice.call(arguments,0));var e={};return l(t,"object")&&!l(t,"array")?e=t:null!=t&&(e={points:t}),this.el("polyline",e)},a.polygon=function(t){arguments.length>1&&(t=Array.prototype.slice.call(arguments,0));var e={};return l(t,"object")&&!l(t,"array")?e=t:null!=t&&(e={points:t}),this.el("polygon",e)},function(){var i=n._.$;function r(){return this.selectAll("stop")}function s(t,e){var r=i("stop"),s={offset:+e+"%"};t=n.color(t),s["stop-color"]=t.hex,t.opacity<1&&(s["stop-opacity"]=t.opacity),i(r,s);for(var o,a=this.stops(),l=0;l<a.length;l++)if(parseFloat(a[l].attr("offset"))>e){this.node.insertBefore(r,a[l].node),o=!0;break}return o||this.node.appendChild(r),this}function o(){if("linearGradient"==this.type){var t=i(this.node,"x1")||0,e=i(this.node,"x2")||1,r=i(this.node,"y1")||0,s=i(this.node,"y2")||0;return n._.box(t,r,math.abs(e-t),math.abs(s-r))}var o=this.node.cx||.5,a=this.node.cy||.5,l=this.node.r||0;return n._.box(o-l,a-l,2*l,2*l)}function l(t){var i=t,r=this.stops();if("string"==typeof t&&(i=e("snap.util.grad.parse",null,"l(0,0,0,1)"+t).firstDefined().stops),n.is(i,"array")){for(var s=0;s<r.length;s++)if(i[s]){var o=n.color(i[s].color),a={offset:i[s].offset+"%"};a["stop-color"]=o.hex,o.opacity<1&&(a["stop-opacity"]=o.opacity),r[s].attr(a)}else r[s].remove();for(s=r.length;s<i.length;s++)this.addStop(i[s].color,i[s].offset);return this}}function h(t,e,a,h,c){var u=n._.make("linearGradient",t);return u.stops=r,u.addStop=s,u.getBBox=o,u.setStops=l,null!=e&&i(u.node,{x1:e,y1:a,x2:h,y2:c}),u}function c(t,e,a,l,h,c){var u=n._.make("radialGradient",t);return u.stops=r,u.addStop=s,u.getBBox=o,null!=e&&i(u.node,{cx:e,cy:a,r:l}),null!=h&&null!=c&&i(u.node,{fx:h,fy:c}),u}a.gradient=function(t){return function(t,n){var r,s=e("snap.util.grad.parse",null,n).firstDefined();if(!s)return null;s.params.unshift(t),r="l"==s.type.toLowerCase()?h.apply(0,s.params):c.apply(0,s.params),s.type!=s.type.toLowerCase()&&i(r.node,{gradientUnits:"userSpaceOnUse"});for(var o=s.stops,a=o.length,l=0;l<a;l++){var u=o[l];r.addStop(u.color,u.offset)}return r}(this.defs,t)},a.gradientLinear=function(t,e,n,i){return h(this.defs,t,e,n,i)},a.gradientRadial=function(t,e,n,i,r){return c(this.defs,t,e,n,i,r)},a.toString=function(){var t,e=this.node.ownerDocument,i=e.createDocumentFragment(),r=e.createElement("div"),s=this.node.cloneNode(!0);return i.appendChild(r),r.appendChild(s),n._.$(s,{xmlns:"http://www.w3.org/2000/svg"}),t=r.innerHTML,i.removeChild(i.firstChild),t},a.toDataURL=function(){if(t&&t.btoa)return"data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(this)))},a.clear=function(){for(var t,e=this.node.firstChild;e;)t=e.nextSibling,"defs"!=e.tagName?e.parentNode.removeChild(e):a.clear.call({node:e}),e=t}}()})),i.plugin((function(t,e,n,i){var r=e.prototype,s=t.is,o=t._.clone,a=/,?([a-z]),?/gi,l=parseFloat,h=Math,c=h.PI,u=h.min,d=h.max,p=h.pow,f=h.abs;function m(t){var e=m.ps=m.ps||{};return e[t]?e[t].sleep=100:e[t]={sleep:100},setTimeout((function(){for(var n in e)e.hasOwnProperty(n)&&n!=t&&(e[n].sleep--,!e[n].sleep&&delete e[n])})),e[t]}function g(t,e,n,i){return null==t&&(t=e=n=i=0),null==e&&(e=t.y,n=t.width,i=t.height,t=t.x),{x:t,y:e,width:n,w:n,height:i,h:i,x2:t+n,y2:e+i,cx:t+n/2,cy:e+i/2,r1:h.min(n,i)/2,r2:h.max(n,i)/2,r0:h.sqrt(n*n+i*i)/2,path:O(t,e,n,i),vb:[t,e,n,i].join(" ")}}function v(){return this.join(",").replace(a,"$1")}function y(t){var e=o(t);return e.toString=v,e}function x(t,e,n,i,r,s,o,a,l){return null==l?C(t,e,n,i,r,s,o,a):E(t,e,n,i,r,s,o,a,function(t,e,n,i,r,s,o,a,l){if(!(l<0||C(t,e,n,i,r,s,o,a)<l)){var h,c=.5,u=1-c;for(h=C(t,e,n,i,r,s,o,a,u);f(h-l)>.01;)h=C(t,e,n,i,r,s,o,a,u+=(h<l?1:-1)*(c/=2));return u}}(t,e,n,i,r,s,o,a,l))}function b(n,i){function r(t){return+(+t).toFixed(3)}return t._.cacher((function(t,s,o){t instanceof e&&(t=t.attr("d"));for(var a,l,h,c,u,d="",p={},f=0,m=0,g=(t=G(t)).length;m<g;m++){if("M"==(h=t[m])[0])a=+h[1],l=+h[2];else{if(f+(c=x(a,l,h[1],h[2],h[3],h[4],h[5],h[6]))>s){if(i&&!p.start){if(d+=["C"+r((u=x(a,l,h[1],h[2],h[3],h[4],h[5],h[6],s-f)).start.x),r(u.start.y),r(u.m.x),r(u.m.y),r(u.x),r(u.y)],o)return d;p.start=d,d=["M"+r(u.x),r(u.y)+"C"+r(u.n.x),r(u.n.y),r(u.end.x),r(u.end.y),r(h[5]),r(h[6])].join(),f+=c,a=+h[5],l=+h[6];continue}if(!n&&!i)return u=x(a,l,h[1],h[2],h[3],h[4],h[5],h[6],s-f)}f+=c,a=+h[5],l=+h[6]}d+=h.shift()+h}return p.end=d,u=n?f:i?p:E(a,l,h[0],h[1],h[2],h[3],h[4],h[5],1)}),null,t._.clone)}var w=b(1),M=b(),_=b(0,1);function E(t,e,n,i,r,s,o,a,l){var u=1-l,d=p(u,3),f=p(u,2),m=l*l,g=m*l,v=t+2*l*(n-t)+m*(r-2*n+t),y=e+2*l*(i-e)+m*(s-2*i+e),x=n+2*l*(r-n)+m*(o-2*r+n),b=i+2*l*(s-i)+m*(a-2*s+i);return{x:d*t+3*f*l*n+3*u*l*l*r+g*o,y:d*e+3*f*l*i+3*u*l*l*s+g*a,m:{x:v,y:y},n:{x:x,y:b},start:{x:u*t+l*n,y:u*e+l*i},end:{x:u*r+l*o,y:u*s+l*a},alpha:90-180*h.atan2(v-x,y-b)/c}}function T(e,n,i,r,s,o,a,l){t.is(e,"array")||(e=[e,n,i,r,s,o,a,l]);var h=H.apply(null,e);return g(h.min.x,h.min.y,h.max.x-h.min.x,h.max.y-h.min.y)}function S(t,e,n){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function A(t,e){return t=g(t),S(e=g(e),t.x,t.y)||S(e,t.x2,t.y)||S(e,t.x,t.y2)||S(e,t.x2,t.y2)||S(t,e.x,e.y)||S(t,e.x2,e.y)||S(t,e.x,e.y2)||S(t,e.x2,e.y2)||(t.x<e.x2&&t.x>e.x||e.x<t.x2&&e.x>t.x)&&(t.y<e.y2&&t.y>e.y||e.y<t.y2&&e.y>t.y)}function P(t,e,n,i,r){return t*(t*(-3*e+9*n-9*i+3*r)+6*e-12*n+6*i)-3*e+3*n}function C(t,e,n,i,r,s,o,a,l){null==l&&(l=1);for(var c=(l=l>1?1:l<0?0:l)/2,u=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],d=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],p=0,f=0;f<12;f++){var m=c*u[f]+c,g=P(m,t,n,r,o),v=P(m,e,i,s,a),y=g*g+v*v;p+=d[f]*h.sqrt(y)}return c*p}function L(t,e,n,i,r,s,o,a){if(!(d(t,n)<u(r,o)||u(t,n)>d(r,o)||d(e,i)<u(s,a)||u(e,i)>d(s,a))){var l=(t-n)*(s-a)-(e-i)*(r-o);if(l){var h=((t*i-e*n)*(r-o)-(t-n)*(r*a-s*o))/l,c=((t*i-e*n)*(s-a)-(e-i)*(r*a-s*o))/l,p=+h.toFixed(2),f=+c.toFixed(2);if(!(p<+u(t,n).toFixed(2)||p>+d(t,n).toFixed(2)||p<+u(r,o).toFixed(2)||p>+d(r,o).toFixed(2)||f<+u(e,i).toFixed(2)||f>+d(e,i).toFixed(2)||f<+u(s,a).toFixed(2)||f>+d(s,a).toFixed(2)))return{x:h,y:c}}}}function R(t,e,n){if(!A(T(t),T(e)))return n?0:[];for(var i=~~(C.apply(0,t)/8),r=~~(C.apply(0,e)/8),s=[],o=[],a={},l=n?0:[],h=0;h<i+1;h++){var c=E.apply(0,t.concat(h/i));s.push({x:c.x,y:c.y,t:h/i})}for(h=0;h<r+1;h++)c=E.apply(0,e.concat(h/r)),o.push({x:c.x,y:c.y,t:h/r});for(h=0;h<i;h++)for(var u=0;u<r;u++){var d=s[h],p=s[h+1],m=o[u],g=o[u+1],v=f(p.x-d.x)<.001?"y":"x",y=f(g.x-m.x)<.001?"y":"x",x=L(d.x,d.y,p.x,p.y,m.x,m.y,g.x,g.y);if(x){if(a[x.x.toFixed(4)]==x.y.toFixed(4))continue;a[x.x.toFixed(4)]=x.y.toFixed(4);var b=d.t+f((x[v]-d[v])/(p[v]-d[v]))*(p.t-d.t),w=m.t+f((x[y]-m[y])/(g[y]-m[y]))*(g.t-m.t);b>=0&&b<=1&&w>=0&&w<=1&&(n?l++:l.push({x:x.x,y:x.y,t1:b,t2:w}))}}return l}function I(t,e,n){t=G(t),e=G(e);for(var i,r,s,o,a,l,h,c,u,d,p=n?0:[],f=0,m=t.length;f<m;f++){var g=t[f];if("M"==g[0])i=a=g[1],r=l=g[2];else{"C"==g[0]?(u=[i,r].concat(g.slice(1)),i=u[6],r=u[7]):(u=[i,r,i,r,a,l,a,l],i=a,r=l);for(var v=0,y=e.length;v<y;v++){var x=e[v];if("M"==x[0])s=h=x[1],o=c=x[2];else{"C"==x[0]?(d=[s,o].concat(x.slice(1)),s=d[6],o=d[7]):(d=[s,o,s,o,h,c,h,c],s=h,o=c);var b=R(u,d,n);if(n)p+=b;else{for(var w=0,M=b.length;w<M;w++)b[w].segment1=f,b[w].segment2=v,b[w].bez1=u,b[w].bez2=d;p=p.concat(b)}}}}}return p}function D(t){var e=m(t);if(e.bbox)return o(e.bbox);if(!t)return g();for(var n,i=0,r=0,s=[],a=[],l=0,h=(t=G(t)).length;l<h;l++)if("M"==(n=t[l])[0])i=n[1],r=n[2],s.push(i),a.push(r);else{var c=H(i,r,n[1],n[2],n[3],n[4],n[5],n[6]);s=s.concat(c.min.x,c.max.x),a=a.concat(c.min.y,c.max.y),i=n[5],r=n[6]}var p=u.apply(0,s),f=u.apply(0,a),v=g(p,f,d.apply(0,s)-p,d.apply(0,a)-f);return e.bbox=o(v),v}function O(t,e,n,i,r){if(r)return[["M",+t+ +r,e],["l",n-2*r,0],["a",r,r,0,0,1,r,r],["l",0,i-2*r],["a",r,r,0,0,1,-r,r],["l",2*r-n,0],["a",r,r,0,0,1,-r,-r],["l",0,2*r-i],["a",r,r,0,0,1,r,-r],["z"]];var s=[["M",t,e],["l",n,0],["l",0,i],["l",-n,0],["z"]];return s.toString=v,s}function F(t,e,n,i,r){if(null==r&&null==i&&(i=n),t=+t,e=+e,n=+n,i=+i,null!=r)var s=Math.PI/180,o=t+n*Math.cos(-i*s),a=t+n*Math.cos(-r*s),l=[["M",o,e+n*Math.sin(-i*s)],["A",n,n,0,+(r-i>180),0,a,e+n*Math.sin(-r*s)]];else l=[["M",t,e],["m",0,-i],["a",n,i,0,1,1,0,2*i],["a",n,i,0,1,1,0,-2*i],["z"]];return l.toString=v,l}var B=t._unit2px,N={path:function(t){return t.attr("path")},circle:function(t){var e=B(t);return F(e.cx,e.cy,e.r)},ellipse:function(t){var e=B(t);return F(e.cx||0,e.cy||0,e.rx,e.ry)},rect:function(t){var e=B(t);return O(e.x||0,e.y||0,e.width,e.height,e.rx,e.ry)},image:function(t){var e=B(t);return O(e.x||0,e.y||0,e.width,e.height)},line:function(t){return"M"+[t.attr("x1")||0,t.attr("y1")||0,t.attr("x2"),t.attr("y2")]},polyline:function(t){return"M"+t.attr("points")},polygon:function(t){return"M"+t.attr("points")+"z"},deflt:function(t){var e=t.node.getBBox();return O(e.x,e.y,e.width,e.height)}};function z(e){var n=m(e);if(n.abs)return y(n.abs);if(s(e,"array")&&s(e&&e[0],"array")||(e=t.parsePathString(e)),!e||!e.length)return[["M",0,0]];var i,r=[],o=0,a=0,l=0,h=0,c=0;"M"==e[0][0]&&(l=o=+e[0][1],h=a=+e[0][2],c++,r[0]=["M",o,a]);for(var u,d,p=3==e.length&&"M"==e[0][0]&&"R"==e[1][0].toUpperCase()&&"Z"==e[2][0].toUpperCase(),f=c,g=e.length;f<g;f++){if(r.push(u=[]),(i=(d=e[f])[0])!=i.toUpperCase())switch(u[0]=i.toUpperCase(),u[0]){case"A":u[1]=d[1],u[2]=d[2],u[3]=d[3],u[4]=d[4],u[5]=d[5],u[6]=+d[6]+o,u[7]=+d[7]+a;break;case"V":u[1]=+d[1]+a;break;case"H":u[1]=+d[1]+o;break;case"R":for(var x=[o,a].concat(d.slice(1)),b=2,w=x.length;b<w;b++)x[b]=+x[b]+o,x[++b]=+x[b]+a;r.pop(),r=r.concat(W(x,p));break;case"O":r.pop(),(x=F(o,a,d[1],d[2])).push(x[0]),r=r.concat(x);break;case"U":r.pop(),r=r.concat(F(o,a,d[1],d[2],d[3])),u=["U"].concat(r[r.length-1].slice(-2));break;case"M":l=+d[1]+o,h=+d[2]+a;default:for(b=1,w=d.length;b<w;b++)u[b]=+d[b]+(b%2?o:a)}else if("R"==i)x=[o,a].concat(d.slice(1)),r.pop(),r=r.concat(W(x,p)),u=["R"].concat(d.slice(-2));else if("O"==i)r.pop(),(x=F(o,a,d[1],d[2])).push(x[0]),r=r.concat(x);else if("U"==i)r.pop(),r=r.concat(F(o,a,d[1],d[2],d[3])),u=["U"].concat(r[r.length-1].slice(-2));else for(var M=0,_=d.length;M<_;M++)u[M]=d[M];if("O"!=(i=i.toUpperCase()))switch(u[0]){case"Z":o=+l,a=+h;break;case"H":o=u[1];break;case"V":a=u[1];break;case"M":l=u[u.length-2],h=u[u.length-1];default:o=u[u.length-2],a=u[u.length-1]}}return r.toString=v,n.abs=y(r),r}function U(t,e,n,i){return[t,e,n,i,n,i]}function k(t,e,n,i,r,s){return[1/3*t+2/3*n,1/3*e+2/3*i,1/3*r+2/3*n,1/3*s+2/3*i,r,s]}function V(e,n,i,r,s,o,a,l,u,d){var p,m=120*c/180,g=c/180*(+s||0),v=[],y=t._.cacher((function(t,e,n){return{x:t*h.cos(n)-e*h.sin(n),y:t*h.sin(n)+e*h.cos(n)}}));if(!i||!r)return[e,n,l,u,l,u];if(d)A=d[0],P=d[1],T=d[2],S=d[3];else{e=(p=y(e,n,-g)).x,n=p.y;var x=(e-(l=(p=y(l,u,-g)).x))/2,b=(n-(u=p.y))/2,w=x*x/(i*i)+b*b/(r*r);w>1&&(i*=w=h.sqrt(w),r*=w);var M=i*i,_=r*r,E=(o==a?-1:1)*h.sqrt(f((M*_-M*b*b-_*x*x)/(M*b*b+_*x*x))),T=E*i*b/r+(e+l)/2,S=E*-r*x/i+(n+u)/2,A=h.asin(((n-S)/r).toFixed(9)),P=h.asin(((u-S)/r).toFixed(9));(A=e<T?c-A:A)<0&&(A=2*c+A),(P=l<T?c-P:P)<0&&(P=2*c+P),a&&A>P&&(A-=2*c),!a&&P>A&&(P-=2*c)}var C=P-A;if(f(C)>m){var L=P,R=l,I=u;P=A+m*(a&&P>A?1:-1),v=V(l=T+i*h.cos(P),u=S+r*h.sin(P),i,r,s,0,a,R,I,[P,L,T,S])}C=P-A;var D=h.cos(A),O=h.sin(A),F=h.cos(P),B=h.sin(P),N=h.tan(C/4),z=4/3*i*N,U=4/3*r*N,k=[e,n],H=[e+z*O,n-U*D],G=[l+z*B,u-U*F],W=[l,u];if(H[0]=2*k[0]-H[0],H[1]=2*k[1]-H[1],d)return[H,G,W].concat(v);for(var j=[],X=0,q=(v=[H,G,W].concat(v).join().split(",")).length;X<q;X++)j[X]=X%2?y(v[X-1],v[X],g).y:y(v[X],v[X+1],g).x;return j}function H(t,e,n,i,r,s,o,a){for(var l,c,p,m,g,v,y,x,b=[],w=[[],[]],M=0;M<2;++M)if(0==M?(c=6*t-12*n+6*r,l=-3*t+9*n-9*r+3*o,p=3*n-3*t):(c=6*e-12*i+6*s,l=-3*e+9*i-9*s+3*a,p=3*i-3*e),f(l)<1e-12){if(f(c)<1e-12)continue;0<(m=-p/c)&&m<1&&b.push(m)}else y=c*c-4*p*l,x=h.sqrt(y),y<0||(0<(g=(-c+x)/(2*l))&&g<1&&b.push(g),0<(v=(-c-x)/(2*l))&&v<1&&b.push(v));for(var _,E=b.length,T=E;E--;)_=1-(m=b[E]),w[0][E]=_*_*_*t+3*_*_*m*n+3*_*m*m*r+m*m*m*o,w[1][E]=_*_*_*e+3*_*_*m*i+3*_*m*m*s+m*m*m*a;return w[0][T]=t,w[1][T]=e,w[0][T+1]=o,w[1][T+1]=a,w[0].length=w[1].length=T+2,{min:{x:u.apply(0,w[0]),y:u.apply(0,w[1])},max:{x:d.apply(0,w[0]),y:d.apply(0,w[1])}}}function G(t,e){var n=!e&&m(t);if(!e&&n.curve)return y(n.curve);for(var i=z(t),r=e&&z(e),s={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},o={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},a=function(t,e,n){var i,r;if(!t)return["C",e.x,e.y,e.x,e.y,e.x,e.y];switch(!(t[0]in{T:1,Q:1})&&(e.qx=e.qy=null),t[0]){case"M":e.X=t[1],e.Y=t[2];break;case"A":t=["C"].concat(V.apply(0,[e.x,e.y].concat(t.slice(1))));break;case"S":"C"==n||"S"==n?(i=2*e.x-e.bx,r=2*e.y-e.by):(i=e.x,r=e.y),t=["C",i,r].concat(t.slice(1));break;case"T":"Q"==n||"T"==n?(e.qx=2*e.x-e.qx,e.qy=2*e.y-e.qy):(e.qx=e.x,e.qy=e.y),t=["C"].concat(k(e.x,e.y,e.qx,e.qy,t[1],t[2]));break;case"Q":e.qx=t[1],e.qy=t[2],t=["C"].concat(k(e.x,e.y,t[1],t[2],t[3],t[4]));break;case"L":t=["C"].concat(U(e.x,e.y,t[1],t[2]));break;case"H":t=["C"].concat(U(e.x,e.y,t[1],e.y));break;case"V":t=["C"].concat(U(e.x,e.y,e.x,t[1]));break;case"Z":t=["C"].concat(U(e.x,e.y,e.X,e.Y))}return t},h=function(t,e){if(t[e].length>7){t[e].shift();for(var n=t[e];n.length;)u[e]="A",r&&(p[e]="A"),t.splice(e++,0,["C"].concat(n.splice(0,6)));t.splice(e,1),x=d(i.length,r&&r.length||0)}},c=function(t,e,n,s,o){t&&e&&"M"==t[o][0]&&"M"!=e[o][0]&&(e.splice(o,0,["M",s.x,s.y]),n.bx=0,n.by=0,n.x=t[o][1],n.y=t[o][2],x=d(i.length,r&&r.length||0))},u=[],p=[],f="",g="",v=0,x=d(i.length,r&&r.length||0);v<x;v++){i[v]&&(f=i[v][0]),"C"!=f&&(u[v]=f,v&&(g=u[v-1])),i[v]=a(i[v],s,g),"A"!=u[v]&&"C"==f&&(u[v]="C"),h(i,v),r&&(r[v]&&(f=r[v][0]),"C"!=f&&(p[v]=f,v&&(g=p[v-1])),r[v]=a(r[v],o,g),"A"!=p[v]&&"C"==f&&(p[v]="C"),h(r,v)),c(i,r,s,o,v),c(r,i,o,s,v);var b=i[v],w=r&&r[v],M=b.length,_=r&&w.length;s.x=b[M-2],s.y=b[M-1],s.bx=l(b[M-4])||s.x,s.by=l(b[M-3])||s.y,o.bx=r&&(l(w[_-4])||o.x),o.by=r&&(l(w[_-3])||o.y),o.x=r&&w[_-2],o.y=r&&w[_-1]}return r||(n.curve=y(i)),r?[i,r]:i}function W(t,e){for(var n=[],i=0,r=t.length;r-2*!e>i;i+=2){var s=[{x:+t[i-2],y:+t[i-1]},{x:+t[i],y:+t[i+1]},{x:+t[i+2],y:+t[i+3]},{x:+t[i+4],y:+t[i+5]}];e?i?r-4==i?s[3]={x:+t[0],y:+t[1]}:r-2==i&&(s[2]={x:+t[0],y:+t[1]},s[3]={x:+t[2],y:+t[3]}):s[0]={x:+t[r-2],y:+t[r-1]}:r-4==i?s[3]=s[2]:i||(s[0]={x:+t[i],y:+t[i+1]}),n.push(["C",(-s[0].x+6*s[1].x+s[2].x)/6,(-s[0].y+6*s[1].y+s[2].y)/6,(s[1].x+6*s[2].x-s[3].x)/6,(s[1].y+6*s[2].y-s[3].y)/6,s[2].x,s[2].y])}return n}t.path=m,t.path.getTotalLength=w,t.path.getPointAtLength=M,t.path.getSubpath=function(t,e,n){if(this.getTotalLength(t)-n<1e-6)return _(t,e).end;var i=_(t,n,1);return e?_(i,e).end:i},r.getTotalLength=function(){if(this.node.getTotalLength)return this.node.getTotalLength()},r.getPointAtLength=function(t){return M(this.attr("d"),t)},r.getSubpath=function(e,n){return t.path.getSubpath(this.attr("d"),e,n)},t._.box=g,t.path.findDotsAtSegment=E,t.path.bezierBBox=T,t.path.isPointInsideBBox=S,t.closest=function(e,n,i,r){for(var s=100,o=g(e-s/2,n-s/2,s,s),a=[],l=i[0].hasOwnProperty("x")?function(t){return{x:i[t].x,y:i[t].y}}:function(t){return{x:i[t],y:r[t]}},h=0;s<=1e6&&!h;){for(var c=0,u=i.length;c<u;c++){var d=l(c);if(S(o,d.x,d.y)){h++,a.push(d);break}}h||(o=g(e-(s*=2)/2,n-s/2,s,s))}if(1e6!=s){var p,f=1/0;for(c=0,u=a.length;c<u;c++){var m=t.len(e,n,a[c].x,a[c].y);f>m&&(f=m,a[c].len=m,p=a[c])}return p}},t.path.isBBoxIntersect=A,t.path.intersection=function(t,e){return I(t,e)},t.path.intersectionNumber=function(t,e){return I(t,e,1)},t.path.isPointInside=function(t,e,n){var i=D(t);return S(i,e,n)&&I(t,[["M",e,n],["H",i.x2+10]],1)%2==1},t.path.getBBox=D,t.path.get=N,t.path.toRelative=function(e){var n=m(e),i=String.prototype.toLowerCase;if(n.rel)return y(n.rel);t.is(e,"array")&&t.is(e&&e[0],"array")||(e=t.parsePathString(e));var r=[],s=0,o=0,a=0,l=0,h=0;"M"==e[0][0]&&(a=s=e[0][1],l=o=e[0][2],h++,r.push(["M",s,o]));for(var c=h,u=e.length;c<u;c++){var d=r[c]=[],p=e[c];if(p[0]!=i.call(p[0]))switch(d[0]=i.call(p[0]),d[0]){case"a":d[1]=p[1],d[2]=p[2],d[3]=p[3],d[4]=p[4],d[5]=p[5],d[6]=+(p[6]-s).toFixed(3),d[7]=+(p[7]-o).toFixed(3);break;case"v":d[1]=+(p[1]-o).toFixed(3);break;case"m":a=p[1],l=p[2];default:for(var f=1,g=p.length;f<g;f++)d[f]=+(p[f]-(f%2?s:o)).toFixed(3)}else{d=r[c]=[],"m"==p[0]&&(a=p[1]+s,l=p[2]+o);for(var x=0,b=p.length;x<b;x++)r[c][x]=p[x]}var w=r[c].length;switch(r[c][0]){case"z":s=a,o=l;break;case"h":s+=+r[c][w-1];break;case"v":o+=+r[c][w-1];break;default:s+=+r[c][w-2],o+=+r[c][w-1]}}return r.toString=v,n.rel=y(r),r},t.path.toAbsolute=z,t.path.toCubic=G,t.path.map=function(t,e){if(!e)return t;var n,i,r,s,o,a,l;for(r=0,o=(t=G(t)).length;r<o;r++)for(s=1,a=(l=t[r]).length;s<a;s+=2)n=e.x(l[s],l[s+1]),i=e.y(l[s],l[s+1]),l[s]=n,l[s+1]=i;return t},t.path.toString=v,t.path.clone=y})),i.plugin((function(t,i,r,s){var o=Math.max,a=Math.min,l=function(t){if(this.items=[],this.bindings={},this.length=0,this.type="set",t)for(var e=0,n=t.length;e<n;e++)t[e]&&(this[this.items.length]=this.items[this.items.length]=t[e],this.length++)},h=l.prototype;h.push=function(){for(var t,e,n=0,i=arguments.length;n<i;n++)(t=arguments[n])&&(this[e=this.items.length]=this.items[e]=t,this.length++);return this},h.pop=function(){return this.length&&delete this[this.length--],this.items.pop()},h.forEach=function(t,e){for(var n=0,i=this.items.length;n<i;n++)if(!1===t.call(e,this.items[n],n))return this;return this},h.animate=function(i,r,s,o){"function"!=typeof s||s.length||(o=s,s=n.linear),i instanceof t._.Animation&&(o=i.callback,s=i.easing,r=s.dur,i=i.attr);var a=arguments;if(t.is(i,"array")&&t.is(a[a.length-1],"array"))var l=!0;var h,c=function(){h?this.b=h:h=this.b},u=0,d=this,p=o&&function(){++u==d.length&&o.call(this)};return this.forEach((function(t,n){e.once("snap.animcreated."+t.id,c),l?a[n]&&t.animate.apply(t,a[n]):t.animate(i,r,s,p)}))},h.remove=function(){for(;this.length;)this.pop().remove();return this},h.bind=function(t,e,n){var i={};if("function"==typeof e)this.bindings[t]=e;else{var r=n||t;this.bindings[t]=function(t){i[r]=t,e.attr(i)}}return this},h.attr=function(t){var e={};for(var n in t)this.bindings[n]?this.bindings[n](t[n]):e[n]=t[n];for(var i=0,r=this.items.length;i<r;i++)this.items[i].attr(e);return this},h.clear=function(){for(;this.length;)this.pop()},h.splice=function(t,e,n){t=t<0?o(this.length+t,0):t,e=o(0,a(this.length-t,e));var i,r=[],s=[],h=[];for(i=2;i<arguments.length;i++)h.push(arguments[i]);for(i=0;i<e;i++)s.push(this[t+i]);for(;i<this.length-t;i++)r.push(this[t+i]);var c=h.length;for(i=0;i<c+r.length;i++)this.items[t+i]=this[t+i]=i<c?h[i]:r[i-c];for(i=this.items.length=this.length-=e-c;this[i];)delete this[i++];return new l(s)},h.exclude=function(t){for(var e=0,n=this.length;e<n;e++)if(this[e]==t)return this.splice(e,1),!0;return!1},h.insertAfter=function(t){for(var e=this.items.length;e--;)this.items[e].insertAfter(t);return this},h.getBBox=function(){for(var t=[],e=[],n=[],i=[],r=this.items.length;r--;)if(!this.items[r].removed){var s=this.items[r].getBBox();t.push(s.x),e.push(s.y),n.push(s.x+s.width),i.push(s.y+s.height)}return{x:t=a.apply(0,t),y:e=a.apply(0,e),x2:n=o.apply(0,n),y2:i=o.apply(0,i),width:n-t,height:i-e,cx:t+(n-t)/2,cy:e+(i-e)/2}},h.clone=function(t){t=new l;for(var e=0,n=this.items.length;e<n;e++)t.push(this.items[e].clone());return t},h.toString=function(){return"Snap‘s set"},h.type="set",t.Set=l,t.set=function(){var t=new l;return arguments.length&&t.push.apply(t,Array.prototype.slice.call(arguments,0)),t}})),i.plugin((function(t,n,i,r){var s={},o=/[%a-z]+$/i,a=String;function l(t){var e=t[0];switch(e.toLowerCase()){case"t":return[e,0,0];case"m":return[e,1,0,0,1,0,0];case"r":return 4==t.length?[e,0,t[2],t[3]]:[e,0];case"s":return 5==t.length?[e,1,1,t[3],t[4]]:3==t.length?[e,1,1]:[e,1]}}function h(t){return t}function c(t){return t.join(" ")}function u(e){return t.rgb(e[0],e[1],e[2],e[3])}function d(t){var e,n,i,r,s,o,a=0,l=[];for(e=0,n=t.length;e<n;e++){for(s="[",o=['"'+t[e][0]+'"'],i=1,r=t[e].length;i<r;i++)o[i]="val["+a+++"]";s+=o+"]",l[e]=s}return Function("val","return Snap.path.toString.call(["+l+"])")}function p(t){for(var e=[],n=0,i=t.length;n<i;n++)for(var r=1,s=t[n].length;r<s;r++)e.push(t[n][r]);return e}function f(t){return isFinite(t)}s.stroke=s.fill="colour",n.prototype.equal=function(t,n){return e("snap.util.equal",this,t,n).firstDefined()},e.on("snap.util.equal",(function(e,n){var i,r,m=a(this.attr(e)||""),g=this;if("colour"==s[e])return i=t.color(m),r=t.color(n),{from:[i.r,i.g,i.b,i.opacity],to:[r.r,r.g,r.b,r.opacity],f:u};if("viewBox"==e)return{from:i=this.attr(e).vb.split(" ").map(Number),to:r=n.split(" ").map(Number),f:c};if("transform"==e||"gradientTransform"==e||"patternTransform"==e)return"string"==typeof n&&(n=a(n).replace(/\.{3}|\u2026/g,m)),function(e,n,i){e=e||new t.Matrix,n=n||new t.Matrix,e=t.parseTransformString(e.toTransformString())||[],n=t.parseTransformString(n.toTransformString())||[];for(var r,s,o,a,h=Math.max(e.length,n.length),c=[],u=[],f=0;f<h;f++){if(o=e[f]||l(n[f]),a=n[f]||l(o),o[0]!=a[0]||"r"==o[0].toLowerCase()&&(o[2]!=a[2]||o[3]!=a[3])||"s"==o[0].toLowerCase()&&(o[3]!=a[3]||o[4]!=a[4])){e=t._.transform2matrix(e,i()),n=t._.transform2matrix(n,i()),c=[["m",e.a,e.b,e.c,e.d,e.e,e.f]],u=[["m",n.a,n.b,n.c,n.d,n.e,n.f]];break}for(c[f]=[],u[f]=[],r=0,s=Math.max(o.length,a.length);r<s;r++)r in o&&(c[f][r]=o[r]),r in a&&(u[f][r]=a[r])}return{from:p(c),to:p(u),f:d(c)}}(m=this.matrix,n=t._.rgTransform.test(n)?t._.transform2matrix(n,this.getBBox()):t._.transform2matrix(t._.svgTransform2string(n),this.getBBox()),(function(){return g.getBBox(1)}));if("d"==e||"path"==e)return{from:p((i=t.path.toCubic(m,n))[0]),to:p(i[1]),f:d(i[0])};if("points"==e)return{from:i=a(m).split(t._.separator),to:r=a(n).split(t._.separator),f:function(t){return t}};if(f(m)&&f(n))return{from:parseFloat(m),to:parseFloat(n),f:h};var v,y,x,b=m.match(o),w=a(n).match(o);return b&&(y=b,x=w,t.is(y,"array")&&t.is(x,"array")&&y.toString()==x.toString())?{from:parseFloat(m),to:parseFloat(n),f:(v=b,function(t){return+t.toFixed(3)+v})}:{from:this.asPX(e),to:this.asPX(e,n),f:h}}))})),i.plugin((function(t,n,i,r){for(var s=n.prototype,o=("createTouch"in r.doc),a=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","touchstart","touchmove","touchend","touchcancel"],l={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},h=function(t,e){var n="y"==t?"scrollTop":"scrollLeft",i=e&&e.node?e.node.ownerDocument:r.doc;return i[n in i.documentElement?"documentElement":"body"][n]},c=function(){return this.originalEvent.preventDefault()},u=function(){return this.originalEvent.stopPropagation()},d=function(t,e,n,i){var r=o&&l[e]?l[e]:e,s=function(r){var s=h("y",i),a=h("x",i);if(o&&l.hasOwnProperty(e))for(var d=0,p=r.targetTouches&&r.targetTouches.length;d<p;d++)if(r.targetTouches[d].target==t||t.contains(r.targetTouches[d].target)){var f=r;(r=r.targetTouches[d]).originalEvent=f,r.preventDefault=c,r.stopPropagation=u;break}var m=r.clientX+a,g=r.clientY+s;return n.call(i,r,m,g)};return e!==r&&t.addEventListener(e,s,!1),t.addEventListener(r,s,!1),function(){return e!==r&&t.removeEventListener(e,s,!1),t.removeEventListener(r,s,!1),!0}},p=[],f=function(t){for(var n,i=t.clientX,r=t.clientY,s=h("y"),a=h("x"),l=p.length;l--;){if(n=p[l],o){for(var c,u=t.touches&&t.touches.length;u--;)if((c=t.touches[u]).identifier==n.el._drag.id||n.el.node.contains(c.target)){i=c.clientX,r=c.clientY,(t.originalEvent?t.originalEvent:t).preventDefault();break}}else t.preventDefault();var d=n.el.node;d.nextSibling,d.parentNode,d.style.display,i+=a,r+=s,e("snap.drag.move."+n.el.id,n.move_scope||n.el,i-n.el._drag.x,r-n.el._drag.y,i,r,t)}},m=function(n){t.unmousemove(f).unmouseup(m);for(var i,r=p.length;r--;)(i=p[r]).el._drag={},e("snap.drag.end."+i.el.id,i.end_scope||i.start_scope||i.move_scope||i.el,n),e.off("snap.drag.*."+i.el.id);p=[]},g=a.length;g--;)!function(e){t[e]=s[e]=function(n,i){if(t.is(n,"function"))this.events=this.events||[],this.events.push({name:e,f:n,unbind:d(this.node||document,e,n,i||this)});else for(var r=0,s=this.events.length;r<s;r++)if(this.events[r].name==e)try{this.events[r].f.call(this)}catch(t){}return this},t["un"+e]=s["un"+e]=function(t){for(var n=this.events||[],i=n.length;i--;)if(n[i].name==e&&(n[i].f==t||!t))return n[i].unbind(),n.splice(i,1),!n.length&&delete this.events,this;return this}}(a[g]);s.hover=function(t,e,n,i){return this.mouseover(t,n).mouseout(e,i||n)},s.unhover=function(t,e){return this.unmouseover(t).unmouseout(e)};var v=[];s.drag=function(n,i,r,s,o,a){var l,h=this;if(!arguments.length)return h.drag((function(t,e){this.attr({transform:l+(l?"T":"t")+[t,e]})}),(function(){l=this.transform().local}));function c(l,c,u){(l.originalEvent||l).preventDefault(),h._drag.x=c,h._drag.y=u,h._drag.id=l.identifier,!p.length&&t.mousemove(f).mouseup(m),p.push({el:h,move_scope:s,start_scope:o,end_scope:a}),i&&e.on("snap.drag.start."+h.id,i),n&&e.on("snap.drag.move."+h.id,n),r&&e.on("snap.drag.end."+h.id,r),e("snap.drag.start."+h.id,o||s||h,c,u,l)}function u(t,n,i){e("snap.draginit."+h.id,h,t,n,i)}return e.on("snap.draginit."+h.id,c),h._drag={},v.push({el:h,start:c,init:u}),h.mousedown(u),h},s.undrag=function(){for(var n=v.length;n--;)v[n].el==this&&(this.unmousedown(v[n].init),v.splice(n,1),e.unbind("snap.drag.*."+this.id),e.unbind("snap.draginit."+this.id));return!v.length&&t.unmousemove(f).unmouseup(m),this}})),i.plugin((function(t,n,i,r){n.prototype;var s=i.prototype,o=/^\s*url\((.+)\)/,a=String,l=t._.$;t.filter={},s.filter=function(e){var i=this;"svg"!=i.type&&(i=i.paper);var r=t.parse(a(e)),s=t._.id(),o=(i.node.offsetWidth,i.node.offsetHeight,l("filter"));return l(o,{id:s,filterUnits:"userSpaceOnUse"}),o.appendChild(r.node),i.defs.appendChild(o),new n(o)},e.on("snap.util.getattr.filter",(function(){e.stop();var n=l(this.node,"filter");if(n){var i=a(n).match(o);return i&&t.select(i[1])}})),e.on("snap.util.attr.filter",(function(i){if(i instanceof n&&"filter"==i.type){e.stop();var r=i.node.id;r||(l(i.node,{id:i.id}),r=i.id),l(this.node,{filter:t.url(r)})}i&&"none"!=i||(e.stop(),this.node.removeAttribute("filter"))})),t.filter.blur=function(e,n){null==e&&(e=2);var i=null==n?e:[e,n];return t.format('<feGaussianBlur stdDeviation="{def}"/>',{def:i})},t.filter.blur.toString=function(){return this()},t.filter.shadow=function(e,n,i,r,s){return null==s&&(null==r?(s=i,i=4,r="#000"):(s=r,r=i,i=4)),null==i&&(i=4),null==s&&(s=1),null==e&&(e=0,n=2),null==n&&(n=e),r=t.color(r),t.format('<feGaussianBlur in="SourceAlpha" stdDeviation="{blur}"/><feOffset dx="{dx}" dy="{dy}" result="offsetblur"/><feFlood flood-color="{color}"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="{opacity}"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>',{color:r,dx:e,dy:n,blur:i,opacity:s})},t.filter.shadow.toString=function(){return this()},t.filter.grayscale=function(e){return null==e&&(e=1),t.format('<feColorMatrix type="matrix" values="{a} {b} {c} 0 0 {d} {e} {f} 0 0 {g} {b} {h} 0 0 0 0 0 1 0"/>',{a:.2126+.7874*(1-e),b:.7152-.7152*(1-e),c:.0722-.0722*(1-e),d:.2126-.2126*(1-e),e:.7152+.2848*(1-e),f:.0722-.0722*(1-e),g:.2126-.2126*(1-e),h:.0722+.9278*(1-e)})},t.filter.grayscale.toString=function(){return this()},t.filter.sepia=function(e){return null==e&&(e=1),t.format('<feColorMatrix type="matrix" values="{a} {b} {c} 0 0 {d} {e} {f} 0 0 {g} {h} {i} 0 0 0 0 0 1 0"/>',{a:.393+.607*(1-e),b:.769-.769*(1-e),c:.189-.189*(1-e),d:.349-.349*(1-e),e:.686+.314*(1-e),f:.168-.168*(1-e),g:.272-.272*(1-e),h:.534-.534*(1-e),i:.131+.869*(1-e)})},t.filter.sepia.toString=function(){return this()},t.filter.saturate=function(e){return null==e&&(e=1),t.format('<feColorMatrix type="saturate" values="{amount}"/>',{amount:1-e})},t.filter.saturate.toString=function(){return this()},t.filter.hueRotate=function(e){return e=e||0,t.format('<feColorMatrix type="hueRotate" values="{angle}"/>',{angle:e})},t.filter.hueRotate.toString=function(){return this()},t.filter.invert=function(e){return null==e&&(e=1),t.format('<feComponentTransfer><feFuncR type="table" tableValues="{amount} {amount2}"/><feFuncG type="table" tableValues="{amount} {amount2}"/><feFuncB type="table" tableValues="{amount} {amount2}"/></feComponentTransfer>',{amount:e,amount2:1-e})},t.filter.invert.toString=function(){return this()},t.filter.brightness=function(e){return null==e&&(e=1),t.format('<feComponentTransfer><feFuncR type="linear" slope="{amount}"/><feFuncG type="linear" slope="{amount}"/><feFuncB type="linear" slope="{amount}"/></feComponentTransfer>',{amount:e})},t.filter.brightness.toString=function(){return this()},t.filter.contrast=function(e){return null==e&&(e=1),t.format('<feComponentTransfer><feFuncR type="linear" slope="{amount}" intercept="{amount2}"/><feFuncG type="linear" slope="{amount}" intercept="{amount2}"/><feFuncB type="linear" slope="{amount}" intercept="{amount2}"/></feComponentTransfer>',{amount:e,amount2:.5-e/2})},t.filter.contrast.toString=function(){return this()}})),i.plugin((function(t,e,n,i,r){var s=t._.box,o=t.is,a=/^[^a-z]*([tbmlrc])/i,l=function(){return"T"+this.dx+","+this.dy};e.prototype.getAlign=function(t,e){null==e&&o(t,"string")&&(e=t,t=null);var n=(t=t||this.paper).getBBox?t.getBBox():s(t),i=this.getBBox(),r={};switch(e=(e=e&&e.match(a))?e[1].toLowerCase():"c"){case"t":r.dx=0,r.dy=n.y-i.y;break;case"b":r.dx=0,r.dy=n.y2-i.y2;break;case"m":r.dx=0,r.dy=n.cy-i.cy;break;case"l":r.dx=n.x-i.x,r.dy=0;break;case"r":r.dx=n.x2-i.x2,r.dy=0;break;default:r.dx=n.cx-i.cx,r.dy=0}return r.toString=l,r},e.prototype.align=function(t,e){return this.transform("..."+this.getAlign(t,e))}})),i.plugin((function(e,n,i,r){function s(t){t=t.split(/(?=#)/);var e=new String(t[5]);return e[50]=t[0],e[100]=t[1],e[200]=t[2],e[300]=t[3],e[400]=t[4],e[500]=t[5],e[600]=t[6],e[700]=t[7],e[800]=t[8],e[900]=t[9],t[10]&&(e.A100=t[10],e.A200=t[11],e.A400=t[12],e.A700=t[13]),e}e.mui={},e.flat={},e.mui.red=s("#ffebee#ffcdd2#ef9a9a#e57373#ef5350#f44336#e53935#d32f2f#c62828#b71c1c#ff8a80#ff5252#ff1744#d50000"),e.mui.pink=s("#FCE4EC#F8BBD0#F48FB1#F06292#EC407A#E91E63#D81B60#C2185B#AD1457#880E4F#FF80AB#FF4081#F50057#C51162"),e.mui.purple=s("#F3E5F5#E1BEE7#CE93D8#BA68C8#AB47BC#9C27B0#8E24AA#7B1FA2#6A1B9A#4A148C#EA80FC#E040FB#D500F9#AA00FF"),e.mui.deeppurple=s("#EDE7F6#D1C4E9#B39DDB#9575CD#7E57C2#673AB7#5E35B1#512DA8#4527A0#311B92#B388FF#7C4DFF#651FFF#6200EA"),e.mui.indigo=s("#E8EAF6#C5CAE9#9FA8DA#7986CB#5C6BC0#3F51B5#3949AB#303F9F#283593#1A237E#8C9EFF#536DFE#3D5AFE#304FFE"),e.mui.blue=s("#E3F2FD#BBDEFB#90CAF9#64B5F6#64B5F6#2196F3#1E88E5#1976D2#1565C0#0D47A1#82B1FF#448AFF#2979FF#2962FF"),e.mui.lightblue=s("#E1F5FE#B3E5FC#81D4FA#4FC3F7#29B6F6#03A9F4#039BE5#0288D1#0277BD#01579B#80D8FF#40C4FF#00B0FF#0091EA"),e.mui.cyan=s("#E0F7FA#B2EBF2#80DEEA#4DD0E1#26C6DA#00BCD4#00ACC1#0097A7#00838F#006064#84FFFF#18FFFF#00E5FF#00B8D4"),e.mui.teal=s("#E0F2F1#B2DFDB#80CBC4#4DB6AC#26A69A#009688#00897B#00796B#00695C#004D40#A7FFEB#64FFDA#1DE9B6#00BFA5"),e.mui.green=s("#E8F5E9#C8E6C9#A5D6A7#81C784#66BB6A#4CAF50#43A047#388E3C#2E7D32#1B5E20#B9F6CA#69F0AE#00E676#00C853"),e.mui.lightgreen=s("#F1F8E9#DCEDC8#C5E1A5#AED581#9CCC65#8BC34A#7CB342#689F38#558B2F#33691E#CCFF90#B2FF59#76FF03#64DD17"),e.mui.lime=s("#F9FBE7#F0F4C3#E6EE9C#DCE775#D4E157#CDDC39#C0CA33#AFB42B#9E9D24#827717#F4FF81#EEFF41#C6FF00#AEEA00"),e.mui.yellow=s("#FFFDE7#FFF9C4#FFF59D#FFF176#FFEE58#FFEB3B#FDD835#FBC02D#F9A825#F57F17#FFFF8D#FFFF00#FFEA00#FFD600"),e.mui.amber=s("#FFF8E1#FFECB3#FFE082#FFD54F#FFCA28#FFC107#FFB300#FFA000#FF8F00#FF6F00#FFE57F#FFD740#FFC400#FFAB00"),e.mui.orange=s("#FFF3E0#FFE0B2#FFCC80#FFB74D#FFA726#FF9800#FB8C00#F57C00#EF6C00#E65100#FFD180#FFAB40#FF9100#FF6D00"),e.mui.deeporange=s("#FBE9E7#FFCCBC#FFAB91#FF8A65#FF7043#FF5722#F4511E#E64A19#D84315#BF360C#FF9E80#FF6E40#FF3D00#DD2C00"),e.mui.brown=s("#EFEBE9#D7CCC8#BCAAA4#A1887F#8D6E63#795548#6D4C41#5D4037#4E342E#3E2723"),e.mui.grey=s("#FAFAFA#F5F5F5#EEEEEE#E0E0E0#BDBDBD#9E9E9E#757575#616161#424242#212121"),e.mui.bluegrey=s("#ECEFF1#CFD8DC#B0BEC5#90A4AE#78909C#607D8B#546E7A#455A64#37474F#263238"),e.flat.turquoise="#1abc9c",e.flat.greensea="#16a085",e.flat.sunflower="#f1c40f",e.flat.orange="#f39c12",e.flat.emerland="#2ecc71",e.flat.nephritis="#27ae60",e.flat.carrot="#e67e22",e.flat.pumpkin="#d35400",e.flat.peterriver="#3498db",e.flat.belizehole="#2980b9",e.flat.alizarin="#e74c3c",e.flat.pomegranate="#c0392b",e.flat.amethyst="#9b59b6",e.flat.wisteria="#8e44ad",e.flat.clouds="#ecf0f1",e.flat.silver="#bdc3c7",e.flat.wetasphalt="#34495e",e.flat.midnightblue="#2c3e50",e.flat.concrete="#95a5a6",e.flat.asbestos="#7f8c8d",e.importMUIColors=function(){for(var n in e.mui)e.mui.hasOwnProperty(n)&&(t[n]=e.mui[n])}})),i}(n,i)}));function re(){}function se(t,e){return Math.floor(Math.random()*(e-t+1))+t}re.maxFromBits=function(t){return Math.pow(2,t)},re.limitUI04=re.maxFromBits(4),re.limitUI06=re.maxFromBits(6),re.limitUI08=re.maxFromBits(8),re.limitUI12=re.maxFromBits(12),re.limitUI14=re.maxFromBits(14),re.limitUI16=re.maxFromBits(16),re.limitUI32=re.maxFromBits(32),re.limitUI40=re.maxFromBits(40),re.limitUI48=re.maxFromBits(48),re.randomUI04=function(){return se(0,re.limitUI04-1)},re.randomUI06=function(){return se(0,re.limitUI06-1)},re.randomUI08=function(){return se(0,re.limitUI08-1)},re.randomUI12=function(){return se(0,re.limitUI12-1)},re.randomUI14=function(){return se(0,re.limitUI14-1)},re.randomUI16=function(){return se(0,re.limitUI16-1)},re.randomUI32=function(){return se(0,re.limitUI32-1)},re.randomUI40=function(){return(0|Math.random()*(1<<30))+(0|1024*Math.random())*(1<<30)},re.randomUI48=function(){return(0|Math.random()*(1<<30))+(0|Math.random()*(1<<18))*(1<<30)},re.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},re.prototype.fromParts=function(t,e,n,i,r,s){return this.version=n>>12&15,this.hex=re.paddedString(t.toString(16),8)+"-"+re.paddedString(e.toString(16),4)+"-"+re.paddedString(n.toString(16),4)+"-"+re.paddedString(i.toString(16),2)+re.paddedString(r.toString(16),2)+"-"+re.paddedString(s.toString(16),12),this},re.prototype.toString=function(){return this.hex},re.prototype.toURN=function(){return"urn:uuid:"+this.hex},re.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},re.prototype.equals=function(t){return t instanceof UUID&&this.hex===t.hex},re.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}},re._create4=function(){return(new re).fromParts(re.randomUI32(),re.randomUI16(),16384|re.randomUI12(),128|re.randomUI06(),re.randomUI08(),re.randomUI48())},re._create1=function(){var t=(new Date).getTime(),e=re.randomUI14(),n=1099511627776*(1|re.randomUI08())+re.randomUI40(),i=re.randomUI04(),r=0;t!=r?(t<r&&e++,r=t,i=re.randomUI04()):Math.random()<1/4&&i<9984?i+=1+re.randomUI04():e++;var s=re.getTimeFieldValues(r),o=s.low+i,a=4095&s.hi|4096,l=(e&=16383)>>>8|128,h=255&e;return(new re).fromParts(o,s.mid,a,l,h,n)},re.create=function(t){return this["_create"+(t=t||4)]()},re.fromTime=function(t,e){e=e||!1;var n=re.getTimeFieldValues(t),i=n.low,r=4095&n.hi|4096;return!1===e?(new re).fromParts(i,n.mid,r,0,0,0):(new re).fromParts(i,n.mid,r,128|re.limitUI06,re.limitUI08-1,re.limitUI48-1)},re.firstFromTime=function(t){return re.fromTime(t,!1)},re.lastFromTime=function(t){return re.fromTime(t,!0)},re.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 re).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},re.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 re.fromURN(e)},re.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 re.fromBytes(e)},re.new=function(){return this.create(4)},re.newTS=function(){return this.create(1)};var oe=re,ae=Y((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=pe,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,T=E*E+_*_*_;if(T<0){var S=-s/3,A=o(S*S*S),P=-w/(2*A),C=r(P<-1?-1:P>1?1:P),L=2*l(A);return[L*n(C/3)-v/3,L*n((C+c)/3)-v/3,L*n((C+2*c)/3)-v/3].filter(a)}if(0===T)return[2*(M=E<0?l(-E):-l(E))-v/3,-M-v/3].filter(a);var R=o(T);return[(M=l(-E+R))-l(E+R)-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,T=w+v,S=m.lli8(y,x,M,_,b,w,E,T),A=m.dist(S,t),P=s(t.y-S.y,t.x-S.x),C=s(e.y-S.y,e.x-S.x),L=s(r.y-S.y,r.x-S.x);return P<L?((P>C||C>L)&&(P+=c),P>L&&(o=L,L=P,P=o)):L<C&&C<P?(o=L,L=P,P=o):L+=c,S.s=P,S.e=L,S.r=A,S},numberSort:function(t,e){return t-e}};t.exports=m}()})),le=Y((function(t){var e,n;e=ae,(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 he=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()},ce={x:!1,y:!1};function ue(t,e,n){if("Z"!==e){if("M"!==e){var i=[!1,ce.x,ce.y].concat(n),r=new(t.bind.apply(t,i)),s=n.slice(-2);return ce={x:s[0],y:s[1]},r}ce={x:n[0],y:n[1]}}}var de=function(t,e){for(var n,i,r=he(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=ue(t,n,r.splice(0,a[n]).map(parseFloat)))&&o.push(i);return new t.PolyBezier(o)},pe=Y((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=ae,u=le,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=de;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,T=w.y+(b-w.y)/i,S={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+(T-n.y)/(1-i)};return new d(t,S,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}()})),fe=pe,me=ve,ge=ve;function ve(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=ye(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=ye(t,o,a,i,!1))===l.next&&(l.steiner=!0),h.push(Ce(l));for(h.sort(Te),r=0;r<h.length;r++)n=Se(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 be(d,p,n,i,r,h,0),p}function ye(t,e,n,i,r){var s,o;if(r===He(t,e,n,i)>0)for(s=e;s<n;s+=i)o=Ue(s,t[s],t[s+1],o);else for(s=n-i;s>=e;s-=i)o=Ue(s,t[s],t[s+1],o);return o&&De(o,o.next)&&(ke(o),o=o.next),o}function xe(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!De(i,i.next)&&0!==Ie(i.prev,i,i.next))i=i.next;else{if(ke(i),(i=e=i.prev)===i.next)break;n=!0}}while(n||i!==e);return e}function be(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=Pe(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?Me(t,i,r,s):we(t))e.push(a.i/n|0),e.push(t.i/n|0),e.push(l.i/n|0),ke(t),t=l.next,h=l.next;else if((t=l)===h){o?1===o?be(t=_e(xe(t),e,n),e,n,i,r,s,2):2===o&&Ee(t,e,n,i,r,s):be(xe(t),e,n,i,r,s,1);break}}}function we(t){var e=t.prev,n=t,i=t.next;if(Ie(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&&Le(r,a,s,l,o,h,f.x,f.y)&&Ie(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Me(t,e,n,i){var r=t.prev,s=t,o=t.next;if(Ie(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=Pe(p,f,e,n,i),y=Pe(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&&Le(a,c,l,u,h,d,x.x,x.y)&&Ie(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&&Le(a,c,l,u,h,d,b.x,b.y)&&Ie(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&&Le(a,c,l,u,h,d,x.x,x.y)&&Ie(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&&Le(a,c,l,u,h,d,b.x,b.y)&&Ie(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function _e(t,e,n){var i=t;do{var r=i.prev,s=i.next.next;!De(r,s)&&Oe(r,i,i.next,s)&&Ne(r,s)&&Ne(s,r)&&(e.push(r.i/n|0),e.push(i.i/n|0),e.push(s.i/n|0),ke(i),ke(i.next),i=t=s),i=i.next}while(i!==t);return xe(i)}function Ee(t,e,n,i,r,s){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Re(o,a)){var l=ze(o,a);return o=xe(o,o.next),l=xe(l,l.next),be(o,e,n,i,r,s,0),void be(l,e,n,i,r,s,0)}a=a.next}o=o.next}while(o!==t)}function Te(t,e){return t.x-e.x}function Se(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&&Le(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),Ne(i,t)&&(l<d||l===d&&(i.x>n.x||i.x===n.x&&Ae(n,i)))&&(n=i,d=l)),i=i.next}while(i!==h);return n}(t,e);if(!n)return e;var i=ze(n,t);return xe(i,i.next),xe(n,n.next)}function Ae(t,e){return Ie(t.prev,t,e.prev)<0&&Ie(e.next,t,t.next)<0}function Pe(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 Ce(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 Le(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 Re(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&&Oe(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(Ne(t,e)&&Ne(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)&&(Ie(t.prev,t,e.prev)||Ie(t,e.prev,e))||De(t,e)&&Ie(t.prev,t,t.next)>0&&Ie(e.prev,e,e.next)>0)}function Ie(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function De(t,e){return t.x===e.x&&t.y===e.y}function Oe(t,e,n,i){var r=Be(Ie(t,e,n)),s=Be(Ie(t,e,i)),o=Be(Ie(n,i,t)),a=Be(Ie(n,i,e));return r!==s&&o!==a||(!(0!==r||!Fe(t,n,e))||(!(0!==s||!Fe(t,i,e))||(!(0!==o||!Fe(n,t,i))||!(0!==a||!Fe(n,e,i)))))}function Fe(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 Be(t){return t>0?1:t<0?-1:0}function Ne(t,e){return Ie(t.prev,t,t.next)<0?Ie(t,e,t.next)>=0&&Ie(t,t.prev,e)>=0:Ie(t,e,t.prev)<0||Ie(t,t.next,e)<0}function ze(t,e){var n=new Ve(t.i,t.x,t.y),i=new Ve(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 Ue(t,e,n,i){var r=new Ve(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 ke(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 Ve(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 He(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}ve.deviation=function(t,e,n,i){var r=e&&e.length,s=r?e[0]*n:t.length,o=Math.abs(He(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(He(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)},ve.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},me.default=ge;class Ge{constructor(t,e){this.next=null,this.key=t,this.data=e,this.left=null,this.right=null}}function We(t,e){return t>e?1:t<e?-1:0}function je(t,e,n){const i=new Ge(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 Xe(t,e,n,i){const r=new Ge(t,e);if(null===n)return r.left=r.right=null,r;const s=i(t,(n=je(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 qe(t,e,n){let i=null,r=null;if(e){const s=n((e=je(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 Ye{constructor(t=We){this._root=null,this._size=0,this._comparator=t}insert(t,e){return this._size++,this._root=Xe(t,e,this._root,this._comparator)}add(t,e){const n=new Ge(t,e);null===this._root&&(n.left=n.right=null,this._size++,this._root=n);const i=this._comparator,r=je(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=je(t,e,n)).key)?(null===e.left?i=e.right:(i=je(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=je(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=je(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 Ge(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 Ge(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 Ge(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 Ge(null,null);let i=n;for(let n=0;n<t.length;n++)i=i.next=new Ge(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}=qe(t,this._root,i);i(t,e)<0?s=Xe(e,n,s,i):r=Xe(e,n,r,i),this._root=function(t,e,n){return null===e?t:(null===t||((e=je(t.key,e,n)).left=t),e)}(r,s,i)}split(t){return qe(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 Ze(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Je(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 $e(t,e,n){return e&&Je(t.prototype,e),n&&Je(t,n),t}var Qe=function(t,e){return t.ll.x<=e.x&&e.x<=t.ur.x&&t.ll.y<=e.y&&e.y<=t.ur.y},Ke=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}}},tn=Number.EPSILON;void 0===tn&&(tn=Math.pow(2,-52));var en,nn=tn*tn,rn=function(t,e){if(-tn<t&&t<tn&&-tn<e&&e<tn)return 0;var n=t-e;return n*n<nn*t*e?0:t<e?-1:1},sn=function(){function t(){Ze(this,t),this.reset()}return $e(t,[{key:"reset",value:function(){this.xRounder=new on,this.yRounder=new on}},{key:"round",value:function(t,e){return{x:this.xRounder.round(t),y:this.yRounder.round(e)}}}]),t}(),on=function(){function t(){Ze(this,t),this.tree=new Ye,this.round(0)}return $e(t,[{key:"round",value:function(t){var e=this.tree.add(t),n=this.tree.prev(e);if(null!==n&&0===rn(e.key,n.key))return this.tree.remove(t),n.key;var i=this.tree.next(e);return null!==i&&0===rn(e.key,i.key)?(this.tree.remove(t),i.key):t}}]),t}(),an=new sn,ln=function(t,e){return t.x*e.y-t.y*e.x},hn=function(t,e){return t.x*e.x+t.y*e.y},cn=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=ln(i,r);return rn(s,0)},un=function(t){return Math.sqrt(hn(t,t))},dn=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 hn(r,i)/un(r)/un(i)},pn=function(t,e,n){return 0===e.y?null:{x:t.x+e.x/e.y*(n-t.y),y:n}},fn=function(t,e,n){return 0===e.x?null:{x:n,y:t.y+e.y/e.x*(n-t.x)}},mn=function(){function t(e,n){Ze(this,t),void 0===e.events?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=n}return $e(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:vn.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}}]),$e(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},ln(l,a)/un(l)/un(a)),cosine:dn(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}(),gn=0,vn=function(){function t(e,n,i,r){Ze(this,t),this.id=++gn,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 $e(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}}]),$e(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=Ke(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=Qe(e,o)&&0===this.comparePoint(o),h=Qe(n,r)&&0===t.comparePoint(r),c=Qe(e,a)&&0===this.comparePoint(a),u=Qe(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 fn(n,i,t.x);if(0===i.x)return fn(t,e,n.x);if(0===e.y)return pn(n,i,t.y);if(0===i.y)return pn(t,e,n.y);var r=ln(e,i);if(0==r)return null;var s={x:n.x-t.x,y:n.y-t.y},o=ln(s,e)/r,a=ln(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:Qe(i,d)?an.round(d.x,d.y):null}},{key:"split",value:function(e){var n=[],i=void 0!==e.events,r=new mn(e,!0),s=new mn(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 mn.comparePoints(a.leftSE.point,a.rightSE.point)>0&&a.swapEvents(),mn.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(Tn.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===Tn.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(Tn.type))}return this._isInResult}}],[{key:"fromRing",value:function(e,n,i){var r,s,o,a=mn.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 mn(r,!0),new mn(s,!1),[i],[o])}}]),t}(),yn=function(){function t(e,n,i){if(Ze(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=an.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=an.round(e[o][0],e[o][1]);l.x===s.x&&l.y===s.y||(this.segments.push(vn.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(vn.fromRing(s,r,this))}return $e(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}(),xn=function(){function t(e,n){if(Ze(this,t),!Array.isArray(e))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new yn(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 yn(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 $e(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}(),bn=function(){function t(e,n){if(Ze(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 xn(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 $e(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}(),wn=function(){function t(e){Ze(this,t),this.events=e;for(var n=0,i=e.length;n<i;n++)e[n].segment.ringOut=this;this.poly=null}return $e(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}}]),$e(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!==cn(r,t,s)&&(e.push(r),t=r)}if(1===e.length)return null;var o=e[0],a=e[1];0===cn(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];mn.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}(),Mn=function(){function t(e){Ze(this,t),this.exteriorRing=e,e.poly=this,this.interiorRings=[]}return $e(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}(),_n=function(){function t(e){Ze(this,t),this.rings=e,this.polys=this._composePolys(e)}return $e(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 Mn(r));else{var s=r.enclosingRing();s.poly||e.push(new Mn(s)),s.poly.addInterior(r)}}return e}}]),t}(),En=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:vn.compare;Ze(this,t),this.queue=e,this.tree=new Ye(n),this.segments=[]}return $e(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=mn.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,T=_.length;E<T;E++)n.push(_[E]);if(!a.isAnEndpoint(M))for(var S=this._splitSafely(a,M),A=0,P=S.length;A<P;A++)n.push(S[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}(),Tn=new(function(){function t(){Ze(this,t)}return $e(t,[{key:"run",value:function(t,e,n){Tn.type=t,an.reset();for(var i=[new bn(e,!0)],r=0,s=n.length;r<s;r++)i.push(new bn(n[r],!1));if(Tn.numMultiPolys=i.length,"difference"===Tn.type)for(var o=i[0],a=1;a<i.length;)null!==Ke(i[a].bbox,o.bbox)?a++:i.splice(a,1);if("intersection"===Tn.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===Ke(c.bbox,i[u].bbox))return[];for(var p=new Ye(mn.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 En(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),T=0,S=E.length;T<S;T++){var A=E[T];void 0===A.consumedBy&&p.insert(A)}b=p.size,w=p.pop()}an.reset();var P=wn.factory(x.segments);return new _n(P).getGeom()}}]),t}()),Sn=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 Tn.run("union",t,n)},An=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 Tn.run("intersection",t,n)},Pn=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 Tn.run("xor",t,n)},Cn=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 Tn.run("difference",t,n)};class Ln{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}=b.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:x}=n,w=(f*(v-s)+m*(y-o)+g*(x-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}=b.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}=b.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 me(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=Ln.TriangulatePolygon2D(e,n);return{vertices:e,triangles:i}}static LookAtMatrix(t,e,n){const{THREE:i}=b.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}=b.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 An(t,...e)}static PolygonDiff(t,...e){return Cn(t,...e)}static PolygonUnion(t,...e){return Sn(t,...e)}static PolygonXOR(t,...e){return Pn(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=Kt($t(),t[0][0],t[0][1]),s=$t();n<i;n+=1)Kt(s,t[n][0],t[n][1]),e.push(e[n-1]+ee(r,s)),Qt(r,s);else for(let n=1,i=t.length,r=qt(jt(),t[0][0],t[0][1],t[0][2]),s=jt();n<i;n+=1)qt(s,t[n][0],t[n][1],t[n][2]),e.push(e[n-1]+Zt(r,s)),Xt(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=Kt($t(),t[s][0],t[s][1]);if(s===t.length-1||n<=0)return[i[0],i[1]];const r=e[s],o=Kt($t(),t[s+1][0],t[s+1][1]),a=e[s+1]-r,l=te($t(),o,i),h=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t}($t(),i,function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t}($t(),l,(n-r)/a));return[h[0],h[1]]}if(3===t[0].length){const i=qt(jt(),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=qt(jt(),t[s+1][0],t[s+1][1],t[s+1][2]),a=e[s+1]-r,l=Yt(jt(),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}(jt(),i,function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}(jt(),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?ee(Kt($t(),t[0],t[1]),Kt($t(),i[0],i[1])):Zt(qt(jt(),t[0],t[1],t[2]),qt(jt(),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?ee(Kt($t(),t[0],t[1]),Kt($t(),o[0],o[1])):Zt(qt(jt(),t[0],t[1],t[2]),qt(jt(),o[0],o[1],o[2])),h=f+d,a=this.GetPointOnDistance(e,n,h),u=2===t.length?ee(Kt($t(),t[0],t[1]),Kt($t(),a[0],a[1])):Zt(qt(jt(),t[0],t[1],t[2]),qt(jt(),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}}}Ln.Epsilon=1e-6,(en=t.PathCommand||(t.PathCommand={})).MOVE="m",en.LINE="l",en.CURVE="c";class Rn{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 fe(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 Rn.PolyonOfPathStep(e)}}class In{constructor(t,e=!0){this.data={id:oe.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=Rn.GenerateStepsFromPath(this.data.path),"shape"===this.data.shapeType&&(this.hollows=Rn.ParseHollows(this.data.hollows)),this.steps.length<=2||!e)return;const n=Rn.PolygonOfShape(this);n&&n.length>2&&(this.data.centroid=Ln.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}}class Dn{}Dn.Ground="ground",Dn.Area="area",Dn.Store="store",Dn.Impassable="impassable",Dn.ParkingSpace="parking-space";class On{static async parseSVG(t,e){const{THREE:n}=b.getInstance(),i=await new Promise(e=>{(new n.FileLoader).load(t,t=>{e(t)})});return this.parseSVGString(i,e)}static async parseSVGString(t,e){const n=await wt(t),i=this.getCanvasNodeFromSvg(n,e);return i?On.getShapesFromCanvasNode(i):[]}static getShapesFromCanvasNode(t){const e=[];if(t.children.length){t.children.map(t=>On.getShapesFromCanvasNode(t)).forEach(t=>{t.forEach(t=>{e.push(t)})})}if(t.commands.length){const n=[];t.commands.forEach(t=>{n.push(`${t.command.toLowerCase()}${t.args.join(",")}`)});let i=2,r=.01,s=.9;t.tag&&(t.tag.indexOf(Dn.Ground)>-1&&(i=0,r=0,s=1),t.tag.indexOf(Dn.Area)>-1&&(i=0,r=.01,s=1),t.tag.indexOf(Dn.ParkingSpace)>-1&&(i=0,r=.02,s=1),t.tag.indexOf(Dn.Store)>-1&&(i=1.8,r=.03,s=1));const o={path:n.join(""),shapeType:"shape",fill:t.fill,fillOpacity:s,strokeOpacity:.2,height:i,zIndex:r,tag:t.tag,parentName:t.tag};t.id&&(o.tag=t.id,o.id=t.id);const a=new In(o);e.push(a)}return e}static planCoordinateToWorldCoordinate(t,e,n){const i=n.imageWidth||4e3,r=i/4e3,s=(i-(n.imageHeight||4e3))/2,o=4*n.scale,a=n.theta*(Math.PI/180),l=(t/r-4e3*n.offsetRatioX)/o,h=((e+s)/r-4e3*n.offsetRatioY)/o;return{x:l*Math.cos(a)+h*Math.sin(a),y:l*Math.sin(a)-h*Math.cos(a)}}static getPathCommands(t,e,n){const i=[],r=t.match(/((?:(?:M|L)(?:(?:[0-9]|[.eE]|-)+,(?:[0-9]|[.-eE]|-)+))|(?:C(?:(?:[0-9]|[.-eE]|-)+,(?:[0-9]|[.-eE]|-)+\s){2}(?:(?:[0-9]|[.-eE]|-)+,(?:[0-9]|[.-eE]|-)+))|(?:Z|z))/gm);return null!==r&&r.forEach(t=>{const r=[],s=t[0];t.substring(1).split(" ").forEach(t=>{r.push(t.split(",").map(t=>parseFloat(t)))});const o=[];r.forEach(t=>{if(t.length<2)return;const[i,r]=t,{x:s,y:a}=On.planCoordinateToWorldCoordinate(e[0]+i,e[1]+r,n);o.push(s),o.push(a)}),"Z"!==s&&i.push({command:s,args:o})}),i}static svgNode2Canvas(t,e,n=!1,i=null,r=null,s=[0,0],o=null){const a="g"===t.name&&(t.attributes.name||t.attributes.id)||o,l={children:[],commands:[],tag:a};if(t.children&&t.children.length){const o=t.attributes.fill||i,h=t.attributes["fill-rule"]||r,c=s.slice();if(t.attributes.transform){const e=/(?:translate\(((?:[0-9]|[.-eE]|-)+),\s((?:[0-9]|[.-eE]|-)+)\))/g.exec(t.attributes.transform);e&&e.length>2&&(c[0]+=parseFloat(e[1]),c[1]+=parseFloat(e[2]))}t.children.forEach(t=>{if(n&&"g"!==t.name)return;const i=On.svgNode2Canvas(t,e,!1,o,h,c,a);i&&l.children.push(i)})}if("path"===t.name){const n=t.attributes.d;l.commands=On.getPathCommands(n,s,e),l.fill=t.attributes.fill||i,l.fillRule=t.attributes["fill-rule"]||r||"nonzero"}if("polygon"===t.name){const n=t.attributes.points.split(" ");for(let t=0;t<n.length;t+=2){const{x:i,y:r}=On.planCoordinateToWorldCoordinate(s[0]+parseFloat(n[t]),s[1]+parseFloat(n[t+1]),e);0===t?l.commands.push({command:"M",args:[i,r]}):l.commands.push({command:"L",args:[i,r]})}l.fill=t.attributes.fill||i,l.fillRule=t.attributes["fill-rule"]||r||"nonzero"}return l}static svg2canvas(t,e){return On.svgNode2Canvas(t,e,!0)}static getPathCommandsWithAlignment(t,e,n){const i=[],r=t.match(/[a-z]|[A-Z](\S*)/gm);return null!==r&&r.forEach(t=>{const r=[],s=t[0];t.substring(1).split(" ").forEach(t=>{r.push(t.split(",").map(t=>parseFloat(t)))});const o=[],a=[];r.forEach(t=>{if(!(t.length<2))for(let e=0;e<t.length;){const n=t.slice(e,e+=2);a.push(n)}}),a.forEach(t=>{const[i,r]=t,{x:s,y:a}=On.get3DPositionsFrom2D([e[0]+i,e[1]+r],n);o.push(s),o.push(a)}),"Z"!==s&&i.push({command:s,args:o})}),i}static get3DPositionsFrom2D([t,e],n){const i=(r=n[0],s=n[1],o=n[2],a=n[3],l=n[4],h=n[5],c=n[6],u=n[7],d=n[8],p=n[9],f=n[10],m=n[11],g=n[12],v=n[13],y=n[14],x=n[15],(b=new Wt(16))[0]=r,b[1]=s,b[2]=o,b[3]=a,b[4]=l,b[5]=h,b[6]=c,b[7]=u,b[8]=d,b[9]=p,b[10]=f,b[11]=m,b[12]=g,b[13]=v,b[14]=y,b[15]=x,b);var r,s,o,a,l,h,c,u,d,p,f,m,g,v,y,x,b;const w=Jt();!function(t,e,n,i,r){t[0]=e,t[1]=n,t[2]=i,t[3]=r}(w,t,e,0,1);const M=Jt();return function(t,e,n){var i=e[0],r=e[1],s=e[2],o=e[3];t[0]=n[0]*i+n[4]*r+n[8]*s+n[12]*o,t[1]=n[1]*i+n[5]*r+n[9]*s+n[13]*o,t[2]=n[2]*i+n[6]*r+n[10]*s+n[14]*o,t[3]=n[3]*i+n[7]*r+n[11]*s+n[15]*o}(M,w,i),{x:M[0],y:M[1]}}static getRotateRadiusToNorth(t){const{THREE:e}=b.getInstance(),n=new e.Vector3,i=new e.Vector3,r=new e.Quaternion;(new e.Matrix4).fromArray(t).decompose(n,r,i);return-(new e.Euler).setFromQuaternion(r).z}static generateCanvasNodeFromSvg(t,e,n=!1,i=null,r=null,s=[0,0],o=null){const a="g"===t.name&&(t.attributes.name||t.attributes.id)||o,l={children:[],commands:[],tag:a,id:t.attributes.id};if(t.children&&t.children.length){const o=t.attributes.fill||i,h=t.attributes["fill-rule"]||r,c=s.slice();if(t.attributes.transform){const e=/(?:translate\(((?:[0-9]|[.-eE]|-)+),\s((?:[0-9]|[.-eE]|-)+)\))/g.exec(t.attributes.transform);e&&e.length>2&&(c[0]+=parseFloat(e[1]),c[1]+=parseFloat(e[2]))}t.children.forEach(t=>{if(n&&"g"!==t.name)return;const i=On.generateCanvasNodeFromSvg(t,e,!1,o,h,c,a);i&&l.children.push(i)})}if("path"===t.name){const n=t.attributes.d;l.commands=On.getPathCommandsWithAlignment(n,s,e),l.fill=t.attributes.fill||i,l.fillRule=t.attributes["fill-rule"]||r||"nonzero"}if("polygon"===t.name){const n=t.attributes.points.split(" ");for(let t=0;t<n.length;t+=2){const{x:i,y:r}=On.get3DPositionsFrom2D([s[0]+parseFloat(n[t]),s[1]+parseFloat(n[t+1])],e);0===t?l.commands.push({command:"M",args:[i,r]}):l.commands.push({command:"L",args:[i,r]})}l.fill=t.attributes.fill||i,l.fillRule=t.attributes["fill-rule"]||r||"nonzero"}return l}static getCanvasNodeFromSvg(t,e){return On.generateCanvasNodeFromSvg(t,e,!0)}static generateNewShape(t,e,n){const{tag:i,fill:r,ownTag:s}=n||{};let o=2,a=.01,l=.9;return i===Dn.Ground&&(o=0,a=0,l=1),i===Dn.Area&&(o=0,a=.01,l=1),i===Dn.ParkingSpace&&(o=0,a=.02,l=1),i===Dn.Store&&(o=1.8,a=.03,l=1),new In({id:e,path:t,shapeType:"shape",fill:r,fillOpacity:l,strokeOpacity:.2,height:o,zIndex:a,tag:s||i,parentName:i})}static parseRectElementToShape(t,e,{tag:n,fill:i,ownTag:r}){const{x:s,y:o,width:a,height:l,id:h}=t.attr(),[c,u,d,p]=[s,o,a,l].map(parseFloat),f=[],m=t.transform().totalMatrix,g=[c,u,c+d,u,c+d,u+p,c,u+p,c,u];for(let t=0;t<g.length;t+=2){const n=[];n.push(t>0?"L":"M");const i=g[t],r=g[t+1],s=m.x(i,r),o=m.y(i,r),{x:a,y:l}=this.get3DPositionsFrom2D([s,o],e);n.push(a,l),f.push(n)}return this.generateNewShape(f.map(([t,...e])=>`${t}${e.join(",")}`).join(""),h,{tag:n,fill:i,ownTag:r})}static parsePolygonElementToShape(t,e,{tag:n,fill:i,ownTag:r}){const{points:s,id:o}=t.attr(),a=s.split(" ").map(parseFloat),l=[],h=t.transform().totalMatrix;for(let t=0;t<a.length;t+=2){const n=[];n.push(t>0?"L":"M");const i=a[t],r=a[t+1],s=h.x(i,r),o=h.y(i,r),{x:c,y:u}=this.get3DPositionsFrom2D([s,o],e);n.push(c,u),l.push(n)}return this.generateNewShape(l.map(([t,...e])=>`${t}${e.join(",")}`).join(""),o,{tag:n,fill:i,ownTag:r})}static parsePathElementToShape(t,e,{tag:n,fill:i,ownTag:r}){const{d:s,id:o}=t.attr(),a=ie.parsePathString(s),l=[],h=t.transform().totalMatrix;return a.forEach(([t,...n])=>{if("Z"===t)return;const i=[];i.push(t.toLowerCase());for(let t=0;t<n.length;t+=2){const r=n[t],s=n[t+1],o=h.x(r,s),a=h.y(r,s),{x:l,y:c}=On.get3DPositionsFrom2D([o,a],e);i.push(l,c)}l.push(i)}),this.generateNewShape(l.map(([t,...e])=>`${t}${e.join(",")}`).join(""),o,{tag:n,fill:i,ownTag:r})}static parseSnapSvgToShapes(t,e,n){try{const{tag:i,fill:r}=n||{},{type:s}=t,o=[],a=t.attr(),l="g"===s&&(a.name||a.id)||i,h=a.name||a.id,c=a.fill||r||"",u=t.children();for(let t=0;t<u.length;t+=1){const n=this.parseSnapSvgToShapes(u[t],e,{tag:l,fill:c});for(let t=0;t<n.length;t+=1)o.push(n[t])}return"path"===s&&o.push(this.parsePathElementToShape(t,e,{tag:l,fill:c,ownTag:h})),"polygon"===s&&o.push(this.parsePolygonElementToShape(t,e,{tag:l,fill:c,ownTag:h})),"rect"===s&&o.push(this.parseRectElementToShape(t,e,{tag:l,fill:c,ownTag:h})),o}catch(t){}return[]}static getCompsFromMat4(t){const{THREE:e}=b.getInstance(),n=new e.Vector3,i=new e.Vector3,r=new e.Quaternion;return(new e.Matrix4).fromArray(t).decompose(n,r,i),{position:n,scale:i,quaternion:r}}static parseSvgToShapes(t,e,n=1){return new Promise(i=>{ie.load(t,t=>{let r=this.parseSnapSvgToShapes(t.select("svg"),e);r=r.map(t=>{const{height:i}=t.getData(),r=On.calcHeightFromMat(i,e)*n;return t.updateData({height:r}),t}),i(r)})})}static calcHeightFromMat(t,e){const{scale:n}=On.getCompsFromMat4(e);return t*(20*n.x)}}class Fn{static dispose(t,e){if(e&&t.children&&t.children.length&&t.children.forEach(t=>{Fn.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}=b.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 Gt)&&e.parent;)e=e.parent;for(;e&&(e instanceof Gt&&n.push(e),e.parent);)e=e.parent;for(let e=0;e<n.length;e++)if(n[e]instanceof Gt){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}=b.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}=b.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}=b.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}=b.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 Bn extends Gt{constructor(t,e,n=1){super(),this.initialized=!1,this.loaded=!1,this.mapping=e,this.groundMeshes=[],this.areas=[],this.opacity=n,t&&this.load(t)}static getShapeDefs(t){const e=[],{THREE:n}=b.getInstance();if(t.commands&&t.commands.length){const i=new n.Shape,r=[];let s=null,o=0;t.commands.forEach(({command:t,args:e})=>{s&&o>1?("M"===t&&(s&&r.push(s),s=new n.Path,s.moveTo(e[0],e[1])),"C"===t&&s.bezierCurveTo(e[0],e[1],e[2],e[3],e[4],e[5]),"L"===t&&s.lineTo(e[0],e[1])):("M"===t&&(o+=1,2===o?(s=new n.Path,s.moveTo(e[0],e[1])):i.moveTo(e[0],e[1])),"C"===t&&i.bezierCurveTo(e[0],e[1],e[2],e[3],e[4],e[5]),"L"===t&&i.lineTo(e[0],e[1]))}),s&&r.push(s),i.holes=r;const a={shape:i};t.fill&&Object.assign(a,{color:parseInt(t.fill.substr(1),16)}),t.tag&&Object.assign(a,{tag:t.tag}),"ground"!==a.tag&&"area"!==a.tag||e.push(a)}return t.children&&t.children.length&&t.children.forEach(t=>{e.push(...Bn.getShapeDefs(t))}),e}async load(t){this.initialized=!1,this.loaded=!1;const{THREE:e}=b.getInstance(),n=await new Promise(n=>{(new e.FileLoader).load(t,t=>{n(t)})}),i=await wt(n),r=On.svg2canvas(i,this.mapping);if(null!==r){const t=Bn.getShapeDefs(r),n=new e.Group;t.forEach(({shape:t,color:i,tag:r})=>{const s=new e.ShapeBufferGeometry(t),o=new e.MeshBasicMaterial({color:i,transparent:!0,opacity:this.opacity,side:e.DoubleSide}),a=Vt("#"+i.toString(16)).lighten(.5).desaturate(.5).rotate(5).hex(),l=new e.MeshBasicMaterial({color:a,transparent:!0,opacity:.7*this.opacity,side:e.DoubleSide,depthWrite:!1}),h=new e.Mesh(s,o);n.add(h);let c=0;"ground"===r&&(h.position.set(0,0,-.5),c=.5);const u=t.getPoints();u.reduce((t,i)=>{const{x:s,y:o}=t,{x:a,y:h}=i,u=new e.BufferGeometry,d=new Float32Array([s,o,0-c,s,o,5+c,a,h,0-c,s,o,5+c,a,h,0-c,a,h,5+c]);u.setAttribute("position",new e.BufferAttribute(d,3));const p=new e.Mesh(u,l);return n.add(p),"area"===r&&this.areas.push(p),i});const{x:d,y:p}=u[u.length-1],{x:f,y:m}=u[0],g=new e.BufferGeometry,v=new Float32Array([d,p,0-c,d,p,5+c,f,m,0-c,d,p,5+c,f,m,0-c,f,m,5+c]);g.setAttribute("position",new e.BufferAttribute(v,3));const y=new e.Mesh(g,l);n.add(y),"area"===r&&(this.areas.push(y),this.areas.push(h))}),this.add(n),this.loaded=!0}}setOpacity(t){const{THREE:e}=b.getInstance();this.traverse(n=>{const i=n;i.isMesh&&i.material instanceof e.Material&&(i.material.opacity=t)})}setShadowEnabled(t){this.groundMeshes.forEach(e=>{e.receiveShadow=t})}setAreasVisible(t){this.areas.forEach(e=>{e.visible=t})}update(){const t=new Ht(this);return!this.initialized&&this.loaded&&(this.initialized=!0,t.needUpdate=!0),this.initialized&&!this.parent&&(t.shouldPlaceElement=!0),t}dispose(){super.dispose(),this.groundMeshes=[],this.areas=[],Fn.dispose(this,!0)}}class Nn{static GenerateShapeFromSteps(e){const{THREE:n}=b.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 zn=function(t,e){return t[0]=e[0],t[1]=e[1],t};const Un="KHR_binary_glTF",kn="KHR_draco_mesh_compression",Vn="KHR_lights_punctual",Hn="KHR_materials_clearcoat",Gn="KHR_materials_pbrSpecularGlossiness",Wn="KHR_materials_transmission",jn="KHR_materials_unlit",Xn="KHR_texture_basisu",qn="KHR_texture_transform",Yn="KHR_mesh_quantization",Zn="EXT_texture_webp",Jn="EXT_meshopt_compression",$n=0,Qn=1,Kn=2,ti=3,ei=4,ni=5,ii=6,ri={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},si={9728:e.NearestFilter,9729:e.LinearFilter,9984:e.NearestMipmapNearestFilter,9985:e.LinearMipmapNearestFilter,9986:e.NearestMipmapLinearFilter,9987:e.LinearMipmapLinearFilter},oi={33071:e.ClampToEdgeWrapping,33648:e.MirroredRepeatWrapping,10497:e.RepeatWrapping},ai={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},li={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},hi={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ci={CUBICSPLINE:void 0,LINEAR:e.InterpolateLinear,STEP:e.InterpolateDiscrete},ui="OPAQUE",di="MASK",pi="BLEND";function fi(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 mi(t){const{THREE:e}=b.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 gi(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 vi(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 yi(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 xi(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 bi(t){const e=t.extensions&&t.extensions[kn];let n;return n=e?`draco:${e.bufferView}:${e.indices}:${xi(e.attributes)}`:`${t.indices}:${xi(t.attributes)}:${t.mode}`,n}class wi{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 Mi{constructor(t){this.parser=t,this.name=Vn,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}=b.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 _i{constructor(){this.name=jn}getMaterialType(){const{THREE:t}=b.getInstance();return t.MeshBasicMaterial}extendParams(t,e,n){const i=[],{THREE:r}=b.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 Ei{constructor(t){this.parser=t,this.name=Hn}getMaterialType(t){const e=this.parser.json.materials[t];if(!e.extensions||!e.extensions[this.name])return null;const{THREE:n}=b.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}=b.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 Ti{constructor(t){this.parser=t,this.name=Wn}getMaterialType(t){const{parser:e}=this,n=e.json.materials[t];if(!n.extensions||!n.extensions[this.name])return null;const{THREE:i}=b.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 Si{constructor(t){this.parser=t,this.name=Xn}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 Ai{constructor(t){this.parser=t,this.name=Zn,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 Pi{constructor(t){this.name=Jn,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 Ci=1313821514,Li=5130562;class Ri{constructor(t){const{THREE:e}=b.getInstance();this.name=Un,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===Ci){const i=new Uint8Array(t,12+s,n);this.content=e.LoaderUtils.decodeText(i)}else if(i===Li){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 Ii{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=kn,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=li[t]||t.toLowerCase();o[e]=s[t]}for(const e in t.attributes){const i=li[e]||e.toLowerCase();if(void 0!==s[e]){const r=n.accessors[t.attributes[e]],s=ri[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 Di{constructor(){this.name=qn}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 Oi 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}=b.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}=b.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 Fi{constructor(){this.name=Gn,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 Oi}extendParams(t,e,n){const{THREE:i}=b.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}=b.getInstance(),n=new Oi(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 Bi{constructor(){this.name=Yn}}class Ni extends e.Interpolant{constructor(){super(...arguments),this.beforeStart_=Ni.prototype.copySampleValue_,this.afterEnd_=Ni.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 zi(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=li[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 vi(t,e),function(t,e,n){const{attributes:i}=e,{THREE:r}=b.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 Ui(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}=b.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 ki{constructor(t,e){this.loadScene=(()=>{function t(e,n,i,r){const{THREE:s}=b.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}=b.getInstance(),l=new a.Group;s.name&&(l.name=o.createUniqueName(s.name)),vi(l,s),s.extensions&&gi(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 wi,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.nodeNamesUsed={};const{THREE:n}=b.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:{}};gi(r,s,i),vi(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[Un].body);const i=this.options;return new Promise((t,r)=>{n.load(fi(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}=b.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=ai[i.type],a=ri[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=ai.SCALAR,n=ri[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=A.GetEnv()===t.Env.Miniapp?{}:self?self.URL||self.webkitURL:{};const{THREE:h}=b.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(A.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(fi(t,o.path),r,void 0,n)})).then(n=>{try{A.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=si[i.magFilter]||h.LinearFilter,n.minFilter=si[i.minFilter]||h.LinearMipmapLinearFilter,n.wrapS=oi[i.wrapS]||h.RepeatWrapping,n.wrapT=oi[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[qn]){const t=void 0!==n.extensions?n.extensions[qn]:void 0;if(t){const e=i.associations.get(r);r=i.extensions[qn].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}=b.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}=b.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}=b.getInstance();if(a[Gn]){const t=i[Gn];s=t.getMaterialType(),l.push(t.extendParams(o,r,e))}else if(a[jn]){const t=i[jn];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||ui;return c===pi?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,c===di&&(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===Oi?i[Gn].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),vi(n,r),e.associations.set(n,{type:"materials",index:t}),r.extensions&&gi(i,n,r),n})}createUniqueName(t){const{THREE:e}=b.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[kn].decodePrimitive(t,e).then(n=>zi(n,t,e))}const s=[],{THREE:o}=b.getInstance();for(let n=0,a=t.length;n<a;n++){const a=t[n],l=bi(a),h=i[l];if(h)s.push(h.promise);else{let t;t=a.extensions&&a.extensions[kn]?r(a):zi(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}=b.getInstance();for(let t=0,e=s.length;t<e;t++){const e=void 0===s[t].material?mi(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===ei||u.mode===ni||u.mode===ii||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===ni?d.geometry=Ui(d.geometry,a.TriangleStripDrawMode):u.mode===ii&&(d.geometry=Ui(d.geometry,a.TriangleFanDrawMode));else if(u.mode===Qn)d=new a.LineSegments(c,p);else if(u.mode===ti)d=new a.Line(c,p);else if(u.mode===Kn)d=new a.LineLoop(c,p);else{if(u.mode!==$n)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);d=new a.Points(c,p)}Object.keys(d.geometry.morphAttributes).length>0&&yi(d,r),d.name=e.createUniqueName(r.name||"mesh_"+t),vi(d,r),u.extensions&&gi(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}=b.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)),vi(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}=b.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,hi[d.path]){case hi.weights:p=a.NumberKeyframeTrack;break;case hi.rotation:p=a.QuaternionKeyframeTrack;break;case hi.position:case hi.scale:default:p=a.VectorKeyframeTrack}const f=e.name?e.name:e.uuid,m=void 0!==u.interpolation?ci[u.interpolation]:a.InterpolateLinear,g=[];hi[d.path]===hi.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]}.${hi[d.path]}`,n.array,v,m);"CUBICSPLINE"===u.interpolation&&(e.createInterpolant=function(t){return new Ni(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}=b.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),vi(a,r),r.extensions&&gi(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 Vi extends e.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(t=>new Ei(t)),this.register(t=>new Si(t)),this.register(t=>new Ai(t)),this.register(t=>new Ti(t)),this.register(t=>new Mi(t)),this.register(t=>new Pi(t))}load(t,e,n,i){const r=this;let s;const{THREE:o}=b.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}=b.getInstance();if("string"==typeof t)r=t;else{if("glTF"===a.LoaderUtils.decodeText(new Uint8Array(t,0,4))){try{s[Un]=new Ri(t)}catch(t){return void(i&&i(t))}r=s[Un].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 ki(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 jn:s[e]=new _i;break;case Gn:s[e]=new Fi;break;case kn:s[e]=new Ii(l,this.dracoLoader);break;case qn:s[e]=new Di;break;case Yn:s[e]=new Bi;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 Hi{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 Gi{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,Gi.EPSILON);for(this.rootNode=new Hi(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}=b.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}=b.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,Gi.EPSILON),w=this.calcExtents(f,m,Gi.EPSILON),M=new Hi(b[0],b[1],d,p,t.level+1),_=new Hi(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}=b.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}=b.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 Gi(e,7)}}Gi.EPSILON=1e-6;class Wi extends Gt{constructor(t,e=!0,n=1){super(),this.reloadTimes=3;const{THREE:i}=b.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}=b.getInstance();(new Vi).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=Gi.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(_.ELEMENT_LOADED,this)},void 0,i=>{const r=n+1;r>this.reloadTimes?this.emit(_.ELEMENT_LOADED_ERROR,this,i):this.load(t,e,r)})}isModelLoaded(){return this.modelLoaded}update(){const t=new Ht(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(),Fn.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}=b.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=Wi.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 ji{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]||ji.nearlyEquals(t[0],r[0],e)||ji.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=ji.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&&!ji.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=ji.nearlyEquals(t,e,i);return!!n&&r||t<e}static nearlyThan(t,e,n,i=1e-4){const r=ji.nearlyEquals(t,e,i);return!!n&&r||t>e}}class Xi{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}=b.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=Xi.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(...Xi.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(Xi.averageStepLength(t)<e)return t;const n=function(t,e){Array.isArray(e)||(e=[]),t.length>0&&e.push(zn([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(zn([0,0],t[t.length-1])),e}(t);return Xi.smoothPath(n,e)}static smoothPathBezier(t,e,n=10){const{THREE:i}=b.getInstance(),r=t.map(([t,e])=>new i.Vector2(t,e));Xi.mergeSamePoint2(r),Xi.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 fe(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}=b.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=Xi.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=[],x=d;f.forEach((t,e)=>{if(0===e){const[e,n]=p[0];v.push([e+t.x*x,n+t.y*x]),y.push([e-t.x*x,n-t.y*x])}const[n,i]=p[e+1];v.push([n+t.x*x,i+t.y*x]),y.push([n-t.x*x,i-t.y*x])}),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 _=new i.ShapeBufferGeometry(M);let T=!1;u&&(T=!0);const S={arrowTexcoordScaleT:{value:o/x*.5},current:{value:0},dynamic:{value:T},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&&(S.arrowTexcoordScaleT.value=t.image.width/t.image.height/x*.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:S,side:i.DoubleSide,depthTest:!T});let P=Number.MAX_SAFE_INTEGER,C=Number.MAX_SAFE_INTEGER;const{array:L,count:R}=_.attributes.position;for(let t=0,e=0;t<R;t+=1,e+=3){const t=L[e],n=L[e+1];L[e]<P&&(P=t),L[e+1]<C&&(C=n)}if(h&&h.groundPlane)for(let t=0,e=0;t<R;t+=1,e+=3){const t=L[e],n=L[e+1];let r=.5;const s=Wi.intersectWithGroundPlane(new i.Vector3(t,n,r),h);s&&(r=s.z+Xi.PathMeshOffsetZ),L[e+2]=r}else{const t=()=>{if(l&&l.isModelLoaded()){for(let t=0,e=0;t<R;t+=1,e+=3){const t=L[e],n=L[e+1];let r=.5;const s=l.intersectGround(new i.Vector3(t,n,r));s&&(r=s.z+Xi.PathMeshOffsetZ),L[e+2]=r}_.attributes.position.needsUpdate=!0}};l&&l.isModelLoaded()&&t(),w.on(E.ELEMENT_LOADED,e=>{e instanceof Wi&&e===l&&t()})}_.attributes.position.needsUpdate=!0;const I=[];if(a){const t=new i.PlaneBufferGeometry(.5*x/.3,.5*x/.3),n=new i.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.8,blending:e.NormalBlending,side:e.DoubleSide,depthTest:!T}),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=Wi.intersectWithGroundPlane(new i.Vector3(o,a,2),h);t&&(t.z+=Xi.ArrowMeshOffsetZ,d.position.copy(t))}else if(l){const t=l.intersectGround(new i.Vector3(o,a,2));t&&(t.z+=Xi.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 D=Math.floor(P),O=Math.floor(C),F=new Map;p.forEach(([t,e],n)=>{const[i,r]=Xi.getPointHash(t,e,D,O,25);F.has(""+i)||F.set(""+i,new Map);const s=F.get(""+i);s.has(""+r)||s.set(""+r,[]),s.get(""+r).push([n,t,e])});const B=new Float32Array(R),N=new Float32Array(3*R);let z=1,U=140/255,k=0,V=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)));z=t[0]/255,U=t[1]/255,k=t[2]/255,V=t[0]/255,H=t[1]/255,G=t[2]/255}const W=V-z,j=H-U,X=G-k;for(let t=0,e=0;t<R;t+=1,e+=3){const n=L[e],i=L[e+1],[r,s]=Xi.getPointHash(n,i,D,O,25);let o=Number.MAX_SAFE_INTEGER;F.has(""+r)&&F.get(""+r).has(""+s)&&F.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];B[t]=l,N[3*t]=z+h*W,N[3*t+1]=U+h*j,N[3*t+2]=k+h*X})}_.addAttribute("progress",new i.BufferAttribute(B,1)),_.addAttribute("a_color",new i.BufferAttribute(N,3)),A.transparent=!0;return{mesh:new i.Mesh(_,A),arrowMeshes:I,newPath:p,pointMap:F,pathMinX:D,pathMinY:O,progressBuffer:B,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();Xi.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();Xi.nearlyEqualsV2(i,r,e)&&(t.splice(n,1),n--)}}static mergeSamePoint3(t,e=1e-4){for(let n=1;n<t.length;n++)Xi.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++)Xi.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&&(Xi.nearlyEqualsV3(t[0],t[t.length-1],r)||(t=Array.from(t)).push(t[0]));let a=!1;const l=Xi.getDistances(t),h=[],c=l[l.length-1];for(let i=0;i<n.length;i++){const s=n[i],a=o[i],u=Xi.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=ji.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;ji.nearlyThan(d,t,!0,r)&&(o||(n.push(f.clone().multiplyScalar(t-d).add(a)),o=!0),ji.nearlyLess(d,l,!1,r)&&n.push(a),ji.nearlyThan(d,l,!0,r)&&(n.push(f.clone().multiplyScalar(l-d).add(a)),Xi.invalidPath(n)&&s.pop(),n=[],s.push(n),h=u[i++],e--,o=!1))}}if(Xi.invalidPath(n)&&s.pop(),e){const t=s[0],e=s[s.length-1];Xi.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=Xi.getDistances(t);return!t.length||ji.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(Xi.nearlyEqualsV3(r,e,n))return[i];const s=t[i-1];if(s&&Xi.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}}Xi.PathMeshOffsetZ=.1,Xi.ArrowMeshOffsetZ=.2;class qi extends e.BufferGeometry{constructor(t,n){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:n};const{THREE:i}=b.getInstance();t=Array.isArray(t)?t:[t];const r=[],s=[],o=[],a=new e.Matrix4,l=new e.Matrix4,h=Array.from(n.extrudePath);Xi.mergeSamePoint3(h),Xi.mergePathSameVectorPoint3(h);let c=n.closed;Xi.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)}},x=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++){x(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}=b.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 Yi,Zi;(Yi=t.StrokeType||(t.StrokeType={}))[Yi.all=0]="all",Yi[Yi.up=1]="up",Yi[Yi.down=2]="down";class Ji extends Gt{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=Nn.GenerateShapeFromSteps(e.getSteps()),{THREE:a}=b.getInstance(),l=`${this.tag}-${s.fill}-${s.fillOpacity}`;if(Ji.SharedResourceMap||(Ji.SharedResourceMap=new Map),this.lowPerformance&&!Ji.SharedResourceMap.has(l)){const t=new a.MeshStandardMaterial({color:s.fill,transparent:!0,opacity:s.fillOpacity,depthWrite:!1});Ji.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=Ji.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}=b.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}=b.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}=b.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}=b.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}=b.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}=b.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,x=d.morphAttributes.position,{morphTargetsRelative:w}=d,M=d.attributes.normal,_=d.morphAttributes.position,{groups:E}=d,{drawRange:T}=d;let S,A,P,C,L,R,I,D;const O=new Float32Array(y.count*y.itemSize),F=new Float32Array(M.count*M.itemSize);if(null!==v)if(Array.isArray(p))for(S=0,P=E.length;S<P;S++)for(L=E[S],R=p[L.materialIndex],I=Math.max(L.start,T.start),D=Math.min(L.start+L.count,T.start+T.count),A=I,C=D;A<C;A+=3)f=v.getX(A),m=v.getX(A+1),g=v.getX(A+2),u(t,R,y,x,w,f,m,g,O),u(t,R,M,_,w,f,m,g,F);else for(I=Math.max(0,T.start),D=Math.min(v.count,T.start+T.count),S=I,P=D;S<P;S+=3)f=v.getX(S),m=v.getX(S+1),g=v.getX(S+2),u(t,p,y,x,w,f,m,g,O),u(t,p,M,_,w,f,m,g,F);else if(void 0!==y)if(Array.isArray(p))for(S=0,P=E.length;S<P;S++)for(L=E[S],R=p[L.materialIndex],I=Math.max(L.start,T.start),D=Math.min(L.start+L.count,T.start+T.count),A=I,C=D;A<C;A+=3)f=A,m=A+1,g=A+2,u(t,R,y,x,w,f,m,g,O),u(t,R,M,_,w,f,m,g,F);else for(I=Math.max(0,T.start),D=Math.min(y.count,T.start+T.count),S=I,P=D;S<P;S+=3)f=S,m=S+1,g=S+2,u(t,p,y,x,w,f,m,g,O),u(t,p,M,_,w,f,m,g,F);return{positionAttribute:y,normalAttribute:M,morphedPositionAttribute:new e.Float32BufferAttribute(O,3),morphedNormalAttribute:new e.Float32BufferAttribute(F,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);Ji.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(A.GetEnv()===t.Env.Miniapp)return}catch(t){}if(i){Ji.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&&(Fn.dispose(this.borderMesh,!0),this.remove(this.borderMesh),this.borderMesh=void 0),t){const{THREE:n}=b.getInstance(),i=this.shape.getData();e=e||Nn.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){Xi.mergeSamePoint3(l),Xi.mergePathSameVectorPoint3(l),Xi.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=Xi.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 qi(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 Ht(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=Ji.SharedResourceMap.get(e);n&&1===n.count&&n.mesh&&Fn.dispose(n.mesh,!0),Ji.SharedResourceMap.delete(e)}Fn.dispose(this,!0);const t=this.children;t&&this.remove(...t),this.borderMesh=void 0,this.shapeMesh=void 0}dispose(){super.dispose(),this.disposeChildren()}}Ji.StrokeType=t.StrokeType.up;class $i 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}=b.getInstance();return n.Object3D.prototype.copy.call(this,t,e),this.element=t.element.cloneNode(!0),this}}class Qi{constructor(){const t=this,{THREE:e}=b.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 $i&&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 $i){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)}}}
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
+ */class Ki{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 Ki(255,255,255))}return t.forEach(t=>{e.push(t.r),e.push(t.g),e.push(t.b)}),new Uint8Array(e)}}
18
+ /*!
19
+ gifken
20
+ Copyright (c) 2013 aaharu
21
+ This software is released under the MIT License.
22
+ https://raw.github.com/aaharu/gifken/master/LICENSE
23
+
24
+ This product includes following software:
25
+ * jsgif
26
+ - Copyright (c) 2011 Shachaf Ben-Kiki
27
+ - https://github.com/shachaf/jsgif
28
+ - https://raw.github.com/shachaf/jsgif/master/LICENSE
29
+ */class tr{static init(t,e){const n=new tr;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}}
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
+ */!function(t){t.GIF89a="GIF89a",t.GIF87a="GIF87a"}(Zi||(Zi={}));class er{static readHeader(t,e){String.fromCharCode(e.getUint8(0),e.getUint8(1),e.getUint8(2),e.getUint8(3),e.getUint8(4),e.getUint8(5))==Zi.GIF87a?t.version=Zi.GIF87a:t.version=Zi.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 tr,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 tr,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}}
36
+ /*!
37
+ gifken
38
+ Copyright (c) 2013 aaharu
39
+ This software is released under the MIT License.
40
+ https://raw.github.com/aaharu/gifken/master/LICENSE
41
+
42
+ This product includes following software:
43
+ * GifWriter.js
44
+ - Copyright (c) 2013 NOBUOKA Yu
45
+ - https://github.com/nobuoka/GifWriter.js
46
+ - https://raw.github.com/nobuoka/GifWriter.js/master/LICENSE.txt
47
+ */class nr{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 ir{constructor(t){this.frameIndex1=0,this.frameIndex2=0,this.frames=[],t||(this._version=Zi.GIF89a,this._width=1,this._height=1,this.colorResolution=112,this.sortFlag=!1,this.bgColorIndex=1,this.pixelAspectRatio=0,this.globalColorTable=Ki.createColorTable([new Ki(0,0,0),new Ki(255,255,255)]))}static parse(t){const e=new ir(!0),n=new DataView(t);let i=er.readHeader(e,n);for(;i=er.readBlock(e,n,i),-1!==i;);return e}versionName(){return Zi[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 ir.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===Zi.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(ir.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=ir.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 ir;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 ir;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 ir;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=ir.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 nr,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()}}
48
+ /*!
49
+ gifken
50
+ Copyright (c) 2013 aaharu
51
+ This software is released under the MIT License.
52
+ https://raw.github.com/aaharu/gifken/master/LICENSE
53
+ */var rr={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},sr={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},or={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 ar(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 lr(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(!yr(t[0])||!yr(t[1]))throw new Error("coordinates must contain numbers");return ar({type:"Point",coordinates:t},e,n)}function hr(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 ar({type:"Polygon",coordinates:t},e,n)}function cr(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 ar({type:"LineString",coordinates:t},e,n)}function ur(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 dr(t,e,n){return void 0===n&&(n={}),ar({type:"MultiLineString",coordinates:t},e,n)}function pr(t,e,n){return void 0===n&&(n={}),ar({type:"MultiPoint",coordinates:t},e,n)}function fr(t,e,n){return void 0===n&&(n={}),ar({type:"MultiPolygon",coordinates:t},e,n)}function mr(t,e){void 0===e&&(e="kilometers");var n=rr[e];if(!n)throw new Error(e+" units is invalid");return t*n}function gr(t,e){void 0===e&&(e="kilometers");var n=rr[e];if(!n)throw new Error(e+" units is invalid");return t/n}function vr(t){return 180*(t%(2*Math.PI))/Math.PI}function yr(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}function xr(t){return!!t&&t.constructor===Object}var br=Object.freeze({__proto__:null,earthRadius:6371008.8,factors:rr,unitsFactors:sr,areaFactors:or,feature:ar,geometry:function(t,e,n){switch(t){case"Point":return lr(e).geometry;case"LineString":return cr(e).geometry;case"Polygon":return hr(e).geometry;case"MultiPoint":return pr(e).geometry;case"MultiLineString":return dr(e).geometry;case"MultiPolygon":return fr(e).geometry;default:throw new Error(t+" is invalid")}},point:lr,points:function(t,e,n){return void 0===n&&(n={}),ur(t.map((function(t){return lr(t,e)})),n)},polygon:hr,polygons:function(t,e,n){return void 0===n&&(n={}),ur(t.map((function(t){return hr(t,e)})),n)},lineString:cr,lineStrings:function(t,e,n){return void 0===n&&(n={}),ur(t.map((function(t){return cr(t,e)})),n)},featureCollection:ur,multiLineString:dr,multiPoint:pr,multiPolygon:fr,geometryCollection:function(t,e,n){return void 0===n&&(n={}),ar({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:mr,lengthToRadians:gr,lengthToDegrees:function(t,e){return vr(gr(t,e))},bearingToAzimuth:function(t){var e=t%360;return e<0&&(e+=360),e},radiansToDegrees:vr,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 mr(gr(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=or[e];if(!i)throw new Error("invalid original units");var r=or[n];if(!r)throw new Error("invalid final units");return t/i*r},isNumber:yr,isObject:xr,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(!yr(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 wr(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===wr(o.geometries[i],e,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Mr(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 _r(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 Er(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 Tr(t,e){Er(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(ar(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(ar({type:o,coordinates:h},i),n,l))return!1}}))}function Sr(t,e){Tr(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!==wr(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=cr([o,s],t.properties);if(!1===e(f,n,i,p,r))return!1;r++,o=s}))&&void 0}}}))}function Ar(t,e){if(!t)throw new Error("geojson is required");Tr(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(cr(s[o],t.properties),n,i,o))return!1}}}))}var Pr=Object.freeze({__proto__:null,coordAll:function(t){var e=[];return wr(t,(function(t){e.push(t)})),e},coordEach:wr,coordReduce:function(t,e,n,i){var r=n;return wr(t,(function(t,i,s,o,a){r=0===i&&void 0===n?t:e(r,t,i,s,o,a)}),i),r},featureEach:_r,featureReduce:function(t,e,n){var i=n;return _r(t,(function(t,r){i=0===r&&void 0===n?t:e(i,t,r)})),i},findPoint:function(t,e){if(!xr(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 lr(l,a,e);case"MultiPoint":return r<0&&(r=l.length+r),lr(l[r],a,e);case"LineString":return o<0&&(o=l.length+o),lr(l[o],a,e);case"Polygon":return s<0&&(s=l.length+s),o<0&&(o=l[s].length+o),lr(l[s][o],a,e);case"MultiLineString":return r<0&&(r=l.length+r),o<0&&(o=l[r].length+o),lr(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),lr(l[r][s][o],a,e)}throw new Error("geojson is invalid")},findSegment:function(t,e){if(!xr(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),cr([l[o],l[o+1]],a,e);case"Polygon":return s<0&&(s=l.length+s),o<0&&(o=l[s].length+o-1),cr([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),cr([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),cr([l[r][s][o],l[r][s][o+1]],a,e)}throw new Error("geojson is invalid")},flattenEach:Tr,flattenReduce:function(t,e,n){var i=n;return Tr(t,(function(t,r,s){i=0===r&&0===s&&void 0===n?t:e(i,t,r,s)})),i},geomEach:Er,geomReduce:function(t,e,n){var i=n;return Er(t,(function(t,r,s,o,a){i=0===r&&void 0===n?t:e(i,t,r,s,o,a)})),i},lineEach:Ar,lineReduce:function(t,e,n){var i=n;return Ar(t,(function(t,r,s,o){i=0===r&&void 0===n?t:e(i,t,r,s,o)})),i},propEach:Mr,propReduce:function(t,e,n){var i=n;return Mr(t,(function(t,r){i=0===r&&void 0===n?t:e(i,t,r)})),i},segmentEach:Sr,segmentReduce:function(t,e,n){var i=n,r=!1;return Sr(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 Cr(t){var e=[1/0,1/0,-1/0,-1/0];return wr(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 Lr(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 Rr(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 Ir(t){return"Feature"===t.type?t.geometry:t}function Dr(t,e,n=0,i=t.length-1,r=Fr){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);Dr(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(Or(t,n,e),r(t[i],s)>0&&Or(t,n,i);o<a;){for(Or(t,o,a),o++,a--;r(t[o],s)<0;)o++;for(;r(t[a],s)>0;)a--}0===r(t[n],s)?Or(t,n,a):(a++,Or(t,a,i)),a<=e&&(n=a+1),e<=a&&(i=a-1)}}function Or(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function Fr(t,e){return t<e?-1:t>e?1:0}Cr.default=Cr;class Br{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(!Yr(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;Yr(t,a)&&(e.leaf?n.push(o):qr(t,a)?this._all(o,n):r.push(o))}e=r.pop()}return n}collides(t){let e=this.data;if(!Yr(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(Yr(t,s)){if(e.leaf||qr(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=Zr([]),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=Nr(t,n.children,e);if(-1!==i)return n.children.splice(i,1),r.push(n),this._condense(r),this}l||n.leaf||!qr(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=Zr(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=Zr([]),s.leaf=!1,s.height=i;const a=Math.ceil(r/o),l=a*Math.ceil(Math.sqrt(o));Jr(t,e,n,l,this.compareMinX);for(let r=e;r<=n;r+=l){const e=Math.min(r+l-1,n);Jr(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=Gr(o),l=jr(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),kr(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=Zr(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=Zr([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=Ur(t,0,o,this.toBBox),a=Ur(t,o,n,this.toBBox),l=Xr(e,a),h=Gr(e)+Gr(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:Vr,r=t.leaf?this.compareMinY:Hr;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=Ur(t,0,e,r),o=Ur(t,n-e,n,r);let a=Wr(s)+Wr(o);for(let i=e;i<n-e;i++){const e=t.children[i];kr(s,t.leaf?r(e):e),a+=Wr(s)}for(let i=n-e-1;i>=e;i--){const e=t.children[i];kr(o,t.leaf?r(e):e),a+=Wr(o)}return a}_adjustParentBBoxes(t,e,n){for(let i=n;i>=0;i--)kr(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 Nr(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){Ur(t,0,t.children.length,e,t)}function Ur(t,e,n,i,r){r||(r=Zr(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];kr(r,t.leaf?i(e):e)}return r}function kr(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 Vr(t,e){return t.minX-e.minX}function Hr(t,e){return t.minY-e.minY}function Gr(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Wr(t){return t.maxX-t.minX+(t.maxY-t.minY)}function jr(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 Xr(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 qr(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Yr(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Zr(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Jr(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;Dr(t,o,e,n,r),s.push(e,o,o,n)}}class $r{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 Qr=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},Kr=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},ts=function(t,e,n,i){return e.length>0&&Array.isArray(e[0])?Kr(t,e,n,i):Qr(t,e,n,i)},es=Qr;ts.nested=Kr,ts.flat=es;function ns(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 is(t){return new Float64Array(t)}const rs=is(4),ss=is(8),os=is(12),as=is(16),ls=is(4);function hs(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 T=t-r,S=n-r,A=e-s,P=i-s;b=T*P,d=134217729*T,p=d-(d-T),f=T-p,d=134217729*P,m=d-(d-P),g=P-m,w=f*g-(b-p*m-f*m-p*g),M=A*S,d=134217729*A,p=d-(d-A),f=A-p,d=134217729*S,m=d-(d-S),g=S-m,_=f*g-(M-p*m-f*m-p*g),v=w-_,u=w-v,rs[0]=w-(v+u)+(u-_),y=b+v,u=y-b,x=b-(y-u)+(v-u),v=x-M,u=x-v,rs[1]=x-(v+u)+(u-M),E=y+v,u=E-y,rs[2]=y-(E-u)+(v-u),rs[3]=E;let C=function(t,e){let n=e[0];for(let i=1;i<t;i++)n+=e[i];return n}(4,rs),L=22204460492503146e-32*o;if(C>=L||-C>=L)return C;if(u=t-T,a=t-(T+u)+(u-r),u=n-S,h=n-(S+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 C;if(L=11093356479670487e-47*o+33306690738754706e-32*Math.abs(C),C+=T*c+P*a-(A*h+S*l),C>=L||-C>=L)return C;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*S,d=134217729*l,p=d-(d-l),f=l-p,d=134217729*S,m=d-(d-S),g=S-m,_=f*g-(M-p*m-f*m-p*g),v=w-_,u=w-v,ls[0]=w-(v+u)+(u-_),y=b+v,u=y-b,x=b-(y-u)+(v-u),v=x-M,u=x-v,ls[1]=x-(v+u)+(u-M),E=y+v,u=E-y,ls[2]=y-(E-u)+(v-u),ls[3]=E;const R=ns(4,rs,4,ls,ss);b=T*c,d=134217729*T,p=d-(d-T),f=T-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,ls[0]=w-(v+u)+(u-_),y=b+v,u=y-b,x=b-(y-u)+(v-u),v=x-M,u=x-v,ls[1]=x-(v+u)+(u-M),E=y+v,u=E-y,ls[2]=y-(E-u)+(v-u),ls[3]=E;const I=ns(R,ss,4,ls,os);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,ls[0]=w-(v+u)+(u-_),y=b+v,u=y-b,x=b-(y-u)+(v-u),v=x-M,u=x-v,ls[1]=x-(v+u)+(u-M),E=y+v,u=E-y,ls[2]=y-(E-u)+(v-u),ls[3]=E;const D=ns(I,os,4,ls,as);return as[D-1]}(t,e,n,i,r,s,h)}function cs(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++)ts(t[e],s)||o.push(t[e]);return function(t){t.sort(Ms);const e=[];for(let n=0;n<t.length;n++){for(;e.length>=2&&gs(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&&gs(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 Br(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=ys(e,o),s.push(o)}const a=new Br(16);for(let t=0;t<s.length;t++)a.insert(vs(s[t]));const l=e*e,h=n*n;for(;s.length;){const t=s.shift(),e=t.p,n=t.next.p,i=xs(e,n);if(i<h)continue;const o=i/l,c=us(r,t.prev.p,e,n,t.next.next.p,o,a);c&&Math.min(xs(c,e),xs(c,n))<=o&&(s.push(t),s.push(ys(c,t)),r.remove(c),a.remove(t),a.insert(vs(t)),a.insert(vs(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 us(t,e,n,i,r,s,o){const a=new $r([],ds);let l=t.data;for(;l;){for(let t=0;t<l.children.length;t++){const e=l.children[t],r=l.leaf?bs(e,n,i):ps(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=bs(s,e,n),h=bs(s,i,r);if(t.dist<l&&t.dist<h&&ms(n,s,o)&&ms(i,s,o))return s}l=a.pop(),l&&(l=l.node)}return null}function ds(t,e){return t.dist-e.dist}function ps(t,e,n){if(fs(t,n)||fs(e,n))return 0;const i=ws(t[0],t[1],e[0],e[1],n.minX,n.minY,n.maxX,n.minY);if(0===i)return 0;const r=ws(t[0],t[1],e[0],e[1],n.minX,n.minY,n.minX,n.maxY);if(0===r)return 0;const s=ws(t[0],t[1],e[0],e[1],n.maxX,n.minY,n.maxX,n.maxY);if(0===s)return 0;const o=ws(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 fs(t,e){return t[0]>=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function ms(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&&gs(l,h,c)>0!=gs(l,h,u)>0&&gs(c,u,l)>0!=gs(c,u,h)>0)return!1;var l,h,c,u;return!0}function gs(t,e,n){return hs(t[0],t[1],e[0],e[1],n[0],n[1])}function vs(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 ys(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 xs(t,e){const n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function bs(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 ws(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,T=0===w?0:w/_,S=(1-T)*r+T*o-((1-E)*t+E*n),A=(1-T)*s+T*a-((1-E)*e+E*i);return S*S+A*A}function Ms(t,e){return t[0]===e[0]?t[1]-e[1]:t[0]-e[0]}function _s(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=Lr(t),r=Ir(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(Es(i,a[h][0],n.ignoreBoundary)){for(var c=!1,u=1;u<a[h].length&&!c;)Es(i,a[h][u],!n.ignoreBoundary)&&(c=!0),u++;c||(l=!0)}return l}function Es(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 Ts(t){if(!t)throw new Error("geojson is required");var e=[];return Tr(t,(function(t){!function(t,e){var n=[],i=t.geometry;if(null!==i){switch(i.type){case"Polygon":n=Rr(i);break;case"LineString":n=[Rr(i)]}n.forEach((function(n){(function(t,e){var n=[];return t.reduce((function(t,i){var r,s,o,a,l,h,c=cr([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)})),ur(e)}function Ss(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(As(e,i,n),s(e[r],p)>0&&As(e,i,r);f<m;){for(As(e,f,m),f++,m--;s(e[f],p)<0;)f++;for(;s(e[m],p)>0;)m--}0===s(e[i],p)?As(e,i,m):(m++,As(e,m,r)),m<=n&&(i=m+1),n<=m&&(r=m-1)}}(t,e,n||0,i||t.length-1,r||Ps)}function As(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function Ps(t,e){return t<e?-1:t>e?1:0}class Cs{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(!Vs(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;Vs(t,a)&&(e.leaf?n.push(o):ks(t,a)?this._all(o,n):r.push(o))}e=r.pop()}return n}collides(t){let e=this.data;if(!Vs(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(Vs(t,s)){if(e.leaf||ks(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=Hs([]),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=Ls(t,n.children,e);if(-1!==i)return n.children.splice(i,1),r.push(n),this._condense(r),this}l||n.leaf||!ks(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=Hs(t.slice(e,n+1)),Rs(s,this.toBBox),s;i||(i=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,i-1))),s=Hs([]),s.leaf=!1,s.height=i;const a=Math.ceil(r/o),l=a*Math.ceil(Math.sqrt(o));Gs(t,e,n,l,this.compareMinX);for(let r=e;r<=n;r+=l){const e=Math.min(r+l-1,n);Gs(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 Rs(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=Bs(o),l=zs(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),Ds(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=Hs(n.children.splice(s,n.children.length-s));o.height=n.height,o.leaf=n.leaf,Rs(n,this.toBBox),Rs(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(n,o)}_splitRoot(t,e){this.data=Hs([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Rs(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=Is(t,0,o,this.toBBox),a=Is(t,o,n,this.toBBox),l=Us(e,a),h=Bs(e)+Bs(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:Os,r=t.leaf?this.compareMinY:Fs;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=Is(t,0,e,r),o=Is(t,n-e,n,r);let a=Ns(s)+Ns(o);for(let i=e;i<n-e;i++){const e=t.children[i];Ds(s,t.leaf?r(e):e),a+=Ns(s)}for(let i=n-e-1;i>=e;i--){const e=t.children[i];Ds(o,t.leaf?r(e):e),a+=Ns(o)}return a}_adjustParentBBoxes(t,e,n){for(let i=n;i>=0;i--)Ds(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():Rs(t[n],this.toBBox)}}function Ls(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 Rs(t,e){Is(t,0,t.children.length,e,t)}function Is(t,e,n,i,r){r||(r=Hs(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];Ds(r,t.leaf?i(e):e)}return r}function Ds(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 Os(t,e){return t.minX-e.minX}function Fs(t,e){return t.minY-e.minY}function Bs(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Ns(t){return t.maxX-t.minX+(t.maxY-t.minY)}function zs(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 Us(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 ks(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Vs(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Hs(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Gs(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;Ss(t,o,e,n,r),s.push(e,o,o,n)}}var Ws=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,js=Pr.featureEach,Xs=(Pr.coordEach,br.polygon,br.featureCollection);function qs(t){var e=new Cs(t);return e.insert=function(t){if("Feature"!==t.type)throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:Ws(t),Cs.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:Ws(t),e.push(t)})):js(t,(function(t){if("Feature"!==t.type)throw new Error("invalid features");t.bbox=t.bbox?t.bbox:Ws(t),e.push(t)})),Cs.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:Ws(t),Cs.prototype.remove.call(this,t,e)},e.clear=function(){return Cs.prototype.clear.call(this)},e.search=function(t){var e=Cs.prototype.search.call(this,this.toBBox(t));return Xs(e)},e.collides=function(t){return Cs.prototype.collides.call(this,this.toBBox(t))},e.all=function(){var t=Cs.prototype.all.call(this);return Xs(t)},e.toJSON=function(){return Cs.prototype.toJSON.call(this)},e.fromJSON=function(t){return Cs.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=Ws(t);else{if("FeatureCollection"!==t.type)throw new Error("invalid geojson");e=Ws(t)}return{minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]}},e}var Ys=qs,Zs=qs;function Js(t,e){var n=Rr(t),i=Rr(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?lr([r+m*(o-r),s+m*(a-s)]):null}function $s(t,e,n){void 0===n&&(n={});for(var i=Lr(t),r=Rr(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")),Qs(r[s],r[s+1],i,o,void 0===n.epsilon?null:n.epsilon))return!0}return!1}function Qs(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 Ks(t,e){var n=Ir(t),i=Ir(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(eo(e.coordinates[n],t.coordinates)){i=!0;break}return i}(n,i);case"LineString":return $s(n,i,{ignoreEndVertices:!0});case"Polygon":case"MultiPolygon":return _s(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++)eo(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(!$s(t.coordinates[i],e))return!1;n||(n=$s(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=_s(t.coordinates[1],e))){n=!1;break}i=_s(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(!$s(t.coordinates[n],e))return!1;return!0}(n,i);case"Polygon":case"MultiPolygon":return function(t,e){var n=Cr(e),i=Cr(t);if(!to(n,i))return!1;for(var r=!1,s=0;s<t.coordinates.length-1;s++){if(!_s(t.coordinates[s],e))return!1;if(r||(r=_s(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=_s(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=Cr(t);if(!to(Cr(e),n))return!1;for(var i=0;i<t.coordinates[0].length;i++)if(!_s(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 to(t,e){return!(t[0]>e[0])&&(!(t[2]<e[2])&&(!(t[1]>e[1])&&!(t[3]<e[3])))}function eo(t,e){return t[0]===e[0]&&t[1]===e[1]}Ys.default=Zs;class no{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")}}class io{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 ro={};function so(){return ro.textPixel||512}function oo(){return ro.imgTextPixel||2048}const ao=so(),lo=oo();function ho(t,e,n){return`${t}-${e}-${n}`}const co=[{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 uo(t,e,n,i,r){const{THREE:s}=b.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,x=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,x,0)),o}class po{static getXY(t,e){return{x:t%e,y:Math.floor(t/e)}}static getSegment(t){return 2**t}static getCount(t){const e=po.getSegment(t);return e*e}static getImageInfo2(t,e,n,i){const r=po.getSegment(n),s=oo()/r;let{x:o,y:a}=po.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_${so()},h_${so()}`}`}}static getImageInfo(t){const{pfid:e,index:n,level:i,rootUrl:r,offLineLevel:s,offLineRootUrl:o}=t,a=po.getSegment(i),l=oo()/a;let{x:h,y:c}=po.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_${so()},h_${so()}`;u=`${r}?x-bce-process=image${po.resizeFirst?`/resize,m_lfit,w_${oo()},h_${oo()}`:""}${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))}}}po.updateTextureMax=1,po.levelMin=0,po.levelMax=2,po.resizeFirst=!1,po.getTileInfoId=ho,po.getVertices=uo;class fo extends Gt{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}=b.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}=b.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}=b.getInstance(),r=t.length,s=this.calcPoints(t,n).map(t=>new i.Vector3(...t)),o=io.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=io.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=ar(t)),"LineString"===e.type&&(e=ar(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=Js(t,e);return r&&i.push(r),ur(i)}var s=Ys();return s.load(Ts(e)),_r(Ts(t),(function(t){_r(s.search(t),(function(e){var r=Js(t,e);if(r){var s=Rr(r).join(",");n[s]||(n[s]=!0,i.push(r))}}))})),ur(i)}(cr([[f.x,f.y],[c.x,c.y],[u.x,u.y],[p.x,p.y]]),cr([[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],T=l>180?M.normalize().multiplyScalar(-1):M.normalize().multiplyScalar(1),S=[w[0]-T.y*n,w[1]+T.x*n],A=[w[0]+T.y*n,w[1]-T.x*n];return{hull:function(t,e){void 0===e&&(e={}),e.concavity=e.concavity||1/0;var n=[];if(wr(t,(function(t){n.push([t[0],t[1]])})),!n.length)return null;var i=cs(n,e.concavity);return i.length>3?hr([i]):null}(ur([lr(_),lr(A),lr(E),lr(S),lr(_)])),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=Ks(lr([t.x,t.y]),n),f=Ks(lr([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&&Ks(lr([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&&Ks(lr([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}=b.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 x=new e.InterleavedBufferAttribute(d,1,9*u+8,!1);this.bufferGeometry.setAttribute("normalScale",x);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),T=this.options.color?new Vt(this.options.color):new Vt("rgb(255, 255, 255)").alpha(0),S=this.options.strokeColor?new Vt(this.options.strokeColor):new Vt("rgb(255, 255, 255)").alpha(0);if(this.uniforms={stripTexture:{type:"t",value:null},fillColor:{type:"v4",value:new e.Vector4(T.red()/255,T.green()/255,T.blue()/255,T.alpha())},strokeColor:{type:"v4",value:new e.Vector4(S.red()/255,S.green()/255,S.blue()/255,S.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:fo.FragmentShader,vertexShader:fo.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){A.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}=b.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}=b.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}=b.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 Ht(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 Vt(t),n=this.uniforms.fillColor.value,{THREE:i}=b.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}}fo.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 ",fo.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 mo{constructor(t,e){this.values=new Map,this.capacity=t,this.totalCost=0,this.costCallback=e}get(t,e){let n;return this.values.has(t)?(n=this.values.get(t),n&&(this.values.delete(t),this.values.set(t,n))):e&&(n=e(t),n&&this.put(t,n)),n}put(t,e,n,i=!1){let r=!1;if(this.totalCost>=this.capacity){if(i)return r;const t=this.values.keys().next().value,e=this.values.get(t);if(e){const i=void 0===this.costCallback?1:this.costCallback(e);this.totalCost-=i,n&&n(t,e),this.values.delete(t)}r=!0}if(this.values.has(t)){let n=1;const i=this.values.get(t);i&&this.costCallback&&(n=this.costCallback(i));const r=void 0===this.costCallback?1:this.costCallback(e);this.values.set(t,e),this.totalCost+=r-n}else{this.values.set(t,e);const n=void 0===this.costCallback?1:this.costCallback(e);this.totalCost+=n}return r}recycle(t,e){let n=!1;const i=this.values.get(t);if(i){n=!0;const r=void 0===this.costCallback?1:this.costCallback(i);this.totalCost-=r,e&&e(t,i),this.values.delete(t)}return n}clear(t){this.values.forEach((e,n)=>{e&&t(n,e)}),this.totalCost=0,this.values.clear()}getCapacity(){return this.capacity}getTotalCost(){return this.totalCost}}class go{constructor(t){const{THREE:e}=b.getInstance();this.textureLoader=new e.TextureLoader,this.textureCache=new mo(t),this.workingTasks=new Map}static disposeAll(){this.hdFaceTexturesCache.dispose(),this.ldFaceTexturesCache.dispose()}static get hdFaceTexturesCache(){return go.sharedHdFaceTextureCache||(go.sharedHdFaceTextureCache=new go(32)),go.sharedHdFaceTextureCache}static get ldFaceTexturesCache(){return go.sharedLdFaceTextureCache||(go.sharedLdFaceTextureCache=new go(32)),go.sharedLdFaceTextureCache}dispose(){this.textureCache.clear((t,e)=>{e.dispose()})}async loadTexture(t,e=!0){const n=this.textureCache.get(t);if(n)return n;let i=this.workingTasks.get(t);return i||(i=new Promise((n,i)=>{this.textureLoader.load(t,i=>{this.textureCache.put(t,i,(t,e)=>{e.dispose()},!e),this.workingTasks.delete(t),n(i)},()=>{},e=>{w.emit("error",`Loading '${t}' failed.`),this.workingTasks.delete(t),i(e)})}),this.workingTasks.set(t,i)),i}async preloadTextures(t,e){const n=e>t.length?t.length:e,i=t.map((t,n)=>{if(t)return this.loadTexture(t,n<e)}),r=[];for(let t=0;t<n;t+=1){const e=i[t];e&&r.push(e)}return Promise.all(r)}recycleTexture(t){return this.textureCache.recycle(t,(t,e)=>{e.dispose()})}getCapacity(){return this.textureCache.getCapacity()}getTotalCost(){return this.textureCache.getTotalCost()}}class vo{constructor(t){this.cubeTextureCache=new mo(t),this.workingTasks=new Map}static disposeAll(){this.sharedInstance.dispose()}dispose(){this.cubeTextureCache.clear((t,e)=>{e.dispose()})}async loadCubeTexture(t,e,n){const i=this.cubeTextureCache.get(t[0]);if(i)return i;const{THREE:r}=b.getInstance();let s=this.workingTasks.get(t[0]);return s||(s=new Promise(async i=>{const s=(await go.ldFaceTexturesCache.preloadTextures(t,t.length)).map(t=>t.image),o=new r.CubeTexture(s);o.needsUpdate=!0,!0===n&&t.forEach(t=>{go.ldFaceTexturesCache.recycleTexture(t)}),this.cubeTextureCache.put(t[0],o,(t,e)=>{e.dispose()},!e),this.workingTasks.delete(t[0]),i(o)}),this.workingTasks.set(t[0],s)),s}async preloadCubeTextures(t,e,n){const i=e>t.length?t.length:e,r=t.map((t,e)=>{if(t)return n?this.loadCubeTexture(t,e<i,n[e]):this.loadCubeTexture(t,e<i)}),s=[];for(let t=0;t<i;t+=1){const e=r[t];e&&s.push(e)}return Promise.all(s)}recycleCubeTexture(t){this.cubeTextureCache.recycle(t[0],(t,e)=>{e.dispose()})}getCapacity(){return this.cubeTextureCache.getCapacity()}}vo.sharedInstance=new vo(3);class yo extends Gt{constructor(t,e,n,i,r=[],s,o,a,l,h,c=!1){super();const{THREE:u}=b.getInstance();this.pid=t,this.seqID=e,this.highTextureURLs=s||[],this.textureURLs=n,this.useLowTextureURLsOnly=!!o,this.tiledTextureURLRoot=a,this.neighborPanoramaIDs=r,this.viewConfigurations=new Map,this.panoViews=new Set,this.initialized=!1,this.needsUpdate=!1,this.legacyMode=c;const d=new u.BoxBufferGeometry(2,2,2);this.wireFrame=new u.LineSegments(new u.EdgesGeometry(d),new u.LineBasicMaterial({color:16711680})),this.wireFrame.material.visible=!1,this.wireFrame.renderOrder=100,this.add(this.wireFrame);const p=new u.SphereBufferGeometry(1,60,40);if(p.scale(1,-1,1),p.rotateY(-90*Math.PI/180),this.sphereMesh=new u.Mesh(p),this.sphereMesh.visible=!1,this.sphereMesh.renderOrder=150,this.add(this.sphereMesh),this.isPlayingVideo=!1,this.videoCanvas=null,this.videoContentType="mp4",this.legacyMode){const t="\n varying vec3 v_position;\n void main(){\n v_position = position;\n v_position.y = v_position.y * -1.0;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",e="\n uniform samplerCube tCube;\n varying vec3 v_position;\n void main(){\n gl_FragColor = textureCube(tCube, v_position);\n }",n={tCube:{type:"t",value:null}};this.uniforms=n,this.material=new u.ShaderMaterial({fragmentShader:e,vertexShader:t,uniforms:n,depthTest:!1,side:u.BackSide}),this.skyBox=new u.Mesh(new u.SphereBufferGeometry(2,32,32)),this.skyBox.frustumCulled=!1,this.skyBox.material=this.material,this.skyBox.renderOrder=100,this.add(this.skyBox),this.updateTexture()}else{const t="\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",e="\n uniform sampler2D tFaceTexture;\n uniform vec2 uvScalar;\n uniform vec2 uvOffset;\n uniform vec4 blendColor;\n varying vec2 vUv;\n void main(){\n vec2 UV = vUv * uvScalar + uvOffset;\n vec4 texColor = texture2D(tFaceTexture, vec2(UV.s, 1.0 - UV.t));\n gl_FragColor = (1.0 - blendColor.a) * texColor + blendColor.a * blendColor;\n // gl_FragColor = vec4(vUv, 0.0, 1.0);\n }";[this.faceGridRows,this.faceGridCols]=i;const n=2/i[1],r=2/i[0];this.faceGridsStates=[],this.faceGridTextureCacheKeys=[],this.panoViews=new Set,this.faceGridsMaterials=[],this.faceGridsUniformses=[],this.skyBoxFaceGrids=[],this.gridCenters=[];for(let s=0;s<6;s++){const o=[],a=[],l=[],h=[],c=[],d=[];for(let s=0;s<i[0];s++){const p=[];for(let d=0;d<i[1];d++){const f=s*i[1]+d;o[f]=0,a[f]="",l[f]={tFaceTexture:{type:"t",value:null},uvScalar:{type:"v2",value:new u.Vector2(1,1)},uvOffset:{type:"v2",value:new u.Vector2(0,0)},blendColor:{type:"v4",value:new u.Vector4(0,0,0,0)}},h[f]=new u.ShaderMaterial({fragmentShader:e,vertexShader:t,uniforms:l[f],depthTest:!1,side:u.BackSide});const m=new u.PlaneBufferGeometry(n,r),g=new u.Mesh(m,h[f]);c[f]=g,g.visible=!0,g.frustumCulled=!1,g.material=h[f],g.renderOrder=100,this.add(g),p[d]=new u.Vector4(0,0,0,1)}d[s]=p}this.faceGridsStates[s]=o,this.faceGridTextureCacheKeys[s]=a,this.faceGridsUniformses[s]=l,this.faceGridsMaterials[s]=h,this.skyBoxFaceGrids[s]=c,this.gridCenters[s]=d}const s=new u.Matrix4,o=new u.Matrix4;for(let t=0;t<i[0];t++)for(let e=0;e<i[1];e++){const o=t*i[1]+e;for(let i=0;i<6;i++)s.makeTranslation(n/2-1+n*e,r/2-1+r*t,0),this.skyBoxFaceGrids[i][o].applyMatrix4(s),this.gridCenters[i][t][e].applyMatrix4(s)}for(let t=0;t<i[0];t++)for(let e=0;e<i[1];e++){const n=t*i[1]+e;s.makeTranslation(1,0,0),o.makeRotationY(Math.PI/2),this.skyBoxFaceGrids[0][n].applyMatrix4(o),this.skyBoxFaceGrids[0][n].applyMatrix4(s),this.gridCenters[0][t][e].applyMatrix4(o).applyMatrix4(s),s.makeTranslation(-1,0,0),o.makeRotationY(-Math.PI/2),this.skyBoxFaceGrids[1][n].applyMatrix4(o),this.skyBoxFaceGrids[1][n].applyMatrix4(s),this.gridCenters[1][t][e].applyMatrix4(o).applyMatrix4(s),s.makeTranslation(0,-1,0),o.makeRotationX(Math.PI/2),this.skyBoxFaceGrids[2][n].applyMatrix4(o),this.skyBoxFaceGrids[2][n].applyMatrix4(s),this.gridCenters[2][t][e].applyMatrix4(o).applyMatrix4(s),s.makeTranslation(0,1,0),o.makeRotationX(-Math.PI/2),this.skyBoxFaceGrids[3][n].applyMatrix4(o),this.skyBoxFaceGrids[3][n].applyMatrix4(s),this.gridCenters[3][t][e].applyMatrix4(o).applyMatrix4(s),s.makeTranslation(0,0,1),o.makeTranslation(0,0,0),this.skyBoxFaceGrids[4][n].applyMatrix4(o),this.skyBoxFaceGrids[4][n].applyMatrix4(s),this.gridCenters[4][t][e].applyMatrix4(o).applyMatrix4(s),s.makeTranslation(0,0,-1),o.makeRotationY(Math.PI),this.skyBoxFaceGrids[5][n].applyMatrix4(o),this.skyBoxFaceGrids[5][n].applyMatrix4(s),this.gridCenters[5][t][e].applyMatrix4(o).applyMatrix4(s)}}l&&this.position.copy(l),h&&this.quaternion.copy(h),this.baseQuaternion=(new u.Quaternion).copy(this.quaternion),this.additionalQuaternion=new u.Quaternion;const f=this.quaternion._onChangeCallback;this.quaternion._onChange(()=>{f();if((new u.Quaternion).multiplyQuaternions(this.baseQuaternion,this.additionalQuaternion).equals(this.quaternion))return;this.baseQuaternion=this.quaternion.clone();const{x:t,y:e,z:n,w:i}=(new u.Quaternion).multiplyQuaternions(this.baseQuaternion,this.additionalQuaternion);this.quaternion.set(t,e,n,i),this.needsUpdate=!0});const m=this.rotation._onChangeCallback;this.rotation._onChange(()=>{m();const t=this.additionalQuaternion.clone().invert();this.baseQuaternion=this.quaternion.clone().multiply(t)}),this.eventListeners={onPanoramaSelected:t=>{this.isSelected=t===this,this.isSelected&&this.emit(_.PANORAMA_SELECTED,this.pid)},onEnded:()=>{}},w.on(E.ELEMENT_SELECTED,this.eventListeners.onPanoramaSelected)}setTexture(t){this.uniforms.tCube.value=t,this.needsUpdate=!0,this.panoramaLoaded||this.emit(_.DID_LOAD_PANORAMA,this.pid),this.panoramaLoaded=!0}pauseVideo(){if("ts"===this.videoContentType)this.mpegVideoPlayer&&this.mpegVideoPlayer.pause();else{const t="pano_vid_"+this.pid;if(this.video=this.video||document.getElementById(t),!this.video)return;this.video.pause()}}async resumeVideo(){if("ts"===this.videoContentType)this.mpegVideoPlayer&&this.mpegVideoPlayer.play();else{const t="pano_vid_"+this.pid;if(this.video=this.video||document.getElementById(t),!this.video)return;await this.video.play()}}stopVideo(){if(this.sphereMesh.visible=!1,"ts"===this.videoContentType){this.mpegVideoPlayer&&(this.mpegVideoPlayer.stop(),this.mpegVideoPlayer.destroy(),this.mpegVideoPlayer=null);const t=this.sphereMesh.material.map;t&&t.dispose(),this.sphereMesh.material.dispose(),this.videoCanvas=null}else{const t="pano_vid_"+this.pid;this.video=this.video||document.getElementById(t);const e=this.sphereMesh.material.map;e&&e.dispose(),this.sphereMesh.material.dispose(),this.video&&(this.video.pause(),this.video.removeAttribute("src"),this.video.load(),this.video=null)}this.eventListeners.onEnded&&this.eventListeners.onEnded(),this.isPlayingVideo=!1,this.needsUpdate=!0}playVideo(t,e,n,i="mp4",r=[2048,2048]){const{onReadyToPlay:s,onEnded:o,onPrepareToPlay:a}=n||{};this.videoContentType=i;const{THREE:l}=b.getInstance();if(this.eventListeners.onEnded=o||(()=>{}),"ts"!==this.videoContentType){const n="pano_vid_"+this.pid;this.video=document.getElementById(n),this.video||(this.video=document.createElement("video"),this.video.id=n,this.video.setAttribute("webkit-playsinline","true"),this.video.setAttribute("x5-playsinline","true"),this.video.setAttribute("playsinline","true"),this.video.setAttribute("crossorigin","anonymous")),this.video.src=t,this.video.loop=!!e,this.video.addEventListener("playing",()=>{this.sphereMesh.visible=!0,this.needsUpdate=!0,s&&s(this.video),this.isPlayingVideo=!0}),this.video.addEventListener("ended",()=>{this.stopVideo()}),this.video.addEventListener("play",()=>{this.needsUpdate=!0,a&&a(this.video)}),this.video.play();const i=new l.VideoTexture(this.video);return i.needsUpdate=!0,this.sphereMesh.material=new l.MeshBasicMaterial({map:i,transparent:!1,depthTest:!1,depthWrite:!1}),this.video}{if(!JSMpeg||!JSMpeg.Player)throw new Error("JSMpeg is needed. Please get JSMpeg from https://github.com/phoboslab/jsmpeg");this.videoCanvas||(this.videoCanvas=document.createElement("canvas"),[this.videoCanvas.width,this.videoCanvas.height]=r),this.mpegVideoPlayer=new JSMpeg.Player(t,{canvas:this.videoCanvas,loop:e,autoplay:!1,disableGl:!1,onSourceEstablished:()=>{this.needsUpdate=!0,a&&a()},onPlay:()=>{this.sphereMesh.visible=!0,this.needsUpdate=!0,s&&s(),this.isPlayingVideo=!0},onPause:()=>{},onStalled:()=>{},onEnded:()=>{this.stopVideo()},chunkSize:8388608,videoBufferSize:4194304,decodeFirstFrame:!1,preserveDrawingBuffer:!1});const n=new l.CanvasTexture(this.videoCanvas);n.needsUpdate=!0,no.DetectIOS()&&(n.flipY=!1),this.sphereMesh.material=new l.MeshBasicMaterial({map:n,transparent:!1,depthTest:!1,depthWrite:!1}),this.mpegVideoPlayer.source.established=!1,this.mpegVideoPlayer.source.loadedSize=0,this.mpegVideoPlayer.demuxer.startTime=0,this.mpegVideoPlayer.demuxer.currentTime=0,this.mpegVideoPlayer.demuxer.bits=null,this.mpegVideoPlayer.demuxer.leftoverBytes=null,this.mpegVideoPlayer.audioOut.resetEnqueuedTime(),this.mpegVideoPlayer.audioOut.unlock(),this.mpegVideoPlayer.seek(0),this.mpegVideoPlayer.play()}return null}getIntersectedTiles(t){if(!t)return{hdTiles:[],ldTiles:[]};const{THREE:e}=b.getInstance();this.updateMatrixWorld(),t.updateMatrixWorld();const n=t.position.clone(),i=this.gridCenters.map(t=>t.map(t=>t.map(t=>{const i=t.clone().applyMatrix4(this.matrixWorld);return new e.Vector3(i.x,i.y,i.z).sub(n).normalize()}))),r=new e.Vector3(0,0,-1).applyQuaternion(t.quaternion),s=[],o=[],a=Math.SQRT1_2;for(let t=0;t<6;t++)for(let e=0;e<this.faceGridRows;e++)for(let n=0;n<this.faceGridCols;n++){const l=i[t][e][n].dot(r);l>=a?s.push([t,e,n,l]):o.push([t,e,n,l])}return this.isPlayingVideo?{hdTiles:[],ldTiles:o}:{hdTiles:s,ldTiles:o}}setFaceTexture(t,e,n,i){const{THREE:r}=b.getInstance(),s=t[0],o=t[1],a=t[2],l=o*this.faceGridCols+a;this.faceGridsUniformses[s][l].tFaceTexture.value=e;const{uvScalar:h,uvOffset:c,blendColor:u}=n||{};this.faceGridsUniformses[s][l].uvScalar.value=h||new r.Vector2(1,1),this.faceGridsUniformses[s][l].uvOffset.value=c||new r.Vector2(0,0),this.faceGridsUniformses[s][l].blendColor.value=u||new r.Vector4(0,0,0,0),i&&(this.faceGridTextureCacheKeys[s][l]=i),this.needsUpdate=!0}async updateTexture(t){if(this.legacyMode){t&&(this.textureURLs=t);const e=await vo.sharedInstance.loadCubeTexture(this.textureURLs);this.setTexture(e)}else{for(let t=0;t<6;t++)for(let e=this.faceGridCols*this.faceGridRows-1;e>=0;e--)this.faceGridsStates[t][e]=0;t&&(this.highTextureURLs=t,this.textureURLs=t)}this.needsUpdate=!0}async updateHDGridTextures(t){if(this.useLowTextureURLsOnly)return[];const{THREE:e}=b.getInstance();if(this.tiledTextureURLRoot){const e=["r","l","t","d","f","b"],n=t.map(t=>`${this.tiledTextureURLRoot}${this.seqID}_${e[t[0]]}_${t[1]}-${t[2]}`),i=await go.hdFaceTexturesCache.preloadTextures(n,t.length);for(let e=t.length-1;e>=0;e--)this.setFaceTexture(t[e],i[e],void 0,n[e]);return i}if(!this.highTextureURLs.length)return[];const n=t.map(t=>""+this.highTextureURLs[t[0]]),i=await go.hdFaceTexturesCache.preloadTextures(n,t.length),r=new e.Vector2(1/this.faceGridCols,1/this.faceGridRows);for(let s=t.length-1;s>=0;s--){const o=new e.Vector2(r.x*t[s][2],r.y*t[s][1]);this.setFaceTexture(t[s],i[s],{uvScalar:r,uvOffset:o},n[s])}return i}async updateLDGridTextures(t){const{THREE:e}=b.getInstance(),n=t.map(t=>""+this.textureURLs[t[0]]),i=await go.ldFaceTexturesCache.preloadTextures(n,t.length),r=new e.Vector2(1/this.faceGridCols,1/this.faceGridRows);for(let s=t.length-1;s>=0;s--){const o=new e.Vector2(r.x*t[s][2],r.y*t[s][1]);this.setFaceTexture(t[s],i[s],{uvScalar:r,uvOffset:o},n[s])}return i}async updateFaceGridsTextures(t,e){this.panoramaLoaded||this.emit(_.WILL_LOAD_PANORAMA,this.pid);const n=[];t.forEach(t=>{2!==this.faceGridsStates[t[0]][this.faceGridCols*t[1]+t[2]]&&n.push(t)}),await this.updateLDGridTextures(n);const i=[];e.forEach(t=>{1!==this.faceGridsStates[t[0]][this.faceGridCols*t[1]+t[2]]&&i.push(t)}),await this.updateLDGridTextures(i);for(let t=0;t<6;t++)for(let e=this.faceGridRows*this.faceGridCols-1;e>=0;e--)this.faceGridsStates[t][e]=0;t.forEach(t=>{this.faceGridsStates[t[0]][this.faceGridCols*t[1]+t[2]]=2}),e.forEach(t=>{this.faceGridsStates[t[0]][this.faceGridCols*t[1]+t[2]]=1}),this.updateHDGridTextures(n),this.panoramaLoaded||this.emit(_.DID_LOAD_PANORAMA,this.pid),this.panoramaLoaded=!0}setUseLowTexturesOnly(t){this.useLowTextureURLsOnly=t}isUseLowTexturesOnly(){return this.useLowTextureURLsOnly}dispose(){super.dispose(),this.faceGridsMaterials&&this.faceGridsMaterials.forEach(t=>{t.forEach(t=>{t.dispose()})}),this.skyBoxFaceGrids&&this.skyBoxFaceGrids.forEach(t=>{t.forEach(t=>{t.geometry&&t.geometry.dispose()})}),this.stopVideo(),this.eventListeners.onEnded&&(this.eventListeners.onEnded=null),this.sphereMesh&&this.sphereMesh.material&&this.sphereMesh.material.dispose(),this.initialized=!1,w.off(E.ELEMENT_SELECTED,this.eventListeners.onPanoramaSelected)}update(){const t=new Ht(this);return this.initialized?(this.needsUpdate||this.isPlayingVideo)&&(t.needUpdate=!0,this.isPlayingVideo&&this.videoCanvas&&this.sphereMesh.material.map&&(this.sphereMesh.material.map.needsUpdate=!0),this.needsUpdate=!1):(this.initialized=!0,t.needUpdate=!0),this.initialized&&!this.parent&&(t.shouldPlaceElement=!0),t}setAdditionalRotationInEuler(t,e,n){const{THREE:i}=b.getInstance();this.additionalQuaternion.setFromEuler(new i.Euler(t,e,n));const{x:r,y:s,z:o,w:a}=this.baseQuaternion.clone().multiply(this.additionalQuaternion);return this.quaternion.set(r,s,o,a),this.needsUpdate=!0,this.additionalQuaternion.clone()}setAdditionalRotationInQuaternion(t,e,n,i){const{THREE:r}=b.getInstance();this.additionalQuaternion.set(t,e,n,i);const{x:s,y:o,z:a,w:l}=this.baseQuaternion.clone().multiply(this.additionalQuaternion);return this.quaternion.set(s,o,a,l),this.needsUpdate=!0,(new r.Euler).setFromQuaternion(this.additionalQuaternion)}addViewConfiguration(t){const e={...this.viewConfigurations.get(t.targetView),...t};this.viewConfigurations.set(t.targetView,e),this.needsUpdate=!0}}var xo;(xo=t.IndicatorDisplayMode||(t.IndicatorDisplayMode={}))[xo.AlwaysHide=0]="AlwaysHide",xo[xo.AlwaysShow=1]="AlwaysShow",xo[xo.Editing=2]="Editing",xo[xo.Show=3]="Show";class bo extends Gt{constructor(e,n,i){super();const{THREE:r}=b.getInstance();this.initialized=!1;const{modelElement:s,groundParams:o,indicatorImageURL:a,invisibleIndicatorImageURL:l,indicatorWidth:h,indicatorHeight:c,indicatorPositionMap:u,globalScale:d}=n||{globalScale:1};this.currentPanoramaID=-1,this.panoramaMap=new Map,this.indicatorMap=new Map,this.indicatorVisibilityMap=new Map,this.indicatorHiddenMap=new Map,this.indicatorPositionMap=u||new Map,this.inSightIndicators=[],this.indicatorWidth=h||2*bo.IndicatorRadius,this.indicatorHeight=c||2*bo.IndicatorRadius,this.maxWorldDistance=13,this.globalScale=d||1,this.group=new r.Group,this.add(this.group),this.viewConfigurations=new Map,this.eventListeners={onFloorModelLoaded:t=>{t===this.modelElement&&this.updateIndicatorsPositions()}},this.groundParams=o,this.bindModelElement(s);const p=["varying vec2 vUv;","void main(){"," vUv = uv;"," gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),f=["uniform sampler2D map;","uniform float opacity;","uniform vec4 blendColor;","varying vec2 vUv;","void main(){"," vec4 texColor = texture2D(map, vUv);"," gl_FragColor = vec4((texColor * (1.0 - blendColor.a) + blendColor * blendColor.a).rgb, texColor.a * opacity);","}"].join("\n");let m,g,v;this.indicatorShaderUniforms={map:{type:"t",value:null},blendColor:{type:"v4",value:new r.Vector4(0,0,0,0)},opacity:{value:1}},this.invisibleIndicatorShaderUniforms={map:{type:"t",value:null},blendColor:{type:"v4",value:new r.Vector4(1,0,0,.5)},opacity:{value:1}},this.indicatorMaterials=new Map,a?(g=new r.PlaneBufferGeometry(this.indicatorWidth,this.indicatorHeight),m=new r.ShaderMaterial({transparent:!0,vertexShader:p,fragmentShader:f,uniforms:this.indicatorShaderUniforms,side:r.DoubleSide,depthTest:!1,depthWrite:!1,name:"indicatorMaterial"}),this.indicatorImageURL=a,(new r.TextureLoader).load(a,t=>{this.indicatorShaderUniforms.map.value=t})):(g=new r.CircleGeometry(this.indicatorWidth/2,32),m=new r.MeshBasicMaterial({transparent:!0}),m.side=r.DoubleSide,m.depthTest=!1,m.depthWrite=!1,m.color=new r.Color(16777215));const y=l||a;y?(v=new r.ShaderMaterial({transparent:!0,vertexShader:p,fragmentShader:f,uniforms:this.invisibleIndicatorShaderUniforms,side:r.DoubleSide,depthTest:!1,depthWrite:!1,name:"invisibleIndicatorMaterial"}),(new r.TextureLoader).load(y,t=>{this.invisibleIndicatorShaderUniforms.map.value=t})):(v=new r.MeshBasicMaterial,v.side=r.DoubleSide,v.depthTest=!1,v.depthWrite=!1,v.color=new r.Color(16711680));const x=new r.Mesh(g,m);this.setIndicatorMeshPrototype(x),this.setIndicatorMaterial(m,t.IndicatorDisplayMode.Editing,!0),this.setIndicatorMaterial(v,t.IndicatorDisplayMode.Editing,!1),this.setIndicatorMaterial(m,t.IndicatorDisplayMode.Show,!0),this.panoramaDatas=new Map,e.forEach(t=>{this.panoramaDatas.set(t.pid,t)}),this.panoramaCreatingTasks=new Map,!0===i&&e.forEach(t=>{this.getPanoramaByPID(t.pid)}),this.modelElement instanceof Wi&&this.modelElement.isModelLoaded()&&this.updateIndicatorsPositions(),w.on(E.ELEMENT_LOADED,this.eventListeners.onFloorModelLoaded),this.initialized=!1,this.needUpdate=!1}dispose(t){super.dispose(),w.off(E.ELEMENT_LOADED,this.eventListeners.onFloorModelLoaded),this.panoramaMap&&(this.panoramaMap.forEach(e=>{this.group.remove(e),t!==e.pid&&vo.sharedInstance.recycleCubeTexture(e.textureURLs),e.dispose()}),this.panoramaMap.clear()),this.indicatorMap&&(this.indicatorMap.forEach(t=>{this.group.remove(t)}),this.indicatorMap.clear()),this.boundBox&&(this.group.remove(this.boundBox),this.boundBox.geometry.dispose()),this.remove(this.group)}update(){const t=new Ht(this);if(this.initialized)if(this.needUpdate){this.getPIDPositionMap(this.inSightIndicators).forEach((t,e)=>{if(!this.indicatorPositionMap.get(e)&&(this.groundParams||this.modelElement instanceof Wi)){let n;if(this.groundParams&&this.groundParams.groundPlane)n=Wi.intersectWithGroundPlane(t,this.groundParams);else{n=this.modelElement.intersectGround(t)}n&&this.indicatorPositionMap.set(e,n)}}),this.inSightIndicators.forEach(t=>{let e=this.indicatorMap.get(t);if(!e){e=this.indicatorMeshPrototype.clone(),this.indicatorMap.set(t,e),this.group.add(e);const n=this.panoramaDatas.get(t);n&&n.position&&e.position.copy(n.position)}const n=this.indicatorPositionMap.get(t);n&&e.position.copy(n)}),this.needUpdate=!1,t.needUpdate=!0}else this.panoramaMap.forEach(e=>{e.update().needUpdate&&(t.needUpdate=!0)});else this.initialized=!0,t.needUpdate=!0;return this.initialized&&!this.parent&&(t.shouldPlaceElement=!0),t}bindModelElement(t){t&&(this.modelElement=t),this.boundBox&&(this.group.remove(this.boundBox),this.boundBox=null),this.getModelBoundBox()}static getBoundBox(t){if(!t)return null;const{THREE:e}=b.getInstance(),n=(new e.Box3).setFromObject(t),i=n.getSize(new e.Vector3),r=Math.max(i.x,i.y,i.z),s=new e.Mesh(new e.BoxBufferGeometry(r,r,r));return s.position.copy(n.max.clone().add(n.min).multiplyScalar(.5)),s}getModelBoundBox(){this.boundBox||(this.boundBox=bo.getBoundBox(this.modelElement),this.boundBox&&(this.boundBox.visible=!0,this.boundBox.frustumCulled=!1,this.boundBox.renderOrder=100,this.group.add(this.boundBox)))}setBoundBoxAppearance(t){this.getModelBoundBox(),this.boundBox&&(this.boundBox.material=t,this.needUpdate=!0)}setBoundBoxVisible(t){this.boundBox&&(this.boundBox.visible=t)}async presentPanorama(t,e,n){t.legacyMode||(await t.updateFaceGridsTextures(e,n),this.needUpdate=!0)}async presentPanoramaOfPID(t,e,n){const i=await this.getPanoramaByPID(t);i&&await this.presentPanorama(i,e,n),this.currentPanoramaID=t,this.emit(_.PANORAMA_PRESENTED,t)}async preloadCubeTexturesOfPIDs(t,e){const n=t.map(t=>{const e=this.panoramaDatas.get(t);if(e)return e.textureURLs});return vo.sharedInstance.preloadCubeTextures(n,e)}visibleRadiusOfView(t){if(!t)return bo.DefaultVisibleRadius;const e=this.viewConfigurations.get(t);return e&&e.visibleRadius?e.visibleRadius:bo.DefaultVisibleRadius}async allPanoramas(){const t=Array.from(this.panoramaMap.values()),e=await Promise.all(Array.from(this.panoramaCreatingTasks.values()));return t.concat(e)}async getAllPanoramas(){return this.initializePanoramasIfNecessary("all")}panoramaIDsAround(t,e){const n=this.panoramaDatas.get(t);if(!n||!n.position)return null;const i=[t],r=this.visibleRadiusOfView(e);return n.neighbourPanoramaIDs.map(t=>this.panoramaDatas.get(t)).forEach(t=>{if(t&&t.position){n.position.distanceTo(t.position)<=r&&i.push(t.pid)}}),i}async presentPanoramaAround(t,e,n,i){this.panoramaIDsAround(t,i)&&await this.presentPanoramaOfPID(t,e,n)}getPIDPositionMap(t){const e=new Map;return t.forEach(t=>{const n=this.panoramaDatas.get(t);n&&e.set(t,n.position)}),e}getIndicatorPosition(t){return this.indicatorPositionMap.get(t)}presentPanoramaIndicators(t){if(!this.modelElement)return;this.inSightIndicators=[];const{THREE:e}=b.getInstance();t.forEach((t,n)=>{if(this.groundParams||this.modelElement instanceof Wi){if(!this.indicatorPositionMap.get(n)){let i;if(this.groundParams&&this.groundParams.groundPlane)i=Wi.intersectWithGroundPlane(t,this.groundParams);else{i=this.modelElement.intersectGround(t)}i&&this.indicatorPositionMap.set(n,i.add(new e.Vector3(0,0,bo.IndicatorOffsetZ)))}}this.inSightIndicators.push(n)}),this.needUpdate=!0}async updateIndicatorsPositions(){const{THREE:t}=b.getInstance();this.panoramaMap.forEach((e,n)=>{if(this.indicatorPositionMap.get(n))return;const{position:i}=e;let r;if(this.groundParams&&this.groundParams.groundPlane)r=Wi.intersectWithGroundPlane(i,this.groundParams);else{r=this.modelElement.intersectGround(i)}r&&this.indicatorPositionMap.set(n,r.add(new t.Vector3(0,0,bo.IndicatorOffsetZ)))});const e=await this.getPIDPositionMap(this.inSightIndicators);this.presentPanoramaIndicators(e)}async presentPanoramaIndicatorsAround(t,e){const n=this.panoramaIDsAround(t,e);if(n){const t=await this.getPIDPositionMap(n);this.presentPanoramaIndicators(t)}}getIndicatorVisibility(t){const e=this.indicatorVisibilityMap.get(t);return void 0===e||e}setIndicatorVisibility(t,e){let n;void 0===e?(n=[],this.indicatorMap.forEach((t,e)=>{n.push(e)})):n=Array.isArray(e)?e:[e],n.forEach(e=>{this.indicatorVisibilityMap.set(e,t);const n=this.indicatorMap.get(e);n&&(this.group.remove(n),this.indicatorMap.delete(e))}),this.needUpdate=!0}setIndicatorHidden(t,e){let n;void 0===e?(n=[],this.indicatorMap.forEach((t,e)=>{n.push(e)})):n=Array.isArray(e)?e:[e],n.forEach(e=>{this.indicatorHiddenMap.set(e,t);const n=this.indicatorMap.get(e);n&&(this.group.remove(n),this.indicatorMap.delete(e))}),this.needUpdate=!0}intersectIndicators(t,e){let n=[];const i=e.normalize(),r=Math.min(this.indicatorHeight,this.indicatorWidth)/2;return this.indicatorMap.forEach((e,s)=>{const o=e.position;if(Number.isNaN(o.x))return;const a=o.clone().sub(t),l=a.dot(i);if(l>0){const t=i.clone().multiplyScalar(l),e=a.sub(t).length();e<=r&&n.push({pid:s,distance:e})}}),n.length>0?(n=n.sort((t,e)=>t.distance<e.distance?-1:t.distance>e.distance?1:0),n[0].pid):-1}intersectIndicatorsOnScreen(t,e,{screenWidth:n,screenHeight:i},r){const s=Array.from(this.indicatorMap),o=s.map(([,t])=>t),a=Fn.getMouseIntersectionOnScreen(o,t,{screenWidth:n,screenHeight:i},e,r,o,this.maxWorldDistance);if(a){const t=s.find(([,t])=>t===a);if(t)return t[0]}return-1}putPanorama(t){const e=this.panoramaMap.get(t.pid);e&&(this.group.remove(e),e.dispose()),this.panoramaMap.set(t.pid,t),this.group.add(t),this.needUpdate=!0}async initializePanoramasIfNecessary(t){let e=[];if(Array.isArray(t))e=t;else if("all"===t)e=Array.from(this.panoramaDatas.keys());else{const n=t;e.push(n);const i=new Set;i.add(n);const r=[n];for(;r.length>0;){const t=r.splice(0,1)[0],n=this.panoramaDatas.get(t);n&&n.neighbourPanoramaIDs.forEach(t=>{i.has(t)||(i.add(t),r.push(t),e.push(t))})}}const n=e.map(t=>this.getPanoramaByPID(t));return Promise.all(n)}async getPanoramaByPID(t){const e=this.panoramaMap.get(t);if(e)return e;const n=this.panoramaCreatingTasks.get(t);if(n)return n;const i=this.panoramaDatas.get(t);if(!i)return;const r=new Promise(t=>{const e=new yo(i.pid,i.seqID,i.textureURLs,[2,2],i.neighbourPanoramaIDs,i.highTextureURLs,i.useLowTextureURLsOnly,i.tiledTextureURLRoot,i.position,i.quaternion,!!i.legacyMode);e.scale.set(this.globalScale,this.globalScale,this.globalScale),this.putPanorama(e),this.panoramaCreatingTasks.delete(i.pid),t(e)});return this.panoramaCreatingTasks.set(i.pid,r),r}getPanoramaByPIDInstant(t){return this.panoramaMap.get(t)||null}getNeghbourPanoClosestToRay(t){if(-1===this.currentPanoramaID)return-1;const e=this.panoramaMap.get(this.currentPanoramaID);if(!e)return-1;if(!e.neighborPanoramaIDs||0===e.neighborPanoramaIDs.length)return-1;const n=t.clone().normalize();let i=-1,r=-1;return e.neighborPanoramaIDs.forEach(t=>{const s=this.panoramaMap.get(t);if(!s)return;const o=s.position.clone().sub(e.position).normalize().dot(n);o>i&&(i=o,r=t)}),i>=Math.cos(12*Math.PI/180)?r:-1}updateIndicatorGeometry(){const{THREE:t}=b.getInstance();let e;e=this.indicatorImageURL?new t.PlaneBufferGeometry(this.indicatorWidth,this.indicatorHeight):new t.CircleGeometry(this.indicatorWidth/2,32);const n=new Set;Array.from(this.indicatorMap).forEach(([,t])=>{n.add(t.geometry),t.geometry=e}),Array.from(n).forEach(t=>{t.dispose()}),this.indicatorMeshPrototype.geometry=e;const i=new t.Mesh(e,this.indicatorMeshPrototype.material);this.setIndicatorMeshPrototype(i)}setIndicatorSize(t,e){this.indicatorWidth=t,this.indicatorHeight=e,this.updateIndicatorGeometry()}setIndicatorImageURL(e){const{THREE:n}=b.getInstance();(new n.TextureLoader).load(e,i=>{const r=["varying vec2 vUv;","void main(){"," vUv = uv;"," gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),s=["uniform sampler2D map;","uniform float opacity;","uniform vec4 blendColor;","varying vec2 vUv;","void main(){"," vec4 texColor = texture2D(map, vUv);"," gl_FragColor = vec4((texColor * (1.0 - blendColor.a) + blendColor * blendColor.a).rgb, texColor.a * opacity);","}"].join("\n");let o=this.getIndicatorMaterial(t.IndicatorDisplayMode.Editing,!0),a=new n.ShaderMaterial({transparent:!0,vertexShader:r,fragmentShader:s,uniforms:this.indicatorShaderUniforms,side:n.DoubleSide,depthTest:!1,depthWrite:!1,name:"indicatorMaterial"});this.setIndicatorMaterial(a,t.IndicatorDisplayMode.Editing,!0),o.dispose(),o=this.getIndicatorMaterial(t.IndicatorDisplayMode.Show,!0),this.setIndicatorMaterial(a,t.IndicatorDisplayMode.Show,!0),o.dispose(),a=new n.ShaderMaterial({transparent:!0,vertexShader:r,fragmentShader:s,uniforms:this.invisibleIndicatorShaderUniforms,side:n.DoubleSide,depthTest:!1,depthWrite:!1,name:"invisibleIndicatorMaterial"}),this.indicatorShaderUniforms.map.value=i,this.invisibleIndicatorShaderUniforms.map.value=i,this.setIndicatorMaterial(a,t.IndicatorDisplayMode.Editing,!1),this.indicatorImageURL||this.setIndicatorMeshPrototype(new n.Mesh(new n.PlaneBufferGeometry(this.indicatorWidth,this.indicatorHeight),a)),this.indicatorImageURL=e,this.needUpdate=!0,this.updateIndicatorGeometry()})}getIndicatorSize(){return[this.indicatorWidth,this.indicatorHeight]}setIndicatorMeshPrototype(t){this.indicatorMeshPrototype=t,this.panoramaMap.forEach((t,e)=>{const n=this.indicatorMap.get(e);n&&(this.group.remove(n),this.indicatorMap.delete(e))}),t.renderOrder=300,this.needUpdate=!0}setIndicatorMaterial(t,e,n){let i=this.indicatorMaterials.get(e);i||(i=new Map,this.indicatorMaterials.set(e,i)),i.set(n,t),this.needUpdate=!0}getIndicatorMaterial(t,e){let n=this.indicatorMaterials.get(t);return n||(n=new Map,this.indicatorMaterials.set(t,n)),n.get(e)}addGroupViewConfiguration(t){const e=this.viewConfigurations.get(t.targetView);e&&(void 0===t.showBoundBox&&void 0!==e.showBoundBox&&(t.showBoundBox=e.showBoundBox),void 0===t.visibleRadius&&void 0!==e.visibleRadius&&(t.visibleRadius=e.visibleRadius),void 0===t.indicatorDisplayMode&&void 0!==e.indicatorDisplayMode&&(t.indicatorDisplayMode=e.indicatorDisplayMode)),this.viewConfigurations.set(t.targetView,t),this.needUpdate=!0}async addViewConfiguration(t){(await this.allPanoramas()).forEach(e=>{e.addViewConfiguration(t)})}setMaxWorldDistance(t){this.maxWorldDistance=t}}bo.DefaultVisibleRadius=10,bo.IndicatorRadius=.1,bo.IndicatorOffsetZ=.1;class wo extends Gt{constructor(t,e,n=1){super(),this.initialized=!1,this.loaded=!1,this.opacity=n,this.mapping=e,this.groundMeshes=[],t&&this.load(t)}static getShapeDefs(t){const e=[],{THREE:n}=b.getInstance();if(t.commands&&t.commands.length){const i=new n.Shape,r=[];let s=null,o=0;t.commands.forEach(({command:t,args:e})=>{s&&o>1?("M"===t&&(s&&r.push(s),s=new n.Path,s.moveTo(e[0],e[1])),"C"===t&&s.bezierCurveTo(e[0],e[1],e[2],e[3],e[4],e[5]),"L"===t&&s.lineTo(e[0],e[1])):("M"===t&&(o+=1,2===o?(s=new n.Path,s.moveTo(e[0],e[1])):i.moveTo(e[0],e[1])),"C"===t&&i.bezierCurveTo(e[0],e[1],e[2],e[3],e[4],e[5]),"L"===t&&i.lineTo(e[0],e[1]))}),s&&r.push(s),i.holes=r;const a={shape:i};t.fill&&Object.assign(a,{color:parseInt(t.fill.substr(1),16)}),t.tag&&Object.assign(a,{tag:t.tag}),e.push(a)}return t.children&&t.children.length&&t.children.forEach(t=>{e.push(...wo.getShapeDefs(t))}),e}async load(t){this.initialized=!1,this.loaded=!1;const{THREE:e}=b.getInstance(),n=await new Promise(n=>{(new e.FileLoader).load(t,t=>{n(t)})}),i=await wt(n),r=On.svg2canvas(i,this.mapping);if(null!==r){const t=wo.getShapeDefs(r),n=new e.Group;t.forEach(({shape:t,color:i,tag:r})=>{const s={steps:1,depth:1,bevelEnabled:!1,bevelThickness:.1,bevelSize:.2,bevelOffset:0,bevelSegments:2};switch(r){case"ground":Object.assign(s,{bevelSize:.1,depth:.8});break;case"store":Object.assign(s,{depth:2,bevelThickness:.3,bevelSize:.3})}const o=new e.ExtrudeBufferGeometry(t,s),a=new e.MeshLambertMaterial({color:i,transparent:!0,opacity:this.opacity}),l=new e.Mesh(o,a);switch(r){case"ground":l.receiveShadow=!0,l.position.set(0,0,-.2),this.groundMeshes.push(l);break;case"impassable":case"store":l.castShadow=!0}n.add(l)}),this.add(n),this.loaded=!0}}setOpacity(t){const{THREE:e}=b.getInstance();this.traverse(n=>{const i=n;i.isMesh&&i.material instanceof e.Material&&(i.material.opacity=t)})}setShadowEnabled(t){this.groundMeshes.forEach(e=>{e.receiveShadow=t})}update(){const t=new Ht(this);return!this.initialized&&this.loaded&&(this.initialized=!0,t.needUpdate=!0),this.initialized&&!this.parent&&(t.shouldPlaceElement=!0),t}dispose(){super.dispose(),this.groundMeshes=[],Fn.dispose(this,!0)}}class Mo{static getCameraLookAtPositionByYawPitch({x:t,y:e,z:n},i,r){const s=Math.cos(r/180*Math.PI),o=s*Math.sin(-i/180*Math.PI),a=s*Math.cos(i/180*Math.PI),l=Math.sin(r/180*Math.PI),{THREE:h}=b.getInstance();return{position:new h.Vector3(t+o,e+a,n+l),degree:i}}static setCameraLookAtByYawPitch(t){const{position:e}=Mo.getCameraLookAtPositionByYawPitch(t.position.clone(),t.getYaw(),t.getPitch());t.lookAt(e,0,0,!1)}static getYawPitchFromCameraLookVector(t){const e=Math.asin(t.z)/Math.PI*180;return{yaw:-Math.atan2(t.x,t.y)/Math.PI*180,pitch:e}}}class _o extends e.Vector3{constructor(t,e,n,i){super(t,e,n),i&&(this.callback=i)}set(t,e,n){return super.set(t,e,n),this.callback&&this.callback(),this}}class Eo extends e.CameraHelper{constructor(t){super(t);const{THREE:e}=b.getInstance(),n=t.matrixWorld.elements.slice();n[12]=0,n[13]=0,n[14]=0,this.matrix=(new e.Matrix4).fromArray(n)}update(){const t=this.camera.matrixWorld.elements.slice();t[12]=0,t[13]=0,t[14]=0,this.matrix.fromArray(t),super.update()}}class To extends Gt{constructor(t,e){super(),this.modelInitialized=!1,this.pointMap=new Map,this.gradientDistance=2,this.viewDistance=(e||{}).viewDistance||30,t&&this.load(t,e)}static generatePathMesh(t,e){const{viewDistance:n=10,gradientDistance:i=2,arrowImageRatio:r=1,arrowImageURL:s,floorModel:o,groundParams:a,color:l,dynamicPathEnabled:h,width:c=.3}=e||{},u=Xi.simplify(t,!0),d=Xi.smoothPath(u.map(t=>[t.x,t.y])),p=[],f=[0],m=[0],{THREE:g}=b.getInstance();d.reduce(([t,e],[n,i],r)=>{p.push(new g.Vector2(e-i,n-t).normalize());const s=Math.sqrt((t-n)**2+(e-i)**2);return f.push(f[r-1]+s),[n,i]});for(let t=0,e=f.length;t<e;t+=1)m[t]=f[t]/f[e-1];const v=[],y=[],x=c;p.forEach((t,e)=>{if(0===e){const[e,n]=d[0];v.push([e+t.x*x,n+t.y*x]),y.push([e-t.x*x,n-t.y*x])}const[n,i]=d[e+1];v.push([n+t.x*x,i+t.y*x]),y.push([n-t.x*x,i-t.y*x])}),y.reverse();const M=new g.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 _=new g.ShapeBufferGeometry(M);let T=!1;h&&(T=!0);const S={arrowTexcoordScaleT:{value:r/x*.5},current:{value:0},dynamic:{value:T},full_length:{value:f[f.length-1]},view_distance:{value:n},gradient_distance:{value:i}};s&&(new g.TextureLoader).load(s,t=>{t.wrapS=g.RepeatWrapping,t.wrapT=g.RepeatWrapping,t.generateMipmaps=!0,t.minFilter=g.LinearMipMapLinearFilter,t.magFilter=g.LinearMipMapLinearFilter,t.image&&t.image.width&&t.image.height&&(S.arrowTexcoordScaleT.value=t.image.width/t.image.height/x*.5)});const A=new g.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:S,side:g.DoubleSide,depthTest:!T});let P=Number.MAX_SAFE_INTEGER,C=Number.MAX_SAFE_INTEGER;const{array:L,count:R}=_.attributes.position;for(let t=0,e=0;t<R;t+=1,e+=3){const t=L[e],n=L[e+1];L[e]<P&&(P=t),L[e+1]<C&&(C=n)}if(a&&a.groundPlane)for(let t=0,e=0;t<R;t+=1,e+=3){const t=L[e],n=L[e+1];let i=.5;const r=Wi.intersectWithGroundPlane(new g.Vector3(t,n,i),a);r&&(i=r.z+Xi.PathMeshOffsetZ),L[e+2]=i}else{const t=()=>{if(o&&o.isModelLoaded()){for(let t=0,e=0;t<R;t+=1,e+=3){const t=L[e],n=L[e+1];let i=.5;const r=o.intersectGround(new g.Vector3(t,n,i));r&&(i=r.z+Xi.PathMeshOffsetZ),L[e+2]=i}_.attributes.position.needsUpdate=!0}};o&&o.isModelLoaded()&&t(),w.on(E.ELEMENT_LOADED,e=>{e instanceof Wi&&e===o&&t()})}_.attributes.position.needsUpdate=!0;const I=[];if(s){const t=new g.PlaneBufferGeometry(.5*x/.3,.5*x/.3),e=new g.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.8,blending:g.NormalBlending,side:g.DoubleSide,depthTest:!T}),n=(new g.TextureLoader).load(s);n.needsUpdate=!0,e.needsUpdate=!0,e.map=n;const i=new g.Mesh(t,e);for(let t=0,n=.8,r=d.length;t<r;t+=1)if(f[t]>n){n+=.8;const[s,l]=d[t],{x:h,y:c}=p[t===r-1?t-1:t],u=i.clone();if(u.position.set(s,l,-.5),a){const t=Wi.intersectWithGroundPlane(new g.Vector3(s,l,2),a);t&&(t.z+=Xi.ArrowMeshOffsetZ,u.position.copy(t))}else if(o){const t=o.intersectGround(new g.Vector3(s,l,2));t&&(t.z+=Xi.ArrowMeshOffsetZ,u.position.copy(t))}u.material=e.clone(),u.rotateZ(new g.Vector2(c,-h).angle()-.5*Math.PI),I.push({arrowMesh:u,index:t})}}const D=Math.floor(P),O=Math.floor(C),F=new Map;d.forEach(([t,e],n)=>{const[i,r]=Xi.getPointHash(t,e,D,O,25);F.has(""+i)||F.set(""+i,new Map);const s=F.get(""+i);s.has(""+r)||s.set(""+r,[]),s.get(""+r).push([n,t,e])});const B=new Float32Array(R),N=new Float32Array(3*R);let z=1,U=140/255,k=0,V=240/255,H=68/255,G=55/255;if(l){const t=[];for(let e=2;e<8;e+=2)t.push(parseInt("0x"+l.slice(e,e+2)));z=t[0]/255,U=t[1]/255,k=t[2]/255,V=t[0]/255,H=t[1]/255,G=t[2]/255}const W=V-z,j=H-U,X=G-k;for(let t=0,e=0;t<R;t+=1,e+=3){const n=L[e],i=L[e+1],[r,s]=Xi.getPointHash(n,i,D,O,25);let o=Number.MAX_SAFE_INTEGER;F.has(""+r)&&F.get(""+r).has(""+s)&&F.get(""+r).get(""+s).forEach(([e,r,s])=>{const a=(n-r)**2+(i-s)**2;if(a>o)return;o=a;const l=f[e],h=m[e];B[t]=l,N[3*t]=z+h*W,N[3*t+1]=U+h*j,N[3*t+2]=k+h*X})}_.addAttribute("progress",new g.BufferAttribute(B,1)),_.addAttribute("a_color",new g.BufferAttribute(N,3)),A.transparent=!0;return{mesh:new g.Mesh(_,A),arrowMeshes:I,newPath:d,pointMap:F,pathMinX:D,pathMinY:O,progressBuffer:B,pathDistance:f}}load(t,e){const{groundParams:n,floorModel:i,arrowImageURL:r,color:s,dynamicPathEnabled:o,width:a,viewDistance:l}=e||{},{mesh:h,arrowMeshes:c,pathMinX:u,pathMinY:d,pointMap:p,pathDistance:f}=To.generatePathMesh(t,{groundParams:n,floorModel:i,arrowImageURL:r,color:s,dynamicPathEnabled:o,width:a,viewDistance:l});this.pathMesh=h,this.pathMesh.up.set(0,0,1),this.pathMesh.renderOrder=200,this.add(this.pathMesh),this.arrowMeshes=[],this.pathArrowMeshes=c,c.forEach(({arrowMesh:t})=>{t.renderOrder=201,this.arrowMeshes.push(t),this.add(t)}),this.pathMinX=u,this.pathMinY=d,this.pointMap=p,this.pathDistance=f,this.modelInitialized=!0}update(){const t=new Ht(this);this.modelInitialized&&(this.modelInitialized=!1,t.needUpdate=!0);const{THREE:e}=b.getInstance();if(this.dynamicPathEnabled&&this.pathMesh&&this.bindedCamera){const{position:{x:t,y:n}}=this.bindedCamera,[i,r]=Xi.getPointHash(t,n,this.pathMinX,this.pathMinY,25);let s=Number.MAX_SAFE_INTEGER,o=0;if(this.pointMap.get(""+i)){const a=this.pointMap.get(""+i).get(""+r);if(this.pointMap.get(""+i)&&a){a.forEach(([e,i,r])=>{const a=(t-i)**2+(n-r)**2;a>s||(s=a,o=this.pathDistance[e])});const i=this.pathDistance[this.pathDistance.length-1];o<5&&(o=0),this.pathArrowMeshes.forEach(({arrowMesh:t,index:n})=>{const r=this.pathDistance[n];let s=o;t.isMesh&&t.material instanceof e.Material&&(t.material.opacity=0),r>s&&r<s+this.viewDistance&&(t.isMesh&&t.material instanceof e.Material&&(t.material.opacity=.8),r<s+this.gradientDistance?t.isMesh&&t.material instanceof e.Material&&(t.material.opacity=Math.abs(r-s)/this.gradientDistance*.8):(s>i-this.viewDistance&&(s=i-this.viewDistance),r>s+this.viewDistance-this.gradientDistance&&t.isMesh&&t.material instanceof e.Material&&(t.material.opacity=Math.abs(s+this.viewDistance-r)/this.gradientDistance*.8))),t.isMesh&&t.material instanceof e.Material&&(t.material.needsUpdate=!0)})}this.pathMesh.material instanceof e.ShaderMaterial&&(this.pathMesh.material.uniforms.current.value=o,this.pathMesh.material.needsUpdate=!0)}}return this.modelInitialized&&!this.parent&&(t.shouldPlaceElement=!0),t}dispose(){super.dispose(),Fn.dispose(this,!0)}setPathSettings(t,e,n){this.bindedCamera=t,this.viewDistance=e,this.dynamicPathEnabled=n}}function So(){}Object.assign(So.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 Ao=[];for(let t=0;t<256;t++)Ao[t]=(t<16?"0":"")+t.toString(16);let Po=1234567;const Co={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(Ao[255&t]+Ao[t>>8&255]+Ao[t>>16&255]+Ao[t>>24&255]+"-"+Ao[255&e]+Ao[e>>8&255]+"-"+Ao[e>>16&15|64]+Ao[e>>24&255]+"-"+Ao[63&n|128]+Ao[n>>8&255]+"-"+Ao[n>>16&255]+Ao[n>>24&255]+Ao[255&i]+Ao[i>>8&255]+Ao[i>>16&255]+Ao[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 Co.lerp(t,e,1-Math.exp(-n*i))},pingpong:function(t,e=1){return e-Math.abs(Co.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&&(Po=t%2147483647),Po=16807*Po%2147483647,(Po-1)/2147483646},degToRad:function(t){return t*Co.DEG2RAD},radToDeg:function(t){return t*Co.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 Lo{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}}Lo.prototype.isVector2=!0;class Ro{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 Io;Ro.prototype.isMatrix3=!0;const Do={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===Io&&(Io=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),Io.width=t.width,Io.height=t.height;const n=Io.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Io}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 Oo=0;class Fo extends So{constructor(t=Fo.DEFAULT_IMAGE,e=Fo.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,l=1,h=3e3){super(),Object.defineProperty(this,"id",{value:Oo++}),this.uuid=Co.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 Lo(0,0),this.repeat=new Lo(1,1),this.center=new Lo(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ro,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=Co.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(Bo(i[t].image)):e.push(Bo(i[t]))}else e=Bo(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 Bo(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?Do.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."),{})}Fo.DEFAULT_IMAGE=void 0,Fo.DEFAULT_MAPPING=300,Fo.prototype.isTexture=!0;class No{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}}No.prototype.isVector4=!0;class zo extends So{constructor(t,e,n){super(),this.width=t,this.height=e,this.depth=1,this.scissor=new No(0,0,t,e),this.scissorTest=!1,this.viewport=new No(0,0,t,e),n=n||{},this.texture=new Fo(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"})}}zo.prototype.isWebGLRenderTarget=!0;(class extends zo{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 Uo{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(Co.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(){}}Uo.prototype.isQuaternion=!0;class ko{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(Ho.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ho.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 Vo.copy(this).projectOnVector(t),this.sub(Vo)}reflect(t){return this.sub(Vo.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(Co.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}}ko.prototype.isVector3=!0;const Vo=new ko,Ho=new Uo;class Go{constructor(t=new ko(1/0,1/0,1/0),e=new ko(-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=jo.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 ko),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 ko),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(),Xo.copy(e.boundingBox),Xo.applyMatrix4(t.matrixWorld),this.union(Xo));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 ko),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,jo),jo.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(Ko),ta.subVectors(this.max,Ko),qo.subVectors(t.a,Ko),Yo.subVectors(t.b,Ko),Zo.subVectors(t.c,Ko),Jo.subVectors(Yo,qo),$o.subVectors(Zo,Yo),Qo.subVectors(qo,Zo);let e=[0,-Jo.z,Jo.y,0,-$o.z,$o.y,0,-Qo.z,Qo.y,Jo.z,0,-Jo.x,$o.z,0,-$o.x,Qo.z,0,-Qo.x,-Jo.y,Jo.x,0,-$o.y,$o.x,0,-Qo.y,Qo.x,0];return!!ia(e,qo,Yo,Zo,ta)&&(e=[1,0,0,0,1,0,0,0,1],!!ia(e,qo,Yo,Zo,ta)&&(ea.crossVectors(Jo,$o),e=[ea.x,ea.y,ea.z],ia(e,qo,Yo,Zo,ta)))}clampPoint(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new ko),e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return jo.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(jo).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()||(Wo[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Wo[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Wo[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Wo[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Wo[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Wo[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Wo[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Wo[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Wo)),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)}}Go.prototype.isBox3=!0;const Wo=[new ko,new ko,new ko,new ko,new ko,new ko,new ko,new ko],jo=new ko,Xo=new Go,qo=new ko,Yo=new ko,Zo=new ko,Jo=new ko,$o=new ko,Qo=new ko,Ko=new ko,ta=new ko,ea=new ko,na=new ko;function ia(t,e,n,i,r){for(let s=0,o=t.length-3;s<=o;s+=3){na.fromArray(t,s);const o=r.x*Math.abs(na.x)+r.y*Math.abs(na.y)+r.z*Math.abs(na.z),a=e.dot(na),l=n.dot(na),h=i.dot(na);if(Math.max(-Math.max(a,l,h),Math.min(a,l,h))>o)return!1}return!0}const ra=new Go,sa=new ko,oa=new ko,aa=new ko;class la{constructor(t=new ko,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):ra.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 ko),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 Go),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){aa.subVectors(t,this.center);const e=aa.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.add(aa.multiplyScalar(n/t)),this.radius+=n}return this}union(t){return oa.subVectors(t.center,this.center).normalize().multiplyScalar(t.radius),this.expandByPoint(sa.copy(t.center).add(oa)),this.expandByPoint(sa.copy(t.center).sub(oa)),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const ha=new ko,ca=new ko,ua=new ko,da=new ko,pa=new ko,fa=new ko,ma=new ko;class ga{constructor(t=new ko,e=new ko(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 ko),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,ha)),this}closestPointToPoint(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new ko),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=ha.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(ha.copy(this.direction).multiplyScalar(e).add(this.origin),ha.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){ca.copy(t).add(e).multiplyScalar(.5),ua.copy(e).sub(t).normalize(),da.copy(this.origin).sub(ca);const r=.5*t.distanceTo(e),s=-this.direction.dot(ua),o=da.dot(this.direction),a=-da.dot(ua),l=da.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(ua).multiplyScalar(u).add(ca),d}intersectSphere(t,e){ha.subVectors(t.center,this.origin);const n=ha.dot(this.direction),i=ha.dot(ha)-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,ha)}intersectTriangle(t,e,n,i,r){pa.subVectors(e,t),fa.subVectors(n,t),ma.crossVectors(pa,fa);let s,o=this.direction.dot(ma);if(o>0){if(i)return null;s=1}else{if(!(o<0))return null;s=-1,o=-o}da.subVectors(this.origin,t);const a=s*this.direction.dot(fa.crossVectors(da,fa));if(a<0)return null;const l=s*this.direction.dot(pa.cross(da));if(l<0)return null;if(a+l>o)return null;const h=-s*da.dot(ma);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 va{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 va).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/ya.setFromMatrixColumn(t,0).length(),r=1/ya.setFromMatrixColumn(t,1).length(),s=1/ya.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(ba,t,wa)}lookAt(t,e,n){const i=this.elements;return Ea.subVectors(t,e),0===Ea.lengthSq()&&(Ea.z=1),Ea.normalize(),Ma.crossVectors(n,Ea),0===Ma.lengthSq()&&(1===Math.abs(n.z)?Ea.x+=1e-4:Ea.z+=1e-4,Ea.normalize(),Ma.crossVectors(n,Ea)),Ma.normalize(),_a.crossVectors(Ea,Ma),i[0]=Ma.x,i[4]=_a.x,i[8]=Ea.x,i[1]=Ma.y,i[5]=_a.y,i[9]=Ea.y,i[2]=Ma.z,i[6]=_a.z,i[10]=Ea.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],T=i[1],S=i[5],A=i[9],P=i[13],C=i[2],L=i[6],R=i[10],I=i[14],D=i[3],O=i[7],F=i[11],B=i[15];return r[0]=s*w+o*T+a*C+l*D,r[4]=s*M+o*S+a*L+l*O,r[8]=s*_+o*A+a*R+l*F,r[12]=s*E+o*P+a*I+l*B,r[1]=h*w+c*T+u*C+d*D,r[5]=h*M+c*S+u*L+d*O,r[9]=h*_+c*A+u*R+d*F,r[13]=h*E+c*P+u*I+d*B,r[2]=p*w+f*T+m*C+g*D,r[6]=p*M+f*S+m*L+g*O,r[10]=p*_+f*A+m*R+g*F,r[14]=p*E+f*P+m*I+g*B,r[3]=v*w+y*T+x*C+b*D,r[7]=v*M+y*S+x*L+b*O,r[11]=v*_+y*A+x*R+b*F,r[15]=v*E+y*P+x*I+b*B,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=ya.set(i[0],i[1],i[2]).length();const s=ya.set(i[4],i[5],i[6]).length(),o=ya.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],xa.copy(this);const a=1/r,l=1/s,h=1/o;return xa.elements[0]*=a,xa.elements[1]*=a,xa.elements[2]*=a,xa.elements[4]*=l,xa.elements[5]*=l,xa.elements[6]*=l,xa.elements[8]*=h,xa.elements[9]*=h,xa.elements[10]*=h,e.setFromRotationMatrix(xa),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}}va.prototype.isMatrix4=!0;const ya=new ko,xa=new va,ba=new ko(0,0,0),wa=new ko(1,1,1),Ma=new ko,_a=new ko,Ea=new ko,Ta=new va,Sa=new Uo;class Aa{constructor(t=0,e=0,n=0,i=Aa.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=Co.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 Ta.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ta,e,n)}setFromVector3(t,e){return this.set(t.x,t.y,t.z,e||this._order)}reorder(t){return Sa.setFromEuler(this),this.setFromQuaternion(Sa,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 ko(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}Aa.prototype.isEuler=!0,Aa.DefaultOrder="XYZ",Aa.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class Pa{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 Ca=0;const La=new ko,Ra=new Uo,Ia=new va,Da=new ko,Oa=new ko,Fa=new ko,Ba=new Uo,Na=new ko(1,0,0),za=new ko(0,1,0),Ua=new ko(0,0,1),ka={type:"added"},Va={type:"removed"};function Ha(){Object.defineProperty(this,"id",{value:Ca++}),this.uuid=Co.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ha.DefaultUp.clone();const t=new ko,e=new Aa,n=new Uo,i=new ko(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 va},normalMatrix:{value:new Ro}}),this.matrix=new va,this.matrixWorld=new va,this.matrixAutoUpdate=Ha.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Pa,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}Ha.DefaultUp=new ko(0,1,0),Ha.DefaultMatrixAutoUpdate=!0,Ha.prototype=Object.assign(Object.create(So.prototype),{constructor:Ha,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 Ra.setFromAxisAngle(t,e),this.quaternion.multiply(Ra),this},rotateOnWorldAxis:function(t,e){return Ra.setFromAxisAngle(t,e),this.quaternion.premultiply(Ra),this},rotateX:function(t){return this.rotateOnAxis(Na,t)},rotateY:function(t){return this.rotateOnAxis(za,t)},rotateZ:function(t){return this.rotateOnAxis(Ua,t)},translateOnAxis:function(t,e){return La.copy(t).applyQuaternion(this.quaternion),this.position.add(La.multiplyScalar(e)),this},translateX:function(t){return this.translateOnAxis(Na,t)},translateY:function(t){return this.translateOnAxis(za,t)},translateZ:function(t){return this.translateOnAxis(Ua,t)},localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:function(t){return t.applyMatrix4(Ia.copy(this.matrixWorld).invert())},lookAt:function(t,e,n){t.isVector3?Da.copy(t):Da.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Oa.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ia.lookAt(Oa,Da,this.up):Ia.lookAt(Da,Oa,this.up),this.quaternion.setFromRotationMatrix(Ia),i&&(Ia.extractRotation(i.matrixWorld),Ra.setFromRotationMatrix(Ia),this.quaternion.premultiply(Ra.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(ka)):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(Va)),this},clear:function(){for(let t=0;t<this.children.length;t++){const e=this.children[t];e.parent=null,e.dispatchEvent(Va)}return this.children.length=0,this},attach:function(t){return this.updateWorldMatrix(!0,!1),Ia.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),Ia.multiply(t.parent.matrixWorld)),t.applyMatrix4(Ia),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 ko),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 Uo),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oa,t,Fa),t},getWorldScale:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),t=new ko),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oa,Ba,t),t},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),t=new ko),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 Ga=new ko,Wa=new ko,ja=new Ro;class Xa{constructor(t=new ko(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=Ga.subVectors(n,e).cross(Wa.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 ko),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 ko);const n=t.delta(Ga),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 ko),t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||ja.getNormalMatrix(t),i=this.coplanarPoint(Ga).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)}}Xa.prototype.isPlane=!0;const qa=new ko,Ya=new ko,Za=new ko,Ja=new ko,$a=new ko,Qa=new ko,Ka=new ko,tl=new ko,el=new ko,nl=new ko;class il{constructor(t=new ko,e=new ko,n=new ko){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 ko),i.subVectors(n,e),qa.subVectors(t,e),i.cross(qa);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){qa.subVectors(i,e),Ya.subVectors(n,e),Za.subVectors(t,e);const s=qa.dot(qa),o=qa.dot(Ya),a=qa.dot(Za),l=Ya.dot(Ya),h=Ya.dot(Za),c=s*l-o*o;if(void 0===r&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),r=new ko),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,Ja),Ja.x>=0&&Ja.y>=0&&Ja.x+Ja.y<=1}static getUV(t,e,n,i,r,s,o,a){return this.getBarycoord(t,e,n,i,Ja),a.set(0,0),a.addScaledVector(r,Ja.x),a.addScaledVector(s,Ja.y),a.addScaledVector(o,Ja.z),a}static isFrontFacing(t,e,n,i){return qa.subVectors(n,e),Ya.subVectors(t,e),qa.cross(Ya).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 qa.subVectors(this.c,this.b),Ya.subVectors(this.a,this.b),.5*qa.cross(Ya).length()}getMidpoint(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new ko),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return il.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 Xa),t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return il.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,n,i,r){return il.getUV(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return il.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return il.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 ko);const n=this.a,i=this.b,r=this.c;let s,o;$a.subVectors(i,n),Qa.subVectors(r,n),tl.subVectors(t,n);const a=$a.dot(tl),l=Qa.dot(tl);if(a<=0&&l<=0)return e.copy(n);el.subVectors(t,i);const h=$a.dot(el),c=Qa.dot(el);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($a,s);nl.subVectors(t,r);const d=$a.dot(nl),p=Qa.dot(nl);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(Qa,o);const m=h*p-d*c;if(m<=0&&c-h>=0&&d-p>=0)return Ka.subVectors(r,i),o=(c-h)/(c-h+(d-p)),e.copy(i).addScaledVector(Ka,o);const g=1/(m+f+u);return s=f*g,o=u*g,e.copy(n).addScaledVector($a,s).addScaledVector(Qa,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let rl=0;function sl(){Object.defineProperty(this,"id",{value:rl++}),this.uuid=Co.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}sl.prototype=Object.assign(Object.create(So.prototype),{constructor:sl,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(sl.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}});const ol={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},al={h:0,s:0,l:0},ll={h:0,s:0,l:0};function hl(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 cl(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function ul(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class dl{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=Co.euclideanModulo(t,1),e=Co.clamp(e,0,1),n=Co.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=hl(r,i,t+1/3),this.g=hl(r,i,t),this.b=hl(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=ol[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=cl(t.r),this.g=cl(t.g),this.b=cl(t.b),this}copyLinearToSRGB(t){return this.r=ul(t.r),this.g=ul(t.g),this.b=ul(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(al),al.h+=t,al.s+=e,al.l+=n,this.setHSL(al.h,al.s,al.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(al),t.getHSL(ll);const n=Co.lerp(al.h,ll.h,e),i=Co.lerp(al.s,ll.s,e),r=Co.lerp(al.l,ll.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()}}dl.NAMES=ol,dl.prototype.isColor=!0,dl.prototype.r=1,dl.prototype.g=1,dl.prototype.b=1;class pl extends sl{constructor(t){super(),this.type="MeshBasicMaterial",this.color=new dl(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}}pl.prototype.isMeshBasicMaterial=!0;const fl=new ko,ml=new Lo;function gl(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 vl(t,e,n){gl.call(this,new Int8Array(t),e,n)}function yl(t,e,n){gl.call(this,new Uint8Array(t),e,n)}function xl(t,e,n){gl.call(this,new Uint8ClampedArray(t),e,n)}function bl(t,e,n){gl.call(this,new Int16Array(t),e,n)}function wl(t,e,n){gl.call(this,new Uint16Array(t),e,n)}function Ml(t,e,n){gl.call(this,new Int32Array(t),e,n)}function _l(t,e,n){gl.call(this,new Uint32Array(t),e,n)}function El(t,e,n){gl.call(this,new Uint16Array(t),e,n)}function Tl(t,e,n){gl.call(this,new Float32Array(t),e,n)}function Sl(t,e,n){gl.call(this,new Float64Array(t),e,n)}function Al(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(gl.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(gl.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 dl),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 Lo),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 ko),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 No),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++)ml.fromBufferAttribute(this,e),ml.applyMatrix3(t),this.setXY(e,ml.x,ml.y);else if(3===this.itemSize)for(let e=0,n=this.count;e<n;e++)fl.fromBufferAttribute(this,e),fl.applyMatrix3(t),this.setXYZ(e,fl.x,fl.y,fl.z);return this},applyMatrix4:function(t){for(let e=0,n=this.count;e<n;e++)fl.x=this.getX(e),fl.y=this.getY(e),fl.z=this.getZ(e),fl.applyMatrix4(t),this.setXYZ(e,fl.x,fl.y,fl.z);return this},applyNormalMatrix:function(t){for(let e=0,n=this.count;e<n;e++)fl.x=this.getX(e),fl.y=this.getY(e),fl.z=this.getZ(e),fl.applyNormalMatrix(t),this.setXYZ(e,fl.x,fl.y,fl.z);return this},transformDirection:function(t){for(let e=0,n=this.count;e<n;e++)fl.x=this.getX(e),fl.y=this.getY(e),fl.z=this.getZ(e),fl.transformDirection(t),this.setXYZ(e,fl.x,fl.y,fl.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}}),vl.prototype=Object.create(gl.prototype),vl.prototype.constructor=vl,yl.prototype=Object.create(gl.prototype),yl.prototype.constructor=yl,xl.prototype=Object.create(gl.prototype),xl.prototype.constructor=xl,bl.prototype=Object.create(gl.prototype),bl.prototype.constructor=bl,wl.prototype=Object.create(gl.prototype),wl.prototype.constructor=wl,Ml.prototype=Object.create(gl.prototype),Ml.prototype.constructor=Ml,_l.prototype=Object.create(gl.prototype),_l.prototype.constructor=_l,El.prototype=Object.create(gl.prototype),El.prototype.constructor=El,El.prototype.isFloat16BufferAttribute=!0,Tl.prototype=Object.create(gl.prototype),Tl.prototype.constructor=Tl,Sl.prototype=Object.create(gl.prototype),Sl.prototype.constructor=Sl;let Pl=0;const Cl=new va,Ll=new Ha,Rl=new ko,Il=new Go,Dl=new Go,Ol=new ko;function Fl(){Object.defineProperty(this,"id",{value:Pl++}),this.uuid=Co.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={}}Fl.prototype=Object.assign(Object.create(So.prototype),{constructor:Fl,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(t){return Array.isArray(t)?this.index=new(Al(t)>65535?_l:wl)(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 Ro).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 Cl.makeRotationX(t),this.applyMatrix4(Cl),this},rotateY:function(t){return Cl.makeRotationY(t),this.applyMatrix4(Cl),this},rotateZ:function(t){return Cl.makeRotationZ(t),this.applyMatrix4(Cl),this},translate:function(t,e,n){return Cl.makeTranslation(t,e,n),this.applyMatrix4(Cl),this},scale:function(t,e,n){return Cl.makeScale(t,e,n),this.applyMatrix4(Cl),this},lookAt:function(t){return Ll.lookAt(t),Ll.updateMatrix(),this.applyMatrix4(Ll.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(Rl).negate(),this.translate(Rl.x,Rl.y,Rl.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 Tl(e,3)),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Go);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 ko(-1/0,-1/0,-1/0),new ko(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];Il.setFromBufferAttribute(n),this.morphTargetsRelative?(Ol.addVectors(this.boundingBox.min,Il.min),this.boundingBox.expandByPoint(Ol),Ol.addVectors(this.boundingBox.max,Il.max),this.boundingBox.expandByPoint(Ol)):(this.boundingBox.expandByPoint(Il.min),this.boundingBox.expandByPoint(Il.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 la);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 ko,1/0);if(t){const n=this.boundingSphere.center;if(Il.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];Dl.setFromBufferAttribute(n),this.morphTargetsRelative?(Ol.addVectors(Il.min,Dl.min),Il.expandByPoint(Ol),Ol.addVectors(Il.max,Dl.max),Il.expandByPoint(Ol)):(Il.expandByPoint(Dl.min),Il.expandByPoint(Dl.max))}Il.getCenter(n);let i=0;for(let e=0,r=t.count;e<r;e++)Ol.fromBufferAttribute(t,e),i=Math.max(i,n.distanceToSquared(Ol));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++)Ol.fromBufferAttribute(s,e),o&&(Rl.fromBufferAttribute(t,e),Ol.add(Rl)),i=Math.max(i,n.distanceToSquared(Ol))}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 gl(new Float32Array(4*o),4));const a=e.tangent.array,l=[],h=[];for(let t=0;t<o;t++)l[t]=new ko,h[t]=new ko;const c=new ko,u=new ko,d=new ko,p=new Lo,f=new Lo,m=new Lo,g=new ko,v=new ko;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 ko,w=new ko,M=new ko,_=new ko;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 gl(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 ko,r=new ko,s=new ko,o=new ko,a=new ko,l=new ko,h=new ko,c=new ko;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++)Ol.fromBufferAttribute(t,e),Ol.normalize(),t.setXYZ(e,Ol.x,Ol.y,Ol.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 gl(s,i,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Fl,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 Fl).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 Bl=new va,Nl=new ga,zl=new la,Ul=new ko,kl=new ko,Vl=new ko,Hl=new ko,Gl=new ko,Wl=new ko,jl=new ko,Xl=new ko,ql=new ko,Yl=new Lo,Zl=new Lo,Jl=new Lo,$l=new ko,Ql=new ko;function Kl(t=new Fl,e=new pl){Ha.call(this),this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}function th(t,e,n,i,r,s,o,a,l,h,c,u){Ul.fromBufferAttribute(r,h),kl.fromBufferAttribute(r,c),Vl.fromBufferAttribute(r,u);const d=t.morphTargetInfluences;if(e.morphTargets&&s&&d){jl.set(0,0,0),Xl.set(0,0,0),ql.set(0,0,0);for(let t=0,e=s.length;t<e;t++){const e=d[t],n=s[t];0!==e&&(Hl.fromBufferAttribute(n,h),Gl.fromBufferAttribute(n,c),Wl.fromBufferAttribute(n,u),o?(jl.addScaledVector(Hl,e),Xl.addScaledVector(Gl,e),ql.addScaledVector(Wl,e)):(jl.addScaledVector(Hl.sub(Ul),e),Xl.addScaledVector(Gl.sub(kl),e),ql.addScaledVector(Wl.sub(Vl),e)))}Ul.add(jl),kl.add(Xl),Vl.add(ql)}t.isSkinnedMesh&&e.skinning&&(t.boneTransform(h,Ul),t.boneTransform(c,kl),t.boneTransform(u,Vl));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;Ql.copy(a),Ql.applyMatrix4(t.matrixWorld);const h=n.ray.origin.distanceTo(Ql);return h<n.near||h>n.far?null:{distance:h,point:Ql.clone(),object:t}}(t,e,n,i,Ul,kl,Vl,$l);if(p){a&&(Yl.fromBufferAttribute(a,h),Zl.fromBufferAttribute(a,c),Jl.fromBufferAttribute(a,u),p.uv=il.getUV($l,Ul,kl,Vl,Yl,Zl,Jl,new Lo)),l&&(Yl.fromBufferAttribute(l,h),Zl.fromBufferAttribute(l,c),Jl.fromBufferAttribute(l,u),p.uv2=il.getUV($l,Ul,kl,Vl,Yl,Zl,Jl,new Lo));const t={a:h,b:c,c:u,normal:new ko,materialIndex:0};il.getNormal(Ul,kl,Vl,t.normal),p.face=t}return p}Kl.prototype=Object.assign(Object.create(Ha.prototype),{constructor:Kl,isMesh:!0,copy:function(t){return Ha.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(),zl.copy(n.boundingSphere),zl.applyMatrix4(r),!1===t.ray.intersectsSphere(zl))return;if(Bl.copy(r).invert(),Nl.copy(t.ray).applyMatrix4(Bl),null!==n.boundingBox&&!1===Nl.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=th(this,f,t,Nl,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=th(this,i,t,Nl,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=th(this,p,t,Nl,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=th(this,i,t,Nl,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 eh extends Fl{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 T=0,S=0;const A=new ko;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),T+=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),S+=6}o.addGroup(d,S,v),d+=S,u+=T}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 Tl(l,3)),this.setAttribute("normal",new Tl(h,3)),this.setAttribute("uv",new Tl(c,2))}}function nh(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 ih(t){const e={};for(let n=0;n<t.length;n++){const i=nh(t[n]);for(const t in i)e[t]=i[t]}return e}const rh={clone:nh,merge:ih};function sh(t){sl.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 oh(){Ha.call(this),this.type="Camera",this.matrixWorldInverse=new va,this.projectionMatrix=new va,this.projectionMatrixInverse=new va}function ah(t=50,e=1,n=.1,i=2e3){oh.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()}sh.prototype=Object.create(sl.prototype),sh.prototype.constructor=sh,sh.prototype.isShaderMaterial=!0,sh.prototype.copy=function(t){return sl.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=nh(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},sh.prototype.toJSON=function(t){const e=sl.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},oh.prototype=Object.assign(Object.create(Ha.prototype),{constructor:oh,isCamera:!0,copy:function(t,e){return Ha.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 ko),this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()},updateMatrixWorld:function(t){Ha.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()},updateWorldMatrix:function(t,e){Ha.prototype.updateWorldMatrix.call(this,t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()},clone:function(){return(new this.constructor).copy(this)}}),ah.prototype=Object.assign(Object.create(oh.prototype),{constructor:ah,isPerspectiveCamera:!0,copy:function(t,e){return oh.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*Co.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){const t=Math.tan(.5*Co.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*Co.RAD2DEG*Math.atan(Math.tan(.5*Co.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*Co.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=Ha.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 lh extends Ha{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 ah(90,1,t,e);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new ko(1,0,0)),this.add(i);const r=new ah(90,1,t,e);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new ko(-1,0,0)),this.add(r);const s=new ah(90,1,t,e);s.layers=this.layers,s.up.set(0,0,1),s.lookAt(new ko(0,1,0)),this.add(s);const o=new ah(90,1,t,e);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new ko(0,-1,0)),this.add(o);const a=new ah(90,1,t,e);a.layers=this.layers,a.up.set(0,-1,0),a.lookAt(new ko(0,0,1)),this.add(a);const l=new ah(90,1,t,e);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new ko(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 hh extends Fo{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}}hh.prototype.isCubeTexture=!0;class ch extends zo{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 hh(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 eh(5,5,5),r=new sh({name:"CubemapFromEquirect",uniforms:nh(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;const s=new Kl(i,r),o=e.minFilter;1008===e.minFilter&&(e.minFilter=1006);return new lh(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)}}ch.prototype.isWebGLCubeRenderTarget=!0;class uh extends Fo{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}}uh.prototype.isDataTexture=!0;const dh=new la,ph=new ko;class fh{constructor(t=new Xa,e=new Xa,n=new Xa,i=new Xa,r=new Xa,s=new Xa){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(),dh.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(dh)}intersectsSprite(t){return dh.center.set(0,0,0),dh.radius=.7071067811865476,dh.applyMatrix4(t.matrixWorld),this.intersectsSphere(dh)}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(ph.x=i.normal.x>0?t.max.x:t.min.x,ph.y=i.normal.y>0?t.max.y:t.min.y,ph.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(ph)<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 mh(){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 gh(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 vh extends Fl{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 Tl(p,3)),this.setAttribute("normal",new Tl(f,3)),this.setAttribute("uv",new Tl(m,2))}}const yh={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}"},xh={common:{diffuse:{value:new dl(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Ro},uv2Transform:{value:new Ro},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 Lo(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 dl(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 dl(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Ro}},sprite:{diffuse:{value:new dl(15658734)},opacity:{value:1},center:{value:new Lo(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Ro}}},bh={basic:{uniforms:ih([xh.common,xh.specularmap,xh.envmap,xh.aomap,xh.lightmap,xh.fog]),vertexShader:yh.meshbasic_vert,fragmentShader:yh.meshbasic_frag},lambert:{uniforms:ih([xh.common,xh.specularmap,xh.envmap,xh.aomap,xh.lightmap,xh.emissivemap,xh.fog,xh.lights,{emissive:{value:new dl(0)}}]),vertexShader:yh.meshlambert_vert,fragmentShader:yh.meshlambert_frag},phong:{uniforms:ih([xh.common,xh.specularmap,xh.envmap,xh.aomap,xh.lightmap,xh.emissivemap,xh.bumpmap,xh.normalmap,xh.displacementmap,xh.fog,xh.lights,{emissive:{value:new dl(0)},specular:{value:new dl(1118481)},shininess:{value:30}}]),vertexShader:yh.meshphong_vert,fragmentShader:yh.meshphong_frag},standard:{uniforms:ih([xh.common,xh.envmap,xh.aomap,xh.lightmap,xh.emissivemap,xh.bumpmap,xh.normalmap,xh.displacementmap,xh.roughnessmap,xh.metalnessmap,xh.fog,xh.lights,{emissive:{value:new dl(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:yh.meshphysical_vert,fragmentShader:yh.meshphysical_frag},toon:{uniforms:ih([xh.common,xh.aomap,xh.lightmap,xh.emissivemap,xh.bumpmap,xh.normalmap,xh.displacementmap,xh.gradientmap,xh.fog,xh.lights,{emissive:{value:new dl(0)}}]),vertexShader:yh.meshtoon_vert,fragmentShader:yh.meshtoon_frag},matcap:{uniforms:ih([xh.common,xh.bumpmap,xh.normalmap,xh.displacementmap,xh.fog,{matcap:{value:null}}]),vertexShader:yh.meshmatcap_vert,fragmentShader:yh.meshmatcap_frag},points:{uniforms:ih([xh.points,xh.fog]),vertexShader:yh.points_vert,fragmentShader:yh.points_frag},dashed:{uniforms:ih([xh.common,xh.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:yh.linedashed_vert,fragmentShader:yh.linedashed_frag},depth:{uniforms:ih([xh.common,xh.displacementmap]),vertexShader:yh.depth_vert,fragmentShader:yh.depth_frag},normal:{uniforms:ih([xh.common,xh.bumpmap,xh.normalmap,xh.displacementmap,{opacity:{value:1}}]),vertexShader:yh.normal_vert,fragmentShader:yh.normal_frag},sprite:{uniforms:ih([xh.sprite,xh.fog]),vertexShader:yh.sprite_vert,fragmentShader:yh.sprite_frag},background:{uniforms:{uvTransform:{value:new Ro},t2D:{value:null}},vertexShader:yh.background_vert,fragmentShader:yh.background_frag},cube:{uniforms:ih([xh.envmap,{opacity:{value:1}}]),vertexShader:yh.cube_vert,fragmentShader:yh.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:yh.equirect_vert,fragmentShader:yh.equirect_frag},distanceRGBA:{uniforms:ih([xh.common,xh.displacementmap,{referencePosition:{value:new ko},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:yh.distanceRGBA_vert,fragmentShader:yh.distanceRGBA_frag},shadow:{uniforms:ih([xh.lights,xh.fog,{color:{value:new dl(0)},opacity:{value:1}}]),vertexShader:yh.shadow_vert,fragmentShader:yh.shadow_frag}};function wh(t,e,n,i,r){const s=new dl(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 Kl(new eh(1,1,1),new sh({name:"BackgroundCubeMaterial",uniforms:nh(bh.cube.uniforms),vertexShader:bh.cube.vertexShader,fragmentShader:bh.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 Kl(new vh(2,2),new sh({name:"BackgroundMaterial",uniforms:nh(bh.background.uniforms),vertexShader:bh.background.vertexShader,fragmentShader:bh.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 Mh(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 _h(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 Eh(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 Th(t){const e=this;let n=null,i=0,r=!1,s=!1;const o=new Xa,a=new Ro,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 Sh(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 ch(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 Ah(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 Ph(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(Al(n)>65535?_l:wl)(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 Ch(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 Lh(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 Rh(t,e){return t[0]-e[0]}function Ih(t,e){return Math.abs(e[1])-Math.abs(t[1])}function Dh(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(Ih);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(Rh);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 Oh(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}}}bh.physical={uniforms:ih([bh.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new Lo(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new dl(0)},transmission:{value:0},transmissionMap:{value:null}}]),vertexShader:yh.meshphysical_vert,fragmentShader:yh.meshphysical_frag};class Fh extends Fo{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}}Fh.prototype.isDataTexture2DArray=!0;class Bh extends Fo{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}}Bh.prototype.isDataTexture3D=!0;const Nh=new Fo,zh=new Fh,Uh=new Bh,kh=new hh,Vh=[],Hh=[],Gh=new Float32Array(16),Wh=new Float32Array(9),jh=new Float32Array(4);function Xh(t,e,n){const i=t[0];if(i<=0||i>0)return t;const r=e*n;let s=Vh[r];if(void 0===s&&(s=new Float32Array(r),Vh[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 qh(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 Yh(t,e){for(let n=0,i=e.length;n<i;n++)t[n]=e[n]}function Zh(t,e){let n=Hh[e];void 0===n&&(n=new Int32Array(e),Hh[e]=n);for(let i=0;i!==e;++i)n[i]=t.allocateTextureUnit();return n}function Jh(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function $h(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(qh(n,e))return;t.uniform2fv(this.addr,e),Yh(n,e)}}function Qh(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(qh(n,e))return;t.uniform3fv(this.addr,e),Yh(n,e)}}function Kh(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(qh(n,e))return;t.uniform4fv(this.addr,e),Yh(n,e)}}function tc(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(qh(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Yh(n,e)}else{if(qh(n,i))return;jh.set(i),t.uniformMatrix2fv(this.addr,!1,jh),Yh(n,i)}}function ec(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(qh(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Yh(n,e)}else{if(qh(n,i))return;Wh.set(i),t.uniformMatrix3fv(this.addr,!1,Wh),Yh(n,i)}}function nc(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(qh(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Yh(n,e)}else{if(qh(n,i))return;Gh.set(i),t.uniformMatrix4fv(this.addr,!1,Gh),Yh(n,i)}}function ic(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function rc(t,e){const n=this.cache;qh(n,e)||(t.uniform2iv(this.addr,e),Yh(n,e))}function sc(t,e){const n=this.cache;qh(n,e)||(t.uniform3iv(this.addr,e),Yh(n,e))}function oc(t,e){const n=this.cache;qh(n,e)||(t.uniform4iv(this.addr,e),Yh(n,e))}function ac(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function lc(t,e){const n=this.cache;qh(n,e)||(t.uniform2uiv(this.addr,e),Yh(n,e))}function hc(t,e){const n=this.cache;qh(n,e)||(t.uniform3uiv(this.addr,e),Yh(n,e))}function cc(t,e){const n=this.cache;qh(n,e)||(t.uniform4uiv(this.addr,e),Yh(n,e))}function uc(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.safeSetTexture2D(e||Nh,r)}function dc(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(e||Uh,r)}function pc(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.safeSetTextureCube(e||kh,r)}function fc(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(e||zh,r)}function mc(t,e){t.uniform1fv(this.addr,e)}function gc(t,e){const n=Xh(e,this.size,2);t.uniform2fv(this.addr,n)}function vc(t,e){const n=Xh(e,this.size,3);t.uniform3fv(this.addr,n)}function yc(t,e){const n=Xh(e,this.size,4);t.uniform4fv(this.addr,n)}function xc(t,e){const n=Xh(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function bc(t,e){const n=Xh(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function wc(t,e){const n=Xh(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Mc(t,e){t.uniform1iv(this.addr,e)}function _c(t,e){t.uniform2iv(this.addr,e)}function Ec(t,e){t.uniform3iv(this.addr,e)}function Tc(t,e){t.uniform4iv(this.addr,e)}function Sc(t,e){t.uniform1uiv(this.addr,e)}function Ac(t,e){t.uniform2uiv(this.addr,e)}function Pc(t,e){t.uniform3uiv(this.addr,e)}function Cc(t,e){t.uniform4uiv(this.addr,e)}function Lc(t,e,n){const i=e.length,r=Zh(n,i);t.uniform1iv(this.addr,r);for(let t=0;t!==i;++t)n.safeSetTexture2D(e[t]||Nh,r[t])}function Rc(t,e,n){const i=e.length,r=Zh(n,i);t.uniform1iv(this.addr,r);for(let t=0;t!==i;++t)n.safeSetTextureCube(e[t]||kh,r[t])}function Ic(t,e,n){this.id=t,this.addr=n,this.cache=[],this.setValue=function(t){switch(t){case 5126:return Jh;case 35664:return $h;case 35665:return Qh;case 35666:return Kh;case 35674:return tc;case 35675:return ec;case 35676:return nc;case 5124:case 35670:return ic;case 35667:case 35671:return rc;case 35668:case 35672:return sc;case 35669:case 35673:return oc;case 5125:return ac;case 36294:return lc;case 36295:return hc;case 36296:return cc;case 35678:case 36198:case 36298:case 36306:case 35682:return uc;case 35679:case 36299:case 36307:return dc;case 35680:case 36300:case 36308:case 36293:return pc;case 36289:case 36303:case 36311:case 36292:return fc}}(e.type)}function Dc(t,e,n){this.id=t,this.addr=n,this.cache=[],this.size=e.size,this.setValue=function(t){switch(t){case 5126:return mc;case 35664:return gc;case 35665:return vc;case 35666:return yc;case 35674:return xc;case 35675:return bc;case 35676:return wc;case 5124:case 35670:return Mc;case 35667:case 35671:return _c;case 35668:case 35672:return Ec;case 35669:case 35673:return Tc;case 5125:return Sc;case 36294:return Ac;case 36295:return Pc;case 36296:return Cc;case 35678:case 36198:case 36298:case 36306:case 35682:return Lc;case 35680:case 36300:case 36308:case 36293:return Rc}}(e.type)}function Oc(t){this.id=t,this.seq=[],this.map={}}Dc.prototype.updateCache=function(t){const e=this.cache;t instanceof Float32Array&&e.length!==t.length&&(this.cache=new Float32Array(t.length)),Yh(e,t)},Oc.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 Fc=/(\w+)(\])?(\[|\.)?/g;function Bc(t,e){t.seq.push(e),t.map[e.id]=e}function Nc(t,e,n){const i=t.name,r=i.length;for(Fc.lastIndex=0;;){const s=Fc.exec(i),o=Fc.lastIndex;let a=s[1];const l="]"===s[2],h=s[3];if(l&&(a|=0),void 0===h||"["===h&&o+2===r){Bc(n,void 0===h?new Ic(a,t,e):new Dc(a,t,e));break}{let t=n.map[a];void 0===t&&(t=new Oc(a),Bc(n,t)),n=t}}}function zc(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);Nc(n,t.getUniformLocation(e,n.name),this)}}function Uc(t,e,n){const i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),i}zc.prototype.setValue=function(t,e,n,i){const r=this.map[e];void 0!==r&&r.setValue(t,n,i)},zc.prototype.setOptional=function(t,e,n){const i=e[n];void 0!==i&&this.setValue(t,n,i)},zc.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)}},zc.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 kc=0;function Vc(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 Hc(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 Gc(t,e){const n=Vc(e);return"vec4 "+t+"( vec4 value ) { return "+n[0]+"ToLinear"+n[1]+"; }"}function Wc(t,e){const n=Vc(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function jc(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 Xc(t){return""!==t}function qc(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 Yc(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Zc=/^[ \t]*#include +<([\w\d./]+)>/gm;function Jc(t){return t.replace(Zc,$c)}function $c(t,e){const n=yh[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return Jc(n)}const Qc=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,Kc=/#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 tu(t){return t.replace(Kc,nu).replace(Qc,eu)}function eu(t,e,n,i){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),nu(t,e,n,i)}function nu(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 iu(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 ru(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(Xc).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(Xc).join("\n"),g.length>0&&(g+="\n"),v=[p,f].filter(Xc).join("\n"),v.length>0&&(v+="\n")):(g=[iu(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(Xc).join("\n"),v=[p,iu(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?yh.tonemapping_pars_fragment:"",0!==n.toneMapping?jc("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",yh.encodings_pars_fragment,n.map?Gc("mapTexelToLinear",n.mapEncoding):"",n.matcap?Gc("matcapTexelToLinear",n.matcapEncoding):"",n.envMap?Gc("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMap?Gc("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.lightMap?Gc("lightMapTexelToLinear",n.lightMapEncoding):"",Wc("linearToOutputTexel",n.outputEncoding),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Xc).join("\n")),o=Jc(o),o=qc(o,n),o=Yc(o,n),a=Jc(a),a=qc(a,n),a=Yc(a,n),o=tu(o),a=tu(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=Uc(r,35633,y+g+o),w=Uc(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=Hc(r,b,"vertex"),n=Hc(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 zc(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=kc++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=b,this.fragmentShader=w,this}function su(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=bh[w];_=t.vertexShader,E=t.fragmentShader}else _=r.vertexShader,E=r.fragmentShader;const T=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!==T?m(T.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=bh[e];n=rh.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 ru(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 ou(){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 au(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 lu(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 hu(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||au),r.length>1&&r.sort(e||lu)}}}function cu(t){let e=new WeakMap;return{get:function(n,i){let r;return!1===e.has(n)?(r=new hu(t),e.set(n,[r])):i>=e.get(n).length?(r=new hu(t),e.get(n).push(r)):r=e.get(n)[i],r},dispose:function(){e=new WeakMap}}}function uu(){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 ko,color:new dl};break;case"SpotLight":n={position:new ko,direction:new ko,color:new dl,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new ko,color:new dl,distance:0,decay:0};break;case"HemisphereLight":n={direction:new ko,skyColor:new dl,groundColor:new dl};break;case"RectAreaLight":n={color:new dl,position:new ko,halfWidth:new ko,halfHeight:new ko}}return t[e.id]=n,n}}}let du=0;function pu(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function fu(t,e){const n=new uu,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 Lo};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Lo,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 ko);const s=new ko,o=new va,a=new va;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(pu);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=xh.LTC_FLOAT_1,r.rectAreaLTC2=xh.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=xh.LTC_HALF_1,r.rectAreaLTC2=xh.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=du++)},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 mu(t,e){const n=new fu(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 gu(t,e){let n=new WeakMap;return{get:function(i,r=0){let s;return!1===n.has(i)?(s=new mu(t,e),n.set(i,[s])):r>=n.get(i).length?(s=new mu(t,e),n.get(i).push(s)):s=n.get(i)[r],s},dispose:function(){n=new WeakMap}}}class vu extends sl{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}}vu.prototype.isMeshDepthMaterial=!0;class yu extends sl{constructor(t){super(),this.type="MeshDistanceMaterial",this.referencePosition=new ko,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}}yu.prototype.isMeshDistanceMaterial=!0;function xu(t,e,n){let i=new fh;const r=new Lo,s=new Lo,o=new No,a=[],l=[],h={},c=n.maxTextureSize,u={0:1,1:0,2:2},d=new sh({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new Lo},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 Fl;f.setAttribute("position",new gl(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Kl(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 vu({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 yu({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 zo(r.x,r.y,t),u.map.texture.name=h.name+".shadowMap",u.mapPass=new zo(r.x,r.y,t),u.camera.updateProjectionMatrix()}if(null===u.map){const t={minFilter:1003,magFilter:1003,format:1023};u.map=new zo(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 bu(t,e,n){const i=n.isWebGL2;const r=new function(){let e=!1;const n=new No;let i=null;const r=new No(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?F(2929):B(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?F(2960):B(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 T=t.getParameter(35661);let S=!1,A=0;const P=t.getParameter(7938);-1!==P.indexOf("WebGL")?(A=parseFloat(/^WebGL (\d)/.exec(P)[1]),S=A>=1):-1!==P.indexOf("OpenGL ES")&&(A=parseFloat(/^OpenGL ES (\d)/.exec(P)[1]),S=A>=2);let C=null,L={};const R=new No(0,0,t.canvas.width,t.canvas.height),I=new No(0,0,t.canvas.width,t.canvas.height);function D(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 O={};function F(e){!0!==a[e]&&(t.enable(e),a[e]=!0)}function B(e){!1!==a[e]&&(t.disable(e),a[e]=!1)}O[3553]=D(3553,3553,1),O[34067]=D(34067,34069,6),r.setClear(0,0,0,1),s.setClear(1),o.setClear(0),F(2929),s.setFunc(3),k(!1),V(1),F(2884),U(0);const N={100:32774,101:32778,102:32779};if(i)N[103]=32775,N[104]=32776;else{const t=e.get("EXT_blend_minmax");null!==t&&(N[103]=t.MIN_EXT,N[104]=t.MAX_EXT)}const z={200:0,201:1,202:768,204:770,210:776,208:774,206:772,203:769,205:771,209:775,207:773};function U(e,n,i,r,s,o,a,l){if(0!==e){if(!1===u&&(F(3042),u=!0),5===e)s=s||n,o=o||i,a=a||r,n===p&&s===g||(t.blendEquationSeparate(N[n],N[s]),p=n,g=s),i===f&&r===m&&o===v&&a===y||(t.blendFuncSeparate(z[i],z[r],z[o],z[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&&(B(3042),u=!1)}function k(e){b!==e&&(e?t.frontFace(2304):t.frontFace(2305),b=e)}function V(e){0!==e?(F(2884),e!==w&&(1===e?t.cullFace(1029):2===e?t.cullFace(1028):t.cullFace(1032))):B(2884),w=e}function H(e,n,i){e?(F(32823),_===n&&E===i||(t.polygonOffset(n,i),_=n,E=i)):B(32823)}function G(e){void 0===e&&(e=33984+T-1),C!==e&&(t.activeTexture(e),C=e)}return{buffers:{color:r,depth:s,stencil:o},enable:F,disable:B,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:U,setMaterial:function(t,e){2===t.side?B(2884):F(2884);let n=1===t.side;e&&(n=!n),k(n),1===t.blending&&!1===t.transparent?U(0):U(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?F(32926):B(32926)},setFlipSided:k,setCullFace:V,setLineWidth:function(e){e!==M&&(S&&t.lineWidth(e),M=e)},setPolygonOffset:H,setScissorTest:function(t){t?F(3089):B(3089)},activeTexture:G,bindTexture:function(e,n){null===C&&G();let i=L[C];void 0===i&&(i={type:void 0,texture:void 0},L[C]=i),i.type===e&&i.texture===n||(t.bindTexture(e,n||O[e]),i.type=e,i.texture=n)},unbindTexture:function(){const e=L[C];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===R.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),R.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={},C=null,L={},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,R.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 wu(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?Co.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 Co.isPowerOfTwo(t.width)&&Co.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 T(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 R(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 S(e,r){const o=i.get(e);e.version>0&&o.__version!==e.version?function(e,i,r){if(6!==i.image.length)return;L(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(C(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 C(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 L(e,n){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",M),e.__webglTexture=t.createTexture(),o.memory.textures++)}function R(e,i,r){let o=3553;i.isDataTexture2DArray&&(o=35866),i.isDataTexture3D&&(o=32879),L(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);C(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 D(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=F(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=F(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=F(n);t.renderbufferStorageMultisample(36161,e,a,n.width,n.height)}else t.renderbufferStorage(36161,a,n.width,n.height)}t.bindRenderbuffer(36161,null)}function O(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),T(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(),D(r.__webglDepthbuffer[i],e,!1)}else n.bindFramebuffer(36160,r.__webglFramebuffer),r.__webglDepthbuffer=t.createRenderbuffer(),D(r.__webglDepthbuffer,e,!1);n.bindFramebuffer(36160,null)}function F(t){return a&&t.isWebGLMultisampleRenderTarget?Math.min(u,t.samples):0}let B=!1,N=!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=T,this.setTexture2DArray=function(t,e){const r=i.get(t);t.version>0&&r.__version!==t.version?R(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?R(r,t,e):(n.activeTexture(33984+e),n.bindTexture(32879,r.__webglTexture))},this.setTextureCube=S,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=F(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(),D(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),C(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),C(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&&O(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===B&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),B=!0),t=t.texture),T(t,e)},this.safeSetTextureCube=function(t,e){t&&t.isWebGLCubeRenderTarget&&(!1===N&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),N=!0),t=t.texture),S(t,e)}}function Mu(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 _u extends ah{constructor(t=[]){super(),this.cameras=t}}_u.prototype.isArrayCamera=!0;class Eu extends Ha{constructor(){super(),this.type="Group"}}function Tu(){this._targetRay=null,this._grip=null,this._hand=null}function Su(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 ah;u.layers.enable(1),u.viewport=new No;const d=new ah;d.layers.enable(2),d.viewport=new No;const p=[u,d],f=new _u;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 Tu,h[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=h[t];return void 0===e&&(e=new Tu,h[t]=e),e.getGripSpace()},this.getHand=function(t){let e=h[t];return void 0===e&&(e=new Tu,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 ko,w=new ko;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 mh;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 Au(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 Pu(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 No,_=new No;let E=null,T=e.width,S=e.height,A=1,P=null,C=null;const L=new No(0,0,T,S),R=new No(0,0,T,S);let I=!1;const D=new fh;let O=!1,F=!1;const B=new va,N=new ko,z={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function U(){return null===x?A:1}let k,V,H,G,W,j,X,q,Y,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(){k=new Ah(lt),V=new Eh(lt,k,t),k.init(V),ot=new Mu(lt,k,V),H=new bu(lt,k,V),G=new Lh(lt),W=new ou,j=new wu(lt,k,H,W,V,ot,G),X=new Sh(m),q=new gh(lt,V),at=new Mh(lt,k,q,V),Y=new Ph(lt,q,G,at),Z=new Oh(lt,Y,q,G),it=new Dh(lt),tt=new Th(W),J=new su(m,X,k,V,at,tt),$=new Au(W),Q=new cu(W),K=new gu(k,V),nt=new wh(m,X,H,Z,a),et=new xu(m,Z,V),rt=new _h(lt,k,G,V),st=new Ch(lt,k,G,V),G.programs=J.programs,m.capabilities=V,m.extensions=k,m.properties=W,m.renderLists=Q,m.shadowMap=et,m.state=H,m.info=G}ct();const ut=new Su(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=k.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=k.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return A},this.setPixelRatio=function(t){void 0!==t&&(A=t,this.setSize(T,S,!1))},this.getSize=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),t=new Lo),t.set(T,S)},this.setSize=function(t,n,i){ut.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(T=t,S=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 Lo),t.set(T*A,S*A).floor()},this.setDrawingBufferSize=function(t,n,i){T=t,S=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 No),t.copy(M)},this.getViewport=function(t){return t.copy(L)},this.setViewport=function(t,e,n,i){t.isVector4?L.set(t.x,t.y,t.z,t.w):L.set(t,e,n,i),H.viewport(M.copy(L).multiplyScalar(A).floor())},this.getScissor=function(t){return t.copy(R)},this.setScissor=function(t,e,n,i){t.isVector4?R.set(t.x,t.y,t.z,t.w):R.set(t,e,n,i),H.scissor(_.copy(R).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){C=t},this.getClearColor=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getClearColor() now requires a Color as an argument"),t=new dl),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=z);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=Y.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=q.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*U()),d.setMode(1)):d.setMode(4);else if(r.isLine){let t=i.linewidth;void 0===t&&(t=1),H.setLineWidth(t*U()),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 mh;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||D.intersectsSprite(t)){i&&N.setFromMatrixPosition(t.matrixWorld).applyMatrix4(B);const e=Z.update(t),r=t.material;r.visible&&u.push(t,e,r,n,N.z,null)}}else if(t.isImmediateRenderObject)i&&N.setFromMatrixPosition(t.matrixWorld).applyMatrix4(B),u.push(t,null,t.material,n,N.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||D.intersectsObject(t))){i&&N.setFromMatrixPosition(t.matrixWorld).applyMatrix4(B);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,N.z,o)}}else r.visible&&u.push(t,e,r,n,N.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=z);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=zc.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=z),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===O&&(!0===F||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),V.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,N.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(V.floatVertexTextures){if(null===t.boneTexture){let n=Math.sqrt(4*e.length);n=Co.ceilPowerOfTwo(n),n=Math.max(n,4);const i=new Float32Array(n*n*4);i.set(t.boneMatrices);const r=new uh(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,S),zc.upload(lt,h.uniformsList,M,j)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(zc.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),B.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),D.setFromProjectionMatrix(B),F=this.localClippingEnabled,O=tt.init(this.clippingPlanes,F,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,C),!0===O&&tt.beginShadows();const r=d.state.shadowsArray;et.render(r,t,e),d.setupLights(),d.setupLightsView(e),!0===O&&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(L).multiplyScalar(A).floor(),_.copy(R).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&&(k.has("EXT_color_buffer_half_float")||V.isWebGL2&&k.has("EXT_color_buffer_float"));if(!(1009===l||ot.convert(l)===lt.getParameter(35738)||1015===l&&(V.isWebGL2||k.has("OES_texture_float")||k.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}))}Eu.prototype.isGroup=!0,Object.assign(Tu.prototype,{constructor:Tu,getHandSpace:function(){return null===this._hand&&(this._hand=new Eu,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 Eu,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return null===this._grip&&(this._grip=new Eu,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 Eu;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(Su.prototype,So.prototype);(class extends Pu{}).prototype.isWebGL1Renderer=!0;class Cu{constructor(t,e=25e-5){this.name="",this.color=new dl(t),this.density=e}clone(){return new Cu(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}Cu.prototype.isFogExp2=!0;class Lu{constructor(t,e=1,n=1e3){this.name="",this.color=new dl(t),this.near=e,this.far=n}clone(){return new Lu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}Lu.prototype.isFog=!0;class Ru extends Ha{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 Iu(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=Co.generateUUID()}Ru.prototype.isScene=!0,Object.defineProperty(Iu.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Iu.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=Co.generateUUID()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new Iu(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=Co.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 Du=new ko;function Ou(t,e,n,i){this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=!0===i}Object.defineProperties(Ou.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(Ou.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(t){for(let e=0,n=this.data.count;e<n;e++)Du.x=this.getX(e),Du.y=this.getY(e),Du.z=this.getZ(e),Du.applyMatrix4(t),this.setXYZ(e,Du.x,Du.y,Du.z);return this},applyNormalMatrix:function(t){for(let e=0,n=this.count;e<n;e++)Du.x=this.getX(e),Du.y=this.getY(e),Du.z=this.getZ(e),Du.applyNormalMatrix(t),this.setXYZ(e,Du.x,Du.y,Du.z);return this},transformDirection:function(t){for(let e=0,n=this.count;e<n;e++)Du.x=this.getX(e),Du.y=this.getY(e),Du.z=this.getZ(e),Du.transformDirection(t),this.setXYZ(e,Du.x,Du.y,Du.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 gl(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 Ou(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 Fu extends sl{constructor(t){super(),this.type="SpriteMaterial",this.color=new dl(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 Bu;Fu.prototype.isSpriteMaterial=!0;const Nu=new ko,zu=new ko,Uu=new ko,ku=new Lo,Vu=new Lo,Hu=new va,Gu=new ko,Wu=new ko,ju=new ko,Xu=new Lo,qu=new Lo,Yu=new Lo;function Zu(t,e,n,i,r,s){ku.subVectors(t,n).addScalar(.5).multiply(i),void 0!==r?(Vu.x=s*ku.x-r*ku.y,Vu.y=r*ku.x+s*ku.y):Vu.copy(ku),t.copy(e),t.x+=Vu.x,t.y+=Vu.y,t.applyMatrix4(Hu)}(class extends Ha{constructor(t){if(super(),this.type="Sprite",void 0===Bu){Bu=new Fl;const t=new Iu(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);Bu.setIndex([0,1,2,0,2,3]),Bu.setAttribute("position",new Ou(t,3,0,!1)),Bu.setAttribute("uv",new Ou(t,2,3,!1))}this.geometry=Bu,this.material=void 0!==t?t:new Fu,this.center=new Lo(.5,.5)}raycast(t,e){null===t.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),zu.setFromMatrixScale(this.matrixWorld),Hu.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Uu.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&zu.multiplyScalar(-Uu.z);const n=this.material.rotation;let i,r;0!==n&&(r=Math.cos(n),i=Math.sin(n));const s=this.center;Zu(Gu.set(-.5,-.5,0),Uu,s,zu,i,r),Zu(Wu.set(.5,-.5,0),Uu,s,zu,i,r),Zu(ju.set(.5,.5,0),Uu,s,zu,i,r),Xu.set(0,0),qu.set(1,0),Yu.set(1,1);let o=t.ray.intersectTriangle(Gu,Wu,ju,!1,Nu);if(null===o&&(Zu(Wu.set(-.5,.5,0),Uu,s,zu,i,r),qu.set(0,1),o=t.ray.intersectTriangle(Gu,ju,Wu,!1,Nu),null===o))return;const a=t.ray.origin.distanceTo(Nu);a<t.near||a>t.far||e.push({distance:a,point:Nu.clone(),uv:il.getUV(Nu,Gu,Wu,ju,Xu,qu,Yu,new Lo),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 Ju=new ko,$u=new No,Qu=new No,Ku=new ko,td=new va;function ed(t,e){Kl.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new va,this.bindMatrixInverse=new va}function nd(){Ha.call(this),this.type="Bone"}ed.prototype=Object.assign(Object.create(Kl.prototype),{constructor:ed,isSkinnedMesh:!0,copy:function(t){return Kl.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 No,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){Kl.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;$u.fromBufferAttribute(i.attributes.skinIndex,t),Qu.fromBufferAttribute(i.attributes.skinWeight,t),Ju.fromBufferAttribute(i.attributes.position,t).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let t=0;t<4;t++){const i=Qu.getComponent(t);if(0!==i){const r=$u.getComponent(t);td.multiplyMatrices(n.bones[r].matrixWorld,n.boneInverses[r]),e.addScaledVector(Ku.copy(Ju).applyMatrix4(td),i)}}return e.applyMatrix4(this.bindMatrixInverse)}}),nd.prototype=Object.assign(Object.create(Ha.prototype),{constructor:nd,isBone:!0});const id=new va,rd=new va;class sd{constructor(t=[],e=[]){this.uuid=Co.generateUUID(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new va)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new va;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let i=0,r=t.length;i<r;i++){const r=t[i]?t[i].matrixWorld:rd;id.multiplyMatrices(r,e[i]),id.toArray(n,16*i)}null!==i&&(i.needsUpdate=!0)}clone(){return new sd(this.bones,this.boneInverses)}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const n=this.bones[e];if(n.name===t)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){const i=t.bones[n];let r=e[i];void 0===r&&(console.warn("THREE.Skeleton: No bone found with UUID:",i),r=new nd),this.bones.push(r),this.boneInverses.push((new va).fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let i=0,r=e.length;i<r;i++){const r=e[i];t.bones.push(r.uuid);const s=n[i];t.boneInverses.push(s.toArray())}return t}}const od=new va,ad=new va,ld=[],hd=new Kl;function cd(t,e,n){Kl.call(this,t,e),this.instanceMatrix=new gl(new Float32Array(16*n),16),this.instanceColor=null,this.count=n,this.frustumCulled=!1}cd.prototype=Object.assign(Object.create(Kl.prototype),{constructor:cd,isInstancedMesh:!0,copy:function(t){return Kl.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(hd.geometry=this.geometry,hd.material=this.material,void 0!==hd.material)for(let r=0;r<i;r++){this.getMatrixAt(r,od),ad.multiplyMatrices(n,od),hd.matrixWorld=ad,hd.raycast(t,ld);for(let t=0,n=ld.length;t<n;t++){const n=ld[t];n.instanceId=r,n.object=this,e.push(n)}ld.length=0}},setColorAt:function(t,e){null===this.instanceColor&&(this.instanceColor=new gl(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 ud extends sl{constructor(t){super(),this.type="LineBasicMaterial",this.color=new dl(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}}ud.prototype.isLineBasicMaterial=!0;const dd=new ko,pd=new ko,fd=new va,md=new ga,gd=new la;function vd(t=new Fl,e=new ud){Ha.call(this),this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}vd.prototype=Object.assign(Object.create(Ha.prototype),{constructor:vd,isLine:!0,copy:function(t){return Ha.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++)dd.fromBufferAttribute(e,t-1),pd.fromBufferAttribute(e,t),n[t]=n[t-1],n[t]+=dd.distanceTo(pd);t.setAttribute("lineDistance",new Tl(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(),gd.copy(n.boundingSphere),gd.applyMatrix4(i),gd.radius+=r,!1===t.ray.intersectsSphere(gd))return;fd.copy(i).invert(),md.copy(t.ray).applyMatrix4(fd);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,l=new ko,h=new ko,c=new ko,u=new ko,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(md.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(md.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 yd=new ko,xd=new ko;function bd(t,e){vd.call(this,t,e),this.type="LineSegments"}bd.prototype=Object.assign(Object.create(vd.prototype),{constructor:bd,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)yd.fromBufferAttribute(e,t),xd.fromBufferAttribute(e,t+1),n[t]=0===t?0:n[t-1],n[t+1]=n[t]+yd.distanceTo(xd);t.setAttribute("lineDistance",new Tl(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 wd extends vd{constructor(t,e){super(t,e),this.type="LineLoop"}}wd.prototype.isLineLoop=!0;class Md extends sl{constructor(t){super(),this.type="PointsMaterial",this.color=new dl(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}}Md.prototype.isPointsMaterial=!0;const _d=new va,Ed=new ga,Td=new la,Sd=new ko;function Ad(t=new Fl,e=new Md){Ha.call(this),this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}function Pd(t,e,n,i,r,s,o){const a=Ed.distanceSqToPoint(t);if(a<n){const n=new ko;Ed.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})}}Ad.prototype=Object.assign(Object.create(Ha.prototype),{constructor:Ad,isPoints:!0,copy:function(t){return Ha.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(),Td.copy(n.boundingSphere),Td.applyMatrix4(i),Td.radius+=r,!1===t.ray.intersectsSphere(Td))return;_d.copy(i).invert(),Ed.copy(t.ray).applyMatrix4(_d);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);Sd.fromBufferAttribute(o,s),Pd(Sd,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++)Sd.fromBufferAttribute(o,n),Pd(Sd,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 Fo{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 Cd extends Fo{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}}Cd.prototype.isCompressedTexture=!0;class Ld extends Fo{constructor(t,e,n,i,r,s,o,a,l){super(t,e,n,i,r,s,o,a,l),this.needsUpdate=!0}}Ld.prototype.isCanvasTexture=!0;(class extends Fo{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 Rd=function(t,e,n){n=n||2;const i=e&&e.length,r=i?e[0]*n:t.length;let s=Id(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=Id(t,a,l,i,!1),h===h.next&&(h.steiner=!0),r.push(Gd(h));for(r.sort(Ud),s=0;s<r.length;s++)kd(r[s],n),n=Dd(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 Od(s,o,n,a,l,p),o};function Id(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=Kd(s,t[s],t[s+1],o);else for(s=n-i;s>=e;s-=i)o=Kd(s,t[s],t[s+1],o);return o&&qd(o,o.next)&&(tp(o),o=o.next),o}function Dd(t,e){if(!t)return t;e||(e=t);let n,i=t;do{if(n=!1,i.steiner||!qd(i,i.next)&&0!==Xd(i.prev,i,i.next))i=i.next;else{if(tp(i),i=e=i.prev,i===i.next)break;n=!0}}while(n||i!==e);return e}function Od(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=Hd(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?Bd(t,i,r,s):Fd(t))e.push(a.i/n),e.push(t.i/n),e.push(l.i/n),tp(t),t=l.next,h=l.next;else if((t=l)===h){o?1===o?Od(t=Nd(Dd(t),e,n),e,n,i,r,s,2):2===o&&zd(t,e,n,i,r,s):Od(Dd(t),e,n,i,r,s,1);break}}function Fd(t){const e=t.prev,n=t,i=t.next;if(Xd(e,n,i)>=0)return!1;let r=t.next.next;for(;r!==t.prev;){if(Wd(e.x,e.y,n.x,n.y,i.x,i.y,r.x,r.y)&&Xd(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Bd(t,e,n,i){const r=t.prev,s=t,o=t.next;if(Xd(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=Hd(a,l,e,n,i),d=Hd(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&&Wd(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&Xd(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==t.prev&&f!==t.next&&Wd(r.x,r.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Xd(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=u;){if(p!==t.prev&&p!==t.next&&Wd(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&Xd(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==t.prev&&f!==t.next&&Wd(r.x,r.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Xd(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function Nd(t,e,n){let i=t;do{const r=i.prev,s=i.next.next;!qd(r,s)&&Yd(r,i,i.next,s)&&$d(r,s)&&$d(s,r)&&(e.push(r.i/n),e.push(i.i/n),e.push(s.i/n),tp(i),tp(i.next),i=t=s),i=i.next}while(i!==t);return Dd(i)}function zd(t,e,n,i,r,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&jd(o,t)){let a=Qd(o,t);return o=Dd(o,o.next),a=Dd(a,a.next),Od(o,e,n,i,r,s),void Od(a,e,n,i,r,s)}t=t.next}o=o.next}while(o!==t)}function Ud(t,e){return t.x-e.x}function kd(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&&Wd(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),$d(n,t)&&(c<u||c===u&&(n.x>s.x||n.x===s.x&&Vd(s,n)))&&(s=n,u=c)),n=n.next}while(n!==a);return s}(t,e)){const n=Qd(e,t);Dd(e,e.next),Dd(n,n.next)}}function Vd(t,e){return Xd(t.prev,t,e.prev)<0&&Xd(e.next,t,t.next)<0}function Hd(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 Gd(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 Wd(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 jd(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&&Yd(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&($d(t,e)&&$d(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)&&(Xd(t.prev,t,e.prev)||Xd(t,e.prev,e))||qd(t,e)&&Xd(t.prev,t,t.next)>0&&Xd(e.prev,e,e.next)>0)}function Xd(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function qd(t,e){return t.x===e.x&&t.y===e.y}function Yd(t,e,n,i){const r=Jd(Xd(t,e,n)),s=Jd(Xd(t,e,i)),o=Jd(Xd(n,i,t)),a=Jd(Xd(n,i,e));return r!==s&&o!==a||(!(0!==r||!Zd(t,n,e))||(!(0!==s||!Zd(t,i,e))||(!(0!==o||!Zd(n,t,i))||!(0!==a||!Zd(n,e,i)))))}function Zd(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 Jd(t){return t>0?1:t<0?-1:0}function $d(t,e){return Xd(t.prev,t,t.next)<0?Xd(t,e,t.next)>=0&&Xd(t,t.prev,e)>=0:Xd(t,e,t.prev)<0||Xd(t,t.next,e)<0}function Qd(t,e){const n=new ep(t.i,t.x,t.y),i=new ep(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 Kd(t,e,n,i){const r=new ep(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 tp(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 ep(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 np={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 np.area(t)<0},triangulateShape:function(t,e){const n=[],i=[],r=[];ip(t),rp(n,t);let s=t.length;e.forEach(ip);for(let t=0;t<e.length;t++)i.push(s),s+=e[t].length,rp(n,e[t]);const o=Rd(n,i);for(let t=0;t<o.length;t+=3)r.push(o.slice(t,t+3));return r}};function ip(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function rp(t,e){for(let n=0;n<e.length;n++)t.push(e[n].x),t.push(e[n].y)}class sp extends Fl{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:op;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 ko,x=new ko,b=new ko),h||(p=0,c=0,u=0,d=0);const M=t.extractPoints(o);let _=M.shape;const E=M.holes;if(!np.isClockWise(_)){_=_.reverse();for(let t=0,e=E.length;t<e;t++){const e=E[t];np.isClockWise(e)&&(E[t]=e.reverse())}}const T=np.triangulateShape(_,E),S=_;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,C=T.length;function L(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 Lo(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 Lo(i/s,r/s)}const R=[];for(let t=0,e=S.length,n=e-1,i=t+1;t<e;t++,n++,i++)n===e&&(n=0),i===e&&(i=0),R[t]=L(S[t],S[n],S[i]);const I=[];let D,O=R.concat();for(let t=0,e=E.length;t<e;t++){const e=E[t];D=[];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),D[t]=L(e[t],e[i],e[r]);I.push(D),O=O.concat(D)}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=S.length;t<e;t++){const e=A(S[t],R[t],i);N(e.x,e.y,-n)}for(let t=0,e=E.length;t<e;t++){const e=E[t];D=I[t];for(let t=0,r=e.length;t<r;t++){const r=A(e[t],D[t],i);N(r.x,r.y,-n)}}}const F=u+d;for(let t=0;t<P;t++){const e=h?A(_[t],O[t],F):_[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),N(b.x,b.y,b.z)):N(e.x,e.y,0)}for(let t=1;t<=a;t++)for(let e=0;e<P;e++){const n=h?A(_[e],O[e],F):_[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),N(b.x,b.y,b.z)):N(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=S.length;t<e;t++){const e=A(S[t],R[t],i);N(e.x,e.y,l+n)}for(let t=0,e=E.length;t<e;t++){const e=E[t];D=I[t];for(let t=0,r=e.length;t<r;t++){const r=A(e[t],D[t],i);w?N(r.x,r.y+g[a-1].y,g[a-1].x+n):N(r.x,r.y,l+n)}}}function B(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);U(e+i+n,e+r+n,e+r+s,e+i+s)}}}function N(t,e,n){s.push(t),s.push(e),s.push(n)}function z(t,e,r){k(t),k(e),k(r);const s=i.length/3,o=m.generateTopUV(n,i,s-3,s-2,s-1);V(o[0]),V(o[1]),V(o[2])}function U(t,e,r,s){k(t),k(e),k(s),k(e),k(r),k(s);const o=i.length/3,a=m.generateSideWallUV(n,i,o-6,o-3,o-2,o-1);V(a[0]),V(a[1]),V(a[3]),V(a[1]),V(a[2]),V(a[3])}function k(t){i.push(s[3*t+0]),i.push(s[3*t+1]),i.push(s[3*t+2])}function V(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<C;t++){const n=T[t];z(n[2]+e,n[1]+e,n[0]+e)}t=a+2*p,e=P*t;for(let t=0;t<C;t++){const n=T[t];z(n[0]+e,n[1]+e,n[2]+e)}}else{for(let t=0;t<C;t++){const e=T[t];z(e[2],e[1],e[0])}for(let t=0;t<C;t++){const e=T[t];z(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;B(S,e),e+=S.length;for(let t=0,n=E.length;t<n;t++){const n=E[t];B(n,e),e+=n.length}n.addGroup(t,i.length/3-t,1)}()}this.setAttribute("position",new Tl(i,3)),this.setAttribute("uv",new Tl(r,2)),this.computeVertexNormals()}toJSON(){const t=Fl.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 op={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 Lo(s,o),new Lo(a,l),new Lo(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 Lo(o,1-l),new Lo(h,1-u),new Lo(d,1-f),new Lo(m,1-v)]:[new Lo(a,1-l),new Lo(c,1-u),new Lo(p,1-f),new Lo(g,1-v)]}};function ap(t,e,n){Fl.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:n};const i=[],r=[],s=[],o=[],a=1e-5,l=new ko,h=new ko,c=new ko,u=new ko,d=new ko;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 Tl(r,3)),this.setAttribute("normal",new Tl(s,3)),this.setAttribute("uv",new Tl(o,2))}ap.prototype=Object.create(Fl.prototype),ap.prototype.constructor=ap;class lp extends Fl{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===np.isClockWise(h)&&(h=h.reverse());for(let t=0,e=c.length;t<e;t++){const e=c[t];!0===np.isClockWise(e)&&(c[t]=e.reverse())}const u=np.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 Tl(i,3)),this.setAttribute("normal",new Tl(r,3)),this.setAttribute("uv",new Tl(s,2))}toJSON(){const t=Fl.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 sl{constructor(t){super(),this.type="ShadowMaterial",this.color=new dl(0),this.transparent=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this}}).prototype.isShadowMaterial=!0;function hp(t){sl.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new dl(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 dl(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Lo(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 cp(t){hp.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Lo(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=Co.clamp(2.5*(t-1)/(t+1),0,1)}}),this.sheen=null,this.transmission=0,this.transmissionMap=null,this.setValues(t)}(class extends sh{constructor(t){super(t),this.type="RawShaderMaterial"}}).prototype.isRawShaderMaterial=!0,hp.prototype=Object.create(sl.prototype),hp.prototype.constructor=hp,hp.prototype.isMeshStandardMaterial=!0,hp.prototype.copy=function(t){return sl.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},cp.prototype=Object.create(hp.prototype),cp.prototype.constructor=cp,cp.prototype.isMeshPhysicalMaterial=!0,cp.prototype.copy=function(t){return hp.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 dl).copy(t.sheen):this.sheen=null,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this};(class extends sl{constructor(t){super(),this.type="MeshPhongMaterial",this.color=new dl(16777215),this.specular=new dl(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new dl(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Lo(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 sl{constructor(t){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new dl(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new dl(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Lo(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 sl{constructor(t){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Lo(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 sl{constructor(t){super(),this.type="MeshLambertMaterial",this.color=new dl(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new dl(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 sl{constructor(t){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new dl(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Lo(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 ud{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 up={arraySlice:function(t,e,n){return up.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=up.convertArray(l,e.times.constructor),e.values=up.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=up.arraySlice(i.values,t,e)}else if(s>=i.times[u]){const t=u*l+a,e=t+l-a;d=up.arraySlice(i.values,t,e)}else{const t=i.createInterpolant(),e=a,n=l-a;t.evaluate(s),d=up.arraySlice(t.resultBuffer,e,n)}if("quaternion"===r){(new Uo).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)Uo.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 dp(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 pp(t,e,n,i){dp.call(this,t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function fp(t,e,n,i){dp.call(this,t,e,n,i)}function mp(t,e,n,i){dp.call(this,t,e,n,i)}Object.assign(dp.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(dp.prototype,{beforeStart_:dp.prototype.copySampleValue_,afterEnd_:dp.prototype.copySampleValue_}),pp.prototype=Object.assign(Object.create(dp.prototype),{constructor:pp,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}}),fp.prototype=Object.assign(Object.create(dp.prototype),{constructor:fp,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}}),mp.prototype=Object.assign(Object.create(dp.prototype),{constructor:mp,interpolate_:function(t){return this.copySampleValue_(t-1)}});class gp{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=up.convertArray(e,this.TimeBufferType),this.values=up.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:up.convertArray(t.times,Array),values:up.convertArray(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(n.interpolation=e)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new mp(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new fp(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new pp(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=up.arraySlice(n,r,s),this.values=up.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&&up.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=up.arraySlice(this.times),e=up.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=up.arraySlice(t,0,s),this.values=up.arraySlice(e,0,s*n)):(this.times=t,this.values=e),this}clone(){const t=up.arraySlice(this.times,0),e=up.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}gp.prototype.TimeBufferType=Float32Array,gp.prototype.ValueBufferType=Float32Array,gp.prototype.DefaultInterpolation=2301;class vp extends gp{}vp.prototype.ValueTypeName="bool",vp.prototype.ValueBufferType=Array,vp.prototype.DefaultInterpolation=2300,vp.prototype.InterpolantFactoryMethodLinear=void 0,vp.prototype.InterpolantFactoryMethodSmooth=void 0;class yp extends gp{}yp.prototype.ValueTypeName="color";class xp extends gp{}function bp(t,e,n,i){dp.call(this,t,e,n,i)}xp.prototype.ValueTypeName="number",bp.prototype=Object.assign(Object.create(dp.prototype),{constructor:bp,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)Uo.slerpFlat(r,0,s,l-o,s,l,a);return r}});class wp extends gp{InterpolantFactoryMethodLinear(t){return new bp(this.times,this.values,this.getValueSize(),t)}}wp.prototype.ValueTypeName="quaternion",wp.prototype.DefaultInterpolation=2301,wp.prototype.InterpolantFactoryMethodSmooth=void 0;class Mp extends gp{}Mp.prototype.ValueTypeName="string",Mp.prototype.ValueBufferType=Array,Mp.prototype.DefaultInterpolation=2300,Mp.prototype.InterpolantFactoryMethodLinear=void 0,Mp.prototype.InterpolantFactoryMethodSmooth=void 0;class _p extends gp{}_p.prototype.ValueTypeName="vector";class Ep{constructor(t,e=-1,n,i=2500){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=Co.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(Tp(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(gp.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=up.getKeyframeOrder(o);o=up.sortedArray(o,1,l),a=up.sortedArray(a,1,l),i||0!==o[0]||(o.push(r),a.push(a[0])),s.push(new xp(".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=[];up.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 xp(".morphTargetInfluence["+n+"]",t,s))}a=t.length*(s||1)}else{const s=".bones["+e[t].name+"]";n(_p,s+".position",r,"pos",i),n(wp,s+".quaternion",r,"rot",i),n(_p,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 Tp(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 xp;case"vector":case"vector2":case"vector3":case"vector4":return _p;case"color":return yp;case"quaternion":return wp;case"bool":case"boolean":return vp;case"string":return Mp}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],n=[];up.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 Sp={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 Ap=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 Pp(t){this.manager=void 0!==t?t:Ap,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}Object.assign(Pp.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 Cp={};function Lp(t){Pp.call(this,t)}function Rp(t){Pp.call(this,t)}Lp.prototype=Object.assign(Object.create(Pp.prototype),{constructor:Lp,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=Sp.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!==Cp[t])return void Cp[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{Cp[t]=[],Cp[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=Cp[t];if(delete Cp[t],200===this.status||0===this.status){0===this.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),Sp.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=Cp[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=Cp[t];delete Cp[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=Cp[t];delete Cp[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}}),Rp.prototype=Object.assign(Object.create(Pp.prototype),{constructor:Rp,load:function(t,e,n,i){const r=this,s=[],o=new Cd,a=new Lp(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 Ip extends Pp{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=Sp.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),Sp.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 Dp extends Pp{constructor(t){super(t)}load(t,e,n,i){const r=new hh,s=new Ip(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 Op(t){Pp.call(this,t)}function Fp(t){Pp.call(this,t)}function Bp(){this.type="Curve",this.arcLengthDivisions=200}Op.prototype=Object.assign(Object.create(Pp.prototype),{constructor:Op,load:function(t,e,n,i){const r=this,s=new uh,o=new Lp(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}}),Fp.prototype=Object.assign(Object.create(Pp.prototype),{constructor:Fp,load:function(t,e,n,i){const r=new Fo,s=new Ip(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(Bp.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 Lo:new ko);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 ko,i=[],r=[],s=[],o=new ko,a=new va;for(let e=0;e<=t;e++){const n=e/t;i[e]=this.getTangentAt(n,new ko),i[e].normalize()}r[0]=new ko,s[0]=new ko;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(Co.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(Co.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 Np extends Bp{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 Lo,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}}Np.prototype.isEllipseCurve=!0;class zp extends Np{constructor(t,e,n,i,r,s){super(t,e,n,n,i,r,s),this.type="ArcCurve"}}function Up(){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)}}}zp.prototype.isArcCurve=!0;const kp=new ko,Vp=new Up,Hp=new Up,Gp=new Up;class Wp extends Bp{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 ko){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]:(kp.subVectors(i[0],i[1]).add(i[0]),o=kp);const c=i[l%r],u=i[(l+1)%r];if(this.closed||l+2<r?a=i[(l+2)%r]:(kp.subVectors(i[r-1],i[r-2]).add(i[r-1]),a=kp),"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),Vp.initNonuniformCatmullRom(o.x,c.x,u.x,a.x,e,n,i),Hp.initNonuniformCatmullRom(o.y,c.y,u.y,a.y,e,n,i),Gp.initNonuniformCatmullRom(o.z,c.z,u.z,a.z,e,n,i)}else"catmullrom"===this.curveType&&(Vp.initCatmullRom(o.x,c.x,u.x,a.x,this.tension),Hp.initCatmullRom(o.y,c.y,u.y,a.y,this.tension),Gp.initCatmullRom(o.z,c.z,u.z,a.z,this.tension));return n.set(Vp.calc(h),Hp.calc(h),Gp.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 ko).fromArray(n))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function jp(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 Xp(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 qp(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)}Wp.prototype.isCatmullRomCurve3=!0;class Yp extends Bp{constructor(t=new Lo,e=new Lo,n=new Lo,i=new Lo){super(),this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new Lo){const n=e,i=this.v0,r=this.v1,s=this.v2,o=this.v3;return n.set(qp(t,i.x,r.x,s.x,o.x),qp(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}}Yp.prototype.isCubicBezierCurve=!0;class Zp extends Bp{constructor(t=new ko,e=new ko,n=new ko,i=new ko){super(),this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new ko){const n=e,i=this.v0,r=this.v1,s=this.v2,o=this.v3;return n.set(qp(t,i.x,r.x,s.x,o.x),qp(t,i.y,r.y,s.y,o.y),qp(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}}Zp.prototype.isCubicBezierCurve3=!0;class Jp extends Bp{constructor(t=new Lo,e=new Lo){super(),this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new Lo){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 Lo;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}}Jp.prototype.isLineCurve=!0;class $p extends Bp{constructor(t=new Lo,e=new Lo,n=new Lo){super(),this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new Lo){const n=e,i=this.v0,r=this.v1,s=this.v2;return n.set(Xp(t,i.x,r.x,s.x),Xp(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}}$p.prototype.isQuadraticBezierCurve=!0;class Qp extends Bp{constructor(t=new ko,e=new ko,n=new ko){super(),this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new ko){const n=e,i=this.v0,r=this.v1,s=this.v2;return n.set(Xp(t,i.x,r.x,s.x),Xp(t,i.y,r.y,s.y),Xp(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}}Qp.prototype.isQuadraticBezierCurve3=!0;class Kp extends Bp{constructor(t=[]){super(),this.type="SplineCurve",this.points=t}getPoint(t,e=new Lo){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(jp(o,a.x,l.x,h.x,c.x),jp(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 Lo).fromArray(n))}return this}}Kp.prototype.isSplineCurve=!0;var tf=Object.freeze({__proto__:null,ArcCurve:zp,CatmullRomCurve3:Wp,CubicBezierCurve:Yp,CubicBezierCurve3:Zp,EllipseCurve:Np,LineCurve:Jp,LineCurve3:class extends Bp{constructor(t=new ko,e=new ko){super(),this.type="LineCurve3",this.isLineCurve3=!0,this.v1=t,this.v2=e}getPoint(t,e=new ko){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:$p,QuadraticBezierCurve3:Qp,SplineCurve:Kp});class ef extends Bp{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 Jp(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 tf[n.type]).fromJSON(n))}return this}}class nf extends ef{constructor(t){super(),this.type="Path",this.currentPoint=new Lo,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 Jp(this.currentPoint.clone(),new Lo(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){const r=new $p(this.currentPoint.clone(),new Lo(t,e),new Lo(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,r,s){const o=new Yp(this.currentPoint.clone(),new Lo(t,e),new Lo(n,i),new Lo(r,s));return this.curves.push(o),this.currentPoint.set(r,s),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new Kp(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 Np(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 rf extends nf{constructor(t){super(t),this.uuid=Co.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 nf).fromJSON(n))}return this}}class sf extends Ha{constructor(t,e=1){super(),this.type="Light",this.color=new dl(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}}sf.prototype.isLight=!0;(class extends sf{constructor(t,e,n){super(t,n),this.type="HemisphereLight",this.position.copy(Ha.DefaultUp),this.updateMatrix(),this.groundColor=new dl(e)}copy(t){return sf.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}).prototype.isHemisphereLight=!0;const of=new va,af=new ko,lf=new ko;class hf{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new Lo(512,512),this.map=null,this.mapPass=null,this.matrix=new va,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new fh,this._frameExtents=new Lo(1,1),this._viewportCount=1,this._viewports=[new No(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;af.setFromMatrixPosition(t.matrixWorld),e.position.copy(af),lf.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(lf),e.updateMatrixWorld(),of.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(of),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 cf extends hf{constructor(){super(new ah(50,1,.5,500)),this.focus=1}updateMatrices(t){const e=this.camera,n=2*Co.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}}cf.prototype.isSpotLightShadow=!0;class uf extends sf{constructor(t,e,n=0,i=Math.PI/3,r=0,s=1){super(t,e),this.type="SpotLight",this.position.copy(Ha.DefaultUp),this.updateMatrix(),this.target=new Ha,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.shadow=new cf}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}}uf.prototype.isSpotLight=!0;const df=new va,pf=new ko,ff=new ko;class mf extends hf{constructor(){super(new ah(90,1,.5,500)),this._frameExtents=new Lo(4,2),this._viewportCount=6,this._viewports=[new No(2,1,1,1),new No(0,1,1,1),new No(3,1,1,1),new No(1,1,1,1),new No(3,0,1,1),new No(1,0,1,1)],this._cubeDirections=[new ko(1,0,0),new ko(-1,0,0),new ko(0,0,1),new ko(0,0,-1),new ko(0,1,0),new ko(0,-1,0)],this._cubeUps=[new ko(0,1,0),new ko(0,1,0),new ko(0,1,0),new ko(0,1,0),new ko(0,0,1),new ko(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()),pf.setFromMatrixPosition(t.matrixWorld),n.position.copy(pf),ff.copy(n.position),ff.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(ff),n.updateMatrixWorld(),i.makeTranslation(-pf.x,-pf.y,-pf.z),df.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(df)}}mf.prototype.isPointLightShadow=!0;class gf extends sf{constructor(t,e,n=0,i=1){super(t,e),this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new mf}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}}gf.prototype.isPointLight=!0;class vf extends oh{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=Ha.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}}vf.prototype.isOrthographicCamera=!0;class yf extends hf{constructor(){super(new vf(-5,5,5,-5,.5,500))}}yf.prototype.isDirectionalLightShadow=!0;class xf extends sf{constructor(t,e){super(t,e),this.type="DirectionalLight",this.position.copy(Ha.DefaultUp),this.updateMatrix(),this.target=new Ha,this.shadow=new yf}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}xf.prototype.isDirectionalLight=!0;(class extends sf{constructor(t,e){super(t,e),this.type="AmbientLight"}}).prototype.isAmbientLight=!0;(class extends sf{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 bf{constructor(){this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new ko)}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)}}bf.prototype.isSphericalHarmonics3=!0;class wf extends sf{constructor(t=new bf,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}}wf.prototype.isLightProbe=!0;const Mf=function(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let n=0,i=t.length;n<i;n++)e+=String.fromCharCode(t[n]);try{return decodeURIComponent(escape(e))}catch(t){return e}},_f=function(t){const e=t.lastIndexOf("/");return-1===e?"./":t.substr(0,e+1)};function Ef(){Fl.call(this),this.type="InstancedBufferGeometry",this.instanceCount=1/0}function Tf(t,e,n,i){"number"==typeof n&&(i=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),gl.call(this,t,e,n),this.meshPerAttribute=i||1}function Sf(t){"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),Pp.call(this,t),this.options={premultiplyAlpha:"none"}}Ef.prototype=Object.assign(Object.create(Fl.prototype),{constructor:Ef,isInstancedBufferGeometry:!0,copy:function(t){return Fl.prototype.copy.call(this,t),this.instanceCount=t.instanceCount,this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){const t=Fl.prototype.toJSON.call(this);return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}),Tf.prototype=Object.assign(Object.create(gl.prototype),{constructor:Tf,isInstancedBufferAttribute:!0,copy:function(t){return gl.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},toJSON:function(){const t=gl.prototype.toJSON.call(this);return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}),Sf.prototype=Object.assign(Object.create(Pp.prototype),{constructor:Sf,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=Sp.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){Sp.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 Af{constructor(){this.type="ShapePath",this.color=new dl,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new nf,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 rf;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=np.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 rf,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 rf,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 Pf(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 Af;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 Cf;(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=Pf(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 Lf=function(){return void 0===Cf&&(Cf=new(window.AudioContext||window.webkitAudioContext)),Cf};class Rf extends Pp{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new Lp(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);Lf().decodeAudioData(t,(function(t){e(t)}))}catch(e){i?i(e):console.error(e),r.manager.itemError(t)}}),n,i)}}(class extends wf{constructor(t,e,n=1){super(void 0,n);const i=(new dl).set(t),r=(new dl).set(e),s=new ko(i.r,i.g,i.b),o=new ko(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 wf{constructor(t,e=1){super(void 0,e);const n=(new dl).set(t);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}}).prototype.isAmbientLightProbe=!0;new va,new va;class If{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){Uo.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){const s=this._workIndex*r;Uo.multiplyQuaternionsFlat(t,s,t,e,t,n),Uo.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 Df=new RegExp("[\\[\\]\\.:\\/]","g"),Of="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",Ff=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]"),Bf=/(WCOD+)?/.source.replace("WCOD",Of),Nf=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),zf=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Uf=new RegExp("^"+Ff+Bf+Nf+zf+"$"),kf=["material","materials","bones"];function Vf(t,e,n){const i=n||Hf.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}function Hf(t,e,n){this.path=e,this.parsedPath=n||Hf.parseTrackName(e),this.node=Hf.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}Object.assign(Vf.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(Hf,{Composite:Vf,create:function(t,e,n){return t&&t.isAnimationObjectGroup?new Hf.Composite(t,e,n):new Hf(t,e,n)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(Df,"")},parseTrackName:function(t){const e=Uf.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!==kf.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(Hf.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=Hf.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(Hf.prototype,{_getValue_unbound:Hf.prototype.getValue,_setValue_unbound:Hf.prototype.setValue});(class{constructor(){this.uuid=Co.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 Hf(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 Hf(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 Hf(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 Gf{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 So{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 If(Hf.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 fp(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?Ep.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 Gf(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?Ep.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 Wf{constructor(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}clone(){return new Wf(void 0===this.value.clone?this.value:this.value.clone())}}function jf(t,e,n){Iu.call(this,t,e),this.meshPerAttribute=n||1}function Xf(t,e,n,i,r){this.buffer=t,this.type=e,this.itemSize=n,this.elementSize=i,this.count=r,this.version=0}function qf(t,e,n=0,i=1/0){this.ray=new ga(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new Pa,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 Yf(t,e){return t.distance-e.distance}function Zf(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++)Zf(i[t],e,n,!0)}}jf.prototype=Object.assign(Object.create(Iu.prototype),{constructor:jf,isInstancedInterleavedBuffer:!0,copy:function(t){return Iu.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},clone:function(t){const e=Iu.prototype.clone.call(this,t);return e.meshPerAttribute=this.meshPerAttribute,e},toJSON:function(t){const e=Iu.prototype.toJSON.call(this,t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}),Object.defineProperty(Xf.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Xf.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(qf.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 Zf(t,this,n,e),n.sort(Yf),n},intersectObjects:function(t,e=!1,n=[]){for(let i=0,r=t.length;i<r;i++)Zf(t[i],this,n,e);return n.sort(Yf),n}});const Jf=new Lo;class $f{constructor(t=new Lo(1/0,1/0),e=new Lo(-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=Jf.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 Lo),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 Lo),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 Lo),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 Lo),e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return Jf.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)}}$f.prototype.isBox2=!0;const Qf=new ko,Kf=new ko;function tm(t){Ha.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}tm.prototype=Object.create(Ha.prototype),tm.prototype.constructor=tm,tm.prototype.isImmediateRenderObject=!0;const em=new ko,nm=new va,im=new va;const rm=new pl({side:1,depthWrite:!1,depthTest:!1});new Kl(new eh,rm);Bp.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(Bp.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},nf.prototype.fromPoints=function(t){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(t)},class extends bd{constructor(t=10,e=10,n=4473924,i=8947848){n=new dl(n),i=new dl(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 Fl;h.setAttribute("position",new Tl(a,3)),h.setAttribute("color",new Tl(l,3));super(h,new ud({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 bd{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 Fl,i=[],r=[],s=new dl(0,0,1),o=new dl(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 Tl(i,3)),n.setAttribute("color",new Tl(r,3));super(n,new ud({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");im.copy(this.root.matrixWorld).invert();for(let t=0,n=0;t<e.length;t++){const r=e[t];r.parent&&r.parent.isBone&&(nm.multiplyMatrices(im,r.matrixWorld),em.setFromMatrixPosition(nm),i.setXYZ(n,em.x,em.y,em.z),nm.multiplyMatrices(im,r.parent.matrixWorld),em.setFromMatrixPosition(nm),i.setXYZ(n+1,em.x,em.y,em.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.")},Pp.prototype.extractUrlBase=function(t){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),_f(t)},Pp.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.")}},$f.prototype.center=function(t){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(t)},$f.prototype.empty=function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},$f.prototype.isIntersectionBox=function(t){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},$f.prototype.size=function(t){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(t)},Go.prototype.center=function(t){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(t)},Go.prototype.empty=function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Go.prototype.isIntersectionBox=function(t){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},Go.prototype.isIntersectionSphere=function(t){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},Go.prototype.size=function(t){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(t)},la.prototype.empty=function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()},fh.prototype.setFromMatrix=function(t){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(t)},class{constructor(t=new ko,e=new ko){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 ko),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 ko),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 ko),this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Qf.subVectors(t,this.start),Kf.subVectors(this.end,this.start);const n=Kf.dot(Kf);let i=Kf.dot(Qf)/n;return e&&(i=Co.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 ko),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)},Co.random16=function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},Co.nearestPowerOfTwo=function(t){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),Co.floorPowerOfTwo(t)},Co.nextPowerOfTwo=function(t){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),Co.ceilPowerOfTwo(t)},Ro.prototype.flattenToArrayOffset=function(t,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},Ro.prototype.multiplyVector3=function(t){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},Ro.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},Ro.prototype.applyToBufferAttribute=function(t){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},Ro.prototype.applyToVector3Array=function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")},Ro.prototype.getInverse=function(t){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(t).invert()},va.prototype.extractPosition=function(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)},va.prototype.flattenToArrayOffset=function(t,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},va.prototype.getPosition=function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new ko).setFromMatrixColumn(this,3)},va.prototype.setRotationFromQuaternion=function(t){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(t)},va.prototype.multiplyToArray=function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},va.prototype.multiplyVector3=function(t){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},va.prototype.multiplyVector4=function(t){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},va.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},va.prototype.rotateAxis=function(t){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),t.transformDirection(this)},va.prototype.crossVector=function(t){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},va.prototype.translate=function(){console.error("THREE.Matrix4: .translate() has been removed.")},va.prototype.rotateX=function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},va.prototype.rotateY=function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},va.prototype.rotateZ=function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},va.prototype.rotateByAxis=function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},va.prototype.applyToBufferAttribute=function(t){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},va.prototype.applyToVector3Array=function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},va.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)},va.prototype.getInverse=function(t){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(t).invert()},Xa.prototype.isIntersectionLine=function(t){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(t)},Uo.prototype.multiplyVector3=function(t){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),t.applyQuaternion(this)},Uo.prototype.inverse=function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()},ga.prototype.isIntersectionBox=function(t){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},ga.prototype.isIntersectionPlane=function(t){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(t)},ga.prototype.isIntersectionSphere=function(t){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},il.prototype.area=function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},il.prototype.barycoordFromPoint=function(t,e){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(t,e)},il.prototype.midpoint=function(t){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(t)},il.prototypenormal=function(t){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(t)},il.prototype.plane=function(t){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(t)},il.barycoordFromPoint=function(t,e,n,i,r){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),il.getBarycoord(t,e,n,i,r)},il.normal=function(t,e,n,i){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),il.getNormal(t,e,n,i)},rf.prototype.extractAllPoints=function(t){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(t)},rf.prototype.extrude=function(t){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new sp(this,t)},rf.prototype.makeGeometry=function(t){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new lp(this,t)},Lo.prototype.fromAttribute=function(t,e,n){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},Lo.prototype.distanceToManhattan=function(t){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},Lo.prototype.lengthManhattan=function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},ko.prototype.setEulerFromRotationMatrix=function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},ko.prototype.setEulerFromQuaternion=function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},ko.prototype.getPositionFromMatrix=function(t){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(t)},ko.prototype.getScaleFromMatrix=function(t){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(t)},ko.prototype.getColumnFromMatrix=function(t,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},ko.prototype.applyProjection=function(t){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(t)},ko.prototype.fromAttribute=function(t,e,n){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},ko.prototype.distanceToManhattan=function(t){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},ko.prototype.lengthManhattan=function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},No.prototype.fromAttribute=function(t,e,n){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},No.prototype.lengthManhattan=function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Ha.prototype.getChildByName=function(t){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(t)},Ha.prototype.renderDepth=function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},Ha.prototype.translate=function(t,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,t)},Ha.prototype.getWorldRotation=function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},Ha.prototype.applyMatrix=function(t){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)},Object.defineProperties(Ha.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.")}}}),Kl.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(Kl.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.")}}}),ed.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},Object.defineProperty(Bp.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}}),ah.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(sf.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(gl.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)}}}),gl.prototype.setDynamic=function(t){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===t?35048:35044),this},gl.prototype.copyIndicesArray=function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},gl.prototype.setArray=function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},Fl.prototype.addIndex=function(t){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(t)},Fl.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 gl(arguments[1],arguments[2])))},Fl.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)},Fl.prototype.clearDrawCalls=function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},Fl.prototype.computeOffsets=function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},Fl.prototype.removeAttribute=function(t){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(t)},Fl.prototype.applyMatrix=function(t){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)},Object.defineProperties(Fl.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(Ef.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(qf.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(Iu.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)}}}),Iu.prototype.setDynamic=function(t){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===t?35048:35044),this},Iu.prototype.setArray=function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},sp.prototype.getArrays=function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")},sp.prototype.addShapeList=function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")},sp.prototype.addShape=function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")},Ru.prototype.dispose=function(){console.error("THREE.Scene: .dispose() has been removed.")},Wf.prototype.onUpdate=function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this},Object.defineProperties(sl.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 dl}},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(cp.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(sh.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}}}),Pu.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)},Pu.prototype.animate=function(t){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(t)},Pu.prototype.getCurrentRenderTarget=function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},Pu.prototype.getMaxAnisotropy=function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},Pu.prototype.getPrecision=function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},Pu.prototype.resetGLState=function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},Pu.prototype.supportsFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},Pu.prototype.supportsHalfFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},Pu.prototype.supportsStandardDerivatives=function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},Pu.prototype.supportsCompressedTextureS3TC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},Pu.prototype.supportsCompressedTexturePVRTC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},Pu.prototype.supportsBlendMinMax=function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},Pu.prototype.supportsVertexTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},Pu.prototype.supportsInstancedArrays=function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},Pu.prototype.enableScissorTest=function(t){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(t)},Pu.prototype.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},Pu.prototype.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},Pu.prototype.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},Pu.prototype.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},Pu.prototype.setFaceCulling=function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},Pu.prototype.allocTextureUnit=function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},Pu.prototype.setTexture=function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},Pu.prototype.setTexture2D=function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},Pu.prototype.setTextureCube=function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},Pu.prototype.getActiveMipMapLevel=function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()},Object.defineProperties(Pu.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(xu.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(zo.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 Ha{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 Rf).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()},lh.prototype.updateCubeMap=function(t,e){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(t,e)},lh.prototype.clear=function(t,e,n,i){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(t,e,n,i)},Do.crossOrigin=void 0,Do.loadTexture=function(t,e,n,i){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");const r=new Fp;r.setCrossOrigin(this.crossOrigin);const s=r.load(t,n,void 0,i);return e&&(s.mapping=e),s},Do.loadTextureCube=function(t,e,n,i){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");const r=new Dp;r.setCrossOrigin(this.crossOrigin);const s=r.load(t,n,void 0,i);return e&&(s.mapping=e),s},Do.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},Do.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 sm=function(){function t(t){Pp.call(this,t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(t){return new s(t)})),this.register((function(t){return new a(t)})),this.register((function(t){return new l(t)})),this.register((function(t){return new o(t)})),this.register((function(t){return new i(t)})),this.register((function(t){return new h(t)}))}function e(){var t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}t.prototype=Object.assign(Object.create(Pp.prototype),{constructor:t,load:function(t,e,n,i){var r,s=this;r=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:_f(t),this.manager.itemStart(t);var o=function(e){i?i(e):console.error(e),s.manager.itemError(t),s.manager.itemEnd(t)},a=new Lp(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,(function(n){try{s.parse(n,r,(function(n){e(n),s.manager.itemEnd(t)}),o)}catch(t){o(t)}}),n,o)},setDRACOLoader:function(t){return this.dracoLoader=t,this},setDDSLoader:function(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')},setKTX2Loader:function(t){return this.ktx2Loader=t,this},setMeshoptDecoder:function(t){return this.meshoptDecoder=t,this},register:function(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this},unregister:function(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this},parse:function(t,e,i,s){var o,a={},l={};if("string"==typeof t)o=t;else if(Mf(new Uint8Array(t,0,4))===c){try{a[n.KHR_BINARY_GLTF]=new p(t)}catch(t){return void(s&&s(t))}o=a[n.KHR_BINARY_GLTF].content}else o=Mf(new Uint8Array(t));var h=JSON.parse(o);if(void 0===h.asset||h.asset.version[0]<2)s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));else{var u=new H(h,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(var d=0;d<this.pluginCallbacks.length;d++){var g=this.pluginCallbacks[d](u);l[g.name]=g,a[g.name]=!0}if(h.extensionsUsed)for(d=0;d<h.extensionsUsed.length;++d){var x=h.extensionsUsed[d],b=h.extensionsRequired||[];switch(x){case n.KHR_MATERIALS_UNLIT:a[x]=new r;break;case n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:a[x]=new v;break;case n.KHR_DRACO_MESH_COMPRESSION:a[x]=new f(h,this.dracoLoader);break;case n.KHR_TEXTURE_TRANSFORM:a[x]=new m;break;case n.KHR_MESH_QUANTIZATION:a[x]=new y;break;default:b.indexOf(x)>=0&&void 0===l[x]&&console.warn('THREE.GLTFLoader: Unknown extension "'+x+'".')}}u.setExtensions(a),u.setPlugins(l),u.parse(i,s)}}});var n={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};function i(t){this.parser=t,this.name=n.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}function r(){this.name=n.KHR_MATERIALS_UNLIT}function s(t){this.parser=t,this.name=n.KHR_MATERIALS_CLEARCOAT}function o(t){this.parser=t,this.name=n.KHR_MATERIALS_TRANSMISSION}function a(t){this.parser=t,this.name=n.KHR_TEXTURE_BASISU}function l(t){this.parser=t,this.name=n.EXT_TEXTURE_WEBP,this.isSupported=null}function h(t){this.name=n.EXT_MESHOPT_COMPRESSION,this.parser=t}i.prototype._markDefs=function(){for(var t=this.parser,e=this.parser.json.nodes||[],n=0,i=e.length;n<i;n++){var r=e[n];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&t._addNodeRef(this.cache,r.extensions[this.name].light)}},i.prototype._loadLight=function(t){var e=this.parser,n="light:"+t,i=e.cache.get(n);if(i)return i;var r,s=e.json,o=((s.extensions&&s.extensions[this.name]||{}).lights||[])[t],a=new dl(16777215);void 0!==o.color&&a.fromArray(o.color);var l=void 0!==o.range?o.range:0;switch(o.type){case"directional":(r=new xf(a)).target.position.set(0,0,-1),r.add(r.target);break;case"point":(r=new gf(a)).distance=l;break;case"spot":(r=new uf(a)).distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,r.angle=o.spot.outerConeAngle,r.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,r.target.position.set(0,0,-1),r.add(r.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return r.position.set(0,0,0),r.decay=2,void 0!==o.intensity&&(r.intensity=o.intensity),r.name=e.createUniqueName(o.name||"light_"+t),i=Promise.resolve(r),e.cache.add(n,i),i},i.prototype.createNodeAttachment=function(t){var e=this,n=this.parser,i=n.json.nodes[t],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(t){return n._getNodeRef(e.cache,r,t)}))},r.prototype.getMaterialType=function(){return pl},r.prototype.extendParams=function(t,e,n){var i=[];t.color=new dl(1,1,1),t.opacity=1;var r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){var s=r.baseColorFactor;t.color.fromArray(s),t.opacity=s[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(t,"map",r.baseColorTexture))}return Promise.all(i)},s.prototype.getMaterialType=function(t){var e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?cp:null},s.prototype.extendMaterialParams=function(t,e){var n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();var r=[],s=i.extensions[this.name];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)){var o=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new Lo(o,-o)}return Promise.all(r)},o.prototype.getMaterialType=function(t){var e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?cp:null},o.prototype.extendMaterialParams=function(t,e){var n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();var 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)},a.prototype.loadTexture=function(t){var e=this.parser,n=e.json,i=n.textures[t];if(!i.extensions||!i.extensions[this.name])return null;var 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)},l.prototype.loadTexture=function(t){var e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;var s=r.extensions[e],o=i.images[s.source],a=n.textureLoader;if(o.uri){var l=n.options.manager.getHandler(o.uri);null!==l&&(a=l)}return this.detectSupport().then((function(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)}))},l.prototype.detectSupport=function(){return this.isSupported||(this.isSupported=new Promise((function(t){var e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported},h.prototype.loadBufferView=function(t){var e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){var i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.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([r,s.ready]).then((function(t){var e=i.byteOffset||0,n=i.byteLength||0,r=i.count,o=i.byteStride,a=new ArrayBuffer(r*o),l=new Uint8Array(t[0],e,n);return s.decodeGltfBuffer(new Uint8Array(a),r,o,l,i.mode,i.filter),a}))}return null};var c="glTF",u=1313821514,d=5130562;function p(t){this.name=n.KHR_BINARY_GLTF,this.content=null,this.body=null;var e=new DataView(t,0,12);if(this.header={magic:Mf(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==c)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");for(var i=this.header.length-12,r=new DataView(t,12),s=0;s<i;){var o=r.getUint32(s,!0);s+=4;var a=r.getUint32(s,!0);if(s+=4,a===u){var l=new Uint8Array(t,12+s,o);this.content=Mf(l)}else if(a===d){var h=12+s;this.body=t.slice(h,h+o)}s+=o}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}function f(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=n.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}function m(){this.name=n.KHR_TEXTURE_TRANSFORM}function g(t){hp.call(this),this.isGLTFSpecularGlossinessMaterial=!0;var e=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),n=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),i=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\ttexelSpecular = sRGBToLinear( texelSpecular );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),r=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= 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"),o={specular:{value:(new dl).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=o,this.onBeforeCompile=function(t){for(var a in o)t.uniforms[a]=o[a];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:function(){return o.specular.value},set:function(t){o.specular.value=t}},specularMap:{get:function(){return o.specularMap.value},set:function(t){o.specularMap.value=t,t?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return o.glossiness.value},set:function(t){o.glossiness.value=t}},glossinessMap:{get:function(){return o.glossinessMap.value},set:function(t){o.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)}function v(){return{name:n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,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:function(){return g},extendParams:function(t,e,n){var i=e.extensions[this.name];t.color=new dl(1,1,1),t.opacity=1;var r=[];if(Array.isArray(i.diffuseFactor)){var s=i.diffuseFactor;t.color.fromArray(s),t.opacity=s[3]}if(void 0!==i.diffuseTexture&&r.push(n.assignTexture(t,"map",i.diffuseTexture)),t.emissive=new dl(0,0,0),t.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,t.specular=new dl(1,1,1),Array.isArray(i.specularFactor)&&t.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){var o=i.specularGlossinessTexture;r.push(n.assignTexture(t,"glossinessMap",o)),r.push(n.assignTexture(t,"specularMap",o))}return Promise.all(r)},createMaterial:function(t){var e=new g(t);return e.fog=!0,e.color=t.color,e.map=void 0===t.map?null:t.map,e.lightMap=null,e.lightMapIntensity=1,e.aoMap=void 0===t.aoMap?null:t.aoMap,e.aoMapIntensity=1,e.emissive=t.emissive,e.emissiveIntensity=1,e.emissiveMap=void 0===t.emissiveMap?null:t.emissiveMap,e.bumpMap=void 0===t.bumpMap?null:t.bumpMap,e.bumpScale=1,e.normalMap=void 0===t.normalMap?null:t.normalMap,e.normalMapType=0,t.normalScale&&(e.normalScale=t.normalScale),e.displacementMap=null,e.displacementScale=1,e.displacementBias=0,e.specularMap=void 0===t.specularMap?null:t.specularMap,e.specular=t.specular,e.glossinessMap=void 0===t.glossinessMap?null:t.glossinessMap,e.glossiness=t.glossiness,e.alphaMap=null,e.envMap=void 0===t.envMap?null:t.envMap,e.envMapIntensity=1,e.refractionRatio=.98,e}}}function y(){this.name=n.KHR_MESH_QUANTIZATION}function x(t,e,n,i){dp.call(this,t,e,n,i)}f.prototype.decodePrimitive=function(t,e){var n=this.json,i=this.dracoLoader,r=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,o={},a={},l={};for(var h in s){var c=R[h]||h.toLowerCase();o[c]=s[h]}for(h in t.attributes){c=R[h]||h.toLowerCase();if(void 0!==s[h]){var u=n.accessors[t.attributes[h]],d=A[u.componentType];l[c]=d,a[c]=!0===u.normalized}}return e.getDependency("bufferView",r).then((function(t){return new Promise((function(e){i.decodeDracoFile(t,(function(t){for(var n in t.attributes){var i=t.attributes[n],r=a[n];void 0!==r&&(i.normalized=r)}e(t)}),o,l)}))}))},m.prototype.extendTexture=function(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},g.prototype=Object.create(hp.prototype),g.prototype.constructor=g,g.prototype.copy=function(t){return hp.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},x.prototype=Object.create(dp.prototype),x.prototype.constructor=x,x.prototype.copySampleValue_=function(t){for(var e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i*3+i,s=0;s!==i;s++)e[s]=n[r+s];return e},x.prototype.beforeStart_=x.prototype.copySampleValue_,x.prototype.afterEnd_=x.prototype.copySampleValue_,x.prototype.interpolate_=function(t,e,n,i){for(var 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,x=0;x!==o;x++){var b=s[f+x+o],w=s[f+x+a]*h,M=s[p+x+o],_=s[p+x]*h;r[x]=v*b+y*w+m*M+g*_}return r};var b=0,w=1,M=2,_=3,E=4,T=5,S=6,A={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},P={9728:1003,9729:1006,9984:1004,9985:1007,9986:1005,9987:1008},C={33071:1001,33648:1002,10497:1e3},L={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},R={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},I={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},D={CUBICSPLINE:void 0,LINEAR:2301,STEP:2300},O="OPAQUE",F="MASK",B="BLEND";function N(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 z(t,e,n){for(var i in n.extensions)void 0===t[i]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=n.extensions[i])}function U(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 k(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(var n=0,i=e.weights.length;n<i;n++)t.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){var r=e.extras.targetNames;if(t.morphTargetInfluences.length===r.length){t.morphTargetDictionary={};for(n=0,i=r.length;n<i;n++)t.morphTargetDictionary[r[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function V(t){for(var e="",n=Object.keys(t).sort(),i=0,r=n.length;i<r;i++)e+=n[i]+":"+t[n[i]]+";";return e}function H(t,n){this.json=t||{},this.extensions={},this.plugins={},this.options=n||{},this.cache=new e,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.nodeNamesUsed={},"undefined"!=typeof createImageBitmap&&!1===/Firefox/.test(navigator.userAgent)?this.textureLoader=new Sf(this.options.manager):this.textureLoader=new Fp(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Lp(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}function G(t,e,n){var i=e.attributes,r=[];function s(e,i){return n.getDependency("accessor",e).then((function(e){t.setAttribute(i,e)}))}for(var o in i){var a=R[o]||o.toLowerCase();a in t.attributes||r.push(s(i[o],a))}if(void 0!==e.indices&&!t.index){var l=n.getDependency("accessor",e.indices).then((function(e){t.setIndex(e)}));r.push(l)}return U(t,e),function(t,e,n){var i=e.attributes,r=new Go;if(void 0!==i.POSITION){var s=(p=n.json.accessors[i.POSITION]).min,o=p.max;if(void 0!==s&&void 0!==o){r.set(new ko(s[0],s[1],s[2]),new ko(o[0],o[1],o[2]));var a=e.targets;if(void 0!==a){for(var l=new ko,h=new ko,c=0,u=a.length;c<u;c++){var d=a[c];if(void 0!==d.POSITION){var p;s=(p=n.json.accessors[d.POSITION]).min,o=p.max;void 0!==s&&void 0!==o?(h.setX(Math.max(Math.abs(s[0]),Math.abs(o[0]))),h.setY(Math.max(Math.abs(s[1]),Math.abs(o[1]))),h.setZ(Math.max(Math.abs(s[2]),Math.abs(o[2]))),l.max(h)):console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(l)}t.boundingBox=r;var f=new la;r.getCenter(f.center),f.radius=r.min.distanceTo(r.max)/2,t.boundingSphere=f}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}(t,e,n),Promise.all(r).then((function(){return void 0!==e.targets?function(t,e,n){for(var i=!1,r=!1,s=0,o=e.length;s<o;s++){if(void 0!==(h=e[s]).POSITION&&(i=!0),void 0!==h.NORMAL&&(r=!0),i&&r)break}if(!i&&!r)return Promise.resolve(t);var a=[],l=[];for(s=0,o=e.length;s<o;s++){var h=e[s];if(i){var c=void 0!==h.POSITION?n.getDependency("accessor",h.POSITION):t.attributes.position;a.push(c)}if(r){c=void 0!==h.NORMAL?n.getDependency("accessor",h.NORMAL):t.attributes.normal;l.push(c)}}return Promise.all([Promise.all(a),Promise.all(l)]).then((function(e){var 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 W(t,e){var n=t.getIndex();if(null===n){var i=[],r=t.getAttribute("position");if(void 0===r)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(var s=0;s<r.count;s++)i.push(s);t.setIndex(i),n=t.getIndex()}var o=n.count-2,a=[];if(2===e)for(s=1;s<=o;s++)a.push(n.getX(0)),a.push(n.getX(s)),a.push(n.getX(s+1));else for(s=0;s<o;s++)s%2==0?(a.push(n.getX(s)),a.push(n.getX(s+1)),a.push(n.getX(s+2))):(a.push(n.getX(s+2)),a.push(n.getX(s+1)),a.push(n.getX(s)));a.length/3!==o&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");var l=t.clone();return l.setIndex(a),l}return H.prototype.setExtensions=function(t){this.extensions=t},H.prototype.setPlugins=function(t){this.plugins=t},H.prototype.parse=function(t,e){var n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this._invokeAll((function(t){return t._markDefs&&t._markDefs()})),Promise.all(this._invokeAll((function(t){return t.beforeRoot&&t.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(e){var s={scene:e[0][i.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:i.asset,parser:n,userData:{}};z(r,s,i),U(s,i),Promise.all(n._invokeAll((function(t){return t.afterRoot&&t.afterRoot(s)}))).then((function(){t(s)}))})).catch(e)},H.prototype._markDefs=function(){for(var t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[],i=0,r=e.length;i<r;i++)for(var s=e[i].joints,o=0,a=s.length;o<a;o++)t[s[o]].isBone=!0;for(var l=0,h=t.length;l<h;l++){var c=t[l];void 0!==c.mesh&&(this._addNodeRef(this.meshCache,c.mesh),void 0!==c.skin&&(n[c.mesh].isSkinnedMesh=!0)),void 0!==c.camera&&this._addNodeRef(this.cameraCache,c.camera)}},H.prototype._addNodeRef=function(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)},H.prototype._getNodeRef=function(t,e,n){if(t.refs[e]<=1)return n;var i=n.clone();return i.name+="_instance_"+t.uses[e]++,i},H.prototype._invokeOne=function(t){var e=Object.values(this.plugins);e.push(this);for(var n=0;n<e.length;n++){var i=t(e[n]);if(i)return i}},H.prototype._invokeAll=function(t){var e=Object.values(this.plugins);e.unshift(this);for(var n=[],i=0;i<e.length;i++){var r=t(e[i]);r&&n.push(r)}return n},H.prototype.getDependency=function(t,e){var n=t+":"+e,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((function(t){return t.loadMesh&&t.loadMesh(e)}));break;case"accessor":i=this.loadAccessor(e);break;case"bufferView":i=this._invokeOne((function(t){return t.loadBufferView&&t.loadBufferView(e)}));break;case"buffer":i=this.loadBuffer(e);break;case"material":i=this._invokeOne((function(t){return t.loadMaterial&&t.loadMaterial(e)}));break;case"texture":i=this._invokeOne((function(t){return 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},H.prototype.getDependencies=function(t){var e=this.cache.get(t);if(!e){var n=this,i=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(i.map((function(e,i){return n.getDependency(t,i)}))),this.cache.add(t,e)}return e},H.prototype.loadBuffer=function(t){var e=this.json.buffers[t],i=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[n.KHR_BINARY_GLTF].body);var r=this.options;return new Promise((function(t,n){i.load(N(e.uri,r.path),t,void 0,(function(){n(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))}))}))},H.prototype.loadBufferView=function(t){var e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then((function(t){var n=e.byteLength||0,i=e.byteOffset||0;return t.slice(i,i+n)}))},H.prototype.loadAccessor=function(t){var e=this,n=this.json,i=this.json.accessors[t];if(void 0===i.bufferView&&void 0===i.sparse)return Promise.resolve(null);var r=[];return void 0!==i.bufferView?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),void 0!==i.sparse&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then((function(t){var r,s=t[0],o=L[i.type],a=A[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;if(u&&u!==h){var p=Math.floor(c/u),f="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,m=e.cache.get(f);m||(m=new Iu(new a(s,p*u,i.count*u/l),u/l),e.cache.add(f,m)),r=new Ou(m,o,c%u/l,d)}else r=new gl(null===s?new a(i.count*o):new a(s,c,i.count*o),o,d);if(void 0!==i.sparse){var g=L.SCALAR,v=A[i.sparse.indices.componentType],y=i.sparse.indices.byteOffset||0,x=i.sparse.values.byteOffset||0,b=new v(t[1],y,i.sparse.count*g),w=new a(t[2],x,i.sparse.count*o);null!==s&&(r=new gl(r.array.slice(),r.itemSize,r.normalized));for(var M=0,_=b.length;M<_;M++){var E=b[M];if(r.setX(E,w[M*o]),o>=2&&r.setY(E,w[M*o+1]),o>=3&&r.setZ(E,w[M*o+2]),o>=4&&r.setW(E,w[M*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return r}))},H.prototype.loadTexture=function(t){var e=this.json,n=this.options,i=e.textures[t],r=e.images[i.source],s=this.textureLoader;if(r.uri){var o=n.manager.getHandler(r.uri);null!==o&&(s=o)}return this.loadTextureImage(t,r,s)},H.prototype.loadTextureImage=function(t,e,n){var i=this,r=this.json,s=this.options,o=r.textures[t],a=self.URL||self.webkitURL,l=e.uri,h=!1,c=!0;if("image/jpeg"===e.mimeType&&(c=!1),void 0!==e.bufferView)l=i.getDependency("bufferView",e.bufferView).then((function(t){if("image/png"===e.mimeType){var n=new DataView(t,25,1).getUint8(0,!1);c=6===n||4===n||3===n}h=!0;var i=new Blob([t],{type:e.mimeType});return l=a.createObjectURL(i)}));else if(void 0===e.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");return Promise.resolve(l).then((function(t){return new Promise((function(e,i){var r=e;!0===n.isImageBitmapLoader&&(r=function(t){e(new Ld(t))}),n.load(N(t,s.path),r,void 0,i)}))})).then((function(e){!0===h&&a.revokeObjectURL(l),e.flipY=!1,o.name&&(e.name=o.name),c||(e.format=1022);var n=(r.samplers||{})[o.sampler]||{};return e.magFilter=P[n.magFilter]||1006,e.minFilter=P[n.minFilter]||1008,e.wrapS=C[n.wrapS]||1e3,e.wrapT=C[n.wrapT]||1e3,i.associations.set(e,{type:"textures",index:t}),e}))},H.prototype.assignTexture=function(t,e,i){var r=this;return this.getDependency("texture",i.index).then((function(s){if(void 0===i.texCoord||0==i.texCoord||"aoMap"===e&&1==i.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+i.texCoord+" for texture "+e+" not yet supported."),r.extensions[n.KHR_TEXTURE_TRANSFORM]){var o=void 0!==i.extensions?i.extensions[n.KHR_TEXTURE_TRANSFORM]:void 0;if(o){var a=r.associations.get(s);s=r.extensions[n.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}t[e]=s}))},H.prototype.assignFinalMaterial=function(t){var e=t.geometry,n=t.material,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;if(t.isPoints){var h="PointsMaterial:"+n.uuid,c=this.cache.get(h);c||(c=new Md,sl.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(h,c)),n=c}else if(t.isLine){h="LineBasicMaterial:"+n.uuid;var u=this.cache.get(h);u||(u=new ud,sl.prototype.copy.call(u,n),u.color.copy(n.color),this.cache.add(h,u)),n=u}if(i||r||s||o||a){h="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(h+="specular-glossiness:"),o&&(h+="skinning:"),i&&(h+="vertex-tangents:"),r&&(h+="vertex-colors:"),s&&(h+="flat-shading:"),a&&(h+="morph-targets:"),l&&(h+="morph-normals:");var d=this.cache.get(h);d||(d=n.clone(),o&&(d.skinning=!0),r&&(d.vertexColors=!0),s&&(d.flatShading=!0),a&&(d.morphTargets=!0),l&&(d.morphNormals=!0),i&&(d.vertexTangents=!0,d.normalScale&&(d.normalScale.y*=-1),d.clearcoatNormalScale&&(d.clearcoatNormalScale.y*=-1)),this.cache.add(h,d),this.associations.set(d,this.associations.get(n))),n=d}n.aoMap&&void 0===e.attributes.uv2&&void 0!==e.attributes.uv&&e.setAttribute("uv2",e.attributes.uv),t.material=n},H.prototype.getMaterialType=function(){return hp},H.prototype.loadMaterial=function(t){var e,i=this,r=this.json,s=this.extensions,o=r.materials[t],a={},l=o.extensions||{},h=[];if(l[n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var c=s[n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];e=c.getMaterialType(),h.push(c.extendParams(a,o,i))}else if(l[n.KHR_MATERIALS_UNLIT]){var u=s[n.KHR_MATERIALS_UNLIT];e=u.getMaterialType(),h.push(u.extendParams(a,o,i))}else{var d=o.pbrMetallicRoughness||{};if(a.color=new dl(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){var p=d.baseColorFactor;a.color.fromArray(p),a.opacity=p[3]}void 0!==d.baseColorTexture&&h.push(i.assignTexture(a,"map",d.baseColorTexture)),a.metalness=void 0!==d.metallicFactor?d.metallicFactor:1,a.roughness=void 0!==d.roughnessFactor?d.roughnessFactor:1,void 0!==d.metallicRoughnessTexture&&(h.push(i.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),h.push(i.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),e=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),h.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)}))))}!0===o.doubleSided&&(a.side=2);var f=o.alphaMode||O;return f===B?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,f===F&&(a.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&e!==pl&&(h.push(i.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new Lo(1,-1),void 0!==o.normalTexture.scale&&a.normalScale.set(o.normalTexture.scale,-o.normalTexture.scale)),void 0!==o.occlusionTexture&&e!==pl&&(h.push(i.assignTexture(a,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(a.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&e!==pl&&(a.emissive=(new dl).fromArray(o.emissiveFactor)),void 0!==o.emissiveTexture&&e!==pl&&h.push(i.assignTexture(a,"emissiveMap",o.emissiveTexture)),Promise.all(h).then((function(){var r;return r=e===g?s[n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new e(a),o.name&&(r.name=o.name),r.map&&(r.map.encoding=3001),r.emissiveMap&&(r.emissiveMap.encoding=3001),U(r,o),i.associations.set(r,{type:"materials",index:t}),o.extensions&&z(s,r,o),r}))},H.prototype.createUniqueName=function(t){for(var e=Hf.sanitizeNodeName(t||""),n=e,i=1;this.nodeNamesUsed[n];++i)n=e+"_"+i;return this.nodeNamesUsed[n]=!0,n},H.prototype.loadGeometries=function(t){var e=this,i=this.extensions,r=this.primitiveCache;function s(t){return i[n.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(n){return G(n,t,e)}))}for(var o,a,l=[],h=0,c=t.length;h<c;h++){var u,d=t[h],p=(a=void 0,(a=(o=d).extensions&&o.extensions[n.KHR_DRACO_MESH_COMPRESSION])?"draco:"+a.bufferView+":"+a.indices+":"+V(a.attributes):o.indices+":"+V(o.attributes)+":"+o.mode),f=r[p];if(f)l.push(f.promise);else u=d.extensions&&d.extensions[n.KHR_DRACO_MESH_COMPRESSION]?s(d):G(new Fl,d,e),r[p]={primitive:d,promise:u},l.push(u)}return Promise.all(l)},H.prototype.loadMesh=function(t){for(var e,n=this,i=this.json,r=this.extensions,s=i.meshes[t],o=s.primitives,a=[],l=0,h=o.length;l<h;l++){var c=void 0===o[l].material?(void 0===(e=this.cache).DefaultMaterial&&(e.DefaultMaterial=new hp({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial):this.getDependency("material",o[l].material);a.push(c)}return a.push(n.loadGeometries(o)),Promise.all(a).then((function(e){for(var i=e.slice(0,e.length-1),a=e[e.length-1],l=[],h=0,c=a.length;h<c;h++){var u,d=a[h],p=o[h],f=i[h];if(p.mode===E||p.mode===T||p.mode===S||void 0===p.mode)!0!==(u=!0===s.isSkinnedMesh?new ed(d,f):new Kl(d,f)).isSkinnedMesh||u.geometry.attributes.skinWeight.normalized||u.normalizeSkinWeights(),p.mode===T?u.geometry=W(u.geometry,1):p.mode===S&&(u.geometry=W(u.geometry,2));else if(p.mode===w)u=new bd(d,f);else if(p.mode===_)u=new vd(d,f);else if(p.mode===M)u=new wd(d,f);else{if(p.mode!==b)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+p.mode);u=new Ad(d,f)}Object.keys(u.geometry.morphAttributes).length>0&&k(u,s),u.name=n.createUniqueName(s.name||"mesh_"+t),U(u,s),p.extensions&&z(r,u,p),n.assignFinalMaterial(u),l.push(u)}if(1===l.length)return l[0];var m=new Eu;for(h=0,c=l.length;h<c;h++)m.add(l[h]);return m}))},H.prototype.loadCamera=function(t){var e,n=this.json.cameras[t],i=n[n.type];if(i)return"perspective"===n.type?e=new ah(Co.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(e=new vf(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),U(e,n),Promise.resolve(e);console.warn("THREE.GLTFLoader: Missing camera parameters.")},H.prototype.loadSkin=function(t){var e=this.json.skins[t],n={joints:e.joints};return void 0===e.inverseBindMatrices?Promise.resolve(n):this.getDependency("accessor",e.inverseBindMatrices).then((function(t){return n.inverseBindMatrices=t,n}))},H.prototype.loadAnimation=function(t){for(var e=this.json.animations[t],n=[],i=[],r=[],s=[],o=[],a=0,l=e.channels.length;a<l;a++){var h=e.channels[a],c=e.samplers[h.sampler],u=h.target,d=void 0!==u.node?u.node:u.id,p=void 0!==e.parameters?e.parameters[c.input]:c.input,f=void 0!==e.parameters?e.parameters[c.output]:c.output;n.push(this.getDependency("node",d)),i.push(this.getDependency("accessor",p)),r.push(this.getDependency("accessor",f)),s.push(c),o.push(u)}return Promise.all([Promise.all(n),Promise.all(i),Promise.all(r),Promise.all(s),Promise.all(o)]).then((function(n){for(var i=n[0],r=n[1],s=n[2],o=n[3],a=n[4],l=[],h=0,c=i.length;h<c;h++){var u=i[h],d=r[h],p=s[h],f=o[h],m=a[h];if(void 0!==u){var g;switch(u.updateMatrix(),u.matrixAutoUpdate=!0,I[m.path]){case I.weights:g=xp;break;case I.rotation:g=wp;break;case I.position:case I.scale:default:g=_p}var v=u.name?u.name:u.uuid,y=void 0!==f.interpolation?D[f.interpolation]:2301,b=[];I[m.path]===I.weights?u.traverse((function(t){!0===t.isMesh&&t.morphTargetInfluences&&b.push(t.name?t.name:t.uuid)})):b.push(v);var w=p.array;if(p.normalized){var M;if(w.constructor===Int8Array)M=1/127;else if(w.constructor===Uint8Array)M=1/255;else if(w.constructor==Int16Array)M=1/32767;else{if(w.constructor!==Uint16Array)throw new Error("THREE.GLTFLoader: Unsupported output accessor component type.");M=1/65535}for(var _=new Float32Array(w.length),E=0,T=w.length;E<T;E++)_[E]=w[E]*M;w=_}for(E=0,T=b.length;E<T;E++){var S=new g(b[E]+"."+I[m.path],d.array,w,y);"CUBICSPLINE"===f.interpolation&&(S.createInterpolant=function(t){return new x(this.times,this.values,this.getValueSize()/3,t)},S.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(S)}}}var A=e.name?e.name:"animation_"+t;return new Ep(A,void 0,l)}))},H.prototype.loadNode=function(t){var e,n=this.json,i=this.extensions,r=this,s=n.nodes[t],o=s.name?r.createUniqueName(s.name):"";return(e=[],void 0!==s.mesh&&e.push(r.getDependency("mesh",s.mesh).then((function(t){var e=r._getNodeRef(r.meshCache,s.mesh,t);return void 0!==s.weights&&e.traverse((function(t){if(t.isMesh)for(var e=0,n=s.weights.length;e<n;e++)t.morphTargetInfluences[e]=s.weights[e]})),e}))),void 0!==s.camera&&e.push(r.getDependency("camera",s.camera).then((function(t){return r._getNodeRef(r.cameraCache,s.camera,t)}))),r._invokeAll((function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)})).forEach((function(t){e.push(t)})),Promise.all(e)).then((function(e){var n;if((n=!0===s.isBone?new nd:e.length>1?new Eu:1===e.length?e[0]:new Ha)!==e[0])for(var a=0,l=e.length;a<l;a++)n.add(e[a]);if(s.name&&(n.userData.name=s.name,n.name=o),U(n,s),s.extensions&&z(i,n,s),void 0!==s.matrix){var h=new va;h.fromArray(s.matrix),n.applyMatrix4(h)}else void 0!==s.translation&&n.position.fromArray(s.translation),void 0!==s.rotation&&n.quaternion.fromArray(s.rotation),void 0!==s.scale&&n.scale.fromArray(s.scale);return r.associations.set(n,{type:"nodes",index:t}),n}))},H.prototype.loadScene=function(){function t(e,n,i,r){var s=i.nodes[e];return r.getDependency("node",e).then((function(t){return void 0===s.skin?t:r.getDependency("skin",s.skin).then((function(t){for(var n=[],i=0,s=(e=t).joints.length;i<s;i++)n.push(r.getDependency("node",e.joints[i]));return Promise.all(n)})).then((function(n){return t.traverse((function(t){if(t.isMesh){for(var i=[],r=[],s=0,o=n.length;s<o;s++){var a=n[s];if(a){i.push(a);var l=new va;void 0!==e.inverseBindMatrices&&l.fromArray(e.inverseBindMatrices.array,16*s),r.push(l)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[s])}t.bind(new sd(i,r),t.matrixWorld)}})),t}));var e})).then((function(e){n.add(e);var o=[];if(s.children)for(var a=s.children,l=0,h=a.length;l<h;l++){var c=a[l];o.push(t(c,e,i,r))}return Promise.all(o)}))}return function(e){var n=this.json,i=this.extensions,r=this.json.scenes[e],s=new Eu;r.name&&(s.name=this.createUniqueName(r.name)),U(s,r),r.extensions&&z(i,s,r);for(var o=r.nodes||[],a=[],l=0,h=o.length;l<h;l++)a.push(t(o[l],s,n,this));return Promise.all(a).then((function(){return s}))}}(),t}();class om extends Gt{constructor(t){super(),this.domElement=t,this.wrapper=document.createElement("div"),this.wrapper.appendChild(this.domElement),this.cssObject=new $i(this.wrapper),this.add(this.cssObject),this.up.set(0,0,1),this.initialzed=!0,this.visibleRadius=1/0}setWrapperCSSClass(t){this.wrapper.className=t}setWrapperDomID(t){this.wrapper.id=t}update(){const t=new Ht(this);return this.initialzed&&(t.shouldPlaceElement=!0,this.initialzed=!1),this.needUpdate&&(t.needUpdate=!0,this.needUpdate=!1),t}}class am extends om{constructor(){super(document.createElement("div"));const{THREE:t}=b.getInstance();this.boundingBox=document.createElement("div"),this.textElement=document.createElement("div"),this.imageElement=document.createElement("img"),this.textPositionInfo={anchor:"center",offsetX:0,offsetY:0},this.imagePositionInfo={anchor:"center",offsetX:0,offsetY:0},this.imageElement.setAttribute("draggable","false"),this.textElement.style.cssText="\n position: absolute;\n transform: translate(-50%, -50%);\n white-space: nowrap;\n border-style: solid;\n border-width: 0;\n border-color: white;\n line-height: 1.5;\n ",this.imageElement.style.cssText="\n position: absolute;\n transform: translate(-50%, -50%);\n ",this.boundingBox.style.cssText="\n position: absolute;\n transform: translate(-50%, -50%);\n display: none;\n border-style: solid;\n border-width: 2px;\n border-color: red;\n border-radius: 4px;\n pointer-events: none;\n ",this.status="idle",this.mouseStart=new t.Vector2,this.mouseEnd=new t.Vector2,this.listeners={onImageLoaded:()=>{this.onImageLoaded()},onMouseDown:t=>{this.onMouseDown(t)},onMouseMove:t=>{this.onMouseMove(t)},onMouseUp:t=>{this.onMouseUp(t)},onTouchStart:t=>{this.onTouchStart(t)},onTouchMove:t=>{this.onTouchMove(t)},onTouchEnd:t=>{this.onTouchEnd(t)}},this.registerListeners(),this.domElement.appendChild(this.imageElement),this.domElement.appendChild(this.textElement),this.domElement.appendChild(this.boundingBox),this.calcBBoxNextFrame=!0}updateTextTransform(){const{offsetX:t,offsetY:e,anchor:n}=this.textPositionInfo,{x:i,y:r}=am.ANCHOR_MAP[n];this.textElement.style.transform=`translate(${i}, ${r}) translate(${t}px, ${e}px)`}updateImageTransform(){const{offsetX:t,offsetY:e,anchor:n}=this.imagePositionInfo,{x:i,y:r}=am.ANCHOR_MAP[n];this.imageElement.style.transform=`translate(${i}, ${r}) translate(${t}px, ${e}px)`}calcBBox(){if(!this.visible||"none"===this.boundingBox.style.display)return;const t=this.domElement.getBoundingClientRect(),e=this.textElement.getBoundingClientRect(),n=this.imageElement.getBoundingClientRect(),{left:i,right:r,top:s,bottom:o}=e,{left:a,right:l,top:h,bottom:c}=n,u=[],{THREE:d}=b.getInstance();"none"!==this.textElement.style.display&&(u.push(new d.Vector2(i,s)),u.push(new d.Vector2(r,o))),"none"!==this.imageElement.style.display&&(u.push(new d.Vector2(a,h)),u.push(new d.Vector2(l,c)));let p=0,f=0,m=0,g=0;if(u.length){const e=(new d.Box2).setFromPoints(u),{x:n,y:i}=t;p=e.max.x-e.min.x+12,f=e.max.y-e.min.y+12,m=e.min.x-n-6,g=e.min.y-i-6}this.boundingBox.style.transform=`translate(${m}px, ${g}px)`,this.boundingBox.style.width=p+"px",this.boundingBox.style.height=f+"px"}registerListeners(){this.imageElement.addEventListener("load",this.listeners.onImageLoaded),this.imageElement.addEventListener("pointerdown",this.listeners.onMouseDown),this.imageElement.addEventListener("touchstart",this.listeners.onTouchStart),this.imageElement.addEventListener("touchmove",this.listeners.onTouchMove),this.imageElement.addEventListener("touchend",this.listeners.onTouchEnd),this.textElement.addEventListener("pointerdown",this.listeners.onMouseDown),this.textElement.addEventListener("touchstart",this.listeners.onTouchStart),this.textElement.addEventListener("touchmove",this.listeners.onTouchMove),this.textElement.addEventListener("touchend",this.listeners.onTouchEnd)}unregisterListeners(){this.imageElement.removeEventListener("load",this.listeners.onImageLoaded),this.imageElement.removeEventListener("pointerdown",this.listeners.onMouseDown),this.imageElement.removeEventListener("touchstart",this.listeners.onTouchStart),this.imageElement.removeEventListener("touchmove",this.listeners.onTouchMove),this.imageElement.removeEventListener("touchend",this.listeners.onTouchEnd),this.textElement.removeEventListener("pointerdown",this.listeners.onMouseDown),this.textElement.removeEventListener("touchstart",this.listeners.onTouchStart),this.textElement.removeEventListener("touchmove",this.listeners.onTouchMove),this.textElement.removeEventListener("touchend",this.listeners.onTouchEnd)}onImageLoaded(){""===this.imageElement.style.width&&(this.imageElement.style.width=this.imageElement.width+"px"),""===this.imageElement.style.height&&(this.imageElement.style.height=this.imageElement.height+"px"),this.calcBBoxNextFrame=!0}onMouseDown(t){"idle"===this.status&&"mouse"===t.pointerType&&0===t.button&&(this.mouseStart.set(t.clientX,t.clientY),this.emit(_.LABEL_DOWN,this,null,0),this.imageElement.ownerDocument.addEventListener("pointermove",this.listeners.onMouseMove),this.imageElement.ownerDocument.addEventListener("pointerup",this.listeners.onMouseUp),this.status="down")}onMouseMove(t){"down"===this.status&&"mouse"===t.pointerType&&0===t.button&&(this.status="move")}onMouseUp(t){"idle"!==this.status&&"mouse"===t.pointerType&&(this.mouseEnd.set(t.clientX,t.clientY),("down"===this.status||this.mouseStart.distanceToSquared(this.mouseEnd)<100)&&this.emit(_.ELEMENT_SELECTED,this,null,0),this.imageElement.ownerDocument.removeEventListener("pointermove",this.listeners.onMouseMove),this.imageElement.ownerDocument.removeEventListener("pointerup",this.listeners.onMouseUp),this.status="idle")}onTouchStart(t){"idle"!==this.status||t.touches.length>1||(this.mouseStart.set(t.touches[0].pageX,t.touches[0].pageY),this.emit(_.LABEL_DOWN,this,null,0),this.status="down")}onTouchMove(t){"down"!==this.status||t.touches.length>1||(this.status="move")}onTouchEnd(t){"idle"!==this.status&&(this.mouseEnd.set(t.changedTouches[0].pageX,t.changedTouches[0].pageY),("down"===this.status||this.mouseStart.distanceToSquared(this.mouseEnd)<100)&&this.emit(_.ELEMENT_SELECTED,this,null,0),this.status="idle")}setAttributes({labelAttrs:t,imageAttrs:e,textAttrs:n}){void 0!==t&&this.setLabelAttrs(t),void 0!==e&&this.setImageAttrs(e),void 0!==n&&this.setTextAttrs(n)}setLabelAttrs(t){void 0!==t.position&&this.setPosition(t.position),void 0!==t.visible&&this.setVisible(t.visible),void 0!==t.bBoxVisible&&this.setBBoxVisible(t.bBoxVisible),void 0!==t.bBoxBorderWidth&&this.setBBoxBorderWidth(t.bBoxBorderWidth),void 0!==t.bBoxBorderColor&&this.setBBoxBorderColor(t.bBoxBorderColor)}setPosition(t){this.position.copy(t),this.needUpdate=!0}setVisible(t){this.visible=t,this.cssObject.visible=t,this.needUpdate=!0}setBBoxVisible(t){this.boundingBox.style.display=t?"block":"none",t&&(this.calcBBoxNextFrame=!0)}setBBoxBorderWidth(t){this.boundingBox.style.borderWidth=t+"px"}setBBoxBorderColor(t){this.boundingBox.style.borderColor=t}setImageAttrs(t){void 0!==t.src&&this.setImageSource(t.src),void 0!==t.visible&&this.setImageVisible(t.visible),void 0!==t.size&&this.setImageSize(t.size.width,t.size.height),void 0!==t.anchor&&this.setImageAnchor(t.anchor),void 0!==t.offset&&this.setImageOffset(t.offset.x,t.offset.y)}setImageVisible(t){this.imageElement.style.display=t?"block":"none"}setImageSource(t){this.imageElement.src=t}setImageSize(t,e){this.imageElement.style.height=e+"px",this.imageElement.style.width=t+"px",this.calcBBoxNextFrame=!0}setImageAnchor(t){this.imagePositionInfo.anchor=t,this.updateImageTransform(),this.calcBBoxNextFrame=!0}setImageOffset(t,e){this.imagePositionInfo.offsetX=t,this.imagePositionInfo.offsetY=e,this.updateImageTransform(),this.calcBBoxNextFrame=!0}setTextAttrs(t){void 0!==t.content&&this.setTextContent(t.content),void 0!==t.visible&&this.setTextVisible(t.visible),void 0!==t.fontSize&&this.setTextFontSize(t.fontSize),void 0!==t.color&&this.setTextColor(t.color),void 0!==t.padding&&this.setTextPadding(t.padding),void 0!==t.anchor&&this.setTextAnchor(t.anchor),void 0!==t.offset&&this.setTextOffset(t.offset.x,t.offset.y),void 0!==t.align&&this.setTextAlign(t.align),void 0!==t.borderWidth&&this.setTextBorderWidth(t.borderWidth),void 0!==t.borderColor&&this.setTextBorderColor(t.borderColor),void 0!==t.borderRadius&&this.setTextBorderRadius(t.borderRadius),void 0!==t.backgroundColor&&this.setTextBackgroundColor(t.backgroundColor)}setTextVisible(t){this.textElement.style.display=t?"block":"none",this.calcBBoxNextFrame=!0}setTextContent(t){this.textElement.innerText=t,this.calcBBoxNextFrame=!0}setTextFontSize(t){this.textElement.style.fontSize=t+"px",this.calcBBoxNextFrame=!0}setTextColor(t){this.textElement.style.color=t}setTextPadding(t){const e={left:0,right:0,top:0,bottom:0};void 0!==t.left&&(e.left=t.left),void 0!==t.right&&(e.right=t.right),void 0!==t.top&&(e.top=t.top),void 0!==t.bottom&&(e.bottom=t.bottom);const{left:n,right:i,top:r,bottom:s}=e;this.textElement.style.padding=`${r}px ${i}px ${s}px ${n}px`,this.calcBBoxNextFrame=!0}setTextAnchor(t){this.textPositionInfo.anchor=t,this.updateTextTransform(),this.calcBBoxNextFrame=!0}setTextOffset(t,e){this.textPositionInfo.offsetX=t,this.textPositionInfo.offsetY=e,this.updateTextTransform(),this.calcBBoxNextFrame=!0}setTextBorderWidth(t){this.textElement.style.borderWidth=t+"px",this.calcBBoxNextFrame=!0}setTextAlign(t){this.textElement.style.textAlign=t}setTextBorderColor(t){this.textElement.style.borderColor=t}setTextBorderRadius(t){this.textElement.style.borderRadius=t+"px"}setTextBackgroundColor(t){this.textElement.style.backgroundColor=t}setLabelID(t){this.labelID=t}update(){const t=new Ht(this);return this.needCalcBBox&&this.calcBBox(),this.needCalcBBox=!1,this.calcBBoxNextFrame&&(this.needCalcBBox=!0),this.calcBBoxNextFrame=!1,this.initialzed&&(t.shouldPlaceElement=!0,this.initialzed=!1),this.needUpdate&&(t.needUpdate=!0,this.needUpdate=!1),t}dispose(){this.unregisterListeners(),this.domElement.removeChild(this.boundingBox),this.domElement.removeChild(this.textElement),this.domElement.removeChild(this.imageElement),super.dispose()}}am.ANCHOR_MAP={center:{x:"-50%",y:"-50%"},left:{x:"0",y:"-50%"},right:{x:"-100%",y:"-50%"},top:{x:"-50%",y:"0"},bottom:{x:"-50%",y:"-100%"},topleft:{x:"0",y:"0"},topright:{x:"-100%",y:"0"},bottomleft:{x:"0",y:"-100%"},bottomright:{x:"-100%",y:"-100%"}};class lm{constructor(t){const{THREE:e}=b.getInstance();this.count=0,this.playSet=new Set,this.playing=!1,this.listeners={onPlaying:()=>{this.playing=!0},onPaused:()=>{this.playing=!1}};const n=document.createElement("video");n.setAttribute("webkit-playsinline","true"),n.setAttribute("x5-playsinline","true"),n.setAttribute("playsinline","true"),n.setAttribute("crossOrigin","anonymous"),n.setAttribute("autoplay","false"),n.setAttribute("muted","true"),n.muted=!0,n.src=t,n.loop=!0,n.volume=0,n.addEventListener("playing",this.listeners.onPlaying),n.addEventListener("pause",this.listeners.onPaused),this.video=n,this.texture=new e.VideoTexture(this.video)}play(t){this.playSet.size<1&&this.video.play(),t&&this.playSet.add(t)}pause(t){t&&this.playSet.delete(t),0===this.playSet.size&&this.video.pause()}destroy(){this.texture&&this.texture.dispose(),this.video&&(this.video.removeEventListener("playing",this.listeners.onPlaying),this.video.removeEventListener("pause",this.listeners.onPaused),this.video.pause(),this.video.removeAttribute("src"),this.video.load())}}class hm extends Gt{constructor(t){super(),hm.Videos||(hm.Videos=new Map),this.initialized=!1,this.up.set(0,0,1),this.visible=!1,this.videoVisible=!1,t&&this.setVideoSrc(t)}static RemoveVideo(t){if(!hm.Videos.has(t))return;const e=hm.Videos.get(t);e.count-1==0?(e.destroy(),hm.Videos.delete(t)):(e.count-=1,hm.Videos.set(t,e))}static AddVideo(t){if(!hm.Videos.has(t)){const e=new lm(t);hm.Videos.set(t,e)}const e=hm.Videos.get(t);return e.count+=1,e}createVideoPlane(){const{THREE:t}=b.getInstance(),e=new t.PlaneBufferGeometry(1.6,.9),n=new t.MeshBasicMaterial({map:this.video.texture,side:t.DoubleSide,transparent:!1,depthTest:!1,depthWrite:!1});this.videoPlane=new t.Mesh(e,n),this.add(this.videoPlane),this.initialized=!0,this.videoVisible=!0}setVideoSrc(t){const e=hm.AddVideo(t);this.video&&(this.videoPlane.material.map=null,hm.RemoveVideo(this.video.video.src)),this.video=e,this.videoPlane&&this.videoPlane.material&&(this.videoPlane.material.map=this.video.texture),this.videoPlane||this.createVideoPlane()}setVideoVisible(t){this.videoVisible=t}setVideoSize(t,e){if(!this.videoPlane)return;const{THREE:n}=b.getInstance(),{geometry:i}=this.videoPlane,r=new n.PlaneBufferGeometry(t,e);this.videoPlane.geometry=r,i.dispose()}play(t){this.video&&(this.video.play(t),this.videoPlane.renderOrder=150)}stop(t){this.video&&(this.video.pause(t),this.videoPlane.renderOrder=1)}update(){const t=new Ht(this);return this.initialized&&!this.parent&&(t.shouldPlaceElement=!0,t.needUpdate=!0),this.visible=this.videoVisible&&this.video&&this.video.playing,this.visible&&(t.needUpdate=!0),t}dispose(){this.video&&hm.RemoveVideo(this.video.video.src),super.dispose(),Fn.dispose(this,!0)}}class cm extends D{constructor(){super(),this.pathMap=new Map,this.renderThisFrame=!0,cm.instanceId=0}init(t){const{THREE:e}=b.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,cm.instanceId++,e.strokeWidth&&e.strokeColor){const n=new fo(t,{...e,strokeWidth:0,width:e.width+2*e.strokeWidth,color:e.strokeColor,renderPixelLine:!0}),r="border_"+cm.instanceId;n.name=r,i.add(n),this.scene.add(n)}const r=new fo(t,{...e,strokeWidth:0,renderPixelLine:!0}),s=cm.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()}}var um,dm,pm,fm,mm=function(t,e){for(var n=new Eu,i=0,r=e.length;i<r;i++)n.add(new Kl(t,e[i]));return n};!function(t){t[t.IDLE=0]="IDLE",t[t.DOWN=1]="DOWN",t[t.MOVE=2]="MOVE"}(um||(um={}));class gm extends D{constructor(e){if(super(),this.needRender=!1,A.GetEnv()===t.Env.Miniapp){if(!e)throw Error("poi-overlay need a offscreenCanvas");gm.canvas=e}else gm.canvas||(gm.canvas=document.createElement("canvas"));const n=A.GetGlobalDPR();gm.canvas.width=500*n,gm.canvas.height=500*n,gm.ctx=gm.canvas.getContext("2d")}init(t){const{THREE:n}=b.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=Fn.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=um.IDLE,this.mousePositionBuffer=new n.Vector2,this.parent.on(E.MOUSE_DOWN,this.listeners.pointerDown),this.parent.on(E.MOUSE_UP,this.listeners.pointerUp),this.parent.on(E.TOUCH_START,this.listeners.touchStart),this.parent.on(E.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}=b.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}=b.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,x=(1-v.y)/2*g;v.set(y,x,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(E.MOUSE_DOWN,this.listeners.pointerDown),this.parent.off(E.MOUSE_UP,this.listeners.pointerUp),this.parent.off(E.TOUCH_START,this.listeners.touchStart),this.parent.off(E.TOUCH_END,this.listeners.touchEnd),this.clearPoi(),gm.canvas&&(gm.canvas.remove(),gm.canvas=null),gm.ctx&&(gm.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}=b.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(_.POI_UP,this.eventTarget,t.button),this.mouseState===um.DOWN&&l<100&&this.emit(_.POI_CLICKED,this.eventTarget,t.button),this.mouseState=um.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}=b.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(_.POI_UP,this.eventTarget,0),this.mouseState===um.DOWN&&l<100&&this.emit(_.POI_CLICKED,this.eventTarget,0),this.mouseState=um.IDLE}onNodePointerDown(t,e,n,i=0){this.mouseState===um.IDLE&&(this.mouseState=um.DOWN,this.mousePositionBuffer.set(e,n),this.eventTarget=t,this.emit(_.POI_DOWN,t,i))}createPoi(t){const e=new vm;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()}}gm.canvas=document.createElement("canvas"),gm.ctx=gm.canvas.getContext("2d");class vm{constructor(t){this._renderThisFrame=!1;const{THREE:n}=b.getInstance();this.dpr=A.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&&Fn.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 x.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(vm.ImageMaterialMap.has(t))if("dealing"===vm.ImageMaterialMap.get(t))this.renderThisFrame=!0;else{this.icon&&this.group.remove(this.icon),this.iconMaterial=vm.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=mm(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{vm.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,vm.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;gm.ctx.font=n*t+"px sans-serif",gm.ctx.fillStyle="black";const s=gm.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),gm.ctx.clearRect(0,0,o,a),gm.ctx.fillText(r,i*t,(n+i)*t);const l=gm.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}}vm.ImageMaterialMap=new Map,vm.ImageMaterialMap=new Map;class ym{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"}(dm||(dm={}));!function(t){t[t.IDLE=0]="IDLE",t[t.DOWN=1]="DOWN",t[t.MOVE=2]="MOVE"}(pm||(pm={}));class xm extends D{constructor(e){if(super(),this.needRender=!1,A.GetEnv()===t.Env.Miniapp){if(!e)throw Error("poi-overlay need a offscreenCanvas");xm.canvas=e}else xm.canvas||(xm.canvas=document.createElement("canvas"));const n=A.GetGlobalDPR();xm.canvas.width=500*n,xm.canvas.height=500*n,xm.ctx=xm.canvas.getContext("2d")}init(t){const{THREE:n}=b.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=Fn.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=pm.IDLE,this.mousePositionBuffer=new n.Vector2,this.parent.on(E.MOUSE_DOWN,this.listeners.pointerDown),this.parent.on(E.MOUSE_UP,this.listeners.pointerUp),this.parent.on(E.TOUCH_START,this.listeners.touchStart),this.parent.on(E.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}=b.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}=b.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,x=(1-v.y)/2*g;v.set(y,x,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(E.MOUSE_DOWN,this.listeners.pointerDown),this.parent.off(E.MOUSE_UP,this.listeners.pointerUp),this.parent.off(E.TOUCH_START,this.listeners.touchStart),this.parent.off(E.TOUCH_END,this.listeners.touchEnd),this.clearPoi(),xm.canvas&&(xm.canvas.remove(),xm.canvas=null),xm.ctx&&(xm.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}=b.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(_.POI_UP,this.eventTarget,t.button),this.mouseState===pm.DOWN&&l<100&&this.emit(_.POI_CLICKED,this.eventTarget,t.button),this.mouseState=pm.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}=b.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(_.POI_UP,this.eventTarget,0),this.mouseState===pm.DOWN&&l<100&&this.emit(_.POI_CLICKED,this.eventTarget,0),this.mouseState=pm.IDLE}onNodePointerDown(t,e,n,i=0){this.mouseState===pm.IDLE&&(this.mouseState=pm.DOWN,this.mousePositionBuffer.set(e,n),this.eventTarget=t,this.emit(_.POI_DOWN,t,i))}createPoi(t){const e=new bm;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 bm{constructor(t){this._renderThisFrame=!1;const{THREE:n}=b.getInstance();this.dpr=A.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&&Fn.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 x.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(bm.ImageMaterialMap.has(t))if("dealing"===bm.ImageMaterialMap.get(t))this.renderThisFrame=!0;else{this.icon&&this.group.remove(this.icon),this.iconMaterial=bm.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=mm(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{bm.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,bm.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;xm.ctx.font=n*t+"px sans-serif",xm.ctx.fillStyle="black";const s=xm.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),xm.ctx.clearRect(0,0,o,a),xm.ctx.fillText(r,i*t,(n+i)*t);const l=xm.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}}bm.ImageMaterialMap=new Map,bm.ImageMaterialMap=new Map;class wm extends M{constructor(){super(),R.GetSharedInstance().registerController(this)}unbind(){this.dispose()}dispose(){this.eventMap.clear(),R.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"}(fm||(fm={}));class Mm extends e.InstancedBufferGeometry{constructor(){super();const{THREE:t}=b.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}=b.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}=b.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}=b.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 _m(){const{THREE:t}=b.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 Em extends e.ShaderMaterial{constructor(t){super((()=>{const{THREE:t}=b.getInstance(),e=function(){const{THREE:t}=b.getInstance();return{uniforms:t.UniformsUtils.merge([t.UniformsLib.common,t.UniformsLib.fog,_m()]),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 Tm extends e.Mesh{constructor(t,e){super(t||new Mm,e||new Em({color:16777215*Math.random()})),this.isLineSegments2=!0;const{THREE:n}=b.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.THREE=e,t.Konva=n,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}=b.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 x=u.projectionMatrix.clone().multiply(m).multiply(u.matrixWorldInverse),w=x.clone().invert(),M=v.clone().multiply(x),_=M.clone().invert(),E=u.matrixWorld.elements.slice();return{upTransOrigin:w.elements.slice(),downTransOrigin:x.elements.slice(),upTrans:_.elements.slice(),downTrans:M.elements.slice(),matrixWorld:E}}},t.Area=Bn,t.BVHNode=Hi,t.BVHTree=Gi,t.BasicCalcTool=io,t.BasicController=class extends wm{constructor(t){super();const{THREE:e}=b.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=fm.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(E.MOUSE_DOWN,this.eventListeners.onMouseDown),this.bindingView.on(E.MOUSE_MOVE,this.eventListeners.onMouseMove),this.bindingView.on(E.MOUSE_UP,this.eventListeners.onMouseUp),this.bindingView.on(E.MOUSE_WHEEL,this.eventListeners.onMouseWheel),this.bindingView.on(E.TOUCH_START,this.eventListeners.onTouchStart),this.bindingView.on(E.TOUCH_MOVE,this.eventListeners.onTouchMove),this.bindingView.on(E.TOUCH_END,this.eventListeners.onTouchEnd),this.bindingView.on(E.CONTEXT_MENU,this.eventListeners.onContextMenu))}unregisterEvents(){this.bindingView&&(this.bindingView.off(E.MOUSE_DOWN,this.eventListeners.onMouseDown),this.bindingView.off(E.MOUSE_MOVE,this.eventListeners.onMouseMove),this.bindingView.off(E.MOUSE_UP,this.eventListeners.onMouseUp),this.bindingView.off(E.MOUSE_WHEEL,this.eventListeners.onMouseWheel),this.bindingView.off(E.TOUCH_START,this.eventListeners.onTouchStart),this.bindingView.off(E.TOUCH_MOVE,this.eventListeners.onTouchMove),this.bindingView.off(E.TOUCH_END,this.eventListeners.onTouchEnd),this.bindingView.off(E.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=fm.ROTATE);break;case e.MOUSE.PAN:this.enablePan&&(this.state=fm.PAN);break;case e.MOUSE.DOLLY:this.enableZoom&&(this.state=fm.DOLLY);break;default:this.state=fm.IDLE}switch(this.state){case fm.ROTATE:this.handleMouseDownRotate(t);break;case fm.PAN:this.handleMouseDownPan(t);break;case fm.DOLLY:this.handleMouseDownDolly(t)}this.state!==fm.IDLE&&(this.bindingView&&(this.bindingView.on(E.MOUSE_MOVE,this.eventListeners.onMouseMove),this.bindingView.on(E.MOUSE_UP,this.eventListeners.onMouseUp)),this.panInertiaBase=0,this.rotateInertiaBase=0,this.zoomInertiaBase=0)}onMouseMove(t){switch(t.preventDefault(),this.state){case fm.ROTATE:this.handleMouseMoveSelfRotate(t);break;case fm.PAN:this.handleMouseMovePan(t);break;case fm.DOLLY:this.handleMouseMoveDolly(t)}}onMouseUp(t){switch(t.preventDefault(),this.bindingView&&(this.bindingView.off(E.MOUSE_MOVE,this.eventListeners.onMouseMove),this.bindingView.off(E.MOUSE_UP,this.eventListeners.onMouseUp)),this.state){case fm.ROTATE:this.handleUpRotate();break;case fm.PAN:this.handleUpPan()}this.state=fm.IDLE}onMouseWheel(t){!this.enableZoom||this.state!==fm.IDLE&&this.state!==fm.ROTATE||(t.preventDefault(),t.stopPropagation(),this.handleMouseWheel(t))}onContextMenu(t){t.preventDefault()}onTouchStart(n){switch(A.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=fm.TOUCH_PAN);break;case e.TOUCH.ROTATE:this.enableRotate&&(this.state=fm.TOUCH_ROTATE);break;default:this.state=fm.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=fm.TOUCH_DOLLY_PAN;break;case e.TOUCH.DOLLY_ROTATE:this.state=fm.TOUCH_DOLLY_ROTATE;break;case"map":this.state=fm.TOUCH_MAP;break;default:this.state=fm.IDLE}break;default:this.state=fm.IDLE}switch(this.state){case fm.TOUCH_PAN:this.handleTouchStartPan(n);break;case fm.TOUCH_ROTATE:this.handleTouchStartRotate(n);break;case fm.TOUCH_DOLLY_ROTATE:this.handleTouchStartDollyRotate(n);break;case fm.TOUCH_DOLLY_PAN:this.handleTouchStartDollyPan(n);break;case fm.TOUCH_MAP:this.handleTouchStartMap(n)}this.state!==fm.IDLE&&(this.bindingView&&(this.bindingView.on(E.MOUSE_MOVE,this.eventListeners.onMouseMove),this.bindingView.on(E.MOUSE_UP,this.eventListeners.onMouseUp)),this.panInertiaBase=0,this.rotateInertiaBase=0,this.zoomInertiaBase=0)}onTouchMove(e){switch(A.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 fm.TOUCH_PAN:this.handleTouchMovePan(e);break;case fm.TOUCH_ROTATE:this.handleTouchMoveSelfRotate(e);break;case fm.TOUCH_DOLLY_ROTATE:this.handleTouchMoveDollyRotate(e);break;case fm.TOUCH_DOLLY_PAN:this.handleTouchMoveDollyPan(e);break;case fm.TOUCH_MAP:this.handleTouchMoveAll(e)}this.timeEnd=this.timeStart,this.timeStart=e.timeStamp}onTouchEnd(e){switch(A.GetEnv()!==t.Env.Miniapp&&e.preventDefault(),this.state){case fm.TOUCH_ROTATE:case fm.TOUCH_DOLLY_ROTATE:this.handleUpRotate();break;case fm.TOUCH_PAN:case fm.TOUCH_DOLLY_PAN:this.handleUpPan();break;case fm.TOUCH_MAP:this.handleUpAll()}this.state=fm.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===fm.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===fm.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===fm.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}=b.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=Fn.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(_.CAMERA_ZOOM,this.zoomMode,"zoom"===this.zoomMode?this.camera.zoom:this.camera.fov,this),this.followMouse&&e&&this.bindingView){const t=Fn.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)*A.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*=A.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}=b.getInstance(),s=this.camera.position.clone(),o=new r.Vector3,a=n||{};new x.Tween({progress:0}).to({progress:1},e).easing(x.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}=b.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}=b.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}=b.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}=b.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}=b.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}=b.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(_.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=Fn,t.Block=Ji,t.BlockSet=class extends Gt{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 Ji(t,this.lowPerformance,this.tag,n);this.blocks.push(e),this.add(e)}),this.loaded=!0}update(){const t=new Ht(this);return!this.initialized&&this.loaded&&(this.initialized=!0,t.needUpdate=!0),this.initialized&&!this.parent&&(t.shouldPlaceElement=!0,this.emit(_.ELEMENT_LOADED,this)),t}dispose(){super.dispose(),this.blocks.forEach(t=>{this.remove(t),t.dispose()}),Fn.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 Gt{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 Ht(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 D{init(t,e=t.container){this.container=e,this.parent=t;const{clientWidth:n,clientHeight:i}=this.container;this.renderer=new Qi,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}},t.Camera=class extends Gt{constructor(t=0,e=-10,n=20){super();const{THREE:i}=b.getInstance();this.initialized=!1,this.camera=new i.PerspectiveCamera,this.lookAtPoint=new i.Vector3,this.helpers=new i.Group,this.intrinsic={resolution:new i.Vector2(2560,1440),fov:new i.Vector2(48.1,28.2),f:new i.Vector2(2782.6289319729026,2775.8932388798476),c:new i.Vector2(1300.277002974277,729.803882570099)},this.intersectables=[],this.renderOrder=250,this.load(t,e,n),Object.defineProperty(this,"position",{value:new _o(this.position.x,this.position.y,this.position.z,()=>{this.updateLookAtThisFrame=!0}),enumerable:!0,configurable:!0}),this.rotation._onChange(()=>{this.onRotationChange()}),this.quaternion._onChange(()=>{this.onQuaternionChange()}),this.eventListeners={onCameraSelected:t=>{this.cameraHelper.visible=t===this,this.updateLookAtThisFrame=!0}},w.on(E.ELEMENT_SELECTED,this.eventListeners.onCameraSelected)}load(t=0,e=-10,n=20){if(this.yaw=t,this.pitch=e,this.visibleScope=n,this.camera.fov=this.intrinsic.fov.y,this.camera.aspect=this.intrinsic.fov.x/this.intrinsic.fov.y,this.camera.near=.1,this.camera.far=200,this.camera.up.set(0,0,1),this.up.set(0,0,1),this.helpers){const{children:t}=this.helpers;this.helpers.remove(...t),t.forEach(t=>{Fn.dispose(t,!0)}),this.intersectables=[]}const{THREE:i}=b.getInstance();this.cameraHelper=new Eo(this.camera);const r=new i.Mesh(new i.BoxGeometry(.2,.2,.2),new i.MeshLambertMaterial({color:255,emissive:468276,depthWrite:!0,depthTest:!0}));this.helpers.add(r),this.add(this.camera),this.add(this.helpers),this.add(this.cameraHelper),this.camera.renderOrder=250,this.helpers.renderOrder=250,this.cameraHelper.renderOrder=250,this.camera.far=this.visibleScope,this.camera.updateProjectionMatrix(),this.cameraHelper.update(),this.camera.far=200,this.camera.updateProjectionMatrix(),this.cameraHelper.visible=!1,this.intersectables.push(r),this.initialized=!0,this.updateLookAtThisFrame=!0}dispose(){super.dispose(),this.remove(this.camera),this.remove(this.helpers),this.remove(this.cameraHelper),Fn.dispose(this.helpers,!0),Fn.dispose(this.cameraHelper,!0),w.off(E.ELEMENT_SELECTED,this.eventListeners.onCameraSelected)}updatePitchYawFromLookVector(t){const{yaw:e,pitch:n}=Mo.getYawPitchFromCameraLookVector(t);this.pitch=n,this.yaw=e}onRotationChange(){const t=this.rotation.clone(),{THREE:e}=b.getInstance();this.rotation.setFromQuaternion(new e.Quaternion(0,0,0,1),void 0,!1),this.camera.rotation.copy(t),this.helpers.rotation.copy(t),this.camera.updateProjectionMatrix();const n=this.camera.getWorldDirection(new e.Vector3(0,0,-1));this.updatePitchYawFromLookVector(n),this.updateLookAtThisFrame=!0}onQuaternionChange(){const t=this.quaternion.clone(),{THREE:e}=b.getInstance();this.quaternion.setFromEuler(new e.Euler(0,0,0),!1),this.camera.quaternion.copy(t),this.helpers.quaternion.copy(t),this.camera.updateProjectionMatrix();const n=this.camera.getWorldDirection(new e.Vector3(0,0,-1));this.updatePitchYawFromLookVector(n),this.updateLookAtThisFrame=!0}update(){const t=new Ht(this);return this.initialized&&!this.parent&&(t.shouldPlaceElement=!0,t.needUpdate=!0),this.updateLookAtThisFrame&&(this.lookAtPoint=Mo.getCameraLookAtPositionByYawPitch(this.position.clone(),this.yaw,this.pitch).position,this.lookAt(this.lookAtPoint,0,0,!1),t.needUpdate=!0,this.updateLookAtThisFrame=!1),t}getThreeCamera(){return this.camera}getIntrinsic(){return this.intrinsic}getYaw(){return this.yaw}getPitch(){return this.pitch}getFov(){return this.camera.fov}getAspect(){return this.camera.aspect}getQuaternion(){return this.camera.quaternion.clone()}setYaw(t){this.yaw=t,this.updateLookAtThisFrame=!0}setPitch(t){this.pitch=t,this.updateLookAtThisFrame=!0}setCameraHelperVisible(t,e){this.cameraHelper.visible=t,this.updateLookAtThisFrame=!!e}lookAt(t,e,n,i=!0){const{THREE:r}=b.getInstance();if(i){let i;i=t instanceof r.Vector3?this.position.clone().add(t.clone().multiplyScalar(-1)).normalize():this.position.clone().add(new r.Vector3(t,e,n).multiplyScalar(-1)).normalize(),this.updatePitchYawFromLookVector(i)}this.helpers.lookAt(t,e,n),this.camera.lookAt(t,e,n),this.camera.updateProjectionMatrix(),this.cameraHelper&&(this.camera.far=this.visibleScope,this.camera.updateProjectionMatrix(),this.cameraHelper.update(),this.camera.far=200,this.camera.updateProjectionMatrix())}updateLookAt(){this.updateLookAtThisFrame=!0}get quaternion(){return this.camera.quaternion.clone()}getViewingFrustumMesh(){this.updateLookAt(),this.update(),this.camera.far=this.visibleScope,this.camera.updateProjectionMatrix(),this.cameraHelper.update();const t=this.camera,e=this.position.clone(),{THREE:n}=b.getInstance(),i=new n.Vector3(0,0,-1).multiplyScalar(this.visibleScope).applyMatrix4(t.matrixWorld),r=new n.Vector3(0,0,1),s=t.fov,o=t.aspect,{near:a,far:l}=t,h=Ln.FrustumMesh(e,i,r,s,o,a,l);return this.camera.far=200,this.camera.updateProjectionMatrix(),h}},t.CanvasOverlay=class extends D{init(t,e=new HTMLElement){const{THREE:n}=b.getInstance();this.container=e,this.parent=t,this.owlly2D=S.getInstance(e),this.layer=this.owlly2D.addLayer(),this.shapes=[],this.renderThisFrame=!0,this.layer.zIndex(0),this.enabled=!0,this.mouseState=dm.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}=b.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(_.CANVAS_VERTEX_UP,this.eventTarget,t.button),this.mouseState===dm.DOWN&&l<100&&this.emit(_.CANVAS_VERTEX_CLICKED,this.eventTarget,t.button),this.mouseState=dm.IDLE}onTouchStart(t){this.owlly2D.stage._touchstart(t)}onTouchEnd(t){const{THREE:e}=b.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(_.CANVAS_VERTEX_UP,this.eventTarget,0),this.mouseState===dm.DOWN&&l<100&&this.emit(_.CANVAS_VERTEX_CLICKED,this.eventTarget,0),this.mouseState=dm.IDLE}onNodePointerDown(t){if(this.mouseState!==dm.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=dm.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(_.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}=b.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}=b.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}=b.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*_,T=(1-M.y)*r*_,S="joints"===l||"endpoints"===l&&(0===e||e===a.length-1);if(e<s.length){const t=s[e];t.x(E),t.y(T),t.visible(S&&y&&f.visible()),t.setAttrs(o)}else{const t=new c.Circle({radius:0,x:E,y:T,stroke:"transparent",strokeWidth:0});t.visible(S&&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},${T}`}).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 ym(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}=b.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=wm,t.CubeFaceConfig=co,t.DOMLabel2D=am,t.DeviceUtils=no,t.Element=Gt,t.ElementFrameContext=Ht,t.EnvironmentUtils=A,t.EventHub=w,t.EventHubClassic=M,t.Events=_,t.Externals=b,t.FloorModel=Wi,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=Vi,t.GLTFMeshElement=class extends Gt{constructor(t,e,n){super(),this.reloadTimes=1;const{THREE:i}=b.getInstance();this.options=e||{},this.meshes=[],this.meshMaterials=[],this.group=new i.Group,this.add(this.group),t&&this.load(t,0,n),this.initialized=!1,this.loaded=!1}load(t,e=0,n){this.initialized=!1,this.loaded=!1;const i=new sm;n&&i.setMeshoptDecoder(n);const{THREE:r}=b.getInstance();i.load(t,t=>{this.add(t.scene),this.group.add(t.scene),this.loaded=!0,this.initialized=!0,this.needUpdate=!0,t.scene.traverse(t=>{t instanceof r.Mesh&&(this.meshes.push(t),this.meshMaterials.push(t.material))}),this.setOptions(this.options),this.emit(_.ELEMENT_LOADED,this)},void 0,i=>{const r=e+1;r>this.reloadTimes?this.emit(_.ELEMENT_LOADED_ERROR,this,i):this.load(t,r,n)})}setOptions(t){const{THREE:e}=b.getInstance();this.meshes.forEach(e=>{t.renderOrder&&(e.renderOrder=t.renderOrder)}),this.meshMaterials.forEach(n=>{n.depthTest=!!t.depthTest,n.transparent=!!t.transparent,t.fillColor&&(n.color=new e.Color(t.fillColor))}),this.options={...t,...this.options}}setSacle(t){this.meshes.forEach(e=>{e.geometry.scale(t,t,t)}),this.needUpdate=!0}setOnCurrentViewChanged(t){this.eventListeners={onCurrentViewChanged:t}}update(){const t=new Ht(this);return!this.initialized&&this.loaded&&(this.initialized=!0,t.needUpdate=!0),this.initialized&&!this.parent&&(t.shouldPlaceElement=!0),t}dispose(){super.dispose(),Fn.dispose(this,!0)}},t.GeometryUtils=Ln,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=lo,t.LineGeometry=class extends Mm{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=Em,t.LineSegments2=Tm,t.MapUtils=Nn,t.MeshElement=class extends Gt{constructor(t,e,n){super();const{THREE:i}=b.getInstance(),r=n||{};this.group=new i.Group,this.add(this.group);const s=r.material||new i.MeshBasicMaterial({color:r.fillColor?r.fillColor:65280,transparent:void 0!==r.transparent&&r.transparent,opacity:void 0!==r.opacity?r.opacity:1,side:i.DoubleSide,depthWrite:!0}),o=[];t.forEach(t=>{o.push(t.x,t.y,t.z)});const a=new Float32Array(o),l=new i.BufferGeometry;l.setAttribute("position",new i.BufferAttribute(a,3)),l.setIndex(e);const h=new i.Mesh(l,s);h.renderOrder=1e3,this.group.add(h),this.initialized=!1,this.loaded=!0}setOnCurrentViewChanged(t){this.eventListeners={onCurrentViewChanged:t}}update(){const t=new Ht(this);return!this.initialized&&this.loaded&&(this.initialized=!0,t.needUpdate=!0),this.initialized&&!this.parent&&(t.shouldPlaceElement=!0),t}dispose(){super.dispose(),Fn.dispose(this,!0)}},t.MeshLine2D=fo,t.OrthographicView=class extends I{createCamera(){if(this.camera)return;const{THREE:t}=b.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}=b.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.Overlay=D,t.OwllyEvents=E,t.Panorama=yo,t.PanoramaGroup=bo,t.Path=To,t.PathGroup=class extends Gt{constructor(t,e){super(),this.pathInitialized=!1,this.pathReloaded=!1,this.paths=[];const n=e||{};this.floorModel=n.floorModel,this.groundParams=n.groundParams,t&&this.load(t,e),this.floorModel&&this.floorModel.isModelLoaded()&&(this.pathReloaded=!0),this.eventListeners={onFloorModelLoaded:t=>{t===this.floorModel&&(this.pathReloaded=!0)}},w.on(E.ELEMENT_LOADED,this.eventListeners.onFloorModelLoaded)}load(t,e){this.pathReloaded=!1,this.paths&&this.paths.length&&(this.paths.forEach(t=>{this.remove(t),t.dispose()}),this.emit(E.DISPOSE_ELEMENT,this.paths));const n=e||{};n.groundParams&&(this.groundParams=n.groundParams),n.floorModel&&(this.floorModel=n.floorModel),this.paths=t.map(t=>{const n=new To(t,e);return this.add(n),n}),this.pathReloaded=!0}updatePathZ(t){const{pathMesh:e,arrowMeshes:n}=t,{THREE:i}=b.getInstance(),r=e.geometry;if(!r)return;const{array:s,count:o}=r.attributes.position;for(let t=0,e=0;t<o;t+=1,e+=3){const t=s[e],n=s[e+1];let r=.5;if(this.groundParams){const e=Wi.intersectWithGroundPlane(new i.Vector3(t,n,r),this.groundParams);e&&(r=e.z+Xi.PathMeshOffsetZ)}else if(this.floorModel){const e=this.floorModel.intersectGround(new i.Vector3(t,n,r));e&&(r=e.z+Xi.PathMeshOffsetZ)}s[e+2]=r}r.attributes.position.needsUpdate=!0,n.forEach(t=>{const{position:e}=t;if(this.groundParams){const n=Wi.intersectWithGroundPlane(e,this.groundParams);n&&(n.z+=Xi.ArrowMeshOffsetZ,t.position.copy(n))}else if(this.floorModel){const n=this.floorModel.intersectGround(e);n&&(n.z+=Xi.ArrowMeshOffsetZ,t.position.copy(n))}})}updatePathsZ(){this.paths.forEach(t=>{this.updatePathZ(t)})}setPathSettings(t,e,n){this.paths.forEach(i=>{i.setPathSettings(t,e,n)}),this.dynamicPathEnabled=n}update(){const t=new Ht(this);return!this.pathInitialized&&this.pathReloaded&&(this.pathInitialized=!0),this.pathReloaded&&(this.updatePathsZ(),t.needUpdate=!0,this.pathReloaded=!1),this.dynamicPathEnabled&&this.paths.forEach(t=>{t.update()}),this.pathInitialized&&!this.parent&&(t.shouldPlaceElement=!0),t}dispose(){super.dispose(),this.paths.forEach(t=>{this.remove(t),t.dispose()}),this.paths=[],w.off(E.ELEMENT_LOADED,this.eventListeners.onFloorModelLoaded)}}
54
+ /**
55
+ * @license
56
+ * Copyright 2010-2021 Three.js Authors
57
+ * SPDX-License-Identifier: MIT
58
+ */,t.PathOverlay2=cm,t.PathUtils=Xi,t.PerspectiveView=class extends I{createCamera(){if(this.camera)return;const{THREE:t}=b.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}=b.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 Gt{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}=b.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 $i(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})}},w.on(_.MOVE_TO_PANORAMA,this.eventListeners.onMoveToPanorama),w.on(E.ELEMENT_POSITION_UPDATED,this.eventListeners.onPositionChanged),e&&this.load(e)}async load(t){this.initialized=!1;const e=t.search(/\.gif$/),{THREE:n}=b.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=ir.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(_.ELEMENT_LOADED,this)}}})},e.send()}else(new n.TextureLoader).load(t,t=>{this.uniforms.map.value=t,this.needUpdate=!0,this.emit(_.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 Ht(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(),w.off(_.MOVE_TO_PANORAMA,this.eventListeners.onMoveToPanorama),w.off(E.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}=b.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=vm,t.Poi3D=bm,t.Poi3DOverlay=xm,t.PoiOverlay=gm,t.PolygonMesh=class extends Gt{constructor(e,n,i){super();const{THREE:r}=b.getInstance();this.shape=e,this.zShape=n,this.group=new r.Group,this.add(this.group);const s=e.getData(),o=(i||{}).material||new r.MeshBasicMaterial({color:e.getData().fill||16776960,transparent:1!==s.opacity,opacity:s.opacity||1,side:r.DoubleSide,depthWrite:!1});this.vertices=[];const a=[],l=[],h=e.getSteps(),c=n.getSteps();h.forEach((e,n)=>{n>0&&e.command===t.PathCommand.MOVE&&l.push(n);const i=e.coords[0],r=c[n].coords[0];this.vertices.push(i[0],i[1],r[0]),a.push(...i)});const u=e.getShapeType();if("shape"===u){const t=new Float32Array(this.vertices),e=new r.BufferGeometry;e.setAttribute("position",new r.BufferAttribute(t,3));const n=me(a,l,2);e.setIndex(n);const i=new r.Mesh(e,o);i.renderOrder=s.zIndex||1e3,this.group.add(i)}else if("line"===u){const t=a.length/2;h.forEach((t,e)=>{const n=t.coords[0],i=c[e].coords[0];this.vertices.push(n[0],n[1],i[1])});const e=new Float32Array(this.vertices);let n;n=l?l.concat([t]):[t];let i=0;n.forEach(n=>{const a=new r.BufferGeometry;a.setAttribute("position",new r.BufferAttribute(e,3));const l=[];for(let e=i;e<n-1;e+=1)l.push(e,e+t,e+1,e+1,e+t,e+t+1);i=n,a.setIndex(l);const h=new r.Mesh(a,o);h.renderOrder=s.zIndex||1e3,this.group.add(h)})}void 0!==s.x&&void 0!==s.y&&this.group.position.set(s.x,s.y,s.height||0),void 0!==s.rotation&&this.group.quaternion.set(...s.rotation),void 0!==s.scale&&this.group.scale.set(...s.scale),this.initialized=!1,this.loaded=!0,this.verticesInvalidated=!1}updateGeometries(){const{THREE:t}=b.getInstance(),e=new Float32Array(this.vertices);this.group.children.forEach(n=>{n.geometry.setAttribute("position",new t.BufferAttribute(e,3))})}updateMaterials(t){this.group.children.forEach(e=>{e.material=t})}applyShapes(t,e){const{THREE:n}=b.getInstance();t&&(this.shape=t),e&&(this.zShape=e),this.vertices=[];const i=this.shape.getSteps(),r=this.zShape.getSteps();i.forEach((t,e)=>{const n=t.coords[0],i=r[e].coords[0];this.vertices.push(n[0],n[1],i[0])}),"line"===this.shape.getShapeType()&&i.forEach((t,e)=>{const n=t.coords[0],i=r[e].coords[0];this.vertices.push(n[0],n[1],i[1])}),this.updateGeometries();const s=new n.MeshBasicMaterial({color:this.shape.getData().fill||16776960,transparent:1!==this.shape.getData().opacity,opacity:this.shape.getData().opacity||1,side:n.DoubleSide,depthWrite:!1});this.updateMaterials(s)}setColor(t,e){const{THREE:n}=b.getInstance(),i=new n.MeshBasicMaterial({color:t,transparent:1!==e,opacity:e||this.shape.getData().opacity,side:n.DoubleSide,depthWrite:!1});this.updateMaterials(i)}applyVertices(){const t=this.shape.getSteps(),e=this.zShape.getSteps();let n=0;if("line"===this.shape.getShapeType()){for(let i=0;i<this.vertices.length/2;i+=3){const r=t[n].coords[0];r[0]=this.vertices[i],r[1]=this.vertices[i+1];e[n].coords[0][0]=this.vertices[i+2],n+=1}n=0;for(let i=this.vertices.length/2;i<this.vertices.length;i+=3){const r=t[n].coords[0];r[0]=this.vertices[i],r[1]=this.vertices[i+1];e[n].coords[0][1]=this.vertices[i+2],n+=1}}else for(let t=0;t<this.vertices.length;t+=3){e[n].coords[0][0]=this.vertices[t+2],n+=1}this.updateGeometries(),this.verticesInvalidated=!1}setVertex(t,e){if(t<0||t>=this.vertices.length/3)return!1;this.group.updateMatrixWorld();const n=this.group.matrixWorld.clone().invert(),i=e.clone().applyMatrix4(n);return this.vertices[3*t]=i.x,this.vertices[3*t+1]=i.y,this.vertices[3*t+2]=i.z,this.verticesInvalidated=!0,!0}getVertexMap(){const{THREE:t}=b.getInstance();this.group.updateMatrixWorld();const e=this.group.matrixWorld,n=new Map;for(let i=this.vertices.length/3-1;i>=0;--i){const r=new t.Vector3(this.vertices[3*i],this.vertices[3*i+1],this.vertices[3*i+2]);n.set(i,r.applyMatrix4(e))}return n}getShape(){return this.shape}getZShape(){return this.zShape}update(){const t=new Ht(this);return!this.initialized&&this.loaded?(this.initialized=!0,t.needUpdate=!0):this.verticesInvalidated&&(this.applyVertices(),t.needUpdate=!0),this.initialized&&!this.parent&&(t.shouldPlaceElement=!0),t}dispose(){super.dispose(),Fn.dispose(this,!0)}},t.RingElement=class extends Gt{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 Ht(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 M{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),R.GetSharedInstance().registerScreen(this)}createRenderer(e,n={}){const{THREE:i}=b.getInstance(),r=this.getRenderParams(e,n);if(this.renderer=i.WebGL1Renderer?new i.WebGL1Renderer(r):new i.WebGLRenderer(r),this.renderer.setPixelRatio(A.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(!(A.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}=b.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(A.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(E.MOUSE_DOWN,t)}mouseMove(t){this.emit(E.MOUSE_MOVE,t)}mouseUp(t){this.emit(E.MOUSE_UP,t)}mouseWheel(t){this.emit(E.MOUSE_WHEEL,t)}touchStart(t){this.emit(E.TOUCH_START,t)}touchMove(t){this.emit(E.TOUCH_MOVE,t)}touchEnd(t){this.emit(E.TOUCH_END,t)}contextMenu(t){this.emit(E.CONTEXT_MENU,t)}dblclick(t){this.emit(E.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(),R.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={}){b.getInstance().setThreeInstance(t),e&&e.konva&&b.getInstance().setKonvaInstance(e.konva)},t.Shape=In,t.ShapeGroup=ym,t.ShapeUtils=Rn,t.SphereMesh=class extends Gt{constructor(t,e){super();const{THREE:n}=b.getInstance(),i=e||{};this.group=new n.Group,this.add(this.group);const r=i.material||new n.MeshBasicMaterial({color:i.fillColor?i.fillColor:65280,transparent:!0,opacity:void 0!==i.opacity?i.opacity:1,side:n.DoubleSide,depthWrite:!0});!1===i.hidden&&(r.visible=!1);const s=new n.SphereGeometry(t,60,40),o=new n.Mesh(s,r);o.renderOrder=1e3,this.group.add(o),this.initialized=!1,this.loaded=!0}setOnCurrentViewChanged(t){this.eventListeners={onCurrentViewChanged:t}}update(){const t=new Ht(this);return!this.initialized&&this.loaded&&(this.initialized=!0,t.needUpdate=!0),this.initialized&&!this.parent&&(t.shouldPlaceElement=!0),t}dispose(){super.dispose(),Fn.dispose(this,!0)}},t.Stage=class{constructor(){const{THREE:t}=b.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=>{w.emit(_.ELEMENT_LOADED,t)}},this.registerEvents(),R.GetSharedInstance().registerStage(this)}registerEvents(){w.on(E.DISPOSE_ELEMENT,this.stageListeners.onDisposeElement),w.on(E.ELEMENT_LOADED,this.stageListeners.onElementLoaded)}initLights(){const{THREE:t}=b.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){R.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()}),w.off(E.DISPOSE_ELEMENT,this.stageListeners.onDisposeElement),w.off(E.ELEMENT_LOADED,this.stageListeners.onElementLoaded),this.disposed=!0,R.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}=b.getInstance();this.scene.background=new e.Color(t)}setFrameTickFunction(t){R.GetSharedInstance().setRequestAnimationFrameFunction(t)}toggleTickSelfManagement(t){R.GetSharedInstance().toggleTickSelfManagement(t)}},t.SvgFloorModel=wo,t.SvgFloors=class extends Gt{constructor(t,e=0){super(),this.initialized=!1,this.loadCounter=0,this.floorInfos=t,this.visibleFloorIndex=e,this.renderThisFrame=!1,this.floors=[],this.floorInfos.forEach(({url:t,mapping:e})=>{this.floors.push(new wo(t,e))}),this.add(...this.floors),this.setFloorVisible(e)}update(){this.floors.forEach(t=>{t.update().shouldPlaceElement&&(this.loadCounter+=1)});const t=new Ht(this);return this.initialized||this.loadCounter!==this.floors.length||(this.initialized=!0,t.needUpdate=!0),this.renderThisFrame&&(t.needUpdate=!0),this.renderThisFrame=!1,this.initialized&&!this.parent&&(t.shouldPlaceElement=!0),t}setFloorVisible(t){this.floors.forEach((e,n)=>{e.visible=n===t})}async switchToFloor(t){if(t<0||t>=this.floors.length)throw Error("Index out of range");if(this.renderThisFrame=!0,t===this.visibleFloorIndex)return;const e=this.floors[this.visibleFloorIndex],n=this.floors[t],i=this.visibleFloorIndex<t;n.position.setZ(i?0:-20),n.setOpacity(0),n.visible=!0,e.setShadowEnabled(!1),await new Promise(r=>{new x.Tween({z:0,alpha:1}).to({z:20,alpha:0},500).easing(x.Easing.Quadratic.InOut).onUpdate(({z:t,alpha:r})=>{i?(e.position.setZ(-t),n.position.setZ(20-t)):(e.position.setZ(t),n.position.setZ(t-20)),e.setOpacity(r),n.setOpacity(1-r),this.renderThisFrame=!0}).onComplete(()=>{e.visible=!1,this.renderThisFrame=!0,this.visibleFloorIndex=t,n.setShadowEnabled(!0),r(null)}).start()})}getCurrentVisibleFloorModel(){return this.floors[this.visibleFloorIndex]}dispose(){for(super.dispose();this.floors.length;){this.floors.pop().dispose()}this.floorInfos=[]}},t.SvgUtils=On,t.TEXT_MAX=16,t.TEXT_PIXEL=ao,t.TEXT_SEGMENT=4,t.TWEEN=x,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 ho(this.pfid,this.level,this.index)}get originVertices(){let t=this._originVertices;if(!t){const e=10*this.pfid%10-1,n=co[e],{revers:i,flipX:r,flipY:s}=n;t=this._originVertices=uo(this.level,this.index,i,r,s)}return t}inCamera(t,e){const{THREE:n}=b.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=po,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.VideoElement=hm,t.View=I,t.getImgTextPixel=oo,t.getTextPixel=so,t.setTileConfig=function(t){ro={...ro,...t}},t.updateTick=function(){const t=R.GetSharedInstance();C||(P=0,C=Date.now()),L=Date.now(),P+=L-C,t.tick(P),C=L},t}({},THREE,Konva);
59
+
60
+ /* eslint-disable */
61
+ Owlly.SetExternal(THREE, optionals);
62
+ THREE.GLTFLoader = Owlly.GLTFLoader;
63
+ THREE.LineGeometry = Owlly.LineGeometry;
64
+ THREE.LineSegments2 = Owlly.LineSegments2;
65
+ THREE.LineMaterial = Owlly.LineMaterial;
66
+ return Owlly;
67
+ };
68
+
69
+ exports.default = getOwlly;