agentshire 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (406) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/LICENSE +21 -0
  3. package/README.md +437 -0
  4. package/README.zh-CN.md +441 -0
  5. package/ROADMAP.md +207 -0
  6. package/THIRD_PARTY_NOTICES.md +49 -0
  7. package/VISION.md +101 -0
  8. package/index.ts +386 -0
  9. package/openclaw.plugin.json +27 -0
  10. package/package.json +100 -0
  11. package/src/bridge/AGENTS.md +136 -0
  12. package/src/bridge/ActivityStream.ts +184 -0
  13. package/src/bridge/CitizenManager.ts +280 -0
  14. package/src/bridge/DirectorBridge.ts +1076 -0
  15. package/src/bridge/EventTranslator.ts +142 -0
  16. package/src/bridge/NpcEventQueue.ts +61 -0
  17. package/src/bridge/ReconnectManager.ts +42 -0
  18. package/src/bridge/RouteManager.ts +270 -0
  19. package/src/bridge/StateTracker.ts +100 -0
  20. package/src/bridge/ToolVfxMapper.ts +94 -0
  21. package/src/bridge/__tests__/ActivityStream.test.ts +156 -0
  22. package/src/bridge/__tests__/CitizenManager.test.ts +174 -0
  23. package/src/bridge/__tests__/EventTranslator.test.ts +292 -0
  24. package/src/bridge/__tests__/NpcEventQueue.test.ts +92 -0
  25. package/src/bridge/__tests__/RouteManager.test.ts +106 -0
  26. package/src/bridge/data/route-config.json +36 -0
  27. package/src/bridge/data/route-config.ts +19 -0
  28. package/src/bridge/implicit-chat.ts +192 -0
  29. package/src/bridge/index.ts +12 -0
  30. package/src/contracts/agent-state.ts +87 -0
  31. package/src/contracts/agui.ts +212 -0
  32. package/src/contracts/chat.ts +67 -0
  33. package/src/contracts/events.ts +170 -0
  34. package/src/contracts/index.ts +71 -0
  35. package/src/contracts/media.ts +77 -0
  36. package/src/contracts/registry.ts +32 -0
  37. package/src/plugin/AGENTS.md +192 -0
  38. package/src/plugin/__tests__/editor-serve-megapack.test.ts +150 -0
  39. package/src/plugin/__tests__/hook-translator.test.ts +197 -0
  40. package/src/plugin/auto-config.ts +131 -0
  41. package/src/plugin/channel.ts +399 -0
  42. package/src/plugin/chat-asset-resolver.ts +75 -0
  43. package/src/plugin/chat-session-watcher.ts +98 -0
  44. package/src/plugin/citizen-agent-manager.ts +178 -0
  45. package/src/plugin/citizen-chat-router.ts +83 -0
  46. package/src/plugin/citizen-workshop-manager.ts +96 -0
  47. package/src/plugin/custom-asset-manager.ts +250 -0
  48. package/src/plugin/editor-serve.ts +1368 -0
  49. package/src/plugin/group-discussion.ts +223 -0
  50. package/src/plugin/hook-translator.ts +202 -0
  51. package/src/plugin/llm-agent-proxy.ts +193 -0
  52. package/src/plugin/outbound-adapter.ts +187 -0
  53. package/src/plugin/paths.ts +33 -0
  54. package/src/plugin/plan-manager.ts +594 -0
  55. package/src/plugin/runtime.ts +9 -0
  56. package/src/plugin/session-history.ts +838 -0
  57. package/src/plugin/session-log-watcher.ts +221 -0
  58. package/src/plugin/soul-prompt-template.ts +290 -0
  59. package/src/plugin/subagent-tracker.ts +205 -0
  60. package/src/plugin/tools.ts +493 -0
  61. package/src/plugin/town-session.ts +40 -0
  62. package/src/plugin/ws-server.ts +680 -0
  63. package/src/town-souls.ts +134 -0
  64. package/town-frontend/dist/assets/CustomAssetStore-oi8aIurt.js +2 -0
  65. package/town-frontend/dist/assets/GLTFLoader-BA5RqSME.js +3804 -0
  66. package/town-frontend/dist/assets/OrbitControls-ZmySp9sQ.js +2 -0
  67. package/town-frontend/dist/assets/SettingsPanel-BO52reJe.js +2 -0
  68. package/town-frontend/dist/assets/SkeletonUtils-BCVmgslc.js +2 -0
  69. package/town-frontend/dist/assets/SkillLearnCard-Dk38iDpy.js +6 -0
  70. package/town-frontend/dist/assets/TopicSetupPanel-DLaLHB_Z.js +2 -0
  71. package/town-frontend/dist/assets/Trap-Bold-CT0JBE39.woff2 +0 -0
  72. package/town-frontend/dist/assets/Trap-SemiBold-R4_-Ld0j.woff2 +0 -0
  73. package/town-frontend/dist/assets/WeatherSystem-Cb3BvHes.js +550 -0
  74. package/town-frontend/dist/assets/avatars/char-female-a.webp +0 -0
  75. package/town-frontend/dist/assets/avatars/char-female-b.webp +0 -0
  76. package/town-frontend/dist/assets/avatars/char-female-c.webp +0 -0
  77. package/town-frontend/dist/assets/avatars/char-female-d.webp +0 -0
  78. package/town-frontend/dist/assets/avatars/char-female-e.webp +0 -0
  79. package/town-frontend/dist/assets/avatars/char-female-f.webp +0 -0
  80. package/town-frontend/dist/assets/avatars/char-male-a.webp +0 -0
  81. package/town-frontend/dist/assets/avatars/char-male-b.webp +0 -0
  82. package/town-frontend/dist/assets/avatars/char-male-c.webp +0 -0
  83. package/town-frontend/dist/assets/avatars/char-male-d.webp +0 -0
  84. package/town-frontend/dist/assets/avatars/char-male-e.webp +0 -0
  85. package/town-frontend/dist/assets/avatars/char-male-f.webp +0 -0
  86. package/town-frontend/dist/assets/avatars/char-pet-beaver.webp +0 -0
  87. package/town-frontend/dist/assets/avatars/char-pet-bee.webp +0 -0
  88. package/town-frontend/dist/assets/avatars/char-pet-bunny.webp +0 -0
  89. package/town-frontend/dist/assets/avatars/char-pet-cat.webp +0 -0
  90. package/town-frontend/dist/assets/avatars/char-pet-caterpillar.webp +0 -0
  91. package/town-frontend/dist/assets/avatars/char-pet-chick.webp +0 -0
  92. package/town-frontend/dist/assets/avatars/char-pet-cow.webp +0 -0
  93. package/town-frontend/dist/assets/avatars/char-pet-crab.webp +0 -0
  94. package/town-frontend/dist/assets/avatars/char-pet-deer.webp +0 -0
  95. package/town-frontend/dist/assets/avatars/char-pet-dog.webp +0 -0
  96. package/town-frontend/dist/assets/avatars/char-pet-elephant.webp +0 -0
  97. package/town-frontend/dist/assets/avatars/char-pet-fish.webp +0 -0
  98. package/town-frontend/dist/assets/avatars/char-pet-fox.webp +0 -0
  99. package/town-frontend/dist/assets/avatars/char-pet-giraffe.webp +0 -0
  100. package/town-frontend/dist/assets/avatars/char-pet-hog.webp +0 -0
  101. package/town-frontend/dist/assets/avatars/char-pet-koala.webp +0 -0
  102. package/town-frontend/dist/assets/avatars/char-pet-lion.webp +0 -0
  103. package/town-frontend/dist/assets/avatars/char-pet-monkey.webp +0 -0
  104. package/town-frontend/dist/assets/avatars/char-pet-panda.webp +0 -0
  105. package/town-frontend/dist/assets/avatars/char-pet-parrot.webp +0 -0
  106. package/town-frontend/dist/assets/avatars/char-pet-penguin.webp +0 -0
  107. package/town-frontend/dist/assets/avatars/char-pet-pig.webp +0 -0
  108. package/town-frontend/dist/assets/avatars/char-pet-polar.webp +0 -0
  109. package/town-frontend/dist/assets/avatars/char-pet-tiger.webp +0 -0
  110. package/town-frontend/dist/assets/character-catalog-DSmLtlNC.js +2 -0
  111. package/town-frontend/dist/assets/citizenEditor-DubGSJOQ.js +296 -0
  112. package/town-frontend/dist/assets/command-parser-BUd15Bmv.js +12 -0
  113. package/town-frontend/dist/assets/editor-B5QO0OtX.js +258 -0
  114. package/town-frontend/dist/assets/editor-Bk8g1NCD.css +1 -0
  115. package/town-frontend/dist/assets/index-BWfrufil.js +2 -0
  116. package/town-frontend/dist/assets/index-faS20RJk.js +6 -0
  117. package/town-frontend/dist/assets/logo-DJI6EtST.png +0 -0
  118. package/town-frontend/dist/assets/logo-title-AdKPZX5E.png +0 -0
  119. package/town-frontend/dist/assets/main-CqsN43aT.js +224 -0
  120. package/town-frontend/dist/assets/main-D7neuy3w.css +1 -0
  121. package/town-frontend/dist/assets/models/buildings/base.bin +0 -0
  122. package/town-frontend/dist/assets/models/buildings/base.gltf +136 -0
  123. package/town-frontend/dist/assets/models/buildings/bench.bin +0 -0
  124. package/town-frontend/dist/assets/models/buildings/bench.gltf +136 -0
  125. package/town-frontend/dist/assets/models/buildings/box_A.bin +0 -0
  126. package/town-frontend/dist/assets/models/buildings/box_A.gltf +136 -0
  127. package/town-frontend/dist/assets/models/buildings/box_B.bin +0 -0
  128. package/town-frontend/dist/assets/models/buildings/box_B.gltf +136 -0
  129. package/town-frontend/dist/assets/models/buildings/building_A.bin +0 -0
  130. package/town-frontend/dist/assets/models/buildings/building_A.gltf +136 -0
  131. package/town-frontend/dist/assets/models/buildings/building_A_withoutBase.bin +0 -0
  132. package/town-frontend/dist/assets/models/buildings/building_A_withoutBase.gltf +136 -0
  133. package/town-frontend/dist/assets/models/buildings/building_B.bin +0 -0
  134. package/town-frontend/dist/assets/models/buildings/building_B.gltf +136 -0
  135. package/town-frontend/dist/assets/models/buildings/building_B_withoutBase.bin +0 -0
  136. package/town-frontend/dist/assets/models/buildings/building_B_withoutBase.gltf +136 -0
  137. package/town-frontend/dist/assets/models/buildings/building_C.bin +0 -0
  138. package/town-frontend/dist/assets/models/buildings/building_C.gltf +136 -0
  139. package/town-frontend/dist/assets/models/buildings/building_C_withoutBase.bin +0 -0
  140. package/town-frontend/dist/assets/models/buildings/building_C_withoutBase.gltf +136 -0
  141. package/town-frontend/dist/assets/models/buildings/building_D.bin +0 -0
  142. package/town-frontend/dist/assets/models/buildings/building_D.gltf +136 -0
  143. package/town-frontend/dist/assets/models/buildings/building_D_withoutBase.bin +0 -0
  144. package/town-frontend/dist/assets/models/buildings/building_D_withoutBase.gltf +136 -0
  145. package/town-frontend/dist/assets/models/buildings/building_E.bin +0 -0
  146. package/town-frontend/dist/assets/models/buildings/building_E.gltf +136 -0
  147. package/town-frontend/dist/assets/models/buildings/building_E_withoutBase.bin +0 -0
  148. package/town-frontend/dist/assets/models/buildings/building_E_withoutBase.gltf +136 -0
  149. package/town-frontend/dist/assets/models/buildings/building_F.bin +0 -0
  150. package/town-frontend/dist/assets/models/buildings/building_F.gltf +136 -0
  151. package/town-frontend/dist/assets/models/buildings/building_F_withoutBase.bin +0 -0
  152. package/town-frontend/dist/assets/models/buildings/building_F_withoutBase.gltf +136 -0
  153. package/town-frontend/dist/assets/models/buildings/building_G.bin +0 -0
  154. package/town-frontend/dist/assets/models/buildings/building_G.gltf +136 -0
  155. package/town-frontend/dist/assets/models/buildings/building_G_withoutBase.bin +0 -0
  156. package/town-frontend/dist/assets/models/buildings/building_G_withoutBase.gltf +136 -0
  157. package/town-frontend/dist/assets/models/buildings/building_H.bin +0 -0
  158. package/town-frontend/dist/assets/models/buildings/building_H.gltf +136 -0
  159. package/town-frontend/dist/assets/models/buildings/building_H_withoutBase.bin +0 -0
  160. package/town-frontend/dist/assets/models/buildings/building_H_withoutBase.gltf +136 -0
  161. package/town-frontend/dist/assets/models/buildings/bush.bin +0 -0
  162. package/town-frontend/dist/assets/models/buildings/bush.gltf +136 -0
  163. package/town-frontend/dist/assets/models/buildings/car_hatchback.bin +0 -0
  164. package/town-frontend/dist/assets/models/buildings/car_hatchback.gltf +442 -0
  165. package/town-frontend/dist/assets/models/buildings/car_police.bin +0 -0
  166. package/town-frontend/dist/assets/models/buildings/car_police.gltf +442 -0
  167. package/town-frontend/dist/assets/models/buildings/car_sedan.bin +0 -0
  168. package/town-frontend/dist/assets/models/buildings/car_sedan.gltf +442 -0
  169. package/town-frontend/dist/assets/models/buildings/car_stationwagon.bin +0 -0
  170. package/town-frontend/dist/assets/models/buildings/car_stationwagon.gltf +442 -0
  171. package/town-frontend/dist/assets/models/buildings/car_taxi.bin +0 -0
  172. package/town-frontend/dist/assets/models/buildings/car_taxi.gltf +442 -0
  173. package/town-frontend/dist/assets/models/buildings/citybits_texture.png +0 -0
  174. package/town-frontend/dist/assets/models/buildings/dumpster.bin +0 -0
  175. package/town-frontend/dist/assets/models/buildings/dumpster.gltf +136 -0
  176. package/town-frontend/dist/assets/models/buildings/firehydrant.bin +0 -0
  177. package/town-frontend/dist/assets/models/buildings/firehydrant.gltf +136 -0
  178. package/town-frontend/dist/assets/models/buildings/road_corner.bin +0 -0
  179. package/town-frontend/dist/assets/models/buildings/road_corner.gltf +136 -0
  180. package/town-frontend/dist/assets/models/buildings/road_corner_curved.bin +0 -0
  181. package/town-frontend/dist/assets/models/buildings/road_corner_curved.gltf +136 -0
  182. package/town-frontend/dist/assets/models/buildings/road_junction.bin +0 -0
  183. package/town-frontend/dist/assets/models/buildings/road_junction.gltf +136 -0
  184. package/town-frontend/dist/assets/models/buildings/road_straight.bin +0 -0
  185. package/town-frontend/dist/assets/models/buildings/road_straight.gltf +136 -0
  186. package/town-frontend/dist/assets/models/buildings/road_straight_crossing.bin +0 -0
  187. package/town-frontend/dist/assets/models/buildings/road_straight_crossing.gltf +136 -0
  188. package/town-frontend/dist/assets/models/buildings/road_tsplit.bin +0 -0
  189. package/town-frontend/dist/assets/models/buildings/road_tsplit.gltf +136 -0
  190. package/town-frontend/dist/assets/models/buildings/streetlight.bin +0 -0
  191. package/town-frontend/dist/assets/models/buildings/streetlight.gltf +136 -0
  192. package/town-frontend/dist/assets/models/buildings/trafficlight_A.bin +0 -0
  193. package/town-frontend/dist/assets/models/buildings/trafficlight_A.gltf +136 -0
  194. package/town-frontend/dist/assets/models/buildings/trafficlight_B.bin +0 -0
  195. package/town-frontend/dist/assets/models/buildings/trafficlight_B.gltf +136 -0
  196. package/town-frontend/dist/assets/models/buildings/trafficlight_C.bin +0 -0
  197. package/town-frontend/dist/assets/models/buildings/trafficlight_C.gltf +136 -0
  198. package/town-frontend/dist/assets/models/buildings/trash_A.bin +0 -0
  199. package/town-frontend/dist/assets/models/buildings/trash_A.gltf +136 -0
  200. package/town-frontend/dist/assets/models/buildings/trash_B.bin +0 -0
  201. package/town-frontend/dist/assets/models/buildings/trash_B.gltf +136 -0
  202. package/town-frontend/dist/assets/models/buildings/watertower.bin +0 -0
  203. package/town-frontend/dist/assets/models/buildings/watertower.gltf +136 -0
  204. package/town-frontend/dist/assets/models/characters/Textures/colormap.png +0 -0
  205. package/town-frontend/dist/assets/models/characters/character-female-a.glb +0 -0
  206. package/town-frontend/dist/assets/models/characters/character-female-b.glb +0 -0
  207. package/town-frontend/dist/assets/models/characters/character-female-c.glb +0 -0
  208. package/town-frontend/dist/assets/models/characters/character-female-d.glb +0 -0
  209. package/town-frontend/dist/assets/models/characters/character-female-e.glb +0 -0
  210. package/town-frontend/dist/assets/models/characters/character-female-f.glb +0 -0
  211. package/town-frontend/dist/assets/models/characters/character-male-a.glb +0 -0
  212. package/town-frontend/dist/assets/models/characters/character-male-b.glb +0 -0
  213. package/town-frontend/dist/assets/models/characters/character-male-c.glb +0 -0
  214. package/town-frontend/dist/assets/models/characters/character-male-d.glb +0 -0
  215. package/town-frontend/dist/assets/models/characters/character-male-e.glb +0 -0
  216. package/town-frontend/dist/assets/models/characters/character-male-f.glb +0 -0
  217. package/town-frontend/dist/assets/models/characters/character-pet-beaver.glb +0 -0
  218. package/town-frontend/dist/assets/models/characters/character-pet-bee.glb +0 -0
  219. package/town-frontend/dist/assets/models/characters/character-pet-bunny.glb +0 -0
  220. package/town-frontend/dist/assets/models/characters/character-pet-cat.glb +0 -0
  221. package/town-frontend/dist/assets/models/characters/character-pet-caterpillar.glb +0 -0
  222. package/town-frontend/dist/assets/models/characters/character-pet-chick.glb +0 -0
  223. package/town-frontend/dist/assets/models/characters/character-pet-cow.glb +0 -0
  224. package/town-frontend/dist/assets/models/characters/character-pet-crab.glb +0 -0
  225. package/town-frontend/dist/assets/models/characters/character-pet-deer.glb +0 -0
  226. package/town-frontend/dist/assets/models/characters/character-pet-dog.glb +0 -0
  227. package/town-frontend/dist/assets/models/characters/character-pet-elephant.glb +0 -0
  228. package/town-frontend/dist/assets/models/characters/character-pet-fish.glb +0 -0
  229. package/town-frontend/dist/assets/models/characters/character-pet-fox.glb +0 -0
  230. package/town-frontend/dist/assets/models/characters/character-pet-giraffe.glb +0 -0
  231. package/town-frontend/dist/assets/models/characters/character-pet-hog.glb +0 -0
  232. package/town-frontend/dist/assets/models/characters/character-pet-koala.glb +0 -0
  233. package/town-frontend/dist/assets/models/characters/character-pet-lion.glb +0 -0
  234. package/town-frontend/dist/assets/models/characters/character-pet-monkey.glb +0 -0
  235. package/town-frontend/dist/assets/models/characters/character-pet-panda.glb +0 -0
  236. package/town-frontend/dist/assets/models/characters/character-pet-parrot.glb +0 -0
  237. package/town-frontend/dist/assets/models/characters/character-pet-penguin.glb +0 -0
  238. package/town-frontend/dist/assets/models/characters/character-pet-pig.glb +0 -0
  239. package/town-frontend/dist/assets/models/characters/character-pet-polar.glb +0 -0
  240. package/town-frontend/dist/assets/models/characters/character-pet-tiger.glb +0 -0
  241. package/town-frontend/dist/assets/models/characters/colormap.png +0 -0
  242. package/town-frontend/dist/assets/models/furniture/armchair.bin +0 -0
  243. package/town-frontend/dist/assets/models/furniture/armchair.gltf +136 -0
  244. package/town-frontend/dist/assets/models/furniture/armchair_pillows.bin +0 -0
  245. package/town-frontend/dist/assets/models/furniture/armchair_pillows.gltf +136 -0
  246. package/town-frontend/dist/assets/models/furniture/bed_double_A.bin +0 -0
  247. package/town-frontend/dist/assets/models/furniture/bed_double_A.gltf +136 -0
  248. package/town-frontend/dist/assets/models/furniture/bed_double_B.bin +0 -0
  249. package/town-frontend/dist/assets/models/furniture/bed_double_B.gltf +136 -0
  250. package/town-frontend/dist/assets/models/furniture/bed_single_A.bin +0 -0
  251. package/town-frontend/dist/assets/models/furniture/bed_single_A.gltf +136 -0
  252. package/town-frontend/dist/assets/models/furniture/bed_single_B.bin +0 -0
  253. package/town-frontend/dist/assets/models/furniture/bed_single_B.gltf +136 -0
  254. package/town-frontend/dist/assets/models/furniture/book_set.bin +0 -0
  255. package/town-frontend/dist/assets/models/furniture/book_set.gltf +136 -0
  256. package/town-frontend/dist/assets/models/furniture/book_single.bin +0 -0
  257. package/town-frontend/dist/assets/models/furniture/book_single.gltf +136 -0
  258. package/town-frontend/dist/assets/models/furniture/cabinet_medium.bin +0 -0
  259. package/town-frontend/dist/assets/models/furniture/cabinet_medium.gltf +136 -0
  260. package/town-frontend/dist/assets/models/furniture/cabinet_medium_decorated.bin +0 -0
  261. package/town-frontend/dist/assets/models/furniture/cabinet_medium_decorated.gltf +136 -0
  262. package/town-frontend/dist/assets/models/furniture/cabinet_small.bin +0 -0
  263. package/town-frontend/dist/assets/models/furniture/cabinet_small.gltf +136 -0
  264. package/town-frontend/dist/assets/models/furniture/cabinet_small_decorated.bin +0 -0
  265. package/town-frontend/dist/assets/models/furniture/cabinet_small_decorated.gltf +136 -0
  266. package/town-frontend/dist/assets/models/furniture/cactus_medium_A.bin +0 -0
  267. package/town-frontend/dist/assets/models/furniture/cactus_medium_A.gltf +136 -0
  268. package/town-frontend/dist/assets/models/furniture/cactus_medium_B.bin +0 -0
  269. package/town-frontend/dist/assets/models/furniture/cactus_medium_B.gltf +136 -0
  270. package/town-frontend/dist/assets/models/furniture/cactus_small_A.bin +0 -0
  271. package/town-frontend/dist/assets/models/furniture/cactus_small_A.gltf +136 -0
  272. package/town-frontend/dist/assets/models/furniture/cactus_small_B.bin +0 -0
  273. package/town-frontend/dist/assets/models/furniture/cactus_small_B.gltf +136 -0
  274. package/town-frontend/dist/assets/models/furniture/chair_A.bin +0 -0
  275. package/town-frontend/dist/assets/models/furniture/chair_A.gltf +136 -0
  276. package/town-frontend/dist/assets/models/furniture/chair_A_wood.bin +0 -0
  277. package/town-frontend/dist/assets/models/furniture/chair_A_wood.gltf +136 -0
  278. package/town-frontend/dist/assets/models/furniture/chair_B.bin +0 -0
  279. package/town-frontend/dist/assets/models/furniture/chair_B.gltf +136 -0
  280. package/town-frontend/dist/assets/models/furniture/chair_B_wood.bin +0 -0
  281. package/town-frontend/dist/assets/models/furniture/chair_B_wood.gltf +136 -0
  282. package/town-frontend/dist/assets/models/furniture/chair_C.bin +0 -0
  283. package/town-frontend/dist/assets/models/furniture/chair_C.gltf +136 -0
  284. package/town-frontend/dist/assets/models/furniture/chair_stool.bin +0 -0
  285. package/town-frontend/dist/assets/models/furniture/chair_stool.gltf +136 -0
  286. package/town-frontend/dist/assets/models/furniture/chair_stool_wood.bin +0 -0
  287. package/town-frontend/dist/assets/models/furniture/chair_stool_wood.gltf +136 -0
  288. package/town-frontend/dist/assets/models/furniture/couch.bin +0 -0
  289. package/town-frontend/dist/assets/models/furniture/couch.gltf +136 -0
  290. package/town-frontend/dist/assets/models/furniture/couch_pillows.bin +0 -0
  291. package/town-frontend/dist/assets/models/furniture/couch_pillows.gltf +136 -0
  292. package/town-frontend/dist/assets/models/furniture/furniturebits_texture.png +0 -0
  293. package/town-frontend/dist/assets/models/furniture/lamp_standing.bin +0 -0
  294. package/town-frontend/dist/assets/models/furniture/lamp_standing.gltf +136 -0
  295. package/town-frontend/dist/assets/models/furniture/lamp_table.bin +0 -0
  296. package/town-frontend/dist/assets/models/furniture/lamp_table.gltf +136 -0
  297. package/town-frontend/dist/assets/models/furniture/pictureframe_large_A.bin +0 -0
  298. package/town-frontend/dist/assets/models/furniture/pictureframe_large_A.gltf +136 -0
  299. package/town-frontend/dist/assets/models/furniture/pictureframe_large_B.bin +0 -0
  300. package/town-frontend/dist/assets/models/furniture/pictureframe_large_B.gltf +136 -0
  301. package/town-frontend/dist/assets/models/furniture/pictureframe_medium.bin +0 -0
  302. package/town-frontend/dist/assets/models/furniture/pictureframe_medium.gltf +136 -0
  303. package/town-frontend/dist/assets/models/furniture/pictureframe_small_A.bin +0 -0
  304. package/town-frontend/dist/assets/models/furniture/pictureframe_small_A.gltf +136 -0
  305. package/town-frontend/dist/assets/models/furniture/pictureframe_small_B.bin +0 -0
  306. package/town-frontend/dist/assets/models/furniture/pictureframe_small_B.gltf +136 -0
  307. package/town-frontend/dist/assets/models/furniture/pictureframe_small_C.bin +0 -0
  308. package/town-frontend/dist/assets/models/furniture/pictureframe_small_C.gltf +136 -0
  309. package/town-frontend/dist/assets/models/furniture/pictureframe_standing_A.bin +0 -0
  310. package/town-frontend/dist/assets/models/furniture/pictureframe_standing_A.gltf +136 -0
  311. package/town-frontend/dist/assets/models/furniture/pictureframe_standing_B.bin +0 -0
  312. package/town-frontend/dist/assets/models/furniture/pictureframe_standing_B.gltf +136 -0
  313. package/town-frontend/dist/assets/models/furniture/pillow_A.bin +0 -0
  314. package/town-frontend/dist/assets/models/furniture/pillow_A.gltf +136 -0
  315. package/town-frontend/dist/assets/models/furniture/pillow_B.bin +0 -0
  316. package/town-frontend/dist/assets/models/furniture/pillow_B.gltf +136 -0
  317. package/town-frontend/dist/assets/models/furniture/rug_oval_A.bin +0 -0
  318. package/town-frontend/dist/assets/models/furniture/rug_oval_A.gltf +136 -0
  319. package/town-frontend/dist/assets/models/furniture/rug_oval_B.bin +0 -0
  320. package/town-frontend/dist/assets/models/furniture/rug_oval_B.gltf +136 -0
  321. package/town-frontend/dist/assets/models/furniture/rug_rectangle_A.bin +0 -0
  322. package/town-frontend/dist/assets/models/furniture/rug_rectangle_A.gltf +136 -0
  323. package/town-frontend/dist/assets/models/furniture/rug_rectangle_B.bin +0 -0
  324. package/town-frontend/dist/assets/models/furniture/rug_rectangle_B.gltf +136 -0
  325. package/town-frontend/dist/assets/models/furniture/rug_rectangle_stripes_A.bin +0 -0
  326. package/town-frontend/dist/assets/models/furniture/rug_rectangle_stripes_A.gltf +136 -0
  327. package/town-frontend/dist/assets/models/furniture/rug_rectangle_stripes_B.bin +0 -0
  328. package/town-frontend/dist/assets/models/furniture/rug_rectangle_stripes_B.gltf +136 -0
  329. package/town-frontend/dist/assets/models/furniture/shelf_A_big.bin +0 -0
  330. package/town-frontend/dist/assets/models/furniture/shelf_A_big.gltf +136 -0
  331. package/town-frontend/dist/assets/models/furniture/shelf_A_small.bin +0 -0
  332. package/town-frontend/dist/assets/models/furniture/shelf_A_small.gltf +136 -0
  333. package/town-frontend/dist/assets/models/furniture/shelf_B_large.bin +0 -0
  334. package/town-frontend/dist/assets/models/furniture/shelf_B_large.gltf +136 -0
  335. package/town-frontend/dist/assets/models/furniture/shelf_B_large_decorated.bin +0 -0
  336. package/town-frontend/dist/assets/models/furniture/shelf_B_large_decorated.gltf +136 -0
  337. package/town-frontend/dist/assets/models/furniture/shelf_B_small.bin +0 -0
  338. package/town-frontend/dist/assets/models/furniture/shelf_B_small.gltf +136 -0
  339. package/town-frontend/dist/assets/models/furniture/shelf_B_small_decorated.bin +0 -0
  340. package/town-frontend/dist/assets/models/furniture/shelf_B_small_decorated.gltf +136 -0
  341. package/town-frontend/dist/assets/models/furniture/table_low.bin +0 -0
  342. package/town-frontend/dist/assets/models/furniture/table_low.gltf +136 -0
  343. package/town-frontend/dist/assets/models/furniture/table_medium.bin +0 -0
  344. package/town-frontend/dist/assets/models/furniture/table_medium.gltf +136 -0
  345. package/town-frontend/dist/assets/models/furniture/table_medium_long.bin +0 -0
  346. package/town-frontend/dist/assets/models/furniture/table_medium_long.gltf +136 -0
  347. package/town-frontend/dist/assets/models/furniture/table_small.bin +0 -0
  348. package/town-frontend/dist/assets/models/furniture/table_small.gltf +136 -0
  349. package/town-frontend/dist/assets/models/props/bench.bin +0 -0
  350. package/town-frontend/dist/assets/models/props/bench.gltf +136 -0
  351. package/town-frontend/dist/assets/models/props/bush.bin +0 -0
  352. package/town-frontend/dist/assets/models/props/bush.gltf +136 -0
  353. package/town-frontend/dist/assets/models/props/capybara.glb +0 -0
  354. package/town-frontend/dist/assets/models/props/car_hatchback.bin +0 -0
  355. package/town-frontend/dist/assets/models/props/car_hatchback.gltf +442 -0
  356. package/town-frontend/dist/assets/models/props/car_sedan.bin +0 -0
  357. package/town-frontend/dist/assets/models/props/car_sedan.gltf +442 -0
  358. package/town-frontend/dist/assets/models/props/car_taxi.bin +0 -0
  359. package/town-frontend/dist/assets/models/props/car_taxi.gltf +442 -0
  360. package/town-frontend/dist/assets/models/props/citybits_texture.png +0 -0
  361. package/town-frontend/dist/assets/models/props/dumpster.bin +0 -0
  362. package/town-frontend/dist/assets/models/props/dumpster.gltf +136 -0
  363. package/town-frontend/dist/assets/models/props/firehydrant.bin +0 -0
  364. package/town-frontend/dist/assets/models/props/firehydrant.gltf +136 -0
  365. package/town-frontend/dist/assets/models/props/streetlight.bin +0 -0
  366. package/town-frontend/dist/assets/models/props/streetlight.gltf +136 -0
  367. package/town-frontend/dist/assets/models/props/trafficlight_A.bin +0 -0
  368. package/town-frontend/dist/assets/models/props/trafficlight_A.gltf +136 -0
  369. package/town-frontend/dist/assets/models/props/trash_A.bin +0 -0
  370. package/town-frontend/dist/assets/models/props/trash_A.gltf +136 -0
  371. package/town-frontend/dist/assets/models/props/watertower.bin +0 -0
  372. package/town-frontend/dist/assets/models/props/watertower.gltf +136 -0
  373. package/town-frontend/dist/assets/models/stage-deco/Flowers_1_D.glb +0 -0
  374. package/town-frontend/dist/assets/models/stage-deco/Flowers_2_B.glb +0 -0
  375. package/town-frontend/dist/assets/models/stage-deco/Grass_A_1.glb +0 -0
  376. package/town-frontend/dist/assets/models/stage-deco/Park_GrassHill_A.glb +0 -0
  377. package/town-frontend/dist/assets/models/stage-deco/Pebles_1_A_2.glb +0 -0
  378. package/town-frontend/dist/assets/music/bgm_day.mp3 +0 -0
  379. package/town-frontend/dist/assets/music/bgm_dusk.mp3 +0 -0
  380. package/town-frontend/dist/assets/music/bgm_night.mp3 +0 -0
  381. package/town-frontend/dist/assets/music/bgm_work.mp3 +0 -0
  382. package/town-frontend/dist/assets/office-whiteboard-idle-CyEwBrq_.webp +0 -0
  383. package/town-frontend/dist/assets/preview-B6hYEQij.js +2 -0
  384. package/town-frontend/dist/assets/town-BKesnERP.js +8888 -0
  385. package/town-frontend/dist/assets/town-BnswKsjF.css +1 -0
  386. package/town-frontend/dist/citizen-editor.html +166 -0
  387. package/town-frontend/dist/editor.html +227 -0
  388. package/town-frontend/dist/index.html +22 -0
  389. package/town-frontend/dist/preview.html +56 -0
  390. package/town-frontend/dist/town.html +165 -0
  391. package/town-frontend/dist/viewer.html +91 -0
  392. package/town-souls/CHEN.md +130 -0
  393. package/town-souls/CHENGZI.md +92 -0
  394. package/town-souls/CITIZEN_tpl.md +16 -0
  395. package/town-souls/DIANDIAN.md +92 -0
  396. package/town-souls/HAITANG.md +94 -0
  397. package/town-souls/QIQI.md +119 -0
  398. package/town-souls/SOUL.md +141 -0
  399. package/town-souls/SOUL_tpl.md +135 -0
  400. package/town-souls/XIAOLIE.md +107 -0
  401. package/town-souls/YAN.md +107 -0
  402. package/town-workspace/IDENTITY.md +5 -0
  403. package/town-workspace/SOUL.md +141 -0
  404. package/town-workspace/project-workflow.md +81 -0
  405. package/town-workspace/town-defaults.json +92 -0
  406. package/town-workspace/town-guide.md +45 -0
@@ -0,0 +1,3804 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2010-2023 Three.js Authors
4
+ * SPDX-License-Identifier: MIT
5
+ */const pa="162",ev={ROTATE:0,DOLLY:1,PAN:2},tv={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Vl=0,ka=1,Wl=2,Gc=1,Xl=2,un=3,pn=0,Ct=1,Zt=2,wn=0,Ei=1,Va=2,Wa=3,Xa=4,ql=5,kn=100,Yl=101,jl=102,qa=103,Ya=104,Kl=200,Jl=201,$l=202,Zl=203,Zr=204,Qr=205,Ql=206,eh=207,th=208,nh=209,ih=210,sh=211,rh=212,ah=213,oh=214,ch=0,lh=1,hh=2,qs=3,uh=4,dh=5,fh=6,ph=7,ma=0,mh=1,gh=2,Rn=0,_h=1,vh=2,xh=3,Mh=4,yh=5,Sh=6,Eh=7,ja="attached",Th="detached",kc=300,bi=301,wi=302,ea=303,ta=304,er=306,Ri=1e3,zt=1001,Ys=1002,pt=1003,na=1004,vi=1005,Et=1006,Ws=1007,dn=1008,Cn=1009,Ah=1010,bh=1011,ga=1012,Vc=1013,An=1014,Wt=1015,ns=1016,Wc=1017,Xc=1018,qn=1020,wh=1021,Ht=1023,Rh=1024,Ch=1025,Yn=1026,Ci=1027,qc=1028,Yc=1029,Lh=1030,jc=1031,Kc=1033,lr=33776,hr=33777,ur=33778,dr=33779,Ka=35840,Ja=35841,$a=35842,Za=35843,Jc=36196,Qa=37492,eo=37496,to=37808,no=37809,io=37810,so=37811,ro=37812,ao=37813,oo=37814,co=37815,lo=37816,ho=37817,uo=37818,fo=37819,po=37820,mo=37821,fr=36492,go=36494,_o=36495,Ph=36283,vo=36284,xo=36285,Mo=36286,Ih=2200,Nh=2201,Dh=2202,is=2300,Li=2301,pr=2302,xi=2400,Mi=2401,js=2402,_a=2500,Uh=2501,Oh=0,$c=1,ia=2,Fh=3200,Bh=3201,va=0,zh=1,Tn="",wt="srgb",xt="srgb-linear",xa="display-p3",tr="display-p3-linear",Ks="linear",Qe="srgb",Js="rec709",$s="p3",$n=7680,yo=519,Hh=512,Gh=513,kh=514,Zc=515,Vh=516,Wh=517,Xh=518,qh=519,sa=35044,So="300 es",ra=1035,fn=2e3,Zs=2001;class Jn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}}const yt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Eo=1234567;const $i=Math.PI/180,Pi=180/Math.PI;function Yt(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(yt[r&255]+yt[r>>8&255]+yt[r>>16&255]+yt[r>>24&255]+"-"+yt[e&255]+yt[e>>8&255]+"-"+yt[e>>16&15|64]+yt[e>>24&255]+"-"+yt[t&63|128]+yt[t>>8&255]+"-"+yt[t>>16&255]+yt[t>>24&255]+yt[n&255]+yt[n>>8&255]+yt[n>>16&255]+yt[n>>24&255]).toLowerCase()}function ct(r,e,t){return Math.max(e,Math.min(t,r))}function Ma(r,e){return(r%e+e)%e}function Yh(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function jh(r,e,t){return r!==e?(t-r)/(e-r):0}function Zi(r,e,t){return(1-t)*r+t*e}function Kh(r,e,t,n){return Zi(r,e,1-Math.exp(-t*n))}function Jh(r,e=1){return e-Math.abs(Ma(r,e*2)-e)}function $h(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function Zh(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function Qh(r,e){return r+Math.floor(Math.random()*(e-r+1))}function eu(r,e){return r+Math.random()*(e-r)}function tu(r){return r*(.5-Math.random())}function nu(r){r!==void 0&&(Eo=r);let e=Eo+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function iu(r){return r*$i}function su(r){return r*Pi}function aa(r){return(r&r-1)===0&&r!==0}function ru(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function Qs(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function au(r,e,t,n,i){const s=Math.cos,a=Math.sin,o=s(t/2),c=a(t/2),l=s((e+n)/2),h=a((e+n)/2),u=s((e-n)/2),d=a((e-n)/2),f=s((n-e)/2),g=a((n-e)/2);switch(i){case"XYX":r.set(o*h,c*u,c*d,o*l);break;case"YZY":r.set(c*d,o*h,c*u,o*l);break;case"ZXZ":r.set(c*u,c*d,o*h,o*l);break;case"XZX":r.set(o*h,c*g,c*f,o*l);break;case"YXY":r.set(c*f,o*h,c*g,o*l);break;case"ZYZ":r.set(c*g,c*f,o*h,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Xt(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function je(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const ou={DEG2RAD:$i,RAD2DEG:Pi,generateUUID:Yt,clamp:ct,euclideanModulo:Ma,mapLinear:Yh,inverseLerp:jh,lerp:Zi,damp:Kh,pingpong:Jh,smoothstep:$h,smootherstep:Zh,randInt:Qh,randFloat:eu,randFloatSpread:tu,seededRandom:nu,degToRad:iu,radToDeg:su,isPowerOfTwo:aa,ceilPowerOfTwo:ru,floorPowerOfTwo:Qs,setQuaternionFromProperEuler:au,normalize:je,denormalize:Xt};class re{constructor(e=0,t=0){re.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,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=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ct(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*i+e.x,this.y=s*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ue{constructor(e,t,n,i,s,a,o,c,l){Ue.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,c,l)}set(e,t,n,i,s,a,o,c,l){const h=this.elements;return h[0]=e,h[1]=i,h[2]=o,h[3]=t,h[4]=s,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],f=n[5],g=n[8],_=i[0],m=i[3],p=i[6],S=i[1],v=i[4],E=i[7],C=i[2],A=i[5],b=i[8];return s[0]=a*_+o*S+c*C,s[3]=a*m+o*v+c*A,s[6]=a*p+o*E+c*b,s[1]=l*_+h*S+u*C,s[4]=l*m+h*v+u*A,s[7]=l*p+h*E+u*b,s[2]=d*_+f*S+g*C,s[5]=d*m+f*v+g*A,s[8]=d*p+f*E+g*b,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8];return t*a*h-t*o*l-n*s*h+n*o*c+i*s*l-i*a*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=h*a-o*l,d=o*c-h*s,f=l*s-a*c,g=t*u+n*d+i*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/g;return e[0]=u*_,e[1]=(i*l-h*n)*_,e[2]=(o*n-i*a)*_,e[3]=d*_,e[4]=(h*t-i*c)*_,e[5]=(i*s-o*t)*_,e[6]=f*_,e[7]=(n*c-l*t)*_,e[8]=(a*t-n*s)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,a,o){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-i*l,i*c,-i*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(mr.makeScale(e,t)),this}rotate(e){return this.premultiply(mr.makeRotation(-e)),this}translate(e,t){return this.premultiply(mr.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const mr=new Ue;function Qc(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}function ss(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function cu(){const r=ss("canvas");return r.style.display="block",r}const To={};function el(r){r in To||(To[r]=!0,console.warn(r))}const Ao=new Ue().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),bo=new Ue().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ds={[xt]:{transfer:Ks,primaries:Js,toReference:r=>r,fromReference:r=>r},[wt]:{transfer:Qe,primaries:Js,toReference:r=>r.convertSRGBToLinear(),fromReference:r=>r.convertLinearToSRGB()},[tr]:{transfer:Ks,primaries:$s,toReference:r=>r.applyMatrix3(bo),fromReference:r=>r.applyMatrix3(Ao)},[xa]:{transfer:Qe,primaries:$s,toReference:r=>r.convertSRGBToLinear().applyMatrix3(bo),fromReference:r=>r.applyMatrix3(Ao).convertLinearToSRGB()}},lu=new Set([xt,tr]),qe={enabled:!0,_workingColorSpace:xt,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(r){if(!lu.has(r))throw new Error(`Unsupported working color space, "${r}".`);this._workingColorSpace=r},convert:function(r,e,t){if(this.enabled===!1||e===t||!e||!t)return r;const n=ds[e].toReference,i=ds[t].fromReference;return i(n(r))},fromWorkingColorSpace:function(r,e){return this.convert(r,this._workingColorSpace,e)},toWorkingColorSpace:function(r,e){return this.convert(r,e,this._workingColorSpace)},getPrimaries:function(r){return ds[r].primaries},getTransfer:function(r){return r===Tn?Ks:ds[r].transfer}};function Ti(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function gr(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Zn;class tl{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Zn===void 0&&(Zn=ss("canvas")),Zn.width=e.width,Zn.height=e.height;const n=Zn.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Zn}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=ss("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let a=0;a<s.length;a++)s[a]=Ti(s[a]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Ti(t[n]/255)*255):t[n]=Ti(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let hu=0;class nl{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:hu++}),this.uuid=Yt(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(_r(i[a].image)):s.push(_r(i[a]))}else s=_r(i);n.url=s}return t||(e.images[this.uuid]=n),n}}function _r(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?tl.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let uu=0;class lt extends Jn{constructor(e=lt.DEFAULT_IMAGE,t=lt.DEFAULT_MAPPING,n=zt,i=zt,s=Et,a=dn,o=Ht,c=Cn,l=lt.DEFAULT_ANISOTROPY,h=Tn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:uu++}),this.uuid=Yt(),this.name="",this.source=new nl(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new re(0,0),this.repeat=new re(1,1),this.center=new re(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ue,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}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(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,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,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==kc)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ri:e.x=e.x-Math.floor(e.x);break;case zt:e.x=e.x<0?0:1;break;case Ys:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ri:e.y=e.y-Math.floor(e.y);break;case zt:e.y=e.y<0?0:1;break;case Ys:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}}lt.DEFAULT_IMAGE=null;lt.DEFAULT_MAPPING=kc;lt.DEFAULT_ANISOTROPY=1;class Ke{constructor(e=0,t=0,n=0,i=1){Ke.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){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: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s;const c=e.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],g=c[9],_=c[2],m=c[6],p=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-_)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+_)<.1&&Math.abs(g+m)<.1&&Math.abs(l+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const v=(l+1)/2,E=(f+1)/2,C=(p+1)/2,A=(h+d)/4,b=(u+_)/4,D=(g+m)/4;return v>E&&v>C?v<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(v),i=A/n,s=b/n):E>C?E<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(E),n=A/i,s=D/i):C<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(C),n=b/s,i=D/s),this.set(n,i,s,t),this}let S=Math.sqrt((m-g)*(m-g)+(u-_)*(u-_)+(d-h)*(d-h));return Math.abs(S)<.001&&(S=1),this.x=(m-g)/S,this.y=(u-_)/S,this.z=(d-h)/S,this.w=Math.acos((l+f+p-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class du extends Jn{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Ke(0,0,e,t),this.scissorTest=!1,this.viewport=new Ke(0,0,e,t);const i={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Et,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0,count:1},n);const s=new lt(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,i=e.textures.length;n<i;n++)this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new nl(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class jn extends du{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class il extends lt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=pt,this.minFilter=pt,this.wrapR=zt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class fu extends lt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=pt,this.minFilter=pt,this.wrapR=zt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class jt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,a,o){let c=n[i+0],l=n[i+1],h=n[i+2],u=n[i+3];const d=s[a+0],f=s[a+1],g=s[a+2],_=s[a+3];if(o===0){e[t+0]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=g,e[t+3]=_;return}if(u!==_||c!==d||l!==f||h!==g){let m=1-o;const p=c*d+l*f+h*g+u*_,S=p>=0?1:-1,v=1-p*p;if(v>Number.EPSILON){const C=Math.sqrt(v),A=Math.atan2(C,p*S);m=Math.sin(m*A)/C,o=Math.sin(o*A)/C}const E=o*S;if(c=c*m+d*E,l=l*m+f*E,h=h*m+g*E,u=u*m+_*E,m===1-o){const C=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=C,l*=C,h*=C,u*=C}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,s,a){const o=n[i],c=n[i+1],l=n[i+2],h=n[i+3],u=s[a],d=s[a+1],f=s[a+2],g=s[a+3];return e[t]=o*g+h*u+c*f-l*d,e[t+1]=c*g+h*d+l*u-o*f,e[t+2]=l*g+h*f+o*d-c*u,e[t+3]=h*g-o*u-c*d-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(i/2),u=o(s/2),d=c(n/2),f=c(i/2),g=c(s/2);switch(a){case"XYZ":this._x=d*h*u+l*f*g,this._y=l*f*u-d*h*g,this._z=l*h*g+d*f*u,this._w=l*h*u-d*f*g;break;case"YXZ":this._x=d*h*u+l*f*g,this._y=l*f*u-d*h*g,this._z=l*h*g-d*f*u,this._w=l*h*u+d*f*g;break;case"ZXY":this._x=d*h*u-l*f*g,this._y=l*f*u+d*h*g,this._z=l*h*g+d*f*u,this._w=l*h*u-d*f*g;break;case"ZYX":this._x=d*h*u-l*f*g,this._y=l*f*u+d*h*g,this._z=l*h*g-d*f*u,this._w=l*h*u+d*f*g;break;case"YZX":this._x=d*h*u+l*f*g,this._y=l*f*u+d*h*g,this._z=l*h*g-d*f*u,this._w=l*h*u-d*f*g;break;case"XZY":this._x=d*h*u-l*f*g,this._y=l*f*u-d*h*g,this._z=l*h*g+d*f*u,this._w=l*h*u+d*f*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],a=t[1],o=t[5],c=t[9],l=t[2],h=t[6],u=t[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(s-l)*f,this._z=(a-i)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(s+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(s-l)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-i)/f,this._x=(s+l)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ct(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,a=e._w,o=t._x,c=t._y,l=t._z,h=t._w;return this._x=n*h+a*o+i*l-s*c,this._y=i*h+a*c+s*o-n*l,this._z=s*h+a*l+n*c-i*o,this._w=a*h-n*o-i*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=s,this;const c=1-o*o;if(c<=Number.EPSILON){const f=1-t;return this._w=f*a+t*this._w,this._x=f*n+t*this._x,this._y=f*i+t*this._y,this._z=f*s+t*this._z,this.normalize(),this}const l=Math.sqrt(c),h=Math.atan2(l,o),u=Math.sin((1-t)*h)/l,d=Math.sin(t*h)/l;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=s*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class R{constructor(e=0,t=0,n=0){R.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(wo.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(wo.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*i-o*n),h=2*(o*t-s*i),u=2*(s*n-a*t);return this.x=t+c*l+a*u-o*h,this.y=n+c*h+o*l-s*u,this.z=i+c*u+s*h-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,s=e.z,a=t.x,o=t.y,c=t.z;return this.x=i*c-s*o,this.y=s*a-n*c,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return vr.copy(this).projectOnVector(e),this.sub(vr)}reflect(e){return this.sub(vr.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ct(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const vr=new R,wo=new jt;class Qt{constructor(e=new R(1/0,1/0,1/0),t=new R(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Gt.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Gt.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Gt.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Gt):Gt.fromBufferAttribute(s,a),Gt.applyMatrix4(e.matrixWorld),this.expandByPoint(Gt);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),fs.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),fs.copy(n.boundingBox)),fs.applyMatrix4(e.matrixWorld),this.union(fs)}const i=e.children;for(let s=0,a=i.length;s<a;s++)this.expandByObject(i[s],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Gt),Gt.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Hi),ps.subVectors(this.max,Hi),Qn.subVectors(e.a,Hi),ei.subVectors(e.b,Hi),ti.subVectors(e.c,Hi),gn.subVectors(ei,Qn),_n.subVectors(ti,ei),Nn.subVectors(Qn,ti);let t=[0,-gn.z,gn.y,0,-_n.z,_n.y,0,-Nn.z,Nn.y,gn.z,0,-gn.x,_n.z,0,-_n.x,Nn.z,0,-Nn.x,-gn.y,gn.x,0,-_n.y,_n.x,0,-Nn.y,Nn.x,0];return!xr(t,Qn,ei,ti,ps)||(t=[1,0,0,0,1,0,0,0,1],!xr(t,Qn,ei,ti,ps))?!1:(ms.crossVectors(gn,_n),t=[ms.x,ms.y,ms.z],xr(t,Qn,ei,ti,ps))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Gt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Gt).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(rn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),rn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),rn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),rn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),rn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),rn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),rn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),rn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(rn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const rn=[new R,new R,new R,new R,new R,new R,new R,new R],Gt=new R,fs=new Qt,Qn=new R,ei=new R,ti=new R,gn=new R,_n=new R,Nn=new R,Hi=new R,ps=new R,ms=new R,Dn=new R;function xr(r,e,t,n,i){for(let s=0,a=r.length-3;s<=a;s+=3){Dn.fromArray(r,s);const o=i.x*Math.abs(Dn.x)+i.y*Math.abs(Dn.y)+i.z*Math.abs(Dn.z),c=e.dot(Dn),l=t.dot(Dn),h=n.dot(Dn);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const pu=new Qt,Gi=new R,Mr=new R;class en{constructor(e=new R,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):pu.setFromPoints(e).getCenter(n);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Gi.subVectors(e,this.center);const t=Gi.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Gi,i/n),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Mr.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Gi.copy(e.center).add(Mr)),this.expandByPoint(Gi.copy(e.center).sub(Mr))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const an=new R,yr=new R,gs=new R,vn=new R,Sr=new R,_s=new R,Er=new R;class as{constructor(e=new R,t=new R(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,an)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=an.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(an.copy(this.origin).addScaledVector(this.direction,t),an.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){yr.copy(e).add(t).multiplyScalar(.5),gs.copy(t).sub(e).normalize(),vn.copy(this.origin).sub(yr);const s=e.distanceTo(t)*.5,a=-this.direction.dot(gs),o=vn.dot(this.direction),c=-vn.dot(gs),l=vn.lengthSq(),h=Math.abs(1-a*a);let u,d,f,g;if(h>0)if(u=a*c-o,d=a*o-c,g=s*h,u>=0)if(d>=-g)if(d<=g){const _=1/h;u*=_,d*=_,f=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d=-s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-g?(u=Math.max(0,-(-a*s+o)),d=u>0?-s:Math.min(Math.max(-s,-c),s),f=-u*u+d*(d+2*c)+l):d<=g?(u=0,d=Math.min(Math.max(-s,-c),s),f=d*(d+2*c)+l):(u=Math.max(0,-(a*s+o)),d=u>0?s:Math.min(Math.max(-s,-c),s),f=-u*u+d*(d+2*c)+l);else d=a>0?-s:s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(yr).addScaledVector(gs,d),f}intersectSphere(e,t){an.subVectors(e.center,this.origin);const n=an.dot(this.direction),i=an.dot(an)-n*n,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,a,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),h>=0?(s=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(s=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),n>a||s>i||((s>n||isNaN(n))&&(n=s),(a<i||isNaN(i))&&(i=a),u>=0?(o=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,c=(e.min.z-d.z)*u),n>c||o>i)||((o>n||n!==n)&&(n=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,an)!==null}intersectTriangle(e,t,n,i,s){Sr.subVectors(t,e),_s.subVectors(n,e),Er.crossVectors(Sr,_s);let a=this.direction.dot(Er),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;vn.subVectors(this.origin,e);const c=o*this.direction.dot(_s.crossVectors(vn,_s));if(c<0)return null;const l=o*this.direction.dot(Sr.cross(vn));if(l<0||c+l>a)return null;const h=-o*vn.dot(Er);return h<0?null:this.at(h/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class be{constructor(e,t,n,i,s,a,o,c,l,h,u,d,f,g,_,m){be.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,c,l,h,u,d,f,g,_,m)}set(e,t,n,i,s,a,o,c,l,h,u,d,f,g,_,m){const p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=s,p[5]=a,p[9]=o,p[13]=c,p[2]=l,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=g,p[11]=_,p[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 be().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/ni.setFromMatrixColumn(e,0).length(),s=1/ni.setFromMatrixColumn(e,1).length(),a=1/ni.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){const d=a*h,f=a*u,g=o*h,_=o*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=f+g*l,t[5]=d-_*l,t[9]=-o*c,t[2]=_-d*l,t[6]=g+f*l,t[10]=a*c}else if(e.order==="YXZ"){const d=c*h,f=c*u,g=l*h,_=l*u;t[0]=d+_*o,t[4]=g*o-f,t[8]=a*l,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=f*o-g,t[6]=_+d*o,t[10]=a*c}else if(e.order==="ZXY"){const d=c*h,f=c*u,g=l*h,_=l*u;t[0]=d-_*o,t[4]=-a*u,t[8]=g+f*o,t[1]=f+g*o,t[5]=a*h,t[9]=_-d*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const d=a*h,f=a*u,g=o*h,_=o*u;t[0]=c*h,t[4]=g*l-f,t[8]=d*l+_,t[1]=c*u,t[5]=_*l+d,t[9]=f*l-g,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const d=a*c,f=a*l,g=o*c,_=o*l;t[0]=c*h,t[4]=_-d*u,t[8]=g*u+f,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-l*h,t[6]=f*u+g,t[10]=d-_*u}else if(e.order==="XZY"){const d=a*c,f=a*l,g=o*c,_=o*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=d*u+_,t[5]=a*h,t[9]=f*u-g,t[2]=g*u-f,t[6]=o*h,t[10]=_*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(mu,e,gu)}lookAt(e,t,n){const i=this.elements;return Pt.subVectors(e,t),Pt.lengthSq()===0&&(Pt.z=1),Pt.normalize(),xn.crossVectors(n,Pt),xn.lengthSq()===0&&(Math.abs(n.z)===1?Pt.x+=1e-4:Pt.z+=1e-4,Pt.normalize(),xn.crossVectors(n,Pt)),xn.normalize(),vs.crossVectors(Pt,xn),i[0]=xn.x,i[4]=vs.x,i[8]=Pt.x,i[1]=xn.y,i[5]=vs.y,i[9]=Pt.y,i[2]=xn.z,i[6]=vs.z,i[10]=Pt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],f=n[13],g=n[2],_=n[6],m=n[10],p=n[14],S=n[3],v=n[7],E=n[11],C=n[15],A=i[0],b=i[4],D=i[8],k=i[12],M=i[1],w=i[5],j=i[9],K=i[13],L=i[2],V=i[6],G=i[10],Y=i[14],W=i[3],X=i[7],ee=i[11],ie=i[15];return s[0]=a*A+o*M+c*L+l*W,s[4]=a*b+o*w+c*V+l*X,s[8]=a*D+o*j+c*G+l*ee,s[12]=a*k+o*K+c*Y+l*ie,s[1]=h*A+u*M+d*L+f*W,s[5]=h*b+u*w+d*V+f*X,s[9]=h*D+u*j+d*G+f*ee,s[13]=h*k+u*K+d*Y+f*ie,s[2]=g*A+_*M+m*L+p*W,s[6]=g*b+_*w+m*V+p*X,s[10]=g*D+_*j+m*G+p*ee,s[14]=g*k+_*K+m*Y+p*ie,s[3]=S*A+v*M+E*L+C*W,s[7]=S*b+v*w+E*V+C*X,s[11]=S*D+v*j+E*G+C*ee,s[15]=S*k+v*K+E*Y+C*ie,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],a=e[1],o=e[5],c=e[9],l=e[13],h=e[2],u=e[6],d=e[10],f=e[14],g=e[3],_=e[7],m=e[11],p=e[15];return g*(+s*c*u-i*l*u-s*o*d+n*l*d+i*o*f-n*c*f)+_*(+t*c*f-t*l*d+s*a*d-i*a*f+i*l*h-s*c*h)+m*(+t*l*u-t*o*f-s*a*u+n*a*f+s*o*h-n*l*h)+p*(-i*o*h-t*c*u+t*o*d+i*a*u-n*a*d+n*c*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=e[9],d=e[10],f=e[11],g=e[12],_=e[13],m=e[14],p=e[15],S=u*m*l-_*d*l+_*c*f-o*m*f-u*c*p+o*d*p,v=g*d*l-h*m*l-g*c*f+a*m*f+h*c*p-a*d*p,E=h*_*l-g*u*l+g*o*f-a*_*f-h*o*p+a*u*p,C=g*u*c-h*_*c-g*o*d+a*_*d+h*o*m-a*u*m,A=t*S+n*v+i*E+s*C;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/A;return e[0]=S*b,e[1]=(_*d*s-u*m*s-_*i*f+n*m*f+u*i*p-n*d*p)*b,e[2]=(o*m*s-_*c*s+_*i*l-n*m*l-o*i*p+n*c*p)*b,e[3]=(u*c*s-o*d*s-u*i*l+n*d*l+o*i*f-n*c*f)*b,e[4]=v*b,e[5]=(h*m*s-g*d*s+g*i*f-t*m*f-h*i*p+t*d*p)*b,e[6]=(g*c*s-a*m*s-g*i*l+t*m*l+a*i*p-t*c*p)*b,e[7]=(a*d*s-h*c*s+h*i*l-t*d*l-a*i*f+t*c*f)*b,e[8]=E*b,e[9]=(g*u*s-h*_*s-g*n*f+t*_*f+h*n*p-t*u*p)*b,e[10]=(a*_*s-g*o*s+g*n*l-t*_*l-a*n*p+t*o*p)*b,e[11]=(h*o*s-a*u*s-h*n*l+t*u*l+a*n*f-t*o*f)*b,e[12]=C*b,e[13]=(h*_*i-g*u*i+g*n*d-t*_*d-h*n*m+t*u*m)*b,e[14]=(g*o*i-a*_*i-g*n*c+t*_*c+a*n*m-t*o*m)*b,e[15]=(a*u*i-h*o*i+h*n*c-t*u*c-a*n*d+t*o*d)*b,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,a=e.x,o=e.y,c=e.z,l=s*a,h=s*o;return this.set(l*a+n,l*o-i*c,l*c+i*o,0,l*o+i*c,h*o+n,h*c-i*a,0,l*c-i*o,h*c+i*a,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,a){return this.set(1,n,s,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,a=t._y,o=t._z,c=t._w,l=s+s,h=a+a,u=o+o,d=s*l,f=s*h,g=s*u,_=a*h,m=a*u,p=o*u,S=c*l,v=c*h,E=c*u,C=n.x,A=n.y,b=n.z;return i[0]=(1-(_+p))*C,i[1]=(f+E)*C,i[2]=(g-v)*C,i[3]=0,i[4]=(f-E)*A,i[5]=(1-(d+p))*A,i[6]=(m+S)*A,i[7]=0,i[8]=(g+v)*b,i[9]=(m-S)*b,i[10]=(1-(d+_))*b,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=ni.set(i[0],i[1],i[2]).length();const a=ni.set(i[4],i[5],i[6]).length(),o=ni.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],kt.copy(this);const l=1/s,h=1/a,u=1/o;return kt.elements[0]*=l,kt.elements[1]*=l,kt.elements[2]*=l,kt.elements[4]*=h,kt.elements[5]*=h,kt.elements[6]*=h,kt.elements[8]*=u,kt.elements[9]*=u,kt.elements[10]*=u,t.setFromRotationMatrix(kt),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,a,o=fn){const c=this.elements,l=2*s/(t-e),h=2*s/(n-i),u=(t+e)/(t-e),d=(n+i)/(n-i);let f,g;if(o===fn)f=-(a+s)/(a-s),g=-2*a*s/(a-s);else if(o===Zs)f=-a/(a-s),g=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=h,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,s,a,o=fn){const c=this.elements,l=1/(t-e),h=1/(n-i),u=1/(a-s),d=(t+e)*l,f=(n+i)*h;let g,_;if(o===fn)g=(a+s)*u,_=-2*u;else if(o===Zs)g=s*u,_=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-d,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-f,c[2]=0,c[6]=0,c[10]=_,c[14]=-g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const ni=new R,kt=new be,mu=new R(0,0,0),gu=new R(1,1,1),xn=new R,vs=new R,Pt=new R,Ro=new be,Co=new jt;class Kt{constructor(e=0,t=0,n=0,i=Kt.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],c=i[1],l=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(ct(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ct(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(ct(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-ct(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(ct(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-ct(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Ro.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ro,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Co.setFromEuler(this),this.setFromQuaternion(Co,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Kt.DEFAULT_ORDER="XYZ";class ya{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let _u=0;const Lo=new R,ii=new jt,on=new be,xs=new R,ki=new R,vu=new R,xu=new jt,Po=new R(1,0,0),Io=new R(0,1,0),No=new R(0,0,1),Mu={type:"added"},yu={type:"removed"},Tr={type:"childadded",child:null},Ar={type:"childremoved",child:null};class et extends Jn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:_u++}),this.uuid=Yt(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=et.DEFAULT_UP.clone();const e=new R,t=new Kt,n=new jt,i=new R(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new be},normalMatrix:{value:new Ue}}),this.matrix=new be,this.matrixWorld=new be,this.matrixAutoUpdate=et.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=et.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ya,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return ii.setFromAxisAngle(e,t),this.quaternion.multiply(ii),this}rotateOnWorldAxis(e,t){return ii.setFromAxisAngle(e,t),this.quaternion.premultiply(ii),this}rotateX(e){return this.rotateOnAxis(Po,e)}rotateY(e){return this.rotateOnAxis(Io,e)}rotateZ(e){return this.rotateOnAxis(No,e)}translateOnAxis(e,t){return Lo.copy(e).applyQuaternion(this.quaternion),this.position.add(Lo.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Po,e)}translateY(e){return this.translateOnAxis(Io,e)}translateZ(e){return this.translateOnAxis(No,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(on.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?xs.copy(e):xs.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),ki.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?on.lookAt(ki,xs,this.up):on.lookAt(xs,ki,this.up),this.quaternion.setFromRotationMatrix(on),i&&(on.extractRotation(i.matrixWorld),ii.setFromRotationMatrix(on),this.quaternion.premultiply(ii.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(Mu),Tr.child=e,this.dispatchEvent(Tr),Tr.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(yu),Ar.child=e,this.dispatchEvent(Ar),Ar.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),on.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),on.multiply(e.parent.matrixWorld)),e.applyMatrix4(on),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ki,e,vu),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ki,xu,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++){const s=t[n];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){const i=this.children;for(let s=0,a=i.length;s<a;s++){const o=i[s];o.matrixWorldAutoUpdate===!0&&o.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function s(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];s(e.shapes,u)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(s(e.materials,this.material[c]));i.material=o}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(s(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),f=a(e.animations),g=a(e.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=i,n;function a(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}et.DEFAULT_UP=new R(0,1,0);et.DEFAULT_MATRIX_AUTO_UPDATE=!0;et.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Vt=new R,cn=new R,br=new R,ln=new R,si=new R,ri=new R,Do=new R,wr=new R,Rr=new R,Cr=new R;class qt{constructor(e=new R,t=new R,n=new R){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Vt.subVectors(e,t),i.cross(Vt);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){Vt.subVectors(i,t),cn.subVectors(n,t),br.subVectors(e,t);const a=Vt.dot(Vt),o=Vt.dot(cn),c=Vt.dot(br),l=cn.dot(cn),h=cn.dot(br),u=a*l-o*o;if(u===0)return s.set(0,0,0),null;const d=1/u,f=(l*c-o*h)*d,g=(a*h-o*c)*d;return s.set(1-f-g,g,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,ln)===null?!1:ln.x>=0&&ln.y>=0&&ln.x+ln.y<=1}static getInterpolation(e,t,n,i,s,a,o,c){return this.getBarycoord(e,t,n,i,ln)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,ln.x),c.addScaledVector(a,ln.y),c.addScaledVector(o,ln.z),c)}static isFrontFacing(e,t,n,i){return Vt.subVectors(n,t),cn.subVectors(e,t),Vt.cross(cn).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Vt.subVectors(this.c,this.b),cn.subVectors(this.a,this.b),Vt.cross(cn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return qt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return qt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,s){return qt.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return qt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return qt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let a,o;si.subVectors(i,n),ri.subVectors(s,n),wr.subVectors(e,n);const c=si.dot(wr),l=ri.dot(wr);if(c<=0&&l<=0)return t.copy(n);Rr.subVectors(e,i);const h=si.dot(Rr),u=ri.dot(Rr);if(h>=0&&u<=h)return t.copy(i);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(n).addScaledVector(si,a);Cr.subVectors(e,s);const f=si.dot(Cr),g=ri.dot(Cr);if(g>=0&&f<=g)return t.copy(s);const _=f*l-c*g;if(_<=0&&l>=0&&g<=0)return o=l/(l-g),t.copy(n).addScaledVector(ri,o);const m=h*g-f*u;if(m<=0&&u-h>=0&&f-g>=0)return Do.subVectors(s,i),o=(u-h)/(u-h+(f-g)),t.copy(i).addScaledVector(Do,o);const p=1/(m+_+d);return a=_*p,o=d*p,t.copy(n).addScaledVector(si,a).addScaledVector(ri,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const sl={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},Mn={h:0,s:0,l:0},Ms={h:0,s:0,l:0};function Lr(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}class ve{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=wt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,qe.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=qe.workingColorSpace){return this.r=e,this.g=t,this.b=n,qe.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=qe.workingColorSpace){if(e=Ma(e,1),t=ct(t,0,1),n=ct(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=Lr(a,s,e+1/3),this.g=Lr(a,s,e),this.b=Lr(a,s,e-1/3)}return qe.toWorkingColorSpace(this,i),this}setStyle(e,t=wt){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=wt){const n=sl[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ti(e.r),this.g=Ti(e.g),this.b=Ti(e.b),this}copyLinearToSRGB(e){return this.r=gr(e.r),this.g=gr(e.g),this.b=gr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=wt){return qe.fromWorkingColorSpace(St.copy(this),e),Math.round(ct(St.r*255,0,255))*65536+Math.round(ct(St.g*255,0,255))*256+Math.round(ct(St.b*255,0,255))}getHexString(e=wt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=qe.workingColorSpace){qe.fromWorkingColorSpace(St.copy(this),t);const n=St.r,i=St.g,s=St.b,a=Math.max(n,i,s),o=Math.min(n,i,s);let c,l;const h=(o+a)/2;if(o===a)c=0,l=0;else{const u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case n:c=(i-s)/u+(i<s?6:0);break;case i:c=(s-n)/u+2;break;case s:c=(n-i)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=qe.workingColorSpace){return qe.fromWorkingColorSpace(St.copy(this),t),e.r=St.r,e.g=St.g,e.b=St.b,e}getStyle(e=wt){qe.fromWorkingColorSpace(St.copy(this),e);const t=St.r,n=St.g,i=St.b;return e!==wt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Mn),this.setHSL(Mn.h+e,Mn.s+t,Mn.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Mn),e.getHSL(Ms);const n=Zi(Mn.h,Ms.h,t),i=Zi(Mn.s,Ms.s,t),s=Zi(Mn.l,Ms.l,t);return this.setHSL(n,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*i,this.g=s[1]*t+s[4]*n+s[7]*i,this.b=s[2]*t+s[5]*n+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const St=new ve;ve.NAMES=sl;let Su=0;class Dt extends Jn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Su++}),this.uuid=Yt(),this.name="",this.type="Material",this.blending=Ei,this.side=pn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Zr,this.blendDst=Qr,this.blendEquation=kn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ve(0,0,0),this.blendAlpha=0,this.depthFunc=qs,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=yo,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=$n,this.stencilZFail=$n,this.stencilZPass=$n,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.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ei&&(n.blending=this.blending),this.side!==pn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Zr&&(n.blendSrc=this.blendSrc),this.blendDst!==Qr&&(n.blendDst=this.blendDst),this.blendEquation!==kn&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==qs&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==yo&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==$n&&(n.stencilFail=this.stencilFail),this.stencilZFail!==$n&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==$n&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const a=[];for(const o in s){const c=s[o];delete c.metadata,a.push(c)}return a}if(t){const s=i(e.textures),a=i(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Wn extends Dt{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ve(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.envMapRotation=new Kt,this.combine=ma,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ot=new R,ys=new re;class vt{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=sa,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Wt,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return el("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)ys.fromBufferAttribute(this,t),ys.applyMatrix3(e),this.setXY(t,ys.x,ys.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)ot.fromBufferAttribute(this,t),ot.applyMatrix3(e),this.setXYZ(t,ot.x,ot.y,ot.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)ot.fromBufferAttribute(this,t),ot.applyMatrix4(e),this.setXYZ(t,ot.x,ot.y,ot.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ot.fromBufferAttribute(this,t),ot.applyNormalMatrix(e),this.setXYZ(t,ot.x,ot.y,ot.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ot.fromBufferAttribute(this,t),ot.transformDirection(e),this.setXYZ(t,ot.x,ot.y,ot.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Xt(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=je(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Xt(t,this.array)),t}setX(e,t){return this.normalized&&(t=je(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Xt(t,this.array)),t}setY(e,t){return this.normalized&&(t=je(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Xt(t,this.array)),t}setZ(e,t){return this.normalized&&(t=je(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Xt(t,this.array)),t}setW(e,t){return this.normalized&&(t=je(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=je(t,this.array),n=je(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=je(t,this.array),n=je(n,this.array),i=je(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=je(t,this.array),n=je(n,this.array),i=je(i,this.array),s=je(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==sa&&(e.usage=this.usage),e}}class rl extends vt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class al extends vt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Ze extends vt{constructor(e,t,n){super(new Float32Array(e),t,n)}}let Eu=0;const Ft=new be,Pr=new et,ai=new R,It=new Qt,Vi=new Qt,ft=new R;class mt extends Jn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Eu++}),this.uuid=Yt(),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={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Qc(e)?al:rl)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new Ue().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ft.makeRotationFromQuaternion(e),this.applyMatrix4(Ft),this}rotateX(e){return Ft.makeRotationX(e),this.applyMatrix4(Ft),this}rotateY(e){return Ft.makeRotationY(e),this.applyMatrix4(Ft),this}rotateZ(e){return Ft.makeRotationZ(e),this.applyMatrix4(Ft),this}translate(e,t,n){return Ft.makeTranslation(e,t,n),this.applyMatrix4(Ft),this}scale(e,t,n){return Ft.makeScale(e,t,n),this.applyMatrix4(Ft),this}lookAt(e){return Pr.lookAt(e),Pr.updateMatrix(),this.applyMatrix4(Pr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ai).negate(),this.translate(ai.x,ai.y,ai.z),this}setFromPoints(e){const t=[];for(let n=0,i=e.length;n<i;n++){const s=e[n];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new Ze(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Qt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new R(-1/0,-1/0,-1/0),new R(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const s=t[n];It.setFromBufferAttribute(s),this.morphTargetsRelative?(ft.addVectors(this.boundingBox.min,It.min),this.boundingBox.expandByPoint(ft),ft.addVectors(this.boundingBox.max,It.max),this.boundingBox.expandByPoint(ft)):(this.boundingBox.expandByPoint(It.min),this.boundingBox.expandByPoint(It.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(){this.boundingSphere===null&&(this.boundingSphere=new en);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new R,1/0);return}if(e){const n=this.boundingSphere.center;if(It.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Vi.setFromBufferAttribute(o),this.morphTargetsRelative?(ft.addVectors(It.min,Vi.min),It.expandByPoint(ft),ft.addVectors(It.max,Vi.max),It.expandByPoint(ft)):(It.expandByPoint(Vi.min),It.expandByPoint(Vi.max))}It.getCenter(n);let i=0;for(let s=0,a=e.count;s<a;s++)ft.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(ft));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)ft.fromBufferAttribute(o,l),c&&(ai.fromBufferAttribute(e,l),ft.add(ai)),i=Math.max(i,n.distanceToSquared(ft))}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)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new vt(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],c=[];for(let D=0;D<n.count;D++)o[D]=new R,c[D]=new R;const l=new R,h=new R,u=new R,d=new re,f=new re,g=new re,_=new R,m=new R;function p(D,k,M){l.fromBufferAttribute(n,D),h.fromBufferAttribute(n,k),u.fromBufferAttribute(n,M),d.fromBufferAttribute(s,D),f.fromBufferAttribute(s,k),g.fromBufferAttribute(s,M),h.sub(l),u.sub(l),f.sub(d),g.sub(d);const w=1/(f.x*g.y-g.x*f.y);isFinite(w)&&(_.copy(h).multiplyScalar(g.y).addScaledVector(u,-f.y).multiplyScalar(w),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(w),o[D].add(_),o[k].add(_),o[M].add(_),c[D].add(m),c[k].add(m),c[M].add(m))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let D=0,k=S.length;D<k;++D){const M=S[D],w=M.start,j=M.count;for(let K=w,L=w+j;K<L;K+=3)p(e.getX(K+0),e.getX(K+1),e.getX(K+2))}const v=new R,E=new R,C=new R,A=new R;function b(D){C.fromBufferAttribute(i,D),A.copy(C);const k=o[D];v.copy(k),v.sub(C.multiplyScalar(C.dot(k))).normalize(),E.crossVectors(A,k);const w=E.dot(c[D])<0?-1:1;a.setXYZW(D,v.x,v.y,v.z,w)}for(let D=0,k=S.length;D<k;++D){const M=S[D],w=M.start,j=M.count;for(let K=w,L=w+j;K<L;K+=3)b(e.getX(K+0)),b(e.getX(K+1)),b(e.getX(K+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new vt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new R,s=new R,a=new R,o=new R,c=new R,l=new R,h=new R,u=new R;if(e)for(let d=0,f=e.count;d<f;d+=3){const g=e.getX(d+0),_=e.getX(d+1),m=e.getX(d+2);i.fromBufferAttribute(t,g),s.fromBufferAttribute(t,_),a.fromBufferAttribute(t,m),h.subVectors(a,s),u.subVectors(i,s),h.cross(u),o.fromBufferAttribute(n,g),c.fromBufferAttribute(n,_),l.fromBufferAttribute(n,m),o.add(h),c.add(h),l.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(_,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),h.subVectors(a,s),u.subVectors(i,s),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)ft.fromBufferAttribute(e,t),ft.normalize(),e.setXYZ(t,ft.x,ft.y,ft.z)}toNonIndexed(){function e(o,c){const l=o.array,h=o.itemSize,u=o.normalized,d=new l.constructor(c.length*h);let f=0,g=0;for(let _=0,m=c.length;_<m;_++){o.isInterleavedBufferAttribute?f=c[_]*o.data.stride+o.offset:f=c[_]*h;for(let p=0;p<h;p++)d[g++]=l[f++]}return new vt(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new mt,n=this.index.array,i=this.attributes;for(const o in i){const c=i[o],l=e(c,n);t.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const c=[],l=s[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=e(d,n);c.push(f)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(e.data))}h.length>0&&(i[c]=h,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const l in i){const h=i[l];this.setAttribute(l,h.clone(t))}const s=e.morphAttributes;for(const l in s){const h=[],u=s[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,h=a.length;l<h;l++){const u=a[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Uo=new be,Un=new as,Ss=new en,Oo=new R,oi=new R,ci=new R,li=new R,Ir=new R,Es=new R,Ts=new re,As=new re,bs=new re,Fo=new R,Bo=new R,zo=new R,ws=new R,Rs=new R;class Nt extends et{constructor(e=new mt,t=new Wn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){Es.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const h=o[c],u=s[c];h!==0&&(Ir.fromBufferAttribute(u,e),a?Es.addScaledVector(Ir,h):Es.addScaledVector(Ir.sub(t),h))}t.add(Es)}return t}raycast(e,t){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Ss.copy(n.boundingSphere),Ss.applyMatrix4(s),Un.copy(e.ray).recast(e.near),!(Ss.containsPoint(Un.origin)===!1&&(Un.intersectSphere(Ss,Oo)===null||Un.origin.distanceToSquared(Oo)>(e.far-e.near)**2))&&(Uo.copy(s).invert(),Un.copy(e.ray).applyMatrix4(Uo),!(n.boundingBox!==null&&Un.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Un)))}_computeIntersections(e,t,n){let i;const s=this.geometry,a=this.material,o=s.index,c=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,_=d.length;g<_;g++){const m=d[g],p=a[m.materialIndex],S=Math.max(m.start,f.start),v=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let E=S,C=v;E<C;E+=3){const A=o.getX(E),b=o.getX(E+1),D=o.getX(E+2);i=Cs(this,p,e,n,l,h,u,A,b,D),i&&(i.faceIndex=Math.floor(E/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const g=Math.max(0,f.start),_=Math.min(o.count,f.start+f.count);for(let m=g,p=_;m<p;m+=3){const S=o.getX(m),v=o.getX(m+1),E=o.getX(m+2);i=Cs(this,a,e,n,l,h,u,S,v,E),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}else if(c!==void 0)if(Array.isArray(a))for(let g=0,_=d.length;g<_;g++){const m=d[g],p=a[m.materialIndex],S=Math.max(m.start,f.start),v=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let E=S,C=v;E<C;E+=3){const A=E,b=E+1,D=E+2;i=Cs(this,p,e,n,l,h,u,A,b,D),i&&(i.faceIndex=Math.floor(E/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const g=Math.max(0,f.start),_=Math.min(c.count,f.start+f.count);for(let m=g,p=_;m<p;m+=3){const S=m,v=m+1,E=m+2;i=Cs(this,a,e,n,l,h,u,S,v,E),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}}}function Tu(r,e,t,n,i,s,a,o){let c;if(e.side===Ct?c=n.intersectTriangle(a,s,i,!0,o):c=n.intersectTriangle(i,s,a,e.side===pn,o),c===null)return null;Rs.copy(o),Rs.applyMatrix4(r.matrixWorld);const l=t.ray.origin.distanceTo(Rs);return l<t.near||l>t.far?null:{distance:l,point:Rs.clone(),object:r}}function Cs(r,e,t,n,i,s,a,o,c,l){r.getVertexPosition(o,oi),r.getVertexPosition(c,ci),r.getVertexPosition(l,li);const h=Tu(r,e,t,n,oi,ci,li,ws);if(h){i&&(Ts.fromBufferAttribute(i,o),As.fromBufferAttribute(i,c),bs.fromBufferAttribute(i,l),h.uv=qt.getInterpolation(ws,oi,ci,li,Ts,As,bs,new re)),s&&(Ts.fromBufferAttribute(s,o),As.fromBufferAttribute(s,c),bs.fromBufferAttribute(s,l),h.uv1=qt.getInterpolation(ws,oi,ci,li,Ts,As,bs,new re)),a&&(Fo.fromBufferAttribute(a,o),Bo.fromBufferAttribute(a,c),zo.fromBufferAttribute(a,l),h.normal=qt.getInterpolation(ws,oi,ci,li,Fo,Bo,zo,new R),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:c,c:l,normal:new R,materialIndex:0};qt.getNormal(oi,ci,li,u.normal),h.face=u}return h}class os extends mt{constructor(e=1,t=1,n=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const c=[],l=[],h=[],u=[];let d=0,f=0;g("z","y","x",-1,-1,n,t,e,a,s,0),g("z","y","x",1,-1,n,t,-e,a,s,1),g("x","z","y",1,1,e,n,t,i,a,2),g("x","z","y",1,-1,e,n,-t,i,a,3),g("x","y","z",1,-1,e,t,n,i,s,4),g("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(c),this.setAttribute("position",new Ze(l,3)),this.setAttribute("normal",new Ze(h,3)),this.setAttribute("uv",new Ze(u,2));function g(_,m,p,S,v,E,C,A,b,D,k){const M=E/b,w=C/D,j=E/2,K=C/2,L=A/2,V=b+1,G=D+1;let Y=0,W=0;const X=new R;for(let ee=0;ee<G;ee++){const ie=ee*w-K;for(let ue=0;ue<V;ue++){const Le=ue*M-j;X[_]=Le*S,X[m]=ie*v,X[p]=L,l.push(X.x,X.y,X.z),X[_]=0,X[m]=0,X[p]=A>0?1:-1,h.push(X.x,X.y,X.z),u.push(ue/b),u.push(1-ee/D),Y+=1}}for(let ee=0;ee<D;ee++)for(let ie=0;ie<b;ie++){const ue=d+ie+V*ee,Le=d+ie+V*(ee+1),z=d+(ie+1)+V*(ee+1),$=d+(ie+1)+V*ee;c.push(ue,Le,$),c.push(Le,z,$),W+=6}o.addGroup(f,W,k),f+=W,d+=Y}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new os(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Ii(r){const e={};for(const t in r){e[t]={};for(const n in r[t]){const i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function bt(r){const e={};for(let t=0;t<r.length;t++){const n=Ii(r[t]);for(const i in n)e[i]=n[i]}return e}function Au(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function ol(r){return r.getRenderTarget()===null?r.outputColorSpace:qe.workingColorSpace}const bu={clone:Ii,merge:bt};var wu=`void main() {
6
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
7
+ }`,Ru=`void main() {
8
+ gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
9
+ }`;class Ln extends Dt{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=wu,this.fragmentShader=Ru,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1,clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ii(e.uniforms),this.uniformsGroups=Au(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?t.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[i]={type:"m4",value:a.toArray()}:t.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class cl extends et{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new be,this.projectionMatrix=new be,this.projectionMatrixInverse=new be,this.coordinateSystem=fn}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const yn=new R,Ho=new re,Go=new re;class Rt extends cl{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Pi*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan($i*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Pi*2*Math.atan(Math.tan($i*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){yn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(yn.x,yn.y).multiplyScalar(-e/yn.z),yn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(yn.x,yn.y).multiplyScalar(-e/yn.z)}getViewSize(e,t){return this.getViewBounds(e,Ho,Go),t.subVectors(Go,Ho)}setViewOffset(e,t,n,i,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan($i*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;s+=a.offsetX*i/c,t-=a.offsetY*n/l,i*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const hi=-90,ui=1;class Cu extends et{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Rt(hi,ui,e,t);i.layers=this.layers,this.add(i);const s=new Rt(hi,ui,e,t);s.layers=this.layers,this.add(s);const a=new Rt(hi,ui,e,t);a.layers=this.layers,this.add(a);const o=new Rt(hi,ui,e,t);o.layers=this.layers,this.add(o);const c=new Rt(hi,ui,e,t);c.layers=this.layers,this.add(c);const l=new Rt(hi,ui,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,s,a,o,c]=t;for(const l of t)this.remove(l);if(e===fn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Zs)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,c,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,s),e.setRenderTarget(n,1,i),e.render(t,a),e.setRenderTarget(n,2,i),e.render(t,o),e.setRenderTarget(n,3,i),e.render(t,c),e.setRenderTarget(n,4,i),e.render(t,l),n.texture.generateMipmaps=_,e.setRenderTarget(n,5,i),e.render(t,h),e.setRenderTarget(u,d,f),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class ll extends lt{constructor(e,t,n,i,s,a,o,c,l,h){e=e!==void 0?e:[],t=t!==void 0?t:bi,super(e,t,n,i,s,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Lu extends jn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new ll(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Et}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
10
+
11
+ varying vec3 vWorldDirection;
12
+
13
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
14
+
15
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
16
+
17
+ }
18
+
19
+ void main() {
20
+
21
+ vWorldDirection = transformDirection( position, modelMatrix );
22
+
23
+ #include <begin_vertex>
24
+ #include <project_vertex>
25
+
26
+ }
27
+ `,fragmentShader:`
28
+
29
+ uniform sampler2D tEquirect;
30
+
31
+ varying vec3 vWorldDirection;
32
+
33
+ #include <common>
34
+
35
+ void main() {
36
+
37
+ vec3 direction = normalize( vWorldDirection );
38
+
39
+ vec2 sampleUV = equirectUv( direction );
40
+
41
+ gl_FragColor = texture2D( tEquirect, sampleUV );
42
+
43
+ }
44
+ `},i=new os(5,5,5),s=new Ln({name:"CubemapFromEquirect",uniforms:Ii(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ct,blending:wn});s.uniforms.tEquirect.value=t;const a=new Nt(i,s),o=t.minFilter;return t.minFilter===dn&&(t.minFilter=Et),new Cu(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,i){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(s)}}const Nr=new R,Pu=new R,Iu=new Ue;class Hn{constructor(e=new R(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=Nr.subVectors(n,t).cross(Pu.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(Nr),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Iu.getNormalMatrix(e),i=this.coplanarPoint(Nr).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const On=new en,Ls=new R;class Sa{constructor(e=new Hn,t=new Hn,n=new Hn,i=new Hn,s=new Hn,a=new Hn){this.planes=[e,t,n,i,s,a]}set(e,t,n,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=fn){const n=this.planes,i=e.elements,s=i[0],a=i[1],o=i[2],c=i[3],l=i[4],h=i[5],u=i[6],d=i[7],f=i[8],g=i[9],_=i[10],m=i[11],p=i[12],S=i[13],v=i[14],E=i[15];if(n[0].setComponents(c-s,d-l,m-f,E-p).normalize(),n[1].setComponents(c+s,d+l,m+f,E+p).normalize(),n[2].setComponents(c+a,d+h,m+g,E+S).normalize(),n[3].setComponents(c-a,d-h,m-g,E-S).normalize(),n[4].setComponents(c-o,d-u,m-_,E-v).normalize(),t===fn)n[5].setComponents(c+o,d+u,m+_,E+v).normalize();else if(t===Zs)n[5].setComponents(o,u,_,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),On.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),On.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(On)}intersectsSprite(e){return On.center.set(0,0,0),On.radius=.7071067811865476,On.applyMatrix4(e.matrixWorld),this.intersectsSphere(On)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(Ls.x=i.normal.x>0?e.max.x:e.min.x,Ls.y=i.normal.y>0?e.max.y:e.min.y,Ls.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ls)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function hl(){let r=null,e=!1,t=null,n=null;function i(s,a){t(s,a),n=r.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(i),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function Nu(r,e){const t=e.isWebGL2,n=new WeakMap;function i(l,h){const u=l.array,d=l.usage,f=u.byteLength,g=r.createBuffer();r.bindBuffer(h,g),r.bufferData(h,u,d),l.onUploadCallback();let _;if(u instanceof Float32Array)_=r.FLOAT;else if(u instanceof Uint16Array)if(l.isFloat16BufferAttribute)if(t)_=r.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else _=r.UNSIGNED_SHORT;else if(u instanceof Int16Array)_=r.SHORT;else if(u instanceof Uint32Array)_=r.UNSIGNED_INT;else if(u instanceof Int32Array)_=r.INT;else if(u instanceof Int8Array)_=r.BYTE;else if(u instanceof Uint8Array)_=r.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)_=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:g,type:_,bytesPerElement:u.BYTES_PER_ELEMENT,version:l.version,size:f}}function s(l,h,u){const d=h.array,f=h._updateRange,g=h.updateRanges;if(r.bindBuffer(u,l),f.count===-1&&g.length===0&&r.bufferSubData(u,0,d),g.length!==0){for(let _=0,m=g.length;_<m;_++){const p=g[_];t?r.bufferSubData(u,p.start*d.BYTES_PER_ELEMENT,d,p.start,p.count):r.bufferSubData(u,p.start*d.BYTES_PER_ELEMENT,d.subarray(p.start,p.start+p.count))}h.clearUpdateRanges()}f.count!==-1&&(t?r.bufferSubData(u,f.offset*d.BYTES_PER_ELEMENT,d,f.offset,f.count):r.bufferSubData(u,f.offset*d.BYTES_PER_ELEMENT,d.subarray(f.offset,f.offset+f.count)),f.count=-1),h.onUploadCallback()}function a(l){return l.isInterleavedBufferAttribute&&(l=l.data),n.get(l)}function o(l){l.isInterleavedBufferAttribute&&(l=l.data);const h=n.get(l);h&&(r.deleteBuffer(h.buffer),n.delete(l))}function c(l,h){if(l.isGLBufferAttribute){const d=n.get(l);(!d||d.version<l.version)&&n.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}l.isInterleavedBufferAttribute&&(l=l.data);const u=n.get(l);if(u===void 0)n.set(l,i(l,h));else if(u.version<l.version){if(u.size!==l.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");s(u.buffer,l,h),u.version=l.version}}return{get:a,remove:o,update:c}}class nr extends mt{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const s=e/2,a=t/2,o=Math.floor(n),c=Math.floor(i),l=o+1,h=c+1,u=e/o,d=t/c,f=[],g=[],_=[],m=[];for(let p=0;p<h;p++){const S=p*d-a;for(let v=0;v<l;v++){const E=v*u-s;g.push(E,-S,0),_.push(0,0,1),m.push(v/o),m.push(1-p/c)}}for(let p=0;p<c;p++)for(let S=0;S<o;S++){const v=S+l*p,E=S+l*(p+1),C=S+1+l*(p+1),A=S+1+l*p;f.push(v,E,A),f.push(E,C,A)}this.setIndex(f),this.setAttribute("position",new Ze(g,3)),this.setAttribute("normal",new Ze(_,3)),this.setAttribute("uv",new Ze(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new nr(e.width,e.height,e.widthSegments,e.heightSegments)}}var Du=`#ifdef USE_ALPHAHASH
45
+ if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
46
+ #endif`,Uu=`#ifdef USE_ALPHAHASH
47
+ const float ALPHA_HASH_SCALE = 0.05;
48
+ float hash2D( vec2 value ) {
49
+ return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
50
+ }
51
+ float hash3D( vec3 value ) {
52
+ return hash2D( vec2( hash2D( value.xy ), value.z ) );
53
+ }
54
+ float getAlphaHashThreshold( vec3 position ) {
55
+ float maxDeriv = max(
56
+ length( dFdx( position.xyz ) ),
57
+ length( dFdy( position.xyz ) )
58
+ );
59
+ float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
60
+ vec2 pixScales = vec2(
61
+ exp2( floor( log2( pixScale ) ) ),
62
+ exp2( ceil( log2( pixScale ) ) )
63
+ );
64
+ vec2 alpha = vec2(
65
+ hash3D( floor( pixScales.x * position.xyz ) ),
66
+ hash3D( floor( pixScales.y * position.xyz ) )
67
+ );
68
+ float lerpFactor = fract( log2( pixScale ) );
69
+ float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
70
+ float a = min( lerpFactor, 1.0 - lerpFactor );
71
+ vec3 cases = vec3(
72
+ x * x / ( 2.0 * a * ( 1.0 - a ) ),
73
+ ( x - 0.5 * a ) / ( 1.0 - a ),
74
+ 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
75
+ );
76
+ float threshold = ( x < ( 1.0 - a ) )
77
+ ? ( ( x < a ) ? cases.x : cases.y )
78
+ : cases.z;
79
+ return clamp( threshold , 1.0e-6, 1.0 );
80
+ }
81
+ #endif`,Ou=`#ifdef USE_ALPHAMAP
82
+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
83
+ #endif`,Fu=`#ifdef USE_ALPHAMAP
84
+ uniform sampler2D alphaMap;
85
+ #endif`,Bu=`#ifdef USE_ALPHATEST
86
+ #ifdef ALPHA_TO_COVERAGE
87
+ diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
88
+ if ( diffuseColor.a == 0.0 ) discard;
89
+ #else
90
+ if ( diffuseColor.a < alphaTest ) discard;
91
+ #endif
92
+ #endif`,zu=`#ifdef USE_ALPHATEST
93
+ uniform float alphaTest;
94
+ #endif`,Hu=`#ifdef USE_AOMAP
95
+ float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
96
+ reflectedLight.indirectDiffuse *= ambientOcclusion;
97
+ #if defined( USE_CLEARCOAT )
98
+ clearcoatSpecularIndirect *= ambientOcclusion;
99
+ #endif
100
+ #if defined( USE_SHEEN )
101
+ sheenSpecularIndirect *= ambientOcclusion;
102
+ #endif
103
+ #if defined( USE_ENVMAP ) && defined( STANDARD )
104
+ float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
105
+ reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
106
+ #endif
107
+ #endif`,Gu=`#ifdef USE_AOMAP
108
+ uniform sampler2D aoMap;
109
+ uniform float aoMapIntensity;
110
+ #endif`,ku=`#ifdef USE_BATCHING
111
+ attribute float batchId;
112
+ uniform highp sampler2D batchingTexture;
113
+ mat4 getBatchingMatrix( const in float i ) {
114
+ int size = textureSize( batchingTexture, 0 ).x;
115
+ int j = int( i ) * 4;
116
+ int x = j % size;
117
+ int y = j / size;
118
+ vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
119
+ vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
120
+ vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
121
+ vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
122
+ return mat4( v1, v2, v3, v4 );
123
+ }
124
+ #endif`,Vu=`#ifdef USE_BATCHING
125
+ mat4 batchingMatrix = getBatchingMatrix( batchId );
126
+ #endif`,Wu=`vec3 transformed = vec3( position );
127
+ #ifdef USE_ALPHAHASH
128
+ vPosition = vec3( position );
129
+ #endif`,Xu=`vec3 objectNormal = vec3( normal );
130
+ #ifdef USE_TANGENT
131
+ vec3 objectTangent = vec3( tangent.xyz );
132
+ #endif`,qu=`float G_BlinnPhong_Implicit( ) {
133
+ return 0.25;
134
+ }
135
+ float D_BlinnPhong( const in float shininess, const in float dotNH ) {
136
+ return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
137
+ }
138
+ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
139
+ vec3 halfDir = normalize( lightDir + viewDir );
140
+ float dotNH = saturate( dot( normal, halfDir ) );
141
+ float dotVH = saturate( dot( viewDir, halfDir ) );
142
+ vec3 F = F_Schlick( specularColor, 1.0, dotVH );
143
+ float G = G_BlinnPhong_Implicit( );
144
+ float D = D_BlinnPhong( shininess, dotNH );
145
+ return F * ( G * D );
146
+ } // validated`,Yu=`#ifdef USE_IRIDESCENCE
147
+ const mat3 XYZ_TO_REC709 = mat3(
148
+ 3.2404542, -0.9692660, 0.0556434,
149
+ -1.5371385, 1.8760108, -0.2040259,
150
+ -0.4985314, 0.0415560, 1.0572252
151
+ );
152
+ vec3 Fresnel0ToIor( vec3 fresnel0 ) {
153
+ vec3 sqrtF0 = sqrt( fresnel0 );
154
+ return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
155
+ }
156
+ vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
157
+ return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
158
+ }
159
+ float IorToFresnel0( float transmittedIor, float incidentIor ) {
160
+ return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
161
+ }
162
+ vec3 evalSensitivity( float OPD, vec3 shift ) {
163
+ float phase = 2.0 * PI * OPD * 1.0e-9;
164
+ vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
165
+ vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
166
+ vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
167
+ vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
168
+ xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
169
+ xyz /= 1.0685e-7;
170
+ vec3 rgb = XYZ_TO_REC709 * xyz;
171
+ return rgb;
172
+ }
173
+ vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
174
+ vec3 I;
175
+ float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
176
+ float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
177
+ float cosTheta2Sq = 1.0 - sinTheta2Sq;
178
+ if ( cosTheta2Sq < 0.0 ) {
179
+ return vec3( 1.0 );
180
+ }
181
+ float cosTheta2 = sqrt( cosTheta2Sq );
182
+ float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
183
+ float R12 = F_Schlick( R0, 1.0, cosTheta1 );
184
+ float T121 = 1.0 - R12;
185
+ float phi12 = 0.0;
186
+ if ( iridescenceIOR < outsideIOR ) phi12 = PI;
187
+ float phi21 = PI - phi12;
188
+ vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
189
+ vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
190
+ vec3 phi23 = vec3( 0.0 );
191
+ if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
192
+ if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
193
+ if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
194
+ float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
195
+ vec3 phi = vec3( phi21 ) + phi23;
196
+ vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
197
+ vec3 r123 = sqrt( R123 );
198
+ vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
199
+ vec3 C0 = R12 + Rs;
200
+ I = C0;
201
+ vec3 Cm = Rs - T121;
202
+ for ( int m = 1; m <= 2; ++ m ) {
203
+ Cm *= r123;
204
+ vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
205
+ I += Cm * Sm;
206
+ }
207
+ return max( I, vec3( 0.0 ) );
208
+ }
209
+ #endif`,ju=`#ifdef USE_BUMPMAP
210
+ uniform sampler2D bumpMap;
211
+ uniform float bumpScale;
212
+ vec2 dHdxy_fwd() {
213
+ vec2 dSTdx = dFdx( vBumpMapUv );
214
+ vec2 dSTdy = dFdy( vBumpMapUv );
215
+ float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
216
+ float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
217
+ float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
218
+ return vec2( dBx, dBy );
219
+ }
220
+ vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
221
+ vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
222
+ vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
223
+ vec3 vN = surf_norm;
224
+ vec3 R1 = cross( vSigmaY, vN );
225
+ vec3 R2 = cross( vN, vSigmaX );
226
+ float fDet = dot( vSigmaX, R1 ) * faceDirection;
227
+ vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
228
+ return normalize( abs( fDet ) * surf_norm - vGrad );
229
+ }
230
+ #endif`,Ku=`#if NUM_CLIPPING_PLANES > 0
231
+ vec4 plane;
232
+ #ifdef ALPHA_TO_COVERAGE
233
+ float distanceToPlane, distanceGradient;
234
+ float clipOpacity = 1.0;
235
+ #pragma unroll_loop_start
236
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
237
+ plane = clippingPlanes[ i ];
238
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
239
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
240
+ clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
241
+ if ( clipOpacity == 0.0 ) discard;
242
+ }
243
+ #pragma unroll_loop_end
244
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
245
+ float unionClipOpacity = 1.0;
246
+ #pragma unroll_loop_start
247
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
248
+ plane = clippingPlanes[ i ];
249
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
250
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
251
+ unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
252
+ }
253
+ #pragma unroll_loop_end
254
+ clipOpacity *= 1.0 - unionClipOpacity;
255
+ #endif
256
+ diffuseColor.a *= clipOpacity;
257
+ if ( diffuseColor.a == 0.0 ) discard;
258
+ #else
259
+ #pragma unroll_loop_start
260
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
261
+ plane = clippingPlanes[ i ];
262
+ if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
263
+ }
264
+ #pragma unroll_loop_end
265
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
266
+ bool clipped = true;
267
+ #pragma unroll_loop_start
268
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
269
+ plane = clippingPlanes[ i ];
270
+ clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
271
+ }
272
+ #pragma unroll_loop_end
273
+ if ( clipped ) discard;
274
+ #endif
275
+ #endif
276
+ #endif`,Ju=`#if NUM_CLIPPING_PLANES > 0
277
+ varying vec3 vClipPosition;
278
+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
279
+ #endif`,$u=`#if NUM_CLIPPING_PLANES > 0
280
+ varying vec3 vClipPosition;
281
+ #endif`,Zu=`#if NUM_CLIPPING_PLANES > 0
282
+ vClipPosition = - mvPosition.xyz;
283
+ #endif`,Qu=`#if defined( USE_COLOR_ALPHA )
284
+ diffuseColor *= vColor;
285
+ #elif defined( USE_COLOR )
286
+ diffuseColor.rgb *= vColor;
287
+ #endif`,ed=`#if defined( USE_COLOR_ALPHA )
288
+ varying vec4 vColor;
289
+ #elif defined( USE_COLOR )
290
+ varying vec3 vColor;
291
+ #endif`,td=`#if defined( USE_COLOR_ALPHA )
292
+ varying vec4 vColor;
293
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
294
+ varying vec3 vColor;
295
+ #endif`,nd=`#if defined( USE_COLOR_ALPHA )
296
+ vColor = vec4( 1.0 );
297
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
298
+ vColor = vec3( 1.0 );
299
+ #endif
300
+ #ifdef USE_COLOR
301
+ vColor *= color;
302
+ #endif
303
+ #ifdef USE_INSTANCING_COLOR
304
+ vColor.xyz *= instanceColor.xyz;
305
+ #endif`,id=`#define PI 3.141592653589793
306
+ #define PI2 6.283185307179586
307
+ #define PI_HALF 1.5707963267948966
308
+ #define RECIPROCAL_PI 0.3183098861837907
309
+ #define RECIPROCAL_PI2 0.15915494309189535
310
+ #define EPSILON 1e-6
311
+ #ifndef saturate
312
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
313
+ #endif
314
+ #define whiteComplement( a ) ( 1.0 - saturate( a ) )
315
+ float pow2( const in float x ) { return x*x; }
316
+ vec3 pow2( const in vec3 x ) { return x*x; }
317
+ float pow3( const in float x ) { return x*x*x; }
318
+ float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
319
+ float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
320
+ float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
321
+ highp float rand( const in vec2 uv ) {
322
+ const highp float a = 12.9898, b = 78.233, c = 43758.5453;
323
+ highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
324
+ return fract( sin( sn ) * c );
325
+ }
326
+ #ifdef HIGH_PRECISION
327
+ float precisionSafeLength( vec3 v ) { return length( v ); }
328
+ #else
329
+ float precisionSafeLength( vec3 v ) {
330
+ float maxComponent = max3( abs( v ) );
331
+ return length( v / maxComponent ) * maxComponent;
332
+ }
333
+ #endif
334
+ struct IncidentLight {
335
+ vec3 color;
336
+ vec3 direction;
337
+ bool visible;
338
+ };
339
+ struct ReflectedLight {
340
+ vec3 directDiffuse;
341
+ vec3 directSpecular;
342
+ vec3 indirectDiffuse;
343
+ vec3 indirectSpecular;
344
+ };
345
+ #ifdef USE_ALPHAHASH
346
+ varying vec3 vPosition;
347
+ #endif
348
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
349
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
350
+ }
351
+ vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
352
+ return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
353
+ }
354
+ mat3 transposeMat3( const in mat3 m ) {
355
+ mat3 tmp;
356
+ tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
357
+ tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
358
+ tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
359
+ return tmp;
360
+ }
361
+ float luminance( const in vec3 rgb ) {
362
+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
363
+ return dot( weights, rgb );
364
+ }
365
+ bool isPerspectiveMatrix( mat4 m ) {
366
+ return m[ 2 ][ 3 ] == - 1.0;
367
+ }
368
+ vec2 equirectUv( in vec3 dir ) {
369
+ float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
370
+ float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
371
+ return vec2( u, v );
372
+ }
373
+ vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
374
+ return RECIPROCAL_PI * diffuseColor;
375
+ }
376
+ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
377
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
378
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
379
+ }
380
+ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
381
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
382
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
383
+ } // validated`,sd=`#ifdef ENVMAP_TYPE_CUBE_UV
384
+ #define cubeUV_minMipLevel 4.0
385
+ #define cubeUV_minTileSize 16.0
386
+ float getFace( vec3 direction ) {
387
+ vec3 absDirection = abs( direction );
388
+ float face = - 1.0;
389
+ if ( absDirection.x > absDirection.z ) {
390
+ if ( absDirection.x > absDirection.y )
391
+ face = direction.x > 0.0 ? 0.0 : 3.0;
392
+ else
393
+ face = direction.y > 0.0 ? 1.0 : 4.0;
394
+ } else {
395
+ if ( absDirection.z > absDirection.y )
396
+ face = direction.z > 0.0 ? 2.0 : 5.0;
397
+ else
398
+ face = direction.y > 0.0 ? 1.0 : 4.0;
399
+ }
400
+ return face;
401
+ }
402
+ vec2 getUV( vec3 direction, float face ) {
403
+ vec2 uv;
404
+ if ( face == 0.0 ) {
405
+ uv = vec2( direction.z, direction.y ) / abs( direction.x );
406
+ } else if ( face == 1.0 ) {
407
+ uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
408
+ } else if ( face == 2.0 ) {
409
+ uv = vec2( - direction.x, direction.y ) / abs( direction.z );
410
+ } else if ( face == 3.0 ) {
411
+ uv = vec2( - direction.z, direction.y ) / abs( direction.x );
412
+ } else if ( face == 4.0 ) {
413
+ uv = vec2( - direction.x, direction.z ) / abs( direction.y );
414
+ } else {
415
+ uv = vec2( direction.x, direction.y ) / abs( direction.z );
416
+ }
417
+ return 0.5 * ( uv + 1.0 );
418
+ }
419
+ vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
420
+ float face = getFace( direction );
421
+ float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
422
+ mipInt = max( mipInt, cubeUV_minMipLevel );
423
+ float faceSize = exp2( mipInt );
424
+ highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
425
+ if ( face > 2.0 ) {
426
+ uv.y += faceSize;
427
+ face -= 3.0;
428
+ }
429
+ uv.x += face * faceSize;
430
+ uv.x += filterInt * 3.0 * cubeUV_minTileSize;
431
+ uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
432
+ uv.x *= CUBEUV_TEXEL_WIDTH;
433
+ uv.y *= CUBEUV_TEXEL_HEIGHT;
434
+ #ifdef texture2DGradEXT
435
+ return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
436
+ #else
437
+ return texture2D( envMap, uv ).rgb;
438
+ #endif
439
+ }
440
+ #define cubeUV_r0 1.0
441
+ #define cubeUV_m0 - 2.0
442
+ #define cubeUV_r1 0.8
443
+ #define cubeUV_m1 - 1.0
444
+ #define cubeUV_r4 0.4
445
+ #define cubeUV_m4 2.0
446
+ #define cubeUV_r5 0.305
447
+ #define cubeUV_m5 3.0
448
+ #define cubeUV_r6 0.21
449
+ #define cubeUV_m6 4.0
450
+ float roughnessToMip( float roughness ) {
451
+ float mip = 0.0;
452
+ if ( roughness >= cubeUV_r1 ) {
453
+ mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
454
+ } else if ( roughness >= cubeUV_r4 ) {
455
+ mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
456
+ } else if ( roughness >= cubeUV_r5 ) {
457
+ mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
458
+ } else if ( roughness >= cubeUV_r6 ) {
459
+ mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
460
+ } else {
461
+ mip = - 2.0 * log2( 1.16 * roughness ); }
462
+ return mip;
463
+ }
464
+ vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
465
+ float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
466
+ float mipF = fract( mip );
467
+ float mipInt = floor( mip );
468
+ vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
469
+ if ( mipF == 0.0 ) {
470
+ return vec4( color0, 1.0 );
471
+ } else {
472
+ vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
473
+ return vec4( mix( color0, color1, mipF ), 1.0 );
474
+ }
475
+ }
476
+ #endif`,rd=`vec3 transformedNormal = objectNormal;
477
+ #ifdef USE_TANGENT
478
+ vec3 transformedTangent = objectTangent;
479
+ #endif
480
+ #ifdef USE_BATCHING
481
+ mat3 bm = mat3( batchingMatrix );
482
+ transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
483
+ transformedNormal = bm * transformedNormal;
484
+ #ifdef USE_TANGENT
485
+ transformedTangent = bm * transformedTangent;
486
+ #endif
487
+ #endif
488
+ #ifdef USE_INSTANCING
489
+ mat3 im = mat3( instanceMatrix );
490
+ transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
491
+ transformedNormal = im * transformedNormal;
492
+ #ifdef USE_TANGENT
493
+ transformedTangent = im * transformedTangent;
494
+ #endif
495
+ #endif
496
+ transformedNormal = normalMatrix * transformedNormal;
497
+ #ifdef FLIP_SIDED
498
+ transformedNormal = - transformedNormal;
499
+ #endif
500
+ #ifdef USE_TANGENT
501
+ transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
502
+ #ifdef FLIP_SIDED
503
+ transformedTangent = - transformedTangent;
504
+ #endif
505
+ #endif`,ad=`#ifdef USE_DISPLACEMENTMAP
506
+ uniform sampler2D displacementMap;
507
+ uniform float displacementScale;
508
+ uniform float displacementBias;
509
+ #endif`,od=`#ifdef USE_DISPLACEMENTMAP
510
+ transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
511
+ #endif`,cd=`#ifdef USE_EMISSIVEMAP
512
+ vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
513
+ totalEmissiveRadiance *= emissiveColor.rgb;
514
+ #endif`,ld=`#ifdef USE_EMISSIVEMAP
515
+ uniform sampler2D emissiveMap;
516
+ #endif`,hd="gl_FragColor = linearToOutputTexel( gl_FragColor );",ud=`
517
+ const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
518
+ vec3( 0.8224621, 0.177538, 0.0 ),
519
+ vec3( 0.0331941, 0.9668058, 0.0 ),
520
+ vec3( 0.0170827, 0.0723974, 0.9105199 )
521
+ );
522
+ const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
523
+ vec3( 1.2249401, - 0.2249404, 0.0 ),
524
+ vec3( - 0.0420569, 1.0420571, 0.0 ),
525
+ vec3( - 0.0196376, - 0.0786361, 1.0982735 )
526
+ );
527
+ vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
528
+ return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
529
+ }
530
+ vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
531
+ return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
532
+ }
533
+ vec4 LinearTransferOETF( in vec4 value ) {
534
+ return value;
535
+ }
536
+ vec4 sRGBTransferOETF( in vec4 value ) {
537
+ return 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 );
538
+ }
539
+ vec4 LinearToLinear( in vec4 value ) {
540
+ return value;
541
+ }
542
+ vec4 LinearTosRGB( in vec4 value ) {
543
+ return sRGBTransferOETF( value );
544
+ }`,dd=`#ifdef USE_ENVMAP
545
+ #ifdef ENV_WORLDPOS
546
+ vec3 cameraToFrag;
547
+ if ( isOrthographic ) {
548
+ cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
549
+ } else {
550
+ cameraToFrag = normalize( vWorldPosition - cameraPosition );
551
+ }
552
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
553
+ #ifdef ENVMAP_MODE_REFLECTION
554
+ vec3 reflectVec = reflect( cameraToFrag, worldNormal );
555
+ #else
556
+ vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
557
+ #endif
558
+ #else
559
+ vec3 reflectVec = vReflect;
560
+ #endif
561
+ #ifdef ENVMAP_TYPE_CUBE
562
+ vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
563
+ #else
564
+ vec4 envColor = vec4( 0.0 );
565
+ #endif
566
+ #ifdef ENVMAP_BLENDING_MULTIPLY
567
+ outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
568
+ #elif defined( ENVMAP_BLENDING_MIX )
569
+ outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
570
+ #elif defined( ENVMAP_BLENDING_ADD )
571
+ outgoingLight += envColor.xyz * specularStrength * reflectivity;
572
+ #endif
573
+ #endif`,fd=`#ifdef USE_ENVMAP
574
+ uniform float envMapIntensity;
575
+ uniform float flipEnvMap;
576
+ uniform mat3 envMapRotation;
577
+ #ifdef ENVMAP_TYPE_CUBE
578
+ uniform samplerCube envMap;
579
+ #else
580
+ uniform sampler2D envMap;
581
+ #endif
582
+
583
+ #endif`,pd=`#ifdef USE_ENVMAP
584
+ uniform float reflectivity;
585
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
586
+ #define ENV_WORLDPOS
587
+ #endif
588
+ #ifdef ENV_WORLDPOS
589
+ varying vec3 vWorldPosition;
590
+ uniform float refractionRatio;
591
+ #else
592
+ varying vec3 vReflect;
593
+ #endif
594
+ #endif`,md=`#ifdef USE_ENVMAP
595
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
596
+ #define ENV_WORLDPOS
597
+ #endif
598
+ #ifdef ENV_WORLDPOS
599
+
600
+ varying vec3 vWorldPosition;
601
+ #else
602
+ varying vec3 vReflect;
603
+ uniform float refractionRatio;
604
+ #endif
605
+ #endif`,gd=`#ifdef USE_ENVMAP
606
+ #ifdef ENV_WORLDPOS
607
+ vWorldPosition = worldPosition.xyz;
608
+ #else
609
+ vec3 cameraToVertex;
610
+ if ( isOrthographic ) {
611
+ cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
612
+ } else {
613
+ cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
614
+ }
615
+ vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
616
+ #ifdef ENVMAP_MODE_REFLECTION
617
+ vReflect = reflect( cameraToVertex, worldNormal );
618
+ #else
619
+ vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
620
+ #endif
621
+ #endif
622
+ #endif`,_d=`#ifdef USE_FOG
623
+ vFogDepth = - mvPosition.z;
624
+ #endif`,vd=`#ifdef USE_FOG
625
+ varying float vFogDepth;
626
+ #endif`,xd=`#ifdef USE_FOG
627
+ #ifdef FOG_EXP2
628
+ float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
629
+ #else
630
+ float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
631
+ #endif
632
+ gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
633
+ #endif`,Md=`#ifdef USE_FOG
634
+ uniform vec3 fogColor;
635
+ varying float vFogDepth;
636
+ #ifdef FOG_EXP2
637
+ uniform float fogDensity;
638
+ #else
639
+ uniform float fogNear;
640
+ uniform float fogFar;
641
+ #endif
642
+ #endif`,yd=`#ifdef USE_GRADIENTMAP
643
+ uniform sampler2D gradientMap;
644
+ #endif
645
+ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
646
+ float dotNL = dot( normal, lightDirection );
647
+ vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
648
+ #ifdef USE_GRADIENTMAP
649
+ return vec3( texture2D( gradientMap, coord ).r );
650
+ #else
651
+ vec2 fw = fwidth( coord ) * 0.5;
652
+ return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
653
+ #endif
654
+ }`,Sd=`#ifdef USE_LIGHTMAP
655
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
656
+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
657
+ reflectedLight.indirectDiffuse += lightMapIrradiance;
658
+ #endif`,Ed=`#ifdef USE_LIGHTMAP
659
+ uniform sampler2D lightMap;
660
+ uniform float lightMapIntensity;
661
+ #endif`,Td=`LambertMaterial material;
662
+ material.diffuseColor = diffuseColor.rgb;
663
+ material.specularStrength = specularStrength;`,Ad=`varying vec3 vViewPosition;
664
+ struct LambertMaterial {
665
+ vec3 diffuseColor;
666
+ float specularStrength;
667
+ };
668
+ void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
669
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
670
+ vec3 irradiance = dotNL * directLight.color;
671
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
672
+ }
673
+ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
674
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
675
+ }
676
+ #define RE_Direct RE_Direct_Lambert
677
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,bd=`uniform bool receiveShadow;
678
+ uniform vec3 ambientLightColor;
679
+ #if defined( USE_LIGHT_PROBES )
680
+ uniform vec3 lightProbe[ 9 ];
681
+ #endif
682
+ vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
683
+ float x = normal.x, y = normal.y, z = normal.z;
684
+ vec3 result = shCoefficients[ 0 ] * 0.886227;
685
+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
686
+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
687
+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
688
+ result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
689
+ result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
690
+ result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
691
+ result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
692
+ result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
693
+ return result;
694
+ }
695
+ vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
696
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
697
+ vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
698
+ return irradiance;
699
+ }
700
+ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
701
+ vec3 irradiance = ambientLightColor;
702
+ return irradiance;
703
+ }
704
+ float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
705
+ #if defined ( LEGACY_LIGHTS )
706
+ if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
707
+ return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
708
+ }
709
+ return 1.0;
710
+ #else
711
+ float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
712
+ if ( cutoffDistance > 0.0 ) {
713
+ distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
714
+ }
715
+ return distanceFalloff;
716
+ #endif
717
+ }
718
+ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
719
+ return smoothstep( coneCosine, penumbraCosine, angleCosine );
720
+ }
721
+ #if NUM_DIR_LIGHTS > 0
722
+ struct DirectionalLight {
723
+ vec3 direction;
724
+ vec3 color;
725
+ };
726
+ uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
727
+ void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
728
+ light.color = directionalLight.color;
729
+ light.direction = directionalLight.direction;
730
+ light.visible = true;
731
+ }
732
+ #endif
733
+ #if NUM_POINT_LIGHTS > 0
734
+ struct PointLight {
735
+ vec3 position;
736
+ vec3 color;
737
+ float distance;
738
+ float decay;
739
+ };
740
+ uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
741
+ void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
742
+ vec3 lVector = pointLight.position - geometryPosition;
743
+ light.direction = normalize( lVector );
744
+ float lightDistance = length( lVector );
745
+ light.color = pointLight.color;
746
+ light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
747
+ light.visible = ( light.color != vec3( 0.0 ) );
748
+ }
749
+ #endif
750
+ #if NUM_SPOT_LIGHTS > 0
751
+ struct SpotLight {
752
+ vec3 position;
753
+ vec3 direction;
754
+ vec3 color;
755
+ float distance;
756
+ float decay;
757
+ float coneCos;
758
+ float penumbraCos;
759
+ };
760
+ uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
761
+ void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
762
+ vec3 lVector = spotLight.position - geometryPosition;
763
+ light.direction = normalize( lVector );
764
+ float angleCos = dot( light.direction, spotLight.direction );
765
+ float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
766
+ if ( spotAttenuation > 0.0 ) {
767
+ float lightDistance = length( lVector );
768
+ light.color = spotLight.color * spotAttenuation;
769
+ light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
770
+ light.visible = ( light.color != vec3( 0.0 ) );
771
+ } else {
772
+ light.color = vec3( 0.0 );
773
+ light.visible = false;
774
+ }
775
+ }
776
+ #endif
777
+ #if NUM_RECT_AREA_LIGHTS > 0
778
+ struct RectAreaLight {
779
+ vec3 color;
780
+ vec3 position;
781
+ vec3 halfWidth;
782
+ vec3 halfHeight;
783
+ };
784
+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;
785
+ uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
786
+ #endif
787
+ #if NUM_HEMI_LIGHTS > 0
788
+ struct HemisphereLight {
789
+ vec3 direction;
790
+ vec3 skyColor;
791
+ vec3 groundColor;
792
+ };
793
+ uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
794
+ vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
795
+ float dotNL = dot( normal, hemiLight.direction );
796
+ float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
797
+ vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
798
+ return irradiance;
799
+ }
800
+ #endif`,wd=`#ifdef USE_ENVMAP
801
+ vec3 getIBLIrradiance( const in vec3 normal ) {
802
+ #ifdef ENVMAP_TYPE_CUBE_UV
803
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
804
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
805
+ return PI * envMapColor.rgb * envMapIntensity;
806
+ #else
807
+ return vec3( 0.0 );
808
+ #endif
809
+ }
810
+ vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
811
+ #ifdef ENVMAP_TYPE_CUBE_UV
812
+ vec3 reflectVec = reflect( - viewDir, normal );
813
+ reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
814
+ reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
815
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
816
+ return envMapColor.rgb * envMapIntensity;
817
+ #else
818
+ return vec3( 0.0 );
819
+ #endif
820
+ }
821
+ #ifdef USE_ANISOTROPY
822
+ vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
823
+ #ifdef ENVMAP_TYPE_CUBE_UV
824
+ vec3 bentNormal = cross( bitangent, viewDir );
825
+ bentNormal = normalize( cross( bentNormal, bitangent ) );
826
+ bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
827
+ return getIBLRadiance( viewDir, bentNormal, roughness );
828
+ #else
829
+ return vec3( 0.0 );
830
+ #endif
831
+ }
832
+ #endif
833
+ #endif`,Rd=`ToonMaterial material;
834
+ material.diffuseColor = diffuseColor.rgb;`,Cd=`varying vec3 vViewPosition;
835
+ struct ToonMaterial {
836
+ vec3 diffuseColor;
837
+ };
838
+ void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
839
+ vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
840
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
841
+ }
842
+ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
843
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
844
+ }
845
+ #define RE_Direct RE_Direct_Toon
846
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Ld=`BlinnPhongMaterial material;
847
+ material.diffuseColor = diffuseColor.rgb;
848
+ material.specularColor = specular;
849
+ material.specularShininess = shininess;
850
+ material.specularStrength = specularStrength;`,Pd=`varying vec3 vViewPosition;
851
+ struct BlinnPhongMaterial {
852
+ vec3 diffuseColor;
853
+ vec3 specularColor;
854
+ float specularShininess;
855
+ float specularStrength;
856
+ };
857
+ void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
858
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
859
+ vec3 irradiance = dotNL * directLight.color;
860
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
861
+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
862
+ }
863
+ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
864
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
865
+ }
866
+ #define RE_Direct RE_Direct_BlinnPhong
867
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Id=`PhysicalMaterial material;
868
+ material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
869
+ vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
870
+ float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
871
+ material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
872
+ material.roughness = min( material.roughness, 1.0 );
873
+ #ifdef IOR
874
+ material.ior = ior;
875
+ #ifdef USE_SPECULAR
876
+ float specularIntensityFactor = specularIntensity;
877
+ vec3 specularColorFactor = specularColor;
878
+ #ifdef USE_SPECULAR_COLORMAP
879
+ specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
880
+ #endif
881
+ #ifdef USE_SPECULAR_INTENSITYMAP
882
+ specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
883
+ #endif
884
+ material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
885
+ #else
886
+ float specularIntensityFactor = 1.0;
887
+ vec3 specularColorFactor = vec3( 1.0 );
888
+ material.specularF90 = 1.0;
889
+ #endif
890
+ material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
891
+ #else
892
+ material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
893
+ material.specularF90 = 1.0;
894
+ #endif
895
+ #ifdef USE_CLEARCOAT
896
+ material.clearcoat = clearcoat;
897
+ material.clearcoatRoughness = clearcoatRoughness;
898
+ material.clearcoatF0 = vec3( 0.04 );
899
+ material.clearcoatF90 = 1.0;
900
+ #ifdef USE_CLEARCOATMAP
901
+ material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
902
+ #endif
903
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
904
+ material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
905
+ #endif
906
+ material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
907
+ material.clearcoatRoughness += geometryRoughness;
908
+ material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
909
+ #endif
910
+ #ifdef USE_IRIDESCENCE
911
+ material.iridescence = iridescence;
912
+ material.iridescenceIOR = iridescenceIOR;
913
+ #ifdef USE_IRIDESCENCEMAP
914
+ material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
915
+ #endif
916
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
917
+ material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
918
+ #else
919
+ material.iridescenceThickness = iridescenceThicknessMaximum;
920
+ #endif
921
+ #endif
922
+ #ifdef USE_SHEEN
923
+ material.sheenColor = sheenColor;
924
+ #ifdef USE_SHEEN_COLORMAP
925
+ material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
926
+ #endif
927
+ material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
928
+ #ifdef USE_SHEEN_ROUGHNESSMAP
929
+ material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
930
+ #endif
931
+ #endif
932
+ #ifdef USE_ANISOTROPY
933
+ #ifdef USE_ANISOTROPYMAP
934
+ mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
935
+ vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
936
+ vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
937
+ #else
938
+ vec2 anisotropyV = anisotropyVector;
939
+ #endif
940
+ material.anisotropy = length( anisotropyV );
941
+ if( material.anisotropy == 0.0 ) {
942
+ anisotropyV = vec2( 1.0, 0.0 );
943
+ } else {
944
+ anisotropyV /= material.anisotropy;
945
+ material.anisotropy = saturate( material.anisotropy );
946
+ }
947
+ material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
948
+ material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
949
+ material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
950
+ #endif`,Nd=`struct PhysicalMaterial {
951
+ vec3 diffuseColor;
952
+ float roughness;
953
+ vec3 specularColor;
954
+ float specularF90;
955
+ #ifdef USE_CLEARCOAT
956
+ float clearcoat;
957
+ float clearcoatRoughness;
958
+ vec3 clearcoatF0;
959
+ float clearcoatF90;
960
+ #endif
961
+ #ifdef USE_IRIDESCENCE
962
+ float iridescence;
963
+ float iridescenceIOR;
964
+ float iridescenceThickness;
965
+ vec3 iridescenceFresnel;
966
+ vec3 iridescenceF0;
967
+ #endif
968
+ #ifdef USE_SHEEN
969
+ vec3 sheenColor;
970
+ float sheenRoughness;
971
+ #endif
972
+ #ifdef IOR
973
+ float ior;
974
+ #endif
975
+ #ifdef USE_TRANSMISSION
976
+ float transmission;
977
+ float transmissionAlpha;
978
+ float thickness;
979
+ float attenuationDistance;
980
+ vec3 attenuationColor;
981
+ #endif
982
+ #ifdef USE_ANISOTROPY
983
+ float anisotropy;
984
+ float alphaT;
985
+ vec3 anisotropyT;
986
+ vec3 anisotropyB;
987
+ #endif
988
+ };
989
+ vec3 clearcoatSpecularDirect = vec3( 0.0 );
990
+ vec3 clearcoatSpecularIndirect = vec3( 0.0 );
991
+ vec3 sheenSpecularDirect = vec3( 0.0 );
992
+ vec3 sheenSpecularIndirect = vec3(0.0 );
993
+ vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
994
+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
995
+ float x2 = x * x;
996
+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
997
+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
998
+ }
999
+ float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
1000
+ float a2 = pow2( alpha );
1001
+ float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
1002
+ float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
1003
+ return 0.5 / max( gv + gl, EPSILON );
1004
+ }
1005
+ float D_GGX( const in float alpha, const in float dotNH ) {
1006
+ float a2 = pow2( alpha );
1007
+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
1008
+ return RECIPROCAL_PI * a2 / pow2( denom );
1009
+ }
1010
+ #ifdef USE_ANISOTROPY
1011
+ float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
1012
+ float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
1013
+ float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
1014
+ float v = 0.5 / ( gv + gl );
1015
+ return saturate(v);
1016
+ }
1017
+ float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
1018
+ float a2 = alphaT * alphaB;
1019
+ highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
1020
+ highp float v2 = dot( v, v );
1021
+ float w2 = a2 / v2;
1022
+ return RECIPROCAL_PI * a2 * pow2 ( w2 );
1023
+ }
1024
+ #endif
1025
+ #ifdef USE_CLEARCOAT
1026
+ vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
1027
+ vec3 f0 = material.clearcoatF0;
1028
+ float f90 = material.clearcoatF90;
1029
+ float roughness = material.clearcoatRoughness;
1030
+ float alpha = pow2( roughness );
1031
+ vec3 halfDir = normalize( lightDir + viewDir );
1032
+ float dotNL = saturate( dot( normal, lightDir ) );
1033
+ float dotNV = saturate( dot( normal, viewDir ) );
1034
+ float dotNH = saturate( dot( normal, halfDir ) );
1035
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1036
+ vec3 F = F_Schlick( f0, f90, dotVH );
1037
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1038
+ float D = D_GGX( alpha, dotNH );
1039
+ return F * ( V * D );
1040
+ }
1041
+ #endif
1042
+ vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1043
+ vec3 f0 = material.specularColor;
1044
+ float f90 = material.specularF90;
1045
+ float roughness = material.roughness;
1046
+ float alpha = pow2( roughness );
1047
+ vec3 halfDir = normalize( lightDir + viewDir );
1048
+ float dotNL = saturate( dot( normal, lightDir ) );
1049
+ float dotNV = saturate( dot( normal, viewDir ) );
1050
+ float dotNH = saturate( dot( normal, halfDir ) );
1051
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1052
+ vec3 F = F_Schlick( f0, f90, dotVH );
1053
+ #ifdef USE_IRIDESCENCE
1054
+ F = mix( F, material.iridescenceFresnel, material.iridescence );
1055
+ #endif
1056
+ #ifdef USE_ANISOTROPY
1057
+ float dotTL = dot( material.anisotropyT, lightDir );
1058
+ float dotTV = dot( material.anisotropyT, viewDir );
1059
+ float dotTH = dot( material.anisotropyT, halfDir );
1060
+ float dotBL = dot( material.anisotropyB, lightDir );
1061
+ float dotBV = dot( material.anisotropyB, viewDir );
1062
+ float dotBH = dot( material.anisotropyB, halfDir );
1063
+ float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
1064
+ float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
1065
+ #else
1066
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1067
+ float D = D_GGX( alpha, dotNH );
1068
+ #endif
1069
+ return F * ( V * D );
1070
+ }
1071
+ vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
1072
+ const float LUT_SIZE = 64.0;
1073
+ const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
1074
+ const float LUT_BIAS = 0.5 / LUT_SIZE;
1075
+ float dotNV = saturate( dot( N, V ) );
1076
+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
1077
+ uv = uv * LUT_SCALE + LUT_BIAS;
1078
+ return uv;
1079
+ }
1080
+ float LTC_ClippedSphereFormFactor( const in vec3 f ) {
1081
+ float l = length( f );
1082
+ return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
1083
+ }
1084
+ vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
1085
+ float x = dot( v1, v2 );
1086
+ float y = abs( x );
1087
+ float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
1088
+ float b = 3.4175940 + ( 4.1616724 + y ) * y;
1089
+ float v = a / b;
1090
+ float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
1091
+ return cross( v1, v2 ) * theta_sintheta;
1092
+ }
1093
+ vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
1094
+ vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
1095
+ vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
1096
+ vec3 lightNormal = cross( v1, v2 );
1097
+ if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
1098
+ vec3 T1, T2;
1099
+ T1 = normalize( V - N * dot( V, N ) );
1100
+ T2 = - cross( N, T1 );
1101
+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
1102
+ vec3 coords[ 4 ];
1103
+ coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
1104
+ coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
1105
+ coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
1106
+ coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
1107
+ coords[ 0 ] = normalize( coords[ 0 ] );
1108
+ coords[ 1 ] = normalize( coords[ 1 ] );
1109
+ coords[ 2 ] = normalize( coords[ 2 ] );
1110
+ coords[ 3 ] = normalize( coords[ 3 ] );
1111
+ vec3 vectorFormFactor = vec3( 0.0 );
1112
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
1113
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
1114
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
1115
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
1116
+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
1117
+ return vec3( result );
1118
+ }
1119
+ #if defined( USE_SHEEN )
1120
+ float D_Charlie( float roughness, float dotNH ) {
1121
+ float alpha = pow2( roughness );
1122
+ float invAlpha = 1.0 / alpha;
1123
+ float cos2h = dotNH * dotNH;
1124
+ float sin2h = max( 1.0 - cos2h, 0.0078125 );
1125
+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
1126
+ }
1127
+ float V_Neubelt( float dotNV, float dotNL ) {
1128
+ return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
1129
+ }
1130
+ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
1131
+ vec3 halfDir = normalize( lightDir + viewDir );
1132
+ float dotNL = saturate( dot( normal, lightDir ) );
1133
+ float dotNV = saturate( dot( normal, viewDir ) );
1134
+ float dotNH = saturate( dot( normal, halfDir ) );
1135
+ float D = D_Charlie( sheenRoughness, dotNH );
1136
+ float V = V_Neubelt( dotNV, dotNL );
1137
+ return sheenColor * ( D * V );
1138
+ }
1139
+ #endif
1140
+ float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1141
+ float dotNV = saturate( dot( normal, viewDir ) );
1142
+ float r2 = roughness * roughness;
1143
+ float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
1144
+ float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
1145
+ float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
1146
+ return saturate( DG * RECIPROCAL_PI );
1147
+ }
1148
+ vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1149
+ float dotNV = saturate( dot( normal, viewDir ) );
1150
+ const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
1151
+ const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
1152
+ vec4 r = roughness * c0 + c1;
1153
+ float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
1154
+ vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
1155
+ return fab;
1156
+ }
1157
+ vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
1158
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1159
+ return specularColor * fab.x + specularF90 * fab.y;
1160
+ }
1161
+ #ifdef USE_IRIDESCENCE
1162
+ void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
1163
+ #else
1164
+ void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
1165
+ #endif
1166
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1167
+ #ifdef USE_IRIDESCENCE
1168
+ vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
1169
+ #else
1170
+ vec3 Fr = specularColor;
1171
+ #endif
1172
+ vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
1173
+ float Ess = fab.x + fab.y;
1174
+ float Ems = 1.0 - Ess;
1175
+ vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
1176
+ singleScatter += FssEss;
1177
+ multiScatter += Fms * Ems;
1178
+ }
1179
+ #if NUM_RECT_AREA_LIGHTS > 0
1180
+ void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1181
+ vec3 normal = geometryNormal;
1182
+ vec3 viewDir = geometryViewDir;
1183
+ vec3 position = geometryPosition;
1184
+ vec3 lightPos = rectAreaLight.position;
1185
+ vec3 halfWidth = rectAreaLight.halfWidth;
1186
+ vec3 halfHeight = rectAreaLight.halfHeight;
1187
+ vec3 lightColor = rectAreaLight.color;
1188
+ float roughness = material.roughness;
1189
+ vec3 rectCoords[ 4 ];
1190
+ rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
1191
+ rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
1192
+ rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
1193
+ vec2 uv = LTC_Uv( normal, viewDir, roughness );
1194
+ vec4 t1 = texture2D( ltc_1, uv );
1195
+ vec4 t2 = texture2D( ltc_2, uv );
1196
+ mat3 mInv = mat3(
1197
+ vec3( t1.x, 0, t1.y ),
1198
+ vec3( 0, 1, 0 ),
1199
+ vec3( t1.z, 0, t1.w )
1200
+ );
1201
+ vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
1202
+ reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
1203
+ reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
1204
+ }
1205
+ #endif
1206
+ void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1207
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
1208
+ vec3 irradiance = dotNL * directLight.color;
1209
+ #ifdef USE_CLEARCOAT
1210
+ float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
1211
+ vec3 ccIrradiance = dotNLcc * directLight.color;
1212
+ clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
1213
+ #endif
1214
+ #ifdef USE_SHEEN
1215
+ sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
1216
+ #endif
1217
+ reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
1218
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1219
+ }
1220
+ void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1221
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1222
+ }
1223
+ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
1224
+ #ifdef USE_CLEARCOAT
1225
+ clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
1226
+ #endif
1227
+ #ifdef USE_SHEEN
1228
+ sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1229
+ #endif
1230
+ vec3 singleScattering = vec3( 0.0 );
1231
+ vec3 multiScattering = vec3( 0.0 );
1232
+ vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
1233
+ #ifdef USE_IRIDESCENCE
1234
+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
1235
+ #else
1236
+ computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
1237
+ #endif
1238
+ vec3 totalScattering = singleScattering + multiScattering;
1239
+ vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
1240
+ reflectedLight.indirectSpecular += radiance * singleScattering;
1241
+ reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
1242
+ reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
1243
+ }
1244
+ #define RE_Direct RE_Direct_Physical
1245
+ #define RE_Direct_RectArea RE_Direct_RectArea_Physical
1246
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
1247
+ #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1248
+ float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1249
+ return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1250
+ }`,Dd=`
1251
+ vec3 geometryPosition = - vViewPosition;
1252
+ vec3 geometryNormal = normal;
1253
+ vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
1254
+ vec3 geometryClearcoatNormal = vec3( 0.0 );
1255
+ #ifdef USE_CLEARCOAT
1256
+ geometryClearcoatNormal = clearcoatNormal;
1257
+ #endif
1258
+ #ifdef USE_IRIDESCENCE
1259
+ float dotNVi = saturate( dot( normal, geometryViewDir ) );
1260
+ if ( material.iridescenceThickness == 0.0 ) {
1261
+ material.iridescence = 0.0;
1262
+ } else {
1263
+ material.iridescence = saturate( material.iridescence );
1264
+ }
1265
+ if ( material.iridescence > 0.0 ) {
1266
+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
1267
+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
1268
+ }
1269
+ #endif
1270
+ IncidentLight directLight;
1271
+ #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
1272
+ PointLight pointLight;
1273
+ #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
1274
+ PointLightShadow pointLightShadow;
1275
+ #endif
1276
+ #pragma unroll_loop_start
1277
+ for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
1278
+ pointLight = pointLights[ i ];
1279
+ getPointLightInfo( pointLight, geometryPosition, directLight );
1280
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
1281
+ pointLightShadow = pointLightShadows[ i ];
1282
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
1283
+ #endif
1284
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1285
+ }
1286
+ #pragma unroll_loop_end
1287
+ #endif
1288
+ #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
1289
+ SpotLight spotLight;
1290
+ vec4 spotColor;
1291
+ vec3 spotLightCoord;
1292
+ bool inSpotLightMap;
1293
+ #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
1294
+ SpotLightShadow spotLightShadow;
1295
+ #endif
1296
+ #pragma unroll_loop_start
1297
+ for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
1298
+ spotLight = spotLights[ i ];
1299
+ getSpotLightInfo( spotLight, geometryPosition, directLight );
1300
+ #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1301
+ #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
1302
+ #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1303
+ #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
1304
+ #else
1305
+ #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1306
+ #endif
1307
+ #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
1308
+ spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
1309
+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
1310
+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
1311
+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
1312
+ #endif
1313
+ #undef SPOT_LIGHT_MAP_INDEX
1314
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1315
+ spotLightShadow = spotLightShadows[ i ];
1316
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1317
+ #endif
1318
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1319
+ }
1320
+ #pragma unroll_loop_end
1321
+ #endif
1322
+ #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
1323
+ DirectionalLight directionalLight;
1324
+ #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
1325
+ DirectionalLightShadow directionalLightShadow;
1326
+ #endif
1327
+ #pragma unroll_loop_start
1328
+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
1329
+ directionalLight = directionalLights[ i ];
1330
+ getDirectionalLightInfo( directionalLight, directLight );
1331
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
1332
+ directionalLightShadow = directionalLightShadows[ i ];
1333
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1334
+ #endif
1335
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1336
+ }
1337
+ #pragma unroll_loop_end
1338
+ #endif
1339
+ #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
1340
+ RectAreaLight rectAreaLight;
1341
+ #pragma unroll_loop_start
1342
+ for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
1343
+ rectAreaLight = rectAreaLights[ i ];
1344
+ RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1345
+ }
1346
+ #pragma unroll_loop_end
1347
+ #endif
1348
+ #if defined( RE_IndirectDiffuse )
1349
+ vec3 iblIrradiance = vec3( 0.0 );
1350
+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
1351
+ #if defined( USE_LIGHT_PROBES )
1352
+ irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
1353
+ #endif
1354
+ #if ( NUM_HEMI_LIGHTS > 0 )
1355
+ #pragma unroll_loop_start
1356
+ for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
1357
+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
1358
+ }
1359
+ #pragma unroll_loop_end
1360
+ #endif
1361
+ #endif
1362
+ #if defined( RE_IndirectSpecular )
1363
+ vec3 radiance = vec3( 0.0 );
1364
+ vec3 clearcoatRadiance = vec3( 0.0 );
1365
+ #endif`,Ud=`#if defined( RE_IndirectDiffuse )
1366
+ #ifdef USE_LIGHTMAP
1367
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1368
+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
1369
+ irradiance += lightMapIrradiance;
1370
+ #endif
1371
+ #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
1372
+ iblIrradiance += getIBLIrradiance( geometryNormal );
1373
+ #endif
1374
+ #endif
1375
+ #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
1376
+ #ifdef USE_ANISOTROPY
1377
+ radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
1378
+ #else
1379
+ radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
1380
+ #endif
1381
+ #ifdef USE_CLEARCOAT
1382
+ clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1383
+ #endif
1384
+ #endif`,Od=`#if defined( RE_IndirectDiffuse )
1385
+ RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1386
+ #endif
1387
+ #if defined( RE_IndirectSpecular )
1388
+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1389
+ #endif`,Fd=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
1390
+ gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1391
+ #endif`,Bd=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
1392
+ uniform float logDepthBufFC;
1393
+ varying float vFragDepth;
1394
+ varying float vIsPerspective;
1395
+ #endif`,zd=`#ifdef USE_LOGDEPTHBUF
1396
+ #ifdef USE_LOGDEPTHBUF_EXT
1397
+ varying float vFragDepth;
1398
+ varying float vIsPerspective;
1399
+ #else
1400
+ uniform float logDepthBufFC;
1401
+ #endif
1402
+ #endif`,Hd=`#ifdef USE_LOGDEPTHBUF
1403
+ #ifdef USE_LOGDEPTHBUF_EXT
1404
+ vFragDepth = 1.0 + gl_Position.w;
1405
+ vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1406
+ #else
1407
+ if ( isPerspectiveMatrix( projectionMatrix ) ) {
1408
+ gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
1409
+ gl_Position.z *= gl_Position.w;
1410
+ }
1411
+ #endif
1412
+ #endif`,Gd=`#ifdef USE_MAP
1413
+ vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1414
+ #ifdef DECODE_VIDEO_TEXTURE
1415
+ sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
1416
+
1417
+ #endif
1418
+ diffuseColor *= sampledDiffuseColor;
1419
+ #endif`,kd=`#ifdef USE_MAP
1420
+ uniform sampler2D map;
1421
+ #endif`,Vd=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1422
+ #if defined( USE_POINTS_UV )
1423
+ vec2 uv = vUv;
1424
+ #else
1425
+ vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
1426
+ #endif
1427
+ #endif
1428
+ #ifdef USE_MAP
1429
+ diffuseColor *= texture2D( map, uv );
1430
+ #endif
1431
+ #ifdef USE_ALPHAMAP
1432
+ diffuseColor.a *= texture2D( alphaMap, uv ).g;
1433
+ #endif`,Wd=`#if defined( USE_POINTS_UV )
1434
+ varying vec2 vUv;
1435
+ #else
1436
+ #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1437
+ uniform mat3 uvTransform;
1438
+ #endif
1439
+ #endif
1440
+ #ifdef USE_MAP
1441
+ uniform sampler2D map;
1442
+ #endif
1443
+ #ifdef USE_ALPHAMAP
1444
+ uniform sampler2D alphaMap;
1445
+ #endif`,Xd=`float metalnessFactor = metalness;
1446
+ #ifdef USE_METALNESSMAP
1447
+ vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1448
+ metalnessFactor *= texelMetalness.b;
1449
+ #endif`,qd=`#ifdef USE_METALNESSMAP
1450
+ uniform sampler2D metalnessMap;
1451
+ #endif`,Yd=`#ifdef USE_INSTANCING_MORPH
1452
+ float morphTargetInfluences[MORPHTARGETS_COUNT];
1453
+ float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1454
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1455
+ morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1456
+ }
1457
+ #endif`,jd=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
1458
+ vColor *= morphTargetBaseInfluence;
1459
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1460
+ #if defined( USE_COLOR_ALPHA )
1461
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
1462
+ #elif defined( USE_COLOR )
1463
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1464
+ #endif
1465
+ }
1466
+ #endif`,Kd=`#ifdef USE_MORPHNORMALS
1467
+ objectNormal *= morphTargetBaseInfluence;
1468
+ #ifdef MORPHTARGETS_TEXTURE
1469
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1470
+ if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1471
+ }
1472
+ #else
1473
+ objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
1474
+ objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
1475
+ objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
1476
+ objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
1477
+ #endif
1478
+ #endif`,Jd=`#ifdef USE_MORPHTARGETS
1479
+ #ifndef USE_INSTANCING_MORPH
1480
+ uniform float morphTargetBaseInfluence;
1481
+ #endif
1482
+ #ifdef MORPHTARGETS_TEXTURE
1483
+ #ifndef USE_INSTANCING_MORPH
1484
+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1485
+ #endif
1486
+ uniform sampler2DArray morphTargetsTexture;
1487
+ uniform ivec2 morphTargetsTextureSize;
1488
+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
1489
+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
1490
+ int y = texelIndex / morphTargetsTextureSize.x;
1491
+ int x = texelIndex - y * morphTargetsTextureSize.x;
1492
+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1493
+ return texelFetch( morphTargetsTexture, morphUV, 0 );
1494
+ }
1495
+ #else
1496
+ #ifndef USE_MORPHNORMALS
1497
+ uniform float morphTargetInfluences[ 8 ];
1498
+ #else
1499
+ uniform float morphTargetInfluences[ 4 ];
1500
+ #endif
1501
+ #endif
1502
+ #endif`,$d=`#ifdef USE_MORPHTARGETS
1503
+ transformed *= morphTargetBaseInfluence;
1504
+ #ifdef MORPHTARGETS_TEXTURE
1505
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1506
+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1507
+ }
1508
+ #else
1509
+ transformed += morphTarget0 * morphTargetInfluences[ 0 ];
1510
+ transformed += morphTarget1 * morphTargetInfluences[ 1 ];
1511
+ transformed += morphTarget2 * morphTargetInfluences[ 2 ];
1512
+ transformed += morphTarget3 * morphTargetInfluences[ 3 ];
1513
+ #ifndef USE_MORPHNORMALS
1514
+ transformed += morphTarget4 * morphTargetInfluences[ 4 ];
1515
+ transformed += morphTarget5 * morphTargetInfluences[ 5 ];
1516
+ transformed += morphTarget6 * morphTargetInfluences[ 6 ];
1517
+ transformed += morphTarget7 * morphTargetInfluences[ 7 ];
1518
+ #endif
1519
+ #endif
1520
+ #endif`,Zd=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1521
+ #ifdef FLAT_SHADED
1522
+ vec3 fdx = dFdx( vViewPosition );
1523
+ vec3 fdy = dFdy( vViewPosition );
1524
+ vec3 normal = normalize( cross( fdx, fdy ) );
1525
+ #else
1526
+ vec3 normal = normalize( vNormal );
1527
+ #ifdef DOUBLE_SIDED
1528
+ normal *= faceDirection;
1529
+ #endif
1530
+ #endif
1531
+ #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
1532
+ #ifdef USE_TANGENT
1533
+ mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1534
+ #else
1535
+ mat3 tbn = getTangentFrame( - vViewPosition, normal,
1536
+ #if defined( USE_NORMALMAP )
1537
+ vNormalMapUv
1538
+ #elif defined( USE_CLEARCOAT_NORMALMAP )
1539
+ vClearcoatNormalMapUv
1540
+ #else
1541
+ vUv
1542
+ #endif
1543
+ );
1544
+ #endif
1545
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1546
+ tbn[0] *= faceDirection;
1547
+ tbn[1] *= faceDirection;
1548
+ #endif
1549
+ #endif
1550
+ #ifdef USE_CLEARCOAT_NORMALMAP
1551
+ #ifdef USE_TANGENT
1552
+ mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1553
+ #else
1554
+ mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
1555
+ #endif
1556
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1557
+ tbn2[0] *= faceDirection;
1558
+ tbn2[1] *= faceDirection;
1559
+ #endif
1560
+ #endif
1561
+ vec3 nonPerturbedNormal = normal;`,Qd=`#ifdef USE_NORMALMAP_OBJECTSPACE
1562
+ normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1563
+ #ifdef FLIP_SIDED
1564
+ normal = - normal;
1565
+ #endif
1566
+ #ifdef DOUBLE_SIDED
1567
+ normal = normal * faceDirection;
1568
+ #endif
1569
+ normal = normalize( normalMatrix * normal );
1570
+ #elif defined( USE_NORMALMAP_TANGENTSPACE )
1571
+ vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1572
+ mapN.xy *= normalScale;
1573
+ normal = normalize( tbn * mapN );
1574
+ #elif defined( USE_BUMPMAP )
1575
+ normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1576
+ #endif`,ef=`#ifndef FLAT_SHADED
1577
+ varying vec3 vNormal;
1578
+ #ifdef USE_TANGENT
1579
+ varying vec3 vTangent;
1580
+ varying vec3 vBitangent;
1581
+ #endif
1582
+ #endif`,tf=`#ifndef FLAT_SHADED
1583
+ varying vec3 vNormal;
1584
+ #ifdef USE_TANGENT
1585
+ varying vec3 vTangent;
1586
+ varying vec3 vBitangent;
1587
+ #endif
1588
+ #endif`,nf=`#ifndef FLAT_SHADED
1589
+ vNormal = normalize( transformedNormal );
1590
+ #ifdef USE_TANGENT
1591
+ vTangent = normalize( transformedTangent );
1592
+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1593
+ #endif
1594
+ #endif`,sf=`#ifdef USE_NORMALMAP
1595
+ uniform sampler2D normalMap;
1596
+ uniform vec2 normalScale;
1597
+ #endif
1598
+ #ifdef USE_NORMALMAP_OBJECTSPACE
1599
+ uniform mat3 normalMatrix;
1600
+ #endif
1601
+ #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
1602
+ mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
1603
+ vec3 q0 = dFdx( eye_pos.xyz );
1604
+ vec3 q1 = dFdy( eye_pos.xyz );
1605
+ vec2 st0 = dFdx( uv.st );
1606
+ vec2 st1 = dFdy( uv.st );
1607
+ vec3 N = surf_norm;
1608
+ vec3 q1perp = cross( q1, N );
1609
+ vec3 q0perp = cross( N, q0 );
1610
+ vec3 T = q1perp * st0.x + q0perp * st1.x;
1611
+ vec3 B = q1perp * st0.y + q0perp * st1.y;
1612
+ float det = max( dot( T, T ), dot( B, B ) );
1613
+ float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1614
+ return mat3( T * scale, B * scale, N );
1615
+ }
1616
+ #endif`,rf=`#ifdef USE_CLEARCOAT
1617
+ vec3 clearcoatNormal = nonPerturbedNormal;
1618
+ #endif`,af=`#ifdef USE_CLEARCOAT_NORMALMAP
1619
+ vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1620
+ clearcoatMapN.xy *= clearcoatNormalScale;
1621
+ clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1622
+ #endif`,of=`#ifdef USE_CLEARCOATMAP
1623
+ uniform sampler2D clearcoatMap;
1624
+ #endif
1625
+ #ifdef USE_CLEARCOAT_NORMALMAP
1626
+ uniform sampler2D clearcoatNormalMap;
1627
+ uniform vec2 clearcoatNormalScale;
1628
+ #endif
1629
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1630
+ uniform sampler2D clearcoatRoughnessMap;
1631
+ #endif`,cf=`#ifdef USE_IRIDESCENCEMAP
1632
+ uniform sampler2D iridescenceMap;
1633
+ #endif
1634
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
1635
+ uniform sampler2D iridescenceThicknessMap;
1636
+ #endif`,lf=`#ifdef OPAQUE
1637
+ diffuseColor.a = 1.0;
1638
+ #endif
1639
+ #ifdef USE_TRANSMISSION
1640
+ diffuseColor.a *= material.transmissionAlpha;
1641
+ #endif
1642
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,hf=`vec3 packNormalToRGB( const in vec3 normal ) {
1643
+ return normalize( normal ) * 0.5 + 0.5;
1644
+ }
1645
+ vec3 unpackRGBToNormal( const in vec3 rgb ) {
1646
+ return 2.0 * rgb.xyz - 1.0;
1647
+ }
1648
+ const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
1649
+ const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
1650
+ const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
1651
+ const float ShiftRight8 = 1. / 256.;
1652
+ vec4 packDepthToRGBA( const in float v ) {
1653
+ vec4 r = vec4( fract( v * PackFactors ), v );
1654
+ r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
1655
+ }
1656
+ float unpackRGBAToDepth( const in vec4 v ) {
1657
+ return dot( v, UnpackFactors );
1658
+ }
1659
+ vec2 packDepthToRG( in highp float v ) {
1660
+ return packDepthToRGBA( v ).yx;
1661
+ }
1662
+ float unpackRGToDepth( const in highp vec2 v ) {
1663
+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
1664
+ }
1665
+ vec4 pack2HalfToRGBA( vec2 v ) {
1666
+ vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
1667
+ return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
1668
+ }
1669
+ vec2 unpackRGBATo2Half( vec4 v ) {
1670
+ return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
1671
+ }
1672
+ float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
1673
+ return ( viewZ + near ) / ( near - far );
1674
+ }
1675
+ float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
1676
+ return depth * ( near - far ) - near;
1677
+ }
1678
+ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
1679
+ return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
1680
+ }
1681
+ float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1682
+ return ( near * far ) / ( ( far - near ) * depth - far );
1683
+ }`,uf=`#ifdef PREMULTIPLIED_ALPHA
1684
+ gl_FragColor.rgb *= gl_FragColor.a;
1685
+ #endif`,df=`vec4 mvPosition = vec4( transformed, 1.0 );
1686
+ #ifdef USE_BATCHING
1687
+ mvPosition = batchingMatrix * mvPosition;
1688
+ #endif
1689
+ #ifdef USE_INSTANCING
1690
+ mvPosition = instanceMatrix * mvPosition;
1691
+ #endif
1692
+ mvPosition = modelViewMatrix * mvPosition;
1693
+ gl_Position = projectionMatrix * mvPosition;`,ff=`#ifdef DITHERING
1694
+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1695
+ #endif`,pf=`#ifdef DITHERING
1696
+ vec3 dithering( vec3 color ) {
1697
+ float grid_position = rand( gl_FragCoord.xy );
1698
+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1699
+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1700
+ return color + dither_shift_RGB;
1701
+ }
1702
+ #endif`,mf=`float roughnessFactor = roughness;
1703
+ #ifdef USE_ROUGHNESSMAP
1704
+ vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1705
+ roughnessFactor *= texelRoughness.g;
1706
+ #endif`,gf=`#ifdef USE_ROUGHNESSMAP
1707
+ uniform sampler2D roughnessMap;
1708
+ #endif`,_f=`#if NUM_SPOT_LIGHT_COORDS > 0
1709
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1710
+ #endif
1711
+ #if NUM_SPOT_LIGHT_MAPS > 0
1712
+ uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
1713
+ #endif
1714
+ #ifdef USE_SHADOWMAP
1715
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1716
+ uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
1717
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1718
+ struct DirectionalLightShadow {
1719
+ float shadowBias;
1720
+ float shadowNormalBias;
1721
+ float shadowRadius;
1722
+ vec2 shadowMapSize;
1723
+ };
1724
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1725
+ #endif
1726
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1727
+ uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
1728
+ struct SpotLightShadow {
1729
+ float shadowBias;
1730
+ float shadowNormalBias;
1731
+ float shadowRadius;
1732
+ vec2 shadowMapSize;
1733
+ };
1734
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1735
+ #endif
1736
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1737
+ uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
1738
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1739
+ struct PointLightShadow {
1740
+ float shadowBias;
1741
+ float shadowNormalBias;
1742
+ float shadowRadius;
1743
+ vec2 shadowMapSize;
1744
+ float shadowCameraNear;
1745
+ float shadowCameraFar;
1746
+ };
1747
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1748
+ #endif
1749
+ float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
1750
+ return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
1751
+ }
1752
+ vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
1753
+ return unpackRGBATo2Half( texture2D( shadow, uv ) );
1754
+ }
1755
+ float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
1756
+ float occlusion = 1.0;
1757
+ vec2 distribution = texture2DDistribution( shadow, uv );
1758
+ float hard_shadow = step( compare , distribution.x );
1759
+ if (hard_shadow != 1.0 ) {
1760
+ float distance = compare - distribution.x ;
1761
+ float variance = max( 0.00000, distribution.y * distribution.y );
1762
+ float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
1763
+ }
1764
+ return occlusion;
1765
+ }
1766
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1767
+ float shadow = 1.0;
1768
+ shadowCoord.xyz /= shadowCoord.w;
1769
+ shadowCoord.z += shadowBias;
1770
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1771
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1772
+ if ( frustumTest ) {
1773
+ #if defined( SHADOWMAP_TYPE_PCF )
1774
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1775
+ float dx0 = - texelSize.x * shadowRadius;
1776
+ float dy0 = - texelSize.y * shadowRadius;
1777
+ float dx1 = + texelSize.x * shadowRadius;
1778
+ float dy1 = + texelSize.y * shadowRadius;
1779
+ float dx2 = dx0 / 2.0;
1780
+ float dy2 = dy0 / 2.0;
1781
+ float dx3 = dx1 / 2.0;
1782
+ float dy3 = dy1 / 2.0;
1783
+ shadow = (
1784
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
1785
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
1786
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
1787
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
1788
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
1789
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
1790
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
1791
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
1792
+ texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
1793
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
1794
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
1795
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
1796
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
1797
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
1798
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
1799
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
1800
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
1801
+ ) * ( 1.0 / 17.0 );
1802
+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
1803
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1804
+ float dx = texelSize.x;
1805
+ float dy = texelSize.y;
1806
+ vec2 uv = shadowCoord.xy;
1807
+ vec2 f = fract( uv * shadowMapSize + 0.5 );
1808
+ uv -= f * texelSize;
1809
+ shadow = (
1810
+ texture2DCompare( shadowMap, uv, shadowCoord.z ) +
1811
+ texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
1812
+ texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
1813
+ texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
1814
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
1815
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
1816
+ f.x ) +
1817
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
1818
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
1819
+ f.x ) +
1820
+ mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
1821
+ texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
1822
+ f.y ) +
1823
+ mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
1824
+ texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
1825
+ f.y ) +
1826
+ mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
1827
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
1828
+ f.x ),
1829
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
1830
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
1831
+ f.x ),
1832
+ f.y )
1833
+ ) * ( 1.0 / 9.0 );
1834
+ #elif defined( SHADOWMAP_TYPE_VSM )
1835
+ shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
1836
+ #else
1837
+ shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
1838
+ #endif
1839
+ }
1840
+ return shadow;
1841
+ }
1842
+ vec2 cubeToUV( vec3 v, float texelSizeY ) {
1843
+ vec3 absV = abs( v );
1844
+ float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
1845
+ absV *= scaleToCube;
1846
+ v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
1847
+ vec2 planar = v.xy;
1848
+ float almostATexel = 1.5 * texelSizeY;
1849
+ float almostOne = 1.0 - almostATexel;
1850
+ if ( absV.z >= almostOne ) {
1851
+ if ( v.z > 0.0 )
1852
+ planar.x = 4.0 - v.x;
1853
+ } else if ( absV.x >= almostOne ) {
1854
+ float signX = sign( v.x );
1855
+ planar.x = v.z * signX + 2.0 * signX;
1856
+ } else if ( absV.y >= almostOne ) {
1857
+ float signY = sign( v.y );
1858
+ planar.x = v.x + 2.0 * signY + 2.0;
1859
+ planar.y = v.z * signY - 2.0;
1860
+ }
1861
+ return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
1862
+ }
1863
+ float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
1864
+ vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
1865
+ vec3 lightToPosition = shadowCoord.xyz;
1866
+ float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
1867
+ vec3 bd3D = normalize( lightToPosition );
1868
+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
1869
+ vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
1870
+ return (
1871
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
1872
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
1873
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
1874
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
1875
+ texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
1876
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
1877
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
1878
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
1879
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
1880
+ ) * ( 1.0 / 9.0 );
1881
+ #else
1882
+ return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
1883
+ #endif
1884
+ }
1885
+ #endif`,vf=`#if NUM_SPOT_LIGHT_COORDS > 0
1886
+ uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1887
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1888
+ #endif
1889
+ #ifdef USE_SHADOWMAP
1890
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1891
+ uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
1892
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1893
+ struct DirectionalLightShadow {
1894
+ float shadowBias;
1895
+ float shadowNormalBias;
1896
+ float shadowRadius;
1897
+ vec2 shadowMapSize;
1898
+ };
1899
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1900
+ #endif
1901
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1902
+ struct SpotLightShadow {
1903
+ float shadowBias;
1904
+ float shadowNormalBias;
1905
+ float shadowRadius;
1906
+ vec2 shadowMapSize;
1907
+ };
1908
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1909
+ #endif
1910
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1911
+ uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
1912
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1913
+ struct PointLightShadow {
1914
+ float shadowBias;
1915
+ float shadowNormalBias;
1916
+ float shadowRadius;
1917
+ vec2 shadowMapSize;
1918
+ float shadowCameraNear;
1919
+ float shadowCameraFar;
1920
+ };
1921
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1922
+ #endif
1923
+ #endif`,xf=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1924
+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1925
+ vec4 shadowWorldPosition;
1926
+ #endif
1927
+ #if defined( USE_SHADOWMAP )
1928
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1929
+ #pragma unroll_loop_start
1930
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1931
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
1932
+ vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
1933
+ }
1934
+ #pragma unroll_loop_end
1935
+ #endif
1936
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1937
+ #pragma unroll_loop_start
1938
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1939
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
1940
+ vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
1941
+ }
1942
+ #pragma unroll_loop_end
1943
+ #endif
1944
+ #endif
1945
+ #if NUM_SPOT_LIGHT_COORDS > 0
1946
+ #pragma unroll_loop_start
1947
+ for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
1948
+ shadowWorldPosition = worldPosition;
1949
+ #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1950
+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
1951
+ #endif
1952
+ vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1953
+ }
1954
+ #pragma unroll_loop_end
1955
+ #endif`,Mf=`float getShadowMask() {
1956
+ float shadow = 1.0;
1957
+ #ifdef USE_SHADOWMAP
1958
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1959
+ DirectionalLightShadow directionalLight;
1960
+ #pragma unroll_loop_start
1961
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1962
+ directionalLight = directionalLightShadows[ i ];
1963
+ shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1964
+ }
1965
+ #pragma unroll_loop_end
1966
+ #endif
1967
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1968
+ SpotLightShadow spotLight;
1969
+ #pragma unroll_loop_start
1970
+ for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
1971
+ spotLight = spotLightShadows[ i ];
1972
+ shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1973
+ }
1974
+ #pragma unroll_loop_end
1975
+ #endif
1976
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1977
+ PointLightShadow pointLight;
1978
+ #pragma unroll_loop_start
1979
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1980
+ pointLight = pointLightShadows[ i ];
1981
+ shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
1982
+ }
1983
+ #pragma unroll_loop_end
1984
+ #endif
1985
+ #endif
1986
+ return shadow;
1987
+ }`,yf=`#ifdef USE_SKINNING
1988
+ mat4 boneMatX = getBoneMatrix( skinIndex.x );
1989
+ mat4 boneMatY = getBoneMatrix( skinIndex.y );
1990
+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );
1991
+ mat4 boneMatW = getBoneMatrix( skinIndex.w );
1992
+ #endif`,Sf=`#ifdef USE_SKINNING
1993
+ uniform mat4 bindMatrix;
1994
+ uniform mat4 bindMatrixInverse;
1995
+ uniform highp sampler2D boneTexture;
1996
+ mat4 getBoneMatrix( const in float i ) {
1997
+ int size = textureSize( boneTexture, 0 ).x;
1998
+ int j = int( i ) * 4;
1999
+ int x = j % size;
2000
+ int y = j / size;
2001
+ vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
2002
+ vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
2003
+ vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
2004
+ vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2005
+ return mat4( v1, v2, v3, v4 );
2006
+ }
2007
+ #endif`,Ef=`#ifdef USE_SKINNING
2008
+ vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2009
+ vec4 skinned = vec4( 0.0 );
2010
+ skinned += boneMatX * skinVertex * skinWeight.x;
2011
+ skinned += boneMatY * skinVertex * skinWeight.y;
2012
+ skinned += boneMatZ * skinVertex * skinWeight.z;
2013
+ skinned += boneMatW * skinVertex * skinWeight.w;
2014
+ transformed = ( bindMatrixInverse * skinned ).xyz;
2015
+ #endif`,Tf=`#ifdef USE_SKINNING
2016
+ mat4 skinMatrix = mat4( 0.0 );
2017
+ skinMatrix += skinWeight.x * boneMatX;
2018
+ skinMatrix += skinWeight.y * boneMatY;
2019
+ skinMatrix += skinWeight.z * boneMatZ;
2020
+ skinMatrix += skinWeight.w * boneMatW;
2021
+ skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
2022
+ objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
2023
+ #ifdef USE_TANGENT
2024
+ objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2025
+ #endif
2026
+ #endif`,Af=`float specularStrength;
2027
+ #ifdef USE_SPECULARMAP
2028
+ vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2029
+ specularStrength = texelSpecular.r;
2030
+ #else
2031
+ specularStrength = 1.0;
2032
+ #endif`,bf=`#ifdef USE_SPECULARMAP
2033
+ uniform sampler2D specularMap;
2034
+ #endif`,wf=`#if defined( TONE_MAPPING )
2035
+ gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2036
+ #endif`,Rf=`#ifndef saturate
2037
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
2038
+ #endif
2039
+ uniform float toneMappingExposure;
2040
+ vec3 LinearToneMapping( vec3 color ) {
2041
+ return saturate( toneMappingExposure * color );
2042
+ }
2043
+ vec3 ReinhardToneMapping( vec3 color ) {
2044
+ color *= toneMappingExposure;
2045
+ return saturate( color / ( vec3( 1.0 ) + color ) );
2046
+ }
2047
+ vec3 OptimizedCineonToneMapping( vec3 color ) {
2048
+ color *= toneMappingExposure;
2049
+ color = max( vec3( 0.0 ), color - 0.004 );
2050
+ return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
2051
+ }
2052
+ vec3 RRTAndODTFit( vec3 v ) {
2053
+ vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
2054
+ vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
2055
+ return a / b;
2056
+ }
2057
+ vec3 ACESFilmicToneMapping( vec3 color ) {
2058
+ const mat3 ACESInputMat = mat3(
2059
+ vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
2060
+ vec3( 0.04823, 0.01566, 0.83777 )
2061
+ );
2062
+ const mat3 ACESOutputMat = mat3(
2063
+ vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
2064
+ vec3( -0.07367, -0.00605, 1.07602 )
2065
+ );
2066
+ color *= toneMappingExposure / 0.6;
2067
+ color = ACESInputMat * color;
2068
+ color = RRTAndODTFit( color );
2069
+ color = ACESOutputMat * color;
2070
+ return saturate( color );
2071
+ }
2072
+ const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
2073
+ vec3( 1.6605, - 0.1246, - 0.0182 ),
2074
+ vec3( - 0.5876, 1.1329, - 0.1006 ),
2075
+ vec3( - 0.0728, - 0.0083, 1.1187 )
2076
+ );
2077
+ const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
2078
+ vec3( 0.6274, 0.0691, 0.0164 ),
2079
+ vec3( 0.3293, 0.9195, 0.0880 ),
2080
+ vec3( 0.0433, 0.0113, 0.8956 )
2081
+ );
2082
+ vec3 agxDefaultContrastApprox( vec3 x ) {
2083
+ vec3 x2 = x * x;
2084
+ vec3 x4 = x2 * x2;
2085
+ return + 15.5 * x4 * x2
2086
+ - 40.14 * x4 * x
2087
+ + 31.96 * x4
2088
+ - 6.868 * x2 * x
2089
+ + 0.4298 * x2
2090
+ + 0.1191 * x
2091
+ - 0.00232;
2092
+ }
2093
+ vec3 AgXToneMapping( vec3 color ) {
2094
+ const mat3 AgXInsetMatrix = mat3(
2095
+ vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
2096
+ vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
2097
+ vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
2098
+ );
2099
+ const mat3 AgXOutsetMatrix = mat3(
2100
+ vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
2101
+ vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
2102
+ vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
2103
+ );
2104
+ const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
2105
+ color *= toneMappingExposure;
2106
+ color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
2107
+ color = AgXInsetMatrix * color;
2108
+ color = max( color, 1e-10 ); color = log2( color );
2109
+ color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
2110
+ color = clamp( color, 0.0, 1.0 );
2111
+ color = agxDefaultContrastApprox( color );
2112
+ color = AgXOutsetMatrix * color;
2113
+ color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
2114
+ color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
2115
+ color = clamp( color, 0.0, 1.0 );
2116
+ return color;
2117
+ }
2118
+ vec3 NeutralToneMapping( vec3 color ) {
2119
+ float startCompression = 0.8 - 0.04;
2120
+ float desaturation = 0.15;
2121
+ color *= toneMappingExposure;
2122
+ float x = min(color.r, min(color.g, color.b));
2123
+ float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
2124
+ color -= offset;
2125
+ float peak = max(color.r, max(color.g, color.b));
2126
+ if (peak < startCompression) return color;
2127
+ float d = 1. - startCompression;
2128
+ float newPeak = 1. - d * d / (peak + d - startCompression);
2129
+ color *= newPeak / peak;
2130
+ float g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);
2131
+ return mix(color, vec3(1, 1, 1), g);
2132
+ }
2133
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,Cf=`#ifdef USE_TRANSMISSION
2134
+ material.transmission = transmission;
2135
+ material.transmissionAlpha = 1.0;
2136
+ material.thickness = thickness;
2137
+ material.attenuationDistance = attenuationDistance;
2138
+ material.attenuationColor = attenuationColor;
2139
+ #ifdef USE_TRANSMISSIONMAP
2140
+ material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
2141
+ #endif
2142
+ #ifdef USE_THICKNESSMAP
2143
+ material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
2144
+ #endif
2145
+ vec3 pos = vWorldPosition;
2146
+ vec3 v = normalize( cameraPosition - pos );
2147
+ vec3 n = inverseTransformDirection( normal, viewMatrix );
2148
+ vec4 transmitted = getIBLVolumeRefraction(
2149
+ n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
2150
+ pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
2151
+ material.attenuationColor, material.attenuationDistance );
2152
+ material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2153
+ totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2154
+ #endif`,Lf=`#ifdef USE_TRANSMISSION
2155
+ uniform float transmission;
2156
+ uniform float thickness;
2157
+ uniform float attenuationDistance;
2158
+ uniform vec3 attenuationColor;
2159
+ #ifdef USE_TRANSMISSIONMAP
2160
+ uniform sampler2D transmissionMap;
2161
+ #endif
2162
+ #ifdef USE_THICKNESSMAP
2163
+ uniform sampler2D thicknessMap;
2164
+ #endif
2165
+ uniform vec2 transmissionSamplerSize;
2166
+ uniform sampler2D transmissionSamplerMap;
2167
+ uniform mat4 modelMatrix;
2168
+ uniform mat4 projectionMatrix;
2169
+ varying vec3 vWorldPosition;
2170
+ float w0( float a ) {
2171
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
2172
+ }
2173
+ float w1( float a ) {
2174
+ return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
2175
+ }
2176
+ float w2( float a ){
2177
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
2178
+ }
2179
+ float w3( float a ) {
2180
+ return ( 1.0 / 6.0 ) * ( a * a * a );
2181
+ }
2182
+ float g0( float a ) {
2183
+ return w0( a ) + w1( a );
2184
+ }
2185
+ float g1( float a ) {
2186
+ return w2( a ) + w3( a );
2187
+ }
2188
+ float h0( float a ) {
2189
+ return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
2190
+ }
2191
+ float h1( float a ) {
2192
+ return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
2193
+ }
2194
+ vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
2195
+ uv = uv * texelSize.zw + 0.5;
2196
+ vec2 iuv = floor( uv );
2197
+ vec2 fuv = fract( uv );
2198
+ float g0x = g0( fuv.x );
2199
+ float g1x = g1( fuv.x );
2200
+ float h0x = h0( fuv.x );
2201
+ float h1x = h1( fuv.x );
2202
+ float h0y = h0( fuv.y );
2203
+ float h1y = h1( fuv.y );
2204
+ vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2205
+ vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2206
+ vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2207
+ vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2208
+ return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
2209
+ g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
2210
+ }
2211
+ vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
2212
+ vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
2213
+ vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
2214
+ vec2 fLodSizeInv = 1.0 / fLodSize;
2215
+ vec2 cLodSizeInv = 1.0 / cLodSize;
2216
+ vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
2217
+ vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
2218
+ return mix( fSample, cSample, fract( lod ) );
2219
+ }
2220
+ vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
2221
+ vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
2222
+ vec3 modelScale;
2223
+ modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
2224
+ modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
2225
+ modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
2226
+ return normalize( refractionVector ) * thickness * modelScale;
2227
+ }
2228
+ float applyIorToRoughness( const in float roughness, const in float ior ) {
2229
+ return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
2230
+ }
2231
+ vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
2232
+ float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
2233
+ return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
2234
+ }
2235
+ vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
2236
+ if ( isinf( attenuationDistance ) ) {
2237
+ return vec3( 1.0 );
2238
+ } else {
2239
+ vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
2240
+ vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
2241
+ }
2242
+ }
2243
+ vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
2244
+ const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
2245
+ const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
2246
+ const in vec3 attenuationColor, const in float attenuationDistance ) {
2247
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
2248
+ vec3 refractedRayExit = position + transmissionRay;
2249
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2250
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2251
+ refractionCoords += 1.0;
2252
+ refractionCoords /= 2.0;
2253
+ vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
2254
+ vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
2255
+ vec3 attenuatedColor = transmittance * transmittedLight.rgb;
2256
+ vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
2257
+ float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2258
+ return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2259
+ }
2260
+ #endif`,Pf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2261
+ varying vec2 vUv;
2262
+ #endif
2263
+ #ifdef USE_MAP
2264
+ varying vec2 vMapUv;
2265
+ #endif
2266
+ #ifdef USE_ALPHAMAP
2267
+ varying vec2 vAlphaMapUv;
2268
+ #endif
2269
+ #ifdef USE_LIGHTMAP
2270
+ varying vec2 vLightMapUv;
2271
+ #endif
2272
+ #ifdef USE_AOMAP
2273
+ varying vec2 vAoMapUv;
2274
+ #endif
2275
+ #ifdef USE_BUMPMAP
2276
+ varying vec2 vBumpMapUv;
2277
+ #endif
2278
+ #ifdef USE_NORMALMAP
2279
+ varying vec2 vNormalMapUv;
2280
+ #endif
2281
+ #ifdef USE_EMISSIVEMAP
2282
+ varying vec2 vEmissiveMapUv;
2283
+ #endif
2284
+ #ifdef USE_METALNESSMAP
2285
+ varying vec2 vMetalnessMapUv;
2286
+ #endif
2287
+ #ifdef USE_ROUGHNESSMAP
2288
+ varying vec2 vRoughnessMapUv;
2289
+ #endif
2290
+ #ifdef USE_ANISOTROPYMAP
2291
+ varying vec2 vAnisotropyMapUv;
2292
+ #endif
2293
+ #ifdef USE_CLEARCOATMAP
2294
+ varying vec2 vClearcoatMapUv;
2295
+ #endif
2296
+ #ifdef USE_CLEARCOAT_NORMALMAP
2297
+ varying vec2 vClearcoatNormalMapUv;
2298
+ #endif
2299
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2300
+ varying vec2 vClearcoatRoughnessMapUv;
2301
+ #endif
2302
+ #ifdef USE_IRIDESCENCEMAP
2303
+ varying vec2 vIridescenceMapUv;
2304
+ #endif
2305
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2306
+ varying vec2 vIridescenceThicknessMapUv;
2307
+ #endif
2308
+ #ifdef USE_SHEEN_COLORMAP
2309
+ varying vec2 vSheenColorMapUv;
2310
+ #endif
2311
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2312
+ varying vec2 vSheenRoughnessMapUv;
2313
+ #endif
2314
+ #ifdef USE_SPECULARMAP
2315
+ varying vec2 vSpecularMapUv;
2316
+ #endif
2317
+ #ifdef USE_SPECULAR_COLORMAP
2318
+ varying vec2 vSpecularColorMapUv;
2319
+ #endif
2320
+ #ifdef USE_SPECULAR_INTENSITYMAP
2321
+ varying vec2 vSpecularIntensityMapUv;
2322
+ #endif
2323
+ #ifdef USE_TRANSMISSIONMAP
2324
+ uniform mat3 transmissionMapTransform;
2325
+ varying vec2 vTransmissionMapUv;
2326
+ #endif
2327
+ #ifdef USE_THICKNESSMAP
2328
+ uniform mat3 thicknessMapTransform;
2329
+ varying vec2 vThicknessMapUv;
2330
+ #endif`,If=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2331
+ varying vec2 vUv;
2332
+ #endif
2333
+ #ifdef USE_MAP
2334
+ uniform mat3 mapTransform;
2335
+ varying vec2 vMapUv;
2336
+ #endif
2337
+ #ifdef USE_ALPHAMAP
2338
+ uniform mat3 alphaMapTransform;
2339
+ varying vec2 vAlphaMapUv;
2340
+ #endif
2341
+ #ifdef USE_LIGHTMAP
2342
+ uniform mat3 lightMapTransform;
2343
+ varying vec2 vLightMapUv;
2344
+ #endif
2345
+ #ifdef USE_AOMAP
2346
+ uniform mat3 aoMapTransform;
2347
+ varying vec2 vAoMapUv;
2348
+ #endif
2349
+ #ifdef USE_BUMPMAP
2350
+ uniform mat3 bumpMapTransform;
2351
+ varying vec2 vBumpMapUv;
2352
+ #endif
2353
+ #ifdef USE_NORMALMAP
2354
+ uniform mat3 normalMapTransform;
2355
+ varying vec2 vNormalMapUv;
2356
+ #endif
2357
+ #ifdef USE_DISPLACEMENTMAP
2358
+ uniform mat3 displacementMapTransform;
2359
+ varying vec2 vDisplacementMapUv;
2360
+ #endif
2361
+ #ifdef USE_EMISSIVEMAP
2362
+ uniform mat3 emissiveMapTransform;
2363
+ varying vec2 vEmissiveMapUv;
2364
+ #endif
2365
+ #ifdef USE_METALNESSMAP
2366
+ uniform mat3 metalnessMapTransform;
2367
+ varying vec2 vMetalnessMapUv;
2368
+ #endif
2369
+ #ifdef USE_ROUGHNESSMAP
2370
+ uniform mat3 roughnessMapTransform;
2371
+ varying vec2 vRoughnessMapUv;
2372
+ #endif
2373
+ #ifdef USE_ANISOTROPYMAP
2374
+ uniform mat3 anisotropyMapTransform;
2375
+ varying vec2 vAnisotropyMapUv;
2376
+ #endif
2377
+ #ifdef USE_CLEARCOATMAP
2378
+ uniform mat3 clearcoatMapTransform;
2379
+ varying vec2 vClearcoatMapUv;
2380
+ #endif
2381
+ #ifdef USE_CLEARCOAT_NORMALMAP
2382
+ uniform mat3 clearcoatNormalMapTransform;
2383
+ varying vec2 vClearcoatNormalMapUv;
2384
+ #endif
2385
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2386
+ uniform mat3 clearcoatRoughnessMapTransform;
2387
+ varying vec2 vClearcoatRoughnessMapUv;
2388
+ #endif
2389
+ #ifdef USE_SHEEN_COLORMAP
2390
+ uniform mat3 sheenColorMapTransform;
2391
+ varying vec2 vSheenColorMapUv;
2392
+ #endif
2393
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2394
+ uniform mat3 sheenRoughnessMapTransform;
2395
+ varying vec2 vSheenRoughnessMapUv;
2396
+ #endif
2397
+ #ifdef USE_IRIDESCENCEMAP
2398
+ uniform mat3 iridescenceMapTransform;
2399
+ varying vec2 vIridescenceMapUv;
2400
+ #endif
2401
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2402
+ uniform mat3 iridescenceThicknessMapTransform;
2403
+ varying vec2 vIridescenceThicknessMapUv;
2404
+ #endif
2405
+ #ifdef USE_SPECULARMAP
2406
+ uniform mat3 specularMapTransform;
2407
+ varying vec2 vSpecularMapUv;
2408
+ #endif
2409
+ #ifdef USE_SPECULAR_COLORMAP
2410
+ uniform mat3 specularColorMapTransform;
2411
+ varying vec2 vSpecularColorMapUv;
2412
+ #endif
2413
+ #ifdef USE_SPECULAR_INTENSITYMAP
2414
+ uniform mat3 specularIntensityMapTransform;
2415
+ varying vec2 vSpecularIntensityMapUv;
2416
+ #endif
2417
+ #ifdef USE_TRANSMISSIONMAP
2418
+ uniform mat3 transmissionMapTransform;
2419
+ varying vec2 vTransmissionMapUv;
2420
+ #endif
2421
+ #ifdef USE_THICKNESSMAP
2422
+ uniform mat3 thicknessMapTransform;
2423
+ varying vec2 vThicknessMapUv;
2424
+ #endif`,Nf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2425
+ vUv = vec3( uv, 1 ).xy;
2426
+ #endif
2427
+ #ifdef USE_MAP
2428
+ vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
2429
+ #endif
2430
+ #ifdef USE_ALPHAMAP
2431
+ vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
2432
+ #endif
2433
+ #ifdef USE_LIGHTMAP
2434
+ vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
2435
+ #endif
2436
+ #ifdef USE_AOMAP
2437
+ vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
2438
+ #endif
2439
+ #ifdef USE_BUMPMAP
2440
+ vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
2441
+ #endif
2442
+ #ifdef USE_NORMALMAP
2443
+ vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
2444
+ #endif
2445
+ #ifdef USE_DISPLACEMENTMAP
2446
+ vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
2447
+ #endif
2448
+ #ifdef USE_EMISSIVEMAP
2449
+ vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
2450
+ #endif
2451
+ #ifdef USE_METALNESSMAP
2452
+ vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
2453
+ #endif
2454
+ #ifdef USE_ROUGHNESSMAP
2455
+ vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
2456
+ #endif
2457
+ #ifdef USE_ANISOTROPYMAP
2458
+ vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
2459
+ #endif
2460
+ #ifdef USE_CLEARCOATMAP
2461
+ vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
2462
+ #endif
2463
+ #ifdef USE_CLEARCOAT_NORMALMAP
2464
+ vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
2465
+ #endif
2466
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2467
+ vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
2468
+ #endif
2469
+ #ifdef USE_IRIDESCENCEMAP
2470
+ vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
2471
+ #endif
2472
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2473
+ vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
2474
+ #endif
2475
+ #ifdef USE_SHEEN_COLORMAP
2476
+ vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
2477
+ #endif
2478
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2479
+ vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
2480
+ #endif
2481
+ #ifdef USE_SPECULARMAP
2482
+ vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
2483
+ #endif
2484
+ #ifdef USE_SPECULAR_COLORMAP
2485
+ vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
2486
+ #endif
2487
+ #ifdef USE_SPECULAR_INTENSITYMAP
2488
+ vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
2489
+ #endif
2490
+ #ifdef USE_TRANSMISSIONMAP
2491
+ vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
2492
+ #endif
2493
+ #ifdef USE_THICKNESSMAP
2494
+ vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2495
+ #endif`,Df=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2496
+ vec4 worldPosition = vec4( transformed, 1.0 );
2497
+ #ifdef USE_BATCHING
2498
+ worldPosition = batchingMatrix * worldPosition;
2499
+ #endif
2500
+ #ifdef USE_INSTANCING
2501
+ worldPosition = instanceMatrix * worldPosition;
2502
+ #endif
2503
+ worldPosition = modelMatrix * worldPosition;
2504
+ #endif`;const Uf=`varying vec2 vUv;
2505
+ uniform mat3 uvTransform;
2506
+ void main() {
2507
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2508
+ gl_Position = vec4( position.xy, 1.0, 1.0 );
2509
+ }`,Of=`uniform sampler2D t2D;
2510
+ uniform float backgroundIntensity;
2511
+ varying vec2 vUv;
2512
+ void main() {
2513
+ vec4 texColor = texture2D( t2D, vUv );
2514
+ #ifdef DECODE_VIDEO_TEXTURE
2515
+ texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
2516
+ #endif
2517
+ texColor.rgb *= backgroundIntensity;
2518
+ gl_FragColor = texColor;
2519
+ #include <tonemapping_fragment>
2520
+ #include <colorspace_fragment>
2521
+ }`,Ff=`varying vec3 vWorldDirection;
2522
+ #include <common>
2523
+ void main() {
2524
+ vWorldDirection = transformDirection( position, modelMatrix );
2525
+ #include <begin_vertex>
2526
+ #include <project_vertex>
2527
+ gl_Position.z = gl_Position.w;
2528
+ }`,Bf=`#ifdef ENVMAP_TYPE_CUBE
2529
+ uniform samplerCube envMap;
2530
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2531
+ uniform sampler2D envMap;
2532
+ #endif
2533
+ uniform float flipEnvMap;
2534
+ uniform float backgroundBlurriness;
2535
+ uniform float backgroundIntensity;
2536
+ uniform mat3 backgroundRotation;
2537
+ varying vec3 vWorldDirection;
2538
+ #include <cube_uv_reflection_fragment>
2539
+ void main() {
2540
+ #ifdef ENVMAP_TYPE_CUBE
2541
+ vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
2542
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2543
+ vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
2544
+ #else
2545
+ vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
2546
+ #endif
2547
+ texColor.rgb *= backgroundIntensity;
2548
+ gl_FragColor = texColor;
2549
+ #include <tonemapping_fragment>
2550
+ #include <colorspace_fragment>
2551
+ }`,zf=`varying vec3 vWorldDirection;
2552
+ #include <common>
2553
+ void main() {
2554
+ vWorldDirection = transformDirection( position, modelMatrix );
2555
+ #include <begin_vertex>
2556
+ #include <project_vertex>
2557
+ gl_Position.z = gl_Position.w;
2558
+ }`,Hf=`uniform samplerCube tCube;
2559
+ uniform float tFlip;
2560
+ uniform float opacity;
2561
+ varying vec3 vWorldDirection;
2562
+ void main() {
2563
+ vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
2564
+ gl_FragColor = texColor;
2565
+ gl_FragColor.a *= opacity;
2566
+ #include <tonemapping_fragment>
2567
+ #include <colorspace_fragment>
2568
+ }`,Gf=`#include <common>
2569
+ #include <batching_pars_vertex>
2570
+ #include <uv_pars_vertex>
2571
+ #include <displacementmap_pars_vertex>
2572
+ #include <morphtarget_pars_vertex>
2573
+ #include <skinning_pars_vertex>
2574
+ #include <logdepthbuf_pars_vertex>
2575
+ #include <clipping_planes_pars_vertex>
2576
+ varying vec2 vHighPrecisionZW;
2577
+ void main() {
2578
+ #include <uv_vertex>
2579
+ #include <batching_vertex>
2580
+ #include <skinbase_vertex>
2581
+ #include <morphinstance_vertex>
2582
+ #ifdef USE_DISPLACEMENTMAP
2583
+ #include <beginnormal_vertex>
2584
+ #include <morphnormal_vertex>
2585
+ #include <skinnormal_vertex>
2586
+ #endif
2587
+ #include <begin_vertex>
2588
+ #include <morphtarget_vertex>
2589
+ #include <skinning_vertex>
2590
+ #include <displacementmap_vertex>
2591
+ #include <project_vertex>
2592
+ #include <logdepthbuf_vertex>
2593
+ #include <clipping_planes_vertex>
2594
+ vHighPrecisionZW = gl_Position.zw;
2595
+ }`,kf=`#if DEPTH_PACKING == 3200
2596
+ uniform float opacity;
2597
+ #endif
2598
+ #include <common>
2599
+ #include <packing>
2600
+ #include <uv_pars_fragment>
2601
+ #include <map_pars_fragment>
2602
+ #include <alphamap_pars_fragment>
2603
+ #include <alphatest_pars_fragment>
2604
+ #include <alphahash_pars_fragment>
2605
+ #include <logdepthbuf_pars_fragment>
2606
+ #include <clipping_planes_pars_fragment>
2607
+ varying vec2 vHighPrecisionZW;
2608
+ void main() {
2609
+ vec4 diffuseColor = vec4( 1.0 );
2610
+ #include <clipping_planes_fragment>
2611
+ #if DEPTH_PACKING == 3200
2612
+ diffuseColor.a = opacity;
2613
+ #endif
2614
+ #include <map_fragment>
2615
+ #include <alphamap_fragment>
2616
+ #include <alphatest_fragment>
2617
+ #include <alphahash_fragment>
2618
+ #include <logdepthbuf_fragment>
2619
+ float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
2620
+ #if DEPTH_PACKING == 3200
2621
+ gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
2622
+ #elif DEPTH_PACKING == 3201
2623
+ gl_FragColor = packDepthToRGBA( fragCoordZ );
2624
+ #endif
2625
+ }`,Vf=`#define DISTANCE
2626
+ varying vec3 vWorldPosition;
2627
+ #include <common>
2628
+ #include <batching_pars_vertex>
2629
+ #include <uv_pars_vertex>
2630
+ #include <displacementmap_pars_vertex>
2631
+ #include <morphtarget_pars_vertex>
2632
+ #include <skinning_pars_vertex>
2633
+ #include <clipping_planes_pars_vertex>
2634
+ void main() {
2635
+ #include <uv_vertex>
2636
+ #include <batching_vertex>
2637
+ #include <skinbase_vertex>
2638
+ #include <morphinstance_vertex>
2639
+ #ifdef USE_DISPLACEMENTMAP
2640
+ #include <beginnormal_vertex>
2641
+ #include <morphnormal_vertex>
2642
+ #include <skinnormal_vertex>
2643
+ #endif
2644
+ #include <begin_vertex>
2645
+ #include <morphtarget_vertex>
2646
+ #include <skinning_vertex>
2647
+ #include <displacementmap_vertex>
2648
+ #include <project_vertex>
2649
+ #include <worldpos_vertex>
2650
+ #include <clipping_planes_vertex>
2651
+ vWorldPosition = worldPosition.xyz;
2652
+ }`,Wf=`#define DISTANCE
2653
+ uniform vec3 referencePosition;
2654
+ uniform float nearDistance;
2655
+ uniform float farDistance;
2656
+ varying vec3 vWorldPosition;
2657
+ #include <common>
2658
+ #include <packing>
2659
+ #include <uv_pars_fragment>
2660
+ #include <map_pars_fragment>
2661
+ #include <alphamap_pars_fragment>
2662
+ #include <alphatest_pars_fragment>
2663
+ #include <alphahash_pars_fragment>
2664
+ #include <clipping_planes_pars_fragment>
2665
+ void main () {
2666
+ vec4 diffuseColor = vec4( 1.0 );
2667
+ #include <clipping_planes_fragment>
2668
+ #include <map_fragment>
2669
+ #include <alphamap_fragment>
2670
+ #include <alphatest_fragment>
2671
+ #include <alphahash_fragment>
2672
+ float dist = length( vWorldPosition - referencePosition );
2673
+ dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2674
+ dist = saturate( dist );
2675
+ gl_FragColor = packDepthToRGBA( dist );
2676
+ }`,Xf=`varying vec3 vWorldDirection;
2677
+ #include <common>
2678
+ void main() {
2679
+ vWorldDirection = transformDirection( position, modelMatrix );
2680
+ #include <begin_vertex>
2681
+ #include <project_vertex>
2682
+ }`,qf=`uniform sampler2D tEquirect;
2683
+ varying vec3 vWorldDirection;
2684
+ #include <common>
2685
+ void main() {
2686
+ vec3 direction = normalize( vWorldDirection );
2687
+ vec2 sampleUV = equirectUv( direction );
2688
+ gl_FragColor = texture2D( tEquirect, sampleUV );
2689
+ #include <tonemapping_fragment>
2690
+ #include <colorspace_fragment>
2691
+ }`,Yf=`uniform float scale;
2692
+ attribute float lineDistance;
2693
+ varying float vLineDistance;
2694
+ #include <common>
2695
+ #include <uv_pars_vertex>
2696
+ #include <color_pars_vertex>
2697
+ #include <fog_pars_vertex>
2698
+ #include <morphtarget_pars_vertex>
2699
+ #include <logdepthbuf_pars_vertex>
2700
+ #include <clipping_planes_pars_vertex>
2701
+ void main() {
2702
+ vLineDistance = scale * lineDistance;
2703
+ #include <uv_vertex>
2704
+ #include <color_vertex>
2705
+ #include <morphinstance_vertex>
2706
+ #include <morphcolor_vertex>
2707
+ #include <begin_vertex>
2708
+ #include <morphtarget_vertex>
2709
+ #include <project_vertex>
2710
+ #include <logdepthbuf_vertex>
2711
+ #include <clipping_planes_vertex>
2712
+ #include <fog_vertex>
2713
+ }`,jf=`uniform vec3 diffuse;
2714
+ uniform float opacity;
2715
+ uniform float dashSize;
2716
+ uniform float totalSize;
2717
+ varying float vLineDistance;
2718
+ #include <common>
2719
+ #include <color_pars_fragment>
2720
+ #include <uv_pars_fragment>
2721
+ #include <map_pars_fragment>
2722
+ #include <fog_pars_fragment>
2723
+ #include <logdepthbuf_pars_fragment>
2724
+ #include <clipping_planes_pars_fragment>
2725
+ void main() {
2726
+ vec4 diffuseColor = vec4( diffuse, opacity );
2727
+ #include <clipping_planes_fragment>
2728
+ if ( mod( vLineDistance, totalSize ) > dashSize ) {
2729
+ discard;
2730
+ }
2731
+ vec3 outgoingLight = vec3( 0.0 );
2732
+ #include <logdepthbuf_fragment>
2733
+ #include <map_fragment>
2734
+ #include <color_fragment>
2735
+ outgoingLight = diffuseColor.rgb;
2736
+ #include <opaque_fragment>
2737
+ #include <tonemapping_fragment>
2738
+ #include <colorspace_fragment>
2739
+ #include <fog_fragment>
2740
+ #include <premultiplied_alpha_fragment>
2741
+ }`,Kf=`#include <common>
2742
+ #include <batching_pars_vertex>
2743
+ #include <uv_pars_vertex>
2744
+ #include <envmap_pars_vertex>
2745
+ #include <color_pars_vertex>
2746
+ #include <fog_pars_vertex>
2747
+ #include <morphtarget_pars_vertex>
2748
+ #include <skinning_pars_vertex>
2749
+ #include <logdepthbuf_pars_vertex>
2750
+ #include <clipping_planes_pars_vertex>
2751
+ void main() {
2752
+ #include <uv_vertex>
2753
+ #include <color_vertex>
2754
+ #include <morphinstance_vertex>
2755
+ #include <morphcolor_vertex>
2756
+ #include <batching_vertex>
2757
+ #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
2758
+ #include <beginnormal_vertex>
2759
+ #include <morphnormal_vertex>
2760
+ #include <skinbase_vertex>
2761
+ #include <skinnormal_vertex>
2762
+ #include <defaultnormal_vertex>
2763
+ #endif
2764
+ #include <begin_vertex>
2765
+ #include <morphtarget_vertex>
2766
+ #include <skinning_vertex>
2767
+ #include <project_vertex>
2768
+ #include <logdepthbuf_vertex>
2769
+ #include <clipping_planes_vertex>
2770
+ #include <worldpos_vertex>
2771
+ #include <envmap_vertex>
2772
+ #include <fog_vertex>
2773
+ }`,Jf=`uniform vec3 diffuse;
2774
+ uniform float opacity;
2775
+ #ifndef FLAT_SHADED
2776
+ varying vec3 vNormal;
2777
+ #endif
2778
+ #include <common>
2779
+ #include <dithering_pars_fragment>
2780
+ #include <color_pars_fragment>
2781
+ #include <uv_pars_fragment>
2782
+ #include <map_pars_fragment>
2783
+ #include <alphamap_pars_fragment>
2784
+ #include <alphatest_pars_fragment>
2785
+ #include <alphahash_pars_fragment>
2786
+ #include <aomap_pars_fragment>
2787
+ #include <lightmap_pars_fragment>
2788
+ #include <envmap_common_pars_fragment>
2789
+ #include <envmap_pars_fragment>
2790
+ #include <fog_pars_fragment>
2791
+ #include <specularmap_pars_fragment>
2792
+ #include <logdepthbuf_pars_fragment>
2793
+ #include <clipping_planes_pars_fragment>
2794
+ void main() {
2795
+ vec4 diffuseColor = vec4( diffuse, opacity );
2796
+ #include <clipping_planes_fragment>
2797
+ #include <logdepthbuf_fragment>
2798
+ #include <map_fragment>
2799
+ #include <color_fragment>
2800
+ #include <alphamap_fragment>
2801
+ #include <alphatest_fragment>
2802
+ #include <alphahash_fragment>
2803
+ #include <specularmap_fragment>
2804
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2805
+ #ifdef USE_LIGHTMAP
2806
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
2807
+ reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
2808
+ #else
2809
+ reflectedLight.indirectDiffuse += vec3( 1.0 );
2810
+ #endif
2811
+ #include <aomap_fragment>
2812
+ reflectedLight.indirectDiffuse *= diffuseColor.rgb;
2813
+ vec3 outgoingLight = reflectedLight.indirectDiffuse;
2814
+ #include <envmap_fragment>
2815
+ #include <opaque_fragment>
2816
+ #include <tonemapping_fragment>
2817
+ #include <colorspace_fragment>
2818
+ #include <fog_fragment>
2819
+ #include <premultiplied_alpha_fragment>
2820
+ #include <dithering_fragment>
2821
+ }`,$f=`#define LAMBERT
2822
+ varying vec3 vViewPosition;
2823
+ #include <common>
2824
+ #include <batching_pars_vertex>
2825
+ #include <uv_pars_vertex>
2826
+ #include <displacementmap_pars_vertex>
2827
+ #include <envmap_pars_vertex>
2828
+ #include <color_pars_vertex>
2829
+ #include <fog_pars_vertex>
2830
+ #include <normal_pars_vertex>
2831
+ #include <morphtarget_pars_vertex>
2832
+ #include <skinning_pars_vertex>
2833
+ #include <shadowmap_pars_vertex>
2834
+ #include <logdepthbuf_pars_vertex>
2835
+ #include <clipping_planes_pars_vertex>
2836
+ void main() {
2837
+ #include <uv_vertex>
2838
+ #include <color_vertex>
2839
+ #include <morphinstance_vertex>
2840
+ #include <morphcolor_vertex>
2841
+ #include <batching_vertex>
2842
+ #include <beginnormal_vertex>
2843
+ #include <morphnormal_vertex>
2844
+ #include <skinbase_vertex>
2845
+ #include <skinnormal_vertex>
2846
+ #include <defaultnormal_vertex>
2847
+ #include <normal_vertex>
2848
+ #include <begin_vertex>
2849
+ #include <morphtarget_vertex>
2850
+ #include <skinning_vertex>
2851
+ #include <displacementmap_vertex>
2852
+ #include <project_vertex>
2853
+ #include <logdepthbuf_vertex>
2854
+ #include <clipping_planes_vertex>
2855
+ vViewPosition = - mvPosition.xyz;
2856
+ #include <worldpos_vertex>
2857
+ #include <envmap_vertex>
2858
+ #include <shadowmap_vertex>
2859
+ #include <fog_vertex>
2860
+ }`,Zf=`#define LAMBERT
2861
+ uniform vec3 diffuse;
2862
+ uniform vec3 emissive;
2863
+ uniform float opacity;
2864
+ #include <common>
2865
+ #include <packing>
2866
+ #include <dithering_pars_fragment>
2867
+ #include <color_pars_fragment>
2868
+ #include <uv_pars_fragment>
2869
+ #include <map_pars_fragment>
2870
+ #include <alphamap_pars_fragment>
2871
+ #include <alphatest_pars_fragment>
2872
+ #include <alphahash_pars_fragment>
2873
+ #include <aomap_pars_fragment>
2874
+ #include <lightmap_pars_fragment>
2875
+ #include <emissivemap_pars_fragment>
2876
+ #include <envmap_common_pars_fragment>
2877
+ #include <envmap_pars_fragment>
2878
+ #include <fog_pars_fragment>
2879
+ #include <bsdfs>
2880
+ #include <lights_pars_begin>
2881
+ #include <normal_pars_fragment>
2882
+ #include <lights_lambert_pars_fragment>
2883
+ #include <shadowmap_pars_fragment>
2884
+ #include <bumpmap_pars_fragment>
2885
+ #include <normalmap_pars_fragment>
2886
+ #include <specularmap_pars_fragment>
2887
+ #include <logdepthbuf_pars_fragment>
2888
+ #include <clipping_planes_pars_fragment>
2889
+ void main() {
2890
+ vec4 diffuseColor = vec4( diffuse, opacity );
2891
+ #include <clipping_planes_fragment>
2892
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2893
+ vec3 totalEmissiveRadiance = emissive;
2894
+ #include <logdepthbuf_fragment>
2895
+ #include <map_fragment>
2896
+ #include <color_fragment>
2897
+ #include <alphamap_fragment>
2898
+ #include <alphatest_fragment>
2899
+ #include <alphahash_fragment>
2900
+ #include <specularmap_fragment>
2901
+ #include <normal_fragment_begin>
2902
+ #include <normal_fragment_maps>
2903
+ #include <emissivemap_fragment>
2904
+ #include <lights_lambert_fragment>
2905
+ #include <lights_fragment_begin>
2906
+ #include <lights_fragment_maps>
2907
+ #include <lights_fragment_end>
2908
+ #include <aomap_fragment>
2909
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
2910
+ #include <envmap_fragment>
2911
+ #include <opaque_fragment>
2912
+ #include <tonemapping_fragment>
2913
+ #include <colorspace_fragment>
2914
+ #include <fog_fragment>
2915
+ #include <premultiplied_alpha_fragment>
2916
+ #include <dithering_fragment>
2917
+ }`,Qf=`#define MATCAP
2918
+ varying vec3 vViewPosition;
2919
+ #include <common>
2920
+ #include <batching_pars_vertex>
2921
+ #include <uv_pars_vertex>
2922
+ #include <color_pars_vertex>
2923
+ #include <displacementmap_pars_vertex>
2924
+ #include <fog_pars_vertex>
2925
+ #include <normal_pars_vertex>
2926
+ #include <morphtarget_pars_vertex>
2927
+ #include <skinning_pars_vertex>
2928
+ #include <logdepthbuf_pars_vertex>
2929
+ #include <clipping_planes_pars_vertex>
2930
+ void main() {
2931
+ #include <uv_vertex>
2932
+ #include <color_vertex>
2933
+ #include <morphinstance_vertex>
2934
+ #include <morphcolor_vertex>
2935
+ #include <batching_vertex>
2936
+ #include <beginnormal_vertex>
2937
+ #include <morphnormal_vertex>
2938
+ #include <skinbase_vertex>
2939
+ #include <skinnormal_vertex>
2940
+ #include <defaultnormal_vertex>
2941
+ #include <normal_vertex>
2942
+ #include <begin_vertex>
2943
+ #include <morphtarget_vertex>
2944
+ #include <skinning_vertex>
2945
+ #include <displacementmap_vertex>
2946
+ #include <project_vertex>
2947
+ #include <logdepthbuf_vertex>
2948
+ #include <clipping_planes_vertex>
2949
+ #include <fog_vertex>
2950
+ vViewPosition = - mvPosition.xyz;
2951
+ }`,ep=`#define MATCAP
2952
+ uniform vec3 diffuse;
2953
+ uniform float opacity;
2954
+ uniform sampler2D matcap;
2955
+ varying vec3 vViewPosition;
2956
+ #include <common>
2957
+ #include <dithering_pars_fragment>
2958
+ #include <color_pars_fragment>
2959
+ #include <uv_pars_fragment>
2960
+ #include <map_pars_fragment>
2961
+ #include <alphamap_pars_fragment>
2962
+ #include <alphatest_pars_fragment>
2963
+ #include <alphahash_pars_fragment>
2964
+ #include <fog_pars_fragment>
2965
+ #include <normal_pars_fragment>
2966
+ #include <bumpmap_pars_fragment>
2967
+ #include <normalmap_pars_fragment>
2968
+ #include <logdepthbuf_pars_fragment>
2969
+ #include <clipping_planes_pars_fragment>
2970
+ void main() {
2971
+ vec4 diffuseColor = vec4( diffuse, opacity );
2972
+ #include <clipping_planes_fragment>
2973
+ #include <logdepthbuf_fragment>
2974
+ #include <map_fragment>
2975
+ #include <color_fragment>
2976
+ #include <alphamap_fragment>
2977
+ #include <alphatest_fragment>
2978
+ #include <alphahash_fragment>
2979
+ #include <normal_fragment_begin>
2980
+ #include <normal_fragment_maps>
2981
+ vec3 viewDir = normalize( vViewPosition );
2982
+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
2983
+ vec3 y = cross( viewDir, x );
2984
+ vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
2985
+ #ifdef USE_MATCAP
2986
+ vec4 matcapColor = texture2D( matcap, uv );
2987
+ #else
2988
+ vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
2989
+ #endif
2990
+ vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
2991
+ #include <opaque_fragment>
2992
+ #include <tonemapping_fragment>
2993
+ #include <colorspace_fragment>
2994
+ #include <fog_fragment>
2995
+ #include <premultiplied_alpha_fragment>
2996
+ #include <dithering_fragment>
2997
+ }`,tp=`#define NORMAL
2998
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
2999
+ varying vec3 vViewPosition;
3000
+ #endif
3001
+ #include <common>
3002
+ #include <batching_pars_vertex>
3003
+ #include <uv_pars_vertex>
3004
+ #include <displacementmap_pars_vertex>
3005
+ #include <normal_pars_vertex>
3006
+ #include <morphtarget_pars_vertex>
3007
+ #include <skinning_pars_vertex>
3008
+ #include <logdepthbuf_pars_vertex>
3009
+ #include <clipping_planes_pars_vertex>
3010
+ void main() {
3011
+ #include <uv_vertex>
3012
+ #include <batching_vertex>
3013
+ #include <beginnormal_vertex>
3014
+ #include <morphinstance_vertex>
3015
+ #include <morphnormal_vertex>
3016
+ #include <skinbase_vertex>
3017
+ #include <skinnormal_vertex>
3018
+ #include <defaultnormal_vertex>
3019
+ #include <normal_vertex>
3020
+ #include <begin_vertex>
3021
+ #include <morphtarget_vertex>
3022
+ #include <skinning_vertex>
3023
+ #include <displacementmap_vertex>
3024
+ #include <project_vertex>
3025
+ #include <logdepthbuf_vertex>
3026
+ #include <clipping_planes_vertex>
3027
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3028
+ vViewPosition = - mvPosition.xyz;
3029
+ #endif
3030
+ }`,np=`#define NORMAL
3031
+ uniform float opacity;
3032
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3033
+ varying vec3 vViewPosition;
3034
+ #endif
3035
+ #include <packing>
3036
+ #include <uv_pars_fragment>
3037
+ #include <normal_pars_fragment>
3038
+ #include <bumpmap_pars_fragment>
3039
+ #include <normalmap_pars_fragment>
3040
+ #include <logdepthbuf_pars_fragment>
3041
+ #include <clipping_planes_pars_fragment>
3042
+ void main() {
3043
+ vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
3044
+ #include <clipping_planes_fragment>
3045
+ #include <logdepthbuf_fragment>
3046
+ #include <normal_fragment_begin>
3047
+ #include <normal_fragment_maps>
3048
+ gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
3049
+ #ifdef OPAQUE
3050
+ gl_FragColor.a = 1.0;
3051
+ #endif
3052
+ }`,ip=`#define PHONG
3053
+ varying vec3 vViewPosition;
3054
+ #include <common>
3055
+ #include <batching_pars_vertex>
3056
+ #include <uv_pars_vertex>
3057
+ #include <displacementmap_pars_vertex>
3058
+ #include <envmap_pars_vertex>
3059
+ #include <color_pars_vertex>
3060
+ #include <fog_pars_vertex>
3061
+ #include <normal_pars_vertex>
3062
+ #include <morphtarget_pars_vertex>
3063
+ #include <skinning_pars_vertex>
3064
+ #include <shadowmap_pars_vertex>
3065
+ #include <logdepthbuf_pars_vertex>
3066
+ #include <clipping_planes_pars_vertex>
3067
+ void main() {
3068
+ #include <uv_vertex>
3069
+ #include <color_vertex>
3070
+ #include <morphcolor_vertex>
3071
+ #include <batching_vertex>
3072
+ #include <beginnormal_vertex>
3073
+ #include <morphinstance_vertex>
3074
+ #include <morphnormal_vertex>
3075
+ #include <skinbase_vertex>
3076
+ #include <skinnormal_vertex>
3077
+ #include <defaultnormal_vertex>
3078
+ #include <normal_vertex>
3079
+ #include <begin_vertex>
3080
+ #include <morphtarget_vertex>
3081
+ #include <skinning_vertex>
3082
+ #include <displacementmap_vertex>
3083
+ #include <project_vertex>
3084
+ #include <logdepthbuf_vertex>
3085
+ #include <clipping_planes_vertex>
3086
+ vViewPosition = - mvPosition.xyz;
3087
+ #include <worldpos_vertex>
3088
+ #include <envmap_vertex>
3089
+ #include <shadowmap_vertex>
3090
+ #include <fog_vertex>
3091
+ }`,sp=`#define PHONG
3092
+ uniform vec3 diffuse;
3093
+ uniform vec3 emissive;
3094
+ uniform vec3 specular;
3095
+ uniform float shininess;
3096
+ uniform float opacity;
3097
+ #include <common>
3098
+ #include <packing>
3099
+ #include <dithering_pars_fragment>
3100
+ #include <color_pars_fragment>
3101
+ #include <uv_pars_fragment>
3102
+ #include <map_pars_fragment>
3103
+ #include <alphamap_pars_fragment>
3104
+ #include <alphatest_pars_fragment>
3105
+ #include <alphahash_pars_fragment>
3106
+ #include <aomap_pars_fragment>
3107
+ #include <lightmap_pars_fragment>
3108
+ #include <emissivemap_pars_fragment>
3109
+ #include <envmap_common_pars_fragment>
3110
+ #include <envmap_pars_fragment>
3111
+ #include <fog_pars_fragment>
3112
+ #include <bsdfs>
3113
+ #include <lights_pars_begin>
3114
+ #include <normal_pars_fragment>
3115
+ #include <lights_phong_pars_fragment>
3116
+ #include <shadowmap_pars_fragment>
3117
+ #include <bumpmap_pars_fragment>
3118
+ #include <normalmap_pars_fragment>
3119
+ #include <specularmap_pars_fragment>
3120
+ #include <logdepthbuf_pars_fragment>
3121
+ #include <clipping_planes_pars_fragment>
3122
+ void main() {
3123
+ vec4 diffuseColor = vec4( diffuse, opacity );
3124
+ #include <clipping_planes_fragment>
3125
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3126
+ vec3 totalEmissiveRadiance = emissive;
3127
+ #include <logdepthbuf_fragment>
3128
+ #include <map_fragment>
3129
+ #include <color_fragment>
3130
+ #include <alphamap_fragment>
3131
+ #include <alphatest_fragment>
3132
+ #include <alphahash_fragment>
3133
+ #include <specularmap_fragment>
3134
+ #include <normal_fragment_begin>
3135
+ #include <normal_fragment_maps>
3136
+ #include <emissivemap_fragment>
3137
+ #include <lights_phong_fragment>
3138
+ #include <lights_fragment_begin>
3139
+ #include <lights_fragment_maps>
3140
+ #include <lights_fragment_end>
3141
+ #include <aomap_fragment>
3142
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
3143
+ #include <envmap_fragment>
3144
+ #include <opaque_fragment>
3145
+ #include <tonemapping_fragment>
3146
+ #include <colorspace_fragment>
3147
+ #include <fog_fragment>
3148
+ #include <premultiplied_alpha_fragment>
3149
+ #include <dithering_fragment>
3150
+ }`,rp=`#define STANDARD
3151
+ varying vec3 vViewPosition;
3152
+ #ifdef USE_TRANSMISSION
3153
+ varying vec3 vWorldPosition;
3154
+ #endif
3155
+ #include <common>
3156
+ #include <batching_pars_vertex>
3157
+ #include <uv_pars_vertex>
3158
+ #include <displacementmap_pars_vertex>
3159
+ #include <color_pars_vertex>
3160
+ #include <fog_pars_vertex>
3161
+ #include <normal_pars_vertex>
3162
+ #include <morphtarget_pars_vertex>
3163
+ #include <skinning_pars_vertex>
3164
+ #include <shadowmap_pars_vertex>
3165
+ #include <logdepthbuf_pars_vertex>
3166
+ #include <clipping_planes_pars_vertex>
3167
+ void main() {
3168
+ #include <uv_vertex>
3169
+ #include <color_vertex>
3170
+ #include <morphinstance_vertex>
3171
+ #include <morphcolor_vertex>
3172
+ #include <batching_vertex>
3173
+ #include <beginnormal_vertex>
3174
+ #include <morphnormal_vertex>
3175
+ #include <skinbase_vertex>
3176
+ #include <skinnormal_vertex>
3177
+ #include <defaultnormal_vertex>
3178
+ #include <normal_vertex>
3179
+ #include <begin_vertex>
3180
+ #include <morphtarget_vertex>
3181
+ #include <skinning_vertex>
3182
+ #include <displacementmap_vertex>
3183
+ #include <project_vertex>
3184
+ #include <logdepthbuf_vertex>
3185
+ #include <clipping_planes_vertex>
3186
+ vViewPosition = - mvPosition.xyz;
3187
+ #include <worldpos_vertex>
3188
+ #include <shadowmap_vertex>
3189
+ #include <fog_vertex>
3190
+ #ifdef USE_TRANSMISSION
3191
+ vWorldPosition = worldPosition.xyz;
3192
+ #endif
3193
+ }`,ap=`#define STANDARD
3194
+ #ifdef PHYSICAL
3195
+ #define IOR
3196
+ #define USE_SPECULAR
3197
+ #endif
3198
+ uniform vec3 diffuse;
3199
+ uniform vec3 emissive;
3200
+ uniform float roughness;
3201
+ uniform float metalness;
3202
+ uniform float opacity;
3203
+ #ifdef IOR
3204
+ uniform float ior;
3205
+ #endif
3206
+ #ifdef USE_SPECULAR
3207
+ uniform float specularIntensity;
3208
+ uniform vec3 specularColor;
3209
+ #ifdef USE_SPECULAR_COLORMAP
3210
+ uniform sampler2D specularColorMap;
3211
+ #endif
3212
+ #ifdef USE_SPECULAR_INTENSITYMAP
3213
+ uniform sampler2D specularIntensityMap;
3214
+ #endif
3215
+ #endif
3216
+ #ifdef USE_CLEARCOAT
3217
+ uniform float clearcoat;
3218
+ uniform float clearcoatRoughness;
3219
+ #endif
3220
+ #ifdef USE_IRIDESCENCE
3221
+ uniform float iridescence;
3222
+ uniform float iridescenceIOR;
3223
+ uniform float iridescenceThicknessMinimum;
3224
+ uniform float iridescenceThicknessMaximum;
3225
+ #endif
3226
+ #ifdef USE_SHEEN
3227
+ uniform vec3 sheenColor;
3228
+ uniform float sheenRoughness;
3229
+ #ifdef USE_SHEEN_COLORMAP
3230
+ uniform sampler2D sheenColorMap;
3231
+ #endif
3232
+ #ifdef USE_SHEEN_ROUGHNESSMAP
3233
+ uniform sampler2D sheenRoughnessMap;
3234
+ #endif
3235
+ #endif
3236
+ #ifdef USE_ANISOTROPY
3237
+ uniform vec2 anisotropyVector;
3238
+ #ifdef USE_ANISOTROPYMAP
3239
+ uniform sampler2D anisotropyMap;
3240
+ #endif
3241
+ #endif
3242
+ varying vec3 vViewPosition;
3243
+ #include <common>
3244
+ #include <packing>
3245
+ #include <dithering_pars_fragment>
3246
+ #include <color_pars_fragment>
3247
+ #include <uv_pars_fragment>
3248
+ #include <map_pars_fragment>
3249
+ #include <alphamap_pars_fragment>
3250
+ #include <alphatest_pars_fragment>
3251
+ #include <alphahash_pars_fragment>
3252
+ #include <aomap_pars_fragment>
3253
+ #include <lightmap_pars_fragment>
3254
+ #include <emissivemap_pars_fragment>
3255
+ #include <iridescence_fragment>
3256
+ #include <cube_uv_reflection_fragment>
3257
+ #include <envmap_common_pars_fragment>
3258
+ #include <envmap_physical_pars_fragment>
3259
+ #include <fog_pars_fragment>
3260
+ #include <lights_pars_begin>
3261
+ #include <normal_pars_fragment>
3262
+ #include <lights_physical_pars_fragment>
3263
+ #include <transmission_pars_fragment>
3264
+ #include <shadowmap_pars_fragment>
3265
+ #include <bumpmap_pars_fragment>
3266
+ #include <normalmap_pars_fragment>
3267
+ #include <clearcoat_pars_fragment>
3268
+ #include <iridescence_pars_fragment>
3269
+ #include <roughnessmap_pars_fragment>
3270
+ #include <metalnessmap_pars_fragment>
3271
+ #include <logdepthbuf_pars_fragment>
3272
+ #include <clipping_planes_pars_fragment>
3273
+ void main() {
3274
+ vec4 diffuseColor = vec4( diffuse, opacity );
3275
+ #include <clipping_planes_fragment>
3276
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3277
+ vec3 totalEmissiveRadiance = emissive;
3278
+ #include <logdepthbuf_fragment>
3279
+ #include <map_fragment>
3280
+ #include <color_fragment>
3281
+ #include <alphamap_fragment>
3282
+ #include <alphatest_fragment>
3283
+ #include <alphahash_fragment>
3284
+ #include <roughnessmap_fragment>
3285
+ #include <metalnessmap_fragment>
3286
+ #include <normal_fragment_begin>
3287
+ #include <normal_fragment_maps>
3288
+ #include <clearcoat_normal_fragment_begin>
3289
+ #include <clearcoat_normal_fragment_maps>
3290
+ #include <emissivemap_fragment>
3291
+ #include <lights_physical_fragment>
3292
+ #include <lights_fragment_begin>
3293
+ #include <lights_fragment_maps>
3294
+ #include <lights_fragment_end>
3295
+ #include <aomap_fragment>
3296
+ vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
3297
+ vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
3298
+ #include <transmission_fragment>
3299
+ vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
3300
+ #ifdef USE_SHEEN
3301
+ float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
3302
+ outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
3303
+ #endif
3304
+ #ifdef USE_CLEARCOAT
3305
+ float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
3306
+ vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
3307
+ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
3308
+ #endif
3309
+ #include <opaque_fragment>
3310
+ #include <tonemapping_fragment>
3311
+ #include <colorspace_fragment>
3312
+ #include <fog_fragment>
3313
+ #include <premultiplied_alpha_fragment>
3314
+ #include <dithering_fragment>
3315
+ }`,op=`#define TOON
3316
+ varying vec3 vViewPosition;
3317
+ #include <common>
3318
+ #include <batching_pars_vertex>
3319
+ #include <uv_pars_vertex>
3320
+ #include <displacementmap_pars_vertex>
3321
+ #include <color_pars_vertex>
3322
+ #include <fog_pars_vertex>
3323
+ #include <normal_pars_vertex>
3324
+ #include <morphtarget_pars_vertex>
3325
+ #include <skinning_pars_vertex>
3326
+ #include <shadowmap_pars_vertex>
3327
+ #include <logdepthbuf_pars_vertex>
3328
+ #include <clipping_planes_pars_vertex>
3329
+ void main() {
3330
+ #include <uv_vertex>
3331
+ #include <color_vertex>
3332
+ #include <morphinstance_vertex>
3333
+ #include <morphcolor_vertex>
3334
+ #include <batching_vertex>
3335
+ #include <beginnormal_vertex>
3336
+ #include <morphnormal_vertex>
3337
+ #include <skinbase_vertex>
3338
+ #include <skinnormal_vertex>
3339
+ #include <defaultnormal_vertex>
3340
+ #include <normal_vertex>
3341
+ #include <begin_vertex>
3342
+ #include <morphtarget_vertex>
3343
+ #include <skinning_vertex>
3344
+ #include <displacementmap_vertex>
3345
+ #include <project_vertex>
3346
+ #include <logdepthbuf_vertex>
3347
+ #include <clipping_planes_vertex>
3348
+ vViewPosition = - mvPosition.xyz;
3349
+ #include <worldpos_vertex>
3350
+ #include <shadowmap_vertex>
3351
+ #include <fog_vertex>
3352
+ }`,cp=`#define TOON
3353
+ uniform vec3 diffuse;
3354
+ uniform vec3 emissive;
3355
+ uniform float opacity;
3356
+ #include <common>
3357
+ #include <packing>
3358
+ #include <dithering_pars_fragment>
3359
+ #include <color_pars_fragment>
3360
+ #include <uv_pars_fragment>
3361
+ #include <map_pars_fragment>
3362
+ #include <alphamap_pars_fragment>
3363
+ #include <alphatest_pars_fragment>
3364
+ #include <alphahash_pars_fragment>
3365
+ #include <aomap_pars_fragment>
3366
+ #include <lightmap_pars_fragment>
3367
+ #include <emissivemap_pars_fragment>
3368
+ #include <gradientmap_pars_fragment>
3369
+ #include <fog_pars_fragment>
3370
+ #include <bsdfs>
3371
+ #include <lights_pars_begin>
3372
+ #include <normal_pars_fragment>
3373
+ #include <lights_toon_pars_fragment>
3374
+ #include <shadowmap_pars_fragment>
3375
+ #include <bumpmap_pars_fragment>
3376
+ #include <normalmap_pars_fragment>
3377
+ #include <logdepthbuf_pars_fragment>
3378
+ #include <clipping_planes_pars_fragment>
3379
+ void main() {
3380
+ vec4 diffuseColor = vec4( diffuse, opacity );
3381
+ #include <clipping_planes_fragment>
3382
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3383
+ vec3 totalEmissiveRadiance = emissive;
3384
+ #include <logdepthbuf_fragment>
3385
+ #include <map_fragment>
3386
+ #include <color_fragment>
3387
+ #include <alphamap_fragment>
3388
+ #include <alphatest_fragment>
3389
+ #include <alphahash_fragment>
3390
+ #include <normal_fragment_begin>
3391
+ #include <normal_fragment_maps>
3392
+ #include <emissivemap_fragment>
3393
+ #include <lights_toon_fragment>
3394
+ #include <lights_fragment_begin>
3395
+ #include <lights_fragment_maps>
3396
+ #include <lights_fragment_end>
3397
+ #include <aomap_fragment>
3398
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
3399
+ #include <opaque_fragment>
3400
+ #include <tonemapping_fragment>
3401
+ #include <colorspace_fragment>
3402
+ #include <fog_fragment>
3403
+ #include <premultiplied_alpha_fragment>
3404
+ #include <dithering_fragment>
3405
+ }`,lp=`uniform float size;
3406
+ uniform float scale;
3407
+ #include <common>
3408
+ #include <color_pars_vertex>
3409
+ #include <fog_pars_vertex>
3410
+ #include <morphtarget_pars_vertex>
3411
+ #include <logdepthbuf_pars_vertex>
3412
+ #include <clipping_planes_pars_vertex>
3413
+ #ifdef USE_POINTS_UV
3414
+ varying vec2 vUv;
3415
+ uniform mat3 uvTransform;
3416
+ #endif
3417
+ void main() {
3418
+ #ifdef USE_POINTS_UV
3419
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
3420
+ #endif
3421
+ #include <color_vertex>
3422
+ #include <morphinstance_vertex>
3423
+ #include <morphcolor_vertex>
3424
+ #include <begin_vertex>
3425
+ #include <morphtarget_vertex>
3426
+ #include <project_vertex>
3427
+ gl_PointSize = size;
3428
+ #ifdef USE_SIZEATTENUATION
3429
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3430
+ if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
3431
+ #endif
3432
+ #include <logdepthbuf_vertex>
3433
+ #include <clipping_planes_vertex>
3434
+ #include <worldpos_vertex>
3435
+ #include <fog_vertex>
3436
+ }`,hp=`uniform vec3 diffuse;
3437
+ uniform float opacity;
3438
+ #include <common>
3439
+ #include <color_pars_fragment>
3440
+ #include <map_particle_pars_fragment>
3441
+ #include <alphatest_pars_fragment>
3442
+ #include <alphahash_pars_fragment>
3443
+ #include <fog_pars_fragment>
3444
+ #include <logdepthbuf_pars_fragment>
3445
+ #include <clipping_planes_pars_fragment>
3446
+ void main() {
3447
+ vec4 diffuseColor = vec4( diffuse, opacity );
3448
+ #include <clipping_planes_fragment>
3449
+ vec3 outgoingLight = vec3( 0.0 );
3450
+ #include <logdepthbuf_fragment>
3451
+ #include <map_particle_fragment>
3452
+ #include <color_fragment>
3453
+ #include <alphatest_fragment>
3454
+ #include <alphahash_fragment>
3455
+ outgoingLight = diffuseColor.rgb;
3456
+ #include <opaque_fragment>
3457
+ #include <tonemapping_fragment>
3458
+ #include <colorspace_fragment>
3459
+ #include <fog_fragment>
3460
+ #include <premultiplied_alpha_fragment>
3461
+ }`,up=`#include <common>
3462
+ #include <batching_pars_vertex>
3463
+ #include <fog_pars_vertex>
3464
+ #include <morphtarget_pars_vertex>
3465
+ #include <skinning_pars_vertex>
3466
+ #include <logdepthbuf_pars_vertex>
3467
+ #include <shadowmap_pars_vertex>
3468
+ void main() {
3469
+ #include <batching_vertex>
3470
+ #include <beginnormal_vertex>
3471
+ #include <morphinstance_vertex>
3472
+ #include <morphnormal_vertex>
3473
+ #include <skinbase_vertex>
3474
+ #include <skinnormal_vertex>
3475
+ #include <defaultnormal_vertex>
3476
+ #include <begin_vertex>
3477
+ #include <morphtarget_vertex>
3478
+ #include <skinning_vertex>
3479
+ #include <project_vertex>
3480
+ #include <logdepthbuf_vertex>
3481
+ #include <worldpos_vertex>
3482
+ #include <shadowmap_vertex>
3483
+ #include <fog_vertex>
3484
+ }`,dp=`uniform vec3 color;
3485
+ uniform float opacity;
3486
+ #include <common>
3487
+ #include <packing>
3488
+ #include <fog_pars_fragment>
3489
+ #include <bsdfs>
3490
+ #include <lights_pars_begin>
3491
+ #include <logdepthbuf_pars_fragment>
3492
+ #include <shadowmap_pars_fragment>
3493
+ #include <shadowmask_pars_fragment>
3494
+ void main() {
3495
+ #include <logdepthbuf_fragment>
3496
+ gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
3497
+ #include <tonemapping_fragment>
3498
+ #include <colorspace_fragment>
3499
+ #include <fog_fragment>
3500
+ }`,fp=`uniform float rotation;
3501
+ uniform vec2 center;
3502
+ #include <common>
3503
+ #include <uv_pars_vertex>
3504
+ #include <fog_pars_vertex>
3505
+ #include <logdepthbuf_pars_vertex>
3506
+ #include <clipping_planes_pars_vertex>
3507
+ void main() {
3508
+ #include <uv_vertex>
3509
+ vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
3510
+ vec2 scale;
3511
+ scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
3512
+ scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
3513
+ #ifndef USE_SIZEATTENUATION
3514
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3515
+ if ( isPerspective ) scale *= - mvPosition.z;
3516
+ #endif
3517
+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
3518
+ vec2 rotatedPosition;
3519
+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
3520
+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
3521
+ mvPosition.xy += rotatedPosition;
3522
+ gl_Position = projectionMatrix * mvPosition;
3523
+ #include <logdepthbuf_vertex>
3524
+ #include <clipping_planes_vertex>
3525
+ #include <fog_vertex>
3526
+ }`,pp=`uniform vec3 diffuse;
3527
+ uniform float opacity;
3528
+ #include <common>
3529
+ #include <uv_pars_fragment>
3530
+ #include <map_pars_fragment>
3531
+ #include <alphamap_pars_fragment>
3532
+ #include <alphatest_pars_fragment>
3533
+ #include <alphahash_pars_fragment>
3534
+ #include <fog_pars_fragment>
3535
+ #include <logdepthbuf_pars_fragment>
3536
+ #include <clipping_planes_pars_fragment>
3537
+ void main() {
3538
+ vec4 diffuseColor = vec4( diffuse, opacity );
3539
+ #include <clipping_planes_fragment>
3540
+ vec3 outgoingLight = vec3( 0.0 );
3541
+ #include <logdepthbuf_fragment>
3542
+ #include <map_fragment>
3543
+ #include <alphamap_fragment>
3544
+ #include <alphatest_fragment>
3545
+ #include <alphahash_fragment>
3546
+ outgoingLight = diffuseColor.rgb;
3547
+ #include <opaque_fragment>
3548
+ #include <tonemapping_fragment>
3549
+ #include <colorspace_fragment>
3550
+ #include <fog_fragment>
3551
+ }`,De={alphahash_fragment:Du,alphahash_pars_fragment:Uu,alphamap_fragment:Ou,alphamap_pars_fragment:Fu,alphatest_fragment:Bu,alphatest_pars_fragment:zu,aomap_fragment:Hu,aomap_pars_fragment:Gu,batching_pars_vertex:ku,batching_vertex:Vu,begin_vertex:Wu,beginnormal_vertex:Xu,bsdfs:qu,iridescence_fragment:Yu,bumpmap_pars_fragment:ju,clipping_planes_fragment:Ku,clipping_planes_pars_fragment:Ju,clipping_planes_pars_vertex:$u,clipping_planes_vertex:Zu,color_fragment:Qu,color_pars_fragment:ed,color_pars_vertex:td,color_vertex:nd,common:id,cube_uv_reflection_fragment:sd,defaultnormal_vertex:rd,displacementmap_pars_vertex:ad,displacementmap_vertex:od,emissivemap_fragment:cd,emissivemap_pars_fragment:ld,colorspace_fragment:hd,colorspace_pars_fragment:ud,envmap_fragment:dd,envmap_common_pars_fragment:fd,envmap_pars_fragment:pd,envmap_pars_vertex:md,envmap_physical_pars_fragment:wd,envmap_vertex:gd,fog_vertex:_d,fog_pars_vertex:vd,fog_fragment:xd,fog_pars_fragment:Md,gradientmap_pars_fragment:yd,lightmap_fragment:Sd,lightmap_pars_fragment:Ed,lights_lambert_fragment:Td,lights_lambert_pars_fragment:Ad,lights_pars_begin:bd,lights_toon_fragment:Rd,lights_toon_pars_fragment:Cd,lights_phong_fragment:Ld,lights_phong_pars_fragment:Pd,lights_physical_fragment:Id,lights_physical_pars_fragment:Nd,lights_fragment_begin:Dd,lights_fragment_maps:Ud,lights_fragment_end:Od,logdepthbuf_fragment:Fd,logdepthbuf_pars_fragment:Bd,logdepthbuf_pars_vertex:zd,logdepthbuf_vertex:Hd,map_fragment:Gd,map_pars_fragment:kd,map_particle_fragment:Vd,map_particle_pars_fragment:Wd,metalnessmap_fragment:Xd,metalnessmap_pars_fragment:qd,morphinstance_vertex:Yd,morphcolor_vertex:jd,morphnormal_vertex:Kd,morphtarget_pars_vertex:Jd,morphtarget_vertex:$d,normal_fragment_begin:Zd,normal_fragment_maps:Qd,normal_pars_fragment:ef,normal_pars_vertex:tf,normal_vertex:nf,normalmap_pars_fragment:sf,clearcoat_normal_fragment_begin:rf,clearcoat_normal_fragment_maps:af,clearcoat_pars_fragment:of,iridescence_pars_fragment:cf,opaque_fragment:lf,packing:hf,premultiplied_alpha_fragment:uf,project_vertex:df,dithering_fragment:ff,dithering_pars_fragment:pf,roughnessmap_fragment:mf,roughnessmap_pars_fragment:gf,shadowmap_pars_fragment:_f,shadowmap_pars_vertex:vf,shadowmap_vertex:xf,shadowmask_pars_fragment:Mf,skinbase_vertex:yf,skinning_pars_vertex:Sf,skinning_vertex:Ef,skinnormal_vertex:Tf,specularmap_fragment:Af,specularmap_pars_fragment:bf,tonemapping_fragment:wf,tonemapping_pars_fragment:Rf,transmission_fragment:Cf,transmission_pars_fragment:Lf,uv_pars_fragment:Pf,uv_pars_vertex:If,uv_vertex:Nf,worldpos_vertex:Df,background_vert:Uf,background_frag:Of,backgroundCube_vert:Ff,backgroundCube_frag:Bf,cube_vert:zf,cube_frag:Hf,depth_vert:Gf,depth_frag:kf,distanceRGBA_vert:Vf,distanceRGBA_frag:Wf,equirect_vert:Xf,equirect_frag:qf,linedashed_vert:Yf,linedashed_frag:jf,meshbasic_vert:Kf,meshbasic_frag:Jf,meshlambert_vert:$f,meshlambert_frag:Zf,meshmatcap_vert:Qf,meshmatcap_frag:ep,meshnormal_vert:tp,meshnormal_frag:np,meshphong_vert:ip,meshphong_frag:sp,meshphysical_vert:rp,meshphysical_frag:ap,meshtoon_vert:op,meshtoon_frag:cp,points_vert:lp,points_frag:hp,shadow_vert:up,shadow_frag:dp,sprite_vert:fp,sprite_frag:pp},ne={common:{diffuse:{value:new ve(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ue},alphaMap:{value:null},alphaMapTransform:{value:new Ue},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ue}},envmap:{envMap:{value:null},envMapRotation:{value:new Ue},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ue}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ue}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ue},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ue},normalScale:{value:new re(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ue},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ue}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ue}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ue}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ve(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:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{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 ve(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ue},alphaTest:{value:0},uvTransform:{value:new Ue}},sprite:{diffuse:{value:new ve(16777215)},opacity:{value:1},center:{value:new re(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ue},alphaMap:{value:null},alphaMapTransform:{value:new Ue},alphaTest:{value:0}}},$t={basic:{uniforms:bt([ne.common,ne.specularmap,ne.envmap,ne.aomap,ne.lightmap,ne.fog]),vertexShader:De.meshbasic_vert,fragmentShader:De.meshbasic_frag},lambert:{uniforms:bt([ne.common,ne.specularmap,ne.envmap,ne.aomap,ne.lightmap,ne.emissivemap,ne.bumpmap,ne.normalmap,ne.displacementmap,ne.fog,ne.lights,{emissive:{value:new ve(0)}}]),vertexShader:De.meshlambert_vert,fragmentShader:De.meshlambert_frag},phong:{uniforms:bt([ne.common,ne.specularmap,ne.envmap,ne.aomap,ne.lightmap,ne.emissivemap,ne.bumpmap,ne.normalmap,ne.displacementmap,ne.fog,ne.lights,{emissive:{value:new ve(0)},specular:{value:new ve(1118481)},shininess:{value:30}}]),vertexShader:De.meshphong_vert,fragmentShader:De.meshphong_frag},standard:{uniforms:bt([ne.common,ne.envmap,ne.aomap,ne.lightmap,ne.emissivemap,ne.bumpmap,ne.normalmap,ne.displacementmap,ne.roughnessmap,ne.metalnessmap,ne.fog,ne.lights,{emissive:{value:new ve(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:De.meshphysical_vert,fragmentShader:De.meshphysical_frag},toon:{uniforms:bt([ne.common,ne.aomap,ne.lightmap,ne.emissivemap,ne.bumpmap,ne.normalmap,ne.displacementmap,ne.gradientmap,ne.fog,ne.lights,{emissive:{value:new ve(0)}}]),vertexShader:De.meshtoon_vert,fragmentShader:De.meshtoon_frag},matcap:{uniforms:bt([ne.common,ne.bumpmap,ne.normalmap,ne.displacementmap,ne.fog,{matcap:{value:null}}]),vertexShader:De.meshmatcap_vert,fragmentShader:De.meshmatcap_frag},points:{uniforms:bt([ne.points,ne.fog]),vertexShader:De.points_vert,fragmentShader:De.points_frag},dashed:{uniforms:bt([ne.common,ne.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:De.linedashed_vert,fragmentShader:De.linedashed_frag},depth:{uniforms:bt([ne.common,ne.displacementmap]),vertexShader:De.depth_vert,fragmentShader:De.depth_frag},normal:{uniforms:bt([ne.common,ne.bumpmap,ne.normalmap,ne.displacementmap,{opacity:{value:1}}]),vertexShader:De.meshnormal_vert,fragmentShader:De.meshnormal_frag},sprite:{uniforms:bt([ne.sprite,ne.fog]),vertexShader:De.sprite_vert,fragmentShader:De.sprite_frag},background:{uniforms:{uvTransform:{value:new Ue},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:De.background_vert,fragmentShader:De.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ue}},vertexShader:De.backgroundCube_vert,fragmentShader:De.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:De.cube_vert,fragmentShader:De.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:De.equirect_vert,fragmentShader:De.equirect_frag},distanceRGBA:{uniforms:bt([ne.common,ne.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:De.distanceRGBA_vert,fragmentShader:De.distanceRGBA_frag},shadow:{uniforms:bt([ne.lights,ne.fog,{color:{value:new ve(0)},opacity:{value:1}}]),vertexShader:De.shadow_vert,fragmentShader:De.shadow_frag}};$t.physical={uniforms:bt([$t.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ue},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ue},clearcoatNormalScale:{value:new re(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ue},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ue},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ue},sheen:{value:0},sheenColor:{value:new ve(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ue},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ue},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ue},transmissionSamplerSize:{value:new re},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ue},attenuationDistance:{value:0},attenuationColor:{value:new ve(0)},specularColor:{value:new ve(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ue},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ue},anisotropyVector:{value:new re},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ue}}]),vertexShader:De.meshphysical_vert,fragmentShader:De.meshphysical_frag};const Ps={r:0,b:0,g:0},Fn=new Kt,mp=new be;function gp(r,e,t,n,i,s,a){const o=new ve(0);let c=s===!0?0:1,l,h,u=null,d=0,f=null;function g(m,p){let S=!1,v=p.isScene===!0?p.background:null;v&&v.isTexture&&(v=(p.backgroundBlurriness>0?t:e).get(v)),v===null?_(o,c):v&&v.isColor&&(_(v,1),S=!0);const E=r.xr.getEnvironmentBlendMode();E==="additive"?n.buffers.color.setClear(0,0,0,1,a):E==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(r.autoClear||S)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),v&&(v.isCubeTexture||v.mapping===er)?(h===void 0&&(h=new Nt(new os(1,1,1),new Ln({name:"BackgroundCubeMaterial",uniforms:Ii($t.backgroundCube.uniforms),vertexShader:$t.backgroundCube.vertexShader,fragmentShader:$t.backgroundCube.fragmentShader,side:Ct,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(C,A,b){this.matrixWorld.copyPosition(b.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),Fn.copy(p.backgroundRotation),Fn.x*=-1,Fn.y*=-1,Fn.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(Fn.y*=-1,Fn.z*=-1),h.material.uniforms.envMap.value=v,h.material.uniforms.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=p.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=p.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(mp.makeRotationFromEuler(Fn)),h.material.toneMapped=qe.getTransfer(v.colorSpace)!==Qe,(u!==v||d!==v.version||f!==r.toneMapping)&&(h.material.needsUpdate=!0,u=v,d=v.version,f=r.toneMapping),h.layers.enableAll(),m.unshift(h,h.geometry,h.material,0,0,null)):v&&v.isTexture&&(l===void 0&&(l=new Nt(new nr(2,2),new Ln({name:"BackgroundMaterial",uniforms:Ii($t.background.uniforms),vertexShader:$t.background.vertexShader,fragmentShader:$t.background.fragmentShader,side:pn,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=v,l.material.uniforms.backgroundIntensity.value=p.backgroundIntensity,l.material.toneMapped=qe.getTransfer(v.colorSpace)!==Qe,v.matrixAutoUpdate===!0&&v.updateMatrix(),l.material.uniforms.uvTransform.value.copy(v.matrix),(u!==v||d!==v.version||f!==r.toneMapping)&&(l.material.needsUpdate=!0,u=v,d=v.version,f=r.toneMapping),l.layers.enableAll(),m.unshift(l,l.geometry,l.material,0,0,null))}function _(m,p){m.getRGB(Ps,ol(r)),n.buffers.color.setClear(Ps.r,Ps.g,Ps.b,p,a)}return{getClearColor:function(){return o},setClearColor:function(m,p=1){o.set(m),c=p,_(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(m){c=m,_(o,c)},render:g}}function _p(r,e,t,n){const i=r.getParameter(r.MAX_VERTEX_ATTRIBS),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),a=n.isWebGL2||s!==null,o={},c=m(null);let l=c,h=!1;function u(L,V,G,Y,W){let X=!1;if(a){const ee=_(Y,G,V);l!==ee&&(l=ee,f(l.object)),X=p(L,Y,G,W),X&&S(L,Y,G,W)}else{const ee=V.wireframe===!0;(l.geometry!==Y.id||l.program!==G.id||l.wireframe!==ee)&&(l.geometry=Y.id,l.program=G.id,l.wireframe=ee,X=!0)}W!==null&&t.update(W,r.ELEMENT_ARRAY_BUFFER),(X||h)&&(h=!1,D(L,V,G,Y),W!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(W).buffer))}function d(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function f(L){return n.isWebGL2?r.bindVertexArray(L):s.bindVertexArrayOES(L)}function g(L){return n.isWebGL2?r.deleteVertexArray(L):s.deleteVertexArrayOES(L)}function _(L,V,G){const Y=G.wireframe===!0;let W=o[L.id];W===void 0&&(W={},o[L.id]=W);let X=W[V.id];X===void 0&&(X={},W[V.id]=X);let ee=X[Y];return ee===void 0&&(ee=m(d()),X[Y]=ee),ee}function m(L){const V=[],G=[],Y=[];for(let W=0;W<i;W++)V[W]=0,G[W]=0,Y[W]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:V,enabledAttributes:G,attributeDivisors:Y,object:L,attributes:{},index:null}}function p(L,V,G,Y){const W=l.attributes,X=V.attributes;let ee=0;const ie=G.getAttributes();for(const ue in ie)if(ie[ue].location>=0){const z=W[ue];let $=X[ue];if($===void 0&&(ue==="instanceMatrix"&&L.instanceMatrix&&($=L.instanceMatrix),ue==="instanceColor"&&L.instanceColor&&($=L.instanceColor)),z===void 0||z.attribute!==$||$&&z.data!==$.data)return!0;ee++}return l.attributesNum!==ee||l.index!==Y}function S(L,V,G,Y){const W={},X=V.attributes;let ee=0;const ie=G.getAttributes();for(const ue in ie)if(ie[ue].location>=0){let z=X[ue];z===void 0&&(ue==="instanceMatrix"&&L.instanceMatrix&&(z=L.instanceMatrix),ue==="instanceColor"&&L.instanceColor&&(z=L.instanceColor));const $={};$.attribute=z,z&&z.data&&($.data=z.data),W[ue]=$,ee++}l.attributes=W,l.attributesNum=ee,l.index=Y}function v(){const L=l.newAttributes;for(let V=0,G=L.length;V<G;V++)L[V]=0}function E(L){C(L,0)}function C(L,V){const G=l.newAttributes,Y=l.enabledAttributes,W=l.attributeDivisors;G[L]=1,Y[L]===0&&(r.enableVertexAttribArray(L),Y[L]=1),W[L]!==V&&((n.isWebGL2?r:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](L,V),W[L]=V)}function A(){const L=l.newAttributes,V=l.enabledAttributes;for(let G=0,Y=V.length;G<Y;G++)V[G]!==L[G]&&(r.disableVertexAttribArray(G),V[G]=0)}function b(L,V,G,Y,W,X,ee){ee===!0?r.vertexAttribIPointer(L,V,G,W,X):r.vertexAttribPointer(L,V,G,Y,W,X)}function D(L,V,G,Y){if(n.isWebGL2===!1&&(L.isInstancedMesh||Y.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;v();const W=Y.attributes,X=G.getAttributes(),ee=V.defaultAttributeValues;for(const ie in X){const ue=X[ie];if(ue.location>=0){let Le=W[ie];if(Le===void 0&&(ie==="instanceMatrix"&&L.instanceMatrix&&(Le=L.instanceMatrix),ie==="instanceColor"&&L.instanceColor&&(Le=L.instanceColor)),Le!==void 0){const z=Le.normalized,$=Le.itemSize,he=t.get(Le);if(he===void 0)continue;const Te=he.buffer,ge=he.type,de=he.bytesPerElement,Ye=n.isWebGL2===!0&&(ge===r.INT||ge===r.UNSIGNED_INT||Le.gpuType===Vc);if(Le.isInterleavedBufferAttribute){const Ae=Le.data,N=Ae.stride,gt=Le.offset;if(Ae.isInstancedInterleavedBuffer){for(let xe=0;xe<ue.locationSize;xe++)C(ue.location+xe,Ae.meshPerAttribute);L.isInstancedMesh!==!0&&Y._maxInstanceCount===void 0&&(Y._maxInstanceCount=Ae.meshPerAttribute*Ae.count)}else for(let xe=0;xe<ue.locationSize;xe++)E(ue.location+xe);r.bindBuffer(r.ARRAY_BUFFER,Te);for(let xe=0;xe<ue.locationSize;xe++)b(ue.location+xe,$/ue.locationSize,ge,z,N*de,(gt+$/ue.locationSize*xe)*de,Ye)}else{if(Le.isInstancedBufferAttribute){for(let Ae=0;Ae<ue.locationSize;Ae++)C(ue.location+Ae,Le.meshPerAttribute);L.isInstancedMesh!==!0&&Y._maxInstanceCount===void 0&&(Y._maxInstanceCount=Le.meshPerAttribute*Le.count)}else for(let Ae=0;Ae<ue.locationSize;Ae++)E(ue.location+Ae);r.bindBuffer(r.ARRAY_BUFFER,Te);for(let Ae=0;Ae<ue.locationSize;Ae++)b(ue.location+Ae,$/ue.locationSize,ge,z,$*de,$/ue.locationSize*Ae*de,Ye)}}else if(ee!==void 0){const z=ee[ie];if(z!==void 0)switch(z.length){case 2:r.vertexAttrib2fv(ue.location,z);break;case 3:r.vertexAttrib3fv(ue.location,z);break;case 4:r.vertexAttrib4fv(ue.location,z);break;default:r.vertexAttrib1fv(ue.location,z)}}}}A()}function k(){j();for(const L in o){const V=o[L];for(const G in V){const Y=V[G];for(const W in Y)g(Y[W].object),delete Y[W];delete V[G]}delete o[L]}}function M(L){if(o[L.id]===void 0)return;const V=o[L.id];for(const G in V){const Y=V[G];for(const W in Y)g(Y[W].object),delete Y[W];delete V[G]}delete o[L.id]}function w(L){for(const V in o){const G=o[V];if(G[L.id]===void 0)continue;const Y=G[L.id];for(const W in Y)g(Y[W].object),delete Y[W];delete G[L.id]}}function j(){K(),h=!0,l!==c&&(l=c,f(l.object))}function K(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:u,reset:j,resetDefaultState:K,dispose:k,releaseStatesOfGeometry:M,releaseStatesOfProgram:w,initAttributes:v,enableAttribute:E,disableUnusedAttributes:A}}function vp(r,e,t,n){const i=n.isWebGL2;let s;function a(h){s=h}function o(h,u){r.drawArrays(s,h,u),t.update(u,s,1)}function c(h,u,d){if(d===0)return;let f,g;if(i)f=r,g="drawArraysInstanced";else if(f=e.get("ANGLE_instanced_arrays"),g="drawArraysInstancedANGLE",f===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}f[g](s,h,u,d),t.update(u,s,d)}function l(h,u,d){if(d===0)return;const f=e.get("WEBGL_multi_draw");if(f===null)for(let g=0;g<d;g++)this.render(h[g],u[g]);else{f.multiDrawArraysWEBGL(s,h,0,u,0,d);let g=0;for(let _=0;_<d;_++)g+=u[_];t.update(g,s,1)}}this.setMode=a,this.render=o,this.renderInstances=c,this.renderMultiDraw=l}function xp(r,e,t){let n;function i(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const b=e.get("EXT_texture_filter_anisotropic");n=r.getParameter(b.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function s(b){if(b==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";b="mediump"}return b==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const a=typeof WebGL2RenderingContext<"u"&&r.constructor.name==="WebGL2RenderingContext";let o=t.precision!==void 0?t.precision:"highp";const c=s(o);c!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",c,"instead."),o=c);const l=a||e.has("WEBGL_draw_buffers"),h=t.logarithmicDepthBuffer===!0,u=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),d=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),f=r.getParameter(r.MAX_TEXTURE_SIZE),g=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),_=r.getParameter(r.MAX_VERTEX_ATTRIBS),m=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),p=r.getParameter(r.MAX_VARYING_VECTORS),S=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),v=d>0,E=a||e.has("OES_texture_float"),C=v&&E,A=a?r.getParameter(r.MAX_SAMPLES):0;return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:i,getMaxPrecision:s,precision:o,logarithmicDepthBuffer:h,maxTextures:u,maxVertexTextures:d,maxTextureSize:f,maxCubemapSize:g,maxAttributes:_,maxVertexUniforms:m,maxVaryings:p,maxFragmentUniforms:S,vertexTextures:v,floatFragmentTextures:E,floatVertexTextures:C,maxSamples:A}}function Mp(r){const e=this;let t=null,n=0,i=!1,s=!1;const a=new Hn,o=new Ue,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||i;return i=d,n=u.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,f){const g=u.clippingPlanes,_=u.clipIntersection,m=u.clipShadows,p=r.get(u);if(!i||g===null||g.length===0||s&&!m)s?h(null):l();else{const S=s?0:n,v=S*4;let E=p.clippingState||null;c.value=E,E=h(g,d,v,f);for(let C=0;C!==v;++C)E[C]=t[C];p.clippingState=E,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=S}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,d,f,g){const _=u!==null?u.length:0;let m=null;if(_!==0){if(m=c.value,g!==!0||m===null){const p=f+_*4,S=d.matrixWorldInverse;o.getNormalMatrix(S),(m===null||m.length<p)&&(m=new Float32Array(p));for(let v=0,E=f;v!==_;++v,E+=4)a.copy(u[v]).applyMatrix4(S,o),a.normal.toArray(m,E),m[E+3]=a.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,m}}function yp(r){let e=new WeakMap;function t(a,o){return o===ea?a.mapping=bi:o===ta&&(a.mapping=wi),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===ea||o===ta)if(e.has(a)){const c=e.get(a).texture;return t(c,a.mapping)}else{const c=a.image;if(c&&c.height>0){const l=new Lu(c.height);return l.fromEquirectangularTexture(r,a),e.set(a,l),a.addEventListener("dispose",i),t(l.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class Ea extends cl{constructor(e=-1,t=1,n=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=i+t,c=i-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,a=s+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const yi=4,ko=[.125,.215,.35,.446,.526,.582],Vn=20,Dr=new Ea,Vo=new ve;let Ur=null,Or=0,Fr=0;const Gn=(1+Math.sqrt(5))/2,di=1/Gn,Wo=[new R(1,1,1),new R(-1,1,1),new R(1,1,-1),new R(-1,1,-1),new R(0,Gn,di),new R(0,Gn,-di),new R(di,0,Gn),new R(-di,0,Gn),new R(Gn,di,0),new R(-Gn,di,0)];class Xo{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Ur=this._renderer.getRenderTarget(),Or=this._renderer.getActiveCubeFace(),Fr=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=jo(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Yo(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Ur,Or,Fr),e.scissorTest=!1,Is(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===bi||e.mapping===wi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ur=this._renderer.getRenderTarget(),Or=this._renderer.getActiveCubeFace(),Fr=this._renderer.getActiveMipmapLevel();const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Et,minFilter:Et,generateMipmaps:!1,type:ns,format:Ht,colorSpace:xt,depthBuffer:!1},i=qo(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=qo(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Sp(s)),this._blurMaterial=Ep(s,e,t)}return i}_compileMaterial(e){const t=new Nt(this._lodPlanes[0],e);this._renderer.compile(t,Dr)}_sceneToCubeUV(e,t,n,i){const o=new Rt(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,d=h.toneMapping;h.getClearColor(Vo),h.toneMapping=Rn,h.autoClear=!1;const f=new Wn({name:"PMREM.Background",side:Ct,depthWrite:!1,depthTest:!1}),g=new Nt(new os,f);let _=!1;const m=e.background;m?m.isColor&&(f.color.copy(m),e.background=null,_=!0):(f.color.copy(Vo),_=!0);for(let p=0;p<6;p++){const S=p%3;S===0?(o.up.set(0,c[p],0),o.lookAt(l[p],0,0)):S===1?(o.up.set(0,0,c[p]),o.lookAt(0,l[p],0)):(o.up.set(0,c[p],0),o.lookAt(0,0,l[p]));const v=this._cubeSize;Is(i,S*v,p>2?v:0,v,v),h.setRenderTarget(i),_&&h.render(g,o),h.render(e,o)}g.geometry.dispose(),g.material.dispose(),h.toneMapping=d,h.autoClear=u,e.background=m}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===bi||e.mapping===wi;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=jo()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Yo());const s=i?this._cubemapMaterial:this._equirectMaterial,a=new Nt(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const c=this._cubeSize;Is(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,Dr)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),a=Wo[(i-1)%Wo.length];this._blur(e,i-1,i,s,a)}t.autoClear=n}_blur(e,t,n,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",s),this._halfBlur(a,e,n,n,i,"longitudinal",s)}_halfBlur(e,t,n,i,s,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,u=new Nt(this._lodPlanes[i],l),d=l.uniforms,f=this._sizeLods[n]-1,g=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*Vn-1),_=s/g,m=isFinite(s)?1+Math.floor(h*_):Vn;m>Vn&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Vn}`);const p=[];let S=0;for(let b=0;b<Vn;++b){const D=b/_,k=Math.exp(-D*D/2);p.push(k),b===0?S+=k:b<m&&(S+=2*k)}for(let b=0;b<p.length;b++)p[b]=p[b]/S;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:v}=this;d.dTheta.value=g,d.mipInt.value=v-n;const E=this._sizeLods[i],C=3*E*(i>v-yi?i-v+yi:0),A=4*(this._cubeSize-E);Is(t,C,A,3*E,2*E),c.setRenderTarget(t),c.render(u,Dr)}}function Sp(r){const e=[],t=[],n=[];let i=r;const s=r-yi+1+ko.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);t.push(o);let c=1/o;a>r-yi?c=ko[a-r+yi-1]:a===0&&(c=0),n.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,g=6,_=3,m=2,p=1,S=new Float32Array(_*g*f),v=new Float32Array(m*g*f),E=new Float32Array(p*g*f);for(let A=0;A<f;A++){const b=A%3*2/3-1,D=A>2?0:-1,k=[b,D,0,b+2/3,D,0,b+2/3,D+1,0,b,D,0,b+2/3,D+1,0,b,D+1,0];S.set(k,_*g*A),v.set(d,m*g*A);const M=[A,A,A,A,A,A];E.set(M,p*g*A)}const C=new mt;C.setAttribute("position",new vt(S,_)),C.setAttribute("uv",new vt(v,m)),C.setAttribute("faceIndex",new vt(E,p)),e.push(C),i>yi&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function qo(r,e,t){const n=new jn(r,e,t);return n.texture.mapping=er,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Is(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function Ep(r,e,t){const n=new Float32Array(Vn),i=new R(0,1,0);return new Ln({name:"SphericalGaussianBlur",defines:{n:Vn,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Ta(),fragmentShader:`
3552
+
3553
+ precision mediump float;
3554
+ precision mediump int;
3555
+
3556
+ varying vec3 vOutputDirection;
3557
+
3558
+ uniform sampler2D envMap;
3559
+ uniform int samples;
3560
+ uniform float weights[ n ];
3561
+ uniform bool latitudinal;
3562
+ uniform float dTheta;
3563
+ uniform float mipInt;
3564
+ uniform vec3 poleAxis;
3565
+
3566
+ #define ENVMAP_TYPE_CUBE_UV
3567
+ #include <cube_uv_reflection_fragment>
3568
+
3569
+ vec3 getSample( float theta, vec3 axis ) {
3570
+
3571
+ float cosTheta = cos( theta );
3572
+ // Rodrigues' axis-angle rotation
3573
+ vec3 sampleDirection = vOutputDirection * cosTheta
3574
+ + cross( axis, vOutputDirection ) * sin( theta )
3575
+ + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
3576
+
3577
+ return bilinearCubeUV( envMap, sampleDirection, mipInt );
3578
+
3579
+ }
3580
+
3581
+ void main() {
3582
+
3583
+ vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
3584
+
3585
+ if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
3586
+
3587
+ axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
3588
+
3589
+ }
3590
+
3591
+ axis = normalize( axis );
3592
+
3593
+ gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
3594
+ gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
3595
+
3596
+ for ( int i = 1; i < n; i++ ) {
3597
+
3598
+ if ( i >= samples ) {
3599
+
3600
+ break;
3601
+
3602
+ }
3603
+
3604
+ float theta = dTheta * float( i );
3605
+ gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
3606
+ gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
3607
+
3608
+ }
3609
+
3610
+ }
3611
+ `,blending:wn,depthTest:!1,depthWrite:!1})}function Yo(){return new Ln({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ta(),fragmentShader:`
3612
+
3613
+ precision mediump float;
3614
+ precision mediump int;
3615
+
3616
+ varying vec3 vOutputDirection;
3617
+
3618
+ uniform sampler2D envMap;
3619
+
3620
+ #include <common>
3621
+
3622
+ void main() {
3623
+
3624
+ vec3 outputDirection = normalize( vOutputDirection );
3625
+ vec2 uv = equirectUv( outputDirection );
3626
+
3627
+ gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3628
+
3629
+ }
3630
+ `,blending:wn,depthTest:!1,depthWrite:!1})}function jo(){return new Ln({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ta(),fragmentShader:`
3631
+
3632
+ precision mediump float;
3633
+ precision mediump int;
3634
+
3635
+ uniform float flipEnvMap;
3636
+
3637
+ varying vec3 vOutputDirection;
3638
+
3639
+ uniform samplerCube envMap;
3640
+
3641
+ void main() {
3642
+
3643
+ gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3644
+
3645
+ }
3646
+ `,blending:wn,depthTest:!1,depthWrite:!1})}function Ta(){return`
3647
+
3648
+ precision mediump float;
3649
+ precision mediump int;
3650
+
3651
+ attribute float faceIndex;
3652
+
3653
+ varying vec3 vOutputDirection;
3654
+
3655
+ // RH coordinate system; PMREM face-indexing convention
3656
+ vec3 getDirection( vec2 uv, float face ) {
3657
+
3658
+ uv = 2.0 * uv - 1.0;
3659
+
3660
+ vec3 direction = vec3( uv, 1.0 );
3661
+
3662
+ if ( face == 0.0 ) {
3663
+
3664
+ direction = direction.zyx; // ( 1, v, u ) pos x
3665
+
3666
+ } else if ( face == 1.0 ) {
3667
+
3668
+ direction = direction.xzy;
3669
+ direction.xz *= -1.0; // ( -u, 1, -v ) pos y
3670
+
3671
+ } else if ( face == 2.0 ) {
3672
+
3673
+ direction.x *= -1.0; // ( -u, v, 1 ) pos z
3674
+
3675
+ } else if ( face == 3.0 ) {
3676
+
3677
+ direction = direction.zyx;
3678
+ direction.xz *= -1.0; // ( -1, v, -u ) neg x
3679
+
3680
+ } else if ( face == 4.0 ) {
3681
+
3682
+ direction = direction.xzy;
3683
+ direction.xy *= -1.0; // ( -u, -1, v ) neg y
3684
+
3685
+ } else if ( face == 5.0 ) {
3686
+
3687
+ direction.z *= -1.0; // ( u, v, -1 ) neg z
3688
+
3689
+ }
3690
+
3691
+ return direction;
3692
+
3693
+ }
3694
+
3695
+ void main() {
3696
+
3697
+ vOutputDirection = getDirection( uv, faceIndex );
3698
+ gl_Position = vec4( position, 1.0 );
3699
+
3700
+ }
3701
+ `}function Tp(r){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const c=o.mapping,l=c===ea||c===ta,h=c===bi||c===wi;if(l||h)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let u=e.get(o);return t===null&&(t=new Xo(r)),u=l?t.fromEquirectangular(o,u):t.fromCubemap(o,u),e.set(o,u),u.texture}else{if(e.has(o))return e.get(o).texture;{const u=o.image;if(l&&u&&u.height>0||h&&u&&i(u)){t===null&&(t=new Xo(r));const d=l?t.fromEquirectangular(o):t.fromCubemap(o);return e.set(o,d),o.addEventListener("dispose",s),d.texture}else return null}}}return o}function i(o){let c=0;const l=6;for(let h=0;h<l;h++)o[h]!==void 0&&c++;return c===l}function s(o){const c=o.target;c.removeEventListener("dispose",s);const l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function Ap(r){const e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=r.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(n){n.isWebGL2?(t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance")):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(n){const i=t(n);return i===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function bp(r,e,t,n){const i={},s=new WeakMap;function a(u){const d=u.target;d.index!==null&&e.remove(d.index);for(const g in d.attributes)e.remove(d.attributes[g]);for(const g in d.morphAttributes){const _=d.morphAttributes[g];for(let m=0,p=_.length;m<p;m++)e.remove(_[m])}d.removeEventListener("dispose",a),delete i[d.id];const f=s.get(d);f&&(e.remove(f),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(u,d){return i[d.id]===!0||(d.addEventListener("dispose",a),i[d.id]=!0,t.memory.geometries++),d}function c(u){const d=u.attributes;for(const g in d)e.update(d[g],r.ARRAY_BUFFER);const f=u.morphAttributes;for(const g in f){const _=f[g];for(let m=0,p=_.length;m<p;m++)e.update(_[m],r.ARRAY_BUFFER)}}function l(u){const d=[],f=u.index,g=u.attributes.position;let _=0;if(f!==null){const S=f.array;_=f.version;for(let v=0,E=S.length;v<E;v+=3){const C=S[v+0],A=S[v+1],b=S[v+2];d.push(C,A,A,b,b,C)}}else if(g!==void 0){const S=g.array;_=g.version;for(let v=0,E=S.length/3-1;v<E;v+=3){const C=v+0,A=v+1,b=v+2;d.push(C,A,A,b,b,C)}}else return;const m=new(Qc(d)?al:rl)(d,1);m.version=_;const p=s.get(u);p&&e.remove(p),s.set(u,m)}function h(u){const d=s.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&l(u)}else l(u);return s.get(u)}return{get:o,update:c,getWireframeAttribute:h}}function wp(r,e,t,n){const i=n.isWebGL2;let s;function a(f){s=f}let o,c;function l(f){o=f.type,c=f.bytesPerElement}function h(f,g){r.drawElements(s,g,o,f*c),t.update(g,s,1)}function u(f,g,_){if(_===0)return;let m,p;if(i)m=r,p="drawElementsInstanced";else if(m=e.get("ANGLE_instanced_arrays"),p="drawElementsInstancedANGLE",m===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[p](s,g,o,f*c,_),t.update(g,s,_)}function d(f,g,_){if(_===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let p=0;p<_;p++)this.render(f[p]/c,g[p]);else{m.multiDrawElementsWEBGL(s,g,0,o,f,0,_);let p=0;for(let S=0;S<_;S++)p+=g[S];t.update(p,s,1)}}this.setMode=a,this.setIndex=l,this.render=h,this.renderInstances=u,this.renderMultiDraw=d}function Rp(r){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(t.calls++,a){case r.TRIANGLES:t.triangles+=o*(s/3);break;case r.LINES:t.lines+=o*(s/2);break;case r.LINE_STRIP:t.lines+=o*(s-1);break;case r.LINE_LOOP:t.lines+=o*s;break;case r.POINTS:t.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function Cp(r,e){return r[0]-e[0]}function Lp(r,e){return Math.abs(e[1])-Math.abs(r[1])}function Pp(r,e,t){const n={},i=new Float32Array(8),s=new WeakMap,a=new Ke,o=[];for(let l=0;l<8;l++)o[l]=[l,0];function c(l,h,u){const d=l.morphTargetInfluences;if(e.isWebGL2===!0){const f=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color,g=f!==void 0?f.length:0;let _=s.get(h);if(_===void 0||_.count!==g){let j=function(){M.dispose(),s.delete(h),h.removeEventListener("dispose",j)};_!==void 0&&_.texture.dispose();const m=h.morphAttributes.position!==void 0,p=h.morphAttributes.normal!==void 0,S=h.morphAttributes.color!==void 0,v=h.morphAttributes.position||[],E=h.morphAttributes.normal||[],C=h.morphAttributes.color||[];let A=0;m===!0&&(A=1),p===!0&&(A=2),S===!0&&(A=3);let b=h.attributes.position.count*A,D=1;b>e.maxTextureSize&&(D=Math.ceil(b/e.maxTextureSize),b=e.maxTextureSize);const k=new Float32Array(b*D*4*g),M=new il(k,b,D,g);M.type=Wt,M.needsUpdate=!0;const w=A*4;for(let K=0;K<g;K++){const L=v[K],V=E[K],G=C[K],Y=b*D*4*K;for(let W=0;W<L.count;W++){const X=W*w;m===!0&&(a.fromBufferAttribute(L,W),k[Y+X+0]=a.x,k[Y+X+1]=a.y,k[Y+X+2]=a.z,k[Y+X+3]=0),p===!0&&(a.fromBufferAttribute(V,W),k[Y+X+4]=a.x,k[Y+X+5]=a.y,k[Y+X+6]=a.z,k[Y+X+7]=0),S===!0&&(a.fromBufferAttribute(G,W),k[Y+X+8]=a.x,k[Y+X+9]=a.y,k[Y+X+10]=a.z,k[Y+X+11]=G.itemSize===4?a.w:1)}}_={count:g,texture:M,size:new re(b,D)},s.set(h,_),h.addEventListener("dispose",j)}if(l.isInstancedMesh===!0&&l.morphTexture!==null)u.getUniforms().setValue(r,"morphTexture",l.morphTexture,t);else{let m=0;for(let S=0;S<d.length;S++)m+=d[S];const p=h.morphTargetsRelative?1:1-m;u.getUniforms().setValue(r,"morphTargetBaseInfluence",p),u.getUniforms().setValue(r,"morphTargetInfluences",d)}u.getUniforms().setValue(r,"morphTargetsTexture",_.texture,t),u.getUniforms().setValue(r,"morphTargetsTextureSize",_.size)}else{const f=d===void 0?0:d.length;let g=n[h.id];if(g===void 0||g.length!==f){g=[];for(let v=0;v<f;v++)g[v]=[v,0];n[h.id]=g}for(let v=0;v<f;v++){const E=g[v];E[0]=v,E[1]=d[v]}g.sort(Lp);for(let v=0;v<8;v++)v<f&&g[v][1]?(o[v][0]=g[v][0],o[v][1]=g[v][1]):(o[v][0]=Number.MAX_SAFE_INTEGER,o[v][1]=0);o.sort(Cp);const _=h.morphAttributes.position,m=h.morphAttributes.normal;let p=0;for(let v=0;v<8;v++){const E=o[v],C=E[0],A=E[1];C!==Number.MAX_SAFE_INTEGER&&A?(_&&h.getAttribute("morphTarget"+v)!==_[C]&&h.setAttribute("morphTarget"+v,_[C]),m&&h.getAttribute("morphNormal"+v)!==m[C]&&h.setAttribute("morphNormal"+v,m[C]),i[v]=A,p+=A):(_&&h.hasAttribute("morphTarget"+v)===!0&&h.deleteAttribute("morphTarget"+v),m&&h.hasAttribute("morphNormal"+v)===!0&&h.deleteAttribute("morphNormal"+v),i[v]=0)}const S=h.morphTargetsRelative?1:1-p;u.getUniforms().setValue(r,"morphTargetBaseInfluence",S),u.getUniforms().setValue(r,"morphTargetInfluences",i)}}return{update:c}}function Ip(r,e,t,n){let i=new WeakMap;function s(c){const l=n.render.frame,h=c.geometry,u=e.get(c,h);if(i.get(u)!==l&&(e.update(u),i.set(u,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),i.get(c)!==l&&(t.update(c.instanceMatrix,r.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,r.ARRAY_BUFFER),i.set(c,l))),c.isSkinnedMesh){const d=c.skeleton;i.get(d)!==l&&(d.update(),i.set(d,l))}return u}function a(){i=new WeakMap}function o(c){const l=c.target;l.removeEventListener("dispose",o),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:s,dispose:a}}class ul extends lt{constructor(e,t,n,i,s,a,o,c,l,h){if(h=h!==void 0?h:Yn,h!==Yn&&h!==Ci)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===Yn&&(n=An),n===void 0&&h===Ci&&(n=qn),super(null,i,s,a,o,c,h,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:pt,this.minFilter=c!==void 0?c:pt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const dl=new lt,fl=new ul(1,1);fl.compareFunction=Zc;const pl=new il,ml=new fu,gl=new ll,Ko=[],Jo=[],$o=new Float32Array(16),Zo=new Float32Array(9),Qo=new Float32Array(4);function Ui(r,e,t){const n=r[0];if(n<=0||n>0)return r;const i=e*t;let s=Ko[i];if(s===void 0&&(s=new Float32Array(i),Ko[i]=s),e!==0){n.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,r[a].toArray(s,o)}return s}function ht(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function ut(r,e){for(let t=0,n=e.length;t<n;t++)r[t]=e[t]}function ir(r,e){let t=Jo[e];t===void 0&&(t=new Int32Array(e),Jo[e]=t);for(let n=0;n!==e;++n)t[n]=r.allocateTextureUnit();return t}function Np(r,e){const t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function Dp(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ht(t,e))return;r.uniform2fv(this.addr,e),ut(t,e)}}function Up(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(ht(t,e))return;r.uniform3fv(this.addr,e),ut(t,e)}}function Op(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ht(t,e))return;r.uniform4fv(this.addr,e),ut(t,e)}}function Fp(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(ht(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),ut(t,e)}else{if(ht(t,n))return;Qo.set(n),r.uniformMatrix2fv(this.addr,!1,Qo),ut(t,n)}}function Bp(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(ht(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),ut(t,e)}else{if(ht(t,n))return;Zo.set(n),r.uniformMatrix3fv(this.addr,!1,Zo),ut(t,n)}}function zp(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(ht(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),ut(t,e)}else{if(ht(t,n))return;$o.set(n),r.uniformMatrix4fv(this.addr,!1,$o),ut(t,n)}}function Hp(r,e){const t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function Gp(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ht(t,e))return;r.uniform2iv(this.addr,e),ut(t,e)}}function kp(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(ht(t,e))return;r.uniform3iv(this.addr,e),ut(t,e)}}function Vp(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ht(t,e))return;r.uniform4iv(this.addr,e),ut(t,e)}}function Wp(r,e){const t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function Xp(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ht(t,e))return;r.uniform2uiv(this.addr,e),ut(t,e)}}function qp(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(ht(t,e))return;r.uniform3uiv(this.addr,e),ut(t,e)}}function Yp(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ht(t,e))return;r.uniform4uiv(this.addr,e),ut(t,e)}}function jp(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i);const s=this.type===r.SAMPLER_2D_SHADOW?fl:dl;t.setTexture2D(e||s,i)}function Kp(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||ml,i)}function Jp(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||gl,i)}function $p(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||pl,i)}function Zp(r){switch(r){case 5126:return Np;case 35664:return Dp;case 35665:return Up;case 35666:return Op;case 35674:return Fp;case 35675:return Bp;case 35676:return zp;case 5124:case 35670:return Hp;case 35667:case 35671:return Gp;case 35668:case 35672:return kp;case 35669:case 35673:return Vp;case 5125:return Wp;case 36294:return Xp;case 36295:return qp;case 36296:return Yp;case 35678:case 36198:case 36298:case 36306:case 35682:return jp;case 35679:case 36299:case 36307:return Kp;case 35680:case 36300:case 36308:case 36293:return Jp;case 36289:case 36303:case 36311:case 36292:return $p}}function Qp(r,e){r.uniform1fv(this.addr,e)}function em(r,e){const t=Ui(e,this.size,2);r.uniform2fv(this.addr,t)}function tm(r,e){const t=Ui(e,this.size,3);r.uniform3fv(this.addr,t)}function nm(r,e){const t=Ui(e,this.size,4);r.uniform4fv(this.addr,t)}function im(r,e){const t=Ui(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function sm(r,e){const t=Ui(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function rm(r,e){const t=Ui(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function am(r,e){r.uniform1iv(this.addr,e)}function om(r,e){r.uniform2iv(this.addr,e)}function cm(r,e){r.uniform3iv(this.addr,e)}function lm(r,e){r.uniform4iv(this.addr,e)}function hm(r,e){r.uniform1uiv(this.addr,e)}function um(r,e){r.uniform2uiv(this.addr,e)}function dm(r,e){r.uniform3uiv(this.addr,e)}function fm(r,e){r.uniform4uiv(this.addr,e)}function pm(r,e,t){const n=this.cache,i=e.length,s=ir(t,i);ht(n,s)||(r.uniform1iv(this.addr,s),ut(n,s));for(let a=0;a!==i;++a)t.setTexture2D(e[a]||dl,s[a])}function mm(r,e,t){const n=this.cache,i=e.length,s=ir(t,i);ht(n,s)||(r.uniform1iv(this.addr,s),ut(n,s));for(let a=0;a!==i;++a)t.setTexture3D(e[a]||ml,s[a])}function gm(r,e,t){const n=this.cache,i=e.length,s=ir(t,i);ht(n,s)||(r.uniform1iv(this.addr,s),ut(n,s));for(let a=0;a!==i;++a)t.setTextureCube(e[a]||gl,s[a])}function _m(r,e,t){const n=this.cache,i=e.length,s=ir(t,i);ht(n,s)||(r.uniform1iv(this.addr,s),ut(n,s));for(let a=0;a!==i;++a)t.setTexture2DArray(e[a]||pl,s[a])}function vm(r){switch(r){case 5126:return Qp;case 35664:return em;case 35665:return tm;case 35666:return nm;case 35674:return im;case 35675:return sm;case 35676:return rm;case 5124:case 35670:return am;case 35667:case 35671:return om;case 35668:case 35672:return cm;case 35669:case 35673:return lm;case 5125:return hm;case 36294:return um;case 36295:return dm;case 36296:return fm;case 35678:case 36198:case 36298:case 36306:case 35682:return pm;case 35679:case 36299:case 36307:return mm;case 35680:case 36300:case 36308:case 36293:return gm;case 36289:case 36303:case 36311:case 36292:return _m}}class xm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Zp(t.type)}}class Mm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=vm(t.type)}}class ym{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let s=0,a=i.length;s!==a;++s){const o=i[s];o.setValue(e,t[o.id],n)}}}const Br=/(\w+)(\])?(\[|\.)?/g;function ec(r,e){r.seq.push(e),r.map[e.id]=e}function Sm(r,e,t){const n=r.name,i=n.length;for(Br.lastIndex=0;;){const s=Br.exec(n),a=Br.lastIndex;let o=s[1];const c=s[2]==="]",l=s[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===i){ec(t,l===void 0?new xm(o,r,e):new Mm(o,r,e));break}else{let u=t.map[o];u===void 0&&(u=new ym(o),ec(t,u)),t=u}}}class Xs{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const s=e.getActiveUniform(t,i),a=e.getUniformLocation(t,s.name);Sm(s,a,this)}}setValue(e,t,n,i){const s=this.map[t];s!==void 0&&s.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let s=0,a=t.length;s!==a;++s){const o=t[s],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,s=e.length;i!==s;++i){const a=e[i];a.id in t&&n.push(a)}return n}}function tc(r,e,t){const n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}const Em=37297;let Tm=0;function Am(r,e){const t=r.split(`
3702
+ `),n=[],i=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=i;a<s;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
3703
+ `)}function bm(r){const e=qe.getPrimaries(qe.workingColorSpace),t=qe.getPrimaries(r);let n;switch(e===t?n="":e===$s&&t===Js?n="LinearDisplayP3ToLinearSRGB":e===Js&&t===$s&&(n="LinearSRGBToLinearDisplayP3"),r){case xt:case tr:return[n,"LinearTransferOETF"];case wt:case xa:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",r),[n,"LinearTransferOETF"]}}function nc(r,e,t){const n=r.getShaderParameter(e,r.COMPILE_STATUS),i=r.getShaderInfoLog(e).trim();if(n&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const a=parseInt(s[1]);return t.toUpperCase()+`
3704
+
3705
+ `+i+`
3706
+
3707
+ `+Am(r.getShaderSource(e),a)}else return i}function wm(r,e){const t=bm(e);return`vec4 ${r}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function Rm(r,e){let t;switch(e){case _h:t="Linear";break;case vh:t="Reinhard";break;case xh:t="OptimizedCineon";break;case Mh:t="ACESFilmic";break;case Sh:t="AgX";break;case Eh:t="Neutral";break;case yh:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function Cm(r){return[r.extensionDerivatives||r.envMapCubeUVHeight||r.bumpMap||r.normalMapTangentSpace||r.clearcoatNormalMap||r.flatShading||r.alphaToCoverage||r.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(r.extensionFragDepth||r.logarithmicDepthBuffer)&&r.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",r.extensionDrawBuffers&&r.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(r.extensionShaderTextureLOD||r.envMap||r.transmission)&&r.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Si).join(`
3708
+ `)}function Lm(r){return[r.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",r.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Si).join(`
3709
+ `)}function Pm(r){const e=[];for(const t in r){const n=r[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
3710
+ `)}function Im(r,e){const t={},n=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const s=r.getActiveAttrib(e,i),a=s.name;let o=1;s.type===r.FLOAT_MAT2&&(o=2),s.type===r.FLOAT_MAT3&&(o=3),s.type===r.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:r.getAttribLocation(e,a),locationSize:o}}return t}function Si(r){return r!==""}function ic(r,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return r.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).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_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function sc(r,e){return r.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Nm=/^[ \t]*#include +<([\w\d./]+)>/gm;function oa(r){return r.replace(Nm,Um)}const Dm=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Um(r,e){let t=De[e];if(t===void 0){const n=Dm.get(e);if(n!==void 0)t=De[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return oa(t)}const Om=/#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 rc(r){return r.replace(Om,Fm)}function Fm(r,e,t,n){let i="";for(let s=parseInt(e);s<parseInt(t);s++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function ac(r){let e=`precision ${r.precision} float;
3711
+ precision ${r.precision} int;
3712
+ precision ${r.precision} sampler2D;
3713
+ precision ${r.precision} samplerCube;
3714
+ `;return r.isWebGL2&&(e+=`precision ${r.precision} sampler3D;
3715
+ precision ${r.precision} sampler2DArray;
3716
+ precision ${r.precision} sampler2DShadow;
3717
+ precision ${r.precision} samplerCubeShadow;
3718
+ precision ${r.precision} sampler2DArrayShadow;
3719
+ precision ${r.precision} isampler2D;
3720
+ precision ${r.precision} isampler3D;
3721
+ precision ${r.precision} isamplerCube;
3722
+ precision ${r.precision} isampler2DArray;
3723
+ precision ${r.precision} usampler2D;
3724
+ precision ${r.precision} usampler3D;
3725
+ precision ${r.precision} usamplerCube;
3726
+ precision ${r.precision} usampler2DArray;
3727
+ `),r.precision==="highp"?e+=`
3728
+ #define HIGH_PRECISION`:r.precision==="mediump"?e+=`
3729
+ #define MEDIUM_PRECISION`:r.precision==="lowp"&&(e+=`
3730
+ #define LOW_PRECISION`),e}function Bm(r){let e="SHADOWMAP_TYPE_BASIC";return r.shadowMapType===Gc?e="SHADOWMAP_TYPE_PCF":r.shadowMapType===Xl?e="SHADOWMAP_TYPE_PCF_SOFT":r.shadowMapType===un&&(e="SHADOWMAP_TYPE_VSM"),e}function zm(r){let e="ENVMAP_TYPE_CUBE";if(r.envMap)switch(r.envMapMode){case bi:case wi:e="ENVMAP_TYPE_CUBE";break;case er:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Hm(r){let e="ENVMAP_MODE_REFLECTION";if(r.envMap)switch(r.envMapMode){case wi:e="ENVMAP_MODE_REFRACTION";break}return e}function Gm(r){let e="ENVMAP_BLENDING_NONE";if(r.envMap)switch(r.combine){case ma:e="ENVMAP_BLENDING_MULTIPLY";break;case mh:e="ENVMAP_BLENDING_MIX";break;case gh:e="ENVMAP_BLENDING_ADD";break}return e}function km(r){const e=r.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function Vm(r,e,t,n){const i=r.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const c=Bm(t),l=zm(t),h=Hm(t),u=Gm(t),d=km(t),f=t.isWebGL2?"":Cm(t),g=Lm(t),_=Pm(s),m=i.createProgram();let p,S,v=t.glslVersion?"#version "+t.glslVersion+`
3731
+ `:"";t.isRawShaderMaterial?(p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_].filter(Si).join(`
3732
+ `),p.length>0&&(p+=`
3733
+ `),S=[f,"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_].filter(Si).join(`
3734
+ `),S.length>0&&(S+=`
3735
+ `)):(p=[ac(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.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"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
3736
+ `].filter(Si).join(`
3737
+ `),S=[f,ac(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Rn?"#define TONE_MAPPING":"",t.toneMapping!==Rn?De.tonemapping_pars_fragment:"",t.toneMapping!==Rn?Rm("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",De.colorspace_pars_fragment,wm("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3738
+ `].filter(Si).join(`
3739
+ `)),a=oa(a),a=ic(a,t),a=sc(a,t),o=oa(o),o=ic(o,t),o=sc(o,t),a=rc(a),o=rc(o),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(v=`#version 300 es
3740
+ `,p=[g,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
3741
+ `)+`
3742
+ `+p,S=["precision mediump sampler2DArray;","#define varying in",t.glslVersion===So?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===So?"":"#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(`
3743
+ `)+`
3744
+ `+S);const E=v+p+a,C=v+S+o,A=tc(i,i.VERTEX_SHADER,E),b=tc(i,i.FRAGMENT_SHADER,C);i.attachShader(m,A),i.attachShader(m,b),t.index0AttributeName!==void 0?i.bindAttribLocation(m,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(m,0,"position"),i.linkProgram(m);function D(j){if(r.debug.checkShaderErrors){const K=i.getProgramInfoLog(m).trim(),L=i.getShaderInfoLog(A).trim(),V=i.getShaderInfoLog(b).trim();let G=!0,Y=!0;if(i.getProgramParameter(m,i.LINK_STATUS)===!1)if(G=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(i,m,A,b);else{const W=nc(i,A,"vertex"),X=nc(i,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(m,i.VALIDATE_STATUS)+`
3745
+
3746
+ Material Name: `+j.name+`
3747
+ Material Type: `+j.type+`
3748
+
3749
+ Program Info Log: `+K+`
3750
+ `+W+`
3751
+ `+X)}else K!==""?console.warn("THREE.WebGLProgram: Program Info Log:",K):(L===""||V==="")&&(Y=!1);Y&&(j.diagnostics={runnable:G,programLog:K,vertexShader:{log:L,prefix:p},fragmentShader:{log:V,prefix:S}})}i.deleteShader(A),i.deleteShader(b),k=new Xs(i,m),M=Im(i,m)}let k;this.getUniforms=function(){return k===void 0&&D(this),k};let M;this.getAttributes=function(){return M===void 0&&D(this),M};let w=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return w===!1&&(w=i.getProgramParameter(m,Em)),w},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Tm++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=A,this.fragmentShader=b,this}let Wm=0;class Xm{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new qm(e),t.set(e,n)),n}}class qm{constructor(e){this.id=Wm++,this.code=e,this.usedTimes=0}}function Ym(r,e,t,n,i,s,a){const o=new ya,c=new Xm,l=new Set,h=[],u=i.isWebGL2,d=i.logarithmicDepthBuffer,f=i.vertexTextures;let g=i.precision;const _={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"};function m(M){return l.add(M),M===0?"uv":`uv${M}`}function p(M,w,j,K,L){const V=K.fog,G=L.geometry,Y=M.isMeshStandardMaterial?K.environment:null,W=(M.isMeshStandardMaterial?t:e).get(M.envMap||Y),X=W&&W.mapping===er?W.image.height:null,ee=_[M.type];M.precision!==null&&(g=i.getMaxPrecision(M.precision),g!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",g,"instead."));const ie=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,ue=ie!==void 0?ie.length:0;let Le=0;G.morphAttributes.position!==void 0&&(Le=1),G.morphAttributes.normal!==void 0&&(Le=2),G.morphAttributes.color!==void 0&&(Le=3);let z,$,he,Te;if(ee){const Je=$t[ee];z=Je.vertexShader,$=Je.fragmentShader}else z=M.vertexShader,$=M.fragmentShader,c.update(M),he=c.getVertexShaderID(M),Te=c.getFragmentShaderID(M);const ge=r.getRenderTarget(),de=L.isInstancedMesh===!0,Ye=L.isBatchedMesh===!0,Ae=!!M.map,N=!!M.matcap,gt=!!W,xe=!!M.aoMap,Be=!!M.lightMap,ye=!!M.bumpMap,Ve=!!M.normalMap,Oe=!!M.displacementMap,ze=!!M.emissiveMap,st=!!M.metalnessMap,T=!!M.roughnessMap,x=M.anisotropy>0,H=M.clearcoat>0,q=M.iridescence>0,Z=M.sheen>0,J=M.transmission>0,Pe=x&&!!M.anisotropyMap,Se=H&&!!M.clearcoatMap,se=H&&!!M.clearcoatNormalMap,oe=H&&!!M.clearcoatRoughnessMap,Ie=q&&!!M.iridescenceMap,Q=q&&!!M.iridescenceThicknessMap,at=Z&&!!M.sheenColorMap,He=Z&&!!M.sheenRoughnessMap,_e=!!M.specularMap,fe=!!M.specularColorMap,pe=!!M.specularIntensityMap,We=J&&!!M.transmissionMap,Re=J&&!!M.thicknessMap,tt=!!M.gradientMap,P=!!M.alphaMap,ae=M.alphaTest>0,O=!!M.alphaHash,te=!!M.extensions;let ce=Rn;M.toneMapped&&(ge===null||ge.isXRRenderTarget===!0)&&(ce=r.toneMapping);const Ge={isWebGL2:u,shaderID:ee,shaderType:M.type,shaderName:M.name,vertexShader:z,fragmentShader:$,defines:M.defines,customVertexShaderID:he,customFragmentShaderID:Te,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:g,batching:Ye,instancing:de,instancingColor:de&&L.instanceColor!==null,instancingMorph:de&&L.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:ge===null?r.outputColorSpace:ge.isXRRenderTarget===!0?ge.texture.colorSpace:xt,alphaToCoverage:!!M.alphaToCoverage,map:Ae,matcap:N,envMap:gt,envMapMode:gt&&W.mapping,envMapCubeUVHeight:X,aoMap:xe,lightMap:Be,bumpMap:ye,normalMap:Ve,displacementMap:f&&Oe,emissiveMap:ze,normalMapObjectSpace:Ve&&M.normalMapType===zh,normalMapTangentSpace:Ve&&M.normalMapType===va,metalnessMap:st,roughnessMap:T,anisotropy:x,anisotropyMap:Pe,clearcoat:H,clearcoatMap:Se,clearcoatNormalMap:se,clearcoatRoughnessMap:oe,iridescence:q,iridescenceMap:Ie,iridescenceThicknessMap:Q,sheen:Z,sheenColorMap:at,sheenRoughnessMap:He,specularMap:_e,specularColorMap:fe,specularIntensityMap:pe,transmission:J,transmissionMap:We,thicknessMap:Re,gradientMap:tt,opaque:M.transparent===!1&&M.blending===Ei&&M.alphaToCoverage===!1,alphaMap:P,alphaTest:ae,alphaHash:O,combine:M.combine,mapUv:Ae&&m(M.map.channel),aoMapUv:xe&&m(M.aoMap.channel),lightMapUv:Be&&m(M.lightMap.channel),bumpMapUv:ye&&m(M.bumpMap.channel),normalMapUv:Ve&&m(M.normalMap.channel),displacementMapUv:Oe&&m(M.displacementMap.channel),emissiveMapUv:ze&&m(M.emissiveMap.channel),metalnessMapUv:st&&m(M.metalnessMap.channel),roughnessMapUv:T&&m(M.roughnessMap.channel),anisotropyMapUv:Pe&&m(M.anisotropyMap.channel),clearcoatMapUv:Se&&m(M.clearcoatMap.channel),clearcoatNormalMapUv:se&&m(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:oe&&m(M.clearcoatRoughnessMap.channel),iridescenceMapUv:Ie&&m(M.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&m(M.iridescenceThicknessMap.channel),sheenColorMapUv:at&&m(M.sheenColorMap.channel),sheenRoughnessMapUv:He&&m(M.sheenRoughnessMap.channel),specularMapUv:_e&&m(M.specularMap.channel),specularColorMapUv:fe&&m(M.specularColorMap.channel),specularIntensityMapUv:pe&&m(M.specularIntensityMap.channel),transmissionMapUv:We&&m(M.transmissionMap.channel),thicknessMapUv:Re&&m(M.thicknessMap.channel),alphaMapUv:P&&m(M.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(Ve||x),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!G.attributes.uv&&(Ae||P),fog:!!V,useFog:M.fog===!0,fogExp2:!!V&&V.isFogExp2,flatShading:M.flatShading===!0,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:L.isSkinnedMesh===!0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:ue,morphTextureStride:Le,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numLightProbes:w.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:M.dithering,shadowMapEnabled:r.shadowMap.enabled&&j.length>0,shadowMapType:r.shadowMap.type,toneMapping:ce,useLegacyLights:r._useLegacyLights,decodeVideoTexture:Ae&&M.map.isVideoTexture===!0&&qe.getTransfer(M.map.colorSpace)===Qe,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Zt,flipSided:M.side===Ct,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionDerivatives:te&&M.extensions.derivatives===!0,extensionFragDepth:te&&M.extensions.fragDepth===!0,extensionDrawBuffers:te&&M.extensions.drawBuffers===!0,extensionShaderTextureLOD:te&&M.extensions.shaderTextureLOD===!0,extensionClipCullDistance:te&&M.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:te&&M.extensions.multiDraw===!0&&n.has("WEBGL_multi_draw"),rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return Ge.vertexUv1s=l.has(1),Ge.vertexUv2s=l.has(2),Ge.vertexUv3s=l.has(3),l.clear(),Ge}function S(M){const w=[];if(M.shaderID?w.push(M.shaderID):(w.push(M.customVertexShaderID),w.push(M.customFragmentShaderID)),M.defines!==void 0)for(const j in M.defines)w.push(j),w.push(M.defines[j]);return M.isRawShaderMaterial===!1&&(v(w,M),E(w,M),w.push(r.outputColorSpace)),w.push(M.customProgramCacheKey),w.join()}function v(M,w){M.push(w.precision),M.push(w.outputColorSpace),M.push(w.envMapMode),M.push(w.envMapCubeUVHeight),M.push(w.mapUv),M.push(w.alphaMapUv),M.push(w.lightMapUv),M.push(w.aoMapUv),M.push(w.bumpMapUv),M.push(w.normalMapUv),M.push(w.displacementMapUv),M.push(w.emissiveMapUv),M.push(w.metalnessMapUv),M.push(w.roughnessMapUv),M.push(w.anisotropyMapUv),M.push(w.clearcoatMapUv),M.push(w.clearcoatNormalMapUv),M.push(w.clearcoatRoughnessMapUv),M.push(w.iridescenceMapUv),M.push(w.iridescenceThicknessMapUv),M.push(w.sheenColorMapUv),M.push(w.sheenRoughnessMapUv),M.push(w.specularMapUv),M.push(w.specularColorMapUv),M.push(w.specularIntensityMapUv),M.push(w.transmissionMapUv),M.push(w.thicknessMapUv),M.push(w.combine),M.push(w.fogExp2),M.push(w.sizeAttenuation),M.push(w.morphTargetsCount),M.push(w.morphAttributeCount),M.push(w.numDirLights),M.push(w.numPointLights),M.push(w.numSpotLights),M.push(w.numSpotLightMaps),M.push(w.numHemiLights),M.push(w.numRectAreaLights),M.push(w.numDirLightShadows),M.push(w.numPointLightShadows),M.push(w.numSpotLightShadows),M.push(w.numSpotLightShadowsWithMaps),M.push(w.numLightProbes),M.push(w.shadowMapType),M.push(w.toneMapping),M.push(w.numClippingPlanes),M.push(w.numClipIntersection),M.push(w.depthPacking)}function E(M,w){o.disableAll(),w.isWebGL2&&o.enable(0),w.supportsVertexTextures&&o.enable(1),w.instancing&&o.enable(2),w.instancingColor&&o.enable(3),w.instancingMorph&&o.enable(4),w.matcap&&o.enable(5),w.envMap&&o.enable(6),w.normalMapObjectSpace&&o.enable(7),w.normalMapTangentSpace&&o.enable(8),w.clearcoat&&o.enable(9),w.iridescence&&o.enable(10),w.alphaTest&&o.enable(11),w.vertexColors&&o.enable(12),w.vertexAlphas&&o.enable(13),w.vertexUv1s&&o.enable(14),w.vertexUv2s&&o.enable(15),w.vertexUv3s&&o.enable(16),w.vertexTangents&&o.enable(17),w.anisotropy&&o.enable(18),w.alphaHash&&o.enable(19),w.batching&&o.enable(20),M.push(o.mask),o.disableAll(),w.fog&&o.enable(0),w.useFog&&o.enable(1),w.flatShading&&o.enable(2),w.logarithmicDepthBuffer&&o.enable(3),w.skinning&&o.enable(4),w.morphTargets&&o.enable(5),w.morphNormals&&o.enable(6),w.morphColors&&o.enable(7),w.premultipliedAlpha&&o.enable(8),w.shadowMapEnabled&&o.enable(9),w.useLegacyLights&&o.enable(10),w.doubleSided&&o.enable(11),w.flipSided&&o.enable(12),w.useDepthPacking&&o.enable(13),w.dithering&&o.enable(14),w.transmission&&o.enable(15),w.sheen&&o.enable(16),w.opaque&&o.enable(17),w.pointsUvs&&o.enable(18),w.decodeVideoTexture&&o.enable(19),w.alphaToCoverage&&o.enable(20),M.push(o.mask)}function C(M){const w=_[M.type];let j;if(w){const K=$t[w];j=bu.clone(K.uniforms)}else j=M.uniforms;return j}function A(M,w){let j;for(let K=0,L=h.length;K<L;K++){const V=h[K];if(V.cacheKey===w){j=V,++j.usedTimes;break}}return j===void 0&&(j=new Vm(r,w,M,s),h.push(j)),j}function b(M){if(--M.usedTimes===0){const w=h.indexOf(M);h[w]=h[h.length-1],h.pop(),M.destroy()}}function D(M){c.remove(M)}function k(){c.dispose()}return{getParameters:p,getProgramCacheKey:S,getUniforms:C,acquireProgram:A,releaseProgram:b,releaseShaderCache:D,programs:h,dispose:k}}function jm(){let r=new WeakMap;function e(s){let a=r.get(s);return a===void 0&&(a={},r.set(s,a)),a}function t(s){r.delete(s)}function n(s,a,o){r.get(s)[a]=o}function i(){r=new WeakMap}return{get:e,remove:t,update:n,dispose:i}}function Km(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function oc(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function cc(){const r=[];let e=0;const t=[],n=[],i=[];function s(){e=0,t.length=0,n.length=0,i.length=0}function a(u,d,f,g,_,m){let p=r[e];return p===void 0?(p={id:u.id,object:u,geometry:d,material:f,groupOrder:g,renderOrder:u.renderOrder,z:_,group:m},r[e]=p):(p.id=u.id,p.object=u,p.geometry=d,p.material=f,p.groupOrder=g,p.renderOrder=u.renderOrder,p.z=_,p.group=m),e++,p}function o(u,d,f,g,_,m){const p=a(u,d,f,g,_,m);f.transmission>0?n.push(p):f.transparent===!0?i.push(p):t.push(p)}function c(u,d,f,g,_,m){const p=a(u,d,f,g,_,m);f.transmission>0?n.unshift(p):f.transparent===!0?i.unshift(p):t.unshift(p)}function l(u,d){t.length>1&&t.sort(u||Km),n.length>1&&n.sort(d||oc),i.length>1&&i.sort(d||oc)}function h(){for(let u=e,d=r.length;u<d;u++){const f=r[u];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:n,transparent:i,init:s,push:o,unshift:c,finish:h,sort:l}}function Jm(){let r=new WeakMap;function e(n,i){const s=r.get(n);let a;return s===void 0?(a=new cc,r.set(n,[a])):i>=s.length?(a=new cc,s.push(a)):a=s[i],a}function t(){r=new WeakMap}return{get:e,dispose:t}}function $m(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new R,color:new ve};break;case"SpotLight":t={position:new R,direction:new R,color:new ve,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new R,color:new ve,distance:0,decay:0};break;case"HemisphereLight":t={direction:new R,skyColor:new ve,groundColor:new ve};break;case"RectAreaLight":t={color:new ve,position:new R,halfWidth:new R,halfHeight:new R};break}return r[e.id]=t,t}}}function Zm(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new re};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new re};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new re,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let Qm=0;function eg(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function tg(r,e){const t=new $m,n=Zm(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let h=0;h<9;h++)i.probe.push(new R);const s=new R,a=new be,o=new be;function c(h,u){let d=0,f=0,g=0;for(let j=0;j<9;j++)i.probe[j].set(0,0,0);let _=0,m=0,p=0,S=0,v=0,E=0,C=0,A=0,b=0,D=0,k=0;h.sort(eg);const M=u===!0?Math.PI:1;for(let j=0,K=h.length;j<K;j++){const L=h[j],V=L.color,G=L.intensity,Y=L.distance,W=L.shadow&&L.shadow.map?L.shadow.map.texture:null;if(L.isAmbientLight)d+=V.r*G*M,f+=V.g*G*M,g+=V.b*G*M;else if(L.isLightProbe){for(let X=0;X<9;X++)i.probe[X].addScaledVector(L.sh.coefficients[X],G);k++}else if(L.isDirectionalLight){const X=t.get(L);if(X.color.copy(L.color).multiplyScalar(L.intensity*M),L.castShadow){const ee=L.shadow,ie=n.get(L);ie.shadowBias=ee.bias,ie.shadowNormalBias=ee.normalBias,ie.shadowRadius=ee.radius,ie.shadowMapSize=ee.mapSize,i.directionalShadow[_]=ie,i.directionalShadowMap[_]=W,i.directionalShadowMatrix[_]=L.shadow.matrix,E++}i.directional[_]=X,_++}else if(L.isSpotLight){const X=t.get(L);X.position.setFromMatrixPosition(L.matrixWorld),X.color.copy(V).multiplyScalar(G*M),X.distance=Y,X.coneCos=Math.cos(L.angle),X.penumbraCos=Math.cos(L.angle*(1-L.penumbra)),X.decay=L.decay,i.spot[p]=X;const ee=L.shadow;if(L.map&&(i.spotLightMap[b]=L.map,b++,ee.updateMatrices(L),L.castShadow&&D++),i.spotLightMatrix[p]=ee.matrix,L.castShadow){const ie=n.get(L);ie.shadowBias=ee.bias,ie.shadowNormalBias=ee.normalBias,ie.shadowRadius=ee.radius,ie.shadowMapSize=ee.mapSize,i.spotShadow[p]=ie,i.spotShadowMap[p]=W,A++}p++}else if(L.isRectAreaLight){const X=t.get(L);X.color.copy(V).multiplyScalar(G),X.halfWidth.set(L.width*.5,0,0),X.halfHeight.set(0,L.height*.5,0),i.rectArea[S]=X,S++}else if(L.isPointLight){const X=t.get(L);if(X.color.copy(L.color).multiplyScalar(L.intensity*M),X.distance=L.distance,X.decay=L.decay,L.castShadow){const ee=L.shadow,ie=n.get(L);ie.shadowBias=ee.bias,ie.shadowNormalBias=ee.normalBias,ie.shadowRadius=ee.radius,ie.shadowMapSize=ee.mapSize,ie.shadowCameraNear=ee.camera.near,ie.shadowCameraFar=ee.camera.far,i.pointShadow[m]=ie,i.pointShadowMap[m]=W,i.pointShadowMatrix[m]=L.shadow.matrix,C++}i.point[m]=X,m++}else if(L.isHemisphereLight){const X=t.get(L);X.skyColor.copy(L.color).multiplyScalar(G*M),X.groundColor.copy(L.groundColor).multiplyScalar(G*M),i.hemi[v]=X,v++}}S>0&&(e.isWebGL2?r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ne.LTC_FLOAT_1,i.rectAreaLTC2=ne.LTC_FLOAT_2):(i.rectAreaLTC1=ne.LTC_HALF_1,i.rectAreaLTC2=ne.LTC_HALF_2):r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ne.LTC_FLOAT_1,i.rectAreaLTC2=ne.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=ne.LTC_HALF_1,i.rectAreaLTC2=ne.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=d,i.ambient[1]=f,i.ambient[2]=g;const w=i.hash;(w.directionalLength!==_||w.pointLength!==m||w.spotLength!==p||w.rectAreaLength!==S||w.hemiLength!==v||w.numDirectionalShadows!==E||w.numPointShadows!==C||w.numSpotShadows!==A||w.numSpotMaps!==b||w.numLightProbes!==k)&&(i.directional.length=_,i.spot.length=p,i.rectArea.length=S,i.point.length=m,i.hemi.length=v,i.directionalShadow.length=E,i.directionalShadowMap.length=E,i.pointShadow.length=C,i.pointShadowMap.length=C,i.spotShadow.length=A,i.spotShadowMap.length=A,i.directionalShadowMatrix.length=E,i.pointShadowMatrix.length=C,i.spotLightMatrix.length=A+b-D,i.spotLightMap.length=b,i.numSpotLightShadowsWithMaps=D,i.numLightProbes=k,w.directionalLength=_,w.pointLength=m,w.spotLength=p,w.rectAreaLength=S,w.hemiLength=v,w.numDirectionalShadows=E,w.numPointShadows=C,w.numSpotShadows=A,w.numSpotMaps=b,w.numLightProbes=k,i.version=Qm++)}function l(h,u){let d=0,f=0,g=0,_=0,m=0;const p=u.matrixWorldInverse;for(let S=0,v=h.length;S<v;S++){const E=h[S];if(E.isDirectionalLight){const C=i.directional[d];C.direction.setFromMatrixPosition(E.matrixWorld),s.setFromMatrixPosition(E.target.matrixWorld),C.direction.sub(s),C.direction.transformDirection(p),d++}else if(E.isSpotLight){const C=i.spot[g];C.position.setFromMatrixPosition(E.matrixWorld),C.position.applyMatrix4(p),C.direction.setFromMatrixPosition(E.matrixWorld),s.setFromMatrixPosition(E.target.matrixWorld),C.direction.sub(s),C.direction.transformDirection(p),g++}else if(E.isRectAreaLight){const C=i.rectArea[_];C.position.setFromMatrixPosition(E.matrixWorld),C.position.applyMatrix4(p),o.identity(),a.copy(E.matrixWorld),a.premultiply(p),o.extractRotation(a),C.halfWidth.set(E.width*.5,0,0),C.halfHeight.set(0,E.height*.5,0),C.halfWidth.applyMatrix4(o),C.halfHeight.applyMatrix4(o),_++}else if(E.isPointLight){const C=i.point[f];C.position.setFromMatrixPosition(E.matrixWorld),C.position.applyMatrix4(p),f++}else if(E.isHemisphereLight){const C=i.hemi[m];C.direction.setFromMatrixPosition(E.matrixWorld),C.direction.transformDirection(p),m++}}}return{setup:c,setupView:l,state:i}}function lc(r,e){const t=new tg(r,e),n=[],i=[];function s(){n.length=0,i.length=0}function a(u){n.push(u)}function o(u){i.push(u)}function c(u){t.setup(n,u)}function l(u){t.setupView(n,u)}return{init:s,state:{lightsArray:n,shadowsArray:i,lights:t},setupLights:c,setupLightsView:l,pushLight:a,pushShadow:o}}function ng(r,e){let t=new WeakMap;function n(s,a=0){const o=t.get(s);let c;return o===void 0?(c=new lc(r,e),t.set(s,[c])):a>=o.length?(c=new lc(r,e),o.push(c)):c=o[a],c}function i(){t=new WeakMap}return{get:n,dispose:i}}class ig extends Dt{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Fh,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class sg extends Dt{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const rg=`void main() {
3752
+ gl_Position = vec4( position, 1.0 );
3753
+ }`,ag=`uniform sampler2D shadow_pass;
3754
+ uniform vec2 resolution;
3755
+ uniform float radius;
3756
+ #include <packing>
3757
+ void main() {
3758
+ const float samples = float( VSM_SAMPLES );
3759
+ float mean = 0.0;
3760
+ float squared_mean = 0.0;
3761
+ float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
3762
+ float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
3763
+ for ( float i = 0.0; i < samples; i ++ ) {
3764
+ float uvOffset = uvStart + i * uvStride;
3765
+ #ifdef HORIZONTAL_PASS
3766
+ vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
3767
+ mean += distribution.x;
3768
+ squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
3769
+ #else
3770
+ float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
3771
+ mean += depth;
3772
+ squared_mean += depth * depth;
3773
+ #endif
3774
+ }
3775
+ mean = mean / samples;
3776
+ squared_mean = squared_mean / samples;
3777
+ float std_dev = sqrt( squared_mean - mean * mean );
3778
+ gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3779
+ }`;function og(r,e,t){let n=new Sa;const i=new re,s=new re,a=new Ke,o=new ig({depthPacking:Bh}),c=new sg,l={},h=t.maxTextureSize,u={[pn]:Ct,[Ct]:pn,[Zt]:Zt},d=new Ln({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new re},radius:{value:4}},vertexShader:rg,fragmentShader:ag}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new mt;g.setAttribute("position",new vt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Nt(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Gc;let p=this.type;this.render=function(A,b,D){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||A.length===0)return;const k=r.getRenderTarget(),M=r.getActiveCubeFace(),w=r.getActiveMipmapLevel(),j=r.state;j.setBlending(wn),j.buffers.color.setClear(1,1,1,1),j.buffers.depth.setTest(!0),j.setScissorTest(!1);const K=p!==un&&this.type===un,L=p===un&&this.type!==un;for(let V=0,G=A.length;V<G;V++){const Y=A[V],W=Y.shadow;if(W===void 0){console.warn("THREE.WebGLShadowMap:",Y,"has no shadow.");continue}if(W.autoUpdate===!1&&W.needsUpdate===!1)continue;i.copy(W.mapSize);const X=W.getFrameExtents();if(i.multiply(X),s.copy(W.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(s.x=Math.floor(h/X.x),i.x=s.x*X.x,W.mapSize.x=s.x),i.y>h&&(s.y=Math.floor(h/X.y),i.y=s.y*X.y,W.mapSize.y=s.y)),W.map===null||K===!0||L===!0){const ie=this.type!==un?{minFilter:pt,magFilter:pt}:{};W.map!==null&&W.map.dispose(),W.map=new jn(i.x,i.y,ie),W.map.texture.name=Y.name+".shadowMap",W.camera.updateProjectionMatrix()}r.setRenderTarget(W.map),r.clear();const ee=W.getViewportCount();for(let ie=0;ie<ee;ie++){const ue=W.getViewport(ie);a.set(s.x*ue.x,s.y*ue.y,s.x*ue.z,s.y*ue.w),j.viewport(a),W.updateMatrices(Y,ie),n=W.getFrustum(),E(b,D,W.camera,Y,this.type)}W.isPointLightShadow!==!0&&this.type===un&&S(W,D),W.needsUpdate=!1}p=this.type,m.needsUpdate=!1,r.setRenderTarget(k,M,w)};function S(A,b){const D=e.update(_);d.defines.VSM_SAMPLES!==A.blurSamples&&(d.defines.VSM_SAMPLES=A.blurSamples,f.defines.VSM_SAMPLES=A.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new jn(i.x,i.y)),d.uniforms.shadow_pass.value=A.map.texture,d.uniforms.resolution.value=A.mapSize,d.uniforms.radius.value=A.radius,r.setRenderTarget(A.mapPass),r.clear(),r.renderBufferDirect(b,null,D,d,_,null),f.uniforms.shadow_pass.value=A.mapPass.texture,f.uniforms.resolution.value=A.mapSize,f.uniforms.radius.value=A.radius,r.setRenderTarget(A.map),r.clear(),r.renderBufferDirect(b,null,D,f,_,null)}function v(A,b,D,k){let M=null;const w=D.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(w!==void 0)M=w;else if(M=D.isPointLight===!0?c:o,r.localClippingEnabled&&b.clipShadows===!0&&Array.isArray(b.clippingPlanes)&&b.clippingPlanes.length!==0||b.displacementMap&&b.displacementScale!==0||b.alphaMap&&b.alphaTest>0||b.map&&b.alphaTest>0){const j=M.uuid,K=b.uuid;let L=l[j];L===void 0&&(L={},l[j]=L);let V=L[K];V===void 0&&(V=M.clone(),L[K]=V,b.addEventListener("dispose",C)),M=V}if(M.visible=b.visible,M.wireframe=b.wireframe,k===un?M.side=b.shadowSide!==null?b.shadowSide:b.side:M.side=b.shadowSide!==null?b.shadowSide:u[b.side],M.alphaMap=b.alphaMap,M.alphaTest=b.alphaTest,M.map=b.map,M.clipShadows=b.clipShadows,M.clippingPlanes=b.clippingPlanes,M.clipIntersection=b.clipIntersection,M.displacementMap=b.displacementMap,M.displacementScale=b.displacementScale,M.displacementBias=b.displacementBias,M.wireframeLinewidth=b.wireframeLinewidth,M.linewidth=b.linewidth,D.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const j=r.properties.get(M);j.light=D}return M}function E(A,b,D,k,M){if(A.visible===!1)return;if(A.layers.test(b.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&M===un)&&(!A.frustumCulled||n.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,A.matrixWorld);const K=e.update(A),L=A.material;if(Array.isArray(L)){const V=K.groups;for(let G=0,Y=V.length;G<Y;G++){const W=V[G],X=L[W.materialIndex];if(X&&X.visible){const ee=v(A,X,k,M);A.onBeforeShadow(r,A,b,D,K,ee,W),r.renderBufferDirect(D,null,K,ee,A,W),A.onAfterShadow(r,A,b,D,K,ee,W)}}}else if(L.visible){const V=v(A,L,k,M);A.onBeforeShadow(r,A,b,D,K,V,null),r.renderBufferDirect(D,null,K,V,A,null),A.onAfterShadow(r,A,b,D,K,V,null)}}const j=A.children;for(let K=0,L=j.length;K<L;K++)E(j[K],b,D,k,M)}function C(A){A.target.removeEventListener("dispose",C);for(const D in l){const k=l[D],M=A.target.uuid;M in k&&(k[M].dispose(),delete k[M])}}}function cg(r,e,t){const n=t.isWebGL2;function i(){let P=!1;const ae=new Ke;let O=null;const te=new Ke(0,0,0,0);return{setMask:function(ce){O!==ce&&!P&&(r.colorMask(ce,ce,ce,ce),O=ce)},setLocked:function(ce){P=ce},setClear:function(ce,Ge,Je,_t,Ut){Ut===!0&&(ce*=_t,Ge*=_t,Je*=_t),ae.set(ce,Ge,Je,_t),te.equals(ae)===!1&&(r.clearColor(ce,Ge,Je,_t),te.copy(ae))},reset:function(){P=!1,O=null,te.set(-1,0,0,0)}}}function s(){let P=!1,ae=null,O=null,te=null;return{setTest:function(ce){ce?de(r.DEPTH_TEST):Ye(r.DEPTH_TEST)},setMask:function(ce){ae!==ce&&!P&&(r.depthMask(ce),ae=ce)},setFunc:function(ce){if(O!==ce){switch(ce){case ch:r.depthFunc(r.NEVER);break;case lh:r.depthFunc(r.ALWAYS);break;case hh:r.depthFunc(r.LESS);break;case qs:r.depthFunc(r.LEQUAL);break;case uh:r.depthFunc(r.EQUAL);break;case dh:r.depthFunc(r.GEQUAL);break;case fh:r.depthFunc(r.GREATER);break;case ph:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}O=ce}},setLocked:function(ce){P=ce},setClear:function(ce){te!==ce&&(r.clearDepth(ce),te=ce)},reset:function(){P=!1,ae=null,O=null,te=null}}}function a(){let P=!1,ae=null,O=null,te=null,ce=null,Ge=null,Je=null,_t=null,Ut=null;return{setTest:function($e){P||($e?de(r.STENCIL_TEST):Ye(r.STENCIL_TEST))},setMask:function($e){ae!==$e&&!P&&(r.stencilMask($e),ae=$e)},setFunc:function($e,Tt,Jt){(O!==$e||te!==Tt||ce!==Jt)&&(r.stencilFunc($e,Tt,Jt),O=$e,te=Tt,ce=Jt)},setOp:function($e,Tt,Jt){(Ge!==$e||Je!==Tt||_t!==Jt)&&(r.stencilOp($e,Tt,Jt),Ge=$e,Je=Tt,_t=Jt)},setLocked:function($e){P=$e},setClear:function($e){Ut!==$e&&(r.clearStencil($e),Ut=$e)},reset:function(){P=!1,ae=null,O=null,te=null,ce=null,Ge=null,Je=null,_t=null,Ut=null}}}const o=new i,c=new s,l=new a,h=new WeakMap,u=new WeakMap;let d={},f={},g=new WeakMap,_=[],m=null,p=!1,S=null,v=null,E=null,C=null,A=null,b=null,D=null,k=new ve(0,0,0),M=0,w=!1,j=null,K=null,L=null,V=null,G=null;const Y=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let W=!1,X=0;const ee=r.getParameter(r.VERSION);ee.indexOf("WebGL")!==-1?(X=parseFloat(/^WebGL (\d)/.exec(ee)[1]),W=X>=1):ee.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(ee)[1]),W=X>=2);let ie=null,ue={};const Le=r.getParameter(r.SCISSOR_BOX),z=r.getParameter(r.VIEWPORT),$=new Ke().fromArray(Le),he=new Ke().fromArray(z);function Te(P,ae,O,te){const ce=new Uint8Array(4),Ge=r.createTexture();r.bindTexture(P,Ge),r.texParameteri(P,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(P,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let Je=0;Je<O;Je++)n&&(P===r.TEXTURE_3D||P===r.TEXTURE_2D_ARRAY)?r.texImage3D(ae,0,r.RGBA,1,1,te,0,r.RGBA,r.UNSIGNED_BYTE,ce):r.texImage2D(ae+Je,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,ce);return Ge}const ge={};ge[r.TEXTURE_2D]=Te(r.TEXTURE_2D,r.TEXTURE_2D,1),ge[r.TEXTURE_CUBE_MAP]=Te(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(ge[r.TEXTURE_2D_ARRAY]=Te(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),ge[r.TEXTURE_3D]=Te(r.TEXTURE_3D,r.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),c.setClear(1),l.setClear(0),de(r.DEPTH_TEST),c.setFunc(qs),Oe(!1),ze(ka),de(r.CULL_FACE),ye(wn);function de(P){d[P]!==!0&&(r.enable(P),d[P]=!0)}function Ye(P){d[P]!==!1&&(r.disable(P),d[P]=!1)}function Ae(P,ae){return f[P]!==ae?(r.bindFramebuffer(P,ae),f[P]=ae,n&&(P===r.DRAW_FRAMEBUFFER&&(f[r.FRAMEBUFFER]=ae),P===r.FRAMEBUFFER&&(f[r.DRAW_FRAMEBUFFER]=ae)),!0):!1}function N(P,ae){let O=_,te=!1;if(P){O=g.get(ae),O===void 0&&(O=[],g.set(ae,O));const ce=P.textures;if(O.length!==ce.length||O[0]!==r.COLOR_ATTACHMENT0){for(let Ge=0,Je=ce.length;Ge<Je;Ge++)O[Ge]=r.COLOR_ATTACHMENT0+Ge;O.length=ce.length,te=!0}}else O[0]!==r.BACK&&(O[0]=r.BACK,te=!0);if(te)if(t.isWebGL2)r.drawBuffers(O);else if(e.has("WEBGL_draw_buffers")===!0)e.get("WEBGL_draw_buffers").drawBuffersWEBGL(O);else throw new Error("THREE.WebGLState: Usage of gl.drawBuffers() require WebGL2 or WEBGL_draw_buffers extension")}function gt(P){return m!==P?(r.useProgram(P),m=P,!0):!1}const xe={[kn]:r.FUNC_ADD,[Yl]:r.FUNC_SUBTRACT,[jl]:r.FUNC_REVERSE_SUBTRACT};if(n)xe[qa]=r.MIN,xe[Ya]=r.MAX;else{const P=e.get("EXT_blend_minmax");P!==null&&(xe[qa]=P.MIN_EXT,xe[Ya]=P.MAX_EXT)}const Be={[Kl]:r.ZERO,[Jl]:r.ONE,[$l]:r.SRC_COLOR,[Zr]:r.SRC_ALPHA,[ih]:r.SRC_ALPHA_SATURATE,[th]:r.DST_COLOR,[Ql]:r.DST_ALPHA,[Zl]:r.ONE_MINUS_SRC_COLOR,[Qr]:r.ONE_MINUS_SRC_ALPHA,[nh]:r.ONE_MINUS_DST_COLOR,[eh]:r.ONE_MINUS_DST_ALPHA,[sh]:r.CONSTANT_COLOR,[rh]:r.ONE_MINUS_CONSTANT_COLOR,[ah]:r.CONSTANT_ALPHA,[oh]:r.ONE_MINUS_CONSTANT_ALPHA};function ye(P,ae,O,te,ce,Ge,Je,_t,Ut,$e){if(P===wn){p===!0&&(Ye(r.BLEND),p=!1);return}if(p===!1&&(de(r.BLEND),p=!0),P!==ql){if(P!==S||$e!==w){if((v!==kn||A!==kn)&&(r.blendEquation(r.FUNC_ADD),v=kn,A=kn),$e)switch(P){case Ei:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Va:r.blendFunc(r.ONE,r.ONE);break;case Wa:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Xa:r.blendFuncSeparate(r.ZERO,r.SRC_COLOR,r.ZERO,r.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",P);break}else switch(P){case Ei:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Va:r.blendFunc(r.SRC_ALPHA,r.ONE);break;case Wa:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Xa:r.blendFunc(r.ZERO,r.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",P);break}E=null,C=null,b=null,D=null,k.set(0,0,0),M=0,S=P,w=$e}return}ce=ce||ae,Ge=Ge||O,Je=Je||te,(ae!==v||ce!==A)&&(r.blendEquationSeparate(xe[ae],xe[ce]),v=ae,A=ce),(O!==E||te!==C||Ge!==b||Je!==D)&&(r.blendFuncSeparate(Be[O],Be[te],Be[Ge],Be[Je]),E=O,C=te,b=Ge,D=Je),(_t.equals(k)===!1||Ut!==M)&&(r.blendColor(_t.r,_t.g,_t.b,Ut),k.copy(_t),M=Ut),S=P,w=!1}function Ve(P,ae){P.side===Zt?Ye(r.CULL_FACE):de(r.CULL_FACE);let O=P.side===Ct;ae&&(O=!O),Oe(O),P.blending===Ei&&P.transparent===!1?ye(wn):ye(P.blending,P.blendEquation,P.blendSrc,P.blendDst,P.blendEquationAlpha,P.blendSrcAlpha,P.blendDstAlpha,P.blendColor,P.blendAlpha,P.premultipliedAlpha),c.setFunc(P.depthFunc),c.setTest(P.depthTest),c.setMask(P.depthWrite),o.setMask(P.colorWrite);const te=P.stencilWrite;l.setTest(te),te&&(l.setMask(P.stencilWriteMask),l.setFunc(P.stencilFunc,P.stencilRef,P.stencilFuncMask),l.setOp(P.stencilFail,P.stencilZFail,P.stencilZPass)),T(P.polygonOffset,P.polygonOffsetFactor,P.polygonOffsetUnits),P.alphaToCoverage===!0?de(r.SAMPLE_ALPHA_TO_COVERAGE):Ye(r.SAMPLE_ALPHA_TO_COVERAGE)}function Oe(P){j!==P&&(P?r.frontFace(r.CW):r.frontFace(r.CCW),j=P)}function ze(P){P!==Vl?(de(r.CULL_FACE),P!==K&&(P===ka?r.cullFace(r.BACK):P===Wl?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):Ye(r.CULL_FACE),K=P}function st(P){P!==L&&(W&&r.lineWidth(P),L=P)}function T(P,ae,O){P?(de(r.POLYGON_OFFSET_FILL),(V!==ae||G!==O)&&(r.polygonOffset(ae,O),V=ae,G=O)):Ye(r.POLYGON_OFFSET_FILL)}function x(P){P?de(r.SCISSOR_TEST):Ye(r.SCISSOR_TEST)}function H(P){P===void 0&&(P=r.TEXTURE0+Y-1),ie!==P&&(r.activeTexture(P),ie=P)}function q(P,ae,O){O===void 0&&(ie===null?O=r.TEXTURE0+Y-1:O=ie);let te=ue[O];te===void 0&&(te={type:void 0,texture:void 0},ue[O]=te),(te.type!==P||te.texture!==ae)&&(ie!==O&&(r.activeTexture(O),ie=O),r.bindTexture(P,ae||ge[P]),te.type=P,te.texture=ae)}function Z(){const P=ue[ie];P!==void 0&&P.type!==void 0&&(r.bindTexture(P.type,null),P.type=void 0,P.texture=void 0)}function J(){try{r.compressedTexImage2D.apply(r,arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function Pe(){try{r.compressedTexImage3D.apply(r,arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function Se(){try{r.texSubImage2D.apply(r,arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function se(){try{r.texSubImage3D.apply(r,arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function oe(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function Ie(){try{r.compressedTexSubImage3D.apply(r,arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function Q(){try{r.texStorage2D.apply(r,arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function at(){try{r.texStorage3D.apply(r,arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function He(){try{r.texImage2D.apply(r,arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function _e(){try{r.texImage3D.apply(r,arguments)}catch(P){console.error("THREE.WebGLState:",P)}}function fe(P){$.equals(P)===!1&&(r.scissor(P.x,P.y,P.z,P.w),$.copy(P))}function pe(P){he.equals(P)===!1&&(r.viewport(P.x,P.y,P.z,P.w),he.copy(P))}function We(P,ae){let O=u.get(ae);O===void 0&&(O=new WeakMap,u.set(ae,O));let te=O.get(P);te===void 0&&(te=r.getUniformBlockIndex(ae,P.name),O.set(P,te))}function Re(P,ae){const te=u.get(ae).get(P);h.get(ae)!==te&&(r.uniformBlockBinding(ae,te,P.__bindingPointIndex),h.set(ae,te))}function tt(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.blendColor(0,0,0,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),n===!0&&(r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),d={},ie=null,ue={},f={},g=new WeakMap,_=[],m=null,p=!1,S=null,v=null,E=null,C=null,A=null,b=null,D=null,k=new ve(0,0,0),M=0,w=!1,j=null,K=null,L=null,V=null,G=null,$.set(0,0,r.canvas.width,r.canvas.height),he.set(0,0,r.canvas.width,r.canvas.height),o.reset(),c.reset(),l.reset()}return{buffers:{color:o,depth:c,stencil:l},enable:de,disable:Ye,bindFramebuffer:Ae,drawBuffers:N,useProgram:gt,setBlending:ye,setMaterial:Ve,setFlipSided:Oe,setCullFace:ze,setLineWidth:st,setPolygonOffset:T,setScissorTest:x,activeTexture:H,bindTexture:q,unbindTexture:Z,compressedTexImage2D:J,compressedTexImage3D:Pe,texImage2D:He,texImage3D:_e,updateUBOMapping:We,uniformBlockBinding:Re,texStorage2D:Q,texStorage3D:at,texSubImage2D:Se,texSubImage3D:se,compressedTexSubImage2D:oe,compressedTexSubImage3D:Ie,scissor:fe,viewport:pe,reset:tt}}function lg(r,e,t,n,i,s,a){const o=i.isWebGL2,c=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new re,u=new WeakMap;let d;const f=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(T,x){return g?new OffscreenCanvas(T,x):ss("canvas")}function m(T,x,H,q){let Z=1;const J=st(T);if((J.width>q||J.height>q)&&(Z=q/Math.max(J.width,J.height)),Z<1||x===!0)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){const Pe=x?Qs:Math.floor,Se=Pe(Z*J.width),se=Pe(Z*J.height);d===void 0&&(d=_(Se,se));const oe=H?_(Se,se):d;return oe.width=Se,oe.height=se,oe.getContext("2d").drawImage(T,0,0,Se,se),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+J.width+"x"+J.height+") to ("+Se+"x"+se+")."),oe}else return"data"in T&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+J.width+"x"+J.height+")."),T;return T}function p(T){const x=st(T);return aa(x.width)&&aa(x.height)}function S(T){return o?!1:T.wrapS!==zt||T.wrapT!==zt||T.minFilter!==pt&&T.minFilter!==Et}function v(T,x){return T.generateMipmaps&&x&&T.minFilter!==pt&&T.minFilter!==Et}function E(T){r.generateMipmap(T)}function C(T,x,H,q,Z=!1){if(o===!1)return x;if(T!==null){if(r[T]!==void 0)return r[T];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let J=x;if(x===r.RED&&(H===r.FLOAT&&(J=r.R32F),H===r.HALF_FLOAT&&(J=r.R16F),H===r.UNSIGNED_BYTE&&(J=r.R8)),x===r.RED_INTEGER&&(H===r.UNSIGNED_BYTE&&(J=r.R8UI),H===r.UNSIGNED_SHORT&&(J=r.R16UI),H===r.UNSIGNED_INT&&(J=r.R32UI),H===r.BYTE&&(J=r.R8I),H===r.SHORT&&(J=r.R16I),H===r.INT&&(J=r.R32I)),x===r.RG&&(H===r.FLOAT&&(J=r.RG32F),H===r.HALF_FLOAT&&(J=r.RG16F),H===r.UNSIGNED_BYTE&&(J=r.RG8)),x===r.RG_INTEGER&&(H===r.UNSIGNED_BYTE&&(J=r.RG8UI),H===r.UNSIGNED_SHORT&&(J=r.RG16UI),H===r.UNSIGNED_INT&&(J=r.RG32UI),H===r.BYTE&&(J=r.RG8I),H===r.SHORT&&(J=r.RG16I),H===r.INT&&(J=r.RG32I)),x===r.RGBA){const Pe=Z?Ks:qe.getTransfer(q);H===r.FLOAT&&(J=r.RGBA32F),H===r.HALF_FLOAT&&(J=r.RGBA16F),H===r.UNSIGNED_BYTE&&(J=Pe===Qe?r.SRGB8_ALPHA8:r.RGBA8),H===r.UNSIGNED_SHORT_4_4_4_4&&(J=r.RGBA4),H===r.UNSIGNED_SHORT_5_5_5_1&&(J=r.RGB5_A1)}return(J===r.R16F||J===r.R32F||J===r.RG16F||J===r.RG32F||J===r.RGBA16F||J===r.RGBA32F)&&e.get("EXT_color_buffer_float"),J}function A(T,x,H){return v(T,H)===!0||T.isFramebufferTexture&&T.minFilter!==pt&&T.minFilter!==Et?Math.log2(Math.max(x.width,x.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?x.mipmaps.length:1}function b(T){return T===pt||T===na||T===vi?r.NEAREST:r.LINEAR}function D(T){const x=T.target;x.removeEventListener("dispose",D),M(x),x.isVideoTexture&&u.delete(x)}function k(T){const x=T.target;x.removeEventListener("dispose",k),j(x)}function M(T){const x=n.get(T);if(x.__webglInit===void 0)return;const H=T.source,q=f.get(H);if(q){const Z=q[x.__cacheKey];Z.usedTimes--,Z.usedTimes===0&&w(T),Object.keys(q).length===0&&f.delete(H)}n.remove(T)}function w(T){const x=n.get(T);r.deleteTexture(x.__webglTexture);const H=T.source,q=f.get(H);delete q[x.__cacheKey],a.memory.textures--}function j(T){const x=n.get(T);if(T.depthTexture&&T.depthTexture.dispose(),T.isWebGLCubeRenderTarget)for(let q=0;q<6;q++){if(Array.isArray(x.__webglFramebuffer[q]))for(let Z=0;Z<x.__webglFramebuffer[q].length;Z++)r.deleteFramebuffer(x.__webglFramebuffer[q][Z]);else r.deleteFramebuffer(x.__webglFramebuffer[q]);x.__webglDepthbuffer&&r.deleteRenderbuffer(x.__webglDepthbuffer[q])}else{if(Array.isArray(x.__webglFramebuffer))for(let q=0;q<x.__webglFramebuffer.length;q++)r.deleteFramebuffer(x.__webglFramebuffer[q]);else r.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&r.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&r.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let q=0;q<x.__webglColorRenderbuffer.length;q++)x.__webglColorRenderbuffer[q]&&r.deleteRenderbuffer(x.__webglColorRenderbuffer[q]);x.__webglDepthRenderbuffer&&r.deleteRenderbuffer(x.__webglDepthRenderbuffer)}const H=T.textures;for(let q=0,Z=H.length;q<Z;q++){const J=n.get(H[q]);J.__webglTexture&&(r.deleteTexture(J.__webglTexture),a.memory.textures--),n.remove(H[q])}n.remove(T)}let K=0;function L(){K=0}function V(){const T=K;return T>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+i.maxTextures),K+=1,T}function G(T){const x=[];return x.push(T.wrapS),x.push(T.wrapT),x.push(T.wrapR||0),x.push(T.magFilter),x.push(T.minFilter),x.push(T.anisotropy),x.push(T.internalFormat),x.push(T.format),x.push(T.type),x.push(T.generateMipmaps),x.push(T.premultiplyAlpha),x.push(T.flipY),x.push(T.unpackAlignment),x.push(T.colorSpace),x.join()}function Y(T,x){const H=n.get(T);if(T.isVideoTexture&&Oe(T),T.isRenderTargetTexture===!1&&T.version>0&&H.__version!==T.version){const q=T.image;if(q===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(q.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{he(H,T,x);return}}t.bindTexture(r.TEXTURE_2D,H.__webglTexture,r.TEXTURE0+x)}function W(T,x){const H=n.get(T);if(T.version>0&&H.__version!==T.version){he(H,T,x);return}t.bindTexture(r.TEXTURE_2D_ARRAY,H.__webglTexture,r.TEXTURE0+x)}function X(T,x){const H=n.get(T);if(T.version>0&&H.__version!==T.version){he(H,T,x);return}t.bindTexture(r.TEXTURE_3D,H.__webglTexture,r.TEXTURE0+x)}function ee(T,x){const H=n.get(T);if(T.version>0&&H.__version!==T.version){Te(H,T,x);return}t.bindTexture(r.TEXTURE_CUBE_MAP,H.__webglTexture,r.TEXTURE0+x)}const ie={[Ri]:r.REPEAT,[zt]:r.CLAMP_TO_EDGE,[Ys]:r.MIRRORED_REPEAT},ue={[pt]:r.NEAREST,[na]:r.NEAREST_MIPMAP_NEAREST,[vi]:r.NEAREST_MIPMAP_LINEAR,[Et]:r.LINEAR,[Ws]:r.LINEAR_MIPMAP_NEAREST,[dn]:r.LINEAR_MIPMAP_LINEAR},Le={[Hh]:r.NEVER,[qh]:r.ALWAYS,[Gh]:r.LESS,[Zc]:r.LEQUAL,[kh]:r.EQUAL,[Xh]:r.GEQUAL,[Vh]:r.GREATER,[Wh]:r.NOTEQUAL};function z(T,x,H){if(x.type===Wt&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===Et||x.magFilter===Ws||x.magFilter===vi||x.magFilter===dn||x.minFilter===Et||x.minFilter===Ws||x.minFilter===vi||x.minFilter===dn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),H?(r.texParameteri(T,r.TEXTURE_WRAP_S,ie[x.wrapS]),r.texParameteri(T,r.TEXTURE_WRAP_T,ie[x.wrapT]),(T===r.TEXTURE_3D||T===r.TEXTURE_2D_ARRAY)&&r.texParameteri(T,r.TEXTURE_WRAP_R,ie[x.wrapR]),r.texParameteri(T,r.TEXTURE_MAG_FILTER,ue[x.magFilter]),r.texParameteri(T,r.TEXTURE_MIN_FILTER,ue[x.minFilter])):(r.texParameteri(T,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(T,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),(T===r.TEXTURE_3D||T===r.TEXTURE_2D_ARRAY)&&r.texParameteri(T,r.TEXTURE_WRAP_R,r.CLAMP_TO_EDGE),(x.wrapS!==zt||x.wrapT!==zt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(T,r.TEXTURE_MAG_FILTER,b(x.magFilter)),r.texParameteri(T,r.TEXTURE_MIN_FILTER,b(x.minFilter)),x.minFilter!==pt&&x.minFilter!==Et&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),x.compareFunction&&(r.texParameteri(T,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(T,r.TEXTURE_COMPARE_FUNC,Le[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===pt||x.minFilter!==vi&&x.minFilter!==dn||x.type===Wt&&e.has("OES_texture_float_linear")===!1||o===!1&&x.type===ns&&e.has("OES_texture_half_float_linear")===!1)return;if(x.anisotropy>1||n.get(x).__currentAnisotropy){const q=e.get("EXT_texture_filter_anisotropic");r.texParameterf(T,q.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,i.getMaxAnisotropy())),n.get(x).__currentAnisotropy=x.anisotropy}}}function $(T,x){let H=!1;T.__webglInit===void 0&&(T.__webglInit=!0,x.addEventListener("dispose",D));const q=x.source;let Z=f.get(q);Z===void 0&&(Z={},f.set(q,Z));const J=G(x);if(J!==T.__cacheKey){Z[J]===void 0&&(Z[J]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,H=!0),Z[J].usedTimes++;const Pe=Z[T.__cacheKey];Pe!==void 0&&(Z[T.__cacheKey].usedTimes--,Pe.usedTimes===0&&w(x)),T.__cacheKey=J,T.__webglTexture=Z[J].texture}return H}function he(T,x,H){let q=r.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(q=r.TEXTURE_2D_ARRAY),x.isData3DTexture&&(q=r.TEXTURE_3D);const Z=$(T,x),J=x.source;t.bindTexture(q,T.__webglTexture,r.TEXTURE0+H);const Pe=n.get(J);if(J.version!==Pe.__version||Z===!0){t.activeTexture(r.TEXTURE0+H);const Se=qe.getPrimaries(qe.workingColorSpace),se=x.colorSpace===Tn?null:qe.getPrimaries(x.colorSpace),oe=x.colorSpace===Tn||Se===se?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,x.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,x.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,oe);const Ie=S(x)&&p(x.image)===!1;let Q=m(x.image,Ie,!1,i.maxTextureSize);Q=ze(x,Q);const at=p(Q)||o,He=s.convert(x.format,x.colorSpace);let _e=s.convert(x.type),fe=C(x.internalFormat,He,_e,x.colorSpace,x.isVideoTexture);z(q,x,at);let pe;const We=x.mipmaps,Re=o&&x.isVideoTexture!==!0&&fe!==Jc,tt=Pe.__version===void 0||Z===!0,P=J.dataReady,ae=A(x,Q,at);if(x.isDepthTexture)fe=r.DEPTH_COMPONENT,o?x.type===Wt?fe=r.DEPTH_COMPONENT32F:x.type===An?fe=r.DEPTH_COMPONENT24:x.type===qn?fe=r.DEPTH24_STENCIL8:fe=r.DEPTH_COMPONENT16:x.type===Wt&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),x.format===Yn&&fe===r.DEPTH_COMPONENT&&x.type!==ga&&x.type!==An&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),x.type=An,_e=s.convert(x.type)),x.format===Ci&&fe===r.DEPTH_COMPONENT&&(fe=r.DEPTH_STENCIL,x.type!==qn&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),x.type=qn,_e=s.convert(x.type))),tt&&(Re?t.texStorage2D(r.TEXTURE_2D,1,fe,Q.width,Q.height):t.texImage2D(r.TEXTURE_2D,0,fe,Q.width,Q.height,0,He,_e,null));else if(x.isDataTexture)if(We.length>0&&at){Re&&tt&&t.texStorage2D(r.TEXTURE_2D,ae,fe,We[0].width,We[0].height);for(let O=0,te=We.length;O<te;O++)pe=We[O],Re?P&&t.texSubImage2D(r.TEXTURE_2D,O,0,0,pe.width,pe.height,He,_e,pe.data):t.texImage2D(r.TEXTURE_2D,O,fe,pe.width,pe.height,0,He,_e,pe.data);x.generateMipmaps=!1}else Re?(tt&&t.texStorage2D(r.TEXTURE_2D,ae,fe,Q.width,Q.height),P&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,Q.width,Q.height,He,_e,Q.data)):t.texImage2D(r.TEXTURE_2D,0,fe,Q.width,Q.height,0,He,_e,Q.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){Re&&tt&&t.texStorage3D(r.TEXTURE_2D_ARRAY,ae,fe,We[0].width,We[0].height,Q.depth);for(let O=0,te=We.length;O<te;O++)pe=We[O],x.format!==Ht?He!==null?Re?P&&t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,O,0,0,0,pe.width,pe.height,Q.depth,He,pe.data,0,0):t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,O,fe,pe.width,pe.height,Q.depth,0,pe.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Re?P&&t.texSubImage3D(r.TEXTURE_2D_ARRAY,O,0,0,0,pe.width,pe.height,Q.depth,He,_e,pe.data):t.texImage3D(r.TEXTURE_2D_ARRAY,O,fe,pe.width,pe.height,Q.depth,0,He,_e,pe.data)}else{Re&&tt&&t.texStorage2D(r.TEXTURE_2D,ae,fe,We[0].width,We[0].height);for(let O=0,te=We.length;O<te;O++)pe=We[O],x.format!==Ht?He!==null?Re?P&&t.compressedTexSubImage2D(r.TEXTURE_2D,O,0,0,pe.width,pe.height,He,pe.data):t.compressedTexImage2D(r.TEXTURE_2D,O,fe,pe.width,pe.height,0,pe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Re?P&&t.texSubImage2D(r.TEXTURE_2D,O,0,0,pe.width,pe.height,He,_e,pe.data):t.texImage2D(r.TEXTURE_2D,O,fe,pe.width,pe.height,0,He,_e,pe.data)}else if(x.isDataArrayTexture)Re?(tt&&t.texStorage3D(r.TEXTURE_2D_ARRAY,ae,fe,Q.width,Q.height,Q.depth),P&&t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,He,_e,Q.data)):t.texImage3D(r.TEXTURE_2D_ARRAY,0,fe,Q.width,Q.height,Q.depth,0,He,_e,Q.data);else if(x.isData3DTexture)Re?(tt&&t.texStorage3D(r.TEXTURE_3D,ae,fe,Q.width,Q.height,Q.depth),P&&t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,He,_e,Q.data)):t.texImage3D(r.TEXTURE_3D,0,fe,Q.width,Q.height,Q.depth,0,He,_e,Q.data);else if(x.isFramebufferTexture){if(tt)if(Re)t.texStorage2D(r.TEXTURE_2D,ae,fe,Q.width,Q.height);else{let O=Q.width,te=Q.height;for(let ce=0;ce<ae;ce++)t.texImage2D(r.TEXTURE_2D,ce,fe,O,te,0,He,_e,null),O>>=1,te>>=1}}else if(We.length>0&&at){if(Re&&tt){const O=st(We[0]);t.texStorage2D(r.TEXTURE_2D,ae,fe,O.width,O.height)}for(let O=0,te=We.length;O<te;O++)pe=We[O],Re?P&&t.texSubImage2D(r.TEXTURE_2D,O,0,0,He,_e,pe):t.texImage2D(r.TEXTURE_2D,O,fe,He,_e,pe);x.generateMipmaps=!1}else if(Re){if(tt){const O=st(Q);t.texStorage2D(r.TEXTURE_2D,ae,fe,O.width,O.height)}P&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,He,_e,Q)}else t.texImage2D(r.TEXTURE_2D,0,fe,He,_e,Q);v(x,at)&&E(q),Pe.__version=J.version,x.onUpdate&&x.onUpdate(x)}T.__version=x.version}function Te(T,x,H){if(x.image.length!==6)return;const q=$(T,x),Z=x.source;t.bindTexture(r.TEXTURE_CUBE_MAP,T.__webglTexture,r.TEXTURE0+H);const J=n.get(Z);if(Z.version!==J.__version||q===!0){t.activeTexture(r.TEXTURE0+H);const Pe=qe.getPrimaries(qe.workingColorSpace),Se=x.colorSpace===Tn?null:qe.getPrimaries(x.colorSpace),se=x.colorSpace===Tn||Pe===Se?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,x.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,x.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,se);const oe=x.isCompressedTexture||x.image[0].isCompressedTexture,Ie=x.image[0]&&x.image[0].isDataTexture,Q=[];for(let O=0;O<6;O++)!oe&&!Ie?Q[O]=m(x.image[O],!1,!0,i.maxCubemapSize):Q[O]=Ie?x.image[O].image:x.image[O],Q[O]=ze(x,Q[O]);const at=Q[0],He=p(at)||o,_e=s.convert(x.format,x.colorSpace),fe=s.convert(x.type),pe=C(x.internalFormat,_e,fe,x.colorSpace),We=o&&x.isVideoTexture!==!0,Re=J.__version===void 0||q===!0,tt=Z.dataReady;let P=A(x,at,He);z(r.TEXTURE_CUBE_MAP,x,He);let ae;if(oe){We&&Re&&t.texStorage2D(r.TEXTURE_CUBE_MAP,P,pe,at.width,at.height);for(let O=0;O<6;O++){ae=Q[O].mipmaps;for(let te=0;te<ae.length;te++){const ce=ae[te];x.format!==Ht?_e!==null?We?tt&&t.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+O,te,0,0,ce.width,ce.height,_e,ce.data):t.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+O,te,pe,ce.width,ce.height,0,ce.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):We?tt&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+O,te,0,0,ce.width,ce.height,_e,fe,ce.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+O,te,pe,ce.width,ce.height,0,_e,fe,ce.data)}}}else{if(ae=x.mipmaps,We&&Re){ae.length>0&&P++;const O=st(Q[0]);t.texStorage2D(r.TEXTURE_CUBE_MAP,P,pe,O.width,O.height)}for(let O=0;O<6;O++)if(Ie){We?tt&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+O,0,0,0,Q[O].width,Q[O].height,_e,fe,Q[O].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+O,0,pe,Q[O].width,Q[O].height,0,_e,fe,Q[O].data);for(let te=0;te<ae.length;te++){const Ge=ae[te].image[O].image;We?tt&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+O,te+1,0,0,Ge.width,Ge.height,_e,fe,Ge.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+O,te+1,pe,Ge.width,Ge.height,0,_e,fe,Ge.data)}}else{We?tt&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+O,0,0,0,_e,fe,Q[O]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+O,0,pe,_e,fe,Q[O]);for(let te=0;te<ae.length;te++){const ce=ae[te];We?tt&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+O,te+1,0,0,_e,fe,ce.image[O]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+O,te+1,pe,_e,fe,ce.image[O])}}}v(x,He)&&E(r.TEXTURE_CUBE_MAP),J.__version=Z.version,x.onUpdate&&x.onUpdate(x)}T.__version=x.version}function ge(T,x,H,q,Z,J){const Pe=s.convert(H.format,H.colorSpace),Se=s.convert(H.type),se=C(H.internalFormat,Pe,Se,H.colorSpace);if(!n.get(x).__hasExternalTextures){const Ie=Math.max(1,x.width>>J),Q=Math.max(1,x.height>>J);Z===r.TEXTURE_3D||Z===r.TEXTURE_2D_ARRAY?t.texImage3D(Z,J,se,Ie,Q,x.depth,0,Pe,Se,null):t.texImage2D(Z,J,se,Ie,Q,0,Pe,Se,null)}t.bindFramebuffer(r.FRAMEBUFFER,T),Ve(x)?c.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,q,Z,n.get(H).__webglTexture,0,ye(x)):(Z===r.TEXTURE_2D||Z>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&Z<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,q,Z,n.get(H).__webglTexture,J),t.bindFramebuffer(r.FRAMEBUFFER,null)}function de(T,x,H){if(r.bindRenderbuffer(r.RENDERBUFFER,T),x.depthBuffer&&!x.stencilBuffer){let q=o===!0?r.DEPTH_COMPONENT24:r.DEPTH_COMPONENT16;if(H||Ve(x)){const Z=x.depthTexture;Z&&Z.isDepthTexture&&(Z.type===Wt?q=r.DEPTH_COMPONENT32F:Z.type===An&&(q=r.DEPTH_COMPONENT24));const J=ye(x);Ve(x)?c.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,J,q,x.width,x.height):r.renderbufferStorageMultisample(r.RENDERBUFFER,J,q,x.width,x.height)}else r.renderbufferStorage(r.RENDERBUFFER,q,x.width,x.height);r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,T)}else if(x.depthBuffer&&x.stencilBuffer){const q=ye(x);H&&Ve(x)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,q,r.DEPTH24_STENCIL8,x.width,x.height):Ve(x)?c.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,q,r.DEPTH24_STENCIL8,x.width,x.height):r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,x.width,x.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,T)}else{const q=x.textures;for(let Z=0;Z<q.length;Z++){const J=q[Z],Pe=s.convert(J.format,J.colorSpace),Se=s.convert(J.type),se=C(J.internalFormat,Pe,Se,J.colorSpace),oe=ye(x);H&&Ve(x)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,oe,se,x.width,x.height):Ve(x)?c.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,oe,se,x.width,x.height):r.renderbufferStorage(r.RENDERBUFFER,se,x.width,x.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function Ye(T,x){if(x&&x.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(r.FRAMEBUFFER,T),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(x.depthTexture).__webglTexture||x.depthTexture.image.width!==x.width||x.depthTexture.image.height!==x.height)&&(x.depthTexture.image.width=x.width,x.depthTexture.image.height=x.height,x.depthTexture.needsUpdate=!0),Y(x.depthTexture,0);const q=n.get(x.depthTexture).__webglTexture,Z=ye(x);if(x.depthTexture.format===Yn)Ve(x)?c.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,q,0,Z):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,q,0);else if(x.depthTexture.format===Ci)Ve(x)?c.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,q,0,Z):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,q,0);else throw new Error("Unknown depthTexture format")}function Ae(T){const x=n.get(T),H=T.isWebGLCubeRenderTarget===!0;if(T.depthTexture&&!x.__autoAllocateDepthBuffer){if(H)throw new Error("target.depthTexture not supported in Cube render targets");Ye(x.__webglFramebuffer,T)}else if(H){x.__webglDepthbuffer=[];for(let q=0;q<6;q++)t.bindFramebuffer(r.FRAMEBUFFER,x.__webglFramebuffer[q]),x.__webglDepthbuffer[q]=r.createRenderbuffer(),de(x.__webglDepthbuffer[q],T,!1)}else t.bindFramebuffer(r.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer=r.createRenderbuffer(),de(x.__webglDepthbuffer,T,!1);t.bindFramebuffer(r.FRAMEBUFFER,null)}function N(T,x,H){const q=n.get(T);x!==void 0&&ge(q.__webglFramebuffer,T,T.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),H!==void 0&&Ae(T)}function gt(T){const x=T.texture,H=n.get(T),q=n.get(x);T.addEventListener("dispose",k);const Z=T.textures,J=T.isWebGLCubeRenderTarget===!0,Pe=Z.length>1,Se=p(T)||o;if(Pe||(q.__webglTexture===void 0&&(q.__webglTexture=r.createTexture()),q.__version=x.version,a.memory.textures++),J){H.__webglFramebuffer=[];for(let se=0;se<6;se++)if(o&&x.mipmaps&&x.mipmaps.length>0){H.__webglFramebuffer[se]=[];for(let oe=0;oe<x.mipmaps.length;oe++)H.__webglFramebuffer[se][oe]=r.createFramebuffer()}else H.__webglFramebuffer[se]=r.createFramebuffer()}else{if(o&&x.mipmaps&&x.mipmaps.length>0){H.__webglFramebuffer=[];for(let se=0;se<x.mipmaps.length;se++)H.__webglFramebuffer[se]=r.createFramebuffer()}else H.__webglFramebuffer=r.createFramebuffer();if(Pe)if(i.drawBuffers)for(let se=0,oe=Z.length;se<oe;se++){const Ie=n.get(Z[se]);Ie.__webglTexture===void 0&&(Ie.__webglTexture=r.createTexture(),a.memory.textures++)}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&T.samples>0&&Ve(T)===!1){H.__webglMultisampledFramebuffer=r.createFramebuffer(),H.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,H.__webglMultisampledFramebuffer);for(let se=0;se<Z.length;se++){const oe=Z[se];H.__webglColorRenderbuffer[se]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,H.__webglColorRenderbuffer[se]);const Ie=s.convert(oe.format,oe.colorSpace),Q=s.convert(oe.type),at=C(oe.internalFormat,Ie,Q,oe.colorSpace,T.isXRRenderTarget===!0),He=ye(T);r.renderbufferStorageMultisample(r.RENDERBUFFER,He,at,T.width,T.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+se,r.RENDERBUFFER,H.__webglColorRenderbuffer[se])}r.bindRenderbuffer(r.RENDERBUFFER,null),T.depthBuffer&&(H.__webglDepthRenderbuffer=r.createRenderbuffer(),de(H.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(r.FRAMEBUFFER,null)}}if(J){t.bindTexture(r.TEXTURE_CUBE_MAP,q.__webglTexture),z(r.TEXTURE_CUBE_MAP,x,Se);for(let se=0;se<6;se++)if(o&&x.mipmaps&&x.mipmaps.length>0)for(let oe=0;oe<x.mipmaps.length;oe++)ge(H.__webglFramebuffer[se][oe],T,x,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+se,oe);else ge(H.__webglFramebuffer[se],T,x,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+se,0);v(x,Se)&&E(r.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Pe){for(let se=0,oe=Z.length;se<oe;se++){const Ie=Z[se],Q=n.get(Ie);t.bindTexture(r.TEXTURE_2D,Q.__webglTexture),z(r.TEXTURE_2D,Ie,Se),ge(H.__webglFramebuffer,T,Ie,r.COLOR_ATTACHMENT0+se,r.TEXTURE_2D,0),v(Ie,Se)&&E(r.TEXTURE_2D)}t.unbindTexture()}else{let se=r.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(o?se=T.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(se,q.__webglTexture),z(se,x,Se),o&&x.mipmaps&&x.mipmaps.length>0)for(let oe=0;oe<x.mipmaps.length;oe++)ge(H.__webglFramebuffer[oe],T,x,r.COLOR_ATTACHMENT0,se,oe);else ge(H.__webglFramebuffer,T,x,r.COLOR_ATTACHMENT0,se,0);v(x,Se)&&E(se),t.unbindTexture()}T.depthBuffer&&Ae(T)}function xe(T){const x=p(T)||o,H=T.textures;for(let q=0,Z=H.length;q<Z;q++){const J=H[q];if(v(J,x)){const Pe=T.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D,Se=n.get(J).__webglTexture;t.bindTexture(Pe,Se),E(Pe),t.unbindTexture()}}}function Be(T){if(o&&T.samples>0&&Ve(T)===!1){const x=T.textures,H=T.width,q=T.height;let Z=r.COLOR_BUFFER_BIT;const J=[],Pe=T.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Se=n.get(T),se=x.length>1;if(se)for(let oe=0;oe<x.length;oe++)t.bindFramebuffer(r.FRAMEBUFFER,Se.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+oe,r.RENDERBUFFER,null),t.bindFramebuffer(r.FRAMEBUFFER,Se.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+oe,r.TEXTURE_2D,null,0);t.bindFramebuffer(r.READ_FRAMEBUFFER,Se.__webglMultisampledFramebuffer),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Se.__webglFramebuffer);for(let oe=0;oe<x.length;oe++){J.push(r.COLOR_ATTACHMENT0+oe),T.depthBuffer&&J.push(Pe);const Ie=Se.__ignoreDepthValues!==void 0?Se.__ignoreDepthValues:!1;if(Ie===!1&&(T.depthBuffer&&(Z|=r.DEPTH_BUFFER_BIT),T.stencilBuffer&&(Z|=r.STENCIL_BUFFER_BIT)),se&&r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,Se.__webglColorRenderbuffer[oe]),Ie===!0&&(r.invalidateFramebuffer(r.READ_FRAMEBUFFER,[Pe]),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[Pe])),se){const Q=n.get(x[oe]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,Q,0)}r.blitFramebuffer(0,0,H,q,0,0,H,q,Z,r.NEAREST),l&&r.invalidateFramebuffer(r.READ_FRAMEBUFFER,J)}if(t.bindFramebuffer(r.READ_FRAMEBUFFER,null),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),se)for(let oe=0;oe<x.length;oe++){t.bindFramebuffer(r.FRAMEBUFFER,Se.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+oe,r.RENDERBUFFER,Se.__webglColorRenderbuffer[oe]);const Ie=n.get(x[oe]).__webglTexture;t.bindFramebuffer(r.FRAMEBUFFER,Se.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+oe,r.TEXTURE_2D,Ie,0)}t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Se.__webglMultisampledFramebuffer)}}function ye(T){return Math.min(i.maxSamples,T.samples)}function Ve(T){const x=n.get(T);return o&&T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function Oe(T){const x=a.render.frame;u.get(T)!==x&&(u.set(T,x),T.update())}function ze(T,x){const H=T.colorSpace,q=T.format,Z=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||T.format===ra||H!==xt&&H!==Tn&&(qe.getTransfer(H)===Qe?o===!1?e.has("EXT_sRGB")===!0&&q===Ht?(T.format=ra,T.minFilter=Et,T.generateMipmaps=!1):x=tl.sRGBToLinear(x):(q!==Ht||Z!==Cn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",H)),x}function st(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(h.width=T.naturalWidth||T.width,h.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(h.width=T.displayWidth,h.height=T.displayHeight):(h.width=T.width,h.height=T.height),h}this.allocateTextureUnit=V,this.resetTextureUnits=L,this.setTexture2D=Y,this.setTexture2DArray=W,this.setTexture3D=X,this.setTextureCube=ee,this.rebindTextures=N,this.setupRenderTarget=gt,this.updateRenderTargetMipmap=xe,this.updateMultisampleRenderTarget=Be,this.setupDepthRenderbuffer=Ae,this.setupFrameBufferTexture=ge,this.useMultisampledRTT=Ve}function hg(r,e,t){const n=t.isWebGL2;function i(s,a=Tn){let o;const c=qe.getTransfer(a);if(s===Cn)return r.UNSIGNED_BYTE;if(s===Wc)return r.UNSIGNED_SHORT_4_4_4_4;if(s===Xc)return r.UNSIGNED_SHORT_5_5_5_1;if(s===Ah)return r.BYTE;if(s===bh)return r.SHORT;if(s===ga)return r.UNSIGNED_SHORT;if(s===Vc)return r.INT;if(s===An)return r.UNSIGNED_INT;if(s===Wt)return r.FLOAT;if(s===ns)return n?r.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===wh)return r.ALPHA;if(s===Ht)return r.RGBA;if(s===Rh)return r.LUMINANCE;if(s===Ch)return r.LUMINANCE_ALPHA;if(s===Yn)return r.DEPTH_COMPONENT;if(s===Ci)return r.DEPTH_STENCIL;if(s===ra)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===qc)return r.RED;if(s===Yc)return r.RED_INTEGER;if(s===Lh)return r.RG;if(s===jc)return r.RG_INTEGER;if(s===Kc)return r.RGBA_INTEGER;if(s===lr||s===hr||s===ur||s===dr)if(c===Qe)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===lr)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===hr)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===ur)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===dr)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===lr)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===hr)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===ur)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===dr)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Ka||s===Ja||s===$a||s===Za)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===Ka)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Ja)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===$a)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Za)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Jc)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Qa||s===eo)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(s===Qa)return c===Qe?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===eo)return c===Qe?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===to||s===no||s===io||s===so||s===ro||s===ao||s===oo||s===co||s===lo||s===ho||s===uo||s===fo||s===po||s===mo)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(s===to)return c===Qe?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===no)return c===Qe?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===io)return c===Qe?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===so)return c===Qe?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===ro)return c===Qe?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===ao)return c===Qe?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===oo)return c===Qe?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===co)return c===Qe?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===lo)return c===Qe?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===ho)return c===Qe?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===uo)return c===Qe?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===fo)return c===Qe?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===po)return c===Qe?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===mo)return c===Qe?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===fr||s===go||s===_o)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(s===fr)return c===Qe?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===go)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===_o)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===Ph||s===vo||s===xo||s===Mo)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(s===fr)return o.COMPRESSED_RED_RGTC1_EXT;if(s===vo)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===xo)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Mo)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===qn?n?r.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}class ug extends Rt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Xn extends et{constructor(){super(),this.isGroup=!0,this.type="Group"}}const dg={type:"move"};class zr{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Xn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Xn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Xn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const _ of e.hand.values()){const m=t.getJointPose(_,n),p=this._getHandJoint(l,_);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,g=.005;l.inputState.pinching&&d>f+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=f-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(dg)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Xn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const fg=`
3780
+ void main() {
3781
+
3782
+ gl_Position = vec4( position, 1.0 );
3783
+
3784
+ }`,pg=`
3785
+ uniform sampler2DArray depthColor;
3786
+ uniform float depthWidth;
3787
+ uniform float depthHeight;
3788
+
3789
+ void main() {
3790
+
3791
+ vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
3792
+
3793
+ if ( coord.x >= 1.0 ) {
3794
+
3795
+ gl_FragDepthEXT = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
3796
+
3797
+ } else {
3798
+
3799
+ gl_FragDepthEXT = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
3800
+
3801
+ }
3802
+
3803
+ }`;class mg{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const i=new lt,s=e.properties.get(i);s.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}render(e,t){if(this.texture!==null){if(this.mesh===null){const n=t.cameras[0].viewport,i=new Ln({extensions:{fragDepth:!0},vertexShader:fg,fragmentShader:pg,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Nt(new nr(20,20),i)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}}class gg extends Jn{constructor(e,t){super();const n=this;let i=null,s=1,a=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,g=null;const _=new mg,m=t.getContextAttributes();let p=null,S=null;const v=[],E=[],C=new re;let A=null;const b=new Rt;b.layers.enable(1),b.viewport=new Ke;const D=new Rt;D.layers.enable(2),D.viewport=new Ke;const k=[b,D],M=new ug;M.layers.enable(1),M.layers.enable(2);let w=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let $=v[z];return $===void 0&&($=new zr,v[z]=$),$.getTargetRaySpace()},this.getControllerGrip=function(z){let $=v[z];return $===void 0&&($=new zr,v[z]=$),$.getGripSpace()},this.getHand=function(z){let $=v[z];return $===void 0&&($=new zr,v[z]=$),$.getHandSpace()};function K(z){const $=E.indexOf(z.inputSource);if($===-1)return;const he=v[$];he!==void 0&&(he.update(z.inputSource,z.frame,l||a),he.dispatchEvent({type:z.type,data:z.inputSource}))}function L(){i.removeEventListener("select",K),i.removeEventListener("selectstart",K),i.removeEventListener("selectend",K),i.removeEventListener("squeeze",K),i.removeEventListener("squeezestart",K),i.removeEventListener("squeezeend",K),i.removeEventListener("end",L),i.removeEventListener("inputsourceschange",V);for(let z=0;z<v.length;z++){const $=E[z];$!==null&&(E[z]=null,v[z].disconnect($))}w=null,j=null,_.reset(),e.setRenderTarget(p),f=null,d=null,u=null,i=null,S=null,Le.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(C.width,C.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(z){s=z,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(z){o=z,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(z){l=z},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(z){if(i=z,i!==null){if(p=e.getRenderTarget(),i.addEventListener("select",K),i.addEventListener("selectstart",K),i.addEventListener("selectend",K),i.addEventListener("squeeze",K),i.addEventListener("squeezestart",K),i.addEventListener("squeezeend",K),i.addEventListener("end",L),i.addEventListener("inputsourceschange",V),m.xrCompatible!==!0&&await t.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(C),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const $={antialias:i.renderState.layers===void 0?m.antialias:!0,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,t,$),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),S=new jn(f.framebufferWidth,f.framebufferHeight,{format:Ht,type:Cn,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let $=null,he=null,Te=null;m.depth&&(Te=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,$=m.stencil?Ci:Yn,he=m.stencil?qn:An);const ge={colorFormat:t.RGBA8,depthFormat:Te,scaleFactor:s};u=new XRWebGLBinding(i,t),d=u.createProjectionLayer(ge),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),S=new jn(d.textureWidth,d.textureHeight,{format:Ht,type:Cn,depthTexture:new ul(d.textureWidth,d.textureHeight,he,void 0,void 0,void 0,void 0,void 0,void 0,$),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0});const de=e.properties.get(S);de.__ignoreDepthValues=d.ignoreDepthValues}S.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await i.requestReferenceSpace(o),Le.setContext(i),Le.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function V(z){for(let $=0;$<z.removed.length;$++){const he=z.removed[$],Te=E.indexOf(he);Te>=0&&(E[Te]=null,v[Te].disconnect(he))}for(let $=0;$<z.added.length;$++){const he=z.added[$];let Te=E.indexOf(he);if(Te===-1){for(let de=0;de<v.length;de++)if(de>=E.length){E.push(he),Te=de;break}else if(E[de]===null){E[de]=he,Te=de;break}if(Te===-1)break}const ge=v[Te];ge&&ge.connect(he)}}const G=new R,Y=new R;function W(z,$,he){G.setFromMatrixPosition($.matrixWorld),Y.setFromMatrixPosition(he.matrixWorld);const Te=G.distanceTo(Y),ge=$.projectionMatrix.elements,de=he.projectionMatrix.elements,Ye=ge[14]/(ge[10]-1),Ae=ge[14]/(ge[10]+1),N=(ge[9]+1)/ge[5],gt=(ge[9]-1)/ge[5],xe=(ge[8]-1)/ge[0],Be=(de[8]+1)/de[0],ye=Ye*xe,Ve=Ye*Be,Oe=Te/(-xe+Be),ze=Oe*-xe;$.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(ze),z.translateZ(Oe),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert();const st=Ye+Oe,T=Ae+Oe,x=ye-ze,H=Ve+(Te-ze),q=N*Ae/T*st,Z=gt*Ae/T*st;z.projectionMatrix.makePerspective(x,H,q,Z,st,T),z.projectionMatrixInverse.copy(z.projectionMatrix).invert()}function X(z,$){$===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices($.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(i===null)return;_.texture!==null&&(z.near=_.depthNear,z.far=_.depthFar),M.near=D.near=b.near=z.near,M.far=D.far=b.far=z.far,(w!==M.near||j!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),w=M.near,j=M.far,b.near=w,b.far=j,D.near=w,D.far=j,b.updateProjectionMatrix(),D.updateProjectionMatrix(),z.updateProjectionMatrix());const $=z.parent,he=M.cameras;X(M,$);for(let Te=0;Te<he.length;Te++)X(he[Te],$);he.length===2?W(M,b,D):M.projectionMatrix.copy(b.projectionMatrix),ee(z,M,$)};function ee(z,$,he){he===null?z.matrix.copy($.matrixWorld):(z.matrix.copy(he.matrixWorld),z.matrix.invert(),z.matrix.multiply($.matrixWorld)),z.matrix.decompose(z.position,z.quaternion,z.scale),z.updateMatrixWorld(!0),z.projectionMatrix.copy($.projectionMatrix),z.projectionMatrixInverse.copy($.projectionMatrixInverse),z.isPerspectiveCamera&&(z.fov=Pi*2*Math.atan(1/z.projectionMatrix.elements[5]),z.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(z){c=z,d!==null&&(d.fixedFoveation=z),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=z)},this.hasDepthSensing=function(){return _.texture!==null};let ie=null;function ue(z,$){if(h=$.getViewerPose(l||a),g=$,h!==null){const he=h.views;f!==null&&(e.setRenderTargetFramebuffer(S,f.framebuffer),e.setRenderTarget(S));let Te=!1;he.length!==M.cameras.length&&(M.cameras.length=0,Te=!0);for(let de=0;de<he.length;de++){const Ye=he[de];let Ae=null;if(f!==null)Ae=f.getViewport(Ye);else{const gt=u.getViewSubImage(d,Ye);Ae=gt.viewport,de===0&&(e.setRenderTargetTextures(S,gt.colorTexture,d.ignoreDepthValues?void 0:gt.depthStencilTexture),e.setRenderTarget(S))}let N=k[de];N===void 0&&(N=new Rt,N.layers.enable(de),N.viewport=new Ke,k[de]=N),N.matrix.fromArray(Ye.transform.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale),N.projectionMatrix.fromArray(Ye.projectionMatrix),N.projectionMatrixInverse.copy(N.projectionMatrix).invert(),N.viewport.set(Ae.x,Ae.y,Ae.width,Ae.height),de===0&&(M.matrix.copy(N.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),Te===!0&&M.cameras.push(N)}const ge=i.enabledFeatures;if(ge&&ge.includes("depth-sensing")){const de=u.getDepthInformation(he[0]);de&&de.isValid&&de.texture&&_.init(e,de,i.renderState)}}for(let he=0;he<v.length;he++){const Te=E[he],ge=v[he];Te!==null&&ge!==void 0&&ge.update(Te,$,l||a)}_.render(e,M),ie&&ie(z,$),$.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:$}),g=null}const Le=new hl;Le.setAnimationLoop(ue),this.setAnimationLoop=function(z){ie=z},this.dispose=function(){}}}const Bn=new Kt,_g=new be;function vg(r,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,ol(r)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function i(m,p,S,v,E){p.isMeshBasicMaterial||p.isMeshLambertMaterial?s(m,p):p.isMeshToonMaterial?(s(m,p),u(m,p)):p.isMeshPhongMaterial?(s(m,p),h(m,p)):p.isMeshStandardMaterial?(s(m,p),d(m,p),p.isMeshPhysicalMaterial&&f(m,p,E)):p.isMeshMatcapMaterial?(s(m,p),g(m,p)):p.isMeshDepthMaterial?s(m,p):p.isMeshDistanceMaterial?(s(m,p),_(m,p)):p.isMeshNormalMaterial?s(m,p):p.isLineBasicMaterial?(a(m,p),p.isLineDashedMaterial&&o(m,p)):p.isPointsMaterial?c(m,p,S,v):p.isSpriteMaterial?l(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function s(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===Ct&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===Ct&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,t(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,t(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const S=e.get(p),v=S.envMap,E=S.envMapRotation;if(v&&(m.envMap.value=v,Bn.copy(E),Bn.x*=-1,Bn.y*=-1,Bn.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(Bn.y*=-1,Bn.z*=-1),m.envMapRotation.value.setFromMatrix4(_g.makeRotationFromEuler(Bn)),m.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap){m.lightMap.value=p.lightMap;const C=r._useLegacyLights===!0?Math.PI:1;m.lightMapIntensity.value=p.lightMapIntensity*C,t(p.lightMap,m.lightMapTransform)}p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function a(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function c(m,p,S,v){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*S,m.scale.value=v*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function l(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function u(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function d(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),e.get(p).envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,S){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Ct&&m.clearcoatNormalScale.value.negate())),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=S.texture,m.transmissionSamplerSize.value.set(S.width,S.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function _(m,p){const S=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(S.matrixWorld),m.nearDistance.value=S.shadow.camera.near,m.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function xg(r,e,t,n){let i={},s={},a=[];const o=t.isWebGL2?r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(S,v){const E=v.program;n.uniformBlockBinding(S,E)}function l(S,v){let E=i[S.id];E===void 0&&(g(S),E=h(S),i[S.id]=E,S.addEventListener("dispose",m));const C=v.program;n.updateUBOMapping(S,C);const A=e.render.frame;s[S.id]!==A&&(d(S),s[S.id]=A)}function h(S){const v=u();S.__bindingPointIndex=v;const E=r.createBuffer(),C=S.__size,A=S.usage;return r.bindBuffer(r.UNIFORM_BUFFER,E),r.bufferData(r.UNIFORM_BUFFER,C,A),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,v,E),E}function u(){for(let S=0;S<o;S++)if(a.indexOf(S)===-1)return a.push(S),S;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(S){const v=i[S.id],E=S.uniforms,C=S.__cache;r.bindBuffer(r.UNIFORM_BUFFER,v);for(let A=0,b=E.length;A<b;A++){const D=Array.isArray(E[A])?E[A]:[E[A]];for(let k=0,M=D.length;k<M;k++){const w=D[k];if(f(w,A,k,C)===!0){const j=w.__offset,K=Array.isArray(w.value)?w.value:[w.value];let L=0;for(let V=0;V<K.length;V++){const G=K[V],Y=_(G);typeof G=="number"||typeof G=="boolean"?(w.__data[0]=G,r.bufferSubData(r.UNIFORM_BUFFER,j+L,w.__data)):G.isMatrix3?(w.__data[0]=G.elements[0],w.__data[1]=G.elements[1],w.__data[2]=G.elements[2],w.__data[3]=0,w.__data[4]=G.elements[3],w.__data[5]=G.elements[4],w.__data[6]=G.elements[5],w.__data[7]=0,w.__data[8]=G.elements[6],w.__data[9]=G.elements[7],w.__data[10]=G.elements[8],w.__data[11]=0):(G.toArray(w.__data,L),L+=Y.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,j,w.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function f(S,v,E,C){const A=S.value,b=v+"_"+E;if(C[b]===void 0)return typeof A=="number"||typeof A=="boolean"?C[b]=A:C[b]=A.clone(),!0;{const D=C[b];if(typeof A=="number"||typeof A=="boolean"){if(D!==A)return C[b]=A,!0}else if(D.equals(A)===!1)return D.copy(A),!0}return!1}function g(S){const v=S.uniforms;let E=0;const C=16;for(let b=0,D=v.length;b<D;b++){const k=Array.isArray(v[b])?v[b]:[v[b]];for(let M=0,w=k.length;M<w;M++){const j=k[M],K=Array.isArray(j.value)?j.value:[j.value];for(let L=0,V=K.length;L<V;L++){const G=K[L],Y=_(G),W=E%C;W!==0&&C-W<Y.boundary&&(E+=C-W),j.__data=new Float32Array(Y.storage/Float32Array.BYTES_PER_ELEMENT),j.__offset=E,E+=Y.storage}}}const A=E%C;return A>0&&(E+=C-A),S.__size=E,S.__cache={},this}function _(S){const v={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(v.boundary=4,v.storage=4):S.isVector2?(v.boundary=8,v.storage=8):S.isVector3||S.isColor?(v.boundary=16,v.storage=12):S.isVector4?(v.boundary=16,v.storage=16):S.isMatrix3?(v.boundary=48,v.storage=48):S.isMatrix4?(v.boundary=64,v.storage=64):S.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",S),v}function m(S){const v=S.target;v.removeEventListener("dispose",m);const E=a.indexOf(v.__bindingPointIndex);a.splice(E,1),r.deleteBuffer(i[v.id]),delete i[v.id],delete s[v.id]}function p(){for(const S in i)r.deleteBuffer(i[S]);a=[],i={},s={}}return{bind:c,update:l,dispose:p}}class Mg{constructor(e={}){const{canvas:t=cu(),context:n=null,depth:i=!0,stencil:s=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0;let d;n!==null?d=n.getContextAttributes().alpha:d=a;const f=new Uint32Array(4),g=new Int32Array(4);let _=null,m=null;const p=[],S=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=wt,this._useLegacyLights=!1,this.toneMapping=Rn,this.toneMappingExposure=1;const v=this;let E=!1,C=0,A=0,b=null,D=-1,k=null;const M=new Ke,w=new Ke;let j=null;const K=new ve(0);let L=0,V=t.width,G=t.height,Y=1,W=null,X=null;const ee=new Ke(0,0,V,G),ie=new Ke(0,0,V,G);let ue=!1;const Le=new Sa;let z=!1,$=!1,he=null;const Te=new be,ge=new re,de=new R,Ye={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ae(){return b===null?Y:1}let N=n;function gt(y,I){for(let F=0;F<y.length;F++){const B=y[F],U=t.getContext(B,I);if(U!==null)return U}return null}try{const y={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${pa}`),t.addEventListener("webglcontextlost",tt,!1),t.addEventListener("webglcontextrestored",P,!1),t.addEventListener("webglcontextcreationerror",ae,!1),N===null){const I=["webgl2","webgl","experimental-webgl"];if(v.isWebGL1Renderer===!0&&I.shift(),N=gt(I,y),N===null)throw gt(I)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&N instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),N.getShaderPrecisionFormat===void 0&&(N.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(y){throw console.error("THREE.WebGLRenderer: "+y.message),y}let xe,Be,ye,Ve,Oe,ze,st,T,x,H,q,Z,J,Pe,Se,se,oe,Ie,Q,at,He,_e,fe,pe;function We(){xe=new Ap(N),Be=new xp(N,xe,e),xe.init(Be),_e=new hg(N,xe,Be),ye=new cg(N,xe,Be),Ve=new Rp(N),Oe=new jm,ze=new lg(N,xe,ye,Oe,Be,_e,Ve),st=new yp(v),T=new Tp(v),x=new Nu(N,Be),fe=new _p(N,xe,x,Be),H=new bp(N,x,Ve,fe),q=new Ip(N,H,x,Ve),Q=new Pp(N,Be,ze),se=new Mp(Oe),Z=new Ym(v,st,T,xe,Be,fe,se),J=new vg(v,Oe),Pe=new Jm,Se=new ng(xe,Be),Ie=new gp(v,st,T,ye,q,d,c),oe=new og(v,q,Be),pe=new xg(N,Ve,Be,ye),at=new vp(N,xe,Ve,Be),He=new wp(N,xe,Ve,Be),Ve.programs=Z.programs,v.capabilities=Be,v.extensions=xe,v.properties=Oe,v.renderLists=Pe,v.shadowMap=oe,v.state=ye,v.info=Ve}We();const Re=new gg(v,N);this.xr=Re,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){const y=xe.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){const y=xe.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return Y},this.setPixelRatio=function(y){y!==void 0&&(Y=y,this.setSize(V,G,!1))},this.getSize=function(y){return y.set(V,G)},this.setSize=function(y,I,F=!0){if(Re.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}V=y,G=I,t.width=Math.floor(y*Y),t.height=Math.floor(I*Y),F===!0&&(t.style.width=y+"px",t.style.height=I+"px"),this.setViewport(0,0,y,I)},this.getDrawingBufferSize=function(y){return y.set(V*Y,G*Y).floor()},this.setDrawingBufferSize=function(y,I,F){V=y,G=I,Y=F,t.width=Math.floor(y*F),t.height=Math.floor(I*F),this.setViewport(0,0,y,I)},this.getCurrentViewport=function(y){return y.copy(M)},this.getViewport=function(y){return y.copy(ee)},this.setViewport=function(y,I,F,B){y.isVector4?ee.set(y.x,y.y,y.z,y.w):ee.set(y,I,F,B),ye.viewport(M.copy(ee).multiplyScalar(Y).round())},this.getScissor=function(y){return y.copy(ie)},this.setScissor=function(y,I,F,B){y.isVector4?ie.set(y.x,y.y,y.z,y.w):ie.set(y,I,F,B),ye.scissor(w.copy(ie).multiplyScalar(Y).round())},this.getScissorTest=function(){return ue},this.setScissorTest=function(y){ye.setScissorTest(ue=y)},this.setOpaqueSort=function(y){W=y},this.setTransparentSort=function(y){X=y},this.getClearColor=function(y){return y.copy(Ie.getClearColor())},this.setClearColor=function(){Ie.setClearColor.apply(Ie,arguments)},this.getClearAlpha=function(){return Ie.getClearAlpha()},this.setClearAlpha=function(){Ie.setClearAlpha.apply(Ie,arguments)},this.clear=function(y=!0,I=!0,F=!0){let B=0;if(y){let U=!1;if(b!==null){const le=b.texture.format;U=le===Kc||le===jc||le===Yc}if(U){const le=b.texture.type,me=le===Cn||le===An||le===ga||le===qn||le===Wc||le===Xc,Me=Ie.getClearColor(),Ee=Ie.getClearAlpha(),Fe=Me.r,we=Me.g,Ce=Me.b;me?(f[0]=Fe,f[1]=we,f[2]=Ce,f[3]=Ee,N.clearBufferuiv(N.COLOR,0,f)):(g[0]=Fe,g[1]=we,g[2]=Ce,g[3]=Ee,N.clearBufferiv(N.COLOR,0,g))}else B|=N.COLOR_BUFFER_BIT}I&&(B|=N.DEPTH_BUFFER_BIT),F&&(B|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),N.clear(B)},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(){t.removeEventListener("webglcontextlost",tt,!1),t.removeEventListener("webglcontextrestored",P,!1),t.removeEventListener("webglcontextcreationerror",ae,!1),Pe.dispose(),Se.dispose(),Oe.dispose(),st.dispose(),T.dispose(),q.dispose(),fe.dispose(),pe.dispose(),Z.dispose(),Re.dispose(),Re.removeEventListener("sessionstart",Ut),Re.removeEventListener("sessionend",$e),he&&(he.dispose(),he=null),Tt.stop()};function tt(y){y.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),E=!0}function P(){console.log("THREE.WebGLRenderer: Context Restored."),E=!1;const y=Ve.autoReset,I=oe.enabled,F=oe.autoUpdate,B=oe.needsUpdate,U=oe.type;We(),Ve.autoReset=y,oe.enabled=I,oe.autoUpdate=F,oe.needsUpdate=B,oe.type=U}function ae(y){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function O(y){const I=y.target;I.removeEventListener("dispose",O),te(I)}function te(y){ce(y),Oe.remove(y)}function ce(y){const I=Oe.get(y).programs;I!==void 0&&(I.forEach(function(F){Z.releaseProgram(F)}),y.isShaderMaterial&&Z.releaseShaderCache(y))}this.renderBufferDirect=function(y,I,F,B,U,le){I===null&&(I=Ye);const me=U.isMesh&&U.matrixWorld.determinant()<0,Me=zl(y,I,F,B,U);ye.setMaterial(B,me);let Ee=F.index,Fe=1;if(B.wireframe===!0){if(Ee=H.getWireframeAttribute(F),Ee===void 0)return;Fe=2}const we=F.drawRange,Ce=F.attributes.position;let rt=we.start*Fe,Lt=(we.start+we.count)*Fe;le!==null&&(rt=Math.max(rt,le.start*Fe),Lt=Math.min(Lt,(le.start+le.count)*Fe)),Ee!==null?(rt=Math.max(rt,0),Lt=Math.min(Lt,Ee.count)):Ce!=null&&(rt=Math.max(rt,0),Lt=Math.min(Lt,Ce.count));const dt=Lt-rt;if(dt<0||dt===1/0)return;fe.setup(U,B,Me,F,Ee);let sn,it=at;if(Ee!==null&&(sn=x.get(Ee),it=He,it.setIndex(sn)),U.isMesh)B.wireframe===!0?(ye.setLineWidth(B.wireframeLinewidth*Ae()),it.setMode(N.LINES)):it.setMode(N.TRIANGLES);else if(U.isLine){let Ne=B.linewidth;Ne===void 0&&(Ne=1),ye.setLineWidth(Ne*Ae()),U.isLineSegments?it.setMode(N.LINES):U.isLineLoop?it.setMode(N.LINE_LOOP):it.setMode(N.LINE_STRIP)}else U.isPoints?it.setMode(N.POINTS):U.isSprite&&it.setMode(N.TRIANGLES);if(U.isBatchedMesh)it.renderMultiDraw(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount);else if(U.isInstancedMesh)it.renderInstances(rt,dt,U.count);else if(F.isInstancedBufferGeometry){const Ne=F._maxInstanceCount!==void 0?F._maxInstanceCount:1/0,rr=Math.min(F.instanceCount,Ne);it.renderInstances(rt,dt,rr)}else it.render(rt,dt)};function Ge(y,I,F){y.transparent===!0&&y.side===Zt&&y.forceSinglePass===!1?(y.side=Ct,y.needsUpdate=!0,us(y,I,F),y.side=pn,y.needsUpdate=!0,us(y,I,F),y.side=Zt):us(y,I,F)}this.compile=function(y,I,F=null){F===null&&(F=y),m=Se.get(F),m.init(),S.push(m),F.traverseVisible(function(U){U.isLight&&U.layers.test(I.layers)&&(m.pushLight(U),U.castShadow&&m.pushShadow(U))}),y!==F&&y.traverseVisible(function(U){U.isLight&&U.layers.test(I.layers)&&(m.pushLight(U),U.castShadow&&m.pushShadow(U))}),m.setupLights(v._useLegacyLights);const B=new Set;return y.traverse(function(U){const le=U.material;if(le)if(Array.isArray(le))for(let me=0;me<le.length;me++){const Me=le[me];Ge(Me,F,U),B.add(Me)}else Ge(le,F,U),B.add(le)}),S.pop(),m=null,B},this.compileAsync=function(y,I,F=null){const B=this.compile(y,I,F);return new Promise(U=>{function le(){if(B.forEach(function(me){Oe.get(me).currentProgram.isReady()&&B.delete(me)}),B.size===0){U(y);return}setTimeout(le,10)}xe.get("KHR_parallel_shader_compile")!==null?le():setTimeout(le,10)})};let Je=null;function _t(y){Je&&Je(y)}function Ut(){Tt.stop()}function $e(){Tt.start()}const Tt=new hl;Tt.setAnimationLoop(_t),typeof self<"u"&&Tt.setContext(self),this.setAnimationLoop=function(y){Je=y,Re.setAnimationLoop(y),y===null?Tt.stop():Tt.start()},Re.addEventListener("sessionstart",Ut),Re.addEventListener("sessionend",$e),this.render=function(y,I){if(I!==void 0&&I.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(E===!0)return;y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),I.parent===null&&I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),Re.enabled===!0&&Re.isPresenting===!0&&(Re.cameraAutoUpdate===!0&&Re.updateCamera(I),I=Re.getCamera()),y.isScene===!0&&y.onBeforeRender(v,y,I,b),m=Se.get(y,S.length),m.init(),S.push(m),Te.multiplyMatrices(I.projectionMatrix,I.matrixWorldInverse),Le.setFromProjectionMatrix(Te),$=this.localClippingEnabled,z=se.init(this.clippingPlanes,$),_=Pe.get(y,p.length),_.init(),p.push(_),Jt(y,I,0,v.sortObjects),_.finish(),v.sortObjects===!0&&_.sort(W,X),this.info.render.frame++,z===!0&&se.beginShadows();const F=m.state.shadowsArray;if(oe.render(F,y,I),z===!0&&se.endShadows(),this.info.autoReset===!0&&this.info.reset(),(Re.enabled===!1||Re.isPresenting===!1||Re.hasDepthSensing()===!1)&&Ie.render(_,y),m.setupLights(v._useLegacyLights),I.isArrayCamera){const B=I.cameras;for(let U=0,le=B.length;U<le;U++){const me=B[U];Oa(_,y,me,me.viewport)}}else Oa(_,y,I);b!==null&&(ze.updateMultisampleRenderTarget(b),ze.updateRenderTargetMipmap(b)),y.isScene===!0&&y.onAfterRender(v,y,I),fe.resetDefaultState(),D=-1,k=null,S.pop(),S.length>0?m=S[S.length-1]:m=null,p.pop(),p.length>0?_=p[p.length-1]:_=null};function Jt(y,I,F,B){if(y.visible===!1)return;if(y.layers.test(I.layers)){if(y.isGroup)F=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(I);else if(y.isLight)m.pushLight(y),y.castShadow&&m.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||Le.intersectsSprite(y)){B&&de.setFromMatrixPosition(y.matrixWorld).applyMatrix4(Te);const me=q.update(y),Me=y.material;Me.visible&&_.push(y,me,Me,F,de.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||Le.intersectsObject(y))){const me=q.update(y),Me=y.material;if(B&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),de.copy(y.boundingSphere.center)):(me.boundingSphere===null&&me.computeBoundingSphere(),de.copy(me.boundingSphere.center)),de.applyMatrix4(y.matrixWorld).applyMatrix4(Te)),Array.isArray(Me)){const Ee=me.groups;for(let Fe=0,we=Ee.length;Fe<we;Fe++){const Ce=Ee[Fe],rt=Me[Ce.materialIndex];rt&&rt.visible&&_.push(y,me,rt,F,de.z,Ce)}}else Me.visible&&_.push(y,me,Me,F,de.z,null)}}const le=y.children;for(let me=0,Me=le.length;me<Me;me++)Jt(le[me],I,F,B)}function Oa(y,I,F,B){const U=y.opaque,le=y.transmissive,me=y.transparent;m.setupLightsView(F),z===!0&&se.setGlobalState(v.clippingPlanes,F),le.length>0&&Bl(U,le,I,F),B&&ye.viewport(M.copy(B)),U.length>0&&hs(U,I,F),le.length>0&&hs(le,I,F),me.length>0&&hs(me,I,F),ye.buffers.depth.setTest(!0),ye.buffers.depth.setMask(!0),ye.buffers.color.setMask(!0),ye.setPolygonOffset(!1)}function Bl(y,I,F,B){if((F.isScene===!0?F.overrideMaterial:null)!==null)return;const le=Be.isWebGL2;he===null&&(he=new jn(1,1,{generateMipmaps:!0,type:xe.has("EXT_color_buffer_half_float")?ns:Cn,minFilter:dn,samples:le?4:0})),v.getDrawingBufferSize(ge),le?he.setSize(ge.x,ge.y):he.setSize(Qs(ge.x),Qs(ge.y));const me=v.getRenderTarget();v.setRenderTarget(he),v.getClearColor(K),L=v.getClearAlpha(),L<1&&v.setClearColor(16777215,.5),v.clear();const Me=v.toneMapping;v.toneMapping=Rn,hs(y,F,B),ze.updateMultisampleRenderTarget(he),ze.updateRenderTargetMipmap(he);let Ee=!1;for(let Fe=0,we=I.length;Fe<we;Fe++){const Ce=I[Fe],rt=Ce.object,Lt=Ce.geometry,dt=Ce.material,sn=Ce.group;if(dt.side===Zt&&rt.layers.test(B.layers)){const it=dt.side;dt.side=Ct,dt.needsUpdate=!0,Fa(rt,F,B,Lt,dt,sn),dt.side=it,dt.needsUpdate=!0,Ee=!0}}Ee===!0&&(ze.updateMultisampleRenderTarget(he),ze.updateRenderTargetMipmap(he)),v.setRenderTarget(me),v.setClearColor(K,L),v.toneMapping=Me}function hs(y,I,F){const B=I.isScene===!0?I.overrideMaterial:null;for(let U=0,le=y.length;U<le;U++){const me=y[U],Me=me.object,Ee=me.geometry,Fe=B===null?me.material:B,we=me.group;Me.layers.test(F.layers)&&Fa(Me,I,F,Ee,Fe,we)}}function Fa(y,I,F,B,U,le){y.onBeforeRender(v,I,F,B,U,le),y.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),U.onBeforeRender(v,I,F,B,y,le),U.transparent===!0&&U.side===Zt&&U.forceSinglePass===!1?(U.side=Ct,U.needsUpdate=!0,v.renderBufferDirect(F,I,B,U,y,le),U.side=pn,U.needsUpdate=!0,v.renderBufferDirect(F,I,B,U,y,le),U.side=Zt):v.renderBufferDirect(F,I,B,U,y,le),y.onAfterRender(v,I,F,B,U,le)}function us(y,I,F){I.isScene!==!0&&(I=Ye);const B=Oe.get(y),U=m.state.lights,le=m.state.shadowsArray,me=U.state.version,Me=Z.getParameters(y,U.state,le,I,F),Ee=Z.getProgramCacheKey(Me);let Fe=B.programs;B.environment=y.isMeshStandardMaterial?I.environment:null,B.fog=I.fog,B.envMap=(y.isMeshStandardMaterial?T:st).get(y.envMap||B.environment),B.envMapRotation=B.environment!==null&&y.envMap===null?I.environmentRotation:y.envMapRotation,Fe===void 0&&(y.addEventListener("dispose",O),Fe=new Map,B.programs=Fe);let we=Fe.get(Ee);if(we!==void 0){if(B.currentProgram===we&&B.lightsStateVersion===me)return za(y,Me),we}else Me.uniforms=Z.getUniforms(y),y.onBuild(F,Me,v),y.onBeforeCompile(Me,v),we=Z.acquireProgram(Me,Ee),Fe.set(Ee,we),B.uniforms=Me.uniforms;const Ce=B.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(Ce.clippingPlanes=se.uniform),za(y,Me),B.needsLights=Gl(y),B.lightsStateVersion=me,B.needsLights&&(Ce.ambientLightColor.value=U.state.ambient,Ce.lightProbe.value=U.state.probe,Ce.directionalLights.value=U.state.directional,Ce.directionalLightShadows.value=U.state.directionalShadow,Ce.spotLights.value=U.state.spot,Ce.spotLightShadows.value=U.state.spotShadow,Ce.rectAreaLights.value=U.state.rectArea,Ce.ltc_1.value=U.state.rectAreaLTC1,Ce.ltc_2.value=U.state.rectAreaLTC2,Ce.pointLights.value=U.state.point,Ce.pointLightShadows.value=U.state.pointShadow,Ce.hemisphereLights.value=U.state.hemi,Ce.directionalShadowMap.value=U.state.directionalShadowMap,Ce.directionalShadowMatrix.value=U.state.directionalShadowMatrix,Ce.spotShadowMap.value=U.state.spotShadowMap,Ce.spotLightMatrix.value=U.state.spotLightMatrix,Ce.spotLightMap.value=U.state.spotLightMap,Ce.pointShadowMap.value=U.state.pointShadowMap,Ce.pointShadowMatrix.value=U.state.pointShadowMatrix),B.currentProgram=we,B.uniformsList=null,we}function Ba(y){if(y.uniformsList===null){const I=y.currentProgram.getUniforms();y.uniformsList=Xs.seqWithValue(I.seq,y.uniforms)}return y.uniformsList}function za(y,I){const F=Oe.get(y);F.outputColorSpace=I.outputColorSpace,F.batching=I.batching,F.instancing=I.instancing,F.instancingColor=I.instancingColor,F.instancingMorph=I.instancingMorph,F.skinning=I.skinning,F.morphTargets=I.morphTargets,F.morphNormals=I.morphNormals,F.morphColors=I.morphColors,F.morphTargetsCount=I.morphTargetsCount,F.numClippingPlanes=I.numClippingPlanes,F.numIntersection=I.numClipIntersection,F.vertexAlphas=I.vertexAlphas,F.vertexTangents=I.vertexTangents,F.toneMapping=I.toneMapping}function zl(y,I,F,B,U){I.isScene!==!0&&(I=Ye),ze.resetTextureUnits();const le=I.fog,me=B.isMeshStandardMaterial?I.environment:null,Me=b===null?v.outputColorSpace:b.isXRRenderTarget===!0?b.texture.colorSpace:xt,Ee=(B.isMeshStandardMaterial?T:st).get(B.envMap||me),Fe=B.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,we=!!F.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ce=!!F.morphAttributes.position,rt=!!F.morphAttributes.normal,Lt=!!F.morphAttributes.color;let dt=Rn;B.toneMapped&&(b===null||b.isXRRenderTarget===!0)&&(dt=v.toneMapping);const sn=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,it=sn!==void 0?sn.length:0,Ne=Oe.get(B),rr=m.state.lights;if(z===!0&&($===!0||y!==k)){const Ot=y===k&&B.id===D;se.setState(B,y,Ot)}let nt=!1;B.version===Ne.__version?(Ne.needsLights&&Ne.lightsStateVersion!==rr.state.version||Ne.outputColorSpace!==Me||U.isBatchedMesh&&Ne.batching===!1||!U.isBatchedMesh&&Ne.batching===!0||U.isInstancedMesh&&Ne.instancing===!1||!U.isInstancedMesh&&Ne.instancing===!0||U.isSkinnedMesh&&Ne.skinning===!1||!U.isSkinnedMesh&&Ne.skinning===!0||U.isInstancedMesh&&Ne.instancingColor===!0&&U.instanceColor===null||U.isInstancedMesh&&Ne.instancingColor===!1&&U.instanceColor!==null||U.isInstancedMesh&&Ne.instancingMorph===!0&&U.morphTexture===null||U.isInstancedMesh&&Ne.instancingMorph===!1&&U.morphTexture!==null||Ne.envMap!==Ee||B.fog===!0&&Ne.fog!==le||Ne.numClippingPlanes!==void 0&&(Ne.numClippingPlanes!==se.numPlanes||Ne.numIntersection!==se.numIntersection)||Ne.vertexAlphas!==Fe||Ne.vertexTangents!==we||Ne.morphTargets!==Ce||Ne.morphNormals!==rt||Ne.morphColors!==Lt||Ne.toneMapping!==dt||Be.isWebGL2===!0&&Ne.morphTargetsCount!==it)&&(nt=!0):(nt=!0,Ne.__version=B.version);let Pn=Ne.currentProgram;nt===!0&&(Pn=us(B,I,U));let Ha=!1,zi=!1,ar=!1;const Mt=Pn.getUniforms(),In=Ne.uniforms;if(ye.useProgram(Pn.program)&&(Ha=!0,zi=!0,ar=!0),B.id!==D&&(D=B.id,zi=!0),Ha||k!==y){Mt.setValue(N,"projectionMatrix",y.projectionMatrix),Mt.setValue(N,"viewMatrix",y.matrixWorldInverse);const Ot=Mt.map.cameraPosition;Ot!==void 0&&Ot.setValue(N,de.setFromMatrixPosition(y.matrixWorld)),Be.logarithmicDepthBuffer&&Mt.setValue(N,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&Mt.setValue(N,"isOrthographic",y.isOrthographicCamera===!0),k!==y&&(k=y,zi=!0,ar=!0)}if(U.isSkinnedMesh){Mt.setOptional(N,U,"bindMatrix"),Mt.setOptional(N,U,"bindMatrixInverse");const Ot=U.skeleton;Ot&&(Be.floatVertexTextures?(Ot.boneTexture===null&&Ot.computeBoneTexture(),Mt.setValue(N,"boneTexture",Ot.boneTexture,ze)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}U.isBatchedMesh&&(Mt.setOptional(N,U,"batchingTexture"),Mt.setValue(N,"batchingTexture",U._matricesTexture,ze));const or=F.morphAttributes;if((or.position!==void 0||or.normal!==void 0||or.color!==void 0&&Be.isWebGL2===!0)&&Q.update(U,F,Pn),(zi||Ne.receiveShadow!==U.receiveShadow)&&(Ne.receiveShadow=U.receiveShadow,Mt.setValue(N,"receiveShadow",U.receiveShadow)),B.isMeshGouraudMaterial&&B.envMap!==null&&(In.envMap.value=Ee,In.flipEnvMap.value=Ee.isCubeTexture&&Ee.isRenderTargetTexture===!1?-1:1),zi&&(Mt.setValue(N,"toneMappingExposure",v.toneMappingExposure),Ne.needsLights&&Hl(In,ar),le&&B.fog===!0&&J.refreshFogUniforms(In,le),J.refreshMaterialUniforms(In,B,Y,G,he),Xs.upload(N,Ba(Ne),In,ze)),B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Xs.upload(N,Ba(Ne),In,ze),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&Mt.setValue(N,"center",U.center),Mt.setValue(N,"modelViewMatrix",U.modelViewMatrix),Mt.setValue(N,"normalMatrix",U.normalMatrix),Mt.setValue(N,"modelMatrix",U.matrixWorld),B.isShaderMaterial||B.isRawShaderMaterial){const Ot=B.uniformsGroups;for(let cr=0,kl=Ot.length;cr<kl;cr++)if(Be.isWebGL2){const Ga=Ot[cr];pe.update(Ga,Pn),pe.bind(Ga,Pn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Pn}function Hl(y,I){y.ambientLightColor.needsUpdate=I,y.lightProbe.needsUpdate=I,y.directionalLights.needsUpdate=I,y.directionalLightShadows.needsUpdate=I,y.pointLights.needsUpdate=I,y.pointLightShadows.needsUpdate=I,y.spotLights.needsUpdate=I,y.spotLightShadows.needsUpdate=I,y.rectAreaLights.needsUpdate=I,y.hemisphereLights.needsUpdate=I}function Gl(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return C},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(y,I,F){Oe.get(y.texture).__webglTexture=I,Oe.get(y.depthTexture).__webglTexture=F;const B=Oe.get(y);B.__hasExternalTextures=!0,B.__autoAllocateDepthBuffer=F===void 0,B.__autoAllocateDepthBuffer||xe.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),B.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(y,I){const F=Oe.get(y);F.__webglFramebuffer=I,F.__useDefaultFramebuffer=I===void 0},this.setRenderTarget=function(y,I=0,F=0){b=y,C=I,A=F;let B=!0,U=null,le=!1,me=!1;if(y){const Ee=Oe.get(y);Ee.__useDefaultFramebuffer!==void 0?(ye.bindFramebuffer(N.FRAMEBUFFER,null),B=!1):Ee.__webglFramebuffer===void 0?ze.setupRenderTarget(y):Ee.__hasExternalTextures&&ze.rebindTextures(y,Oe.get(y.texture).__webglTexture,Oe.get(y.depthTexture).__webglTexture);const Fe=y.texture;(Fe.isData3DTexture||Fe.isDataArrayTexture||Fe.isCompressedArrayTexture)&&(me=!0);const we=Oe.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(we[I])?U=we[I][F]:U=we[I],le=!0):Be.isWebGL2&&y.samples>0&&ze.useMultisampledRTT(y)===!1?U=Oe.get(y).__webglMultisampledFramebuffer:Array.isArray(we)?U=we[F]:U=we,M.copy(y.viewport),w.copy(y.scissor),j=y.scissorTest}else M.copy(ee).multiplyScalar(Y).floor(),w.copy(ie).multiplyScalar(Y).floor(),j=ue;if(ye.bindFramebuffer(N.FRAMEBUFFER,U)&&Be.drawBuffers&&B&&ye.drawBuffers(y,U),ye.viewport(M),ye.scissor(w),ye.setScissorTest(j),le){const Ee=Oe.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+I,Ee.__webglTexture,F)}else if(me){const Ee=Oe.get(y.texture),Fe=I||0;N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,Ee.__webglTexture,F||0,Fe)}D=-1},this.readRenderTargetPixels=function(y,I,F,B,U,le,me){if(!(y&&y.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Me=Oe.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&me!==void 0&&(Me=Me[me]),Me){ye.bindFramebuffer(N.FRAMEBUFFER,Me);try{const Ee=y.texture,Fe=Ee.format,we=Ee.type;if(Fe!==Ht&&_e.convert(Fe)!==N.getParameter(N.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Ce=we===ns&&(xe.has("EXT_color_buffer_half_float")||Be.isWebGL2&&xe.has("EXT_color_buffer_float"));if(we!==Cn&&_e.convert(we)!==N.getParameter(N.IMPLEMENTATION_COLOR_READ_TYPE)&&!(we===Wt&&(Be.isWebGL2||xe.has("OES_texture_float")||xe.has("WEBGL_color_buffer_float")))&&!Ce){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}I>=0&&I<=y.width-B&&F>=0&&F<=y.height-U&&N.readPixels(I,F,B,U,_e.convert(Fe),_e.convert(we),le)}finally{const Ee=b!==null?Oe.get(b).__webglFramebuffer:null;ye.bindFramebuffer(N.FRAMEBUFFER,Ee)}}},this.copyFramebufferToTexture=function(y,I,F=0){const B=Math.pow(2,-F),U=Math.floor(I.image.width*B),le=Math.floor(I.image.height*B);ze.setTexture2D(I,0),N.copyTexSubImage2D(N.TEXTURE_2D,F,0,0,y.x,y.y,U,le),ye.unbindTexture()},this.copyTextureToTexture=function(y,I,F,B=0){const U=I.image.width,le=I.image.height,me=_e.convert(F.format),Me=_e.convert(F.type);ze.setTexture2D(F,0),N.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,F.flipY),N.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),N.pixelStorei(N.UNPACK_ALIGNMENT,F.unpackAlignment),I.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,B,y.x,y.y,U,le,me,Me,I.image.data):I.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,B,y.x,y.y,I.mipmaps[0].width,I.mipmaps[0].height,me,I.mipmaps[0].data):N.texSubImage2D(N.TEXTURE_2D,B,y.x,y.y,me,Me,I.image),B===0&&F.generateMipmaps&&N.generateMipmap(N.TEXTURE_2D),ye.unbindTexture()},this.copyTextureToTexture3D=function(y,I,F,B,U=0){if(v.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const le=Math.round(y.max.x-y.min.x),me=Math.round(y.max.y-y.min.y),Me=y.max.z-y.min.z+1,Ee=_e.convert(B.format),Fe=_e.convert(B.type);let we;if(B.isData3DTexture)ze.setTexture3D(B,0),we=N.TEXTURE_3D;else if(B.isDataArrayTexture||B.isCompressedArrayTexture)ze.setTexture2DArray(B,0),we=N.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}N.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,B.flipY),N.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),N.pixelStorei(N.UNPACK_ALIGNMENT,B.unpackAlignment);const Ce=N.getParameter(N.UNPACK_ROW_LENGTH),rt=N.getParameter(N.UNPACK_IMAGE_HEIGHT),Lt=N.getParameter(N.UNPACK_SKIP_PIXELS),dt=N.getParameter(N.UNPACK_SKIP_ROWS),sn=N.getParameter(N.UNPACK_SKIP_IMAGES),it=F.isCompressedTexture?F.mipmaps[U]:F.image;N.pixelStorei(N.UNPACK_ROW_LENGTH,it.width),N.pixelStorei(N.UNPACK_IMAGE_HEIGHT,it.height),N.pixelStorei(N.UNPACK_SKIP_PIXELS,y.min.x),N.pixelStorei(N.UNPACK_SKIP_ROWS,y.min.y),N.pixelStorei(N.UNPACK_SKIP_IMAGES,y.min.z),F.isDataTexture||F.isData3DTexture?N.texSubImage3D(we,U,I.x,I.y,I.z,le,me,Me,Ee,Fe,it.data):B.isCompressedArrayTexture?N.compressedTexSubImage3D(we,U,I.x,I.y,I.z,le,me,Me,Ee,it.data):N.texSubImage3D(we,U,I.x,I.y,I.z,le,me,Me,Ee,Fe,it),N.pixelStorei(N.UNPACK_ROW_LENGTH,Ce),N.pixelStorei(N.UNPACK_IMAGE_HEIGHT,rt),N.pixelStorei(N.UNPACK_SKIP_PIXELS,Lt),N.pixelStorei(N.UNPACK_SKIP_ROWS,dt),N.pixelStorei(N.UNPACK_SKIP_IMAGES,sn),U===0&&B.generateMipmaps&&N.generateMipmap(we),ye.unbindTexture()},this.initTexture=function(y){y.isCubeTexture?ze.setTextureCube(y,0):y.isData3DTexture?ze.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?ze.setTexture2DArray(y,0):ze.setTexture2D(y,0),ye.unbindTexture()},this.resetState=function(){C=0,A=0,b=null,ye.reset(),fe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return fn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===xa?"display-p3":"srgb",t.unpackColorSpace=qe.workingColorSpace===tr?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class yg extends Mg{}yg.prototype.isWebGL1Renderer=!0;class _l{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new ve(e),this.near=t,this.far=n}clone(){return new _l(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class nv extends et{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Kt,this.environmentRotation=new Kt,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class vl{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=sa,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Yt()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return el("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Yt()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Yt()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const At=new R;class rs{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)At.fromBufferAttribute(this,t),At.applyMatrix4(e),this.setXYZ(t,At.x,At.y,At.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)At.fromBufferAttribute(this,t),At.applyNormalMatrix(e),this.setXYZ(t,At.x,At.y,At.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)At.fromBufferAttribute(this,t),At.transformDirection(e),this.setXYZ(t,At.x,At.y,At.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Xt(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=je(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=je(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=je(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=je(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=je(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Xt(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Xt(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Xt(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Xt(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=je(t,this.array),n=je(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=je(t,this.array),n=je(n,this.array),i=je(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=je(t,this.array),n=je(n,this.array),i=je(i,this.array),s=je(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new vt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new rs(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Sg extends Dt{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ve(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let fi;const Wi=new R,pi=new R,mi=new R,gi=new re,Xi=new re,xl=new be,Ns=new R,qi=new R,Ds=new R,hc=new re,Hr=new re,uc=new re;class iv extends et{constructor(e=new Sg){if(super(),this.isSprite=!0,this.type="Sprite",fi===void 0){fi=new mt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new vl(t,5);fi.setIndex([0,1,2,0,2,3]),fi.setAttribute("position",new rs(n,3,0,!1)),fi.setAttribute("uv",new rs(n,2,3,!1))}this.geometry=fi,this.material=e,this.center=new re(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),pi.setFromMatrixScale(this.matrixWorld),xl.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),mi.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&pi.multiplyScalar(-mi.z);const n=this.material.rotation;let i,s;n!==0&&(s=Math.cos(n),i=Math.sin(n));const a=this.center;Us(Ns.set(-.5,-.5,0),mi,a,pi,i,s),Us(qi.set(.5,-.5,0),mi,a,pi,i,s),Us(Ds.set(.5,.5,0),mi,a,pi,i,s),hc.set(0,0),Hr.set(1,0),uc.set(1,1);let o=e.ray.intersectTriangle(Ns,qi,Ds,!1,Wi);if(o===null&&(Us(qi.set(-.5,.5,0),mi,a,pi,i,s),Hr.set(0,1),o=e.ray.intersectTriangle(Ns,Ds,qi,!1,Wi),o===null))return;const c=e.ray.origin.distanceTo(Wi);c<e.near||c>e.far||t.push({distance:c,point:Wi.clone(),uv:qt.getInterpolation(Wi,Ns,qi,Ds,hc,Hr,uc,new re),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Us(r,e,t,n,i,s){gi.subVectors(r,t).addScalar(.5).multiply(n),i!==void 0?(Xi.x=s*gi.x-i*gi.y,Xi.y=i*gi.x+s*gi.y):Xi.copy(gi),r.copy(e),r.x+=Xi.x,r.y+=Xi.y,r.applyMatrix4(xl)}const dc=new R,fc=new Ke,pc=new Ke,Eg=new R,mc=new be,Os=new R,Gr=new en,gc=new be,kr=new as;class Tg extends Nt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ja,this.bindMatrix=new be,this.bindMatrixInverse=new be,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Qt),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Os),this.boundingBox.expandByPoint(Os)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new en),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Os),this.boundingSphere.expandByPoint(Os)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Gr.copy(this.boundingSphere),Gr.applyMatrix4(i),e.ray.intersectsSphere(Gr)!==!1&&(gc.copy(i).invert(),kr.copy(e.ray).applyMatrix4(gc),!(this.boundingBox!==null&&kr.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,kr)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Ke,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===ja?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Th?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;fc.fromBufferAttribute(i.attributes.skinIndex,e),pc.fromBufferAttribute(i.attributes.skinWeight,e),dc.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=pc.getComponent(s);if(a!==0){const o=fc.getComponent(s);mc.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(Eg.copy(dc).applyMatrix4(mc),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Ml extends et{constructor(){super(),this.isBone=!0,this.type="Bone"}}class yl extends lt{constructor(e=null,t=1,n=1,i,s,a,o,c,l=pt,h=pt,u,d){super(null,a,o,c,l,h,i,s,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const _c=new be,Ag=new be;class Aa{constructor(e=[],t=[]){this.uuid=Yt(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new be)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new be;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:Ag;_c.multiplyMatrices(o,t[s]),_c.toArray(n,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Aa(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new yl(t,e,e,Ht,Wt);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const s=e.bones[n];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new Ml),this.bones.push(a),this.boneInverses.push(new be().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,s=t.length;i<s;i++){const a=t[i];e.bones.push(a.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class ca extends vt{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const _i=new be,vc=new be,Fs=[],xc=new Qt,bg=new be,Yi=new Nt,ji=new en;class wg extends Nt{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new ca(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,bg)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Qt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,_i),xc.copy(e.boundingBox).applyMatrix4(_i),this.boundingBox.union(xc)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new en),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,_i),ji.copy(e.boundingSphere).applyMatrix4(_i),this.boundingSphere.union(ji)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,s=n.length+1,a=e*s+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(Yi.geometry=this.geometry,Yi.material=this.material,Yi.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ji.copy(this.boundingSphere),ji.applyMatrix4(n),e.ray.intersectsSphere(ji)!==!1))for(let s=0;s<i;s++){this.getMatrixAt(s,_i),vc.multiplyMatrices(n,_i),Yi.matrixWorld=vc,Yi.raycast(e,Fs);for(let a=0,o=Fs.length;a<o;a++){const c=Fs[a];c.instanceId=s,c.object=this,t.push(c)}Fs.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new ca(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new yl(new Float32Array(i*this.count),i,this.count,qc,Wt));const s=this.morphTexture.source.data.data;let a=0;for(let l=0;l<n.length;l++)a+=n[l];const o=this.geometry.morphTargetsRelative?1:1-a,c=i*e;s[c]=o,s.set(n,c+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class sr extends Dt{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ve(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Mc=new R,yc=new R,Sc=new be,Vr=new as,Bs=new en;class ba extends et{constructor(e=new mt,t=new sr){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,s=t.count;i<s;i++)Mc.fromBufferAttribute(t,i-1),yc.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Mc.distanceTo(yc);e.setAttribute("lineDistance",new Ze(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Bs.copy(n.boundingSphere),Bs.applyMatrix4(i),Bs.radius+=s,e.ray.intersectsSphere(Bs)===!1)return;Sc.copy(i).invert(),Vr.copy(e.ray).applyMatrix4(Sc);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=new R,h=new R,u=new R,d=new R,f=this.isLineSegments?2:1,g=n.index,m=n.attributes.position;if(g!==null){const p=Math.max(0,a.start),S=Math.min(g.count,a.start+a.count);for(let v=p,E=S-1;v<E;v+=f){const C=g.getX(v),A=g.getX(v+1);if(l.fromBufferAttribute(m,C),h.fromBufferAttribute(m,A),Vr.distanceSqToSegment(l,h,d,u)>c)continue;d.applyMatrix4(this.matrixWorld);const D=e.ray.origin.distanceTo(d);D<e.near||D>e.far||t.push({distance:D,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{const p=Math.max(0,a.start),S=Math.min(m.count,a.start+a.count);for(let v=p,E=S-1;v<E;v+=f){if(l.fromBufferAttribute(m,v),h.fromBufferAttribute(m,v+1),Vr.distanceSqToSegment(l,h,d,u)>c)continue;d.applyMatrix4(this.matrixWorld);const A=e.ray.origin.distanceTo(d);A<e.near||A>e.far||t.push({distance:A,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}const Ec=new R,Tc=new R;class wa extends ba{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,s=t.count;i<s;i+=2)Ec.fromBufferAttribute(t,i),Tc.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Ec.distanceTo(Tc);e.setAttribute("lineDistance",new Ze(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Rg extends ba{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Sl extends Dt{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ve(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Ac=new be,la=new as,zs=new en,Hs=new R;class Cg extends et{constructor(e=new mt,t=new Sl){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),zs.copy(n.boundingSphere),zs.applyMatrix4(i),zs.radius+=s,e.ray.intersectsSphere(zs)===!1)return;Ac.copy(i).invert(),la.copy(e.ray).applyMatrix4(Ac);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,u=n.attributes.position;if(l!==null){const d=Math.max(0,a.start),f=Math.min(l.count,a.start+a.count);for(let g=d,_=f;g<_;g++){const m=l.getX(g);Hs.fromBufferAttribute(u,m),bc(Hs,m,c,i,e,t,this)}}else{const d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let g=d,_=f;g<_;g++)Hs.fromBufferAttribute(u,g),bc(Hs,g,c,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function bc(r,e,t,n,i,s,a){const o=la.distanceSqToPoint(r);if(o<t){const c=new R;la.closestPointToPoint(r,c),c.applyMatrix4(n);const l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,object:a})}}class sv extends lt{constructor(e,t,n,i,s,a,o,c,l){super(e,t,n,i,s,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class tn{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let o=0,c=s-1,l;for(;o<=c;)if(i=Math.floor(o+(c-o)/2),l=n[i]-a,l<0)o=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===a)return i/(s-1);const h=n[i],d=n[i+1]-h,f=(a-h)/d;return(i+f)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const a=this.getPoint(i),o=this.getPoint(s),c=t||(a.isVector2?new re:new R);return c.copy(o).sub(a).normalize(),c}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new R,i=[],s=[],a=[],o=new R,c=new be;for(let f=0;f<=e;f++){const g=f/e;i[f]=this.getTangentAt(g,new R)}s[0]=new R,a[0]=new R;let l=Number.MAX_VALUE;const h=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);h<=l&&(l=h,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),d<=l&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],o),a[0].crossVectors(i[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(i[f-1],i[f]),o.length()>Number.EPSILON){o.normalize();const g=Math.acos(ct(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(c.makeRotationAxis(o,g))}a[f].crossVectors(i[f],s[f])}if(t===!0){let f=Math.acos(ct(s[0].dot(s[e]),-1,1));f/=e,i[0].dot(o.crossVectors(s[0],s[e]))>0&&(f=-f);for(let g=1;g<=e;g++)s[g].applyMatrix4(c.makeRotationAxis(i[g],f*g)),a[g].crossVectors(i[g],s[g])}return{tangents:i,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Ra extends tn{constructor(e=0,t=0,n=1,i=1,s=0,a=Math.PI*2,o=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=c}getPoint(e,t=new re){const n=t,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(a?s=0:s=i),this.aClockwise===!0&&!a&&(s===i?s=-i:s=s-i);const o=this.aStartAngle+e*s;let c=this.aX+this.xRadius*Math.cos(o),l=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=c-this.aX,f=l-this.aY;c=d*h-f*u+this.aX,l=d*u+f*h+this.aY}return n.set(c,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class Lg extends Ra{constructor(e,t,n,i,s,a){super(e,t,n,n,i,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function Ca(){let r=0,e=0,t=0,n=0;function i(s,a,o,c){r=s,e=o,t=-3*s+3*a-2*o-c,n=2*s-2*a+o+c}return{initCatmullRom:function(s,a,o,c,l){i(a,o,l*(o-s),l*(c-a))},initNonuniformCatmullRom:function(s,a,o,c,l,h,u){let d=(a-s)/l-(o-s)/(l+h)+(o-a)/h,f=(o-a)/h-(c-a)/(h+u)+(c-o)/u;d*=h,f*=h,i(a,o,d,f)},calc:function(s){const a=s*s,o=a*s;return r+e*s+t*a+n*o}}}const Gs=new R,Wr=new Ca,Xr=new Ca,qr=new Ca;class Pg extends tn{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new R){const n=t,i=this.points,s=i.length,a=(s-(this.closed?0:1))*e;let o=Math.floor(a),c=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:c===0&&o===s-1&&(o=s-2,c=1);let l,h;this.closed||o>0?l=i[(o-1)%s]:(Gs.subVectors(i[0],i[1]).add(i[0]),l=Gs);const u=i[o%s],d=i[(o+1)%s];if(this.closed||o+2<s?h=i[(o+2)%s]:(Gs.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=Gs),this.curveType==="centripetal"||this.curveType==="chordal"){const f=this.curveType==="chordal"?.5:.25;let g=Math.pow(l.distanceToSquared(u),f),_=Math.pow(u.distanceToSquared(d),f),m=Math.pow(d.distanceToSquared(h),f);_<1e-4&&(_=1),g<1e-4&&(g=_),m<1e-4&&(m=_),Wr.initNonuniformCatmullRom(l.x,u.x,d.x,h.x,g,_,m),Xr.initNonuniformCatmullRom(l.y,u.y,d.y,h.y,g,_,m),qr.initNonuniformCatmullRom(l.z,u.z,d.z,h.z,g,_,m)}else this.curveType==="catmullrom"&&(Wr.initCatmullRom(l.x,u.x,d.x,h.x,this.tension),Xr.initCatmullRom(l.y,u.y,d.y,h.y,this.tension),qr.initCatmullRom(l.z,u.z,d.z,h.z,this.tension));return n.set(Wr.calc(c),Xr.calc(c),qr.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new R().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function wc(r,e,t,n,i){const s=(n-e)*.5,a=(i-t)*.5,o=r*r,c=r*o;return(2*t-2*n+s+a)*c+(-3*t+3*n-2*s-a)*o+s*r+t}function Ig(r,e){const t=1-r;return t*t*e}function Ng(r,e){return 2*(1-r)*r*e}function Dg(r,e){return r*r*e}function Qi(r,e,t,n){return Ig(r,e)+Ng(r,t)+Dg(r,n)}function Ug(r,e){const t=1-r;return t*t*t*e}function Og(r,e){const t=1-r;return 3*t*t*r*e}function Fg(r,e){return 3*(1-r)*r*r*e}function Bg(r,e){return r*r*r*e}function es(r,e,t,n,i){return Ug(r,e)+Og(r,t)+Fg(r,n)+Bg(r,i)}class El extends tn{constructor(e=new re,t=new re,n=new re,i=new re){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new re){const n=t,i=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(es(e,i.x,s.x,a.x,o.x),es(e,i.y,s.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class zg extends tn{constructor(e=new R,t=new R,n=new R,i=new R){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new R){const n=t,i=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(es(e,i.x,s.x,a.x,o.x),es(e,i.y,s.y,a.y,o.y),es(e,i.z,s.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Tl extends tn{constructor(e=new re,t=new re){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new re){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new re){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Hg extends tn{constructor(e=new R,t=new R){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new R){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new R){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Al extends tn{constructor(e=new re,t=new re,n=new re){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new re){const n=t,i=this.v0,s=this.v1,a=this.v2;return n.set(Qi(e,i.x,s.x,a.x),Qi(e,i.y,s.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Gg extends tn{constructor(e=new R,t=new R,n=new R){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new R){const n=t,i=this.v0,s=this.v1,a=this.v2;return n.set(Qi(e,i.x,s.x,a.x),Qi(e,i.y,s.y,a.y),Qi(e,i.z,s.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class bl extends tn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new re){const n=t,i=this.points,s=(i.length-1)*e,a=Math.floor(s),o=s-a,c=i[a===0?a:a-1],l=i[a],h=i[a>i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return n.set(wc(o,c.x,l.x,h.x,u.x),wc(o,c.y,l.y,h.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new re().fromArray(i))}return this}}var Rc=Object.freeze({__proto__:null,ArcCurve:Lg,CatmullRomCurve3:Pg,CubicBezierCurve:El,CubicBezierCurve3:zg,EllipseCurve:Ra,LineCurve:Tl,LineCurve3:Hg,QuadraticBezierCurve:Al,QuadraticBezierCurve3:Gg,SplineCurve:bl});class kg extends tn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Rc[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=n){const a=i[s]-n,o=this.curves[s],c=o.getLength(),l=c===0?0:1-a/c;return o.getPointAt(l,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.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 e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,s=this.curves;i<s.length;i++){const a=s[i],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,c=a.getPoints(o);for(let l=0;l<c.length;l++){const h=c[l];n&&n.equals(h)||(t.push(h),n=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(new Rc[i.type]().fromJSON(i))}return this}}class Vg extends kg{constructor(e){super(),this.type="Path",this.currentPoint=new re,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new Tl(this.currentPoint.clone(),new re(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const s=new Al(this.currentPoint.clone(),new re(e,t),new re(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,a){const o=new El(this.currentPoint.clone(),new re(e,t),new re(n,i),new re(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new bl(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,a){const o=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+o,t+c,n,i,s,a),this}absarc(e,t,n,i,s,a){return this.absellipse(e,t,n,n,i,s,a),this}ellipse(e,t,n,i,s,a,o,c){const l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,n,i,s,a,o,c),this}absellipse(e,t,n,i,s,a,o,c){const l=new Ra(e,t,n,i,s,a,o,c);if(this.curves.length>0){const u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);const h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class La extends mt{constructor(e=[new re(0,-.5),new re(.5,0),new re(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=ct(i,0,Math.PI*2);const s=[],a=[],o=[],c=[],l=[],h=1/t,u=new R,d=new re,f=new R,g=new R,_=new R;let m=0,p=0;for(let S=0;S<=e.length-1;S++)switch(S){case 0:m=e[S+1].x-e[S].x,p=e[S+1].y-e[S].y,f.x=p*1,f.y=-m,f.z=p*0,_.copy(f),f.normalize(),c.push(f.x,f.y,f.z);break;case e.length-1:c.push(_.x,_.y,_.z);break;default:m=e[S+1].x-e[S].x,p=e[S+1].y-e[S].y,f.x=p*1,f.y=-m,f.z=p*0,g.copy(f),f.x+=_.x,f.y+=_.y,f.z+=_.z,f.normalize(),c.push(f.x,f.y,f.z),_.copy(g)}for(let S=0;S<=t;S++){const v=n+S*h*i,E=Math.sin(v),C=Math.cos(v);for(let A=0;A<=e.length-1;A++){u.x=e[A].x*E,u.y=e[A].y,u.z=e[A].x*C,a.push(u.x,u.y,u.z),d.x=S/t,d.y=A/(e.length-1),o.push(d.x,d.y);const b=c[3*A+0]*E,D=c[3*A+1],k=c[3*A+0]*C;l.push(b,D,k)}}for(let S=0;S<t;S++)for(let v=0;v<e.length-1;v++){const E=v+S*e.length,C=E,A=E+e.length,b=E+e.length+1,D=E+1;s.push(C,A,D),s.push(b,D,A)}this.setIndex(s),this.setAttribute("position",new Ze(a,3)),this.setAttribute("uv",new Ze(o,2)),this.setAttribute("normal",new Ze(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new La(e.points,e.segments,e.phiStart,e.phiLength)}}class wl extends La{constructor(e=1,t=1,n=4,i=8){const s=new Vg;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:n,radialSegments:i}}static fromJSON(e){return new wl(e.radius,e.length,e.capSegments,e.radialSegments)}}class Pa extends mt{constructor(e=1,t=1,n=1,i=32,s=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:c};const l=this;i=Math.floor(i),s=Math.floor(s);const h=[],u=[],d=[],f=[];let g=0;const _=[],m=n/2;let p=0;S(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(h),this.setAttribute("position",new Ze(u,3)),this.setAttribute("normal",new Ze(d,3)),this.setAttribute("uv",new Ze(f,2));function S(){const E=new R,C=new R;let A=0;const b=(t-e)/n;for(let D=0;D<=s;D++){const k=[],M=D/s,w=M*(t-e)+e;for(let j=0;j<=i;j++){const K=j/i,L=K*c+o,V=Math.sin(L),G=Math.cos(L);C.x=w*V,C.y=-M*n+m,C.z=w*G,u.push(C.x,C.y,C.z),E.set(V,b,G).normalize(),d.push(E.x,E.y,E.z),f.push(K,1-M),k.push(g++)}_.push(k)}for(let D=0;D<i;D++)for(let k=0;k<s;k++){const M=_[k][D],w=_[k+1][D],j=_[k+1][D+1],K=_[k][D+1];h.push(M,w,K),h.push(w,j,K),A+=6}l.addGroup(p,A,0),p+=A}function v(E){const C=g,A=new re,b=new R;let D=0;const k=E===!0?e:t,M=E===!0?1:-1;for(let j=1;j<=i;j++)u.push(0,m*M,0),d.push(0,M,0),f.push(.5,.5),g++;const w=g;for(let j=0;j<=i;j++){const L=j/i*c+o,V=Math.cos(L),G=Math.sin(L);b.x=k*G,b.y=m*M,b.z=k*V,u.push(b.x,b.y,b.z),d.push(0,M,0),A.x=V*.5+.5,A.y=G*.5*M+.5,f.push(A.x,A.y),g++}for(let j=0;j<i;j++){const K=C+j,L=w+j;E===!0?h.push(L,L+1,K):h.push(L+1,L,K),D+=3}l.addGroup(p,D,E===!0?1:2),p+=D}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Pa(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Rl extends Pa{constructor(e=1,t=1,n=32,i=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,n,i,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Rl(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Cl extends mt{constructor(e=.5,t=1,n=32,i=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:s,thetaLength:a},n=Math.max(3,n),i=Math.max(1,i);const o=[],c=[],l=[],h=[];let u=e;const d=(t-e)/i,f=new R,g=new re;for(let _=0;_<=i;_++){for(let m=0;m<=n;m++){const p=s+m/n*a;f.x=u*Math.cos(p),f.y=u*Math.sin(p),c.push(f.x,f.y,f.z),l.push(0,0,1),g.x=(f.x/t+1)/2,g.y=(f.y/t+1)/2,h.push(g.x,g.y)}u+=d}for(let _=0;_<i;_++){const m=_*(n+1);for(let p=0;p<n;p++){const S=p+m,v=S,E=S+n+1,C=S+n+2,A=S+1;o.push(v,E,A),o.push(E,C,A)}}this.setIndex(o),this.setAttribute("position",new Ze(c,3)),this.setAttribute("normal",new Ze(l,3)),this.setAttribute("uv",new Ze(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Cl(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Ll extends mt{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const c=Math.min(a+o,Math.PI);let l=0;const h=[],u=new R,d=new R,f=[],g=[],_=[],m=[];for(let p=0;p<=n;p++){const S=[],v=p/n;let E=0;p===0&&a===0?E=.5/t:p===n&&c===Math.PI&&(E=-.5/t);for(let C=0;C<=t;C++){const A=C/t;u.x=-e*Math.cos(i+A*s)*Math.sin(a+v*o),u.y=e*Math.cos(a+v*o),u.z=e*Math.sin(i+A*s)*Math.sin(a+v*o),g.push(u.x,u.y,u.z),d.copy(u).normalize(),_.push(d.x,d.y,d.z),m.push(A+E,1-v),S.push(l++)}h.push(S)}for(let p=0;p<n;p++)for(let S=0;S<t;S++){const v=h[p][S+1],E=h[p][S],C=h[p+1][S],A=h[p+1][S+1];(p!==0||a>0)&&f.push(v,E,A),(p!==n-1||c<Math.PI)&&f.push(E,C,A)}this.setIndex(f),this.setAttribute("position",new Ze(g,3)),this.setAttribute("normal",new Ze(_,3)),this.setAttribute("uv",new Ze(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ll(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Pl extends mt{constructor(e=1,t=.4,n=12,i=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:s},n=Math.floor(n),i=Math.floor(i);const a=[],o=[],c=[],l=[],h=new R,u=new R,d=new R;for(let f=0;f<=n;f++)for(let g=0;g<=i;g++){const _=g/i*s,m=f/n*Math.PI*2;u.x=(e+t*Math.cos(m))*Math.cos(_),u.y=(e+t*Math.cos(m))*Math.sin(_),u.z=t*Math.sin(m),o.push(u.x,u.y,u.z),h.x=e*Math.cos(_),h.y=e*Math.sin(_),d.subVectors(u,h).normalize(),c.push(d.x,d.y,d.z),l.push(g/i),l.push(f/n)}for(let f=1;f<=n;f++)for(let g=1;g<=i;g++){const _=(i+1)*f+g-1,m=(i+1)*(f-1)+g-1,p=(i+1)*(f-1)+g,S=(i+1)*f+g;a.push(_,m,S),a.push(m,p,S)}this.setIndex(a),this.setAttribute("position",new Ze(o,3)),this.setAttribute("normal",new Ze(c,3)),this.setAttribute("uv",new Ze(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Pl(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class rv extends Dt{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new ve(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class Ia extends Dt{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new ve(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 ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new re(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Kt,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class mn extends Ia{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new re(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ct(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ve(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new ve(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ve(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class av extends Dt{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ve(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new re(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Kt,this.combine=ma,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}function ks(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function Wg(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Xg(r){function e(i,s){return r[i]-r[s]}const t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function Cc(r,e,t){const n=r.length,i=new r.constructor(n);for(let s=0,a=0;a!==n;++s){const o=t[s]*e;for(let c=0;c!==e;++c)i[a++]=r[o+c]}return i}function Il(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=r[i++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do a=s[n],a!==void 0&&(e.push(s.time),t.push(a)),s=r[i++];while(s!==void 0)}class cs{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],s=t[n-1];e:{t:{let a;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(s=i,i=t[++n],e<i)break t}a=t.length;break n}if(!(e>=s)){const o=t[1];e<o&&(n=2,s=o);for(let c=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(i=s,s=t[--n-1],e>=s)break t}a=n,n=0;break n}break e}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let a=0;a!==i;++a)t[a]=n[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class qg extends cs{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:xi,endingEnd:xi}}intervalChanged_(e,t,n){const i=this.parameterPositions;let s=e-2,a=e+1,o=i[s],c=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case Mi:s=e,o=2*t-n;break;case js:s=i.length-2,o=t+i[s]-i[s+1];break;default:s=e,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case Mi:a=e,c=2*n-t;break;case js:a=1,c=n+i[1]-i[0];break;default:a=e-1,c=t}const l=(n-t)*.5,h=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(c-n),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,g=(n-t)/(i-t),_=g*g,m=_*g,p=-d*m+2*d*_-d*g,S=(1+d)*m+(-1.5-2*d)*_+(-.5+d)*g+1,v=(-1-f)*m+(1.5+f)*_+.5*g,E=f*m-f*_;for(let C=0;C!==o;++C)s[C]=p*a[h+C]+S*a[l+C]+v*a[c+C]+E*a[u+C];return s}}class Nl extends cs{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=(n-t)/(i-t),u=1-h;for(let d=0;d!==o;++d)s[d]=a[l+d]*u+a[c+d]*h;return s}}class Yg extends cs{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class nn{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=ks(t,this.TimeBufferType),this.values=ks(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:ks(e.times,Array),values:ks(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Yg(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Nl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new qg(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case is:t=this.InterpolantFactoryMethodDiscrete;break;case Li:t=this.InterpolantFactoryMethodLinear;break;case pr:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return is;case this.InterpolantFactoryMethodLinear:return Li;case this.InterpolantFactoryMethodSmooth:return pr}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let s=0,a=i-1;for(;s!==i&&n[s]<e;)++s;for(;a!==-1&&n[a]>t;)--a;if(++a,s!==0||a!==i){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const c=n[o];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(a!==null&&a>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,c,a),e=!1;break}a=c}if(i!==void 0&&Wg(i))for(let o=0,c=i.length;o!==c;++o){const l=i[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===pr,s=e.length-1;let a=1;for(let o=1;o<s;++o){let c=!1;const l=e[o],h=e[o+1];if(l!==h&&(o!==1||l!==e[0]))if(i)c=!0;else{const u=o*n,d=u-n,f=u+n;for(let g=0;g!==n;++g){const _=t[u+g];if(_!==t[d+g]||_!==t[f+g]){c=!0;break}}}if(c){if(o!==a){e[a]=e[o];const u=o*n,d=a*n;for(let f=0;f!==n;++f)t[d+f]=t[u+f]}++a}}if(s>0){e[a]=e[s];for(let o=s*n,c=a*n,l=0;l!==n;++l)t[c+l]=t[o+l];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}nn.prototype.TimeBufferType=Float32Array;nn.prototype.ValueBufferType=Float32Array;nn.prototype.DefaultInterpolation=Li;class Oi extends nn{}Oi.prototype.ValueTypeName="bool";Oi.prototype.ValueBufferType=Array;Oi.prototype.DefaultInterpolation=is;Oi.prototype.InterpolantFactoryMethodLinear=void 0;Oi.prototype.InterpolantFactoryMethodSmooth=void 0;class Dl extends nn{}Dl.prototype.ValueTypeName="color";class Ni extends nn{}Ni.prototype.ValueTypeName="number";class jg extends cs{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-t)/(i-t);let l=e*o;for(let h=l+o;l!==h;l+=4)jt.slerpFlat(s,0,a,l-o,a,l,c);return s}}class Kn extends nn{InterpolantFactoryMethodLinear(e){return new jg(this.times,this.values,this.getValueSize(),e)}}Kn.prototype.ValueTypeName="quaternion";Kn.prototype.DefaultInterpolation=Li;Kn.prototype.InterpolantFactoryMethodSmooth=void 0;class Fi extends nn{}Fi.prototype.ValueTypeName="string";Fi.prototype.ValueBufferType=Array;Fi.prototype.DefaultInterpolation=is;Fi.prototype.InterpolantFactoryMethodLinear=void 0;Fi.prototype.InterpolantFactoryMethodSmooth=void 0;class Di extends nn{}Di.prototype.ValueTypeName="vector";class ha{constructor(e,t=-1,n,i=_a){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Yt(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(Jg(n[a]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=n.length;s!==a;++s)t.push(nn.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,a=[];for(let o=0;o<s;o++){let c=[],l=[];c.push((o+s-1)%s,o,(o+1)%s),l.push(0,1,0);const h=Xg(c);c=Cc(c,1,h),l=Cc(l,1,h),!i&&c[0]===0&&(c.push(s),l.push(l[0])),a.push(new Ni(".morphTargetInfluences["+t[o].name+"]",c,l).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,c=e.length;o<c;o++){const l=e[o],h=l.name.match(s);if(h&&h.length>1){const u=h[1];let d=i[u];d||(i[u]=d=[]),d.push(l)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(u,d,f,g,_){if(f.length!==0){const m=[],p=[];Il(f,m,p,g),m.length!==0&&_.push(new u(d,m,p))}},i=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let c=e.length||-1;const l=e.hierarchy||[];for(let u=0;u<l.length;u++){const d=l[u].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const f={};let g;for(g=0;g<d.length;g++)if(d[g].morphTargets)for(let _=0;_<d[g].morphTargets.length;_++)f[d[g].morphTargets[_]]=-1;for(const _ in f){const m=[],p=[];for(let S=0;S!==d[g].morphTargets.length;++S){const v=d[g];m.push(v.time),p.push(v.morphTarget===_?1:0)}i.push(new Ni(".morphTargetInfluence["+_+"]",m,p))}c=f.length*a}else{const f=".bones["+t[u].name+"]";n(Di,f+".position",d,"pos",i),n(Kn,f+".quaternion",d,"rot",i),n(Di,f+".scale",d,"scl",i)}}return i.length===0?null:new this(s,c,i,o)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function Kg(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ni;case"vector":case"vector2":case"vector3":case"vector4":return Di;case"color":return Dl;case"quaternion":return Kn;case"bool":case"boolean":return Oi;case"string":return Fi}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function Jg(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=Kg(r.type);if(r.times===void 0){const t=[],n=[];Il(r.keys,t,n,"value"),r.times=t,r.values=n}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}const bn={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};class $g{constructor(e,t,n){const i=this;let s=!1,a=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){o++,s===!1&&i.onStart!==void 0&&i.onStart(h,a,o),s=!0},this.itemEnd=function(h){a++,i.onProgress!==void 0&&i.onProgress(h,a,o),a===o&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){const f=l[u],g=l[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return g}return null}}}const Zg=new $g;class Bi{constructor(e){this.manager=e!==void 0?e:Zg,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,s){n.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Bi.DEFAULT_MATERIAL_NAME="__DEFAULT";const hn={};class Qg extends Error{constructor(e,t){super(e),this.response=t}}class Ul extends Bi{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=bn.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(hn[e]!==void 0){hn[e].push({onLoad:t,onProgress:n,onError:i});return}hn[e]=[],hn[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=hn[e],u=l.body.getReader(),d=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),f=d?parseInt(d):0,g=f!==0;let _=0;const m=new ReadableStream({start(p){S();function S(){u.read().then(({done:v,value:E})=>{if(v)p.close();else{_+=E.byteLength;const C=new ProgressEvent("progress",{lengthComputable:g,loaded:_,total:f});for(let A=0,b=h.length;A<b;A++){const D=h[A];D.onProgress&&D.onProgress(C)}p.enqueue(E),S()}})}}});return new Response(m)}else throw new Qg(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return l.json();default:if(o===void 0)return l.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return l.arrayBuffer().then(g=>f.decode(g))}}}).then(l=>{bn.add(e,l);const h=hn[e];delete hn[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=hn[e];if(h===void 0)throw this.manager.itemError(e),l;delete hn[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class e_ extends Bi{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=bn.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=ss("img");function c(){h(),bn.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(u){h(),i&&i(u),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class t_ extends Bi{constructor(e){super(e)}load(e,t,n,i){const s=new lt,a=new e_(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},n,i),s}}class ls extends et{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new ve(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}class ov extends ls{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(et.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ve(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Yr=new be,Lc=new R,Pc=new R;class Na{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new re(512,512),this.map=null,this.mapPass=null,this.matrix=new be,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Sa,this._frameExtents=new re(1,1),this._viewportCount=1,this._viewports=[new Ke(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Lc.setFromMatrixPosition(e.matrixWorld),t.position.copy(Lc),Pc.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Pc),t.updateMatrixWorld(),Yr.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Yr),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Yr)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class n_ extends Na{constructor(){super(new Rt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=Pi*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class i_ extends ls{constructor(e,t,n=0,i=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(et.DEFAULT_UP),this.updateMatrix(),this.target=new et,this.distance=n,this.angle=i,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new n_}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Ic=new be,Ki=new R,jr=new R;class s_ extends Na{constructor(){super(new Rt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new re(4,2),this._viewportCount=6,this._viewports=[new Ke(2,1,1,1),new Ke(0,1,1,1),new Ke(3,1,1,1),new Ke(1,1,1,1),new Ke(3,0,1,1),new Ke(1,0,1,1)],this._cubeDirections=[new R(1,0,0),new R(-1,0,0),new R(0,0,1),new R(0,0,-1),new R(0,1,0),new R(0,-1,0)],this._cubeUps=[new R(0,1,0),new R(0,1,0),new R(0,1,0),new R(0,1,0),new R(0,0,1),new R(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Ki.setFromMatrixPosition(e.matrixWorld),n.position.copy(Ki),jr.copy(n.position),jr.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(jr),n.updateMatrixWorld(),i.makeTranslation(-Ki.x,-Ki.y,-Ki.z),Ic.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ic)}}class r_ extends ls{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new s_}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class a_ extends Na{constructor(){super(new Ea(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class o_ extends ls{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(et.DEFAULT_UP),this.updateMatrix(),this.target=new et,this.shadow=new a_}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class cv extends ls{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class ts{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class c_ extends Bi{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=bn.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(l=>{t&&t(l),s.manager.itemEnd(e)}).catch(l=>{i&&i(l)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const c=fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){return bn.add(e,l),t&&t(l),s.manager.itemEnd(e),l}).catch(function(l){i&&i(l),bn.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});bn.add(e,c),s.manager.itemStart(e)}}class lv{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Nc(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=Nc();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Nc(){return(typeof performance>"u"?Date:performance).now()}class l_{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,s,a;switch(t){case"quaternion":i=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,i=this.valueSize,s=e*i+i;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==i;++o)n[s+o]=n[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(n,s,0,o,i)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,i=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const c=t*this._origIndex;this._mixBufferRegion(n,i,c,1-s,t)}a>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){o.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let s=n,a=i;s!==a;++s)t[s]=t[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,s){if(i>=.5)for(let a=0;a!==s;++a)e[t+a]=e[n+a]}_slerp(e,t,n,i){jt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,s){const a=this._workIndex*s;jt.multiplyQuaternionsFlat(e,a,e,t,e,n),jt.slerpFlat(e,t,e,t,e,a,i)}_lerp(e,t,n,i,s){const a=1-i;for(let o=0;o!==s;++o){const c=t+o;e[c]=e[c]*a+e[n+o]*i}}_lerpAdditive(e,t,n,i,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[n+a]*i}}}const Da="\\[\\]\\.:\\/",h_=new RegExp("["+Da+"]","g"),Ua="[^"+Da+"]",u_="[^"+Da.replace("\\.","")+"]",d_=/((?:WC+[\/:])*)/.source.replace("WC",Ua),f_=/(WCOD+)?/.source.replace("WCOD",u_),p_=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ua),m_=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ua),g_=new RegExp("^"+d_+f_+p_+m_+"$"),__=["material","materials","bones","map"];class v_{constructor(e,t,n){const i=n||Xe.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class Xe{constructor(e,t,n){this.path=t,this.parsedPath=n||Xe.parseTrackName(t),this.node=Xe.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Xe.Composite(e,t,n):new Xe(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(h_,"")}static parseTrackName(e){const t=g_.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);__.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===t||o.uuid===t)return o;const c=n(o.children);if(c)return c}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let s=t.propertyIndex;if(e||(e=Xe.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const a=e[i];if(a===void 0){const l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Xe.Composite=v_;Xe.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Xe.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Xe.prototype.GetterByBindingType=[Xe.prototype._getValue_direct,Xe.prototype._getValue_array,Xe.prototype._getValue_arrayElement,Xe.prototype._getValue_toArray];Xe.prototype.SetterByBindingTypeAndVersioning=[[Xe.prototype._setValue_direct,Xe.prototype._setValue_direct_setNeedsUpdate,Xe.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Xe.prototype._setValue_array,Xe.prototype._setValue_array_setNeedsUpdate,Xe.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Xe.prototype._setValue_arrayElement,Xe.prototype._setValue_arrayElement_setNeedsUpdate,Xe.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Xe.prototype._setValue_fromArray,Xe.prototype._setValue_fromArray_setNeedsUpdate,Xe.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class x_{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const s=t.tracks,a=s.length,o=new Array(a),c={endingStart:xi,endingEnd:xi};for(let l=0;l!==a;++l){const h=s[l].createInterpolant(null);o[l]=h,h.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Nh,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&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,s=e._clip.duration,a=s/i,o=i/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,s=i.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const c=o.parameterPositions,l=o.sampleValues;return c[0]=s,c[1]=s+n,l[0]=e/a,l[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const c=(e-s)*n;c<0||n===0?t=0:(this._startTime=null,t=n*c)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case Uh:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulateAdditive(o);break;case _a:default:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,s=this._loopCount;const a=n===Dh;if(e===0)return s===-1?i:a&&(s&1)===1?t-i:i;if(n===Ih){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),i>=t||i<0){const o=Math.floor(i/t);i-=t*o,s+=Math.abs(o);const c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){const l=e<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=i;if(a&&(s&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=Mi,i.endingEnd=Mi):(e?i.endingStart=this.zeroSlopeAtStart?Mi:xi:i.endingStart=js,t?i.endingEnd=this.zeroSlopeAtEnd?Mi:xi:i.endingEnd=js)}_scheduleFading(e,t,n){const i=this._mixer,s=i.time;let a=this._weightInterpolant;a===null&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,c=a.sampleValues;return o[0]=s,c[0]=t,o[1]=s+e,c[1]=n,this}}const M_=new Float32Array(1);class hv extends Jn{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,s=i.length,a=e._propertyBindings,o=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName;let h=l[c];h===void 0&&(h={},l[c]=h);for(let u=0;u!==s;++u){const d=i[u],f=d.name;let g=h[f];if(g!==void 0)++g.referenceCount,a[u]=g;else{if(g=a[u],g!==void 0){g._cacheIndex===null&&(++g.referenceCount,this._addInactiveBinding(g,c,f));continue}const _=t&&t._propertyBindings[u].binding.parsedPath;g=new l_(Xe.create(n,f,_),d.ValueTypeName,d.getValueSize()),++g.referenceCount,this._addInactiveBinding(g,c,f),a[u]=g}o[u].resultBuffer=g.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const i=this._actions,s=this._actionsByClip;let a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{const o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,a=this._actionsByClip,o=a[s],c=o.knownActions,l=c[c.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,c[h]=l,c.pop(),e._byClipCacheIndex=null;const u=o.actionByRoot,d=(e._localRoot||this._root).uuid;delete u[d],c.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_addInactiveBinding(e,t,n){const i=this._bindingsByRootAndName,s=this._bindings;let a=i[t];a===void 0&&(a={},i[t]=a),a[n]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,i=n.rootNode.uuid,s=n.path,a=this._bindingsByRootAndName,o=a[i],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete o[s],Object.keys(o).length===0&&delete a[i]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new Nl(new Float32Array(2),new Float32Array(2),1,M_),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,s=t[i];e.__cacheIndex=i,t[i]=e,s.__cacheIndex=n,t[n]=s}clipAction(e,t,n){const i=t||this._root,s=i.uuid;let a=typeof e=="string"?ha.findByName(i,e):e;const o=a!==null?a.uuid:e,c=this._actionsByClip[o];let l=null;if(n===void 0&&(a!==null?n=a.blendMode:n=_a),c!==void 0){const u=c.actionByRoot[s];if(u!==void 0&&u.blendMode===n)return u;l=c.knownActions[0],a===null&&(a=l._clip)}if(a===null)return null;const h=new x_(this,a,t,n);return this._bindAction(h,l),this._addInactiveAction(h,o,s),h}existingAction(e,t){const n=t||this._root,i=n.uuid,s=typeof e=="string"?ha.findByName(n,e):e,a=s?s.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[i]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,s,a);const o=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)o[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,i=this._actionsByClip,s=i[n];if(s!==void 0){const a=s.knownActions;for(let o=0,c=a.length;o!==c;++o){const l=a[o];this._deactivateAction(l);const h=l._cacheIndex,u=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(l)}delete i[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const a in n){const o=n[a].actionByRoot,c=o[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}const i=this._bindingsByRootAndName,s=i[t];if(s!==void 0)for(const a in s){const o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}const Dc=new be;class uv{constructor(e,t,n=0,i=1/0){this.ray=new as(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new ya,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Dc.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Dc),this}intersectObject(e,t=!0,n=[]){return ua(e,this,n,t),n.sort(Uc),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)ua(e[i],this,n,t);return n.sort(Uc),n}}function Uc(r,e){return r.distance-e.distance}function ua(r,e,t,n){if(r.layers.test(e.layers)&&r.raycast(e,t),n===!0){const i=r.children;for(let s=0,a=i.length;s<a;s++)ua(i[s],e,t,!0)}}class dv{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(ct(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class fv extends wa{constructor(e=10,t=10,n=4473924,i=8947848){n=new ve(n),i=new ve(i);const s=t/2,a=e/t,o=e/2,c=[],l=[];for(let d=0,f=0,g=-o;d<=t;d++,g+=a){c.push(-o,0,g,o,0,g),c.push(g,0,-o,g,0,o);const _=d===s?n:i;_.toArray(l,f),f+=3,_.toArray(l,f),f+=3,_.toArray(l,f),f+=3,_.toArray(l,f),f+=3}const h=new mt;h.setAttribute("position",new Ze(c,3)),h.setAttribute("color",new Ze(l,3));const u=new sr({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Vs=new Qt;class pv extends wa{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(8*3),s=new mt;s.setIndex(new vt(n,1)),s.setAttribute("position",new vt(i,3)),super(s,new sr({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&Vs.setFromObject(this.object),Vs.isEmpty())return;const t=Vs.min,n=Vs.max,i=this.geometry.attributes.position,s=i.array;s[0]=n.x,s[1]=n.y,s[2]=n.z,s[3]=t.x,s[4]=n.y,s[5]=n.z,s[6]=t.x,s[7]=t.y,s[8]=n.z,s[9]=n.x,s[10]=t.y,s[11]=n.z,s[12]=n.x,s[13]=n.y,s[14]=t.z,s[15]=t.x,s[16]=n.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=n.x,s[22]=t.y,s[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:pa}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=pa);function Oc(r,e){if(e===Oh)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===ia||e===$c){let t=r.getIndex();if(t===null){const a=[],o=r.getAttribute("position");if(o!==void 0){for(let c=0;c<o.count;c++)a.push(c);r.setIndex(a),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const n=t.count-2,i=[];if(e===ia)for(let a=1;a<=n;a++)i.push(t.getX(0)),i.push(t.getX(a)),i.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(i.push(t.getX(a)),i.push(t.getX(a+1)),i.push(t.getX(a+2))):(i.push(t.getX(a+2)),i.push(t.getX(a+1)),i.push(t.getX(a)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=r.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}class mv extends Bi{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new A_(t)}),this.register(function(t){return new D_(t)}),this.register(function(t){return new U_(t)}),this.register(function(t){return new O_(t)}),this.register(function(t){return new w_(t)}),this.register(function(t){return new R_(t)}),this.register(function(t){return new C_(t)}),this.register(function(t){return new L_(t)}),this.register(function(t){return new T_(t)}),this.register(function(t){return new P_(t)}),this.register(function(t){return new b_(t)}),this.register(function(t){return new N_(t)}),this.register(function(t){return new I_(t)}),this.register(function(t){return new S_(t)}),this.register(function(t){return new F_(t)}),this.register(function(t){return new B_(t)})}load(e,t,n,i){const s=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const l=ts.extractUrlBase(e);a=ts.resolveURL(l,this.path)}else a=ts.extractUrlBase(e);this.manager.itemStart(e);const o=function(l){i?i(l):console.error(l),s.manager.itemError(e),s.manager.itemEnd(e)},c=new Ul(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{s.parse(l,a,function(h){t(h),s.manager.itemEnd(e)},o)}catch(h){o(h)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let s;const a={},o={},c=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===Ol){try{a[ke.KHR_BINARY_GLTF]=new z_(e)}catch(u){i&&i(u);return}s=JSON.parse(a[ke.KHR_BINARY_GLTF].content)}else s=JSON.parse(c.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new Z_(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](l);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[u.name]=u,a[u.name]=!0}if(s.extensionsUsed)for(let h=0;h<s.extensionsUsed.length;++h){const u=s.extensionsUsed[h],d=s.extensionsRequired||[];switch(u){case ke.KHR_MATERIALS_UNLIT:a[u]=new E_;break;case ke.KHR_DRACO_MESH_COMPRESSION:a[u]=new H_(s,this.dracoLoader);break;case ke.KHR_TEXTURE_TRANSFORM:a[u]=new G_;break;case ke.KHR_MESH_QUANTIZATION:a[u]=new k_;break;default:d.indexOf(u)>=0&&o[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(a),l.setPlugins(o),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function y_(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}const ke={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_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class S_{constructor(e){this.parser=e,this.name=ke.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const s=t.json,c=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let l;const h=new ve(16777215);c.color!==void 0&&h.setRGB(c.color[0],c.color[1],c.color[2],xt);const u=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new o_(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new r_(h),l.distance=u;break;case"spot":l=new i_(h),l.distance=u,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),l.decay=2,En(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),i=Promise.resolve(l),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,s=n.json.nodes[e],o=(s.extensions&&s.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(c){return n._getNodeRef(t.cache,o,c)})}}class E_{constructor(){this.name=ke.KHR_MATERIALS_UNLIT}getMaterialType(){return Wn}extendParams(e,t,n){const i=[];e.color=new ve(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const a=s.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],xt),e.opacity=a[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,wt))}return Promise.all(i)}}class T_{constructor(e){this.parser=e,this.name=ke.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}}class A_{constructor(e){this.parser=e,this.name=ke.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:mn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];if(a.clearcoatFactor!==void 0&&(t.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const o=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new re(o,o)}return Promise.all(s)}}class b_{constructor(e){this.parser=e,this.name=ke.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:mn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return a.iridescenceFactor!==void 0&&(t.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(t.iridescenceIOR=a.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(s)}}class w_{constructor(e){this.parser=e,this.name=ke.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:mn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new ve(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=i.extensions[this.name];if(a.sheenColorFactor!==void 0){const o=a.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],xt)}return a.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,wt)),a.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(s)}}class R_{constructor(e){this.parser=e,this.name=ke.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:mn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return a.transmissionFactor!==void 0&&(t.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(s)}}class C_{constructor(e){this.parser=e,this.name=ke.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:mn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];t.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const o=a.attenuationColor||[1,1,1];return t.attenuationColor=new ve().setRGB(o[0],o[1],o[2],xt),Promise.all(s)}}class L_{constructor(e){this.parser=e,this.name=ke.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:mn}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class P_{constructor(e){this.parser=e,this.name=ke.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:mn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];t.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",a.specularTexture));const o=a.specularColorFactor||[1,1,1];return t.specularColor=new ve().setRGB(o[0],o[1],o[2],xt),a.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,wt)),Promise.all(s)}}class I_{constructor(e){this.parser=e,this.name=ke.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:mn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return t.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(s)}}class N_{constructor(e){this.parser=e,this.name=ke.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:mn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return a.anisotropyStrength!==void 0&&(t.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(t.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(s)}}class D_{constructor(e){this.parser=e,this.name=ke.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],a=t.options.ktx2Loader;if(!a){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 t.loadTextureImage(e,s.source,a)}}class U_{constructor(e){this.parser=e,this.name=ke.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=i.images[a.source];let c=n.textureLoader;if(o.uri){const l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,a.source,c);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class O_{constructor(e){this.parser=e,this.name=ke.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=i.images[a.source];let c=n.textureLoader;if(o.uri){const l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,a.source,c);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class F_{constructor(e){this.name=ke.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(o){const c=i.byteOffset||0,l=i.byteLength||0,h=i.count,u=i.byteStride,d=new Uint8Array(o,c,l);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(h,u,d,i.mode,i.filter).then(function(f){return f.buffer}):a.ready.then(function(){const f=new ArrayBuffer(h*u);return a.decodeGltfBuffer(new Uint8Array(f),h,u,d,i.mode,i.filter),f})})}else return null}}class B_{constructor(e){this.name=ke.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const l of i.primitives)if(l.mode!==Bt.TRIANGLES&&l.mode!==Bt.TRIANGLE_STRIP&&l.mode!==Bt.TRIANGLE_FAN&&l.mode!==void 0)return null;const a=n.extensions[this.name].attributes,o=[],c={};for(const l in a)o.push(this.parser.getDependency("accessor",a[l]).then(h=>(c[l]=h,c[l])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(l=>{const h=l.pop(),u=h.isGroup?h.children:[h],d=l[0].count,f=[];for(const g of u){const _=new be,m=new R,p=new jt,S=new R(1,1,1),v=new wg(g.geometry,g.material,d);for(let E=0;E<d;E++)c.TRANSLATION&&m.fromBufferAttribute(c.TRANSLATION,E),c.ROTATION&&p.fromBufferAttribute(c.ROTATION,E),c.SCALE&&S.fromBufferAttribute(c.SCALE,E),v.setMatrixAt(E,_.compose(m,p,S));for(const E in c)if(E==="_COLOR_0"){const C=c[E];v.instanceColor=new ca(C.array,C.itemSize,C.normalized)}else E!=="TRANSLATION"&&E!=="ROTATION"&&E!=="SCALE"&&g.geometry.setAttribute(E,c[E]);et.prototype.copy.call(v,g),this.parser.assignFinalMaterial(v),f.push(v)}return h.isGroup?(h.clear(),h.add(...f),h):f[0]}))}}const Ol="glTF",Ji=12,Fc={JSON:1313821514,BIN:5130562};class z_{constructor(e){this.name=ke.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ji),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ol)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-Ji,s=new DataView(e,Ji);let a=0;for(;a<i;){const o=s.getUint32(a,!0);a+=4;const c=s.getUint32(a,!0);if(a+=4,c===Fc.JSON){const l=new Uint8Array(e,Ji+a,o);this.content=n.decode(l)}else if(c===Fc.BIN){const l=Ji+a;this.body=e.slice(l,l+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class H_{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ke.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},c={},l={};for(const h in a){const u=da[h]||h.toLowerCase();o[u]=a[h]}for(const h in e.attributes){const u=da[h]||h.toLowerCase();if(a[h]!==void 0){const d=n.accessors[e.attributes[h]],f=Ai[d.componentType];l[u]=f.name,c[u]=d.normalized===!0}}return t.getDependency("bufferView",s).then(function(h){return new Promise(function(u,d){i.decodeDracoFile(h,function(f){for(const g in f.attributes){const _=f.attributes[g],m=c[g];m!==void 0&&(_.normalized=m)}u(f)},o,l,xt,d)})})}}class G_{constructor(){this.name=ke.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class k_{constructor(){this.name=ke.KHR_MESH_QUANTIZATION}}class Fl extends cs{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let a=0;a!==i;a++)t[a]=n[s+a];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=o*2,l=o*3,h=i-t,u=(n-t)/h,d=u*u,f=d*u,g=e*l,_=g-l,m=-2*f+3*d,p=f-d,S=1-m,v=p-d+u;for(let E=0;E!==o;E++){const C=a[_+E+o],A=a[_+E+c]*h,b=a[g+E+o],D=a[g+E]*h;s[E]=S*C+v*A+m*b+p*D}return s}}const V_=new jt;class W_ extends Fl{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return V_.fromArray(s).normalize().toArray(s),s}}const Bt={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Ai={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Bc={9728:pt,9729:Et,9984:na,9985:Ws,9986:vi,9987:dn},zc={33071:zt,33648:Ys,10497:Ri},Kr={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},da={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Sn={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},X_={CUBICSPLINE:void 0,LINEAR:Li,STEP:is},Jr={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function q_(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new Ia({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:pn})),r.DefaultMaterial}function zn(r,e,t){for(const n in t.extensions)r[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function En(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Y_(r,e,t){let n=!1,i=!1,s=!1;for(let l=0,h=e.length;l<h;l++){const u=e[l];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(i=!0),u.COLOR_0!==void 0&&(s=!0),n&&i&&s)break}if(!n&&!i&&!s)return Promise.resolve(r);const a=[],o=[],c=[];for(let l=0,h=e.length;l<h;l++){const u=e[l];if(n){const d=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):r.attributes.position;a.push(d)}if(i){const d=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):r.attributes.normal;o.push(d)}if(s){const d=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):r.attributes.color;c.push(d)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(c)]).then(function(l){const h=l[0],u=l[1],d=l[2];return n&&(r.morphAttributes.position=h),i&&(r.morphAttributes.normal=u),s&&(r.morphAttributes.color=d),r.morphTargetsRelative=!0,r})}function j_(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)r.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function K_(r){let e;const t=r.extensions&&r.extensions[ke.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+$r(t.attributes):e=r.indices+":"+$r(r.attributes)+":"+r.mode,r.targets!==void 0)for(let n=0,i=r.targets.length;n<i;n++)e+=":"+$r(r.targets[n]);return e}function $r(r){let e="";const t=Object.keys(r).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+r[t[n]]+";";return e}function fa(r){switch(r){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function J_(r){return r.search(/\.jpe?g($|\?)/i)>0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const $_=new be;class Z_{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new y_,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=!1,s=-1;typeof navigator<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,i=navigator.userAgent.indexOf("Firefox")>-1,s=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||i&&s<98?this.textureLoader=new t_(this.options.manager):this.textureLoader=new c_(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ul(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){const o={scene:a[0][i.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:i.asset,parser:n,userData:{}};return zn(s,o,i),En(o,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(o)})).then(function(){e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i<s;i++){const a=t[i].joints;for(let o=0,c=a.length;o<c;o++)e[a[o]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const a=e[i];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),s=(a,o)=>{const c=this.associations.get(a);c!=null&&this.associations.set(o,c);for(const[l,h]of a.children.entries())s(h,o.children[l])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const s=e(t[i]);s&&n.push(s)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":i=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(s,a){return n.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[ke.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,a){n.load(ts.resolveURL(t.uri,i.path),s,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const a=Kr[i.type],o=Ai[i.componentType],c=i.normalized===!0,l=new o(i.count*a);return Promise.resolve(new vt(l,a,c))}const s=[];return i.bufferView!==void 0?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),i.sparse!==void 0&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then(function(a){const o=a[0],c=Kr[i.type],l=Ai[i.componentType],h=l.BYTES_PER_ELEMENT,u=h*c,d=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,g=i.normalized===!0;let _,m;if(f&&f!==u){const p=Math.floor(d/f),S="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count;let v=t.cache.get(S);v||(_=new l(o,p*f,i.count*f/h),v=new vl(_,f/h),t.cache.add(S,v)),m=new rs(v,c,d%f/h,g)}else o===null?_=new l(i.count*c):_=new l(o,d,i.count*c),m=new vt(_,c,g);if(i.sparse!==void 0){const p=Kr.SCALAR,S=Ai[i.sparse.indices.componentType],v=i.sparse.indices.byteOffset||0,E=i.sparse.values.byteOffset||0,C=new S(a[1],v,i.sparse.count*p),A=new l(a[2],E,i.sparse.count*c);o!==null&&(m=new vt(m.array.slice(),m.itemSize,m.normalized));for(let b=0,D=C.length;b<D;b++){const k=C[b];if(m.setX(k,A[b*c]),c>=2&&m.setY(k,A[b*c+1]),c>=3&&m.setZ(k,A[b*c+2]),c>=4&&m.setW(k,A[b*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,a=t.images[s];let o=this.textureLoader;if(a.uri){const c=n.manager.getHandler(a.uri);c!==null&&(o=c)}return this.loadTextureImage(e,s,o)}loadTextureImage(e,t,n){const i=this,s=this.json,a=s.textures[e],o=s.images[t],c=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=a.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);const d=(s.samplers||{})[a.sampler]||{};return h.magFilter=Bc[d.magFilter]||Et,h.minFilter=Bc[d.minFilter]||dn,h.wrapS=zc[d.wrapS]||Ri,h.wrapT=zc[d.wrapT]||Ri,i.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const a=i.images[e],o=self.URL||self.webkitURL;let c=a.uri||"",l=!1;if(a.bufferView!==void 0)c=n.getDependency("bufferView",a.bufferView).then(function(u){l=!0;const d=new Blob([u],{type:a.mimeType});return c=o.createObjectURL(d),c});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(c).then(function(u){return new Promise(function(d,f){let g=d;t.isImageBitmapLoader===!0&&(g=function(_){const m=new lt(_);m.needsUpdate=!0,d(m)}),t.load(ts.resolveURL(u,s.path),g,void 0,f)})}).then(function(u){return l===!0&&o.revokeObjectURL(c),u.userData.mimeType=a.mimeType||J_(a.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),u});return this.sourceCache[e]=h,h}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),s.extensions[ke.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[ke.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const c=s.associations.get(a);a=s.extensions[ke.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),s.associations.set(a,c)}}return i!==void 0&&(a.colorSpace=i),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new Sl,Dt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(o,c)),n=c}else if(e.isLine){const o="LineBasicMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new sr,Dt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(o,c)),n=c}if(i||s||a){let o="ClonedMaterial:"+n.uuid+":";i&&(o+="derivative-tangents:"),s&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let c=this.cache.get(o);c||(c=n.clone(),s&&(c.vertexColors=!0),a&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(o,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return Ia}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let a;const o={},c=s.extensions||{},l=[];if(c[ke.KHR_MATERIALS_UNLIT]){const u=i[ke.KHR_MATERIALS_UNLIT];a=u.getMaterialType(),l.push(u.extendParams(o,s,t))}else{const u=s.pbrMetallicRoughness||{};if(o.color=new ve(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],xt),o.opacity=d[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(o,"map",u.baseColorTexture,wt)),o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture))),a=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}s.doubleSided===!0&&(o.side=Zt);const h=s.alphaMode||Jr.OPAQUE;if(h===Jr.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===Jr.MASK&&(o.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&a!==Wn&&(l.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new re(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;o.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&a!==Wn&&(l.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&a!==Wn){const u=s.emissiveFactor;o.emissive=new ve().setRGB(u[0],u[1],u[2],xt)}return s.emissiveTexture!==void 0&&a!==Wn&&l.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,wt)),Promise.all(l).then(function(){const u=new a(o);return s.name&&(u.name=s.name),En(u,s),t.associations.set(u,{materials:e}),s.extensions&&zn(i,u,s),u})}createUniqueName(e){const t=Xe.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(o){return n[ke.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(c){return Hc(c,o,t)})}const a=[];for(let o=0,c=e.length;o<c;o++){const l=e[o],h=K_(l),u=i[h];if(u)a.push(u.promise);else{let d;l.extensions&&l.extensions[ke.KHR_DRACO_MESH_COMPRESSION]?d=s(l):d=Hc(new mt,l,t),i[h]={primitive:l,promise:d},a.push(d)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],a=s.primitives,o=[];for(let c=0,l=a.length;c<l;c++){const h=a[c].material===void 0?q_(this.cache):this.getDependency("material",a[c].material);o.push(h)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(c){const l=c.slice(0,c.length-1),h=c[c.length-1],u=[];for(let f=0,g=h.length;f<g;f++){const _=h[f],m=a[f];let p;const S=l[f];if(m.mode===Bt.TRIANGLES||m.mode===Bt.TRIANGLE_STRIP||m.mode===Bt.TRIANGLE_FAN||m.mode===void 0)p=s.isSkinnedMesh===!0?new Tg(_,S):new Nt(_,S),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),m.mode===Bt.TRIANGLE_STRIP?p.geometry=Oc(p.geometry,$c):m.mode===Bt.TRIANGLE_FAN&&(p.geometry=Oc(p.geometry,ia));else if(m.mode===Bt.LINES)p=new wa(_,S);else if(m.mode===Bt.LINE_STRIP)p=new ba(_,S);else if(m.mode===Bt.LINE_LOOP)p=new Rg(_,S);else if(m.mode===Bt.POINTS)p=new Cg(_,S);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(p.geometry.morphAttributes).length>0&&j_(p,s),p.name=t.createUniqueName(s.name||"mesh_"+e),En(p,s),m.extensions&&zn(i,p,m),t.assignFinalMaterial(p),u.push(p)}for(let f=0,g=u.length;f<g;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return s.extensions&&zn(i,u[0],s),u[0];const d=new Xn;s.extensions&&zn(i,d,s),t.associations.set(d,{meshes:e});for(let f=0,g=u.length;f<g;f++)d.add(u[f]);return d})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new Rt(ou.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new Ea(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),En(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,s=t.joints.length;i<s;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const s=i.pop(),a=i,o=[],c=[];for(let l=0,h=a.length;l<h;l++){const u=a[l];if(u){o.push(u);const d=new be;s!==null&&d.fromArray(s.array,l*16),c.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new Aa(o,c)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,a=[],o=[],c=[],l=[],h=[];for(let u=0,d=i.channels.length;u<d;u++){const f=i.channels[u],g=i.samplers[f.sampler],_=f.target,m=_.node,p=i.parameters!==void 0?i.parameters[g.input]:g.input,S=i.parameters!==void 0?i.parameters[g.output]:g.output;_.node!==void 0&&(a.push(this.getDependency("node",m)),o.push(this.getDependency("accessor",p)),c.push(this.getDependency("accessor",S)),l.push(g),h.push(_))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(h)]).then(function(u){const d=u[0],f=u[1],g=u[2],_=u[3],m=u[4],p=[];for(let S=0,v=d.length;S<v;S++){const E=d[S],C=f[S],A=g[S],b=_[S],D=m[S];if(E===void 0)continue;E.updateMatrix&&E.updateMatrix();const k=n._createAnimationTracks(E,C,A,b,D);if(k)for(let M=0;M<k.length;M++)p.push(k[M])}return new ha(s,void 0,p)})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(s){const a=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let c=0,l=i.weights.length;c<l;c++)o.morphTargetInfluences[c]=i.weights[c]}),a})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],s=n._loadNodeShallow(e),a=[],o=i.children||[];for(let l=0,h=o.length;l<h;l++)a.push(n.getDependency("node",o[l]));const c=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([s,Promise.all(a),c]).then(function(l){const h=l[0],u=l[1],d=l[2];d!==null&&h.traverse(function(f){f.isSkinnedMesh&&f.bind(d,$_)});for(let f=0,g=u.length;f<g;f++)h.add(u[f]);return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],a=s.name?i.createUniqueName(s.name):"",o=[],c=i._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&o.push(c),s.camera!==void 0&&o.push(i.getDependency("camera",s.camera).then(function(l){return i._getNodeRef(i.cameraCache,s.camera,l)})),i._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){o.push(l)}),this.nodeCache[e]=Promise.all(o).then(function(l){let h;if(s.isBone===!0?h=new Ml:l.length>1?h=new Xn:l.length===1?h=l[0]:h=new et,h!==l[0])for(let u=0,d=l.length;u<d;u++)h.add(l[u]);if(s.name&&(h.userData.name=s.name,h.name=a),En(h,s),s.extensions&&zn(n,h,s),s.matrix!==void 0){const u=new be;u.fromArray(s.matrix),h.applyMatrix4(u)}else s.translation!==void 0&&h.position.fromArray(s.translation),s.rotation!==void 0&&h.quaternion.fromArray(s.rotation),s.scale!==void 0&&h.scale.fromArray(s.scale);return i.associations.has(h)||i.associations.set(h,{}),i.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,s=new Xn;n.name&&(s.name=i.createUniqueName(n.name)),En(s,n),n.extensions&&zn(t,s,n);const a=n.nodes||[],o=[];for(let c=0,l=a.length;c<l;c++)o.push(i.getDependency("node",a[c]));return Promise.all(o).then(function(c){for(let h=0,u=c.length;h<u;h++)s.add(c[h]);const l=h=>{const u=new Map;for(const[d,f]of i.associations)(d instanceof Dt||d instanceof lt)&&u.set(d,f);return h.traverse(d=>{const f=i.associations.get(d);f!=null&&u.set(d,f)}),u};return i.associations=l(s),s})}_createAnimationTracks(e,t,n,i,s){const a=[],o=e.name?e.name:e.uuid,c=[];Sn[s.path]===Sn.weights?e.traverse(function(d){d.morphTargetInfluences&&c.push(d.name?d.name:d.uuid)}):c.push(o);let l;switch(Sn[s.path]){case Sn.weights:l=Ni;break;case Sn.rotation:l=Kn;break;case Sn.position:case Sn.scale:l=Di;break;default:switch(n.itemSize){case 1:l=Ni;break;case 2:case 3:default:l=Di;break}break}const h=i.interpolation!==void 0?X_[i.interpolation]:Li,u=this._getArrayFromAccessor(n);for(let d=0,f=c.length;d<f;d++){const g=new l(c[d]+"."+Sn[s.path],t.array,u,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),a.push(g)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=fa(t.constructor),i=new Float32Array(t.length);for(let s=0,a=t.length;s<a;s++)i[s]=t[s]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof Kn?W_:Fl;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Q_(r,e,t){const n=e.attributes,i=new Qt;if(n.POSITION!==void 0){const o=t.json.accessors[n.POSITION],c=o.min,l=o.max;if(c!==void 0&&l!==void 0){if(i.set(new R(c[0],c[1],c[2]),new R(l[0],l[1],l[2])),o.normalized){const h=fa(Ai[o.componentType]);i.min.multiplyScalar(h),i.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const o=new R,c=new R;for(let l=0,h=s.length;l<h;l++){const u=s[l];if(u.POSITION!==void 0){const d=t.json.accessors[u.POSITION],f=d.min,g=d.max;if(f!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(g[2]))),d.normalized){const _=fa(Ai[d.componentType]);c.multiplyScalar(_)}o.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(o)}r.boundingBox=i;const a=new en;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,r.boundingSphere=a}function Hc(r,e,t){const n=e.attributes,i=[];function s(a,o){return t.getDependency("accessor",a).then(function(c){r.setAttribute(o,c)})}for(const a in n){const o=da[a]||a.toLowerCase();o in r.attributes||i.push(s(n[a],o))}if(e.indices!==void 0&&!r.index){const a=t.getDependency("accessor",e.indices).then(function(o){r.setIndex(o)});i.push(a)}return qe.workingColorSpace!==xt&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${qe.workingColorSpace}" not supported.`),En(r,e),Q_(r,e,t),Promise.all(i).then(function(){return e.targets!==void 0?Y_(r,e.targets,t):r})}export{Sg as $,cv as A,os as B,ve as C,o_ as D,jn as E,_l as F,Xn as G,ov as H,ns as I,Va as J,pn as K,Et as L,Nt as M,wn as N,Ea as O,Xl as P,Cl as Q,uv as R,nv as S,Zt as T,bu as U,R as V,Mg as W,vt as X,Sl as Y,Cg as Z,Pl as _,lv as a,iv as a0,hv as a1,wl as a2,Ih as a3,Nh as a4,wa as a5,Sh as a6,Ct as a7,rv as a8,La as a9,Jn as aa,ev as ab,tv as ac,jt as ad,as as ae,Rt as b,av as c,nr as d,Pa as e,r_ as f,Ll as g,wt as h,Qt as i,sv as j,Ia as k,Wn as l,i_ as m,ou as n,re as o,Hn as p,dv as q,fv as r,sr as s,Rl as t,pv as u,mt as v,ba as w,mv as x,Ze as y,Ln as z};
3804
+ //# sourceMappingURL=GLTFLoader-BA5RqSME.js.map