synabun 1.3.0 → 2.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 (1163) hide show
  1. package/CHANGELOG.md +205 -662
  2. package/LICENSE-COMMERCIAL.md +33 -0
  3. package/NOTICE +17 -0
  4. package/README.md +175 -853
  5. package/THIRD-PARTY-LICENSES.md +136 -0
  6. package/benchmarks/browser-live-results.json +79 -0
  7. package/benchmarks/browser-v2-results.json +258 -0
  8. package/benchmarks/fixtures/browser/README.md +57 -0
  9. package/benchmarks/fixtures/browser/page-state.json +132 -0
  10. package/benchmarks/fixtures/browser/social.json +92 -0
  11. package/benchmarks/fixtures/browser/target.json +319 -0
  12. package/benchmarks/fixtures/desktop/README.md +58 -0
  13. package/benchmarks/fixtures/desktop/abstention.json +59 -0
  14. package/benchmarks/fixtures/desktop/adversarial.json +22 -0
  15. package/benchmarks/fixtures/desktop/forbidden.json +93 -0
  16. package/benchmarks/fixtures/desktop/generate.mjs +1023 -0
  17. package/benchmarks/fixtures/desktop/target.json +136 -0
  18. package/bin/synabun.js +30 -0
  19. package/docs/whatsapp.md +325 -0
  20. package/hooks/claude-code/post-plan.mjs +613 -391
  21. package/hooks/claude-code/post-remember.mjs +246 -122
  22. package/hooks/claude-code/pre-compact.mjs +171 -110
  23. package/hooks/claude-code/pre-task.mjs +133 -0
  24. package/hooks/claude-code/pre-websearch.mjs +15 -4
  25. package/hooks/claude-code/prompt-origin.mjs +94 -0
  26. package/hooks/claude-code/prompt-submit.mjs +1244 -861
  27. package/hooks/claude-code/session-start.mjs +114 -156
  28. package/hooks/claude-code/shared.mjs +1228 -368
  29. package/hooks/claude-code/state.mjs +167 -0
  30. package/hooks/claude-code/stop.mjs +515 -140
  31. package/hooks/claude-code/subagent-start.mjs +154 -0
  32. package/hooks/claude-code/subagent-stop.mjs +102 -0
  33. package/hooks/claude-code/task-gate.mjs +150 -0
  34. package/launcher.mjs +40 -0
  35. package/lib/claude-hooks.js +137 -0
  36. package/lib/claude-usage-audit.js +141 -0
  37. package/lib/client-config-repair.js +145 -0
  38. package/lib/data-home-migration.js +502 -0
  39. package/lib/desktop-pwa.js +206 -0
  40. package/lib/external-tools.js +221 -0
  41. package/lib/first-launch-protection.js +245 -0
  42. package/lib/packaged-runtime.js +110 -0
  43. package/lib/paths.d.ts +21 -0
  44. package/lib/paths.js +103 -0
  45. package/lib/start-launcher.js +1309 -0
  46. package/mcp-server/dist/config.d.ts +22 -0
  47. package/mcp-server/dist/config.d.ts.map +1 -0
  48. package/mcp-server/dist/config.js +109 -0
  49. package/mcp-server/dist/config.js.map +1 -0
  50. package/mcp-server/dist/http.d.ts +30 -0
  51. package/mcp-server/dist/http.d.ts.map +1 -0
  52. package/mcp-server/dist/http.js +276 -0
  53. package/mcp-server/dist/http.js.map +1 -0
  54. package/mcp-server/dist/index.d.ts +48 -0
  55. package/mcp-server/dist/index.d.ts.map +1 -0
  56. package/mcp-server/dist/index.js +538 -0
  57. package/mcp-server/dist/index.js.map +1 -0
  58. package/mcp-server/dist/preload-http.d.ts +3 -0
  59. package/mcp-server/dist/preload-http.d.ts.map +1 -0
  60. package/mcp-server/dist/preload-http.js +28 -0
  61. package/mcp-server/dist/preload-http.js.map +1 -0
  62. package/mcp-server/dist/preload.d.ts +3 -0
  63. package/mcp-server/dist/preload.d.ts.map +1 -0
  64. package/mcp-server/dist/preload.js +32 -0
  65. package/mcp-server/dist/preload.js.map +1 -0
  66. package/mcp-server/dist/scripts/migrate-qdrant-to-sqlite.d.ts +19 -0
  67. package/mcp-server/dist/scripts/migrate-qdrant-to-sqlite.d.ts.map +1 -0
  68. package/mcp-server/dist/scripts/migrate-qdrant-to-sqlite.js +403 -0
  69. package/mcp-server/dist/scripts/migrate-qdrant-to-sqlite.js.map +1 -0
  70. package/mcp-server/dist/scripts/setup-embeddings.d.ts +3 -0
  71. package/mcp-server/dist/scripts/setup-embeddings.d.ts.map +1 -0
  72. package/mcp-server/dist/scripts/setup-embeddings.js +15 -0
  73. package/mcp-server/dist/scripts/setup-embeddings.js.map +1 -0
  74. package/mcp-server/dist/services/assistant-judgments.d.ts +79 -0
  75. package/mcp-server/dist/services/assistant-judgments.d.ts.map +1 -0
  76. package/mcp-server/dist/services/assistant-judgments.js +128 -0
  77. package/mcp-server/dist/services/assistant-judgments.js.map +1 -0
  78. package/mcp-server/dist/services/browser-assist-gate.d.ts +314 -0
  79. package/mcp-server/dist/services/browser-assist-gate.d.ts.map +1 -0
  80. package/mcp-server/dist/services/browser-assist-gate.js +344 -0
  81. package/mcp-server/dist/services/browser-assist-gate.js.map +1 -0
  82. package/mcp-server/dist/services/browser-assist.d.ts +104 -0
  83. package/mcp-server/dist/services/browser-assist.d.ts.map +1 -0
  84. package/mcp-server/dist/services/browser-assist.js +282 -0
  85. package/mcp-server/dist/services/browser-assist.js.map +1 -0
  86. package/mcp-server/dist/services/browser-bench.d.ts +772 -0
  87. package/mcp-server/dist/services/browser-bench.d.ts.map +1 -0
  88. package/mcp-server/dist/services/browser-bench.js +424 -0
  89. package/mcp-server/dist/services/browser-bench.js.map +1 -0
  90. package/mcp-server/dist/services/browser-judgments.d.ts +196 -0
  91. package/mcp-server/dist/services/browser-judgments.d.ts.map +1 -0
  92. package/mcp-server/dist/services/browser-judgments.js +363 -0
  93. package/mcp-server/dist/services/browser-judgments.js.map +1 -0
  94. package/mcp-server/dist/services/browser-risk.d.ts +166 -0
  95. package/mcp-server/dist/services/browser-risk.d.ts.map +1 -0
  96. package/mcp-server/dist/services/browser-risk.js +458 -0
  97. package/mcp-server/dist/services/browser-risk.js.map +1 -0
  98. package/mcp-server/dist/services/categories.d.ts +61 -0
  99. package/mcp-server/dist/services/categories.d.ts.map +1 -0
  100. package/mcp-server/dist/services/categories.js +377 -0
  101. package/mcp-server/dist/services/categories.js.map +1 -0
  102. package/mcp-server/dist/services/codex-config-heal.d.ts +49 -0
  103. package/mcp-server/dist/services/codex-config-heal.d.ts.map +1 -0
  104. package/mcp-server/dist/services/codex-config-heal.js +346 -0
  105. package/mcp-server/dist/services/codex-config-heal.js.map +1 -0
  106. package/mcp-server/dist/services/desktop-assist-gate.d.ts +198 -0
  107. package/mcp-server/dist/services/desktop-assist-gate.d.ts.map +1 -0
  108. package/mcp-server/dist/services/desktop-assist-gate.js +202 -0
  109. package/mcp-server/dist/services/desktop-assist-gate.js.map +1 -0
  110. package/mcp-server/dist/services/desktop-assist.d.ts +104 -0
  111. package/mcp-server/dist/services/desktop-assist.d.ts.map +1 -0
  112. package/mcp-server/dist/services/desktop-assist.js +266 -0
  113. package/mcp-server/dist/services/desktop-assist.js.map +1 -0
  114. package/mcp-server/dist/services/desktop-bench.d.ts +553 -0
  115. package/mcp-server/dist/services/desktop-bench.d.ts.map +1 -0
  116. package/mcp-server/dist/services/desktop-bench.js +311 -0
  117. package/mcp-server/dist/services/desktop-bench.js.map +1 -0
  118. package/mcp-server/dist/services/desktop-client.d.ts +23 -0
  119. package/mcp-server/dist/services/desktop-client.d.ts.map +1 -0
  120. package/mcp-server/dist/services/desktop-client.js +79 -0
  121. package/mcp-server/dist/services/desktop-client.js.map +1 -0
  122. package/mcp-server/dist/services/desktop-judgments.d.ts +125 -0
  123. package/mcp-server/dist/services/desktop-judgments.d.ts.map +1 -0
  124. package/mcp-server/dist/services/desktop-judgments.js +177 -0
  125. package/mcp-server/dist/services/desktop-judgments.js.map +1 -0
  126. package/mcp-server/dist/services/desktop-risk.d.ts +283 -0
  127. package/mcp-server/dist/services/desktop-risk.d.ts.map +1 -0
  128. package/mcp-server/dist/services/desktop-risk.js +605 -0
  129. package/mcp-server/dist/services/desktop-risk.js.map +1 -0
  130. package/mcp-server/dist/services/discord.d.ts +112 -0
  131. package/mcp-server/dist/services/discord.d.ts.map +1 -0
  132. package/mcp-server/dist/services/discord.js +477 -0
  133. package/mcp-server/dist/services/discord.js.map +1 -0
  134. package/mcp-server/dist/services/edit-stale.d.ts +81 -0
  135. package/mcp-server/dist/services/edit-stale.d.ts.map +1 -0
  136. package/mcp-server/dist/services/edit-stale.js +358 -0
  137. package/mcp-server/dist/services/edit-stale.js.map +1 -0
  138. package/mcp-server/dist/services/embedding-service.d.ts +16 -0
  139. package/mcp-server/dist/services/embedding-service.d.ts.map +1 -0
  140. package/mcp-server/dist/services/embedding-service.js +126 -0
  141. package/mcp-server/dist/services/embedding-service.js.map +1 -0
  142. package/mcp-server/dist/services/embedding-worker.d.ts +2 -0
  143. package/mcp-server/dist/services/embedding-worker.d.ts.map +1 -0
  144. package/mcp-server/dist/services/embedding-worker.js +52 -0
  145. package/mcp-server/dist/services/embedding-worker.js.map +1 -0
  146. package/mcp-server/dist/services/fb-regions.d.ts +71 -0
  147. package/mcp-server/dist/services/fb-regions.d.ts.map +1 -0
  148. package/mcp-server/dist/services/fb-regions.js +211 -0
  149. package/mcp-server/dist/services/fb-regions.js.map +1 -0
  150. package/mcp-server/dist/services/file-checksums.d.ts +22 -0
  151. package/mcp-server/dist/services/file-checksums.d.ts.map +1 -0
  152. package/mcp-server/dist/services/file-checksums.js +55 -0
  153. package/mcp-server/dist/services/file-checksums.js.map +1 -0
  154. package/mcp-server/dist/services/file-excerpt.d.ts +24 -0
  155. package/mcp-server/dist/services/file-excerpt.d.ts.map +1 -0
  156. package/mcp-server/dist/services/file-excerpt.js +65 -0
  157. package/mcp-server/dist/services/file-excerpt.js.map +1 -0
  158. package/mcp-server/dist/services/identity.d.ts +124 -0
  159. package/mcp-server/dist/services/identity.d.ts.map +1 -0
  160. package/mcp-server/dist/services/identity.js +241 -0
  161. package/mcp-server/dist/services/identity.js.map +1 -0
  162. package/mcp-server/dist/services/local-embeddings.d.ts +2 -0
  163. package/mcp-server/dist/services/local-embeddings.d.ts.map +1 -0
  164. package/mcp-server/dist/services/local-embeddings.js +3 -0
  165. package/mcp-server/dist/services/local-embeddings.js.map +1 -0
  166. package/mcp-server/dist/services/memory-client.d.ts +4 -0
  167. package/mcp-server/dist/services/memory-client.d.ts.map +1 -0
  168. package/mcp-server/dist/services/memory-client.js +27 -0
  169. package/mcp-server/dist/services/memory-client.js.map +1 -0
  170. package/mcp-server/dist/services/memory-judge-backfill.d.ts +135 -0
  171. package/mcp-server/dist/services/memory-judge-backfill.d.ts.map +1 -0
  172. package/mcp-server/dist/services/memory-judge-backfill.js +510 -0
  173. package/mcp-server/dist/services/memory-judge-backfill.js.map +1 -0
  174. package/mcp-server/dist/services/memory-judgments.d.ts +362 -0
  175. package/mcp-server/dist/services/memory-judgments.d.ts.map +1 -0
  176. package/mcp-server/dist/services/memory-judgments.js +674 -0
  177. package/mcp-server/dist/services/memory-judgments.js.map +1 -0
  178. package/mcp-server/dist/services/memory-maintenance.d.ts +108 -0
  179. package/mcp-server/dist/services/memory-maintenance.d.ts.map +1 -0
  180. package/mcp-server/dist/services/memory-maintenance.js +403 -0
  181. package/mcp-server/dist/services/memory-maintenance.js.map +1 -0
  182. package/mcp-server/dist/services/memory-retrieval.d.ts +66 -0
  183. package/mcp-server/dist/services/memory-retrieval.d.ts.map +1 -0
  184. package/mcp-server/dist/services/memory-retrieval.js +412 -0
  185. package/mcp-server/dist/services/memory-retrieval.js.map +1 -0
  186. package/mcp-server/dist/services/memory-schema.d.ts +16 -0
  187. package/mcp-server/dist/services/memory-schema.d.ts.map +1 -0
  188. package/mcp-server/dist/services/memory-schema.js +282 -0
  189. package/mcp-server/dist/services/memory-schema.js.map +1 -0
  190. package/mcp-server/dist/services/memory-sessions.d.ts +24 -0
  191. package/mcp-server/dist/services/memory-sessions.d.ts.map +1 -0
  192. package/mcp-server/dist/services/memory-sessions.js +110 -0
  193. package/mcp-server/dist/services/memory-sessions.js.map +1 -0
  194. package/mcp-server/dist/services/memory-triage.d.ts +60 -0
  195. package/mcp-server/dist/services/memory-triage.d.ts.map +1 -0
  196. package/mcp-server/dist/services/memory-triage.js +189 -0
  197. package/mcp-server/dist/services/memory-triage.js.map +1 -0
  198. package/mcp-server/dist/services/memory-verification.d.ts +24 -0
  199. package/mcp-server/dist/services/memory-verification.d.ts.map +1 -0
  200. package/mcp-server/dist/services/memory-verification.js +92 -0
  201. package/mcp-server/dist/services/memory-verification.js.map +1 -0
  202. package/mcp-server/dist/services/memory-writer.d.ts +26 -0
  203. package/mcp-server/dist/services/memory-writer.d.ts.map +1 -0
  204. package/mcp-server/dist/services/memory-writer.js +126 -0
  205. package/mcp-server/dist/services/memory-writer.js.map +1 -0
  206. package/mcp-server/dist/services/neural-interface.d.ts +439 -0
  207. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -0
  208. package/mcp-server/dist/services/neural-interface.js +1135 -0
  209. package/mcp-server/dist/services/neural-interface.js.map +1 -0
  210. package/mcp-server/dist/services/profiles.d.ts +120 -0
  211. package/mcp-server/dist/services/profiles.d.ts.map +1 -0
  212. package/mcp-server/dist/services/profiles.js +387 -0
  213. package/mcp-server/dist/services/profiles.js.map +1 -0
  214. package/mcp-server/dist/services/secret-gate.d.ts +29 -0
  215. package/mcp-server/dist/services/secret-gate.d.ts.map +1 -0
  216. package/mcp-server/dist/services/secret-gate.js +43 -0
  217. package/mcp-server/dist/services/secret-gate.js.map +1 -0
  218. package/mcp-server/dist/services/server-instructions.d.ts +10 -0
  219. package/mcp-server/dist/services/server-instructions.d.ts.map +1 -0
  220. package/mcp-server/dist/services/server-instructions.js +101 -0
  221. package/mcp-server/dist/services/server-instructions.js.map +1 -0
  222. package/mcp-server/dist/services/sqlite.d.ts +235 -0
  223. package/mcp-server/dist/services/sqlite.d.ts.map +1 -0
  224. package/mcp-server/dist/services/sqlite.js +1185 -0
  225. package/mcp-server/dist/services/sqlite.js.map +1 -0
  226. package/mcp-server/dist/services/typesafe-bench.d.ts +99 -0
  227. package/mcp-server/dist/services/typesafe-bench.d.ts.map +1 -0
  228. package/mcp-server/dist/services/typesafe-bench.js +218 -0
  229. package/mcp-server/dist/services/typesafe-bench.js.map +1 -0
  230. package/mcp-server/dist/services/typesafe-config.d.ts +342 -0
  231. package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -0
  232. package/mcp-server/dist/services/typesafe-config.js +746 -0
  233. package/mcp-server/dist/services/typesafe-config.js.map +1 -0
  234. package/mcp-server/dist/services/typesafe.d.ts +213 -0
  235. package/mcp-server/dist/services/typesafe.d.ts.map +1 -0
  236. package/mcp-server/dist/services/typesafe.js +330 -0
  237. package/mcp-server/dist/services/typesafe.js.map +1 -0
  238. package/mcp-server/dist/services/vector-cache.d.ts +68 -0
  239. package/mcp-server/dist/services/vector-cache.d.ts.map +1 -0
  240. package/mcp-server/dist/services/vector-cache.js +271 -0
  241. package/mcp-server/dist/services/vector-cache.js.map +1 -0
  242. package/mcp-server/dist/services/whiteboard-geometry.d.ts +305 -0
  243. package/mcp-server/dist/services/whiteboard-geometry.d.ts.map +1 -0
  244. package/mcp-server/dist/services/whiteboard-geometry.js +666 -0
  245. package/mcp-server/dist/services/whiteboard-geometry.js.map +1 -0
  246. package/mcp-server/dist/tools/agents.d.ts +212 -0
  247. package/mcp-server/dist/tools/agents.d.ts.map +1 -0
  248. package/mcp-server/dist/tools/agents.js +407 -0
  249. package/mcp-server/dist/tools/agents.js.map +1 -0
  250. package/mcp-server/dist/tools/bluesky.d.ts +39 -0
  251. package/mcp-server/dist/tools/bluesky.d.ts.map +1 -0
  252. package/mcp-server/dist/tools/bluesky.js +1144 -0
  253. package/mcp-server/dist/tools/bluesky.js.map +1 -0
  254. package/mcp-server/dist/tools/browser-advanced.d.ts +58 -0
  255. package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -0
  256. package/mcp-server/dist/tools/browser-advanced.js +106 -0
  257. package/mcp-server/dist/tools/browser-advanced.js.map +1 -0
  258. package/mcp-server/dist/tools/browser-batch.d.ts +99 -0
  259. package/mcp-server/dist/tools/browser-batch.d.ts.map +1 -0
  260. package/mcp-server/dist/tools/browser-batch.js +187 -0
  261. package/mcp-server/dist/tools/browser-batch.js.map +1 -0
  262. package/mcp-server/dist/tools/browser-cheatsheet.d.ts +21 -0
  263. package/mcp-server/dist/tools/browser-cheatsheet.d.ts.map +1 -0
  264. package/mcp-server/dist/tools/browser-cheatsheet.js +144 -0
  265. package/mcp-server/dist/tools/browser-cheatsheet.js.map +1 -0
  266. package/mcp-server/dist/tools/browser-interact.d.ts +239 -0
  267. package/mcp-server/dist/tools/browser-interact.d.ts.map +1 -0
  268. package/mcp-server/dist/tools/browser-interact.js +300 -0
  269. package/mcp-server/dist/tools/browser-interact.js.map +1 -0
  270. package/mcp-server/dist/tools/browser-navigate.d.ts +90 -0
  271. package/mcp-server/dist/tools/browser-navigate.d.ts.map +1 -0
  272. package/mcp-server/dist/tools/browser-navigate.js +142 -0
  273. package/mcp-server/dist/tools/browser-navigate.js.map +1 -0
  274. package/mcp-server/dist/tools/browser-observe.d.ts +561 -0
  275. package/mcp-server/dist/tools/browser-observe.d.ts.map +1 -0
  276. package/mcp-server/dist/tools/browser-observe.js +2009 -0
  277. package/mcp-server/dist/tools/browser-observe.js.map +1 -0
  278. package/mcp-server/dist/tools/browser.d.ts +34 -0
  279. package/mcp-server/dist/tools/browser.d.ts.map +1 -0
  280. package/mcp-server/dist/tools/browser.js +112 -0
  281. package/mcp-server/dist/tools/browser.js.map +1 -0
  282. package/mcp-server/dist/tools/card-tools.d.ts +82 -0
  283. package/mcp-server/dist/tools/card-tools.d.ts.map +1 -0
  284. package/mcp-server/dist/tools/card-tools.js +137 -0
  285. package/mcp-server/dist/tools/card-tools.js.map +1 -0
  286. package/mcp-server/dist/tools/card.d.ts +8 -0
  287. package/mcp-server/dist/tools/card.d.ts.map +1 -0
  288. package/mcp-server/dist/tools/card.js +16 -0
  289. package/mcp-server/dist/tools/card.js.map +1 -0
  290. package/mcp-server/dist/tools/category.d.ts +32 -0
  291. package/mcp-server/dist/tools/category.d.ts.map +1 -0
  292. package/mcp-server/dist/tools/category.js +290 -0
  293. package/mcp-server/dist/tools/category.js.map +1 -0
  294. package/mcp-server/dist/tools/choice.d.ts +160 -0
  295. package/mcp-server/dist/tools/choice.d.ts.map +1 -0
  296. package/mcp-server/dist/tools/choice.js +80 -0
  297. package/mcp-server/dist/tools/choice.js.map +1 -0
  298. package/mcp-server/dist/tools/computer.d.ts +71 -0
  299. package/mcp-server/dist/tools/computer.d.ts.map +1 -0
  300. package/mcp-server/dist/tools/computer.js +174 -0
  301. package/mcp-server/dist/tools/computer.js.map +1 -0
  302. package/mcp-server/dist/tools/discord-channel.d.ts +44 -0
  303. package/mcp-server/dist/tools/discord-channel.d.ts.map +1 -0
  304. package/mcp-server/dist/tools/discord-channel.js +236 -0
  305. package/mcp-server/dist/tools/discord-channel.js.map +1 -0
  306. package/mcp-server/dist/tools/discord-guild.d.ts +20 -0
  307. package/mcp-server/dist/tools/discord-guild.d.ts.map +1 -0
  308. package/mcp-server/dist/tools/discord-guild.js +138 -0
  309. package/mcp-server/dist/tools/discord-guild.js.map +1 -0
  310. package/mcp-server/dist/tools/discord-member.d.ts +26 -0
  311. package/mcp-server/dist/tools/discord-member.d.ts.map +1 -0
  312. package/mcp-server/dist/tools/discord-member.js +122 -0
  313. package/mcp-server/dist/tools/discord-member.js.map +1 -0
  314. package/mcp-server/dist/tools/discord-message.d.ts +36 -0
  315. package/mcp-server/dist/tools/discord-message.d.ts.map +1 -0
  316. package/mcp-server/dist/tools/discord-message.js +184 -0
  317. package/mcp-server/dist/tools/discord-message.js.map +1 -0
  318. package/mcp-server/dist/tools/discord-onboarding.d.ts +32 -0
  319. package/mcp-server/dist/tools/discord-onboarding.d.ts.map +1 -0
  320. package/mcp-server/dist/tools/discord-onboarding.js +179 -0
  321. package/mcp-server/dist/tools/discord-onboarding.js.map +1 -0
  322. package/mcp-server/dist/tools/discord-role.d.ts +34 -0
  323. package/mcp-server/dist/tools/discord-role.d.ts.map +1 -0
  324. package/mcp-server/dist/tools/discord-role.js +178 -0
  325. package/mcp-server/dist/tools/discord-role.js.map +1 -0
  326. package/mcp-server/dist/tools/discord-thread.d.ts +28 -0
  327. package/mcp-server/dist/tools/discord-thread.d.ts.map +1 -0
  328. package/mcp-server/dist/tools/discord-thread.js +88 -0
  329. package/mcp-server/dist/tools/discord-thread.js.map +1 -0
  330. package/mcp-server/dist/tools/discord-webhook.d.ts +32 -0
  331. package/mcp-server/dist/tools/discord-webhook.d.ts.map +1 -0
  332. package/mcp-server/dist/tools/discord-webhook.js +154 -0
  333. package/mcp-server/dist/tools/discord-webhook.js.map +1 -0
  334. package/mcp-server/dist/tools/discord.d.ts +7 -0
  335. package/mcp-server/dist/tools/discord.d.ts.map +1 -0
  336. package/mcp-server/dist/tools/discord.js +25 -0
  337. package/mcp-server/dist/tools/discord.js.map +1 -0
  338. package/mcp-server/dist/tools/fb-groups.d.ts +98 -0
  339. package/mcp-server/dist/tools/fb-groups.d.ts.map +1 -0
  340. package/mcp-server/dist/tools/fb-groups.js +369 -0
  341. package/mcp-server/dist/tools/fb-groups.js.map +1 -0
  342. package/mcp-server/dist/tools/forget.d.ts +14 -0
  343. package/mcp-server/dist/tools/forget.d.ts.map +1 -0
  344. package/mcp-server/dist/tools/forget.js +26 -0
  345. package/mcp-server/dist/tools/forget.js.map +1 -0
  346. package/mcp-server/dist/tools/git-tools.d.ts +24 -0
  347. package/mcp-server/dist/tools/git-tools.d.ts.map +1 -0
  348. package/mcp-server/dist/tools/git-tools.js +107 -0
  349. package/mcp-server/dist/tools/git-tools.js.map +1 -0
  350. package/mcp-server/dist/tools/git.d.ts +7 -0
  351. package/mcp-server/dist/tools/git.d.ts.map +1 -0
  352. package/mcp-server/dist/tools/git.js +11 -0
  353. package/mcp-server/dist/tools/git.js.map +1 -0
  354. package/mcp-server/dist/tools/gsc/experience.d.ts +135 -0
  355. package/mcp-server/dist/tools/gsc/experience.d.ts.map +1 -0
  356. package/mcp-server/dist/tools/gsc/experience.js +351 -0
  357. package/mcp-server/dist/tools/gsc/experience.js.map +1 -0
  358. package/mcp-server/dist/tools/gsc/helpers.d.ts +78 -0
  359. package/mcp-server/dist/tools/gsc/helpers.d.ts.map +1 -0
  360. package/mcp-server/dist/tools/gsc/helpers.js +258 -0
  361. package/mcp-server/dist/tools/gsc/helpers.js.map +1 -0
  362. package/mcp-server/dist/tools/gsc/indexing.d.ts +121 -0
  363. package/mcp-server/dist/tools/gsc/indexing.d.ts.map +1 -0
  364. package/mcp-server/dist/tools/gsc/indexing.js +357 -0
  365. package/mcp-server/dist/tools/gsc/indexing.js.map +1 -0
  366. package/mcp-server/dist/tools/gsc/inspect.d.ts +78 -0
  367. package/mcp-server/dist/tools/gsc/inspect.d.ts.map +1 -0
  368. package/mcp-server/dist/tools/gsc/inspect.js +321 -0
  369. package/mcp-server/dist/tools/gsc/inspect.js.map +1 -0
  370. package/mcp-server/dist/tools/gsc/navigate.d.ts +44 -0
  371. package/mcp-server/dist/tools/gsc/navigate.d.ts.map +1 -0
  372. package/mcp-server/dist/tools/gsc/navigate.js +197 -0
  373. package/mcp-server/dist/tools/gsc/navigate.js.map +1 -0
  374. package/mcp-server/dist/tools/gsc/performance.d.ts +84 -0
  375. package/mcp-server/dist/tools/gsc/performance.d.ts.map +1 -0
  376. package/mcp-server/dist/tools/gsc/performance.js +274 -0
  377. package/mcp-server/dist/tools/gsc/performance.js.map +1 -0
  378. package/mcp-server/dist/tools/gsc/settings.d.ts +153 -0
  379. package/mcp-server/dist/tools/gsc/settings.d.ts.map +1 -0
  380. package/mcp-server/dist/tools/gsc/settings.js +425 -0
  381. package/mcp-server/dist/tools/gsc/settings.js.map +1 -0
  382. package/mcp-server/dist/tools/gsc.d.ts +7 -0
  383. package/mcp-server/dist/tools/gsc.d.ts.map +1 -0
  384. package/mcp-server/dist/tools/gsc.js +51 -0
  385. package/mcp-server/dist/tools/gsc.js.map +1 -0
  386. package/mcp-server/dist/tools/image-tools.d.ts +24 -0
  387. package/mcp-server/dist/tools/image-tools.d.ts.map +1 -0
  388. package/mcp-server/dist/tools/image-tools.js +80 -0
  389. package/mcp-server/dist/tools/image-tools.js.map +1 -0
  390. package/mcp-server/dist/tools/image.d.ts +10 -0
  391. package/mcp-server/dist/tools/image.d.ts.map +1 -0
  392. package/mcp-server/dist/tools/image.js +14 -0
  393. package/mcp-server/dist/tools/image.js.map +1 -0
  394. package/mcp-server/dist/tools/leonardo-browser-tools.d.ts +97 -0
  395. package/mcp-server/dist/tools/leonardo-browser-tools.d.ts.map +1 -0
  396. package/mcp-server/dist/tools/leonardo-browser-tools.js +228 -0
  397. package/mcp-server/dist/tools/leonardo-browser-tools.js.map +1 -0
  398. package/mcp-server/dist/tools/leonardo.d.ts +13 -0
  399. package/mcp-server/dist/tools/leonardo.d.ts.map +1 -0
  400. package/mcp-server/dist/tools/leonardo.js +21 -0
  401. package/mcp-server/dist/tools/leonardo.js.map +1 -0
  402. package/mcp-server/dist/tools/loop.d.ts +30 -0
  403. package/mcp-server/dist/tools/loop.d.ts.map +1 -0
  404. package/mcp-server/dist/tools/loop.js +401 -0
  405. package/mcp-server/dist/tools/loop.js.map +1 -0
  406. package/mcp-server/dist/tools/memories.d.ts +56 -0
  407. package/mcp-server/dist/tools/memories.d.ts.map +1 -0
  408. package/mcp-server/dist/tools/memories.js +171 -0
  409. package/mcp-server/dist/tools/memories.js.map +1 -0
  410. package/mcp-server/dist/tools/morelogin.d.ts +24 -0
  411. package/mcp-server/dist/tools/morelogin.d.ts.map +1 -0
  412. package/mcp-server/dist/tools/morelogin.js +79 -0
  413. package/mcp-server/dist/tools/morelogin.js.map +1 -0
  414. package/mcp-server/dist/tools/profile.d.ts +17 -0
  415. package/mcp-server/dist/tools/profile.d.ts.map +1 -0
  416. package/mcp-server/dist/tools/profile.js +114 -0
  417. package/mcp-server/dist/tools/profile.js.map +1 -0
  418. package/mcp-server/dist/tools/recall.d.ts +71 -0
  419. package/mcp-server/dist/tools/recall.d.ts.map +1 -0
  420. package/mcp-server/dist/tools/recall.js +147 -0
  421. package/mcp-server/dist/tools/recall.js.map +1 -0
  422. package/mcp-server/dist/tools/reflect.d.ts +56 -0
  423. package/mcp-server/dist/tools/reflect.d.ts.map +1 -0
  424. package/mcp-server/dist/tools/reflect.js +157 -0
  425. package/mcp-server/dist/tools/reflect.js.map +1 -0
  426. package/mcp-server/dist/tools/remember.d.ts +62 -0
  427. package/mcp-server/dist/tools/remember.d.ts.map +1 -0
  428. package/mcp-server/dist/tools/remember.js +201 -0
  429. package/mcp-server/dist/tools/remember.js.map +1 -0
  430. package/mcp-server/dist/tools/response.d.ts +23 -0
  431. package/mcp-server/dist/tools/response.d.ts.map +1 -0
  432. package/mcp-server/dist/tools/response.js +24 -0
  433. package/mcp-server/dist/tools/response.js.map +1 -0
  434. package/mcp-server/dist/tools/restore.d.ts +14 -0
  435. package/mcp-server/dist/tools/restore.d.ts.map +1 -0
  436. package/mcp-server/dist/tools/restore.js +23 -0
  437. package/mcp-server/dist/tools/restore.js.map +1 -0
  438. package/mcp-server/dist/tools/style-guide-tools.d.ts +51 -0
  439. package/mcp-server/dist/tools/style-guide-tools.d.ts.map +1 -0
  440. package/mcp-server/dist/tools/style-guide-tools.js +231 -0
  441. package/mcp-server/dist/tools/style-guide-tools.js.map +1 -0
  442. package/mcp-server/dist/tools/style-guide.d.ts +8 -0
  443. package/mcp-server/dist/tools/style-guide.d.ts.map +1 -0
  444. package/mcp-server/dist/tools/style-guide.js +12 -0
  445. package/mcp-server/dist/tools/style-guide.js.map +1 -0
  446. package/mcp-server/dist/tools/sync.d.ts +20 -0
  447. package/mcp-server/dist/tools/sync.d.ts.map +1 -0
  448. package/mcp-server/dist/tools/sync.js +156 -0
  449. package/mcp-server/dist/tools/sync.js.map +1 -0
  450. package/mcp-server/dist/tools/tictactoe-tools.d.ts +18 -0
  451. package/mcp-server/dist/tools/tictactoe-tools.d.ts.map +1 -0
  452. package/mcp-server/dist/tools/tictactoe-tools.js +78 -0
  453. package/mcp-server/dist/tools/tictactoe-tools.js.map +1 -0
  454. package/mcp-server/dist/tools/tictactoe.d.ts +7 -0
  455. package/mcp-server/dist/tools/tictactoe.d.ts.map +1 -0
  456. package/mcp-server/dist/tools/tictactoe.js +11 -0
  457. package/mcp-server/dist/tools/tictactoe.js.map +1 -0
  458. package/mcp-server/dist/tools/utils.d.ts +19 -0
  459. package/mcp-server/dist/tools/utils.d.ts.map +1 -0
  460. package/mcp-server/dist/tools/utils.js +54 -0
  461. package/mcp-server/dist/tools/utils.js.map +1 -0
  462. package/mcp-server/dist/tools/whiteboard-format.d.ts +88 -0
  463. package/mcp-server/dist/tools/whiteboard-format.d.ts.map +1 -0
  464. package/mcp-server/dist/tools/whiteboard-format.js +337 -0
  465. package/mcp-server/dist/tools/whiteboard-format.js.map +1 -0
  466. package/mcp-server/dist/tools/whiteboard-tools.d.ts +326 -0
  467. package/mcp-server/dist/tools/whiteboard-tools.d.ts.map +1 -0
  468. package/mcp-server/dist/tools/whiteboard-tools.js +222 -0
  469. package/mcp-server/dist/tools/whiteboard-tools.js.map +1 -0
  470. package/mcp-server/dist/tools/whiteboard.d.ts +8 -0
  471. package/mcp-server/dist/tools/whiteboard.d.ts.map +1 -0
  472. package/mcp-server/dist/tools/whiteboard.js +16 -0
  473. package/mcp-server/dist/tools/whiteboard.js.map +1 -0
  474. package/mcp-server/dist/tools/youtube/analytics.d.ts +46 -0
  475. package/mcp-server/dist/tools/youtube/analytics.d.ts.map +1 -0
  476. package/mcp-server/dist/tools/youtube/analytics.js +83 -0
  477. package/mcp-server/dist/tools/youtube/analytics.js.map +1 -0
  478. package/mcp-server/dist/tools/youtube/dedup.d.ts +35 -0
  479. package/mcp-server/dist/tools/youtube/dedup.d.ts.map +1 -0
  480. package/mcp-server/dist/tools/youtube/dedup.js +56 -0
  481. package/mcp-server/dist/tools/youtube/dedup.js.map +1 -0
  482. package/mcp-server/dist/tools/youtube/download.d.ts +31 -0
  483. package/mcp-server/dist/tools/youtube/download.d.ts.map +1 -0
  484. package/mcp-server/dist/tools/youtube/download.js +30 -0
  485. package/mcp-server/dist/tools/youtube/download.js.map +1 -0
  486. package/mcp-server/dist/tools/youtube/helpers.d.ts +66 -0
  487. package/mcp-server/dist/tools/youtube/helpers.d.ts.map +1 -0
  488. package/mcp-server/dist/tools/youtube/helpers.js +143 -0
  489. package/mcp-server/dist/tools/youtube/helpers.js.map +1 -0
  490. package/mcp-server/dist/tools/youtube/media.d.ts +43 -0
  491. package/mcp-server/dist/tools/youtube/media.d.ts.map +1 -0
  492. package/mcp-server/dist/tools/youtube/media.js +97 -0
  493. package/mcp-server/dist/tools/youtube/media.js.map +1 -0
  494. package/mcp-server/dist/tools/youtube/metadata.d.ts +33 -0
  495. package/mcp-server/dist/tools/youtube/metadata.d.ts.map +1 -0
  496. package/mcp-server/dist/tools/youtube/metadata.js +106 -0
  497. package/mcp-server/dist/tools/youtube/metadata.js.map +1 -0
  498. package/mcp-server/dist/tools/youtube/navigate.d.ts +30 -0
  499. package/mcp-server/dist/tools/youtube/navigate.d.ts.map +1 -0
  500. package/mcp-server/dist/tools/youtube/navigate.js +71 -0
  501. package/mcp-server/dist/tools/youtube/navigate.js.map +1 -0
  502. package/mcp-server/dist/tools/youtube/playlist.d.ts +29 -0
  503. package/mcp-server/dist/tools/youtube/playlist.d.ts.map +1 -0
  504. package/mcp-server/dist/tools/youtube/playlist.js +128 -0
  505. package/mcp-server/dist/tools/youtube/playlist.js.map +1 -0
  506. package/mcp-server/dist/tools/youtube/schedule.d.ts +31 -0
  507. package/mcp-server/dist/tools/youtube/schedule.d.ts.map +1 -0
  508. package/mcp-server/dist/tools/youtube/schedule.js +147 -0
  509. package/mcp-server/dist/tools/youtube/schedule.js.map +1 -0
  510. package/mcp-server/dist/tools/youtube/source.d.ts +36 -0
  511. package/mcp-server/dist/tools/youtube/source.d.ts.map +1 -0
  512. package/mcp-server/dist/tools/youtube/source.js +85 -0
  513. package/mcp-server/dist/tools/youtube/source.js.map +1 -0
  514. package/mcp-server/dist/tools/youtube/upload.d.ts +53 -0
  515. package/mcp-server/dist/tools/youtube/upload.d.ts.map +1 -0
  516. package/mcp-server/dist/tools/youtube/upload.js +255 -0
  517. package/mcp-server/dist/tools/youtube/upload.js.map +1 -0
  518. package/mcp-server/dist/tools/youtube.d.ts +12 -0
  519. package/mcp-server/dist/tools/youtube.d.ts.map +1 -0
  520. package/mcp-server/dist/tools/youtube.js +38 -0
  521. package/mcp-server/dist/tools/youtube.js.map +1 -0
  522. package/mcp-server/dist/tui.d.ts +3 -0
  523. package/mcp-server/dist/tui.d.ts.map +1 -0
  524. package/mcp-server/dist/tui.js +806 -0
  525. package/mcp-server/dist/tui.js.map +1 -0
  526. package/mcp-server/dist/types.d.ts +77 -0
  527. package/mcp-server/dist/types.d.ts.map +1 -0
  528. package/mcp-server/dist/types.js +2 -0
  529. package/mcp-server/dist/types.js.map +1 -0
  530. package/mcp-server/package-lock.json +4798 -0
  531. package/mcp-server/package.json +55 -38
  532. package/mcp-server/run.mjs +12 -2
  533. package/mcp-server/src/config.ts +48 -3
  534. package/mcp-server/src/http.ts +296 -93
  535. package/mcp-server/src/index.ts +546 -203
  536. package/mcp-server/src/preload-http.ts +19 -18
  537. package/mcp-server/src/preload.ts +19 -18
  538. package/mcp-server/src/scripts/setup-embeddings.ts +9 -0
  539. package/mcp-server/src/services/assistant-judgments.ts +157 -0
  540. package/mcp-server/src/services/browser-assist-gate.ts +383 -0
  541. package/mcp-server/src/services/browser-assist.ts +267 -0
  542. package/mcp-server/src/services/browser-bench.ts +477 -0
  543. package/mcp-server/src/services/browser-judgments.ts +414 -0
  544. package/mcp-server/src/services/browser-risk.ts +484 -0
  545. package/mcp-server/src/services/categories.ts +36 -19
  546. package/mcp-server/src/services/codex-config-heal.ts +403 -0
  547. package/mcp-server/src/services/desktop-assist-gate.ts +251 -0
  548. package/mcp-server/src/services/desktop-assist.ts +308 -0
  549. package/mcp-server/src/services/desktop-bench.ts +372 -0
  550. package/mcp-server/src/services/desktop-client.ts +76 -0
  551. package/mcp-server/src/services/desktop-judgments.ts +218 -0
  552. package/mcp-server/src/services/desktop-risk.ts +743 -0
  553. package/mcp-server/src/services/edit-stale.ts +299 -0
  554. package/mcp-server/src/services/embedding-service.ts +108 -0
  555. package/mcp-server/src/services/embedding-worker.ts +46 -0
  556. package/mcp-server/src/services/fb-regions.ts +221 -0
  557. package/mcp-server/src/services/file-checksums.ts +26 -9
  558. package/mcp-server/src/services/file-excerpt.ts +59 -0
  559. package/mcp-server/src/services/identity.ts +291 -0
  560. package/mcp-server/src/services/local-embeddings.ts +2 -77
  561. package/mcp-server/src/services/memory-client.ts +23 -0
  562. package/mcp-server/src/services/memory-judge-backfill.ts +462 -0
  563. package/mcp-server/src/services/memory-judgments.ts +901 -0
  564. package/mcp-server/src/services/memory-maintenance.ts +360 -0
  565. package/mcp-server/src/services/memory-retrieval.ts +349 -0
  566. package/mcp-server/src/services/memory-schema.ts +280 -0
  567. package/mcp-server/src/services/memory-sessions.ts +87 -0
  568. package/mcp-server/src/services/memory-triage.ts +182 -0
  569. package/mcp-server/src/services/memory-verification.ts +68 -0
  570. package/mcp-server/src/services/memory-writer.ts +125 -0
  571. package/mcp-server/src/services/neural-interface.ts +1217 -73
  572. package/mcp-server/src/services/profiles.ts +428 -0
  573. package/mcp-server/src/services/secret-gate.ts +52 -0
  574. package/mcp-server/src/services/server-instructions.ts +122 -0
  575. package/mcp-server/src/services/sqlite.ts +1456 -823
  576. package/mcp-server/src/services/typesafe-bench.ts +247 -0
  577. package/mcp-server/src/services/typesafe-config.ts +790 -0
  578. package/mcp-server/src/services/typesafe.ts +390 -0
  579. package/mcp-server/src/services/vector-cache.ts +255 -0
  580. package/mcp-server/src/services/whiteboard-geometry.ts +711 -0
  581. package/mcp-server/src/tools/agents.ts +539 -0
  582. package/mcp-server/src/tools/bluesky.ts +1186 -0
  583. package/mcp-server/src/tools/browser-advanced.ts +15 -6
  584. package/mcp-server/src/tools/browser-batch.ts +178 -0
  585. package/mcp-server/src/tools/browser-cheatsheet.ts +155 -0
  586. package/mcp-server/src/tools/browser-interact.ts +362 -255
  587. package/mcp-server/src/tools/browser-navigate.ts +164 -77
  588. package/mcp-server/src/tools/browser-observe.ts +2222 -1330
  589. package/mcp-server/src/tools/browser.ts +181 -107
  590. package/mcp-server/src/tools/card.ts +7 -5
  591. package/mcp-server/src/tools/choice.ts +103 -0
  592. package/mcp-server/src/tools/computer.ts +190 -0
  593. package/mcp-server/src/tools/discord.ts +10 -23
  594. package/mcp-server/src/tools/fb-groups.ts +387 -0
  595. package/mcp-server/src/tools/forget.ts +1 -1
  596. package/mcp-server/src/tools/git.ts +3 -1
  597. package/mcp-server/src/tools/gsc/experience.ts +440 -0
  598. package/mcp-server/src/tools/gsc/helpers.ts +288 -0
  599. package/mcp-server/src/tools/gsc/indexing.ts +495 -0
  600. package/mcp-server/src/tools/gsc/inspect.ts +391 -0
  601. package/mcp-server/src/tools/gsc/navigate.ts +236 -0
  602. package/mcp-server/src/tools/gsc/performance.ts +352 -0
  603. package/mcp-server/src/tools/gsc/settings.ts +564 -0
  604. package/mcp-server/src/tools/gsc.ts +95 -0
  605. package/mcp-server/src/tools/image.ts +3 -1
  606. package/mcp-server/src/tools/leonardo-browser-tools.ts +47 -37
  607. package/mcp-server/src/tools/leonardo.ts +7 -5
  608. package/mcp-server/src/tools/loop.ts +118 -25
  609. package/mcp-server/src/tools/memories.ts +65 -5
  610. package/mcp-server/src/tools/morelogin.ts +81 -0
  611. package/mcp-server/src/tools/profile.ts +122 -0
  612. package/mcp-server/src/tools/recall.ts +105 -261
  613. package/mcp-server/src/tools/reflect.ts +171 -145
  614. package/mcp-server/src/tools/remember.ts +223 -115
  615. package/mcp-server/src/tools/style-guide-tools.ts +250 -0
  616. package/mcp-server/src/tools/style-guide.ts +16 -0
  617. package/mcp-server/src/tools/sync.ts +66 -9
  618. package/mcp-server/src/tools/tictactoe.ts +3 -1
  619. package/mcp-server/src/tools/utils.ts +22 -0
  620. package/mcp-server/src/tools/whiteboard-format.ts +394 -0
  621. package/mcp-server/src/tools/whiteboard-tools.ts +191 -183
  622. package/mcp-server/src/tools/whiteboard.ts +7 -5
  623. package/mcp-server/src/tools/youtube/analytics.ts +106 -0
  624. package/mcp-server/src/tools/youtube/dedup.ts +57 -0
  625. package/mcp-server/src/tools/youtube/download.ts +41 -0
  626. package/mcp-server/src/tools/youtube/helpers.ts +183 -0
  627. package/mcp-server/src/tools/youtube/media.ts +109 -0
  628. package/mcp-server/src/tools/youtube/metadata.ts +112 -0
  629. package/mcp-server/src/tools/youtube/navigate.ts +81 -0
  630. package/mcp-server/src/tools/youtube/playlist.ts +134 -0
  631. package/mcp-server/src/tools/youtube/schedule.ts +158 -0
  632. package/mcp-server/src/tools/youtube/source.ts +101 -0
  633. package/mcp-server/src/tools/youtube/upload.ts +296 -0
  634. package/mcp-server/src/tools/youtube.ts +47 -0
  635. package/mcp-server/src/tui.ts +8 -9
  636. package/neural-interface/games/TicTacToe/1.svg +1 -0
  637. package/neural-interface/games/TicTacToe/2.svg +1 -0
  638. package/neural-interface/games/TicTacToe/3.svg +1 -0
  639. package/neural-interface/games/TicTacToe/4.svg +1 -0
  640. package/neural-interface/games/TicTacToe/5.svg +1 -0
  641. package/neural-interface/games/TicTacToe/6.svg +1 -0
  642. package/neural-interface/games/TicTacToe/7.svg +1 -0
  643. package/neural-interface/games/TicTacToe/8.svg +1 -0
  644. package/neural-interface/games/TicTacToe/9.svg +1 -0
  645. package/neural-interface/games/TicTacToe/Board.svg +1 -0
  646. package/neural-interface/games/TicTacToe/Circle.svg +1 -0
  647. package/neural-interface/games/TicTacToe/Cross.svg +1 -0
  648. package/neural-interface/i18n/en.json +7022 -0
  649. package/neural-interface/i18n/pt-BR.json +7026 -0
  650. package/neural-interface/lib/assistant-api.js +1005 -0
  651. package/neural-interface/lib/assistant-attachments.js +121 -0
  652. package/neural-interface/lib/assistant-brains/claude.js +207 -0
  653. package/neural-interface/lib/assistant-brains/codex-browser-policy-hook.mjs +43 -0
  654. package/neural-interface/lib/assistant-brains/codex-route-gate-hook.mjs +56 -0
  655. package/neural-interface/lib/assistant-brains/codex.js +213 -0
  656. package/neural-interface/lib/assistant-brains/opencode-browser-policy.js +47 -0
  657. package/neural-interface/lib/assistant-brains/opencode-route-gate.js +62 -0
  658. package/neural-interface/lib/assistant-brains/opencode.js +320 -0
  659. package/neural-interface/lib/assistant-budget.js +318 -0
  660. package/neural-interface/lib/assistant-catalog.js +731 -0
  661. package/neural-interface/lib/assistant-clarify.js +664 -0
  662. package/neural-interface/lib/assistant-config.js +232 -0
  663. package/neural-interface/lib/assistant-dispatch.js +2744 -0
  664. package/neural-interface/lib/assistant-envelope.js +582 -0
  665. package/neural-interface/lib/assistant-evidence.js +236 -0
  666. package/neural-interface/lib/assistant-hidden-models.js +272 -0
  667. package/neural-interface/lib/assistant-jev.js +117 -0
  668. package/neural-interface/lib/assistant-judgments.js +111 -0
  669. package/neural-interface/lib/assistant-media.js +335 -0
  670. package/neural-interface/lib/assistant-memory.js +398 -0
  671. package/neural-interface/lib/assistant-persona.js +444 -0
  672. package/neural-interface/lib/assistant-plan-permissions.js +448 -0
  673. package/neural-interface/lib/assistant-playbooks/design.md +87 -0
  674. package/neural-interface/lib/assistant-playbooks.js +72 -0
  675. package/neural-interface/lib/assistant-pricing.js +159 -0
  676. package/neural-interface/lib/assistant-route-gate-codex.js +163 -0
  677. package/neural-interface/lib/assistant-route-gate.js +212 -0
  678. package/neural-interface/lib/assistant-router.js +1324 -0
  679. package/neural-interface/lib/assistant-runtime.js +3337 -0
  680. package/neural-interface/lib/assistant-task-prompt.js +472 -0
  681. package/neural-interface/lib/assistant-usage.js +1688 -0
  682. package/neural-interface/lib/augmented-path.js +70 -0
  683. package/neural-interface/lib/automation-storage-migration.js +54 -0
  684. package/neural-interface/lib/backup-service.js +851 -0
  685. package/neural-interface/lib/backup-zip-reader.js +262 -0
  686. package/neural-interface/lib/browser-assist-api.js +41 -0
  687. package/neural-interface/lib/browser-console.js +176 -0
  688. package/neural-interface/lib/browser-execution.js +241 -0
  689. package/neural-interface/lib/browser-extraction.js +191 -0
  690. package/neural-interface/lib/browser-language.js +83 -0
  691. package/neural-interface/lib/browser-screenshot.js +399 -0
  692. package/neural-interface/lib/browser-semantic-context.js +639 -0
  693. package/neural-interface/lib/browser-snapshots.js +192 -0
  694. package/neural-interface/lib/browser-tab-recovery.js +119 -0
  695. package/neural-interface/lib/browser-targets.js +70 -0
  696. package/neural-interface/lib/browser-tool-policy.js +926 -0
  697. package/neural-interface/lib/claude-accounts.js +230 -0
  698. package/neural-interface/lib/claude-agent-bridge.js +3203 -0
  699. package/neural-interface/lib/claude-bypass-policy.js +99 -0
  700. package/neural-interface/lib/claude-executable.js +241 -0
  701. package/neural-interface/lib/claude-history.js +429 -0
  702. package/neural-interface/lib/claude-model-catalog.js +444 -0
  703. package/neural-interface/lib/claude-panel-requests.js +165 -0
  704. package/neural-interface/lib/claude-panel-session.js +272 -0
  705. package/neural-interface/lib/claude-permission-rules.js +153 -0
  706. package/neural-interface/lib/claude-session-cleanup.js +71 -0
  707. package/neural-interface/lib/claude-session-list.js +82 -0
  708. package/neural-interface/lib/claude-session-ops.js +140 -0
  709. package/neural-interface/lib/claude-settings-view.js +51 -0
  710. package/neural-interface/lib/claude-skin-connect.js +79 -0
  711. package/neural-interface/lib/claude-stall-policy.js +7 -0
  712. package/neural-interface/lib/claude-temporary.js +435 -0
  713. package/neural-interface/lib/cli-update-planner.js +312 -0
  714. package/neural-interface/lib/codex-capabilities.d.ts +41 -0
  715. package/neural-interface/lib/codex-capabilities.js +148 -0
  716. package/neural-interface/lib/codex-collaboration-mode.js +17 -0
  717. package/neural-interface/lib/codex-compat-rpc.js +241 -0
  718. package/neural-interface/lib/codex-mcp-approvals.js +56 -0
  719. package/neural-interface/lib/codex-mcp-apps.js +47 -0
  720. package/neural-interface/lib/codex-model-context.js +202 -0
  721. package/neural-interface/lib/codex-plan-store.js +71 -0
  722. package/neural-interface/lib/codex-request-journal.js +242 -0
  723. package/neural-interface/lib/codex-runtime-path.js +213 -0
  724. package/neural-interface/lib/codex-session-catalog.js +231 -0
  725. package/neural-interface/lib/codex-session-settings.js +46 -0
  726. package/neural-interface/lib/codex-sidepanel-permissions.js +110 -0
  727. package/neural-interface/lib/codex-thread-history.js +165 -0
  728. package/neural-interface/lib/codex-user-verification.js +34 -0
  729. package/neural-interface/lib/codex-writer-lifecycle.js +152 -0
  730. package/neural-interface/lib/confined-fs.js +256 -0
  731. package/neural-interface/lib/db.js +922 -0
  732. package/neural-interface/lib/design-md.js +9 -0
  733. package/neural-interface/lib/desktop/api.js +92 -0
  734. package/neural-interface/lib/desktop/audit.js +62 -0
  735. package/neural-interface/lib/desktop/build.js +423 -0
  736. package/neural-interface/lib/desktop/config.js +606 -0
  737. package/neural-interface/lib/desktop/coords.js +76 -0
  738. package/neural-interface/lib/desktop/fake-helper.js +1192 -0
  739. package/neural-interface/lib/desktop/frames.js +77 -0
  740. package/neural-interface/lib/desktop/grants.js +84 -0
  741. package/neural-interface/lib/desktop/guards.js +170 -0
  742. package/neural-interface/lib/desktop/helper/SynabunDesktop.swift +3056 -0
  743. package/neural-interface/lib/desktop/lease.js +51 -0
  744. package/neural-interface/lib/desktop/manager.js +545 -0
  745. package/neural-interface/lib/desktop/press-contexts.js +103 -0
  746. package/neural-interface/lib/desktop/protocol.js +495 -0
  747. package/neural-interface/lib/desktop/service.js +1202 -0
  748. package/neural-interface/lib/effort-levels.js +148 -0
  749. package/neural-interface/lib/event-loop-monitor.js +67 -0
  750. package/neural-interface/lib/exec-loop-command.js +209 -0
  751. package/neural-interface/lib/folder-picker.ps1 +77 -0
  752. package/neural-interface/lib/http-guards.js +287 -0
  753. package/neural-interface/lib/jsonl-lines.js +94 -0
  754. package/neural-interface/lib/loop-logger.js +127 -0
  755. package/neural-interface/lib/mcp-client-config.js +133 -0
  756. package/neural-interface/lib/mcp-installer.js +487 -0
  757. package/neural-interface/lib/mcp-profile-refresh-coordinator.js +78 -0
  758. package/neural-interface/lib/mcp-profile-servers.js +120 -0
  759. package/neural-interface/lib/memo-cache.js +84 -0
  760. package/neural-interface/lib/memory-api.js +758 -0
  761. package/neural-interface/lib/memory-map-api.js +1150 -0
  762. package/neural-interface/lib/memory-map-layout.js +872 -0
  763. package/neural-interface/lib/memory-map-worker.js +165 -0
  764. package/neural-interface/lib/memory-session-capture.js +81 -0
  765. package/neural-interface/lib/memory-timers.js +62 -0
  766. package/neural-interface/lib/morelogin.js +301 -0
  767. package/neural-interface/lib/native-binary-runtime.js +382 -0
  768. package/neural-interface/lib/native-loop-goal.js +33 -0
  769. package/neural-interface/lib/native-loop-providers.js +1002 -0
  770. package/neural-interface/lib/native-loop-runtime.js +747 -0
  771. package/neural-interface/lib/offline-page.js +54 -0
  772. package/neural-interface/lib/opencode-hidden-models.js +113 -0
  773. package/neural-interface/lib/opencode-history.js +253 -0
  774. package/neural-interface/lib/opencode-runtime-config.js +58 -0
  775. package/neural-interface/lib/opencode-v2-client.js +486 -0
  776. package/neural-interface/lib/opencode-v2-ws-requests.js +955 -0
  777. package/neural-interface/lib/path-confine.js +213 -0
  778. package/neural-interface/lib/plugin-installer.js +264 -0
  779. package/neural-interface/lib/project-storage.js +766 -0
  780. package/neural-interface/lib/pty-host/core.js +603 -0
  781. package/neural-interface/lib/pty-host/flow.js +43 -0
  782. package/neural-interface/lib/pty-host/host.js +47 -0
  783. package/neural-interface/lib/pty-host/manager.js +360 -0
  784. package/neural-interface/lib/pty-host/protocol.js +81 -0
  785. package/neural-interface/lib/pty-host/snapshot.js +133 -0
  786. package/neural-interface/lib/remote-policy.js +582 -0
  787. package/neural-interface/lib/rulesets/api.js +175 -0
  788. package/neural-interface/lib/rulesets/fs-safe.js +245 -0
  789. package/neural-interface/lib/rulesets/installer.js +1453 -0
  790. package/neural-interface/lib/rulesets/json-edit.js +186 -0
  791. package/neural-interface/lib/rulesets/lock.js +170 -0
  792. package/neural-interface/lib/rulesets/managed-text.js +314 -0
  793. package/neural-interface/lib/rulesets/normalise.js +24 -0
  794. package/neural-interface/lib/rulesets/render.js +84 -0
  795. package/neural-interface/lib/schedule-launch-intent.js +40 -0
  796. package/neural-interface/lib/session-cache-builder.js +524 -0
  797. package/neural-interface/lib/session-chunker.js +344 -0
  798. package/neural-interface/lib/session-indexer.js +327 -0
  799. package/neural-interface/lib/session-title-generator.js +232 -0
  800. package/neural-interface/lib/skill-prompt-bridge.js +11 -0
  801. package/neural-interface/lib/style-guide/api.js +375 -0
  802. package/neural-interface/lib/style-guide/color.js +352 -0
  803. package/neural-interface/lib/style-guide/export-css.js +99 -0
  804. package/neural-interface/lib/style-guide/export-dtcg.js +209 -0
  805. package/neural-interface/lib/style-guide/export-tailwind.js +102 -0
  806. package/neural-interface/lib/style-guide/fonts.json +227 -0
  807. package/neural-interface/lib/style-guide/import.js +1268 -0
  808. package/neural-interface/lib/style-guide/pointers.js +103 -0
  809. package/neural-interface/lib/style-guide/presets.js +232 -0
  810. package/neural-interface/lib/style-guide/render-design-md.js +319 -0
  811. package/neural-interface/lib/style-guide/schema.js +848 -0
  812. package/neural-interface/lib/style-guide/security.js +43 -0
  813. package/neural-interface/lib/style-guide/store.js +491 -0
  814. package/neural-interface/lib/style-guide/summary.js +106 -0
  815. package/neural-interface/lib/style-guide/tokens.js +170 -0
  816. package/neural-interface/lib/synabun-update-plan.js +324 -0
  817. package/neural-interface/lib/synabun-version.js +179 -0
  818. package/neural-interface/lib/system-restore.js +99 -0
  819. package/neural-interface/lib/terminal-env.js +86 -0
  820. package/neural-interface/lib/ui-blob-store.js +106 -0
  821. package/neural-interface/lib/vector-cache.js +2 -0
  822. package/neural-interface/lib/virtual-socket.js +60 -0
  823. package/neural-interface/lib/whatsapp/api.js +146 -0
  824. package/neural-interface/lib/whatsapp/auth-store.js +389 -0
  825. package/neural-interface/lib/whatsapp/baileys-adapter.js +457 -0
  826. package/neural-interface/lib/whatsapp/brain.js +128 -0
  827. package/neural-interface/lib/whatsapp/bridge.js +1499 -0
  828. package/neural-interface/lib/whatsapp/cards.js +519 -0
  829. package/neural-interface/lib/whatsapp/commands.js +92 -0
  830. package/neural-interface/lib/whatsapp/config.js +291 -0
  831. package/neural-interface/lib/whatsapp/connector/entry.mjs +25 -0
  832. package/neural-interface/lib/whatsapp/connector/manifest.json +6 -0
  833. package/neural-interface/lib/whatsapp/connector/npm-shrinkwrap.json +717 -0
  834. package/neural-interface/lib/whatsapp/connector/package.json +8 -0
  835. package/neural-interface/lib/whatsapp/fake-baileys.js +444 -0
  836. package/neural-interface/lib/whatsapp/format.js +552 -0
  837. package/neural-interface/lib/whatsapp/host-core.js +1225 -0
  838. package/neural-interface/lib/whatsapp/host.js +119 -0
  839. package/neural-interface/lib/whatsapp/identity.js +288 -0
  840. package/neural-interface/lib/whatsapp/inbound.js +149 -0
  841. package/neural-interface/lib/whatsapp/installer.js +562 -0
  842. package/neural-interface/lib/whatsapp/manager.js +638 -0
  843. package/neural-interface/lib/whatsapp/paths.js +81 -0
  844. package/neural-interface/lib/whatsapp/protocol.js +327 -0
  845. package/neural-interface/lib/whatsapp/qr-svg.js +57 -0
  846. package/neural-interface/lib/whatsapp/redact.js +130 -0
  847. package/neural-interface/lib/whatsapp/service.js +1305 -0
  848. package/neural-interface/lib/whatsapp/vendor/qrcodegen.js +848 -0
  849. package/neural-interface/package-lock.json +4431 -0
  850. package/neural-interface/package.json +58 -27
  851. package/neural-interface/public/apple-touch-icon.png +0 -0
  852. package/neural-interface/public/category-logos/synabun.png +0 -0
  853. package/neural-interface/public/claude.svg +1 -0
  854. package/neural-interface/public/favicon-16x16.png +0 -0
  855. package/neural-interface/public/favicon-32x32.png +0 -0
  856. package/neural-interface/public/icon-192.png +0 -0
  857. package/neural-interface/public/icon-512.png +0 -0
  858. package/neural-interface/public/index.html +32 -182
  859. package/neural-interface/public/index2d.html +2 -2
  860. package/neural-interface/public/install-app.html +31 -0
  861. package/neural-interface/public/logo-synabun.png +0 -0
  862. package/neural-interface/public/logoHD.png +0 -0
  863. package/neural-interface/public/manifest.json +2 -0
  864. package/neural-interface/public/mcp.svg +4 -0
  865. package/neural-interface/public/offline.html +670 -299
  866. package/neural-interface/public/onboarding.html +804 -161
  867. package/neural-interface/public/opencode-logo-dark-square.svg +1 -0
  868. package/neural-interface/public/shared/agent-runtime-options.js +596 -0
  869. package/neural-interface/public/shared/api.js +339 -28
  870. package/neural-interface/public/shared/assistant/asst-accounts.js +318 -0
  871. package/neural-interface/public/shared/assistant/asst-agents-dock.js +296 -0
  872. package/neural-interface/public/shared/assistant/asst-api.js +270 -0
  873. package/neural-interface/public/shared/assistant/asst-brain-picker.js +744 -0
  874. package/neural-interface/public/shared/assistant/asst-budget.js +333 -0
  875. package/neural-interface/public/shared/assistant/asst-composer.js +656 -0
  876. package/neural-interface/public/shared/assistant/asst-computer.js +803 -0
  877. package/neural-interface/public/shared/assistant/asst-control.js +1018 -0
  878. package/neural-interface/public/shared/assistant/asst-hosts.js +262 -0
  879. package/neural-interface/public/shared/assistant/asst-mascot.js +313 -0
  880. package/neural-interface/public/shared/assistant/asst-menu.js +375 -0
  881. package/neural-interface/public/shared/assistant/asst-panel.js +1845 -0
  882. package/neural-interface/public/shared/assistant/asst-rack-styles.js +586 -0
  883. package/neural-interface/public/shared/assistant/asst-render.js +3305 -0
  884. package/neural-interface/public/shared/assistant/asst-route.js +1653 -0
  885. package/neural-interface/public/shared/assistant/asst-roving.js +75 -0
  886. package/neural-interface/public/shared/assistant/asst-sanitize.js +117 -0
  887. package/neural-interface/public/shared/assistant/asst-sidepanel-styles.js +488 -0
  888. package/neural-interface/public/shared/assistant/asst-sidepanel.js +675 -0
  889. package/neural-interface/public/shared/assistant/asst-slash.js +258 -0
  890. package/neural-interface/public/shared/assistant/asst-state.js +727 -0
  891. package/neural-interface/public/shared/assistant/asst-styles.js +1686 -0
  892. package/neural-interface/public/shared/assistant/asst-tool-kinds.js +1017 -0
  893. package/neural-interface/public/shared/assistant/asst-usage.js +444 -0
  894. package/neural-interface/public/shared/assistant/asst-ws.js +175 -0
  895. package/neural-interface/public/shared/automation-context.js +75 -0
  896. package/neural-interface/public/shared/blob-store.js +99 -0
  897. package/neural-interface/public/shared/cdx/cdx-capabilities.js +118 -0
  898. package/neural-interface/public/shared/cdx/cdx-cards.js +37 -0
  899. package/neural-interface/public/shared/cdx/cdx-commands.js +171 -0
  900. package/neural-interface/public/shared/cdx/cdx-context-menu.js +402 -0
  901. package/neural-interface/public/shared/cdx/cdx-context-model.js +220 -0
  902. package/neural-interface/public/shared/cdx/cdx-features.js +408 -0
  903. package/neural-interface/public/shared/cdx/cdx-icons.js +89 -0
  904. package/neural-interface/public/shared/cdx/cdx-mcp-app-host.js +414 -0
  905. package/neural-interface/public/shared/cdx/cdx-mcp-app-proxy.html +6 -0
  906. package/neural-interface/public/shared/cdx/cdx-mcp-app-proxy.js +56 -0
  907. package/neural-interface/public/shared/cdx/cdx-mcp-app.js +178 -0
  908. package/neural-interface/public/shared/cdx/cdx-model-catalog.js +120 -0
  909. package/neural-interface/public/shared/cdx/cdx-output-model.js +261 -0
  910. package/neural-interface/public/shared/cdx/cdx-output.js +382 -0
  911. package/neural-interface/public/shared/cdx/cdx-panel.js +1372 -0
  912. package/neural-interface/public/shared/cdx/cdx-plan.js +266 -0
  913. package/neural-interface/public/shared/cdx/cdx-protocol.js +682 -0
  914. package/neural-interface/public/shared/cdx/cdx-render.js +3381 -0
  915. package/neural-interface/public/shared/cdx/cdx-requests.js +1136 -0
  916. package/neural-interface/public/shared/cdx/cdx-styles.js +3251 -0
  917. package/neural-interface/public/shared/cdx/cdx-tabs.js +7992 -0
  918. package/neural-interface/public/shared/cdx/cdx-ws.js +363 -0
  919. package/neural-interface/public/shared/cli-status.js +169 -0
  920. package/neural-interface/public/shared/command-runner-model.js +30 -0
  921. package/neural-interface/public/shared/constants.js +22 -5
  922. package/neural-interface/public/shared/cp/cp-agents.js +186 -0
  923. package/neural-interface/public/shared/cp/cp-bash.js +252 -0
  924. package/neural-interface/public/shared/cp/cp-compose.js +159 -0
  925. package/neural-interface/public/shared/cp/cp-context-menu.js +309 -0
  926. package/neural-interface/public/shared/cp/cp-context-model.js +157 -0
  927. package/neural-interface/public/shared/cp/cp-context-window.js +80 -0
  928. package/neural-interface/public/shared/cp/cp-ctx.js +11 -0
  929. package/neural-interface/public/shared/cp/cp-diff.js +255 -0
  930. package/neural-interface/public/shared/cp/cp-event-rows.js +637 -0
  931. package/neural-interface/public/shared/cp/cp-events.js +846 -0
  932. package/neural-interface/public/shared/cp/cp-markdown.js +104 -0
  933. package/neural-interface/public/shared/cp/cp-permission-model.js +905 -0
  934. package/neural-interface/public/shared/cp/cp-permissions.js +626 -0
  935. package/neural-interface/public/shared/cp/cp-rehydrate.js +113 -0
  936. package/neural-interface/public/shared/cp/cp-restore.js +224 -0
  937. package/neural-interface/public/shared/cp/cp-session-model.js +338 -0
  938. package/neural-interface/public/shared/cp/cp-session-settings.js +254 -0
  939. package/neural-interface/public/shared/cp/cp-sessions.js +227 -0
  940. package/neural-interface/public/shared/cp/cp-statusline.js +153 -0
  941. package/neural-interface/public/shared/cp/cp-styles.js +349 -0
  942. package/neural-interface/public/shared/cp/cp-tasks-model.js +282 -0
  943. package/neural-interface/public/shared/cp/cp-tasks.js +107 -0
  944. package/neural-interface/public/shared/cp/cp-temporary-view.js +56 -0
  945. package/neural-interface/public/shared/cp/cp-temporary.js +231 -0
  946. package/neural-interface/public/shared/cp/cp-tool-cards.js +326 -0
  947. package/neural-interface/public/shared/cp/cp-tool-results.js +618 -0
  948. package/neural-interface/public/shared/cp/cp-usage-model.js +124 -0
  949. package/neural-interface/public/shared/graph-activity.js +68 -0
  950. package/neural-interface/public/shared/html-shell.js +116 -17
  951. package/neural-interface/public/shared/i18n.js +132 -34
  952. package/neural-interface/public/shared/node-positions-store.js +44 -0
  953. package/neural-interface/public/shared/ocp-hidden-models.js +116 -0
  954. package/neural-interface/public/shared/ocp-v2/ocp-v2-approvals.js +355 -0
  955. package/neural-interface/public/shared/ocp-v2/ocp-v2-autoaccept-button.js +35 -0
  956. package/neural-interface/public/shared/ocp-v2/ocp-v2-automation-ownership.js +72 -0
  957. package/neural-interface/public/shared/ocp-v2/ocp-v2-binding.js +280 -0
  958. package/neural-interface/public/shared/ocp-v2/ocp-v2-caps.js +67 -0
  959. package/neural-interface/public/shared/ocp-v2/ocp-v2-changes-logic.js +179 -0
  960. package/neural-interface/public/shared/ocp-v2/ocp-v2-changes.js +164 -0
  961. package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +725 -0
  962. package/neural-interface/public/shared/ocp-v2/ocp-v2-compact-button.js +75 -0
  963. package/neural-interface/public/shared/ocp-v2/ocp-v2-composer-logic.js +1204 -0
  964. package/neural-interface/public/shared/ocp-v2/ocp-v2-confirm-logic.js +117 -0
  965. package/neural-interface/public/shared/ocp-v2/ocp-v2-confirm.js +59 -0
  966. package/neural-interface/public/shared/ocp-v2/ocp-v2-context-gauge.js +252 -0
  967. package/neural-interface/public/shared/ocp-v2/ocp-v2-context-menu.js +478 -0
  968. package/neural-interface/public/shared/ocp-v2/ocp-v2-context-model.js +179 -0
  969. package/neural-interface/public/shared/ocp-v2/ocp-v2-events.js +233 -0
  970. package/neural-interface/public/shared/ocp-v2/ocp-v2-icons.js +30 -0
  971. package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +1065 -0
  972. package/neural-interface/public/shared/ocp-v2/ocp-v2-mention-hints.js +182 -0
  973. package/neural-interface/public/shared/ocp-v2/ocp-v2-modelpicker.js +655 -0
  974. package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +2636 -0
  975. package/neural-interface/public/shared/ocp-v2/ocp-v2-plan.js +601 -0
  976. package/neural-interface/public/shared/ocp-v2/ocp-v2-profile-inheritance.js +78 -0
  977. package/neural-interface/public/shared/ocp-v2/ocp-v2-projectbar.js +649 -0
  978. package/neural-interface/public/shared/ocp-v2/ocp-v2-providers.js +35 -0
  979. package/neural-interface/public/shared/ocp-v2/ocp-v2-rehydrate.js +357 -0
  980. package/neural-interface/public/shared/ocp-v2/ocp-v2-render-logic.js +189 -0
  981. package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +1869 -0
  982. package/neural-interface/public/shared/ocp-v2/ocp-v2-select.js +42 -0
  983. package/neural-interface/public/shared/ocp-v2/ocp-v2-send-logic.js +117 -0
  984. package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +1714 -0
  985. package/neural-interface/public/shared/ocp-v2/ocp-v2-session-actions.js +468 -0
  986. package/neural-interface/public/shared/ocp-v2/ocp-v2-session-widgets.js +63 -0
  987. package/neural-interface/public/shared/ocp-v2/ocp-v2-sessions-logic.js +366 -0
  988. package/neural-interface/public/shared/ocp-v2/ocp-v2-settings-link.js +19 -0
  989. package/neural-interface/public/shared/ocp-v2/ocp-v2-slash-hints.js +343 -0
  990. package/neural-interface/public/shared/ocp-v2/ocp-v2-state.js +746 -0
  991. package/neural-interface/public/shared/ocp-v2/ocp-v2-status-logic.js +347 -0
  992. package/neural-interface/public/shared/ocp-v2/ocp-v2-status.js +338 -0
  993. package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +3543 -0
  994. package/neural-interface/public/shared/ocp-v2/ocp-v2-subagents-logic.js +482 -0
  995. package/neural-interface/public/shared/ocp-v2/ocp-v2-tools-logic.js +351 -0
  996. package/neural-interface/public/shared/ocp-v2/ocp-v2-tools.js +168 -0
  997. package/neural-interface/public/shared/ocp-v2/ocp-v2-variantpicker.js +315 -0
  998. package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +545 -0
  999. package/neural-interface/public/shared/provider-icons.js +30 -0
  1000. package/neural-interface/public/shared/pwa-install-page.js +34 -0
  1001. package/neural-interface/public/shared/pwa-install.css +12 -0
  1002. package/neural-interface/public/shared/pwa-install.js +28 -0
  1003. package/neural-interface/public/shared/session-title.js +100 -0
  1004. package/neural-interface/public/shared/settings/settings-ia.js +389 -0
  1005. package/neural-interface/public/shared/settings/settings-kit.js +234 -0
  1006. package/neural-interface/public/shared/settings/settings-rules.js +160 -0
  1007. package/neural-interface/public/shared/settings/settings-search.js +463 -0
  1008. package/neural-interface/public/shared/settings/settings-shell.js +570 -0
  1009. package/neural-interface/public/shared/start-bridge.js +583 -0
  1010. package/neural-interface/public/shared/state.js +5 -0
  1011. package/neural-interface/public/shared/storage.js +50 -7
  1012. package/neural-interface/public/shared/styleguide/sg-agents.js +42 -0
  1013. package/neural-interface/public/shared/styleguide/sg-brand.js +4 -0
  1014. package/neural-interface/public/shared/styleguide/sg-color-client.js +388 -0
  1015. package/neural-interface/public/shared/styleguide/sg-colors.js +151 -0
  1016. package/neural-interface/public/shared/styleguide/sg-components.js +35 -0
  1017. package/neural-interface/public/shared/styleguide/sg-history.js +41 -0
  1018. package/neural-interface/public/shared/styleguide/sg-icons-logo.js +38 -0
  1019. package/neural-interface/public/shared/styleguide/sg-imagery.js +4 -0
  1020. package/neural-interface/public/shared/styleguide/sg-import-export.js +48 -0
  1021. package/neural-interface/public/shared/styleguide/sg-kit.js +284 -0
  1022. package/neural-interface/public/shared/styleguide/sg-labels.js +318 -0
  1023. package/neural-interface/public/shared/styleguide/sg-layout.js +4 -0
  1024. package/neural-interface/public/shared/styleguide/sg-motion.js +5 -0
  1025. package/neural-interface/public/shared/styleguide/sg-panel.js +237 -0
  1026. package/neural-interface/public/shared/styleguide/sg-preview.js +138 -0
  1027. package/neural-interface/public/shared/styleguide/sg-rules.js +9 -0
  1028. package/neural-interface/public/shared/styleguide/sg-shape.js +24 -0
  1029. package/neural-interface/public/shared/styleguide/sg-state.js +132 -0
  1030. package/neural-interface/public/shared/styleguide/sg-typography.js +125 -0
  1031. package/neural-interface/public/shared/styles.css +8614 -1477
  1032. package/neural-interface/public/shared/synabun-mascot.js +1625 -0
  1033. package/neural-interface/public/shared/synabun-ticker.js +376 -0
  1034. package/neural-interface/public/shared/term-ready.js +307 -0
  1035. package/neural-interface/public/shared/term-renderer.js +343 -0
  1036. package/neural-interface/public/shared/ui-assistant-panel.js +10 -0
  1037. package/neural-interface/public/shared/ui-assistant.js +77 -0
  1038. package/neural-interface/public/shared/ui-automation-studio.js +5105 -3573
  1039. package/neural-interface/public/shared/ui-claude-panel.js +11685 -6333
  1040. package/neural-interface/public/shared/ui-codex-panel.js +12 -0
  1041. package/neural-interface/public/shared/ui-command-runner.js +251 -468
  1042. package/neural-interface/public/shared/ui-cost-widget.js +55 -34
  1043. package/neural-interface/public/shared/ui-detail.js +77 -14
  1044. package/neural-interface/public/shared/ui-explorer.js +360 -181
  1045. package/neural-interface/public/shared/ui-file-explorer.js +485 -107
  1046. package/neural-interface/public/shared/ui-help.js +2 -2
  1047. package/neural-interface/public/shared/ui-image-gallery.js +45 -21
  1048. package/neural-interface/public/shared/ui-judgments.js +1346 -0
  1049. package/neural-interface/public/shared/ui-keybinds.js +3 -2
  1050. package/neural-interface/public/shared/ui-link.js +105 -51
  1051. package/neural-interface/public/shared/ui-loading.js +222 -11
  1052. package/neural-interface/public/shared/ui-memory-maintenance.js +111 -0
  1053. package/neural-interface/public/shared/ui-menubar.js +100 -31
  1054. package/neural-interface/public/shared/ui-native-loop-router-state.js +94 -0
  1055. package/neural-interface/public/shared/ui-native-loop-router.js +493 -0
  1056. package/neural-interface/public/shared/ui-native-window-id.js +7 -0
  1057. package/neural-interface/public/shared/ui-navbar.js +357 -222
  1058. package/neural-interface/public/shared/ui-notifications.js +58 -12
  1059. package/neural-interface/public/shared/ui-opencode-panel-v2.js +17 -0
  1060. package/neural-interface/public/shared/ui-panels.js +15 -7
  1061. package/neural-interface/public/shared/ui-resume.js +823 -653
  1062. package/neural-interface/public/shared/ui-schedule-queue.js +172 -0
  1063. package/neural-interface/public/shared/ui-schedules-studio.js +1882 -0
  1064. package/neural-interface/public/shared/ui-scroll-follow.js +194 -0
  1065. package/neural-interface/public/shared/ui-sessions.js +789 -34
  1066. package/neural-interface/public/shared/ui-settings.js +5774 -2194
  1067. package/neural-interface/public/shared/ui-sidepanel-layout.js +109 -0
  1068. package/neural-interface/public/shared/ui-sidepanel-runtime.js +19 -0
  1069. package/neural-interface/public/shared/ui-sidepanel-session-entry.js +40 -0
  1070. package/neural-interface/public/shared/ui-sidepanel-sessions.js +221 -0
  1071. package/neural-interface/public/shared/ui-sidepanel-state.js +131 -0
  1072. package/neural-interface/public/shared/ui-sidepanel-tray.js +547 -0
  1073. package/neural-interface/public/shared/ui-sidepanel-windows.js +387 -0
  1074. package/neural-interface/public/shared/ui-skills.js +18 -32
  1075. package/neural-interface/public/shared/ui-styleguide.js +35 -0
  1076. package/neural-interface/public/shared/ui-sync.js +87 -0
  1077. package/neural-interface/public/shared/ui-terminal.js +7863 -6385
  1078. package/neural-interface/public/shared/ui-tool-updates.js +292 -0
  1079. package/neural-interface/public/shared/ui-tooltip.js +156 -15
  1080. package/neural-interface/public/shared/ui-tutorial-draw.js +119 -683
  1081. package/neural-interface/public/shared/ui-tutorial-layout.js +135 -0
  1082. package/neural-interface/public/shared/ui-tutorial-steps.js +59 -2209
  1083. package/neural-interface/public/shared/ui-tutorial.css +102 -0
  1084. package/neural-interface/public/shared/ui-tutorial.js +557 -1076
  1085. package/neural-interface/public/shared/ui-update.js +420 -68
  1086. package/neural-interface/public/shared/ui-whatsapp.js +941 -0
  1087. package/neural-interface/public/shared/ui-whiteboard.js +1076 -233
  1088. package/neural-interface/public/shared/ui-workspaces.js +2 -1
  1089. package/neural-interface/public/shared/utils.js +58 -0
  1090. package/neural-interface/public/shared/vterm-buffer.js +15 -5
  1091. package/neural-interface/public/shared/whatsapp/wa-phone.js +65 -0
  1092. package/neural-interface/public/shared/whatsapp/wa-view.js +411 -0
  1093. package/neural-interface/public/sidepanel-session.html +18 -0
  1094. package/neural-interface/public/sw.js +10 -2
  1095. package/neural-interface/public/synabun.png +0 -0
  1096. package/neural-interface/public/variant/2d/graph.js +1707 -1635
  1097. package/neural-interface/public/variant/2d/lasso.js +2 -1
  1098. package/neural-interface/public/variant/2d/layout.js +595 -594
  1099. package/neural-interface/public/variant/2d/main.js +557 -521
  1100. package/neural-interface/public/variant/2d/settings-gfx.js +18 -24
  1101. package/neural-interface/public/variant/3d/main.js +517 -500
  1102. package/neural-interface/public/variant/3d/map-controls.js +144 -0
  1103. package/neural-interface/public/variant/3d/map-data.js +251 -0
  1104. package/neural-interface/public/variant/3d/map-labels.js +241 -0
  1105. package/neural-interface/public/variant/3d/map-pick.js +90 -0
  1106. package/neural-interface/public/variant/3d/map-renderer.js +521 -0
  1107. package/neural-interface/public/variant/3d/map-shaders.js +158 -0
  1108. package/neural-interface/public/variant/3d/map-view.js +618 -0
  1109. package/neural-interface/public/vendor/three/manifest.json +3 -0
  1110. package/neural-interface/public/vendor/three/three-0.169.0.min.js +3844 -0
  1111. package/neural-interface/public/vendor/xterm/manifest.json +3 -0
  1112. package/neural-interface/public/vendor/xterm/xterm-6.0.0.css +285 -0
  1113. package/neural-interface/public/vendor/xterm/xterm-6.0.0.min.js +192 -0
  1114. package/neural-interface/scripts/build-vendor.mjs +64 -0
  1115. package/neural-interface/scripts/codex-protocol-fixture.mjs +83 -0
  1116. package/neural-interface/scripts/rebuild-pty.js +39 -22
  1117. package/neural-interface/scripts/vendor-three-entry.js +24 -0
  1118. package/neural-interface/scripts/vendor-xterm-entry.js +8 -0
  1119. package/neural-interface/server.js +33983 -15000
  1120. package/neural-interface/skins/default/skin.css +90 -0
  1121. package/neural-interface/skins/default/skin.json +8 -0
  1122. package/neural-interface/templates/rulesets/README.md +9 -0
  1123. package/neural-interface/templates/rulesets/claude.md +3 -0
  1124. package/neural-interface/templates/rulesets/codex.md +2 -0
  1125. package/neural-interface/templates/rulesets/coexistence.md +6 -0
  1126. package/neural-interface/templates/rulesets/core.md +26 -0
  1127. package/neural-interface/templates/rulesets/cursor.md +2 -0
  1128. package/neural-interface/templates/rulesets/gemini.md +2 -0
  1129. package/neural-interface/templates/rulesets/legacy-hashes.json +227 -0
  1130. package/neural-interface/templates/rulesets/manifest.json +12 -0
  1131. package/neural-interface/templates/rulesets/opencode.md +2 -0
  1132. package/package.json +131 -53
  1133. package/postinstall.js +55 -26
  1134. package/preuninstall.js +187 -0
  1135. package/scripts/restore-data-home-from-backup.mjs +239 -0
  1136. package/setup.js +872 -260
  1137. package/skills/leonardo/SKILL.md +19 -10
  1138. package/skills/leonardo/modules/image-prompter.md +18 -12
  1139. package/skills/leonardo/modules/video-prompter.md +19 -13
  1140. package/skills/synabun/SKILL.md +209 -185
  1141. package/skills/synabun/icon.png +0 -0
  1142. package/skills/synabun/modules/audit.md +380 -374
  1143. package/skills/synabun/modules/changelog.md +15 -6
  1144. package/skills/synabun/modules/idea.md +148 -144
  1145. package/skills/synabun/modules/memorize.md +13 -4
  1146. package/skills/synabun/modules/schedule.md +198 -0
  1147. package/skills/synabun/synabunicon.png +0 -0
  1148. package/updater.cmd +31 -0
  1149. package/updater.mjs +382 -0
  1150. package/updater.sh +29 -0
  1151. package/hooks/claude-code/test-user-learning.mjs +0 -531
  1152. package/neural-interface/public/claude-chat.css +0 -878
  1153. package/neural-interface/public/claude-chat.html +0 -92
  1154. package/neural-interface/public/claude-chat.js +0 -1168
  1155. package/neural-interface/public/index-legacy.html +0 -14677
  1156. package/neural-interface/public/index2d-legacy.html +0 -8193
  1157. package/neural-interface/public/shared/html-term-renderer.js +0 -1022
  1158. package/neural-interface/public/variant/3d/background.js +0 -884
  1159. package/neural-interface/public/variant/3d/camera.js +0 -661
  1160. package/neural-interface/public/variant/3d/gfx.js +0 -116
  1161. package/neural-interface/public/variant/3d/graph.js +0 -2399
  1162. package/neural-interface/public/variant/3d/settings-gfx.js +0 -228
  1163. package/neural-interface/templates/CLAUDE-template.md +0 -211
@@ -0,0 +1,3844 @@
1
+ var Vn={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Hn={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Xl=0,fo=1,Yl=2;var ml=1,ql=2,Qe=3,xn=0,ve=1,tn=2,gn=0,Un=1,yr=2,po=3,mo=4,Zl=5,Cn=100,Jl=101,Kl=102,$l=103,jl=104,Ql=200,tc=201,ec=202,nc=203,Mr=204,Sr=205,ic=206,sc=207,rc=208,ac=209,oc=210,lc=211,cc=212,hc=213,uc=214,br=0,Er=1,wr=2,hi=3,Tr=4,Ar=5,Rr=6,Cr=7,gl=0,dc=1,fc=2,_n=0,pc=1,mc=2,gc=3,_c=4,xc=5,vc=6,yc=7;var _l=300,ui=301,di=302,Pr=303,Ir=304,Os=306,Lr=1e3,Ln=1001,Dr=1002,Pe=1003,Mc=1004;var Oi=1005;var Be=1006,Ws=1007;var Dn=1008;var sn=1009,xl=1010,vl=1011,Ci=1012,Wa=1013,Nn=1014,en=1015,Di=1016,Xa=1017,Ya=1018,fi=1020,yl=35902,Ml=1021,Sl=1022,ze=1023,bl=1024,El=1025,oi=1026,pi=1027,wl=1028,qa=1029,Tl=1030,Za=1031;var Ja=1033,ls=33776,cs=33777,hs=33778,us=33779,Ur=35840,Nr=35841,Or=35842,Fr=35843,Br=36196,zr=37492,kr=37496,Vr=37808,Hr=37809,Gr=37810,Wr=37811,Xr=37812,Yr=37813,qr=37814,Zr=37815,Jr=37816,Kr=37817,$r=37818,jr=37819,Qr=37820,ta=37821,ds=36492,ea=36494,na=36495,Al=36283,ia=36284,sa=36285,ra=36286;var ps=2300,aa=2301,Xs=2302,go=2400,_o=2401,xo=2402;var Sc=3200,bc=3201;var Ec=0,wc=1,mn="",Xe="srgb",yn="srgb-linear",Ka="display-p3",Fs="display-p3-linear",ms="linear",jt="srgb",gs="rec709",_s="p3";var Wn=7680;var vo=519,Tc=512,Ac=513,Rc=514,Rl=515,Cc=516,Pc=517,Ic=518,Lc=519,yo=35044,Dc=35048;var Mo="300 es",nn=2e3,xs=2001,rn=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;let n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;let s=this._listeners[t];if(s!==void 0){let r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){if(this._listeners===void 0)return;let n=this._listeners[t.type];if(n!==void 0){t.target=this;let s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,t);t.target=null}}},ue=["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"],So=1234567,Ti=Math.PI/180,Pi=180/Math.PI;function _i(){let i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(ue[i&255]+ue[i>>8&255]+ue[i>>16&255]+ue[i>>24&255]+"-"+ue[t&255]+ue[t>>8&255]+"-"+ue[t>>16&15|64]+ue[t>>24&255]+"-"+ue[e&63|128]+ue[e>>8&255]+"-"+ue[e>>16&255]+ue[e>>24&255]+ue[n&255]+ue[n>>8&255]+ue[n>>16&255]+ue[n>>24&255]).toLowerCase()}function fe(i,t,e){return Math.max(t,Math.min(e,i))}function $a(i,t){return(i%t+t)%t}function Uc(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function Nc(i,t,e){return i!==t?(e-i)/(t-i):0}function Ai(i,t,e){return(1-e)*i+e*t}function Oc(i,t,e,n){return Ai(i,t,1-Math.exp(-e*n))}function Fc(i,t=1){return t-Math.abs($a(i,t*2)-t)}function Bc(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function zc(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function kc(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Vc(i,t){return i+Math.random()*(t-i)}function Hc(i){return i*(.5-Math.random())}function Gc(i){i!==void 0&&(So=i);let t=So+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Wc(i){return i*Ti}function Xc(i){return i*Pi}function Yc(i){return(i&i-1)===0&&i!==0}function qc(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Zc(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Jc(i,t,e,n,s){let r=Math.cos,a=Math.sin,o=r(e/2),l=a(e/2),c=r((t+n)/2),h=a((t+n)/2),p=r((t-n)/2),f=a((t-n)/2),m=r((n-t)/2),x=a((n-t)/2);switch(s){case"XYX":i.set(o*h,l*p,l*f,o*c);break;case"YZY":i.set(l*f,o*h,l*p,o*c);break;case"ZXZ":i.set(l*p,l*f,o*h,o*c);break;case"XZX":i.set(o*h,l*x,l*m,o*c);break;case"YXY":i.set(l*m,o*h,l*x,o*c);break;case"ZYZ":i.set(l*x,l*m,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function si(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function pe(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}var Cl={DEG2RAD:Ti,RAD2DEG:Pi,generateUUID:_i,clamp:fe,euclideanModulo:$a,mapLinear:Uc,inverseLerp:Nc,lerp:Ai,damp:Oc,pingpong:Fc,smoothstep:Bc,smootherstep:zc,randInt:kc,randFloat:Vc,randFloatSpread:Hc,seededRandom:Gc,degToRad:Wc,radToDeg:Xc,isPowerOfTwo:Yc,ceilPowerOfTwo:qc,floorPowerOfTwo:Zc,setQuaternionFromProperEuler:Jc,normalize:pe,denormalize:si},It=class i{constructor(t=0,e=0){i.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(fe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*s+t.x,this.y=r*s+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Pt=class i{constructor(t,e,n,s,r,a,o,l,c){i.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,l,c)}set(t,e,n,s,r,a,o,l,c){let h=this.elements;return h[0]=t,h[1]=s,h[2]=o,h[3]=e,h[4]=r,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],p=n[7],f=n[2],m=n[5],x=n[8],y=s[0],d=s[3],u=s[6],w=s[1],S=s[4],E=s[7],O=s[2],C=s[5],T=s[8];return r[0]=a*y+o*w+l*O,r[3]=a*d+o*S+l*C,r[6]=a*u+o*E+l*T,r[1]=c*y+h*w+p*O,r[4]=c*d+h*S+p*C,r[7]=c*u+h*E+p*T,r[2]=f*y+m*w+x*O,r[5]=f*d+m*S+x*C,r[8]=f*u+m*E+x*T,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8];return e*a*h-e*o*c-n*r*h+n*o*l+s*r*c-s*a*l}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],p=h*a-o*c,f=o*l-h*r,m=c*r-a*l,x=e*p+n*f+s*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/x;return t[0]=p*y,t[1]=(s*c-h*n)*y,t[2]=(o*n-s*a)*y,t[3]=f*y,t[4]=(h*e-s*l)*y,t[5]=(s*r-o*e)*y,t[6]=m*y,t[7]=(n*l-c*e)*y,t[8]=(a*e-n*r)*y,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,a,o){let l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+t,-s*c,s*l,-s*(-c*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Ys.makeScale(t,e)),this}rotate(t){return this.premultiply(Ys.makeRotation(-t)),this}translate(t,e){return this.premultiply(Ys.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}},Ys=new Pt;function Pl(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function vs(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Kc(){let i=vs("canvas");return i.style.display="block",i}var bo={};function fs(i){i in bo||(bo[i]=!0,console.warn(i))}function $c(i,t,e){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}function jc(i){let t=i.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function Qc(i){let t=i.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}var Eo=new Pt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),wo=new Pt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),vi={[yn]:{transfer:ms,primaries:gs,luminanceCoefficients:[.2126,.7152,.0722],toReference:i=>i,fromReference:i=>i},[Xe]:{transfer:jt,primaries:gs,luminanceCoefficients:[.2126,.7152,.0722],toReference:i=>i.convertSRGBToLinear(),fromReference:i=>i.convertLinearToSRGB()},[Fs]:{transfer:ms,primaries:_s,luminanceCoefficients:[.2289,.6917,.0793],toReference:i=>i.applyMatrix3(wo),fromReference:i=>i.applyMatrix3(Eo)},[Ka]:{transfer:jt,primaries:_s,luminanceCoefficients:[.2289,.6917,.0793],toReference:i=>i.convertSRGBToLinear().applyMatrix3(wo),fromReference:i=>i.applyMatrix3(Eo).convertLinearToSRGB()}},th=new Set([yn,Fs]),Wt={enabled:!0,_workingColorSpace:yn,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(i){if(!th.has(i))throw new Error(`Unsupported working color space, "${i}".`);this._workingColorSpace=i},convert:function(i,t,e){if(this.enabled===!1||t===e||!t||!e)return i;let n=vi[t].toReference,s=vi[e].fromReference;return s(n(i))},fromWorkingColorSpace:function(i,t){return this.convert(i,this._workingColorSpace,t)},toWorkingColorSpace:function(i,t){return this.convert(i,t,this._workingColorSpace)},getPrimaries:function(i){return vi[i].primaries},getTransfer:function(i){return i===mn?ms:vi[i].transfer},getLuminanceCoefficients:function(i,t=this._workingColorSpace){return i.fromArray(vi[t].luminanceCoefficients)}};function li(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function qs(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Xn,oa=class{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Xn===void 0&&(Xn=vs("canvas")),Xn.width=t.width,Xn.height=t.height;let n=Xn.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Xn}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=vs("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=li(r[a]/255)*255;return n.putImageData(s,0,0),e}else if(t.data){let e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(li(e[n]/255)*255):e[n]=li(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}},eh=0,ys=class{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:eh++}),this.uuid=_i(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(Zs(s[a].image)):r.push(Zs(s[a]))}else r=Zs(s);n.url=r}return e||(t.images[this.uuid]=n),n}};function Zs(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?oa.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var nh=0,Le=class i extends rn{constructor(t=i.DEFAULT_IMAGE,e=i.DEFAULT_MAPPING,n=Ln,s=Ln,r=Be,a=Dn,o=ze,l=sn,c=i.DEFAULT_ANISOTROPY,h=mn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:nh++}),this.uuid=_i(),this.name="",this.source=new ys(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new It(0,0),this.repeat=new It(1,1),this.center=new It(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Pt,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.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).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),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==_l)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Lr:t.x=t.x-Math.floor(t.x);break;case Ln:t.x=t.x<0?0:1;break;case Dr:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Lr:t.y=t.y-Math.floor(t.y);break;case Ln:t.y=t.y<0?0:1;break;case Dr:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};Le.DEFAULT_IMAGE=null;Le.DEFAULT_MAPPING=_l;Le.DEFAULT_ANISOTROPY=1;var ie=class i{constructor(t=0,e=0,n=0,s=1){i.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*s+a[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,r,l=t.elements,c=l[0],h=l[4],p=l[8],f=l[1],m=l[5],x=l[9],y=l[2],d=l[6],u=l[10];if(Math.abs(h-f)<.01&&Math.abs(p-y)<.01&&Math.abs(x-d)<.01){if(Math.abs(h+f)<.1&&Math.abs(p+y)<.1&&Math.abs(x+d)<.1&&Math.abs(c+m+u-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let S=(c+1)/2,E=(m+1)/2,O=(u+1)/2,C=(h+f)/4,T=(p+y)/4,F=(x+d)/4;return S>E&&S>O?S<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(S),s=C/n,r=T/n):E>O?E<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(E),n=C/s,r=F/s):O<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(O),n=T/r,s=F/r),this.set(n,s,r,e),this}let w=Math.sqrt((d-x)*(d-x)+(p-y)*(p-y)+(f-h)*(f-h));return Math.abs(w)<.001&&(w=1),this.x=(d-x)/w,this.y=(p-y)/w,this.z=(f-h)/w,this.w=Math.acos((c+m+u-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},la=class extends rn{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new ie(0,0,t,e),this.scissorTest=!1,this.viewport=new ie(0,0,t,e);let s={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Be,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);let r=new Le(s,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);r.flipY=!1,r.generateMipmaps=n.generateMipmaps,r.internalFormat=n.internalFormat,this.textures=[];let a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=t,this.textures[s].image.height=e,this.textures[s].image.depth=n;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let n=0,s=t.textures.length;n<s;n++)this.textures[n]=t.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;let e=Object.assign({},t.texture.image);return this.texture.source=new ys(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},an=class extends la{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}},Ms=class extends Le{constructor(t=null,e=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=Pe,this.minFilter=Pe,this.wrapR=Ln,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}};var ca=class extends Le{constructor(t=null,e=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=Pe,this.minFilter=Pe,this.wrapR=Ln,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Ve=class{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,a,o){let l=n[s+0],c=n[s+1],h=n[s+2],p=n[s+3],f=r[a+0],m=r[a+1],x=r[a+2],y=r[a+3];if(o===0){t[e+0]=l,t[e+1]=c,t[e+2]=h,t[e+3]=p;return}if(o===1){t[e+0]=f,t[e+1]=m,t[e+2]=x,t[e+3]=y;return}if(p!==y||l!==f||c!==m||h!==x){let d=1-o,u=l*f+c*m+h*x+p*y,w=u>=0?1:-1,S=1-u*u;if(S>Number.EPSILON){let O=Math.sqrt(S),C=Math.atan2(O,u*w);d=Math.sin(d*C)/O,o=Math.sin(o*C)/O}let E=o*w;if(l=l*d+f*E,c=c*d+m*E,h=h*d+x*E,p=p*d+y*E,d===1-o){let O=1/Math.sqrt(l*l+c*c+h*h+p*p);l*=O,c*=O,h*=O,p*=O}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=p}static multiplyQuaternionsFlat(t,e,n,s,r,a){let o=n[s],l=n[s+1],c=n[s+2],h=n[s+3],p=r[a],f=r[a+1],m=r[a+2],x=r[a+3];return t[e]=o*x+h*p+l*m-c*f,t[e+1]=l*x+h*f+c*p-o*m,t[e+2]=c*x+h*m+o*f-l*p,t[e+3]=h*x-o*p-l*f-c*m,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let n=t._x,s=t._y,r=t._z,a=t._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(s/2),p=o(r/2),f=l(n/2),m=l(s/2),x=l(r/2);switch(a){case"XYZ":this._x=f*h*p+c*m*x,this._y=c*m*p-f*h*x,this._z=c*h*x+f*m*p,this._w=c*h*p-f*m*x;break;case"YXZ":this._x=f*h*p+c*m*x,this._y=c*m*p-f*h*x,this._z=c*h*x-f*m*p,this._w=c*h*p+f*m*x;break;case"ZXY":this._x=f*h*p-c*m*x,this._y=c*m*p+f*h*x,this._z=c*h*x+f*m*p,this._w=c*h*p-f*m*x;break;case"ZYX":this._x=f*h*p-c*m*x,this._y=c*m*p+f*h*x,this._z=c*h*x-f*m*p,this._w=c*h*p+f*m*x;break;case"YZX":this._x=f*h*p+c*m*x,this._y=c*m*p+f*h*x,this._z=c*h*x-f*m*p,this._w=c*h*p-f*m*x;break;case"XZY":this._x=f*h*p-c*m*x,this._y=c*m*p-f*h*x,this._z=c*h*x+f*m*p,this._w=c*h*p+f*m*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],s=e[4],r=e[8],a=e[1],o=e[5],l=e[9],c=e[2],h=e[6],p=e[10],f=n+o+p;if(f>0){let m=.5/Math.sqrt(f+1);this._w=.25/m,this._x=(h-l)*m,this._y=(r-c)*m,this._z=(a-s)*m}else if(n>o&&n>p){let m=2*Math.sqrt(1+n-o-p);this._w=(h-l)/m,this._x=.25*m,this._y=(s+a)/m,this._z=(r+c)/m}else if(o>p){let m=2*Math.sqrt(1+o-n-p);this._w=(r-c)/m,this._x=(s+a)/m,this._y=.25*m,this._z=(l+h)/m}else{let m=2*Math.sqrt(1+p-n-o);this._w=(a-s)/m,this._x=(r+c)/m,this._y=(l+h)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(fe(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let n=t._x,s=t._y,r=t._z,a=t._w,o=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+a*o+s*c-r*l,this._y=s*h+a*l+r*o-n*c,this._z=r*h+a*c+n*l-s*o,this._w=a*h-n*o-s*l-r*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let n=this._x,s=this._y,r=this._z,a=this._w,o=a*t._w+n*t._x+s*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=s,this._z=r,this;let l=1-o*o;if(l<=Number.EPSILON){let m=1-e;return this._w=m*a+e*this._w,this._x=m*n+e*this._x,this._y=m*s+e*this._y,this._z=m*r+e*this._z,this.normalize(),this}let c=Math.sqrt(l),h=Math.atan2(c,o),p=Math.sin((1-e)*h)/c,f=Math.sin(e*h)/c;return this._w=a*p+this._w*f,this._x=n*p+this._x*f,this._y=s*p+this._y*f,this._z=r*p+this._z*f,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},L=class i{constructor(t=0,e=0,n=0){i.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(To.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(To.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(t){let e=this.x,n=this.y,s=this.z,r=t.x,a=t.y,o=t.z,l=t.w,c=2*(a*s-o*n),h=2*(o*e-r*s),p=2*(r*n-a*e);return this.x=e+l*c+a*p-o*h,this.y=n+l*h+o*c-r*p,this.z=s+l*p+r*h-a*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=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(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,s=t.y,r=t.z,a=e.x,o=e.y,l=e.z;return this.x=s*l-r*o,this.y=r*a-n*l,this.z=n*o-s*a,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Js.copy(this).projectOnVector(t),this.sub(Js)}reflect(t){return this.sub(Js.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(fe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Js=new L,To=new Ve,On=class{constructor(t=new L(1/0,1/0,1/0),e=new L(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Ue.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Ue.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=Ue.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);let n=t.geometry;if(n!==void 0){let r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,Ue):Ue.fromBufferAttribute(r,a),Ue.applyMatrix4(t.matrixWorld),this.expandByPoint(Ue);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Fi.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Fi.copy(n.boundingBox)),Fi.applyMatrix4(t.matrixWorld),this.union(Fi)}let s=t.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Ue),Ue.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(yi),Bi.subVectors(this.max,yi),Yn.subVectors(t.a,yi),qn.subVectors(t.b,yi),Zn.subVectors(t.c,yi),cn.subVectors(qn,Yn),hn.subVectors(Zn,qn),Sn.subVectors(Yn,Zn);let e=[0,-cn.z,cn.y,0,-hn.z,hn.y,0,-Sn.z,Sn.y,cn.z,0,-cn.x,hn.z,0,-hn.x,Sn.z,0,-Sn.x,-cn.y,cn.x,0,-hn.y,hn.x,0,-Sn.y,Sn.x,0];return!Ks(e,Yn,qn,Zn,Bi)||(e=[1,0,0,0,1,0,0,0,1],!Ks(e,Yn,qn,Zn,Bi))?!1:(zi.crossVectors(cn,hn),e=[zi.x,zi.y,zi.z],Ks(e,Yn,qn,Zn,Bi))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ue).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Ue).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Ze[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ze[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ze[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ze[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ze[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ze[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ze[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ze[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ze),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},Ze=[new L,new L,new L,new L,new L,new L,new L,new L],Ue=new L,Fi=new On,Yn=new L,qn=new L,Zn=new L,cn=new L,hn=new L,Sn=new L,yi=new L,Bi=new L,zi=new L,bn=new L;function Ks(i,t,e,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){bn.fromArray(i,r);let o=s.x*Math.abs(bn.x)+s.y*Math.abs(bn.y)+s.z*Math.abs(bn.z),l=t.dot(bn),c=e.dot(bn),h=n.dot(bn);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}var ih=new On,Mi=new L,$s=new L,Fn=class{constructor(t=new L,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let n=this.center;e!==void 0?n.copy(e):ih.setFromPoints(t).getCenter(n);let s=0;for(let r=0,a=t.length;r<a;r++)s=Math.max(s,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(s),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){let n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Mi.subVectors(t,this.center);let e=Mi.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Mi,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):($s.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Mi.copy(t.center).add($s)),this.expandByPoint(Mi.copy(t.center).sub($s))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}},Je=new L,js=new L,ki=new L,un=new L,Qs=new L,Vi=new L,tr=new L,Bn=class{constructor(t=new L,e=new L(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Je)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=Je.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Je.copy(this.origin).addScaledVector(this.direction,e),Je.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){js.copy(t).add(e).multiplyScalar(.5),ki.copy(e).sub(t).normalize(),un.copy(this.origin).sub(js);let r=t.distanceTo(e)*.5,a=-this.direction.dot(ki),o=un.dot(this.direction),l=-un.dot(ki),c=un.lengthSq(),h=Math.abs(1-a*a),p,f,m,x;if(h>0)if(p=a*l-o,f=a*o-l,x=r*h,p>=0)if(f>=-x)if(f<=x){let y=1/h;p*=y,f*=y,m=p*(p+a*f+2*o)+f*(a*p+f+2*l)+c}else f=r,p=Math.max(0,-(a*f+o)),m=-p*p+f*(f+2*l)+c;else f=-r,p=Math.max(0,-(a*f+o)),m=-p*p+f*(f+2*l)+c;else f<=-x?(p=Math.max(0,-(-a*r+o)),f=p>0?-r:Math.min(Math.max(-r,-l),r),m=-p*p+f*(f+2*l)+c):f<=x?(p=0,f=Math.min(Math.max(-r,-l),r),m=f*(f+2*l)+c):(p=Math.max(0,-(a*r+o)),f=p>0?r:Math.min(Math.max(-r,-l),r),m=-p*p+f*(f+2*l)+c);else f=a>0?-r:r,p=Math.max(0,-(a*f+o)),m=-p*p+f*(f+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,p),s&&s.copy(js).addScaledVector(ki,f),m}intersectSphere(t,e){Je.subVectors(t.center,this.origin);let n=Je.dot(this.direction),s=Je.dot(Je)-n*n,r=t.radius*t.radius;if(s>r)return null;let a=Math.sqrt(r-s),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,a,o,l,c=1/this.direction.x,h=1/this.direction.y,p=1/this.direction.z,f=this.origin;return c>=0?(n=(t.min.x-f.x)*c,s=(t.max.x-f.x)*c):(n=(t.max.x-f.x)*c,s=(t.min.x-f.x)*c),h>=0?(r=(t.min.y-f.y)*h,a=(t.max.y-f.y)*h):(r=(t.max.y-f.y)*h,a=(t.min.y-f.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),p>=0?(o=(t.min.z-f.z)*p,l=(t.max.z-f.z)*p):(o=(t.max.z-f.z)*p,l=(t.min.z-f.z)*p),n>l||o>s)||((o>n||n!==n)&&(n=o),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,Je)!==null}intersectTriangle(t,e,n,s,r){Qs.subVectors(e,t),Vi.subVectors(n,t),tr.crossVectors(Qs,Vi);let a=this.direction.dot(tr),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;un.subVectors(this.origin,t);let l=o*this.direction.dot(Vi.crossVectors(un,Vi));if(l<0)return null;let c=o*this.direction.dot(Qs.cross(un));if(c<0||l+c>a)return null;let h=-o*un.dot(tr);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ee=class i{constructor(t,e,n,s,r,a,o,l,c,h,p,f,m,x,y,d){i.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,l,c,h,p,f,m,x,y,d)}set(t,e,n,s,r,a,o,l,c,h,p,f,m,x,y,d){let u=this.elements;return u[0]=t,u[4]=e,u[8]=n,u[12]=s,u[1]=r,u[5]=a,u[9]=o,u[13]=l,u[2]=c,u[6]=h,u[10]=p,u[14]=f,u[3]=m,u[7]=x,u[11]=y,u[15]=d,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 i().fromArray(this.elements)}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,n=t.elements,s=1/Jn.setFromMatrixColumn(t,0).length(),r=1/Jn.setFromMatrixColumn(t,1).length(),a=1/Jn.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,n=t.x,s=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),p=Math.sin(r);if(t.order==="XYZ"){let f=a*h,m=a*p,x=o*h,y=o*p;e[0]=l*h,e[4]=-l*p,e[8]=c,e[1]=m+x*c,e[5]=f-y*c,e[9]=-o*l,e[2]=y-f*c,e[6]=x+m*c,e[10]=a*l}else if(t.order==="YXZ"){let f=l*h,m=l*p,x=c*h,y=c*p;e[0]=f+y*o,e[4]=x*o-m,e[8]=a*c,e[1]=a*p,e[5]=a*h,e[9]=-o,e[2]=m*o-x,e[6]=y+f*o,e[10]=a*l}else if(t.order==="ZXY"){let f=l*h,m=l*p,x=c*h,y=c*p;e[0]=f-y*o,e[4]=-a*p,e[8]=x+m*o,e[1]=m+x*o,e[5]=a*h,e[9]=y-f*o,e[2]=-a*c,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){let f=a*h,m=a*p,x=o*h,y=o*p;e[0]=l*h,e[4]=x*c-m,e[8]=f*c+y,e[1]=l*p,e[5]=y*c+f,e[9]=m*c-x,e[2]=-c,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){let f=a*l,m=a*c,x=o*l,y=o*c;e[0]=l*h,e[4]=y-f*p,e[8]=x*p+m,e[1]=p,e[5]=a*h,e[9]=-o*h,e[2]=-c*h,e[6]=m*p+x,e[10]=f-y*p}else if(t.order==="XZY"){let f=a*l,m=a*c,x=o*l,y=o*c;e[0]=l*h,e[4]=-p,e[8]=c*h,e[1]=f*p+y,e[5]=a*h,e[9]=m*p-x,e[2]=x*p-m,e[6]=o*h,e[10]=y*p+f}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(sh,t,rh)}lookAt(t,e,n){let s=this.elements;return we.subVectors(t,e),we.lengthSq()===0&&(we.z=1),we.normalize(),dn.crossVectors(n,we),dn.lengthSq()===0&&(Math.abs(n.z)===1?we.x+=1e-4:we.z+=1e-4,we.normalize(),dn.crossVectors(n,we)),dn.normalize(),Hi.crossVectors(we,dn),s[0]=dn.x,s[4]=Hi.x,s[8]=we.x,s[1]=dn.y,s[5]=Hi.y,s[9]=we.y,s[2]=dn.z,s[6]=Hi.z,s[10]=we.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],p=n[5],f=n[9],m=n[13],x=n[2],y=n[6],d=n[10],u=n[14],w=n[3],S=n[7],E=n[11],O=n[15],C=s[0],T=s[4],F=s[8],tt=s[12],g=s[1],M=s[5],H=s[9],z=s[13],G=s[2],J=s[6],B=s[10],j=s[14],V=s[3],ot=s[7],lt=s[11],gt=s[15];return r[0]=a*C+o*g+l*G+c*V,r[4]=a*T+o*M+l*J+c*ot,r[8]=a*F+o*H+l*B+c*lt,r[12]=a*tt+o*z+l*j+c*gt,r[1]=h*C+p*g+f*G+m*V,r[5]=h*T+p*M+f*J+m*ot,r[9]=h*F+p*H+f*B+m*lt,r[13]=h*tt+p*z+f*j+m*gt,r[2]=x*C+y*g+d*G+u*V,r[6]=x*T+y*M+d*J+u*ot,r[10]=x*F+y*H+d*B+u*lt,r[14]=x*tt+y*z+d*j+u*gt,r[3]=w*C+S*g+E*G+O*V,r[7]=w*T+S*M+E*J+O*ot,r[11]=w*F+S*H+E*B+O*lt,r[15]=w*tt+S*z+E*j+O*gt,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[4],s=t[8],r=t[12],a=t[1],o=t[5],l=t[9],c=t[13],h=t[2],p=t[6],f=t[10],m=t[14],x=t[3],y=t[7],d=t[11],u=t[15];return x*(+r*l*p-s*c*p-r*o*f+n*c*f+s*o*m-n*l*m)+y*(+e*l*m-e*c*f+r*a*f-s*a*m+s*c*h-r*l*h)+d*(+e*c*p-e*o*m-r*a*p+n*a*m+r*o*h-n*c*h)+u*(-s*o*h-e*l*p+e*o*f+s*a*p-n*a*f+n*l*h)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){let s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],p=t[9],f=t[10],m=t[11],x=t[12],y=t[13],d=t[14],u=t[15],w=p*d*c-y*f*c+y*l*m-o*d*m-p*l*u+o*f*u,S=x*f*c-h*d*c-x*l*m+a*d*m+h*l*u-a*f*u,E=h*y*c-x*p*c+x*o*m-a*y*m-h*o*u+a*p*u,O=x*p*l-h*y*l-x*o*f+a*y*f+h*o*d-a*p*d,C=e*w+n*S+s*E+r*O;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let T=1/C;return t[0]=w*T,t[1]=(y*f*r-p*d*r-y*s*m+n*d*m+p*s*u-n*f*u)*T,t[2]=(o*d*r-y*l*r+y*s*c-n*d*c-o*s*u+n*l*u)*T,t[3]=(p*l*r-o*f*r-p*s*c+n*f*c+o*s*m-n*l*m)*T,t[4]=S*T,t[5]=(h*d*r-x*f*r+x*s*m-e*d*m-h*s*u+e*f*u)*T,t[6]=(x*l*r-a*d*r-x*s*c+e*d*c+a*s*u-e*l*u)*T,t[7]=(a*f*r-h*l*r+h*s*c-e*f*c-a*s*m+e*l*m)*T,t[8]=E*T,t[9]=(x*p*r-h*y*r-x*n*m+e*y*m+h*n*u-e*p*u)*T,t[10]=(a*y*r-x*o*r+x*n*c-e*y*c-a*n*u+e*o*u)*T,t[11]=(h*o*r-a*p*r-h*n*c+e*p*c+a*n*m-e*o*m)*T,t[12]=O*T,t[13]=(h*y*s-x*p*s+x*n*f-e*y*f-h*n*d+e*p*d)*T,t[14]=(x*o*s-a*y*s-x*n*l+e*y*l+a*n*d-e*o*d)*T,t[15]=(a*p*s-h*o*s+h*n*l-e*p*l-a*n*f+e*o*f)*T,this}scale(t){let e=this.elements,n=t.x,s=t.y,r=t.z;return e[0]*=n,e[4]*=s,e[8]*=r,e[1]*=n,e[5]*=s,e[9]*=r,e[2]*=n,e[6]*=s,e[10]*=r,e[3]*=n,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),s=Math.sin(e),r=1-n,a=t.x,o=t.y,l=t.z,c=r*a,h=r*o;return this.set(c*a+n,c*o-s*l,c*l+s*o,0,c*o+s*l,h*o+n,h*l-s*a,0,c*l-s*o,h*l+s*a,r*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,s,r,a){return this.set(1,n,r,0,t,1,a,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){let s=this.elements,r=e._x,a=e._y,o=e._z,l=e._w,c=r+r,h=a+a,p=o+o,f=r*c,m=r*h,x=r*p,y=a*h,d=a*p,u=o*p,w=l*c,S=l*h,E=l*p,O=n.x,C=n.y,T=n.z;return s[0]=(1-(y+u))*O,s[1]=(m+E)*O,s[2]=(x-S)*O,s[3]=0,s[4]=(m-E)*C,s[5]=(1-(f+u))*C,s[6]=(d+w)*C,s[7]=0,s[8]=(x+S)*T,s[9]=(d-w)*T,s[10]=(1-(f+y))*T,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){let s=this.elements,r=Jn.set(s[0],s[1],s[2]).length(),a=Jn.set(s[4],s[5],s[6]).length(),o=Jn.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),t.x=s[12],t.y=s[13],t.z=s[14],Ne.copy(this);let c=1/r,h=1/a,p=1/o;return Ne.elements[0]*=c,Ne.elements[1]*=c,Ne.elements[2]*=c,Ne.elements[4]*=h,Ne.elements[5]*=h,Ne.elements[6]*=h,Ne.elements[8]*=p,Ne.elements[9]*=p,Ne.elements[10]*=p,e.setFromRotationMatrix(Ne),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,s,r,a,o=nn){let l=this.elements,c=2*r/(e-t),h=2*r/(n-s),p=(e+t)/(e-t),f=(n+s)/(n-s),m,x;if(o===nn)m=-(a+r)/(a-r),x=-2*a*r/(a-r);else if(o===xs)m=-a/(a-r),x=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=p,l[12]=0,l[1]=0,l[5]=h,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=x,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,s,r,a,o=nn){let l=this.elements,c=1/(e-t),h=1/(n-s),p=1/(a-r),f=(e+t)*c,m=(n+s)*h,x,y;if(o===nn)x=(a+r)*p,y=-2*p;else if(o===xs)x=r*p,y=-1*p;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-f,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=y,l[14]=-x,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}},Jn=new L,Ne=new ee,sh=new L(0,0,0),rh=new L(1,1,1),dn=new L,Hi=new L,we=new L,Ao=new ee,Ro=new Ve,on=class i{constructor(t=0,e=0,n=0,s=i.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,s=this._order){return this._x=t,this._y=e,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){let s=t.elements,r=s[0],a=s[4],o=s[8],l=s[1],c=s[5],h=s[9],p=s[2],f=s[6],m=s[10];switch(e){case"XYZ":this._y=Math.asin(fe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,m),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(f,c),this._z=0);break;case"YXZ":this._x=Math.asin(-fe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-p,r),this._z=0);break;case"ZXY":this._x=Math.asin(fe(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-p,m),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-fe(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(f,m),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(fe(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-p,r)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-fe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(f,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Ao.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ao,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Ro.setFromEuler(this),this.setFromQuaternion(Ro,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};on.DEFAULT_ORDER="XYZ";var Ss=class{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}},ah=0,Co=new L,Kn=new Ve,Ke=new ee,Gi=new L,Si=new L,oh=new L,lh=new Ve,Po=new L(1,0,0),Io=new L(0,1,0),Lo=new L(0,0,1),Do={type:"added"},ch={type:"removed"},$n={type:"childadded",child:null},er={type:"childremoved",child:null},Ae=class i extends rn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ah++}),this.uuid=_i(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let t=new L,e=new on,n=new Ve,s=new L(1,1,1);function r(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new ee},normalMatrix:{value:new Pt}}),this.matrix=new ee,this.matrixWorld=new ee,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ss,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Kn.setFromAxisAngle(t,e),this.quaternion.multiply(Kn),this}rotateOnWorldAxis(t,e){return Kn.setFromAxisAngle(t,e),this.quaternion.premultiply(Kn),this}rotateX(t){return this.rotateOnAxis(Po,t)}rotateY(t){return this.rotateOnAxis(Io,t)}rotateZ(t){return this.rotateOnAxis(Lo,t)}translateOnAxis(t,e){return Co.copy(t).applyQuaternion(this.quaternion),this.position.add(Co.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Po,t)}translateY(t){return this.translateOnAxis(Io,t)}translateZ(t){return this.translateOnAxis(Lo,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Ke.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Gi.copy(t):Gi.set(t,e,n);let s=this.parent;this.updateWorldMatrix(!0,!1),Si.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ke.lookAt(Si,Gi,this.up):Ke.lookAt(Gi,Si,this.up),this.quaternion.setFromRotationMatrix(Ke),s&&(Ke.extractRotation(s.matrixWorld),Kn.setFromRotationMatrix(Ke),this.quaternion.premultiply(Kn.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Do),$n.child=t,this.dispatchEvent($n),$n.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(ch),er.child=t,this.dispatchEvent(er),er.child=null),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Ke.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Ke.multiply(t.parent.matrixWorld)),t.applyMatrix4(Ke),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Do),$n.child=t,this.dispatchEvent($n),$n.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,s=this.children.length;n<s;n++){let a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);let s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Si,t,oh),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Si,lh,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverseVisible(t)}traverseAncestors(t){let e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){let n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){let s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].updateWorldMatrix(!1,!0)}}toJSON(t){let e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.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()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){let p=l[c];r(t.shapes,p)}else r(t.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(t.materials,this.material[l]));s.material=o}else s.material=r(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){let l=this.animations[o];s.animations.push(r(t.animations,l))}}if(e){let o=a(t.geometries),l=a(t.materials),c=a(t.textures),h=a(t.images),p=a(t.shapes),f=a(t.skeletons),m=a(t.animations),x=a(t.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),p.length>0&&(n.shapes=p),f.length>0&&(n.skeletons=f),m.length>0&&(n.animations=m),x.length>0&&(n.nodes=x)}return n.object=s,n;function a(o){let l=[];for(let c in o){let h=o[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){let s=t.children[n];this.add(s.clone())}return this}};Ae.DEFAULT_UP=new L(0,1,0);Ae.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ae.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Oe=new L,$e=new L,nr=new L,je=new L,jn=new L,Qn=new L,Uo=new L,ir=new L,sr=new L,rr=new L,ar=new ie,or=new ie,lr=new ie,Pn=class i{constructor(t=new L,e=new L,n=new L){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,s){s.subVectors(n,e),Oe.subVectors(t,e),s.cross(Oe);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){Oe.subVectors(s,e),$e.subVectors(n,e),nr.subVectors(t,e);let a=Oe.dot(Oe),o=Oe.dot($e),l=Oe.dot(nr),c=$e.dot($e),h=$e.dot(nr),p=a*c-o*o;if(p===0)return r.set(0,0,0),null;let f=1/p,m=(c*l-o*h)*f,x=(a*h-o*l)*f;return r.set(1-m-x,x,m)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,je)===null?!1:je.x>=0&&je.y>=0&&je.x+je.y<=1}static getInterpolation(t,e,n,s,r,a,o,l){return this.getBarycoord(t,e,n,s,je)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,je.x),l.addScaledVector(a,je.y),l.addScaledVector(o,je.z),l)}static getInterpolatedAttribute(t,e,n,s,r,a){return ar.setScalar(0),or.setScalar(0),lr.setScalar(0),ar.fromBufferAttribute(t,e),or.fromBufferAttribute(t,n),lr.fromBufferAttribute(t,s),a.setScalar(0),a.addScaledVector(ar,r.x),a.addScaledVector(or,r.y),a.addScaledVector(lr,r.z),a}static isFrontFacing(t,e,n,s){return Oe.subVectors(n,e),$e.subVectors(t,e),Oe.cross($e).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Oe.subVectors(this.c,this.b),$e.subVectors(this.a,this.b),Oe.cross($e).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return i.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return i.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,r){return i.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return i.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return i.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,s=this.b,r=this.c,a,o;jn.subVectors(s,n),Qn.subVectors(r,n),ir.subVectors(t,n);let l=jn.dot(ir),c=Qn.dot(ir);if(l<=0&&c<=0)return e.copy(n);sr.subVectors(t,s);let h=jn.dot(sr),p=Qn.dot(sr);if(h>=0&&p<=h)return e.copy(s);let f=l*p-h*c;if(f<=0&&l>=0&&h<=0)return a=l/(l-h),e.copy(n).addScaledVector(jn,a);rr.subVectors(t,r);let m=jn.dot(rr),x=Qn.dot(rr);if(x>=0&&m<=x)return e.copy(r);let y=m*c-l*x;if(y<=0&&c>=0&&x<=0)return o=c/(c-x),e.copy(n).addScaledVector(Qn,o);let d=h*x-m*p;if(d<=0&&p-h>=0&&m-x>=0)return Uo.subVectors(r,s),o=(p-h)/(p-h+(m-x)),e.copy(s).addScaledVector(Uo,o);let u=1/(d+y+f);return a=y*u,o=f*u,e.copy(n).addScaledVector(jn,a).addScaledVector(Qn,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},Il={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},fn={h:0,s:0,l:0},Wi={h:0,s:0,l:0};function cr(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}var zt=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Xe){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Wt.toWorkingColorSpace(this,e),this}setRGB(t,e,n,s=Wt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Wt.toWorkingColorSpace(this,s),this}setHSL(t,e,n,s=Wt.workingColorSpace){if(t=$a(t,1),e=fe(e,0,1),n=fe(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=cr(a,r,t+1/3),this.g=cr(a,r,t),this.b=cr(a,r,t-1/3)}return Wt.toWorkingColorSpace(this,s),this}setStyle(t,e=Xe){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r,a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){let r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Xe){let n=Il[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=li(t.r),this.g=li(t.g),this.b=li(t.b),this}copyLinearToSRGB(t){return this.r=qs(t.r),this.g=qs(t.g),this.b=qs(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Xe){return Wt.fromWorkingColorSpace(de.copy(this),t),Math.round(fe(de.r*255,0,255))*65536+Math.round(fe(de.g*255,0,255))*256+Math.round(fe(de.b*255,0,255))}getHexString(t=Xe){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Wt.workingColorSpace){Wt.fromWorkingColorSpace(de.copy(this),e);let n=de.r,s=de.g,r=de.b,a=Math.max(n,s,r),o=Math.min(n,s,r),l,c,h=(o+a)/2;if(o===a)l=0,c=0;else{let p=a-o;switch(c=h<=.5?p/(a+o):p/(2-a-o),a){case n:l=(s-r)/p+(s<r?6:0);break;case s:l=(r-n)/p+2;break;case r:l=(n-s)/p+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=Wt.workingColorSpace){return Wt.fromWorkingColorSpace(de.copy(this),e),t.r=de.r,t.g=de.g,t.b=de.b,t}getStyle(t=Xe){Wt.fromWorkingColorSpace(de.copy(this),t);let e=de.r,n=de.g,s=de.b;return t!==Xe?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(t,e,n){return this.getHSL(fn),this.setHSL(fn.h+t,fn.s+e,fn.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(fn),t.getHSL(Wi);let n=Ai(fn.h,Wi.h,e),s=Ai(fn.s,Wi.s,e),r=Ai(fn.l,Wi.l,e);return this.setHSL(n,s,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,n=this.g,s=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*s,this.g=r[1]*e+r[4]*n+r[7]*s,this.b=r[2]*e+r[5]*n+r[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},de=new zt;zt.NAMES=Il;var hh=0,vn=class extends rn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:hh++}),this.uuid=_i(),this.name="",this.type="Material",this.blending=Un,this.side=xn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Mr,this.blendDst=Sr,this.blendEquation=Cn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new zt(0,0,0),this.blendAlpha=0,this.depthFunc=hi,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=vo,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Wn,this.stencilZFail=Wn,this.stencilZPass=Wn,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(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let 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(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),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(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).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(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).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(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).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!==Un&&(n.blending=this.blending),this.side!==xn&&(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!==Mr&&(n.blendSrc=this.blendSrc),this.blendDst!==Sr&&(n.blendDst=this.blendDst),this.blendEquation!==Cn&&(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!==hi&&(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!==vo&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Wn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Wn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Wn&&(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 s(r){let a=[];for(let o in r){let l=r[o];delete l.metadata,a.push(l)}return a}if(e){let r=s(t.textures),a=s(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}},bs=class extends vn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new zt(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 on,this.combine=gl,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}};var re=new L,Xi=new It,ye=class{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=yo,this.updateRanges=[],this.gpuType=en,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[t+s]=e.array[n+s];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Xi.fromBufferAttribute(this,e),Xi.applyMatrix3(t),this.setXY(e,Xi.x,Xi.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)re.fromBufferAttribute(this,e),re.applyMatrix3(t),this.setXYZ(e,re.x,re.y,re.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)re.fromBufferAttribute(this,e),re.applyMatrix4(t),this.setXYZ(e,re.x,re.y,re.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)re.fromBufferAttribute(this,e),re.applyNormalMatrix(t),this.setXYZ(e,re.x,re.y,re.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)re.fromBufferAttribute(this,e),re.transformDirection(t),this.setXYZ(e,re.x,re.y,re.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=si(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=pe(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=si(e,this.array)),e}setX(t,e){return this.normalized&&(e=pe(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=si(e,this.array)),e}setY(t,e){return this.normalized&&(e=pe(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=si(e,this.array)),e}setZ(t,e){return this.normalized&&(e=pe(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=si(e,this.array)),e}setW(t,e){return this.normalized&&(e=pe(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=pe(e,this.array),n=pe(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,s){return t*=this.itemSize,this.normalized&&(e=pe(e,this.array),n=pe(n,this.array),s=pe(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t*=this.itemSize,this.normalized&&(e=pe(e,this.array),n=pe(n,this.array),s=pe(s,this.array),r=pe(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==yo&&(t.usage=this.usage),t}};var Es=class extends ye{constructor(t,e,n){super(new Uint16Array(t),e,n)}};var ws=class extends ye{constructor(t,e,n){super(new Uint32Array(t),e,n)}};var ke=class extends ye{constructor(t,e,n){super(new Float32Array(t),e,n)}},uh=0,Ce=new ee,hr=new Ae,ti=new L,Te=new On,bi=new On,ce=new L,He=class i extends rn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:uh++}),this.uuid=_i(),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(t){return Array.isArray(t)?this.index=new(Pl(t)?ws:Es)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Pt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return Ce.makeRotationFromQuaternion(t),this.applyMatrix4(Ce),this}rotateX(t){return Ce.makeRotationX(t),this.applyMatrix4(Ce),this}rotateY(t){return Ce.makeRotationY(t),this.applyMatrix4(Ce),this}rotateZ(t){return Ce.makeRotationZ(t),this.applyMatrix4(Ce),this}translate(t,e,n){return Ce.makeTranslation(t,e,n),this.applyMatrix4(Ce),this}scale(t,e,n){return Ce.makeScale(t,e,n),this.applyMatrix4(Ce),this}lookAt(t){return hr.lookAt(t),hr.updateMatrix(),this.applyMatrix4(hr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ti).negate(),this.translate(ti.x,ti.y,ti.z),this}setFromPoints(t){let e=[];for(let n=0,s=t.length;n<s;n++){let r=t[n];e.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new ke(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new On);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new L(-1/0,-1/0,-1/0),new L(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n<s;n++){let r=e[n];Te.setFromBufferAttribute(r),this.morphTargetsRelative?(ce.addVectors(this.boundingBox.min,Te.min),this.boundingBox.expandByPoint(ce),ce.addVectors(this.boundingBox.max,Te.max),this.boundingBox.expandByPoint(ce)):(this.boundingBox.expandByPoint(Te.min),this.boundingBox.expandByPoint(Te.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 Fn);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new L,1/0);return}if(t){let n=this.boundingSphere.center;if(Te.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){let o=e[r];bi.setFromBufferAttribute(o),this.morphTargetsRelative?(ce.addVectors(Te.min,bi.min),Te.expandByPoint(ce),ce.addVectors(Te.max,bi.max),Te.expandByPoint(ce)):(Te.expandByPoint(bi.min),Te.expandByPoint(bi.max))}Te.getCenter(n);let s=0;for(let r=0,a=t.count;r<a;r++)ce.fromBufferAttribute(t,r),s=Math.max(s,n.distanceToSquared(ce));if(e)for(let r=0,a=e.length;r<a;r++){let o=e[r],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)ce.fromBufferAttribute(o,c),l&&(ti.fromBufferAttribute(t,c),ce.add(ti)),s=Math.max(s,n.distanceToSquared(ce))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=e.position,s=e.normal,r=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ye(new Float32Array(4*n.count),4));let a=this.getAttribute("tangent"),o=[],l=[];for(let F=0;F<n.count;F++)o[F]=new L,l[F]=new L;let c=new L,h=new L,p=new L,f=new It,m=new It,x=new It,y=new L,d=new L;function u(F,tt,g){c.fromBufferAttribute(n,F),h.fromBufferAttribute(n,tt),p.fromBufferAttribute(n,g),f.fromBufferAttribute(r,F),m.fromBufferAttribute(r,tt),x.fromBufferAttribute(r,g),h.sub(c),p.sub(c),m.sub(f),x.sub(f);let M=1/(m.x*x.y-x.x*m.y);isFinite(M)&&(y.copy(h).multiplyScalar(x.y).addScaledVector(p,-m.y).multiplyScalar(M),d.copy(p).multiplyScalar(m.x).addScaledVector(h,-x.x).multiplyScalar(M),o[F].add(y),o[tt].add(y),o[g].add(y),l[F].add(d),l[tt].add(d),l[g].add(d))}let w=this.groups;w.length===0&&(w=[{start:0,count:t.count}]);for(let F=0,tt=w.length;F<tt;++F){let g=w[F],M=g.start,H=g.count;for(let z=M,G=M+H;z<G;z+=3)u(t.getX(z+0),t.getX(z+1),t.getX(z+2))}let S=new L,E=new L,O=new L,C=new L;function T(F){O.fromBufferAttribute(s,F),C.copy(O);let tt=o[F];S.copy(tt),S.sub(O.multiplyScalar(O.dot(tt))).normalize(),E.crossVectors(C,tt);let M=E.dot(l[F])<0?-1:1;a.setXYZW(F,S.x,S.y,S.z,M)}for(let F=0,tt=w.length;F<tt;++F){let g=w[F],M=g.start,H=g.count;for(let z=M,G=M+H;z<G;z+=3)T(t.getX(z+0)),T(t.getX(z+1)),T(t.getX(z+2))}}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new ye(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let f=0,m=n.count;f<m;f++)n.setXYZ(f,0,0,0);let s=new L,r=new L,a=new L,o=new L,l=new L,c=new L,h=new L,p=new L;if(t)for(let f=0,m=t.count;f<m;f+=3){let x=t.getX(f+0),y=t.getX(f+1),d=t.getX(f+2);s.fromBufferAttribute(e,x),r.fromBufferAttribute(e,y),a.fromBufferAttribute(e,d),h.subVectors(a,r),p.subVectors(s,r),h.cross(p),o.fromBufferAttribute(n,x),l.fromBufferAttribute(n,y),c.fromBufferAttribute(n,d),o.add(h),l.add(h),c.add(h),n.setXYZ(x,o.x,o.y,o.z),n.setXYZ(y,l.x,l.y,l.z),n.setXYZ(d,c.x,c.y,c.z)}else for(let f=0,m=e.count;f<m;f+=3)s.fromBufferAttribute(e,f+0),r.fromBufferAttribute(e,f+1),a.fromBufferAttribute(e,f+2),h.subVectors(a,r),p.subVectors(s,r),h.cross(p),n.setXYZ(f+0,h.x,h.y,h.z),n.setXYZ(f+1,h.x,h.y,h.z),n.setXYZ(f+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)ce.fromBufferAttribute(t,e),ce.normalize(),t.setXYZ(e,ce.x,ce.y,ce.z)}toNonIndexed(){function t(o,l){let c=o.array,h=o.itemSize,p=o.normalized,f=new c.constructor(l.length*h),m=0,x=0;for(let y=0,d=l.length;y<d;y++){o.isInterleavedBufferAttribute?m=l[y]*o.data.stride+o.offset:m=l[y]*h;for(let u=0;u<h;u++)f[x++]=c[m++]}return new ye(f,h,p)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new i,n=this.index.array,s=this.attributes;for(let o in s){let l=s[o],c=t(l,n);e.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let l=[],c=r[o];for(let h=0,p=c.length;h<p;h++){let f=c[h],m=t(f,n);l.push(m)}e.morphAttributes[o]=l}e.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let o=0,l=a.length;o<l;o++){let c=a[o];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){let t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let l in n){let c=n[l];t.data.attributes[l]=c.toJSON(t.data)}let s={},r=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let p=0,f=c.length;p<f;p++){let m=c[p];h.push(m.toJSON(t.data))}h.length>0&&(s[l]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone(e));let s=t.attributes;for(let c in s){let h=s[c];this.setAttribute(c,h.clone(e))}let r=t.morphAttributes;for(let c in r){let h=[],p=r[c];for(let f=0,m=p.length;f<m;f++)h.push(p[f].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;let a=t.groups;for(let c=0,h=a.length;c<h;c++){let p=a[c];this.addGroup(p.start,p.count,p.materialIndex)}let o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());let l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},No=new ee,En=new Bn,Yi=new Fn,Oo=new L,qi=new L,Zi=new L,Ji=new L,ur=new L,Ki=new L,Fo=new L,$i=new L,Ie=class extends Ae{constructor(t=new He,e=new bs){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(t,e){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(s,t);let o=this.morphTargetInfluences;if(r&&o){Ki.set(0,0,0);for(let l=0,c=r.length;l<c;l++){let h=o[l],p=r[l];h!==0&&(ur.fromBufferAttribute(p,t),a?Ki.addScaledVector(ur,h):Ki.addScaledVector(ur.sub(e),h))}e.add(Ki)}return e}raycast(t,e){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Yi.copy(n.boundingSphere),Yi.applyMatrix4(r),En.copy(t.ray).recast(t.near),!(Yi.containsPoint(En.origin)===!1&&(En.intersectSphere(Yi,Oo)===null||En.origin.distanceToSquared(Oo)>(t.far-t.near)**2))&&(No.copy(r).invert(),En.copy(t.ray).applyMatrix4(No),!(n.boundingBox!==null&&En.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,En)))}_computeIntersections(t,e,n){let s,r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,p=r.attributes.normal,f=r.groups,m=r.drawRange;if(o!==null)if(Array.isArray(a))for(let x=0,y=f.length;x<y;x++){let d=f[x],u=a[d.materialIndex],w=Math.max(d.start,m.start),S=Math.min(o.count,Math.min(d.start+d.count,m.start+m.count));for(let E=w,O=S;E<O;E+=3){let C=o.getX(E),T=o.getX(E+1),F=o.getX(E+2);s=ji(this,u,t,n,c,h,p,C,T,F),s&&(s.faceIndex=Math.floor(E/3),s.face.materialIndex=d.materialIndex,e.push(s))}}else{let x=Math.max(0,m.start),y=Math.min(o.count,m.start+m.count);for(let d=x,u=y;d<u;d+=3){let w=o.getX(d),S=o.getX(d+1),E=o.getX(d+2);s=ji(this,a,t,n,c,h,p,w,S,E),s&&(s.faceIndex=Math.floor(d/3),e.push(s))}}else if(l!==void 0)if(Array.isArray(a))for(let x=0,y=f.length;x<y;x++){let d=f[x],u=a[d.materialIndex],w=Math.max(d.start,m.start),S=Math.min(l.count,Math.min(d.start+d.count,m.start+m.count));for(let E=w,O=S;E<O;E+=3){let C=E,T=E+1,F=E+2;s=ji(this,u,t,n,c,h,p,C,T,F),s&&(s.faceIndex=Math.floor(E/3),s.face.materialIndex=d.materialIndex,e.push(s))}}else{let x=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let d=x,u=y;d<u;d+=3){let w=d,S=d+1,E=d+2;s=ji(this,a,t,n,c,h,p,w,S,E),s&&(s.faceIndex=Math.floor(d/3),e.push(s))}}}};function dh(i,t,e,n,s,r,a,o){let l;if(t.side===ve?l=n.intersectTriangle(a,r,s,!0,o):l=n.intersectTriangle(s,r,a,t.side===xn,o),l===null)return null;$i.copy(o),$i.applyMatrix4(i.matrixWorld);let c=e.ray.origin.distanceTo($i);return c<e.near||c>e.far?null:{distance:c,point:$i.clone(),object:i}}function ji(i,t,e,n,s,r,a,o,l,c){i.getVertexPosition(o,qi),i.getVertexPosition(l,Zi),i.getVertexPosition(c,Ji);let h=dh(i,t,e,n,qi,Zi,Ji,Fo);if(h){let p=new L;Pn.getBarycoord(Fo,qi,Zi,Ji,p),s&&(h.uv=Pn.getInterpolatedAttribute(s,o,l,c,p,new It)),r&&(h.uv1=Pn.getInterpolatedAttribute(r,o,l,c,p,new It)),a&&(h.normal=Pn.getInterpolatedAttribute(a,o,l,c,p,new L),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let f={a:o,b:l,c,normal:new L,materialIndex:0};Pn.getNormal(qi,Zi,Ji,f.normal),h.face=f,h.barycoord=p}return h}var Ii=class i extends He{constructor(t=1,e=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};let o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);let l=[],c=[],h=[],p=[],f=0,m=0;x("z","y","x",-1,-1,n,e,t,a,r,0),x("z","y","x",1,-1,n,e,-t,a,r,1),x("x","z","y",1,1,t,n,e,s,a,2),x("x","z","y",1,-1,t,n,-e,s,a,3),x("x","y","z",1,-1,t,e,n,s,r,4),x("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new ke(c,3)),this.setAttribute("normal",new ke(h,3)),this.setAttribute("uv",new ke(p,2));function x(y,d,u,w,S,E,O,C,T,F,tt){let g=E/T,M=O/F,H=E/2,z=O/2,G=C/2,J=T+1,B=F+1,j=0,V=0,ot=new L;for(let lt=0;lt<B;lt++){let gt=lt*M-z;for(let kt=0;kt<J;kt++){let Xt=kt*g-H;ot[y]=Xt*w,ot[d]=gt*S,ot[u]=G,c.push(ot.x,ot.y,ot.z),ot[y]=0,ot[d]=0,ot[u]=C>0?1:-1,h.push(ot.x,ot.y,ot.z),p.push(kt/T),p.push(1-lt/F),j+=1}}for(let lt=0;lt<F;lt++)for(let gt=0;gt<T;gt++){let kt=f+gt+J*lt,Xt=f+gt+J*(lt+1),W=f+(gt+1)+J*(lt+1),K=f+(gt+1)+J*lt;l.push(kt,Xt,K),l.push(Xt,W,K),V+=6}o.addGroup(m,V,tt),m+=V,f+=j}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new i(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}};function mi(i){let t={};for(let e in i){t[e]={};for(let n in i[e]){let s=i[e][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=s.clone():Array.isArray(s)?t[e][n]=s.slice():t[e][n]=s}}return t}function me(i){let t={};for(let e=0;e<i.length;e++){let n=mi(i[e]);for(let s in n)t[s]=n[s]}return t}function fh(i){let t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function Ll(i){let t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Wt.workingColorSpace}var ph={clone:mi,merge:me},mh=`void main() {
2
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
+ }`,gh=`void main() {
4
+ gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
5
+ }`,Ge=class extends vn{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=mh,this.fragmentShader=gh,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={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,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=mi(t.uniforms),this.uniformsGroups=fh(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){let e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(let s in this.uniforms){let a=this.uniforms[s].value;a&&a.isTexture?e.uniforms[s]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[s]={type:"m4",value:a.toArray()}:e.uniforms[s]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}},Ts=class extends Ae{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ee,this.projectionMatrix=new ee,this.projectionMatrixInverse=new ee,this.coordinateSystem=nn}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},pn=new L,Bo=new It,zo=new It,xe=class extends Ts{constructor(t=50,e=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=.5*this.getFilmHeight()/t;this.fov=Pi*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(Ti*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Pi*2*Math.atan(Math.tan(Ti*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){pn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(pn.x,pn.y).multiplyScalar(-t/pn.z),pn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(pn.x,pn.y).multiplyScalar(-t/pn.z)}getViewSize(t,e){return this.getViewBounds(t,Bo,zo),e.subVectors(zo,Bo)}setViewOffset(t,e,n,s,r,a){this.aspect=t/e,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(Ti*.5*this.fov)/this.zoom,n=2*e,s=this.aspect*n,r=-.5*s,a=this.view;if(this.view!==null&&this.view.enabled){let l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,e-=a.offsetY*n/c,s*=a.width/l,n*=a.height/c}let o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}},ei=-90,ni=1,ha=class extends Ae{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new xe(ei,ni,t,e);s.layers=this.layers,this.add(s);let r=new xe(ei,ni,t,e);r.layers=this.layers,this.add(r);let a=new xe(ei,ni,t,e);a.layers=this.layers,this.add(a);let o=new xe(ei,ni,t,e);o.layers=this.layers,this.add(o);let l=new xe(ei,ni,t,e);l.layers=this.layers,this.add(l);let c=new xe(ei,ni,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let t=this.coordinateSystem,e=this.children.concat(),[n,s,r,a,o,l]=e;for(let c of e)this.remove(c);if(t===nn)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.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),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(t===xs)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.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),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(let c of e)this.add(c),c.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());let[r,a,o,l,c,h]=this.children,p=t.getRenderTarget(),f=t.getActiveCubeFace(),m=t.getActiveMipmapLevel(),x=t.xr.enabled;t.xr.enabled=!1;let y=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,s),t.render(e,r),t.setRenderTarget(n,1,s),t.render(e,a),t.setRenderTarget(n,2,s),t.render(e,o),t.setRenderTarget(n,3,s),t.render(e,l),t.setRenderTarget(n,4,s),t.render(e,c),n.texture.generateMipmaps=y,t.setRenderTarget(n,5,s),t.render(e,h),t.setRenderTarget(p,f,m),t.xr.enabled=x,n.texture.needsPMREMUpdate=!0}},As=class extends Le{constructor(t,e,n,s,r,a,o,l,c,h){t=t!==void 0?t:[],e=e!==void 0?e:ui,super(t,e,n,s,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},ua=class extends an{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];this.texture=new As(s,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:Be}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
6
+
7
+ varying vec3 vWorldDirection;
8
+
9
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
10
+
11
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
12
+
13
+ }
14
+
15
+ void main() {
16
+
17
+ vWorldDirection = transformDirection( position, modelMatrix );
18
+
19
+ #include <begin_vertex>
20
+ #include <project_vertex>
21
+
22
+ }
23
+ `,fragmentShader:`
24
+
25
+ uniform sampler2D tEquirect;
26
+
27
+ varying vec3 vWorldDirection;
28
+
29
+ #include <common>
30
+
31
+ void main() {
32
+
33
+ vec3 direction = normalize( vWorldDirection );
34
+
35
+ vec2 sampleUV = equirectUv( direction );
36
+
37
+ gl_FragColor = texture2D( tEquirect, sampleUV );
38
+
39
+ }
40
+ `},s=new Ii(5,5,5),r=new Ge({name:"CubemapFromEquirect",uniforms:mi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:ve,blending:gn});r.uniforms.tEquirect.value=e;let a=new Ie(s,r),o=e.minFilter;return e.minFilter===Dn&&(e.minFilter=Be),new ha(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,n,s){let r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,s);t.setRenderTarget(r)}},dr=new L,_h=new L,xh=new Pt,Fe=class{constructor(t=new L(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,s){return this.normal.set(t,e,n),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let s=dr.subVectors(n,e).cross(_h.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){let n=t.delta(dr),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let r=-(t.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let n=e||xh.getNormalMatrix(t),s=this.coplanarPoint(dr).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}},wn=new Fn,Qi=new L,Rs=class{constructor(t=new Fe,e=new Fe,n=new Fe,s=new Fe,r=new Fe,a=new Fe){this.planes=[t,e,n,s,r,a]}set(t,e,n,s,r,a){let o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(t){let e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=nn){let n=this.planes,s=t.elements,r=s[0],a=s[1],o=s[2],l=s[3],c=s[4],h=s[5],p=s[6],f=s[7],m=s[8],x=s[9],y=s[10],d=s[11],u=s[12],w=s[13],S=s[14],E=s[15];if(n[0].setComponents(l-r,f-c,d-m,E-u).normalize(),n[1].setComponents(l+r,f+c,d+m,E+u).normalize(),n[2].setComponents(l+a,f+h,d+x,E+w).normalize(),n[3].setComponents(l-a,f-h,d-x,E-w).normalize(),n[4].setComponents(l-o,f-p,d-y,E-S).normalize(),e===nn)n[5].setComponents(l+o,f+p,d+y,E+S).normalize();else if(e===xs)n[5].setComponents(o,p,y,S).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),wn.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),wn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(wn)}intersectsSprite(t){return wn.center.set(0,0,0),wn.radius=.7071067811865476,wn.applyMatrix4(t.matrixWorld),this.intersectsSphere(wn)}intersectsSphere(t){let e=this.planes,n=t.center,s=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(t){let e=this.planes;for(let n=0;n<6;n++){let s=e[n];if(Qi.x=s.normal.x>0?t.max.x:t.min.x,Qi.y=s.normal.y>0?t.max.y:t.min.y,Qi.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(Qi)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function Dl(){let i=null,t=!1,e=null,n=null;function s(r,a){e(r,a),n=i.requestAnimationFrame(s)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){i=r}}}function vh(i){let t=new WeakMap;function e(o,l){let c=o.array,h=o.usage,p=c.byteLength,f=i.createBuffer();i.bindBuffer(l,f),i.bufferData(l,c,h),o.onUploadCallback();let m;if(c instanceof Float32Array)m=i.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?m=i.HALF_FLOAT:m=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)m=i.SHORT;else if(c instanceof Uint32Array)m=i.UNSIGNED_INT;else if(c instanceof Int32Array)m=i.INT;else if(c instanceof Int8Array)m=i.BYTE;else if(c instanceof Uint8Array)m=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)m=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:f,type:m,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:p}}function n(o,l,c){let h=l.array,p=l.updateRanges;if(i.bindBuffer(c,o),p.length===0)i.bufferSubData(c,0,h);else{p.sort((m,x)=>m.start-x.start);let f=0;for(let m=1;m<p.length;m++){let x=p[f],y=p[m];y.start<=x.start+x.count+1?x.count=Math.max(x.count,y.start+y.count-x.start):(++f,p[f]=y)}p.length=f+1;for(let m=0,x=p.length;m<x;m++){let y=p[m];i.bufferSubData(c,y.start*h.BYTES_PER_ELEMENT,h,y.start,y.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),t.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);let l=t.get(o);l&&(i.deleteBuffer(l.buffer),t.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){let h=t.get(o);(!h||h.version<o.version)&&t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let c=t.get(o);if(c===void 0)t.set(o,e(o,l));else if(c.version<o.version){if(c.size!==o.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.");n(c.buffer,o,l),c.version=o.version}}return{get:s,remove:r,update:a}}var Cs=class i extends He{constructor(t=1,e=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:s};let r=t/2,a=e/2,o=Math.floor(n),l=Math.floor(s),c=o+1,h=l+1,p=t/o,f=e/l,m=[],x=[],y=[],d=[];for(let u=0;u<h;u++){let w=u*f-a;for(let S=0;S<c;S++){let E=S*p-r;x.push(E,-w,0),y.push(0,0,1),d.push(S/o),d.push(1-u/l)}}for(let u=0;u<l;u++)for(let w=0;w<o;w++){let S=w+c*u,E=w+c*(u+1),O=w+1+c*(u+1),C=w+1+c*u;m.push(S,E,C),m.push(E,O,C)}this.setIndex(m),this.setAttribute("position",new ke(x,3)),this.setAttribute("normal",new ke(y,3)),this.setAttribute("uv",new ke(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new i(t.width,t.height,t.widthSegments,t.heightSegments)}},yh=`#ifdef USE_ALPHAHASH
41
+ if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
42
+ #endif`,Mh=`#ifdef USE_ALPHAHASH
43
+ const float ALPHA_HASH_SCALE = 0.05;
44
+ float hash2D( vec2 value ) {
45
+ return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
46
+ }
47
+ float hash3D( vec3 value ) {
48
+ return hash2D( vec2( hash2D( value.xy ), value.z ) );
49
+ }
50
+ float getAlphaHashThreshold( vec3 position ) {
51
+ float maxDeriv = max(
52
+ length( dFdx( position.xyz ) ),
53
+ length( dFdy( position.xyz ) )
54
+ );
55
+ float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
56
+ vec2 pixScales = vec2(
57
+ exp2( floor( log2( pixScale ) ) ),
58
+ exp2( ceil( log2( pixScale ) ) )
59
+ );
60
+ vec2 alpha = vec2(
61
+ hash3D( floor( pixScales.x * position.xyz ) ),
62
+ hash3D( floor( pixScales.y * position.xyz ) )
63
+ );
64
+ float lerpFactor = fract( log2( pixScale ) );
65
+ float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
66
+ float a = min( lerpFactor, 1.0 - lerpFactor );
67
+ vec3 cases = vec3(
68
+ x * x / ( 2.0 * a * ( 1.0 - a ) ),
69
+ ( x - 0.5 * a ) / ( 1.0 - a ),
70
+ 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
71
+ );
72
+ float threshold = ( x < ( 1.0 - a ) )
73
+ ? ( ( x < a ) ? cases.x : cases.y )
74
+ : cases.z;
75
+ return clamp( threshold , 1.0e-6, 1.0 );
76
+ }
77
+ #endif`,Sh=`#ifdef USE_ALPHAMAP
78
+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
79
+ #endif`,bh=`#ifdef USE_ALPHAMAP
80
+ uniform sampler2D alphaMap;
81
+ #endif`,Eh=`#ifdef USE_ALPHATEST
82
+ #ifdef ALPHA_TO_COVERAGE
83
+ diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
84
+ if ( diffuseColor.a == 0.0 ) discard;
85
+ #else
86
+ if ( diffuseColor.a < alphaTest ) discard;
87
+ #endif
88
+ #endif`,wh=`#ifdef USE_ALPHATEST
89
+ uniform float alphaTest;
90
+ #endif`,Th=`#ifdef USE_AOMAP
91
+ float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
92
+ reflectedLight.indirectDiffuse *= ambientOcclusion;
93
+ #if defined( USE_CLEARCOAT )
94
+ clearcoatSpecularIndirect *= ambientOcclusion;
95
+ #endif
96
+ #if defined( USE_SHEEN )
97
+ sheenSpecularIndirect *= ambientOcclusion;
98
+ #endif
99
+ #if defined( USE_ENVMAP ) && defined( STANDARD )
100
+ float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
101
+ reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
102
+ #endif
103
+ #endif`,Ah=`#ifdef USE_AOMAP
104
+ uniform sampler2D aoMap;
105
+ uniform float aoMapIntensity;
106
+ #endif`,Rh=`#ifdef USE_BATCHING
107
+ #if ! defined( GL_ANGLE_multi_draw )
108
+ #define gl_DrawID _gl_DrawID
109
+ uniform int _gl_DrawID;
110
+ #endif
111
+ uniform highp sampler2D batchingTexture;
112
+ uniform highp usampler2D batchingIdTexture;
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
+ float getIndirectIndex( const in int i ) {
125
+ int size = textureSize( batchingIdTexture, 0 ).x;
126
+ int x = i % size;
127
+ int y = i / size;
128
+ return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
129
+ }
130
+ #endif
131
+ #ifdef USE_BATCHING_COLOR
132
+ uniform sampler2D batchingColorTexture;
133
+ vec3 getBatchingColor( const in float i ) {
134
+ int size = textureSize( batchingColorTexture, 0 ).x;
135
+ int j = int( i );
136
+ int x = j % size;
137
+ int y = j / size;
138
+ return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
139
+ }
140
+ #endif`,Ch=`#ifdef USE_BATCHING
141
+ mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
142
+ #endif`,Ph=`vec3 transformed = vec3( position );
143
+ #ifdef USE_ALPHAHASH
144
+ vPosition = vec3( position );
145
+ #endif`,Ih=`vec3 objectNormal = vec3( normal );
146
+ #ifdef USE_TANGENT
147
+ vec3 objectTangent = vec3( tangent.xyz );
148
+ #endif`,Lh=`float G_BlinnPhong_Implicit( ) {
149
+ return 0.25;
150
+ }
151
+ float D_BlinnPhong( const in float shininess, const in float dotNH ) {
152
+ return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
153
+ }
154
+ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
155
+ vec3 halfDir = normalize( lightDir + viewDir );
156
+ float dotNH = saturate( dot( normal, halfDir ) );
157
+ float dotVH = saturate( dot( viewDir, halfDir ) );
158
+ vec3 F = F_Schlick( specularColor, 1.0, dotVH );
159
+ float G = G_BlinnPhong_Implicit( );
160
+ float D = D_BlinnPhong( shininess, dotNH );
161
+ return F * ( G * D );
162
+ } // validated`,Dh=`#ifdef USE_IRIDESCENCE
163
+ const mat3 XYZ_TO_REC709 = mat3(
164
+ 3.2404542, -0.9692660, 0.0556434,
165
+ -1.5371385, 1.8760108, -0.2040259,
166
+ -0.4985314, 0.0415560, 1.0572252
167
+ );
168
+ vec3 Fresnel0ToIor( vec3 fresnel0 ) {
169
+ vec3 sqrtF0 = sqrt( fresnel0 );
170
+ return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
171
+ }
172
+ vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
173
+ return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
174
+ }
175
+ float IorToFresnel0( float transmittedIor, float incidentIor ) {
176
+ return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
177
+ }
178
+ vec3 evalSensitivity( float OPD, vec3 shift ) {
179
+ float phase = 2.0 * PI * OPD * 1.0e-9;
180
+ vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
181
+ vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
182
+ vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
183
+ vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
184
+ 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 ) );
185
+ xyz /= 1.0685e-7;
186
+ vec3 rgb = XYZ_TO_REC709 * xyz;
187
+ return rgb;
188
+ }
189
+ vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
190
+ vec3 I;
191
+ float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
192
+ float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
193
+ float cosTheta2Sq = 1.0 - sinTheta2Sq;
194
+ if ( cosTheta2Sq < 0.0 ) {
195
+ return vec3( 1.0 );
196
+ }
197
+ float cosTheta2 = sqrt( cosTheta2Sq );
198
+ float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
199
+ float R12 = F_Schlick( R0, 1.0, cosTheta1 );
200
+ float T121 = 1.0 - R12;
201
+ float phi12 = 0.0;
202
+ if ( iridescenceIOR < outsideIOR ) phi12 = PI;
203
+ float phi21 = PI - phi12;
204
+ vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
205
+ vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
206
+ vec3 phi23 = vec3( 0.0 );
207
+ if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
208
+ if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
209
+ if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
210
+ float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
211
+ vec3 phi = vec3( phi21 ) + phi23;
212
+ vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
213
+ vec3 r123 = sqrt( R123 );
214
+ vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
215
+ vec3 C0 = R12 + Rs;
216
+ I = C0;
217
+ vec3 Cm = Rs - T121;
218
+ for ( int m = 1; m <= 2; ++ m ) {
219
+ Cm *= r123;
220
+ vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
221
+ I += Cm * Sm;
222
+ }
223
+ return max( I, vec3( 0.0 ) );
224
+ }
225
+ #endif`,Uh=`#ifdef USE_BUMPMAP
226
+ uniform sampler2D bumpMap;
227
+ uniform float bumpScale;
228
+ vec2 dHdxy_fwd() {
229
+ vec2 dSTdx = dFdx( vBumpMapUv );
230
+ vec2 dSTdy = dFdy( vBumpMapUv );
231
+ float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
232
+ float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
233
+ float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
234
+ return vec2( dBx, dBy );
235
+ }
236
+ vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
237
+ vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
238
+ vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
239
+ vec3 vN = surf_norm;
240
+ vec3 R1 = cross( vSigmaY, vN );
241
+ vec3 R2 = cross( vN, vSigmaX );
242
+ float fDet = dot( vSigmaX, R1 ) * faceDirection;
243
+ vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
244
+ return normalize( abs( fDet ) * surf_norm - vGrad );
245
+ }
246
+ #endif`,Nh=`#if NUM_CLIPPING_PLANES > 0
247
+ vec4 plane;
248
+ #ifdef ALPHA_TO_COVERAGE
249
+ float distanceToPlane, distanceGradient;
250
+ float clipOpacity = 1.0;
251
+ #pragma unroll_loop_start
252
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
253
+ plane = clippingPlanes[ i ];
254
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
255
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
256
+ clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
257
+ if ( clipOpacity == 0.0 ) discard;
258
+ }
259
+ #pragma unroll_loop_end
260
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
261
+ float unionClipOpacity = 1.0;
262
+ #pragma unroll_loop_start
263
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
264
+ plane = clippingPlanes[ i ];
265
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
266
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
267
+ unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
268
+ }
269
+ #pragma unroll_loop_end
270
+ clipOpacity *= 1.0 - unionClipOpacity;
271
+ #endif
272
+ diffuseColor.a *= clipOpacity;
273
+ if ( diffuseColor.a == 0.0 ) discard;
274
+ #else
275
+ #pragma unroll_loop_start
276
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
277
+ plane = clippingPlanes[ i ];
278
+ if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
279
+ }
280
+ #pragma unroll_loop_end
281
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
282
+ bool clipped = true;
283
+ #pragma unroll_loop_start
284
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
285
+ plane = clippingPlanes[ i ];
286
+ clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
287
+ }
288
+ #pragma unroll_loop_end
289
+ if ( clipped ) discard;
290
+ #endif
291
+ #endif
292
+ #endif`,Oh=`#if NUM_CLIPPING_PLANES > 0
293
+ varying vec3 vClipPosition;
294
+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
295
+ #endif`,Fh=`#if NUM_CLIPPING_PLANES > 0
296
+ varying vec3 vClipPosition;
297
+ #endif`,Bh=`#if NUM_CLIPPING_PLANES > 0
298
+ vClipPosition = - mvPosition.xyz;
299
+ #endif`,zh=`#if defined( USE_COLOR_ALPHA )
300
+ diffuseColor *= vColor;
301
+ #elif defined( USE_COLOR )
302
+ diffuseColor.rgb *= vColor;
303
+ #endif`,kh=`#if defined( USE_COLOR_ALPHA )
304
+ varying vec4 vColor;
305
+ #elif defined( USE_COLOR )
306
+ varying vec3 vColor;
307
+ #endif`,Vh=`#if defined( USE_COLOR_ALPHA )
308
+ varying vec4 vColor;
309
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
310
+ varying vec3 vColor;
311
+ #endif`,Hh=`#if defined( USE_COLOR_ALPHA )
312
+ vColor = vec4( 1.0 );
313
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
314
+ vColor = vec3( 1.0 );
315
+ #endif
316
+ #ifdef USE_COLOR
317
+ vColor *= color;
318
+ #endif
319
+ #ifdef USE_INSTANCING_COLOR
320
+ vColor.xyz *= instanceColor.xyz;
321
+ #endif
322
+ #ifdef USE_BATCHING_COLOR
323
+ vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
324
+ vColor.xyz *= batchingColor.xyz;
325
+ #endif`,Gh=`#define PI 3.141592653589793
326
+ #define PI2 6.283185307179586
327
+ #define PI_HALF 1.5707963267948966
328
+ #define RECIPROCAL_PI 0.3183098861837907
329
+ #define RECIPROCAL_PI2 0.15915494309189535
330
+ #define EPSILON 1e-6
331
+ #ifndef saturate
332
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
333
+ #endif
334
+ #define whiteComplement( a ) ( 1.0 - saturate( a ) )
335
+ float pow2( const in float x ) { return x*x; }
336
+ vec3 pow2( const in vec3 x ) { return x*x; }
337
+ float pow3( const in float x ) { return x*x*x; }
338
+ float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
339
+ float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
340
+ float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
341
+ highp float rand( const in vec2 uv ) {
342
+ const highp float a = 12.9898, b = 78.233, c = 43758.5453;
343
+ highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
344
+ return fract( sin( sn ) * c );
345
+ }
346
+ #ifdef HIGH_PRECISION
347
+ float precisionSafeLength( vec3 v ) { return length( v ); }
348
+ #else
349
+ float precisionSafeLength( vec3 v ) {
350
+ float maxComponent = max3( abs( v ) );
351
+ return length( v / maxComponent ) * maxComponent;
352
+ }
353
+ #endif
354
+ struct IncidentLight {
355
+ vec3 color;
356
+ vec3 direction;
357
+ bool visible;
358
+ };
359
+ struct ReflectedLight {
360
+ vec3 directDiffuse;
361
+ vec3 directSpecular;
362
+ vec3 indirectDiffuse;
363
+ vec3 indirectSpecular;
364
+ };
365
+ #ifdef USE_ALPHAHASH
366
+ varying vec3 vPosition;
367
+ #endif
368
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
369
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
370
+ }
371
+ vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
372
+ return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
373
+ }
374
+ mat3 transposeMat3( const in mat3 m ) {
375
+ mat3 tmp;
376
+ tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
377
+ tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
378
+ tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
379
+ return tmp;
380
+ }
381
+ bool isPerspectiveMatrix( mat4 m ) {
382
+ return m[ 2 ][ 3 ] == - 1.0;
383
+ }
384
+ vec2 equirectUv( in vec3 dir ) {
385
+ float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
386
+ float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
387
+ return vec2( u, v );
388
+ }
389
+ vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
390
+ return RECIPROCAL_PI * diffuseColor;
391
+ }
392
+ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
393
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
394
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
395
+ }
396
+ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
397
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
398
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
399
+ } // validated`,Wh=`#ifdef ENVMAP_TYPE_CUBE_UV
400
+ #define cubeUV_minMipLevel 4.0
401
+ #define cubeUV_minTileSize 16.0
402
+ float getFace( vec3 direction ) {
403
+ vec3 absDirection = abs( direction );
404
+ float face = - 1.0;
405
+ if ( absDirection.x > absDirection.z ) {
406
+ if ( absDirection.x > absDirection.y )
407
+ face = direction.x > 0.0 ? 0.0 : 3.0;
408
+ else
409
+ face = direction.y > 0.0 ? 1.0 : 4.0;
410
+ } else {
411
+ if ( absDirection.z > absDirection.y )
412
+ face = direction.z > 0.0 ? 2.0 : 5.0;
413
+ else
414
+ face = direction.y > 0.0 ? 1.0 : 4.0;
415
+ }
416
+ return face;
417
+ }
418
+ vec2 getUV( vec3 direction, float face ) {
419
+ vec2 uv;
420
+ if ( face == 0.0 ) {
421
+ uv = vec2( direction.z, direction.y ) / abs( direction.x );
422
+ } else if ( face == 1.0 ) {
423
+ uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
424
+ } else if ( face == 2.0 ) {
425
+ uv = vec2( - direction.x, direction.y ) / abs( direction.z );
426
+ } else if ( face == 3.0 ) {
427
+ uv = vec2( - direction.z, direction.y ) / abs( direction.x );
428
+ } else if ( face == 4.0 ) {
429
+ uv = vec2( - direction.x, direction.z ) / abs( direction.y );
430
+ } else {
431
+ uv = vec2( direction.x, direction.y ) / abs( direction.z );
432
+ }
433
+ return 0.5 * ( uv + 1.0 );
434
+ }
435
+ vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
436
+ float face = getFace( direction );
437
+ float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
438
+ mipInt = max( mipInt, cubeUV_minMipLevel );
439
+ float faceSize = exp2( mipInt );
440
+ highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
441
+ if ( face > 2.0 ) {
442
+ uv.y += faceSize;
443
+ face -= 3.0;
444
+ }
445
+ uv.x += face * faceSize;
446
+ uv.x += filterInt * 3.0 * cubeUV_minTileSize;
447
+ uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
448
+ uv.x *= CUBEUV_TEXEL_WIDTH;
449
+ uv.y *= CUBEUV_TEXEL_HEIGHT;
450
+ #ifdef texture2DGradEXT
451
+ return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
452
+ #else
453
+ return texture2D( envMap, uv ).rgb;
454
+ #endif
455
+ }
456
+ #define cubeUV_r0 1.0
457
+ #define cubeUV_m0 - 2.0
458
+ #define cubeUV_r1 0.8
459
+ #define cubeUV_m1 - 1.0
460
+ #define cubeUV_r4 0.4
461
+ #define cubeUV_m4 2.0
462
+ #define cubeUV_r5 0.305
463
+ #define cubeUV_m5 3.0
464
+ #define cubeUV_r6 0.21
465
+ #define cubeUV_m6 4.0
466
+ float roughnessToMip( float roughness ) {
467
+ float mip = 0.0;
468
+ if ( roughness >= cubeUV_r1 ) {
469
+ mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
470
+ } else if ( roughness >= cubeUV_r4 ) {
471
+ mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
472
+ } else if ( roughness >= cubeUV_r5 ) {
473
+ mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
474
+ } else if ( roughness >= cubeUV_r6 ) {
475
+ mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
476
+ } else {
477
+ mip = - 2.0 * log2( 1.16 * roughness ); }
478
+ return mip;
479
+ }
480
+ vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
481
+ float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
482
+ float mipF = fract( mip );
483
+ float mipInt = floor( mip );
484
+ vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
485
+ if ( mipF == 0.0 ) {
486
+ return vec4( color0, 1.0 );
487
+ } else {
488
+ vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
489
+ return vec4( mix( color0, color1, mipF ), 1.0 );
490
+ }
491
+ }
492
+ #endif`,Xh=`vec3 transformedNormal = objectNormal;
493
+ #ifdef USE_TANGENT
494
+ vec3 transformedTangent = objectTangent;
495
+ #endif
496
+ #ifdef USE_BATCHING
497
+ mat3 bm = mat3( batchingMatrix );
498
+ transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
499
+ transformedNormal = bm * transformedNormal;
500
+ #ifdef USE_TANGENT
501
+ transformedTangent = bm * transformedTangent;
502
+ #endif
503
+ #endif
504
+ #ifdef USE_INSTANCING
505
+ mat3 im = mat3( instanceMatrix );
506
+ transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
507
+ transformedNormal = im * transformedNormal;
508
+ #ifdef USE_TANGENT
509
+ transformedTangent = im * transformedTangent;
510
+ #endif
511
+ #endif
512
+ transformedNormal = normalMatrix * transformedNormal;
513
+ #ifdef FLIP_SIDED
514
+ transformedNormal = - transformedNormal;
515
+ #endif
516
+ #ifdef USE_TANGENT
517
+ transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
518
+ #ifdef FLIP_SIDED
519
+ transformedTangent = - transformedTangent;
520
+ #endif
521
+ #endif`,Yh=`#ifdef USE_DISPLACEMENTMAP
522
+ uniform sampler2D displacementMap;
523
+ uniform float displacementScale;
524
+ uniform float displacementBias;
525
+ #endif`,qh=`#ifdef USE_DISPLACEMENTMAP
526
+ transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
527
+ #endif`,Zh=`#ifdef USE_EMISSIVEMAP
528
+ vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
529
+ totalEmissiveRadiance *= emissiveColor.rgb;
530
+ #endif`,Jh=`#ifdef USE_EMISSIVEMAP
531
+ uniform sampler2D emissiveMap;
532
+ #endif`,Kh="gl_FragColor = linearToOutputTexel( gl_FragColor );",$h=`
533
+ const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
534
+ vec3( 0.8224621, 0.177538, 0.0 ),
535
+ vec3( 0.0331941, 0.9668058, 0.0 ),
536
+ vec3( 0.0170827, 0.0723974, 0.9105199 )
537
+ );
538
+ const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
539
+ vec3( 1.2249401, - 0.2249404, 0.0 ),
540
+ vec3( - 0.0420569, 1.0420571, 0.0 ),
541
+ vec3( - 0.0196376, - 0.0786361, 1.0982735 )
542
+ );
543
+ vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
544
+ return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
545
+ }
546
+ vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
547
+ return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
548
+ }
549
+ vec4 LinearTransferOETF( in vec4 value ) {
550
+ return value;
551
+ }
552
+ vec4 sRGBTransferOETF( in vec4 value ) {
553
+ 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 );
554
+ }`,jh=`#ifdef USE_ENVMAP
555
+ #ifdef ENV_WORLDPOS
556
+ vec3 cameraToFrag;
557
+ if ( isOrthographic ) {
558
+ cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
559
+ } else {
560
+ cameraToFrag = normalize( vWorldPosition - cameraPosition );
561
+ }
562
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
563
+ #ifdef ENVMAP_MODE_REFLECTION
564
+ vec3 reflectVec = reflect( cameraToFrag, worldNormal );
565
+ #else
566
+ vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
567
+ #endif
568
+ #else
569
+ vec3 reflectVec = vReflect;
570
+ #endif
571
+ #ifdef ENVMAP_TYPE_CUBE
572
+ vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
573
+ #else
574
+ vec4 envColor = vec4( 0.0 );
575
+ #endif
576
+ #ifdef ENVMAP_BLENDING_MULTIPLY
577
+ outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
578
+ #elif defined( ENVMAP_BLENDING_MIX )
579
+ outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
580
+ #elif defined( ENVMAP_BLENDING_ADD )
581
+ outgoingLight += envColor.xyz * specularStrength * reflectivity;
582
+ #endif
583
+ #endif`,Qh=`#ifdef USE_ENVMAP
584
+ uniform float envMapIntensity;
585
+ uniform float flipEnvMap;
586
+ uniform mat3 envMapRotation;
587
+ #ifdef ENVMAP_TYPE_CUBE
588
+ uniform samplerCube envMap;
589
+ #else
590
+ uniform sampler2D envMap;
591
+ #endif
592
+
593
+ #endif`,tu=`#ifdef USE_ENVMAP
594
+ uniform float reflectivity;
595
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
596
+ #define ENV_WORLDPOS
597
+ #endif
598
+ #ifdef ENV_WORLDPOS
599
+ varying vec3 vWorldPosition;
600
+ uniform float refractionRatio;
601
+ #else
602
+ varying vec3 vReflect;
603
+ #endif
604
+ #endif`,eu=`#ifdef USE_ENVMAP
605
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
606
+ #define ENV_WORLDPOS
607
+ #endif
608
+ #ifdef ENV_WORLDPOS
609
+
610
+ varying vec3 vWorldPosition;
611
+ #else
612
+ varying vec3 vReflect;
613
+ uniform float refractionRatio;
614
+ #endif
615
+ #endif`,nu=`#ifdef USE_ENVMAP
616
+ #ifdef ENV_WORLDPOS
617
+ vWorldPosition = worldPosition.xyz;
618
+ #else
619
+ vec3 cameraToVertex;
620
+ if ( isOrthographic ) {
621
+ cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
622
+ } else {
623
+ cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
624
+ }
625
+ vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
626
+ #ifdef ENVMAP_MODE_REFLECTION
627
+ vReflect = reflect( cameraToVertex, worldNormal );
628
+ #else
629
+ vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
630
+ #endif
631
+ #endif
632
+ #endif`,iu=`#ifdef USE_FOG
633
+ vFogDepth = - mvPosition.z;
634
+ #endif`,su=`#ifdef USE_FOG
635
+ varying float vFogDepth;
636
+ #endif`,ru=`#ifdef USE_FOG
637
+ #ifdef FOG_EXP2
638
+ float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
639
+ #else
640
+ float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
641
+ #endif
642
+ gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
643
+ #endif`,au=`#ifdef USE_FOG
644
+ uniform vec3 fogColor;
645
+ varying float vFogDepth;
646
+ #ifdef FOG_EXP2
647
+ uniform float fogDensity;
648
+ #else
649
+ uniform float fogNear;
650
+ uniform float fogFar;
651
+ #endif
652
+ #endif`,ou=`#ifdef USE_GRADIENTMAP
653
+ uniform sampler2D gradientMap;
654
+ #endif
655
+ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
656
+ float dotNL = dot( normal, lightDirection );
657
+ vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
658
+ #ifdef USE_GRADIENTMAP
659
+ return vec3( texture2D( gradientMap, coord ).r );
660
+ #else
661
+ vec2 fw = fwidth( coord ) * 0.5;
662
+ return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
663
+ #endif
664
+ }`,lu=`#ifdef USE_LIGHTMAP
665
+ uniform sampler2D lightMap;
666
+ uniform float lightMapIntensity;
667
+ #endif`,cu=`LambertMaterial material;
668
+ material.diffuseColor = diffuseColor.rgb;
669
+ material.specularStrength = specularStrength;`,hu=`varying vec3 vViewPosition;
670
+ struct LambertMaterial {
671
+ vec3 diffuseColor;
672
+ float specularStrength;
673
+ };
674
+ 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 ) {
675
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
676
+ vec3 irradiance = dotNL * directLight.color;
677
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
678
+ }
679
+ 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 ) {
680
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
681
+ }
682
+ #define RE_Direct RE_Direct_Lambert
683
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,uu=`uniform bool receiveShadow;
684
+ uniform vec3 ambientLightColor;
685
+ #if defined( USE_LIGHT_PROBES )
686
+ uniform vec3 lightProbe[ 9 ];
687
+ #endif
688
+ vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
689
+ float x = normal.x, y = normal.y, z = normal.z;
690
+ vec3 result = shCoefficients[ 0 ] * 0.886227;
691
+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
692
+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
693
+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
694
+ result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
695
+ result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
696
+ result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
697
+ result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
698
+ result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
699
+ return result;
700
+ }
701
+ vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
702
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
703
+ vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
704
+ return irradiance;
705
+ }
706
+ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
707
+ vec3 irradiance = ambientLightColor;
708
+ return irradiance;
709
+ }
710
+ float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
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
+ }
717
+ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
718
+ return smoothstep( coneCosine, penumbraCosine, angleCosine );
719
+ }
720
+ #if NUM_DIR_LIGHTS > 0
721
+ struct DirectionalLight {
722
+ vec3 direction;
723
+ vec3 color;
724
+ };
725
+ uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
726
+ void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
727
+ light.color = directionalLight.color;
728
+ light.direction = directionalLight.direction;
729
+ light.visible = true;
730
+ }
731
+ #endif
732
+ #if NUM_POINT_LIGHTS > 0
733
+ struct PointLight {
734
+ vec3 position;
735
+ vec3 color;
736
+ float distance;
737
+ float decay;
738
+ };
739
+ uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
740
+ void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
741
+ vec3 lVector = pointLight.position - geometryPosition;
742
+ light.direction = normalize( lVector );
743
+ float lightDistance = length( lVector );
744
+ light.color = pointLight.color;
745
+ light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
746
+ light.visible = ( light.color != vec3( 0.0 ) );
747
+ }
748
+ #endif
749
+ #if NUM_SPOT_LIGHTS > 0
750
+ struct SpotLight {
751
+ vec3 position;
752
+ vec3 direction;
753
+ vec3 color;
754
+ float distance;
755
+ float decay;
756
+ float coneCos;
757
+ float penumbraCos;
758
+ };
759
+ uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
760
+ void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
761
+ vec3 lVector = spotLight.position - geometryPosition;
762
+ light.direction = normalize( lVector );
763
+ float angleCos = dot( light.direction, spotLight.direction );
764
+ float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
765
+ if ( spotAttenuation > 0.0 ) {
766
+ float lightDistance = length( lVector );
767
+ light.color = spotLight.color * spotAttenuation;
768
+ light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
769
+ light.visible = ( light.color != vec3( 0.0 ) );
770
+ } else {
771
+ light.color = vec3( 0.0 );
772
+ light.visible = false;
773
+ }
774
+ }
775
+ #endif
776
+ #if NUM_RECT_AREA_LIGHTS > 0
777
+ struct RectAreaLight {
778
+ vec3 color;
779
+ vec3 position;
780
+ vec3 halfWidth;
781
+ vec3 halfHeight;
782
+ };
783
+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;
784
+ uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
785
+ #endif
786
+ #if NUM_HEMI_LIGHTS > 0
787
+ struct HemisphereLight {
788
+ vec3 direction;
789
+ vec3 skyColor;
790
+ vec3 groundColor;
791
+ };
792
+ uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
793
+ vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
794
+ float dotNL = dot( normal, hemiLight.direction );
795
+ float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
796
+ vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
797
+ return irradiance;
798
+ }
799
+ #endif`,du=`#ifdef USE_ENVMAP
800
+ vec3 getIBLIrradiance( const in vec3 normal ) {
801
+ #ifdef ENVMAP_TYPE_CUBE_UV
802
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
803
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
804
+ return PI * envMapColor.rgb * envMapIntensity;
805
+ #else
806
+ return vec3( 0.0 );
807
+ #endif
808
+ }
809
+ vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
810
+ #ifdef ENVMAP_TYPE_CUBE_UV
811
+ vec3 reflectVec = reflect( - viewDir, normal );
812
+ reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
813
+ reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
814
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
815
+ return envMapColor.rgb * envMapIntensity;
816
+ #else
817
+ return vec3( 0.0 );
818
+ #endif
819
+ }
820
+ #ifdef USE_ANISOTROPY
821
+ vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
822
+ #ifdef ENVMAP_TYPE_CUBE_UV
823
+ vec3 bentNormal = cross( bitangent, viewDir );
824
+ bentNormal = normalize( cross( bentNormal, bitangent ) );
825
+ bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
826
+ return getIBLRadiance( viewDir, bentNormal, roughness );
827
+ #else
828
+ return vec3( 0.0 );
829
+ #endif
830
+ }
831
+ #endif
832
+ #endif`,fu=`ToonMaterial material;
833
+ material.diffuseColor = diffuseColor.rgb;`,pu=`varying vec3 vViewPosition;
834
+ struct ToonMaterial {
835
+ vec3 diffuseColor;
836
+ };
837
+ 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 ) {
838
+ vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
839
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
840
+ }
841
+ 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 ) {
842
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
843
+ }
844
+ #define RE_Direct RE_Direct_Toon
845
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,mu=`BlinnPhongMaterial material;
846
+ material.diffuseColor = diffuseColor.rgb;
847
+ material.specularColor = specular;
848
+ material.specularShininess = shininess;
849
+ material.specularStrength = specularStrength;`,gu=`varying vec3 vViewPosition;
850
+ struct BlinnPhongMaterial {
851
+ vec3 diffuseColor;
852
+ vec3 specularColor;
853
+ float specularShininess;
854
+ float specularStrength;
855
+ };
856
+ 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 ) {
857
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
858
+ vec3 irradiance = dotNL * directLight.color;
859
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
860
+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
861
+ }
862
+ 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 ) {
863
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
864
+ }
865
+ #define RE_Direct RE_Direct_BlinnPhong
866
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,_u=`PhysicalMaterial material;
867
+ material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
868
+ vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
869
+ float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
870
+ material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
871
+ material.roughness = min( material.roughness, 1.0 );
872
+ #ifdef IOR
873
+ material.ior = ior;
874
+ #ifdef USE_SPECULAR
875
+ float specularIntensityFactor = specularIntensity;
876
+ vec3 specularColorFactor = specularColor;
877
+ #ifdef USE_SPECULAR_COLORMAP
878
+ specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
879
+ #endif
880
+ #ifdef USE_SPECULAR_INTENSITYMAP
881
+ specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
882
+ #endif
883
+ material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
884
+ #else
885
+ float specularIntensityFactor = 1.0;
886
+ vec3 specularColorFactor = vec3( 1.0 );
887
+ material.specularF90 = 1.0;
888
+ #endif
889
+ material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
890
+ #else
891
+ material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
892
+ material.specularF90 = 1.0;
893
+ #endif
894
+ #ifdef USE_CLEARCOAT
895
+ material.clearcoat = clearcoat;
896
+ material.clearcoatRoughness = clearcoatRoughness;
897
+ material.clearcoatF0 = vec3( 0.04 );
898
+ material.clearcoatF90 = 1.0;
899
+ #ifdef USE_CLEARCOATMAP
900
+ material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
901
+ #endif
902
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
903
+ material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
904
+ #endif
905
+ material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
906
+ material.clearcoatRoughness += geometryRoughness;
907
+ material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
908
+ #endif
909
+ #ifdef USE_DISPERSION
910
+ material.dispersion = dispersion;
911
+ #endif
912
+ #ifdef USE_IRIDESCENCE
913
+ material.iridescence = iridescence;
914
+ material.iridescenceIOR = iridescenceIOR;
915
+ #ifdef USE_IRIDESCENCEMAP
916
+ material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
917
+ #endif
918
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
919
+ material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
920
+ #else
921
+ material.iridescenceThickness = iridescenceThicknessMaximum;
922
+ #endif
923
+ #endif
924
+ #ifdef USE_SHEEN
925
+ material.sheenColor = sheenColor;
926
+ #ifdef USE_SHEEN_COLORMAP
927
+ material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
928
+ #endif
929
+ material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
930
+ #ifdef USE_SHEEN_ROUGHNESSMAP
931
+ material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
932
+ #endif
933
+ #endif
934
+ #ifdef USE_ANISOTROPY
935
+ #ifdef USE_ANISOTROPYMAP
936
+ mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
937
+ vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
938
+ vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
939
+ #else
940
+ vec2 anisotropyV = anisotropyVector;
941
+ #endif
942
+ material.anisotropy = length( anisotropyV );
943
+ if( material.anisotropy == 0.0 ) {
944
+ anisotropyV = vec2( 1.0, 0.0 );
945
+ } else {
946
+ anisotropyV /= material.anisotropy;
947
+ material.anisotropy = saturate( material.anisotropy );
948
+ }
949
+ material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
950
+ material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
951
+ material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
952
+ #endif`,xu=`struct PhysicalMaterial {
953
+ vec3 diffuseColor;
954
+ float roughness;
955
+ vec3 specularColor;
956
+ float specularF90;
957
+ float dispersion;
958
+ #ifdef USE_CLEARCOAT
959
+ float clearcoat;
960
+ float clearcoatRoughness;
961
+ vec3 clearcoatF0;
962
+ float clearcoatF90;
963
+ #endif
964
+ #ifdef USE_IRIDESCENCE
965
+ float iridescence;
966
+ float iridescenceIOR;
967
+ float iridescenceThickness;
968
+ vec3 iridescenceFresnel;
969
+ vec3 iridescenceF0;
970
+ #endif
971
+ #ifdef USE_SHEEN
972
+ vec3 sheenColor;
973
+ float sheenRoughness;
974
+ #endif
975
+ #ifdef IOR
976
+ float ior;
977
+ #endif
978
+ #ifdef USE_TRANSMISSION
979
+ float transmission;
980
+ float transmissionAlpha;
981
+ float thickness;
982
+ float attenuationDistance;
983
+ vec3 attenuationColor;
984
+ #endif
985
+ #ifdef USE_ANISOTROPY
986
+ float anisotropy;
987
+ float alphaT;
988
+ vec3 anisotropyT;
989
+ vec3 anisotropyB;
990
+ #endif
991
+ };
992
+ vec3 clearcoatSpecularDirect = vec3( 0.0 );
993
+ vec3 clearcoatSpecularIndirect = vec3( 0.0 );
994
+ vec3 sheenSpecularDirect = vec3( 0.0 );
995
+ vec3 sheenSpecularIndirect = vec3(0.0 );
996
+ vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
997
+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
998
+ float x2 = x * x;
999
+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
1000
+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
1001
+ }
1002
+ float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
1003
+ float a2 = pow2( alpha );
1004
+ float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
1005
+ float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
1006
+ return 0.5 / max( gv + gl, EPSILON );
1007
+ }
1008
+ float D_GGX( const in float alpha, const in float dotNH ) {
1009
+ float a2 = pow2( alpha );
1010
+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
1011
+ return RECIPROCAL_PI * a2 / pow2( denom );
1012
+ }
1013
+ #ifdef USE_ANISOTROPY
1014
+ 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 ) {
1015
+ float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
1016
+ float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
1017
+ float v = 0.5 / ( gv + gl );
1018
+ return saturate(v);
1019
+ }
1020
+ float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
1021
+ float a2 = alphaT * alphaB;
1022
+ highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
1023
+ highp float v2 = dot( v, v );
1024
+ float w2 = a2 / v2;
1025
+ return RECIPROCAL_PI * a2 * pow2 ( w2 );
1026
+ }
1027
+ #endif
1028
+ #ifdef USE_CLEARCOAT
1029
+ vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
1030
+ vec3 f0 = material.clearcoatF0;
1031
+ float f90 = material.clearcoatF90;
1032
+ float roughness = material.clearcoatRoughness;
1033
+ float alpha = pow2( roughness );
1034
+ vec3 halfDir = normalize( lightDir + viewDir );
1035
+ float dotNL = saturate( dot( normal, lightDir ) );
1036
+ float dotNV = saturate( dot( normal, viewDir ) );
1037
+ float dotNH = saturate( dot( normal, halfDir ) );
1038
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1039
+ vec3 F = F_Schlick( f0, f90, dotVH );
1040
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1041
+ float D = D_GGX( alpha, dotNH );
1042
+ return F * ( V * D );
1043
+ }
1044
+ #endif
1045
+ vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1046
+ vec3 f0 = material.specularColor;
1047
+ float f90 = material.specularF90;
1048
+ float roughness = material.roughness;
1049
+ float alpha = pow2( roughness );
1050
+ vec3 halfDir = normalize( lightDir + viewDir );
1051
+ float dotNL = saturate( dot( normal, lightDir ) );
1052
+ float dotNV = saturate( dot( normal, viewDir ) );
1053
+ float dotNH = saturate( dot( normal, halfDir ) );
1054
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1055
+ vec3 F = F_Schlick( f0, f90, dotVH );
1056
+ #ifdef USE_IRIDESCENCE
1057
+ F = mix( F, material.iridescenceFresnel, material.iridescence );
1058
+ #endif
1059
+ #ifdef USE_ANISOTROPY
1060
+ float dotTL = dot( material.anisotropyT, lightDir );
1061
+ float dotTV = dot( material.anisotropyT, viewDir );
1062
+ float dotTH = dot( material.anisotropyT, halfDir );
1063
+ float dotBL = dot( material.anisotropyB, lightDir );
1064
+ float dotBV = dot( material.anisotropyB, viewDir );
1065
+ float dotBH = dot( material.anisotropyB, halfDir );
1066
+ float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
1067
+ float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
1068
+ #else
1069
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1070
+ float D = D_GGX( alpha, dotNH );
1071
+ #endif
1072
+ return F * ( V * D );
1073
+ }
1074
+ vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
1075
+ const float LUT_SIZE = 64.0;
1076
+ const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
1077
+ const float LUT_BIAS = 0.5 / LUT_SIZE;
1078
+ float dotNV = saturate( dot( N, V ) );
1079
+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
1080
+ uv = uv * LUT_SCALE + LUT_BIAS;
1081
+ return uv;
1082
+ }
1083
+ float LTC_ClippedSphereFormFactor( const in vec3 f ) {
1084
+ float l = length( f );
1085
+ return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
1086
+ }
1087
+ vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
1088
+ float x = dot( v1, v2 );
1089
+ float y = abs( x );
1090
+ float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
1091
+ float b = 3.4175940 + ( 4.1616724 + y ) * y;
1092
+ float v = a / b;
1093
+ float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
1094
+ return cross( v1, v2 ) * theta_sintheta;
1095
+ }
1096
+ vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
1097
+ vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
1098
+ vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
1099
+ vec3 lightNormal = cross( v1, v2 );
1100
+ if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
1101
+ vec3 T1, T2;
1102
+ T1 = normalize( V - N * dot( V, N ) );
1103
+ T2 = - cross( N, T1 );
1104
+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
1105
+ vec3 coords[ 4 ];
1106
+ coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
1107
+ coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
1108
+ coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
1109
+ coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
1110
+ coords[ 0 ] = normalize( coords[ 0 ] );
1111
+ coords[ 1 ] = normalize( coords[ 1 ] );
1112
+ coords[ 2 ] = normalize( coords[ 2 ] );
1113
+ coords[ 3 ] = normalize( coords[ 3 ] );
1114
+ vec3 vectorFormFactor = vec3( 0.0 );
1115
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
1116
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
1117
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
1118
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
1119
+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
1120
+ return vec3( result );
1121
+ }
1122
+ #if defined( USE_SHEEN )
1123
+ float D_Charlie( float roughness, float dotNH ) {
1124
+ float alpha = pow2( roughness );
1125
+ float invAlpha = 1.0 / alpha;
1126
+ float cos2h = dotNH * dotNH;
1127
+ float sin2h = max( 1.0 - cos2h, 0.0078125 );
1128
+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
1129
+ }
1130
+ float V_Neubelt( float dotNV, float dotNL ) {
1131
+ return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
1132
+ }
1133
+ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
1134
+ vec3 halfDir = normalize( lightDir + viewDir );
1135
+ float dotNL = saturate( dot( normal, lightDir ) );
1136
+ float dotNV = saturate( dot( normal, viewDir ) );
1137
+ float dotNH = saturate( dot( normal, halfDir ) );
1138
+ float D = D_Charlie( sheenRoughness, dotNH );
1139
+ float V = V_Neubelt( dotNV, dotNL );
1140
+ return sheenColor * ( D * V );
1141
+ }
1142
+ #endif
1143
+ float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1144
+ float dotNV = saturate( dot( normal, viewDir ) );
1145
+ float r2 = roughness * roughness;
1146
+ float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
1147
+ float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
1148
+ float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
1149
+ return saturate( DG * RECIPROCAL_PI );
1150
+ }
1151
+ vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1152
+ float dotNV = saturate( dot( normal, viewDir ) );
1153
+ const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
1154
+ const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
1155
+ vec4 r = roughness * c0 + c1;
1156
+ float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
1157
+ vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
1158
+ return fab;
1159
+ }
1160
+ vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
1161
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1162
+ return specularColor * fab.x + specularF90 * fab.y;
1163
+ }
1164
+ #ifdef USE_IRIDESCENCE
1165
+ 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 ) {
1166
+ #else
1167
+ 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 ) {
1168
+ #endif
1169
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1170
+ #ifdef USE_IRIDESCENCE
1171
+ vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
1172
+ #else
1173
+ vec3 Fr = specularColor;
1174
+ #endif
1175
+ vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
1176
+ float Ess = fab.x + fab.y;
1177
+ float Ems = 1.0 - Ess;
1178
+ vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
1179
+ singleScatter += FssEss;
1180
+ multiScatter += Fms * Ems;
1181
+ }
1182
+ #if NUM_RECT_AREA_LIGHTS > 0
1183
+ 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 ) {
1184
+ vec3 normal = geometryNormal;
1185
+ vec3 viewDir = geometryViewDir;
1186
+ vec3 position = geometryPosition;
1187
+ vec3 lightPos = rectAreaLight.position;
1188
+ vec3 halfWidth = rectAreaLight.halfWidth;
1189
+ vec3 halfHeight = rectAreaLight.halfHeight;
1190
+ vec3 lightColor = rectAreaLight.color;
1191
+ float roughness = material.roughness;
1192
+ vec3 rectCoords[ 4 ];
1193
+ rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
1194
+ rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
1195
+ rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
1196
+ vec2 uv = LTC_Uv( normal, viewDir, roughness );
1197
+ vec4 t1 = texture2D( ltc_1, uv );
1198
+ vec4 t2 = texture2D( ltc_2, uv );
1199
+ mat3 mInv = mat3(
1200
+ vec3( t1.x, 0, t1.y ),
1201
+ vec3( 0, 1, 0 ),
1202
+ vec3( t1.z, 0, t1.w )
1203
+ );
1204
+ vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
1205
+ reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
1206
+ reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
1207
+ }
1208
+ #endif
1209
+ 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 ) {
1210
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
1211
+ vec3 irradiance = dotNL * directLight.color;
1212
+ #ifdef USE_CLEARCOAT
1213
+ float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
1214
+ vec3 ccIrradiance = dotNLcc * directLight.color;
1215
+ clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
1216
+ #endif
1217
+ #ifdef USE_SHEEN
1218
+ sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
1219
+ #endif
1220
+ reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
1221
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1222
+ }
1223
+ 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 ) {
1224
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1225
+ }
1226
+ 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) {
1227
+ #ifdef USE_CLEARCOAT
1228
+ clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
1229
+ #endif
1230
+ #ifdef USE_SHEEN
1231
+ sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1232
+ #endif
1233
+ vec3 singleScattering = vec3( 0.0 );
1234
+ vec3 multiScattering = vec3( 0.0 );
1235
+ vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
1236
+ #ifdef USE_IRIDESCENCE
1237
+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
1238
+ #else
1239
+ computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
1240
+ #endif
1241
+ vec3 totalScattering = singleScattering + multiScattering;
1242
+ vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
1243
+ reflectedLight.indirectSpecular += radiance * singleScattering;
1244
+ reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
1245
+ reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
1246
+ }
1247
+ #define RE_Direct RE_Direct_Physical
1248
+ #define RE_Direct_RectArea RE_Direct_RectArea_Physical
1249
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
1250
+ #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1251
+ float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1252
+ return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1253
+ }`,vu=`
1254
+ vec3 geometryPosition = - vViewPosition;
1255
+ vec3 geometryNormal = normal;
1256
+ vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
1257
+ vec3 geometryClearcoatNormal = vec3( 0.0 );
1258
+ #ifdef USE_CLEARCOAT
1259
+ geometryClearcoatNormal = clearcoatNormal;
1260
+ #endif
1261
+ #ifdef USE_IRIDESCENCE
1262
+ float dotNVi = saturate( dot( normal, geometryViewDir ) );
1263
+ if ( material.iridescenceThickness == 0.0 ) {
1264
+ material.iridescence = 0.0;
1265
+ } else {
1266
+ material.iridescence = saturate( material.iridescence );
1267
+ }
1268
+ if ( material.iridescence > 0.0 ) {
1269
+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
1270
+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
1271
+ }
1272
+ #endif
1273
+ IncidentLight directLight;
1274
+ #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
1275
+ PointLight pointLight;
1276
+ #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
1277
+ PointLightShadow pointLightShadow;
1278
+ #endif
1279
+ #pragma unroll_loop_start
1280
+ for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
1281
+ pointLight = pointLights[ i ];
1282
+ getPointLightInfo( pointLight, geometryPosition, directLight );
1283
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
1284
+ pointLightShadow = pointLightShadows[ i ];
1285
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
1286
+ #endif
1287
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1288
+ }
1289
+ #pragma unroll_loop_end
1290
+ #endif
1291
+ #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
1292
+ SpotLight spotLight;
1293
+ vec4 spotColor;
1294
+ vec3 spotLightCoord;
1295
+ bool inSpotLightMap;
1296
+ #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
1297
+ SpotLightShadow spotLightShadow;
1298
+ #endif
1299
+ #pragma unroll_loop_start
1300
+ for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
1301
+ spotLight = spotLights[ i ];
1302
+ getSpotLightInfo( spotLight, geometryPosition, directLight );
1303
+ #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1304
+ #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
1305
+ #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1306
+ #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
1307
+ #else
1308
+ #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1309
+ #endif
1310
+ #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
1311
+ spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
1312
+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
1313
+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
1314
+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
1315
+ #endif
1316
+ #undef SPOT_LIGHT_MAP_INDEX
1317
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1318
+ spotLightShadow = spotLightShadows[ i ];
1319
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1320
+ #endif
1321
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1322
+ }
1323
+ #pragma unroll_loop_end
1324
+ #endif
1325
+ #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
1326
+ DirectionalLight directionalLight;
1327
+ #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
1328
+ DirectionalLightShadow directionalLightShadow;
1329
+ #endif
1330
+ #pragma unroll_loop_start
1331
+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
1332
+ directionalLight = directionalLights[ i ];
1333
+ getDirectionalLightInfo( directionalLight, directLight );
1334
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
1335
+ directionalLightShadow = directionalLightShadows[ i ];
1336
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1337
+ #endif
1338
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1339
+ }
1340
+ #pragma unroll_loop_end
1341
+ #endif
1342
+ #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
1343
+ RectAreaLight rectAreaLight;
1344
+ #pragma unroll_loop_start
1345
+ for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
1346
+ rectAreaLight = rectAreaLights[ i ];
1347
+ RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1348
+ }
1349
+ #pragma unroll_loop_end
1350
+ #endif
1351
+ #if defined( RE_IndirectDiffuse )
1352
+ vec3 iblIrradiance = vec3( 0.0 );
1353
+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
1354
+ #if defined( USE_LIGHT_PROBES )
1355
+ irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
1356
+ #endif
1357
+ #if ( NUM_HEMI_LIGHTS > 0 )
1358
+ #pragma unroll_loop_start
1359
+ for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
1360
+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
1361
+ }
1362
+ #pragma unroll_loop_end
1363
+ #endif
1364
+ #endif
1365
+ #if defined( RE_IndirectSpecular )
1366
+ vec3 radiance = vec3( 0.0 );
1367
+ vec3 clearcoatRadiance = vec3( 0.0 );
1368
+ #endif`,yu=`#if defined( RE_IndirectDiffuse )
1369
+ #ifdef USE_LIGHTMAP
1370
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1371
+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
1372
+ irradiance += lightMapIrradiance;
1373
+ #endif
1374
+ #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
1375
+ iblIrradiance += getIBLIrradiance( geometryNormal );
1376
+ #endif
1377
+ #endif
1378
+ #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
1379
+ #ifdef USE_ANISOTROPY
1380
+ radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
1381
+ #else
1382
+ radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
1383
+ #endif
1384
+ #ifdef USE_CLEARCOAT
1385
+ clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1386
+ #endif
1387
+ #endif`,Mu=`#if defined( RE_IndirectDiffuse )
1388
+ RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1389
+ #endif
1390
+ #if defined( RE_IndirectSpecular )
1391
+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1392
+ #endif`,Su=`#if defined( USE_LOGDEPTHBUF )
1393
+ gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1394
+ #endif`,bu=`#if defined( USE_LOGDEPTHBUF )
1395
+ uniform float logDepthBufFC;
1396
+ varying float vFragDepth;
1397
+ varying float vIsPerspective;
1398
+ #endif`,Eu=`#ifdef USE_LOGDEPTHBUF
1399
+ varying float vFragDepth;
1400
+ varying float vIsPerspective;
1401
+ #endif`,wu=`#ifdef USE_LOGDEPTHBUF
1402
+ vFragDepth = 1.0 + gl_Position.w;
1403
+ vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1404
+ #endif`,Tu=`#ifdef USE_MAP
1405
+ vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1406
+ #ifdef DECODE_VIDEO_TEXTURE
1407
+ 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 );
1408
+
1409
+ #endif
1410
+ diffuseColor *= sampledDiffuseColor;
1411
+ #endif`,Au=`#ifdef USE_MAP
1412
+ uniform sampler2D map;
1413
+ #endif`,Ru=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1414
+ #if defined( USE_POINTS_UV )
1415
+ vec2 uv = vUv;
1416
+ #else
1417
+ vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
1418
+ #endif
1419
+ #endif
1420
+ #ifdef USE_MAP
1421
+ diffuseColor *= texture2D( map, uv );
1422
+ #endif
1423
+ #ifdef USE_ALPHAMAP
1424
+ diffuseColor.a *= texture2D( alphaMap, uv ).g;
1425
+ #endif`,Cu=`#if defined( USE_POINTS_UV )
1426
+ varying vec2 vUv;
1427
+ #else
1428
+ #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1429
+ uniform mat3 uvTransform;
1430
+ #endif
1431
+ #endif
1432
+ #ifdef USE_MAP
1433
+ uniform sampler2D map;
1434
+ #endif
1435
+ #ifdef USE_ALPHAMAP
1436
+ uniform sampler2D alphaMap;
1437
+ #endif`,Pu=`float metalnessFactor = metalness;
1438
+ #ifdef USE_METALNESSMAP
1439
+ vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1440
+ metalnessFactor *= texelMetalness.b;
1441
+ #endif`,Iu=`#ifdef USE_METALNESSMAP
1442
+ uniform sampler2D metalnessMap;
1443
+ #endif`,Lu=`#ifdef USE_INSTANCING_MORPH
1444
+ float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1445
+ float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1446
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1447
+ morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1448
+ }
1449
+ #endif`,Du=`#if defined( USE_MORPHCOLORS )
1450
+ vColor *= morphTargetBaseInfluence;
1451
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1452
+ #if defined( USE_COLOR_ALPHA )
1453
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
1454
+ #elif defined( USE_COLOR )
1455
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1456
+ #endif
1457
+ }
1458
+ #endif`,Uu=`#ifdef USE_MORPHNORMALS
1459
+ objectNormal *= morphTargetBaseInfluence;
1460
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1461
+ if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1462
+ }
1463
+ #endif`,Nu=`#ifdef USE_MORPHTARGETS
1464
+ #ifndef USE_INSTANCING_MORPH
1465
+ uniform float morphTargetBaseInfluence;
1466
+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1467
+ #endif
1468
+ uniform sampler2DArray morphTargetsTexture;
1469
+ uniform ivec2 morphTargetsTextureSize;
1470
+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
1471
+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
1472
+ int y = texelIndex / morphTargetsTextureSize.x;
1473
+ int x = texelIndex - y * morphTargetsTextureSize.x;
1474
+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1475
+ return texelFetch( morphTargetsTexture, morphUV, 0 );
1476
+ }
1477
+ #endif`,Ou=`#ifdef USE_MORPHTARGETS
1478
+ transformed *= morphTargetBaseInfluence;
1479
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1480
+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1481
+ }
1482
+ #endif`,Fu=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1483
+ #ifdef FLAT_SHADED
1484
+ vec3 fdx = dFdx( vViewPosition );
1485
+ vec3 fdy = dFdy( vViewPosition );
1486
+ vec3 normal = normalize( cross( fdx, fdy ) );
1487
+ #else
1488
+ vec3 normal = normalize( vNormal );
1489
+ #ifdef DOUBLE_SIDED
1490
+ normal *= faceDirection;
1491
+ #endif
1492
+ #endif
1493
+ #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
1494
+ #ifdef USE_TANGENT
1495
+ mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1496
+ #else
1497
+ mat3 tbn = getTangentFrame( - vViewPosition, normal,
1498
+ #if defined( USE_NORMALMAP )
1499
+ vNormalMapUv
1500
+ #elif defined( USE_CLEARCOAT_NORMALMAP )
1501
+ vClearcoatNormalMapUv
1502
+ #else
1503
+ vUv
1504
+ #endif
1505
+ );
1506
+ #endif
1507
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1508
+ tbn[0] *= faceDirection;
1509
+ tbn[1] *= faceDirection;
1510
+ #endif
1511
+ #endif
1512
+ #ifdef USE_CLEARCOAT_NORMALMAP
1513
+ #ifdef USE_TANGENT
1514
+ mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1515
+ #else
1516
+ mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
1517
+ #endif
1518
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1519
+ tbn2[0] *= faceDirection;
1520
+ tbn2[1] *= faceDirection;
1521
+ #endif
1522
+ #endif
1523
+ vec3 nonPerturbedNormal = normal;`,Bu=`#ifdef USE_NORMALMAP_OBJECTSPACE
1524
+ normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1525
+ #ifdef FLIP_SIDED
1526
+ normal = - normal;
1527
+ #endif
1528
+ #ifdef DOUBLE_SIDED
1529
+ normal = normal * faceDirection;
1530
+ #endif
1531
+ normal = normalize( normalMatrix * normal );
1532
+ #elif defined( USE_NORMALMAP_TANGENTSPACE )
1533
+ vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1534
+ mapN.xy *= normalScale;
1535
+ normal = normalize( tbn * mapN );
1536
+ #elif defined( USE_BUMPMAP )
1537
+ normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1538
+ #endif`,zu=`#ifndef FLAT_SHADED
1539
+ varying vec3 vNormal;
1540
+ #ifdef USE_TANGENT
1541
+ varying vec3 vTangent;
1542
+ varying vec3 vBitangent;
1543
+ #endif
1544
+ #endif`,ku=`#ifndef FLAT_SHADED
1545
+ varying vec3 vNormal;
1546
+ #ifdef USE_TANGENT
1547
+ varying vec3 vTangent;
1548
+ varying vec3 vBitangent;
1549
+ #endif
1550
+ #endif`,Vu=`#ifndef FLAT_SHADED
1551
+ vNormal = normalize( transformedNormal );
1552
+ #ifdef USE_TANGENT
1553
+ vTangent = normalize( transformedTangent );
1554
+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1555
+ #endif
1556
+ #endif`,Hu=`#ifdef USE_NORMALMAP
1557
+ uniform sampler2D normalMap;
1558
+ uniform vec2 normalScale;
1559
+ #endif
1560
+ #ifdef USE_NORMALMAP_OBJECTSPACE
1561
+ uniform mat3 normalMatrix;
1562
+ #endif
1563
+ #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
1564
+ mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
1565
+ vec3 q0 = dFdx( eye_pos.xyz );
1566
+ vec3 q1 = dFdy( eye_pos.xyz );
1567
+ vec2 st0 = dFdx( uv.st );
1568
+ vec2 st1 = dFdy( uv.st );
1569
+ vec3 N = surf_norm;
1570
+ vec3 q1perp = cross( q1, N );
1571
+ vec3 q0perp = cross( N, q0 );
1572
+ vec3 T = q1perp * st0.x + q0perp * st1.x;
1573
+ vec3 B = q1perp * st0.y + q0perp * st1.y;
1574
+ float det = max( dot( T, T ), dot( B, B ) );
1575
+ float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1576
+ return mat3( T * scale, B * scale, N );
1577
+ }
1578
+ #endif`,Gu=`#ifdef USE_CLEARCOAT
1579
+ vec3 clearcoatNormal = nonPerturbedNormal;
1580
+ #endif`,Wu=`#ifdef USE_CLEARCOAT_NORMALMAP
1581
+ vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1582
+ clearcoatMapN.xy *= clearcoatNormalScale;
1583
+ clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1584
+ #endif`,Xu=`#ifdef USE_CLEARCOATMAP
1585
+ uniform sampler2D clearcoatMap;
1586
+ #endif
1587
+ #ifdef USE_CLEARCOAT_NORMALMAP
1588
+ uniform sampler2D clearcoatNormalMap;
1589
+ uniform vec2 clearcoatNormalScale;
1590
+ #endif
1591
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1592
+ uniform sampler2D clearcoatRoughnessMap;
1593
+ #endif`,Yu=`#ifdef USE_IRIDESCENCEMAP
1594
+ uniform sampler2D iridescenceMap;
1595
+ #endif
1596
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
1597
+ uniform sampler2D iridescenceThicknessMap;
1598
+ #endif`,qu=`#ifdef OPAQUE
1599
+ diffuseColor.a = 1.0;
1600
+ #endif
1601
+ #ifdef USE_TRANSMISSION
1602
+ diffuseColor.a *= material.transmissionAlpha;
1603
+ #endif
1604
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Zu=`vec3 packNormalToRGB( const in vec3 normal ) {
1605
+ return normalize( normal ) * 0.5 + 0.5;
1606
+ }
1607
+ vec3 unpackRGBToNormal( const in vec3 rgb ) {
1608
+ return 2.0 * rgb.xyz - 1.0;
1609
+ }
1610
+ const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
1611
+ const float Inv255 = 1. / 255.;
1612
+ const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
1613
+ const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
1614
+ const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
1615
+ const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
1616
+ vec4 packDepthToRGBA( const in float v ) {
1617
+ if( v <= 0.0 )
1618
+ return vec4( 0., 0., 0., 0. );
1619
+ if( v >= 1.0 )
1620
+ return vec4( 1., 1., 1., 1. );
1621
+ float vuf;
1622
+ float af = modf( v * PackFactors.a, vuf );
1623
+ float bf = modf( vuf * ShiftRight8, vuf );
1624
+ float gf = modf( vuf * ShiftRight8, vuf );
1625
+ return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
1626
+ }
1627
+ vec3 packDepthToRGB( const in float v ) {
1628
+ if( v <= 0.0 )
1629
+ return vec3( 0., 0., 0. );
1630
+ if( v >= 1.0 )
1631
+ return vec3( 1., 1., 1. );
1632
+ float vuf;
1633
+ float bf = modf( v * PackFactors.b, vuf );
1634
+ float gf = modf( vuf * ShiftRight8, vuf );
1635
+ return vec3( vuf * Inv255, gf * PackUpscale, bf );
1636
+ }
1637
+ vec2 packDepthToRG( const in float v ) {
1638
+ if( v <= 0.0 )
1639
+ return vec2( 0., 0. );
1640
+ if( v >= 1.0 )
1641
+ return vec2( 1., 1. );
1642
+ float vuf;
1643
+ float gf = modf( v * 256., vuf );
1644
+ return vec2( vuf * Inv255, gf );
1645
+ }
1646
+ float unpackRGBAToDepth( const in vec4 v ) {
1647
+ return dot( v, UnpackFactors4 );
1648
+ }
1649
+ float unpackRGBToDepth( const in vec3 v ) {
1650
+ return dot( v, UnpackFactors3 );
1651
+ }
1652
+ float unpackRGToDepth( const in vec2 v ) {
1653
+ return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
1654
+ }
1655
+ vec4 pack2HalfToRGBA( const in vec2 v ) {
1656
+ vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
1657
+ return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
1658
+ }
1659
+ vec2 unpackRGBATo2Half( const in vec4 v ) {
1660
+ return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
1661
+ }
1662
+ float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
1663
+ return ( viewZ + near ) / ( near - far );
1664
+ }
1665
+ float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
1666
+ return depth * ( near - far ) - near;
1667
+ }
1668
+ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
1669
+ return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
1670
+ }
1671
+ float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1672
+ return ( near * far ) / ( ( far - near ) * depth - far );
1673
+ }`,Ju=`#ifdef PREMULTIPLIED_ALPHA
1674
+ gl_FragColor.rgb *= gl_FragColor.a;
1675
+ #endif`,Ku=`vec4 mvPosition = vec4( transformed, 1.0 );
1676
+ #ifdef USE_BATCHING
1677
+ mvPosition = batchingMatrix * mvPosition;
1678
+ #endif
1679
+ #ifdef USE_INSTANCING
1680
+ mvPosition = instanceMatrix * mvPosition;
1681
+ #endif
1682
+ mvPosition = modelViewMatrix * mvPosition;
1683
+ gl_Position = projectionMatrix * mvPosition;`,$u=`#ifdef DITHERING
1684
+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1685
+ #endif`,ju=`#ifdef DITHERING
1686
+ vec3 dithering( vec3 color ) {
1687
+ float grid_position = rand( gl_FragCoord.xy );
1688
+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1689
+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1690
+ return color + dither_shift_RGB;
1691
+ }
1692
+ #endif`,Qu=`float roughnessFactor = roughness;
1693
+ #ifdef USE_ROUGHNESSMAP
1694
+ vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1695
+ roughnessFactor *= texelRoughness.g;
1696
+ #endif`,td=`#ifdef USE_ROUGHNESSMAP
1697
+ uniform sampler2D roughnessMap;
1698
+ #endif`,ed=`#if NUM_SPOT_LIGHT_COORDS > 0
1699
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1700
+ #endif
1701
+ #if NUM_SPOT_LIGHT_MAPS > 0
1702
+ uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
1703
+ #endif
1704
+ #ifdef USE_SHADOWMAP
1705
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1706
+ uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
1707
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1708
+ struct DirectionalLightShadow {
1709
+ float shadowIntensity;
1710
+ float shadowBias;
1711
+ float shadowNormalBias;
1712
+ float shadowRadius;
1713
+ vec2 shadowMapSize;
1714
+ };
1715
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1716
+ #endif
1717
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1718
+ uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
1719
+ struct SpotLightShadow {
1720
+ float shadowIntensity;
1721
+ float shadowBias;
1722
+ float shadowNormalBias;
1723
+ float shadowRadius;
1724
+ vec2 shadowMapSize;
1725
+ };
1726
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1727
+ #endif
1728
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1729
+ uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
1730
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1731
+ struct PointLightShadow {
1732
+ float shadowIntensity;
1733
+ float shadowBias;
1734
+ float shadowNormalBias;
1735
+ float shadowRadius;
1736
+ vec2 shadowMapSize;
1737
+ float shadowCameraNear;
1738
+ float shadowCameraFar;
1739
+ };
1740
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1741
+ #endif
1742
+ float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
1743
+ return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
1744
+ }
1745
+ vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
1746
+ return unpackRGBATo2Half( texture2D( shadow, uv ) );
1747
+ }
1748
+ float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
1749
+ float occlusion = 1.0;
1750
+ vec2 distribution = texture2DDistribution( shadow, uv );
1751
+ float hard_shadow = step( compare , distribution.x );
1752
+ if (hard_shadow != 1.0 ) {
1753
+ float distance = compare - distribution.x ;
1754
+ float variance = max( 0.00000, distribution.y * distribution.y );
1755
+ 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 );
1756
+ }
1757
+ return occlusion;
1758
+ }
1759
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1760
+ float shadow = 1.0;
1761
+ shadowCoord.xyz /= shadowCoord.w;
1762
+ shadowCoord.z += shadowBias;
1763
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1764
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1765
+ if ( frustumTest ) {
1766
+ #if defined( SHADOWMAP_TYPE_PCF )
1767
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1768
+ float dx0 = - texelSize.x * shadowRadius;
1769
+ float dy0 = - texelSize.y * shadowRadius;
1770
+ float dx1 = + texelSize.x * shadowRadius;
1771
+ float dy1 = + texelSize.y * shadowRadius;
1772
+ float dx2 = dx0 / 2.0;
1773
+ float dy2 = dy0 / 2.0;
1774
+ float dx3 = dx1 / 2.0;
1775
+ float dy3 = dy1 / 2.0;
1776
+ shadow = (
1777
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
1778
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
1779
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
1780
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
1781
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
1782
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
1783
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
1784
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
1785
+ texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
1786
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
1787
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
1788
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
1789
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
1790
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
1791
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
1792
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
1793
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
1794
+ ) * ( 1.0 / 17.0 );
1795
+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
1796
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1797
+ float dx = texelSize.x;
1798
+ float dy = texelSize.y;
1799
+ vec2 uv = shadowCoord.xy;
1800
+ vec2 f = fract( uv * shadowMapSize + 0.5 );
1801
+ uv -= f * texelSize;
1802
+ shadow = (
1803
+ texture2DCompare( shadowMap, uv, shadowCoord.z ) +
1804
+ texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
1805
+ texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
1806
+ texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
1807
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
1808
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
1809
+ f.x ) +
1810
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
1811
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
1812
+ f.x ) +
1813
+ mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
1814
+ texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
1815
+ f.y ) +
1816
+ mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
1817
+ texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
1818
+ f.y ) +
1819
+ mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
1820
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
1821
+ f.x ),
1822
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
1823
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
1824
+ f.x ),
1825
+ f.y )
1826
+ ) * ( 1.0 / 9.0 );
1827
+ #elif defined( SHADOWMAP_TYPE_VSM )
1828
+ shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
1829
+ #else
1830
+ shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
1831
+ #endif
1832
+ }
1833
+ return mix( 1.0, shadow, shadowIntensity );
1834
+ }
1835
+ vec2 cubeToUV( vec3 v, float texelSizeY ) {
1836
+ vec3 absV = abs( v );
1837
+ float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
1838
+ absV *= scaleToCube;
1839
+ v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
1840
+ vec2 planar = v.xy;
1841
+ float almostATexel = 1.5 * texelSizeY;
1842
+ float almostOne = 1.0 - almostATexel;
1843
+ if ( absV.z >= almostOne ) {
1844
+ if ( v.z > 0.0 )
1845
+ planar.x = 4.0 - v.x;
1846
+ } else if ( absV.x >= almostOne ) {
1847
+ float signX = sign( v.x );
1848
+ planar.x = v.z * signX + 2.0 * signX;
1849
+ } else if ( absV.y >= almostOne ) {
1850
+ float signY = sign( v.y );
1851
+ planar.x = v.x + 2.0 * signY + 2.0;
1852
+ planar.y = v.z * signY - 2.0;
1853
+ }
1854
+ return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
1855
+ }
1856
+ float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
1857
+ float shadow = 1.0;
1858
+ vec3 lightToPosition = shadowCoord.xyz;
1859
+
1860
+ float lightToPositionLength = length( lightToPosition );
1861
+ if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
1862
+ float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
1863
+ vec3 bd3D = normalize( lightToPosition );
1864
+ vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
1865
+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
1866
+ vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
1867
+ shadow = (
1868
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
1869
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
1870
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
1871
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
1872
+ texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
1873
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
1874
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
1875
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
1876
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
1877
+ ) * ( 1.0 / 9.0 );
1878
+ #else
1879
+ shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
1880
+ #endif
1881
+ }
1882
+ return mix( 1.0, shadow, shadowIntensity );
1883
+ }
1884
+ #endif`,nd=`#if NUM_SPOT_LIGHT_COORDS > 0
1885
+ uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1886
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1887
+ #endif
1888
+ #ifdef USE_SHADOWMAP
1889
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1890
+ uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
1891
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1892
+ struct DirectionalLightShadow {
1893
+ float shadowIntensity;
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 shadowIntensity;
1904
+ float shadowBias;
1905
+ float shadowNormalBias;
1906
+ float shadowRadius;
1907
+ vec2 shadowMapSize;
1908
+ };
1909
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1910
+ #endif
1911
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1912
+ uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
1913
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1914
+ struct PointLightShadow {
1915
+ float shadowIntensity;
1916
+ float shadowBias;
1917
+ float shadowNormalBias;
1918
+ float shadowRadius;
1919
+ vec2 shadowMapSize;
1920
+ float shadowCameraNear;
1921
+ float shadowCameraFar;
1922
+ };
1923
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1924
+ #endif
1925
+ #endif`,id=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1926
+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1927
+ vec4 shadowWorldPosition;
1928
+ #endif
1929
+ #if defined( USE_SHADOWMAP )
1930
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1931
+ #pragma unroll_loop_start
1932
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1933
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
1934
+ vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
1935
+ }
1936
+ #pragma unroll_loop_end
1937
+ #endif
1938
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1939
+ #pragma unroll_loop_start
1940
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1941
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
1942
+ vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
1943
+ }
1944
+ #pragma unroll_loop_end
1945
+ #endif
1946
+ #endif
1947
+ #if NUM_SPOT_LIGHT_COORDS > 0
1948
+ #pragma unroll_loop_start
1949
+ for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
1950
+ shadowWorldPosition = worldPosition;
1951
+ #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1952
+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
1953
+ #endif
1954
+ vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1955
+ }
1956
+ #pragma unroll_loop_end
1957
+ #endif`,sd=`float getShadowMask() {
1958
+ float shadow = 1.0;
1959
+ #ifdef USE_SHADOWMAP
1960
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1961
+ DirectionalLightShadow directionalLight;
1962
+ #pragma unroll_loop_start
1963
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1964
+ directionalLight = directionalLightShadows[ i ];
1965
+ shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1966
+ }
1967
+ #pragma unroll_loop_end
1968
+ #endif
1969
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1970
+ SpotLightShadow spotLight;
1971
+ #pragma unroll_loop_start
1972
+ for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
1973
+ spotLight = spotLightShadows[ i ];
1974
+ shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1975
+ }
1976
+ #pragma unroll_loop_end
1977
+ #endif
1978
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1979
+ PointLightShadow pointLight;
1980
+ #pragma unroll_loop_start
1981
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1982
+ pointLight = pointLightShadows[ i ];
1983
+ shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
1984
+ }
1985
+ #pragma unroll_loop_end
1986
+ #endif
1987
+ #endif
1988
+ return shadow;
1989
+ }`,rd=`#ifdef USE_SKINNING
1990
+ mat4 boneMatX = getBoneMatrix( skinIndex.x );
1991
+ mat4 boneMatY = getBoneMatrix( skinIndex.y );
1992
+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );
1993
+ mat4 boneMatW = getBoneMatrix( skinIndex.w );
1994
+ #endif`,ad=`#ifdef USE_SKINNING
1995
+ uniform mat4 bindMatrix;
1996
+ uniform mat4 bindMatrixInverse;
1997
+ uniform highp sampler2D boneTexture;
1998
+ mat4 getBoneMatrix( const in float i ) {
1999
+ int size = textureSize( boneTexture, 0 ).x;
2000
+ int j = int( i ) * 4;
2001
+ int x = j % size;
2002
+ int y = j / size;
2003
+ vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
2004
+ vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
2005
+ vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
2006
+ vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2007
+ return mat4( v1, v2, v3, v4 );
2008
+ }
2009
+ #endif`,od=`#ifdef USE_SKINNING
2010
+ vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2011
+ vec4 skinned = vec4( 0.0 );
2012
+ skinned += boneMatX * skinVertex * skinWeight.x;
2013
+ skinned += boneMatY * skinVertex * skinWeight.y;
2014
+ skinned += boneMatZ * skinVertex * skinWeight.z;
2015
+ skinned += boneMatW * skinVertex * skinWeight.w;
2016
+ transformed = ( bindMatrixInverse * skinned ).xyz;
2017
+ #endif`,ld=`#ifdef USE_SKINNING
2018
+ mat4 skinMatrix = mat4( 0.0 );
2019
+ skinMatrix += skinWeight.x * boneMatX;
2020
+ skinMatrix += skinWeight.y * boneMatY;
2021
+ skinMatrix += skinWeight.z * boneMatZ;
2022
+ skinMatrix += skinWeight.w * boneMatW;
2023
+ skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
2024
+ objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
2025
+ #ifdef USE_TANGENT
2026
+ objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2027
+ #endif
2028
+ #endif`,cd=`float specularStrength;
2029
+ #ifdef USE_SPECULARMAP
2030
+ vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2031
+ specularStrength = texelSpecular.r;
2032
+ #else
2033
+ specularStrength = 1.0;
2034
+ #endif`,hd=`#ifdef USE_SPECULARMAP
2035
+ uniform sampler2D specularMap;
2036
+ #endif`,ud=`#if defined( TONE_MAPPING )
2037
+ gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2038
+ #endif`,dd=`#ifndef saturate
2039
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
2040
+ #endif
2041
+ uniform float toneMappingExposure;
2042
+ vec3 LinearToneMapping( vec3 color ) {
2043
+ return saturate( toneMappingExposure * color );
2044
+ }
2045
+ vec3 ReinhardToneMapping( vec3 color ) {
2046
+ color *= toneMappingExposure;
2047
+ return saturate( color / ( vec3( 1.0 ) + color ) );
2048
+ }
2049
+ vec3 CineonToneMapping( vec3 color ) {
2050
+ color *= toneMappingExposure;
2051
+ color = max( vec3( 0.0 ), color - 0.004 );
2052
+ return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
2053
+ }
2054
+ vec3 RRTAndODTFit( vec3 v ) {
2055
+ vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
2056
+ vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
2057
+ return a / b;
2058
+ }
2059
+ vec3 ACESFilmicToneMapping( vec3 color ) {
2060
+ const mat3 ACESInputMat = mat3(
2061
+ vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
2062
+ vec3( 0.04823, 0.01566, 0.83777 )
2063
+ );
2064
+ const mat3 ACESOutputMat = mat3(
2065
+ vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
2066
+ vec3( -0.07367, -0.00605, 1.07602 )
2067
+ );
2068
+ color *= toneMappingExposure / 0.6;
2069
+ color = ACESInputMat * color;
2070
+ color = RRTAndODTFit( color );
2071
+ color = ACESOutputMat * color;
2072
+ return saturate( color );
2073
+ }
2074
+ const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
2075
+ vec3( 1.6605, - 0.1246, - 0.0182 ),
2076
+ vec3( - 0.5876, 1.1329, - 0.1006 ),
2077
+ vec3( - 0.0728, - 0.0083, 1.1187 )
2078
+ );
2079
+ const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
2080
+ vec3( 0.6274, 0.0691, 0.0164 ),
2081
+ vec3( 0.3293, 0.9195, 0.0880 ),
2082
+ vec3( 0.0433, 0.0113, 0.8956 )
2083
+ );
2084
+ vec3 agxDefaultContrastApprox( vec3 x ) {
2085
+ vec3 x2 = x * x;
2086
+ vec3 x4 = x2 * x2;
2087
+ return + 15.5 * x4 * x2
2088
+ - 40.14 * x4 * x
2089
+ + 31.96 * x4
2090
+ - 6.868 * x2 * x
2091
+ + 0.4298 * x2
2092
+ + 0.1191 * x
2093
+ - 0.00232;
2094
+ }
2095
+ vec3 AgXToneMapping( vec3 color ) {
2096
+ const mat3 AgXInsetMatrix = mat3(
2097
+ vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
2098
+ vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
2099
+ vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
2100
+ );
2101
+ const mat3 AgXOutsetMatrix = mat3(
2102
+ vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
2103
+ vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
2104
+ vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
2105
+ );
2106
+ const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
2107
+ color *= toneMappingExposure;
2108
+ color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
2109
+ color = AgXInsetMatrix * color;
2110
+ color = max( color, 1e-10 ); color = log2( color );
2111
+ color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
2112
+ color = clamp( color, 0.0, 1.0 );
2113
+ color = agxDefaultContrastApprox( color );
2114
+ color = AgXOutsetMatrix * color;
2115
+ color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
2116
+ color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
2117
+ color = clamp( color, 0.0, 1.0 );
2118
+ return color;
2119
+ }
2120
+ vec3 NeutralToneMapping( vec3 color ) {
2121
+ const float StartCompression = 0.8 - 0.04;
2122
+ const float Desaturation = 0.15;
2123
+ color *= toneMappingExposure;
2124
+ float x = min( color.r, min( color.g, color.b ) );
2125
+ float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
2126
+ color -= offset;
2127
+ float peak = max( color.r, max( color.g, color.b ) );
2128
+ if ( peak < StartCompression ) return color;
2129
+ float d = 1. - StartCompression;
2130
+ float newPeak = 1. - d * d / ( peak + d - StartCompression );
2131
+ color *= newPeak / peak;
2132
+ float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2133
+ return mix( color, vec3( newPeak ), g );
2134
+ }
2135
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,fd=`#ifdef USE_TRANSMISSION
2136
+ material.transmission = transmission;
2137
+ material.transmissionAlpha = 1.0;
2138
+ material.thickness = thickness;
2139
+ material.attenuationDistance = attenuationDistance;
2140
+ material.attenuationColor = attenuationColor;
2141
+ #ifdef USE_TRANSMISSIONMAP
2142
+ material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
2143
+ #endif
2144
+ #ifdef USE_THICKNESSMAP
2145
+ material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
2146
+ #endif
2147
+ vec3 pos = vWorldPosition;
2148
+ vec3 v = normalize( cameraPosition - pos );
2149
+ vec3 n = inverseTransformDirection( normal, viewMatrix );
2150
+ vec4 transmitted = getIBLVolumeRefraction(
2151
+ n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
2152
+ pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
2153
+ material.attenuationColor, material.attenuationDistance );
2154
+ material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2155
+ totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2156
+ #endif`,pd=`#ifdef USE_TRANSMISSION
2157
+ uniform float transmission;
2158
+ uniform float thickness;
2159
+ uniform float attenuationDistance;
2160
+ uniform vec3 attenuationColor;
2161
+ #ifdef USE_TRANSMISSIONMAP
2162
+ uniform sampler2D transmissionMap;
2163
+ #endif
2164
+ #ifdef USE_THICKNESSMAP
2165
+ uniform sampler2D thicknessMap;
2166
+ #endif
2167
+ uniform vec2 transmissionSamplerSize;
2168
+ uniform sampler2D transmissionSamplerMap;
2169
+ uniform mat4 modelMatrix;
2170
+ uniform mat4 projectionMatrix;
2171
+ varying vec3 vWorldPosition;
2172
+ float w0( float a ) {
2173
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
2174
+ }
2175
+ float w1( float a ) {
2176
+ return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
2177
+ }
2178
+ float w2( float a ){
2179
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
2180
+ }
2181
+ float w3( float a ) {
2182
+ return ( 1.0 / 6.0 ) * ( a * a * a );
2183
+ }
2184
+ float g0( float a ) {
2185
+ return w0( a ) + w1( a );
2186
+ }
2187
+ float g1( float a ) {
2188
+ return w2( a ) + w3( a );
2189
+ }
2190
+ float h0( float a ) {
2191
+ return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
2192
+ }
2193
+ float h1( float a ) {
2194
+ return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
2195
+ }
2196
+ vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
2197
+ uv = uv * texelSize.zw + 0.5;
2198
+ vec2 iuv = floor( uv );
2199
+ vec2 fuv = fract( uv );
2200
+ float g0x = g0( fuv.x );
2201
+ float g1x = g1( fuv.x );
2202
+ float h0x = h0( fuv.x );
2203
+ float h1x = h1( fuv.x );
2204
+ float h0y = h0( fuv.y );
2205
+ float h1y = h1( fuv.y );
2206
+ vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2207
+ vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2208
+ vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2209
+ vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2210
+ return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
2211
+ g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
2212
+ }
2213
+ vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
2214
+ vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
2215
+ vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
2216
+ vec2 fLodSizeInv = 1.0 / fLodSize;
2217
+ vec2 cLodSizeInv = 1.0 / cLodSize;
2218
+ vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
2219
+ vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
2220
+ return mix( fSample, cSample, fract( lod ) );
2221
+ }
2222
+ vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
2223
+ vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
2224
+ vec3 modelScale;
2225
+ modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
2226
+ modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
2227
+ modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
2228
+ return normalize( refractionVector ) * thickness * modelScale;
2229
+ }
2230
+ float applyIorToRoughness( const in float roughness, const in float ior ) {
2231
+ return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
2232
+ }
2233
+ vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
2234
+ float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
2235
+ return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
2236
+ }
2237
+ vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
2238
+ if ( isinf( attenuationDistance ) ) {
2239
+ return vec3( 1.0 );
2240
+ } else {
2241
+ vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
2242
+ vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
2243
+ }
2244
+ }
2245
+ vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
2246
+ const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
2247
+ const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
2248
+ const in vec3 attenuationColor, const in float attenuationDistance ) {
2249
+ vec4 transmittedLight;
2250
+ vec3 transmittance;
2251
+ #ifdef USE_DISPERSION
2252
+ float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
2253
+ vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
2254
+ for ( int i = 0; i < 3; i ++ ) {
2255
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
2256
+ vec3 refractedRayExit = position + transmissionRay;
2257
+
2258
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2259
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2260
+ refractionCoords += 1.0;
2261
+ refractionCoords /= 2.0;
2262
+
2263
+ vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
2264
+ transmittedLight[ i ] = transmissionSample[ i ];
2265
+ transmittedLight.a += transmissionSample.a;
2266
+ transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
2267
+ }
2268
+ transmittedLight.a /= 3.0;
2269
+
2270
+ #else
2271
+
2272
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
2273
+ vec3 refractedRayExit = position + transmissionRay;
2274
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2275
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2276
+ refractionCoords += 1.0;
2277
+ refractionCoords /= 2.0;
2278
+ transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
2279
+ transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
2280
+
2281
+ #endif
2282
+ vec3 attenuatedColor = transmittance * transmittedLight.rgb;
2283
+ vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
2284
+ float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2285
+ return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2286
+ }
2287
+ #endif`,md=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2288
+ varying vec2 vUv;
2289
+ #endif
2290
+ #ifdef USE_MAP
2291
+ varying vec2 vMapUv;
2292
+ #endif
2293
+ #ifdef USE_ALPHAMAP
2294
+ varying vec2 vAlphaMapUv;
2295
+ #endif
2296
+ #ifdef USE_LIGHTMAP
2297
+ varying vec2 vLightMapUv;
2298
+ #endif
2299
+ #ifdef USE_AOMAP
2300
+ varying vec2 vAoMapUv;
2301
+ #endif
2302
+ #ifdef USE_BUMPMAP
2303
+ varying vec2 vBumpMapUv;
2304
+ #endif
2305
+ #ifdef USE_NORMALMAP
2306
+ varying vec2 vNormalMapUv;
2307
+ #endif
2308
+ #ifdef USE_EMISSIVEMAP
2309
+ varying vec2 vEmissiveMapUv;
2310
+ #endif
2311
+ #ifdef USE_METALNESSMAP
2312
+ varying vec2 vMetalnessMapUv;
2313
+ #endif
2314
+ #ifdef USE_ROUGHNESSMAP
2315
+ varying vec2 vRoughnessMapUv;
2316
+ #endif
2317
+ #ifdef USE_ANISOTROPYMAP
2318
+ varying vec2 vAnisotropyMapUv;
2319
+ #endif
2320
+ #ifdef USE_CLEARCOATMAP
2321
+ varying vec2 vClearcoatMapUv;
2322
+ #endif
2323
+ #ifdef USE_CLEARCOAT_NORMALMAP
2324
+ varying vec2 vClearcoatNormalMapUv;
2325
+ #endif
2326
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2327
+ varying vec2 vClearcoatRoughnessMapUv;
2328
+ #endif
2329
+ #ifdef USE_IRIDESCENCEMAP
2330
+ varying vec2 vIridescenceMapUv;
2331
+ #endif
2332
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2333
+ varying vec2 vIridescenceThicknessMapUv;
2334
+ #endif
2335
+ #ifdef USE_SHEEN_COLORMAP
2336
+ varying vec2 vSheenColorMapUv;
2337
+ #endif
2338
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2339
+ varying vec2 vSheenRoughnessMapUv;
2340
+ #endif
2341
+ #ifdef USE_SPECULARMAP
2342
+ varying vec2 vSpecularMapUv;
2343
+ #endif
2344
+ #ifdef USE_SPECULAR_COLORMAP
2345
+ varying vec2 vSpecularColorMapUv;
2346
+ #endif
2347
+ #ifdef USE_SPECULAR_INTENSITYMAP
2348
+ varying vec2 vSpecularIntensityMapUv;
2349
+ #endif
2350
+ #ifdef USE_TRANSMISSIONMAP
2351
+ uniform mat3 transmissionMapTransform;
2352
+ varying vec2 vTransmissionMapUv;
2353
+ #endif
2354
+ #ifdef USE_THICKNESSMAP
2355
+ uniform mat3 thicknessMapTransform;
2356
+ varying vec2 vThicknessMapUv;
2357
+ #endif`,gd=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2358
+ varying vec2 vUv;
2359
+ #endif
2360
+ #ifdef USE_MAP
2361
+ uniform mat3 mapTransform;
2362
+ varying vec2 vMapUv;
2363
+ #endif
2364
+ #ifdef USE_ALPHAMAP
2365
+ uniform mat3 alphaMapTransform;
2366
+ varying vec2 vAlphaMapUv;
2367
+ #endif
2368
+ #ifdef USE_LIGHTMAP
2369
+ uniform mat3 lightMapTransform;
2370
+ varying vec2 vLightMapUv;
2371
+ #endif
2372
+ #ifdef USE_AOMAP
2373
+ uniform mat3 aoMapTransform;
2374
+ varying vec2 vAoMapUv;
2375
+ #endif
2376
+ #ifdef USE_BUMPMAP
2377
+ uniform mat3 bumpMapTransform;
2378
+ varying vec2 vBumpMapUv;
2379
+ #endif
2380
+ #ifdef USE_NORMALMAP
2381
+ uniform mat3 normalMapTransform;
2382
+ varying vec2 vNormalMapUv;
2383
+ #endif
2384
+ #ifdef USE_DISPLACEMENTMAP
2385
+ uniform mat3 displacementMapTransform;
2386
+ varying vec2 vDisplacementMapUv;
2387
+ #endif
2388
+ #ifdef USE_EMISSIVEMAP
2389
+ uniform mat3 emissiveMapTransform;
2390
+ varying vec2 vEmissiveMapUv;
2391
+ #endif
2392
+ #ifdef USE_METALNESSMAP
2393
+ uniform mat3 metalnessMapTransform;
2394
+ varying vec2 vMetalnessMapUv;
2395
+ #endif
2396
+ #ifdef USE_ROUGHNESSMAP
2397
+ uniform mat3 roughnessMapTransform;
2398
+ varying vec2 vRoughnessMapUv;
2399
+ #endif
2400
+ #ifdef USE_ANISOTROPYMAP
2401
+ uniform mat3 anisotropyMapTransform;
2402
+ varying vec2 vAnisotropyMapUv;
2403
+ #endif
2404
+ #ifdef USE_CLEARCOATMAP
2405
+ uniform mat3 clearcoatMapTransform;
2406
+ varying vec2 vClearcoatMapUv;
2407
+ #endif
2408
+ #ifdef USE_CLEARCOAT_NORMALMAP
2409
+ uniform mat3 clearcoatNormalMapTransform;
2410
+ varying vec2 vClearcoatNormalMapUv;
2411
+ #endif
2412
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2413
+ uniform mat3 clearcoatRoughnessMapTransform;
2414
+ varying vec2 vClearcoatRoughnessMapUv;
2415
+ #endif
2416
+ #ifdef USE_SHEEN_COLORMAP
2417
+ uniform mat3 sheenColorMapTransform;
2418
+ varying vec2 vSheenColorMapUv;
2419
+ #endif
2420
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2421
+ uniform mat3 sheenRoughnessMapTransform;
2422
+ varying vec2 vSheenRoughnessMapUv;
2423
+ #endif
2424
+ #ifdef USE_IRIDESCENCEMAP
2425
+ uniform mat3 iridescenceMapTransform;
2426
+ varying vec2 vIridescenceMapUv;
2427
+ #endif
2428
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2429
+ uniform mat3 iridescenceThicknessMapTransform;
2430
+ varying vec2 vIridescenceThicknessMapUv;
2431
+ #endif
2432
+ #ifdef USE_SPECULARMAP
2433
+ uniform mat3 specularMapTransform;
2434
+ varying vec2 vSpecularMapUv;
2435
+ #endif
2436
+ #ifdef USE_SPECULAR_COLORMAP
2437
+ uniform mat3 specularColorMapTransform;
2438
+ varying vec2 vSpecularColorMapUv;
2439
+ #endif
2440
+ #ifdef USE_SPECULAR_INTENSITYMAP
2441
+ uniform mat3 specularIntensityMapTransform;
2442
+ varying vec2 vSpecularIntensityMapUv;
2443
+ #endif
2444
+ #ifdef USE_TRANSMISSIONMAP
2445
+ uniform mat3 transmissionMapTransform;
2446
+ varying vec2 vTransmissionMapUv;
2447
+ #endif
2448
+ #ifdef USE_THICKNESSMAP
2449
+ uniform mat3 thicknessMapTransform;
2450
+ varying vec2 vThicknessMapUv;
2451
+ #endif`,_d=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2452
+ vUv = vec3( uv, 1 ).xy;
2453
+ #endif
2454
+ #ifdef USE_MAP
2455
+ vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
2456
+ #endif
2457
+ #ifdef USE_ALPHAMAP
2458
+ vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
2459
+ #endif
2460
+ #ifdef USE_LIGHTMAP
2461
+ vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
2462
+ #endif
2463
+ #ifdef USE_AOMAP
2464
+ vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
2465
+ #endif
2466
+ #ifdef USE_BUMPMAP
2467
+ vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
2468
+ #endif
2469
+ #ifdef USE_NORMALMAP
2470
+ vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
2471
+ #endif
2472
+ #ifdef USE_DISPLACEMENTMAP
2473
+ vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
2474
+ #endif
2475
+ #ifdef USE_EMISSIVEMAP
2476
+ vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
2477
+ #endif
2478
+ #ifdef USE_METALNESSMAP
2479
+ vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
2480
+ #endif
2481
+ #ifdef USE_ROUGHNESSMAP
2482
+ vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
2483
+ #endif
2484
+ #ifdef USE_ANISOTROPYMAP
2485
+ vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
2486
+ #endif
2487
+ #ifdef USE_CLEARCOATMAP
2488
+ vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
2489
+ #endif
2490
+ #ifdef USE_CLEARCOAT_NORMALMAP
2491
+ vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
2492
+ #endif
2493
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2494
+ vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
2495
+ #endif
2496
+ #ifdef USE_IRIDESCENCEMAP
2497
+ vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
2498
+ #endif
2499
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2500
+ vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
2501
+ #endif
2502
+ #ifdef USE_SHEEN_COLORMAP
2503
+ vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
2504
+ #endif
2505
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2506
+ vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
2507
+ #endif
2508
+ #ifdef USE_SPECULARMAP
2509
+ vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
2510
+ #endif
2511
+ #ifdef USE_SPECULAR_COLORMAP
2512
+ vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
2513
+ #endif
2514
+ #ifdef USE_SPECULAR_INTENSITYMAP
2515
+ vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
2516
+ #endif
2517
+ #ifdef USE_TRANSMISSIONMAP
2518
+ vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
2519
+ #endif
2520
+ #ifdef USE_THICKNESSMAP
2521
+ vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2522
+ #endif`,xd=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2523
+ vec4 worldPosition = vec4( transformed, 1.0 );
2524
+ #ifdef USE_BATCHING
2525
+ worldPosition = batchingMatrix * worldPosition;
2526
+ #endif
2527
+ #ifdef USE_INSTANCING
2528
+ worldPosition = instanceMatrix * worldPosition;
2529
+ #endif
2530
+ worldPosition = modelMatrix * worldPosition;
2531
+ #endif`,vd=`varying vec2 vUv;
2532
+ uniform mat3 uvTransform;
2533
+ void main() {
2534
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2535
+ gl_Position = vec4( position.xy, 1.0, 1.0 );
2536
+ }`,yd=`uniform sampler2D t2D;
2537
+ uniform float backgroundIntensity;
2538
+ varying vec2 vUv;
2539
+ void main() {
2540
+ vec4 texColor = texture2D( t2D, vUv );
2541
+ #ifdef DECODE_VIDEO_TEXTURE
2542
+ 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 );
2543
+ #endif
2544
+ texColor.rgb *= backgroundIntensity;
2545
+ gl_FragColor = texColor;
2546
+ #include <tonemapping_fragment>
2547
+ #include <colorspace_fragment>
2548
+ }`,Md=`varying vec3 vWorldDirection;
2549
+ #include <common>
2550
+ void main() {
2551
+ vWorldDirection = transformDirection( position, modelMatrix );
2552
+ #include <begin_vertex>
2553
+ #include <project_vertex>
2554
+ gl_Position.z = gl_Position.w;
2555
+ }`,Sd=`#ifdef ENVMAP_TYPE_CUBE
2556
+ uniform samplerCube envMap;
2557
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2558
+ uniform sampler2D envMap;
2559
+ #endif
2560
+ uniform float flipEnvMap;
2561
+ uniform float backgroundBlurriness;
2562
+ uniform float backgroundIntensity;
2563
+ uniform mat3 backgroundRotation;
2564
+ varying vec3 vWorldDirection;
2565
+ #include <cube_uv_reflection_fragment>
2566
+ void main() {
2567
+ #ifdef ENVMAP_TYPE_CUBE
2568
+ vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
2569
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2570
+ vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
2571
+ #else
2572
+ vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
2573
+ #endif
2574
+ texColor.rgb *= backgroundIntensity;
2575
+ gl_FragColor = texColor;
2576
+ #include <tonemapping_fragment>
2577
+ #include <colorspace_fragment>
2578
+ }`,bd=`varying vec3 vWorldDirection;
2579
+ #include <common>
2580
+ void main() {
2581
+ vWorldDirection = transformDirection( position, modelMatrix );
2582
+ #include <begin_vertex>
2583
+ #include <project_vertex>
2584
+ gl_Position.z = gl_Position.w;
2585
+ }`,Ed=`uniform samplerCube tCube;
2586
+ uniform float tFlip;
2587
+ uniform float opacity;
2588
+ varying vec3 vWorldDirection;
2589
+ void main() {
2590
+ vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
2591
+ gl_FragColor = texColor;
2592
+ gl_FragColor.a *= opacity;
2593
+ #include <tonemapping_fragment>
2594
+ #include <colorspace_fragment>
2595
+ }`,wd=`#include <common>
2596
+ #include <batching_pars_vertex>
2597
+ #include <uv_pars_vertex>
2598
+ #include <displacementmap_pars_vertex>
2599
+ #include <morphtarget_pars_vertex>
2600
+ #include <skinning_pars_vertex>
2601
+ #include <logdepthbuf_pars_vertex>
2602
+ #include <clipping_planes_pars_vertex>
2603
+ varying vec2 vHighPrecisionZW;
2604
+ void main() {
2605
+ #include <uv_vertex>
2606
+ #include <batching_vertex>
2607
+ #include <skinbase_vertex>
2608
+ #include <morphinstance_vertex>
2609
+ #ifdef USE_DISPLACEMENTMAP
2610
+ #include <beginnormal_vertex>
2611
+ #include <morphnormal_vertex>
2612
+ #include <skinnormal_vertex>
2613
+ #endif
2614
+ #include <begin_vertex>
2615
+ #include <morphtarget_vertex>
2616
+ #include <skinning_vertex>
2617
+ #include <displacementmap_vertex>
2618
+ #include <project_vertex>
2619
+ #include <logdepthbuf_vertex>
2620
+ #include <clipping_planes_vertex>
2621
+ vHighPrecisionZW = gl_Position.zw;
2622
+ }`,Td=`#if DEPTH_PACKING == 3200
2623
+ uniform float opacity;
2624
+ #endif
2625
+ #include <common>
2626
+ #include <packing>
2627
+ #include <uv_pars_fragment>
2628
+ #include <map_pars_fragment>
2629
+ #include <alphamap_pars_fragment>
2630
+ #include <alphatest_pars_fragment>
2631
+ #include <alphahash_pars_fragment>
2632
+ #include <logdepthbuf_pars_fragment>
2633
+ #include <clipping_planes_pars_fragment>
2634
+ varying vec2 vHighPrecisionZW;
2635
+ void main() {
2636
+ vec4 diffuseColor = vec4( 1.0 );
2637
+ #include <clipping_planes_fragment>
2638
+ #if DEPTH_PACKING == 3200
2639
+ diffuseColor.a = opacity;
2640
+ #endif
2641
+ #include <map_fragment>
2642
+ #include <alphamap_fragment>
2643
+ #include <alphatest_fragment>
2644
+ #include <alphahash_fragment>
2645
+ #include <logdepthbuf_fragment>
2646
+ float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
2647
+ #if DEPTH_PACKING == 3200
2648
+ gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
2649
+ #elif DEPTH_PACKING == 3201
2650
+ gl_FragColor = packDepthToRGBA( fragCoordZ );
2651
+ #elif DEPTH_PACKING == 3202
2652
+ gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
2653
+ #elif DEPTH_PACKING == 3203
2654
+ gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2655
+ #endif
2656
+ }`,Ad=`#define DISTANCE
2657
+ varying vec3 vWorldPosition;
2658
+ #include <common>
2659
+ #include <batching_pars_vertex>
2660
+ #include <uv_pars_vertex>
2661
+ #include <displacementmap_pars_vertex>
2662
+ #include <morphtarget_pars_vertex>
2663
+ #include <skinning_pars_vertex>
2664
+ #include <clipping_planes_pars_vertex>
2665
+ void main() {
2666
+ #include <uv_vertex>
2667
+ #include <batching_vertex>
2668
+ #include <skinbase_vertex>
2669
+ #include <morphinstance_vertex>
2670
+ #ifdef USE_DISPLACEMENTMAP
2671
+ #include <beginnormal_vertex>
2672
+ #include <morphnormal_vertex>
2673
+ #include <skinnormal_vertex>
2674
+ #endif
2675
+ #include <begin_vertex>
2676
+ #include <morphtarget_vertex>
2677
+ #include <skinning_vertex>
2678
+ #include <displacementmap_vertex>
2679
+ #include <project_vertex>
2680
+ #include <worldpos_vertex>
2681
+ #include <clipping_planes_vertex>
2682
+ vWorldPosition = worldPosition.xyz;
2683
+ }`,Rd=`#define DISTANCE
2684
+ uniform vec3 referencePosition;
2685
+ uniform float nearDistance;
2686
+ uniform float farDistance;
2687
+ varying vec3 vWorldPosition;
2688
+ #include <common>
2689
+ #include <packing>
2690
+ #include <uv_pars_fragment>
2691
+ #include <map_pars_fragment>
2692
+ #include <alphamap_pars_fragment>
2693
+ #include <alphatest_pars_fragment>
2694
+ #include <alphahash_pars_fragment>
2695
+ #include <clipping_planes_pars_fragment>
2696
+ void main () {
2697
+ vec4 diffuseColor = vec4( 1.0 );
2698
+ #include <clipping_planes_fragment>
2699
+ #include <map_fragment>
2700
+ #include <alphamap_fragment>
2701
+ #include <alphatest_fragment>
2702
+ #include <alphahash_fragment>
2703
+ float dist = length( vWorldPosition - referencePosition );
2704
+ dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2705
+ dist = saturate( dist );
2706
+ gl_FragColor = packDepthToRGBA( dist );
2707
+ }`,Cd=`varying vec3 vWorldDirection;
2708
+ #include <common>
2709
+ void main() {
2710
+ vWorldDirection = transformDirection( position, modelMatrix );
2711
+ #include <begin_vertex>
2712
+ #include <project_vertex>
2713
+ }`,Pd=`uniform sampler2D tEquirect;
2714
+ varying vec3 vWorldDirection;
2715
+ #include <common>
2716
+ void main() {
2717
+ vec3 direction = normalize( vWorldDirection );
2718
+ vec2 sampleUV = equirectUv( direction );
2719
+ gl_FragColor = texture2D( tEquirect, sampleUV );
2720
+ #include <tonemapping_fragment>
2721
+ #include <colorspace_fragment>
2722
+ }`,Id=`uniform float scale;
2723
+ attribute float lineDistance;
2724
+ varying float vLineDistance;
2725
+ #include <common>
2726
+ #include <uv_pars_vertex>
2727
+ #include <color_pars_vertex>
2728
+ #include <fog_pars_vertex>
2729
+ #include <morphtarget_pars_vertex>
2730
+ #include <logdepthbuf_pars_vertex>
2731
+ #include <clipping_planes_pars_vertex>
2732
+ void main() {
2733
+ vLineDistance = scale * lineDistance;
2734
+ #include <uv_vertex>
2735
+ #include <color_vertex>
2736
+ #include <morphinstance_vertex>
2737
+ #include <morphcolor_vertex>
2738
+ #include <begin_vertex>
2739
+ #include <morphtarget_vertex>
2740
+ #include <project_vertex>
2741
+ #include <logdepthbuf_vertex>
2742
+ #include <clipping_planes_vertex>
2743
+ #include <fog_vertex>
2744
+ }`,Ld=`uniform vec3 diffuse;
2745
+ uniform float opacity;
2746
+ uniform float dashSize;
2747
+ uniform float totalSize;
2748
+ varying float vLineDistance;
2749
+ #include <common>
2750
+ #include <color_pars_fragment>
2751
+ #include <uv_pars_fragment>
2752
+ #include <map_pars_fragment>
2753
+ #include <fog_pars_fragment>
2754
+ #include <logdepthbuf_pars_fragment>
2755
+ #include <clipping_planes_pars_fragment>
2756
+ void main() {
2757
+ vec4 diffuseColor = vec4( diffuse, opacity );
2758
+ #include <clipping_planes_fragment>
2759
+ if ( mod( vLineDistance, totalSize ) > dashSize ) {
2760
+ discard;
2761
+ }
2762
+ vec3 outgoingLight = vec3( 0.0 );
2763
+ #include <logdepthbuf_fragment>
2764
+ #include <map_fragment>
2765
+ #include <color_fragment>
2766
+ outgoingLight = diffuseColor.rgb;
2767
+ #include <opaque_fragment>
2768
+ #include <tonemapping_fragment>
2769
+ #include <colorspace_fragment>
2770
+ #include <fog_fragment>
2771
+ #include <premultiplied_alpha_fragment>
2772
+ }`,Dd=`#include <common>
2773
+ #include <batching_pars_vertex>
2774
+ #include <uv_pars_vertex>
2775
+ #include <envmap_pars_vertex>
2776
+ #include <color_pars_vertex>
2777
+ #include <fog_pars_vertex>
2778
+ #include <morphtarget_pars_vertex>
2779
+ #include <skinning_pars_vertex>
2780
+ #include <logdepthbuf_pars_vertex>
2781
+ #include <clipping_planes_pars_vertex>
2782
+ void main() {
2783
+ #include <uv_vertex>
2784
+ #include <color_vertex>
2785
+ #include <morphinstance_vertex>
2786
+ #include <morphcolor_vertex>
2787
+ #include <batching_vertex>
2788
+ #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
2789
+ #include <beginnormal_vertex>
2790
+ #include <morphnormal_vertex>
2791
+ #include <skinbase_vertex>
2792
+ #include <skinnormal_vertex>
2793
+ #include <defaultnormal_vertex>
2794
+ #endif
2795
+ #include <begin_vertex>
2796
+ #include <morphtarget_vertex>
2797
+ #include <skinning_vertex>
2798
+ #include <project_vertex>
2799
+ #include <logdepthbuf_vertex>
2800
+ #include <clipping_planes_vertex>
2801
+ #include <worldpos_vertex>
2802
+ #include <envmap_vertex>
2803
+ #include <fog_vertex>
2804
+ }`,Ud=`uniform vec3 diffuse;
2805
+ uniform float opacity;
2806
+ #ifndef FLAT_SHADED
2807
+ varying vec3 vNormal;
2808
+ #endif
2809
+ #include <common>
2810
+ #include <dithering_pars_fragment>
2811
+ #include <color_pars_fragment>
2812
+ #include <uv_pars_fragment>
2813
+ #include <map_pars_fragment>
2814
+ #include <alphamap_pars_fragment>
2815
+ #include <alphatest_pars_fragment>
2816
+ #include <alphahash_pars_fragment>
2817
+ #include <aomap_pars_fragment>
2818
+ #include <lightmap_pars_fragment>
2819
+ #include <envmap_common_pars_fragment>
2820
+ #include <envmap_pars_fragment>
2821
+ #include <fog_pars_fragment>
2822
+ #include <specularmap_pars_fragment>
2823
+ #include <logdepthbuf_pars_fragment>
2824
+ #include <clipping_planes_pars_fragment>
2825
+ void main() {
2826
+ vec4 diffuseColor = vec4( diffuse, opacity );
2827
+ #include <clipping_planes_fragment>
2828
+ #include <logdepthbuf_fragment>
2829
+ #include <map_fragment>
2830
+ #include <color_fragment>
2831
+ #include <alphamap_fragment>
2832
+ #include <alphatest_fragment>
2833
+ #include <alphahash_fragment>
2834
+ #include <specularmap_fragment>
2835
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2836
+ #ifdef USE_LIGHTMAP
2837
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
2838
+ reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
2839
+ #else
2840
+ reflectedLight.indirectDiffuse += vec3( 1.0 );
2841
+ #endif
2842
+ #include <aomap_fragment>
2843
+ reflectedLight.indirectDiffuse *= diffuseColor.rgb;
2844
+ vec3 outgoingLight = reflectedLight.indirectDiffuse;
2845
+ #include <envmap_fragment>
2846
+ #include <opaque_fragment>
2847
+ #include <tonemapping_fragment>
2848
+ #include <colorspace_fragment>
2849
+ #include <fog_fragment>
2850
+ #include <premultiplied_alpha_fragment>
2851
+ #include <dithering_fragment>
2852
+ }`,Nd=`#define LAMBERT
2853
+ varying vec3 vViewPosition;
2854
+ #include <common>
2855
+ #include <batching_pars_vertex>
2856
+ #include <uv_pars_vertex>
2857
+ #include <displacementmap_pars_vertex>
2858
+ #include <envmap_pars_vertex>
2859
+ #include <color_pars_vertex>
2860
+ #include <fog_pars_vertex>
2861
+ #include <normal_pars_vertex>
2862
+ #include <morphtarget_pars_vertex>
2863
+ #include <skinning_pars_vertex>
2864
+ #include <shadowmap_pars_vertex>
2865
+ #include <logdepthbuf_pars_vertex>
2866
+ #include <clipping_planes_pars_vertex>
2867
+ void main() {
2868
+ #include <uv_vertex>
2869
+ #include <color_vertex>
2870
+ #include <morphinstance_vertex>
2871
+ #include <morphcolor_vertex>
2872
+ #include <batching_vertex>
2873
+ #include <beginnormal_vertex>
2874
+ #include <morphnormal_vertex>
2875
+ #include <skinbase_vertex>
2876
+ #include <skinnormal_vertex>
2877
+ #include <defaultnormal_vertex>
2878
+ #include <normal_vertex>
2879
+ #include <begin_vertex>
2880
+ #include <morphtarget_vertex>
2881
+ #include <skinning_vertex>
2882
+ #include <displacementmap_vertex>
2883
+ #include <project_vertex>
2884
+ #include <logdepthbuf_vertex>
2885
+ #include <clipping_planes_vertex>
2886
+ vViewPosition = - mvPosition.xyz;
2887
+ #include <worldpos_vertex>
2888
+ #include <envmap_vertex>
2889
+ #include <shadowmap_vertex>
2890
+ #include <fog_vertex>
2891
+ }`,Od=`#define LAMBERT
2892
+ uniform vec3 diffuse;
2893
+ uniform vec3 emissive;
2894
+ uniform float opacity;
2895
+ #include <common>
2896
+ #include <packing>
2897
+ #include <dithering_pars_fragment>
2898
+ #include <color_pars_fragment>
2899
+ #include <uv_pars_fragment>
2900
+ #include <map_pars_fragment>
2901
+ #include <alphamap_pars_fragment>
2902
+ #include <alphatest_pars_fragment>
2903
+ #include <alphahash_pars_fragment>
2904
+ #include <aomap_pars_fragment>
2905
+ #include <lightmap_pars_fragment>
2906
+ #include <emissivemap_pars_fragment>
2907
+ #include <envmap_common_pars_fragment>
2908
+ #include <envmap_pars_fragment>
2909
+ #include <fog_pars_fragment>
2910
+ #include <bsdfs>
2911
+ #include <lights_pars_begin>
2912
+ #include <normal_pars_fragment>
2913
+ #include <lights_lambert_pars_fragment>
2914
+ #include <shadowmap_pars_fragment>
2915
+ #include <bumpmap_pars_fragment>
2916
+ #include <normalmap_pars_fragment>
2917
+ #include <specularmap_pars_fragment>
2918
+ #include <logdepthbuf_pars_fragment>
2919
+ #include <clipping_planes_pars_fragment>
2920
+ void main() {
2921
+ vec4 diffuseColor = vec4( diffuse, opacity );
2922
+ #include <clipping_planes_fragment>
2923
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2924
+ vec3 totalEmissiveRadiance = emissive;
2925
+ #include <logdepthbuf_fragment>
2926
+ #include <map_fragment>
2927
+ #include <color_fragment>
2928
+ #include <alphamap_fragment>
2929
+ #include <alphatest_fragment>
2930
+ #include <alphahash_fragment>
2931
+ #include <specularmap_fragment>
2932
+ #include <normal_fragment_begin>
2933
+ #include <normal_fragment_maps>
2934
+ #include <emissivemap_fragment>
2935
+ #include <lights_lambert_fragment>
2936
+ #include <lights_fragment_begin>
2937
+ #include <lights_fragment_maps>
2938
+ #include <lights_fragment_end>
2939
+ #include <aomap_fragment>
2940
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
2941
+ #include <envmap_fragment>
2942
+ #include <opaque_fragment>
2943
+ #include <tonemapping_fragment>
2944
+ #include <colorspace_fragment>
2945
+ #include <fog_fragment>
2946
+ #include <premultiplied_alpha_fragment>
2947
+ #include <dithering_fragment>
2948
+ }`,Fd=`#define MATCAP
2949
+ varying vec3 vViewPosition;
2950
+ #include <common>
2951
+ #include <batching_pars_vertex>
2952
+ #include <uv_pars_vertex>
2953
+ #include <color_pars_vertex>
2954
+ #include <displacementmap_pars_vertex>
2955
+ #include <fog_pars_vertex>
2956
+ #include <normal_pars_vertex>
2957
+ #include <morphtarget_pars_vertex>
2958
+ #include <skinning_pars_vertex>
2959
+ #include <logdepthbuf_pars_vertex>
2960
+ #include <clipping_planes_pars_vertex>
2961
+ void main() {
2962
+ #include <uv_vertex>
2963
+ #include <color_vertex>
2964
+ #include <morphinstance_vertex>
2965
+ #include <morphcolor_vertex>
2966
+ #include <batching_vertex>
2967
+ #include <beginnormal_vertex>
2968
+ #include <morphnormal_vertex>
2969
+ #include <skinbase_vertex>
2970
+ #include <skinnormal_vertex>
2971
+ #include <defaultnormal_vertex>
2972
+ #include <normal_vertex>
2973
+ #include <begin_vertex>
2974
+ #include <morphtarget_vertex>
2975
+ #include <skinning_vertex>
2976
+ #include <displacementmap_vertex>
2977
+ #include <project_vertex>
2978
+ #include <logdepthbuf_vertex>
2979
+ #include <clipping_planes_vertex>
2980
+ #include <fog_vertex>
2981
+ vViewPosition = - mvPosition.xyz;
2982
+ }`,Bd=`#define MATCAP
2983
+ uniform vec3 diffuse;
2984
+ uniform float opacity;
2985
+ uniform sampler2D matcap;
2986
+ varying vec3 vViewPosition;
2987
+ #include <common>
2988
+ #include <dithering_pars_fragment>
2989
+ #include <color_pars_fragment>
2990
+ #include <uv_pars_fragment>
2991
+ #include <map_pars_fragment>
2992
+ #include <alphamap_pars_fragment>
2993
+ #include <alphatest_pars_fragment>
2994
+ #include <alphahash_pars_fragment>
2995
+ #include <fog_pars_fragment>
2996
+ #include <normal_pars_fragment>
2997
+ #include <bumpmap_pars_fragment>
2998
+ #include <normalmap_pars_fragment>
2999
+ #include <logdepthbuf_pars_fragment>
3000
+ #include <clipping_planes_pars_fragment>
3001
+ void main() {
3002
+ vec4 diffuseColor = vec4( diffuse, opacity );
3003
+ #include <clipping_planes_fragment>
3004
+ #include <logdepthbuf_fragment>
3005
+ #include <map_fragment>
3006
+ #include <color_fragment>
3007
+ #include <alphamap_fragment>
3008
+ #include <alphatest_fragment>
3009
+ #include <alphahash_fragment>
3010
+ #include <normal_fragment_begin>
3011
+ #include <normal_fragment_maps>
3012
+ vec3 viewDir = normalize( vViewPosition );
3013
+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
3014
+ vec3 y = cross( viewDir, x );
3015
+ vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
3016
+ #ifdef USE_MATCAP
3017
+ vec4 matcapColor = texture2D( matcap, uv );
3018
+ #else
3019
+ vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
3020
+ #endif
3021
+ vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
3022
+ #include <opaque_fragment>
3023
+ #include <tonemapping_fragment>
3024
+ #include <colorspace_fragment>
3025
+ #include <fog_fragment>
3026
+ #include <premultiplied_alpha_fragment>
3027
+ #include <dithering_fragment>
3028
+ }`,zd=`#define NORMAL
3029
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3030
+ varying vec3 vViewPosition;
3031
+ #endif
3032
+ #include <common>
3033
+ #include <batching_pars_vertex>
3034
+ #include <uv_pars_vertex>
3035
+ #include <displacementmap_pars_vertex>
3036
+ #include <normal_pars_vertex>
3037
+ #include <morphtarget_pars_vertex>
3038
+ #include <skinning_pars_vertex>
3039
+ #include <logdepthbuf_pars_vertex>
3040
+ #include <clipping_planes_pars_vertex>
3041
+ void main() {
3042
+ #include <uv_vertex>
3043
+ #include <batching_vertex>
3044
+ #include <beginnormal_vertex>
3045
+ #include <morphinstance_vertex>
3046
+ #include <morphnormal_vertex>
3047
+ #include <skinbase_vertex>
3048
+ #include <skinnormal_vertex>
3049
+ #include <defaultnormal_vertex>
3050
+ #include <normal_vertex>
3051
+ #include <begin_vertex>
3052
+ #include <morphtarget_vertex>
3053
+ #include <skinning_vertex>
3054
+ #include <displacementmap_vertex>
3055
+ #include <project_vertex>
3056
+ #include <logdepthbuf_vertex>
3057
+ #include <clipping_planes_vertex>
3058
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3059
+ vViewPosition = - mvPosition.xyz;
3060
+ #endif
3061
+ }`,kd=`#define NORMAL
3062
+ uniform float opacity;
3063
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3064
+ varying vec3 vViewPosition;
3065
+ #endif
3066
+ #include <packing>
3067
+ #include <uv_pars_fragment>
3068
+ #include <normal_pars_fragment>
3069
+ #include <bumpmap_pars_fragment>
3070
+ #include <normalmap_pars_fragment>
3071
+ #include <logdepthbuf_pars_fragment>
3072
+ #include <clipping_planes_pars_fragment>
3073
+ void main() {
3074
+ vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
3075
+ #include <clipping_planes_fragment>
3076
+ #include <logdepthbuf_fragment>
3077
+ #include <normal_fragment_begin>
3078
+ #include <normal_fragment_maps>
3079
+ gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
3080
+ #ifdef OPAQUE
3081
+ gl_FragColor.a = 1.0;
3082
+ #endif
3083
+ }`,Vd=`#define PHONG
3084
+ varying vec3 vViewPosition;
3085
+ #include <common>
3086
+ #include <batching_pars_vertex>
3087
+ #include <uv_pars_vertex>
3088
+ #include <displacementmap_pars_vertex>
3089
+ #include <envmap_pars_vertex>
3090
+ #include <color_pars_vertex>
3091
+ #include <fog_pars_vertex>
3092
+ #include <normal_pars_vertex>
3093
+ #include <morphtarget_pars_vertex>
3094
+ #include <skinning_pars_vertex>
3095
+ #include <shadowmap_pars_vertex>
3096
+ #include <logdepthbuf_pars_vertex>
3097
+ #include <clipping_planes_pars_vertex>
3098
+ void main() {
3099
+ #include <uv_vertex>
3100
+ #include <color_vertex>
3101
+ #include <morphcolor_vertex>
3102
+ #include <batching_vertex>
3103
+ #include <beginnormal_vertex>
3104
+ #include <morphinstance_vertex>
3105
+ #include <morphnormal_vertex>
3106
+ #include <skinbase_vertex>
3107
+ #include <skinnormal_vertex>
3108
+ #include <defaultnormal_vertex>
3109
+ #include <normal_vertex>
3110
+ #include <begin_vertex>
3111
+ #include <morphtarget_vertex>
3112
+ #include <skinning_vertex>
3113
+ #include <displacementmap_vertex>
3114
+ #include <project_vertex>
3115
+ #include <logdepthbuf_vertex>
3116
+ #include <clipping_planes_vertex>
3117
+ vViewPosition = - mvPosition.xyz;
3118
+ #include <worldpos_vertex>
3119
+ #include <envmap_vertex>
3120
+ #include <shadowmap_vertex>
3121
+ #include <fog_vertex>
3122
+ }`,Hd=`#define PHONG
3123
+ uniform vec3 diffuse;
3124
+ uniform vec3 emissive;
3125
+ uniform vec3 specular;
3126
+ uniform float shininess;
3127
+ uniform float opacity;
3128
+ #include <common>
3129
+ #include <packing>
3130
+ #include <dithering_pars_fragment>
3131
+ #include <color_pars_fragment>
3132
+ #include <uv_pars_fragment>
3133
+ #include <map_pars_fragment>
3134
+ #include <alphamap_pars_fragment>
3135
+ #include <alphatest_pars_fragment>
3136
+ #include <alphahash_pars_fragment>
3137
+ #include <aomap_pars_fragment>
3138
+ #include <lightmap_pars_fragment>
3139
+ #include <emissivemap_pars_fragment>
3140
+ #include <envmap_common_pars_fragment>
3141
+ #include <envmap_pars_fragment>
3142
+ #include <fog_pars_fragment>
3143
+ #include <bsdfs>
3144
+ #include <lights_pars_begin>
3145
+ #include <normal_pars_fragment>
3146
+ #include <lights_phong_pars_fragment>
3147
+ #include <shadowmap_pars_fragment>
3148
+ #include <bumpmap_pars_fragment>
3149
+ #include <normalmap_pars_fragment>
3150
+ #include <specularmap_pars_fragment>
3151
+ #include <logdepthbuf_pars_fragment>
3152
+ #include <clipping_planes_pars_fragment>
3153
+ void main() {
3154
+ vec4 diffuseColor = vec4( diffuse, opacity );
3155
+ #include <clipping_planes_fragment>
3156
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3157
+ vec3 totalEmissiveRadiance = emissive;
3158
+ #include <logdepthbuf_fragment>
3159
+ #include <map_fragment>
3160
+ #include <color_fragment>
3161
+ #include <alphamap_fragment>
3162
+ #include <alphatest_fragment>
3163
+ #include <alphahash_fragment>
3164
+ #include <specularmap_fragment>
3165
+ #include <normal_fragment_begin>
3166
+ #include <normal_fragment_maps>
3167
+ #include <emissivemap_fragment>
3168
+ #include <lights_phong_fragment>
3169
+ #include <lights_fragment_begin>
3170
+ #include <lights_fragment_maps>
3171
+ #include <lights_fragment_end>
3172
+ #include <aomap_fragment>
3173
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
3174
+ #include <envmap_fragment>
3175
+ #include <opaque_fragment>
3176
+ #include <tonemapping_fragment>
3177
+ #include <colorspace_fragment>
3178
+ #include <fog_fragment>
3179
+ #include <premultiplied_alpha_fragment>
3180
+ #include <dithering_fragment>
3181
+ }`,Gd=`#define STANDARD
3182
+ varying vec3 vViewPosition;
3183
+ #ifdef USE_TRANSMISSION
3184
+ varying vec3 vWorldPosition;
3185
+ #endif
3186
+ #include <common>
3187
+ #include <batching_pars_vertex>
3188
+ #include <uv_pars_vertex>
3189
+ #include <displacementmap_pars_vertex>
3190
+ #include <color_pars_vertex>
3191
+ #include <fog_pars_vertex>
3192
+ #include <normal_pars_vertex>
3193
+ #include <morphtarget_pars_vertex>
3194
+ #include <skinning_pars_vertex>
3195
+ #include <shadowmap_pars_vertex>
3196
+ #include <logdepthbuf_pars_vertex>
3197
+ #include <clipping_planes_pars_vertex>
3198
+ void main() {
3199
+ #include <uv_vertex>
3200
+ #include <color_vertex>
3201
+ #include <morphinstance_vertex>
3202
+ #include <morphcolor_vertex>
3203
+ #include <batching_vertex>
3204
+ #include <beginnormal_vertex>
3205
+ #include <morphnormal_vertex>
3206
+ #include <skinbase_vertex>
3207
+ #include <skinnormal_vertex>
3208
+ #include <defaultnormal_vertex>
3209
+ #include <normal_vertex>
3210
+ #include <begin_vertex>
3211
+ #include <morphtarget_vertex>
3212
+ #include <skinning_vertex>
3213
+ #include <displacementmap_vertex>
3214
+ #include <project_vertex>
3215
+ #include <logdepthbuf_vertex>
3216
+ #include <clipping_planes_vertex>
3217
+ vViewPosition = - mvPosition.xyz;
3218
+ #include <worldpos_vertex>
3219
+ #include <shadowmap_vertex>
3220
+ #include <fog_vertex>
3221
+ #ifdef USE_TRANSMISSION
3222
+ vWorldPosition = worldPosition.xyz;
3223
+ #endif
3224
+ }`,Wd=`#define STANDARD
3225
+ #ifdef PHYSICAL
3226
+ #define IOR
3227
+ #define USE_SPECULAR
3228
+ #endif
3229
+ uniform vec3 diffuse;
3230
+ uniform vec3 emissive;
3231
+ uniform float roughness;
3232
+ uniform float metalness;
3233
+ uniform float opacity;
3234
+ #ifdef IOR
3235
+ uniform float ior;
3236
+ #endif
3237
+ #ifdef USE_SPECULAR
3238
+ uniform float specularIntensity;
3239
+ uniform vec3 specularColor;
3240
+ #ifdef USE_SPECULAR_COLORMAP
3241
+ uniform sampler2D specularColorMap;
3242
+ #endif
3243
+ #ifdef USE_SPECULAR_INTENSITYMAP
3244
+ uniform sampler2D specularIntensityMap;
3245
+ #endif
3246
+ #endif
3247
+ #ifdef USE_CLEARCOAT
3248
+ uniform float clearcoat;
3249
+ uniform float clearcoatRoughness;
3250
+ #endif
3251
+ #ifdef USE_DISPERSION
3252
+ uniform float dispersion;
3253
+ #endif
3254
+ #ifdef USE_IRIDESCENCE
3255
+ uniform float iridescence;
3256
+ uniform float iridescenceIOR;
3257
+ uniform float iridescenceThicknessMinimum;
3258
+ uniform float iridescenceThicknessMaximum;
3259
+ #endif
3260
+ #ifdef USE_SHEEN
3261
+ uniform vec3 sheenColor;
3262
+ uniform float sheenRoughness;
3263
+ #ifdef USE_SHEEN_COLORMAP
3264
+ uniform sampler2D sheenColorMap;
3265
+ #endif
3266
+ #ifdef USE_SHEEN_ROUGHNESSMAP
3267
+ uniform sampler2D sheenRoughnessMap;
3268
+ #endif
3269
+ #endif
3270
+ #ifdef USE_ANISOTROPY
3271
+ uniform vec2 anisotropyVector;
3272
+ #ifdef USE_ANISOTROPYMAP
3273
+ uniform sampler2D anisotropyMap;
3274
+ #endif
3275
+ #endif
3276
+ varying vec3 vViewPosition;
3277
+ #include <common>
3278
+ #include <packing>
3279
+ #include <dithering_pars_fragment>
3280
+ #include <color_pars_fragment>
3281
+ #include <uv_pars_fragment>
3282
+ #include <map_pars_fragment>
3283
+ #include <alphamap_pars_fragment>
3284
+ #include <alphatest_pars_fragment>
3285
+ #include <alphahash_pars_fragment>
3286
+ #include <aomap_pars_fragment>
3287
+ #include <lightmap_pars_fragment>
3288
+ #include <emissivemap_pars_fragment>
3289
+ #include <iridescence_fragment>
3290
+ #include <cube_uv_reflection_fragment>
3291
+ #include <envmap_common_pars_fragment>
3292
+ #include <envmap_physical_pars_fragment>
3293
+ #include <fog_pars_fragment>
3294
+ #include <lights_pars_begin>
3295
+ #include <normal_pars_fragment>
3296
+ #include <lights_physical_pars_fragment>
3297
+ #include <transmission_pars_fragment>
3298
+ #include <shadowmap_pars_fragment>
3299
+ #include <bumpmap_pars_fragment>
3300
+ #include <normalmap_pars_fragment>
3301
+ #include <clearcoat_pars_fragment>
3302
+ #include <iridescence_pars_fragment>
3303
+ #include <roughnessmap_pars_fragment>
3304
+ #include <metalnessmap_pars_fragment>
3305
+ #include <logdepthbuf_pars_fragment>
3306
+ #include <clipping_planes_pars_fragment>
3307
+ void main() {
3308
+ vec4 diffuseColor = vec4( diffuse, opacity );
3309
+ #include <clipping_planes_fragment>
3310
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3311
+ vec3 totalEmissiveRadiance = emissive;
3312
+ #include <logdepthbuf_fragment>
3313
+ #include <map_fragment>
3314
+ #include <color_fragment>
3315
+ #include <alphamap_fragment>
3316
+ #include <alphatest_fragment>
3317
+ #include <alphahash_fragment>
3318
+ #include <roughnessmap_fragment>
3319
+ #include <metalnessmap_fragment>
3320
+ #include <normal_fragment_begin>
3321
+ #include <normal_fragment_maps>
3322
+ #include <clearcoat_normal_fragment_begin>
3323
+ #include <clearcoat_normal_fragment_maps>
3324
+ #include <emissivemap_fragment>
3325
+ #include <lights_physical_fragment>
3326
+ #include <lights_fragment_begin>
3327
+ #include <lights_fragment_maps>
3328
+ #include <lights_fragment_end>
3329
+ #include <aomap_fragment>
3330
+ vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
3331
+ vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
3332
+ #include <transmission_fragment>
3333
+ vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
3334
+ #ifdef USE_SHEEN
3335
+ float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
3336
+ outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
3337
+ #endif
3338
+ #ifdef USE_CLEARCOAT
3339
+ float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
3340
+ vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
3341
+ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
3342
+ #endif
3343
+ #include <opaque_fragment>
3344
+ #include <tonemapping_fragment>
3345
+ #include <colorspace_fragment>
3346
+ #include <fog_fragment>
3347
+ #include <premultiplied_alpha_fragment>
3348
+ #include <dithering_fragment>
3349
+ }`,Xd=`#define TOON
3350
+ varying vec3 vViewPosition;
3351
+ #include <common>
3352
+ #include <batching_pars_vertex>
3353
+ #include <uv_pars_vertex>
3354
+ #include <displacementmap_pars_vertex>
3355
+ #include <color_pars_vertex>
3356
+ #include <fog_pars_vertex>
3357
+ #include <normal_pars_vertex>
3358
+ #include <morphtarget_pars_vertex>
3359
+ #include <skinning_pars_vertex>
3360
+ #include <shadowmap_pars_vertex>
3361
+ #include <logdepthbuf_pars_vertex>
3362
+ #include <clipping_planes_pars_vertex>
3363
+ void main() {
3364
+ #include <uv_vertex>
3365
+ #include <color_vertex>
3366
+ #include <morphinstance_vertex>
3367
+ #include <morphcolor_vertex>
3368
+ #include <batching_vertex>
3369
+ #include <beginnormal_vertex>
3370
+ #include <morphnormal_vertex>
3371
+ #include <skinbase_vertex>
3372
+ #include <skinnormal_vertex>
3373
+ #include <defaultnormal_vertex>
3374
+ #include <normal_vertex>
3375
+ #include <begin_vertex>
3376
+ #include <morphtarget_vertex>
3377
+ #include <skinning_vertex>
3378
+ #include <displacementmap_vertex>
3379
+ #include <project_vertex>
3380
+ #include <logdepthbuf_vertex>
3381
+ #include <clipping_planes_vertex>
3382
+ vViewPosition = - mvPosition.xyz;
3383
+ #include <worldpos_vertex>
3384
+ #include <shadowmap_vertex>
3385
+ #include <fog_vertex>
3386
+ }`,Yd=`#define TOON
3387
+ uniform vec3 diffuse;
3388
+ uniform vec3 emissive;
3389
+ uniform float opacity;
3390
+ #include <common>
3391
+ #include <packing>
3392
+ #include <dithering_pars_fragment>
3393
+ #include <color_pars_fragment>
3394
+ #include <uv_pars_fragment>
3395
+ #include <map_pars_fragment>
3396
+ #include <alphamap_pars_fragment>
3397
+ #include <alphatest_pars_fragment>
3398
+ #include <alphahash_pars_fragment>
3399
+ #include <aomap_pars_fragment>
3400
+ #include <lightmap_pars_fragment>
3401
+ #include <emissivemap_pars_fragment>
3402
+ #include <gradientmap_pars_fragment>
3403
+ #include <fog_pars_fragment>
3404
+ #include <bsdfs>
3405
+ #include <lights_pars_begin>
3406
+ #include <normal_pars_fragment>
3407
+ #include <lights_toon_pars_fragment>
3408
+ #include <shadowmap_pars_fragment>
3409
+ #include <bumpmap_pars_fragment>
3410
+ #include <normalmap_pars_fragment>
3411
+ #include <logdepthbuf_pars_fragment>
3412
+ #include <clipping_planes_pars_fragment>
3413
+ void main() {
3414
+ vec4 diffuseColor = vec4( diffuse, opacity );
3415
+ #include <clipping_planes_fragment>
3416
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3417
+ vec3 totalEmissiveRadiance = emissive;
3418
+ #include <logdepthbuf_fragment>
3419
+ #include <map_fragment>
3420
+ #include <color_fragment>
3421
+ #include <alphamap_fragment>
3422
+ #include <alphatest_fragment>
3423
+ #include <alphahash_fragment>
3424
+ #include <normal_fragment_begin>
3425
+ #include <normal_fragment_maps>
3426
+ #include <emissivemap_fragment>
3427
+ #include <lights_toon_fragment>
3428
+ #include <lights_fragment_begin>
3429
+ #include <lights_fragment_maps>
3430
+ #include <lights_fragment_end>
3431
+ #include <aomap_fragment>
3432
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
3433
+ #include <opaque_fragment>
3434
+ #include <tonemapping_fragment>
3435
+ #include <colorspace_fragment>
3436
+ #include <fog_fragment>
3437
+ #include <premultiplied_alpha_fragment>
3438
+ #include <dithering_fragment>
3439
+ }`,qd=`uniform float size;
3440
+ uniform float scale;
3441
+ #include <common>
3442
+ #include <color_pars_vertex>
3443
+ #include <fog_pars_vertex>
3444
+ #include <morphtarget_pars_vertex>
3445
+ #include <logdepthbuf_pars_vertex>
3446
+ #include <clipping_planes_pars_vertex>
3447
+ #ifdef USE_POINTS_UV
3448
+ varying vec2 vUv;
3449
+ uniform mat3 uvTransform;
3450
+ #endif
3451
+ void main() {
3452
+ #ifdef USE_POINTS_UV
3453
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
3454
+ #endif
3455
+ #include <color_vertex>
3456
+ #include <morphinstance_vertex>
3457
+ #include <morphcolor_vertex>
3458
+ #include <begin_vertex>
3459
+ #include <morphtarget_vertex>
3460
+ #include <project_vertex>
3461
+ gl_PointSize = size;
3462
+ #ifdef USE_SIZEATTENUATION
3463
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3464
+ if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
3465
+ #endif
3466
+ #include <logdepthbuf_vertex>
3467
+ #include <clipping_planes_vertex>
3468
+ #include <worldpos_vertex>
3469
+ #include <fog_vertex>
3470
+ }`,Zd=`uniform vec3 diffuse;
3471
+ uniform float opacity;
3472
+ #include <common>
3473
+ #include <color_pars_fragment>
3474
+ #include <map_particle_pars_fragment>
3475
+ #include <alphatest_pars_fragment>
3476
+ #include <alphahash_pars_fragment>
3477
+ #include <fog_pars_fragment>
3478
+ #include <logdepthbuf_pars_fragment>
3479
+ #include <clipping_planes_pars_fragment>
3480
+ void main() {
3481
+ vec4 diffuseColor = vec4( diffuse, opacity );
3482
+ #include <clipping_planes_fragment>
3483
+ vec3 outgoingLight = vec3( 0.0 );
3484
+ #include <logdepthbuf_fragment>
3485
+ #include <map_particle_fragment>
3486
+ #include <color_fragment>
3487
+ #include <alphatest_fragment>
3488
+ #include <alphahash_fragment>
3489
+ outgoingLight = diffuseColor.rgb;
3490
+ #include <opaque_fragment>
3491
+ #include <tonemapping_fragment>
3492
+ #include <colorspace_fragment>
3493
+ #include <fog_fragment>
3494
+ #include <premultiplied_alpha_fragment>
3495
+ }`,Jd=`#include <common>
3496
+ #include <batching_pars_vertex>
3497
+ #include <fog_pars_vertex>
3498
+ #include <morphtarget_pars_vertex>
3499
+ #include <skinning_pars_vertex>
3500
+ #include <logdepthbuf_pars_vertex>
3501
+ #include <shadowmap_pars_vertex>
3502
+ void main() {
3503
+ #include <batching_vertex>
3504
+ #include <beginnormal_vertex>
3505
+ #include <morphinstance_vertex>
3506
+ #include <morphnormal_vertex>
3507
+ #include <skinbase_vertex>
3508
+ #include <skinnormal_vertex>
3509
+ #include <defaultnormal_vertex>
3510
+ #include <begin_vertex>
3511
+ #include <morphtarget_vertex>
3512
+ #include <skinning_vertex>
3513
+ #include <project_vertex>
3514
+ #include <logdepthbuf_vertex>
3515
+ #include <worldpos_vertex>
3516
+ #include <shadowmap_vertex>
3517
+ #include <fog_vertex>
3518
+ }`,Kd=`uniform vec3 color;
3519
+ uniform float opacity;
3520
+ #include <common>
3521
+ #include <packing>
3522
+ #include <fog_pars_fragment>
3523
+ #include <bsdfs>
3524
+ #include <lights_pars_begin>
3525
+ #include <logdepthbuf_pars_fragment>
3526
+ #include <shadowmap_pars_fragment>
3527
+ #include <shadowmask_pars_fragment>
3528
+ void main() {
3529
+ #include <logdepthbuf_fragment>
3530
+ gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
3531
+ #include <tonemapping_fragment>
3532
+ #include <colorspace_fragment>
3533
+ #include <fog_fragment>
3534
+ }`,$d=`uniform float rotation;
3535
+ uniform vec2 center;
3536
+ #include <common>
3537
+ #include <uv_pars_vertex>
3538
+ #include <fog_pars_vertex>
3539
+ #include <logdepthbuf_pars_vertex>
3540
+ #include <clipping_planes_pars_vertex>
3541
+ void main() {
3542
+ #include <uv_vertex>
3543
+ vec4 mvPosition = modelViewMatrix[ 3 ];
3544
+ vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
3545
+ #ifndef USE_SIZEATTENUATION
3546
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3547
+ if ( isPerspective ) scale *= - mvPosition.z;
3548
+ #endif
3549
+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
3550
+ vec2 rotatedPosition;
3551
+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
3552
+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
3553
+ mvPosition.xy += rotatedPosition;
3554
+ gl_Position = projectionMatrix * mvPosition;
3555
+ #include <logdepthbuf_vertex>
3556
+ #include <clipping_planes_vertex>
3557
+ #include <fog_vertex>
3558
+ }`,jd=`uniform vec3 diffuse;
3559
+ uniform float opacity;
3560
+ #include <common>
3561
+ #include <uv_pars_fragment>
3562
+ #include <map_pars_fragment>
3563
+ #include <alphamap_pars_fragment>
3564
+ #include <alphatest_pars_fragment>
3565
+ #include <alphahash_pars_fragment>
3566
+ #include <fog_pars_fragment>
3567
+ #include <logdepthbuf_pars_fragment>
3568
+ #include <clipping_planes_pars_fragment>
3569
+ void main() {
3570
+ vec4 diffuseColor = vec4( diffuse, opacity );
3571
+ #include <clipping_planes_fragment>
3572
+ vec3 outgoingLight = vec3( 0.0 );
3573
+ #include <logdepthbuf_fragment>
3574
+ #include <map_fragment>
3575
+ #include <alphamap_fragment>
3576
+ #include <alphatest_fragment>
3577
+ #include <alphahash_fragment>
3578
+ outgoingLight = diffuseColor.rgb;
3579
+ #include <opaque_fragment>
3580
+ #include <tonemapping_fragment>
3581
+ #include <colorspace_fragment>
3582
+ #include <fog_fragment>
3583
+ }`,Ct={alphahash_fragment:yh,alphahash_pars_fragment:Mh,alphamap_fragment:Sh,alphamap_pars_fragment:bh,alphatest_fragment:Eh,alphatest_pars_fragment:wh,aomap_fragment:Th,aomap_pars_fragment:Ah,batching_pars_vertex:Rh,batching_vertex:Ch,begin_vertex:Ph,beginnormal_vertex:Ih,bsdfs:Lh,iridescence_fragment:Dh,bumpmap_pars_fragment:Uh,clipping_planes_fragment:Nh,clipping_planes_pars_fragment:Oh,clipping_planes_pars_vertex:Fh,clipping_planes_vertex:Bh,color_fragment:zh,color_pars_fragment:kh,color_pars_vertex:Vh,color_vertex:Hh,common:Gh,cube_uv_reflection_fragment:Wh,defaultnormal_vertex:Xh,displacementmap_pars_vertex:Yh,displacementmap_vertex:qh,emissivemap_fragment:Zh,emissivemap_pars_fragment:Jh,colorspace_fragment:Kh,colorspace_pars_fragment:$h,envmap_fragment:jh,envmap_common_pars_fragment:Qh,envmap_pars_fragment:tu,envmap_pars_vertex:eu,envmap_physical_pars_fragment:du,envmap_vertex:nu,fog_vertex:iu,fog_pars_vertex:su,fog_fragment:ru,fog_pars_fragment:au,gradientmap_pars_fragment:ou,lightmap_pars_fragment:lu,lights_lambert_fragment:cu,lights_lambert_pars_fragment:hu,lights_pars_begin:uu,lights_toon_fragment:fu,lights_toon_pars_fragment:pu,lights_phong_fragment:mu,lights_phong_pars_fragment:gu,lights_physical_fragment:_u,lights_physical_pars_fragment:xu,lights_fragment_begin:vu,lights_fragment_maps:yu,lights_fragment_end:Mu,logdepthbuf_fragment:Su,logdepthbuf_pars_fragment:bu,logdepthbuf_pars_vertex:Eu,logdepthbuf_vertex:wu,map_fragment:Tu,map_pars_fragment:Au,map_particle_fragment:Ru,map_particle_pars_fragment:Cu,metalnessmap_fragment:Pu,metalnessmap_pars_fragment:Iu,morphinstance_vertex:Lu,morphcolor_vertex:Du,morphnormal_vertex:Uu,morphtarget_pars_vertex:Nu,morphtarget_vertex:Ou,normal_fragment_begin:Fu,normal_fragment_maps:Bu,normal_pars_fragment:zu,normal_pars_vertex:ku,normal_vertex:Vu,normalmap_pars_fragment:Hu,clearcoat_normal_fragment_begin:Gu,clearcoat_normal_fragment_maps:Wu,clearcoat_pars_fragment:Xu,iridescence_pars_fragment:Yu,opaque_fragment:qu,packing:Zu,premultiplied_alpha_fragment:Ju,project_vertex:Ku,dithering_fragment:$u,dithering_pars_fragment:ju,roughnessmap_fragment:Qu,roughnessmap_pars_fragment:td,shadowmap_pars_fragment:ed,shadowmap_pars_vertex:nd,shadowmap_vertex:id,shadowmask_pars_fragment:sd,skinbase_vertex:rd,skinning_pars_vertex:ad,skinning_vertex:od,skinnormal_vertex:ld,specularmap_fragment:cd,specularmap_pars_fragment:hd,tonemapping_fragment:ud,tonemapping_pars_fragment:dd,transmission_fragment:fd,transmission_pars_fragment:pd,uv_pars_fragment:md,uv_pars_vertex:gd,uv_vertex:_d,worldpos_vertex:xd,background_vert:vd,background_frag:yd,backgroundCube_vert:Md,backgroundCube_frag:Sd,cube_vert:bd,cube_frag:Ed,depth_vert:wd,depth_frag:Td,distanceRGBA_vert:Ad,distanceRGBA_frag:Rd,equirect_vert:Cd,equirect_frag:Pd,linedashed_vert:Id,linedashed_frag:Ld,meshbasic_vert:Dd,meshbasic_frag:Ud,meshlambert_vert:Nd,meshlambert_frag:Od,meshmatcap_vert:Fd,meshmatcap_frag:Bd,meshnormal_vert:zd,meshnormal_frag:kd,meshphong_vert:Vd,meshphong_frag:Hd,meshphysical_vert:Gd,meshphysical_frag:Wd,meshtoon_vert:Xd,meshtoon_frag:Yd,points_vert:qd,points_frag:Zd,shadow_vert:Jd,shadow_frag:Kd,sprite_vert:$d,sprite_frag:jd},et={common:{diffuse:{value:new zt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Pt},alphaMap:{value:null},alphaMapTransform:{value:new Pt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Pt}},envmap:{envMap:{value:null},envMapRotation:{value:new Pt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Pt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Pt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Pt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Pt},normalScale:{value:new It(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Pt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Pt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Pt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Pt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new zt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,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 zt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Pt},alphaTest:{value:0},uvTransform:{value:new Pt}},sprite:{diffuse:{value:new zt(16777215)},opacity:{value:1},center:{value:new It(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Pt},alphaMap:{value:null},alphaMapTransform:{value:new Pt},alphaTest:{value:0}}},Ye={basic:{uniforms:me([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.fog]),vertexShader:Ct.meshbasic_vert,fragmentShader:Ct.meshbasic_frag},lambert:{uniforms:me([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.fog,et.lights,{emissive:{value:new zt(0)}}]),vertexShader:Ct.meshlambert_vert,fragmentShader:Ct.meshlambert_frag},phong:{uniforms:me([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.fog,et.lights,{emissive:{value:new zt(0)},specular:{value:new zt(1118481)},shininess:{value:30}}]),vertexShader:Ct.meshphong_vert,fragmentShader:Ct.meshphong_frag},standard:{uniforms:me([et.common,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.roughnessmap,et.metalnessmap,et.fog,et.lights,{emissive:{value:new zt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ct.meshphysical_vert,fragmentShader:Ct.meshphysical_frag},toon:{uniforms:me([et.common,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.gradientmap,et.fog,et.lights,{emissive:{value:new zt(0)}}]),vertexShader:Ct.meshtoon_vert,fragmentShader:Ct.meshtoon_frag},matcap:{uniforms:me([et.common,et.bumpmap,et.normalmap,et.displacementmap,et.fog,{matcap:{value:null}}]),vertexShader:Ct.meshmatcap_vert,fragmentShader:Ct.meshmatcap_frag},points:{uniforms:me([et.points,et.fog]),vertexShader:Ct.points_vert,fragmentShader:Ct.points_frag},dashed:{uniforms:me([et.common,et.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ct.linedashed_vert,fragmentShader:Ct.linedashed_frag},depth:{uniforms:me([et.common,et.displacementmap]),vertexShader:Ct.depth_vert,fragmentShader:Ct.depth_frag},normal:{uniforms:me([et.common,et.bumpmap,et.normalmap,et.displacementmap,{opacity:{value:1}}]),vertexShader:Ct.meshnormal_vert,fragmentShader:Ct.meshnormal_frag},sprite:{uniforms:me([et.sprite,et.fog]),vertexShader:Ct.sprite_vert,fragmentShader:Ct.sprite_frag},background:{uniforms:{uvTransform:{value:new Pt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ct.background_vert,fragmentShader:Ct.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Pt}},vertexShader:Ct.backgroundCube_vert,fragmentShader:Ct.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ct.cube_vert,fragmentShader:Ct.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ct.equirect_vert,fragmentShader:Ct.equirect_frag},distanceRGBA:{uniforms:me([et.common,et.displacementmap,{referencePosition:{value:new L},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ct.distanceRGBA_vert,fragmentShader:Ct.distanceRGBA_frag},shadow:{uniforms:me([et.lights,et.fog,{color:{value:new zt(0)},opacity:{value:1}}]),vertexShader:Ct.shadow_vert,fragmentShader:Ct.shadow_frag}};Ye.physical={uniforms:me([Ye.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Pt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Pt},clearcoatNormalScale:{value:new It(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Pt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Pt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Pt},sheen:{value:0},sheenColor:{value:new zt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Pt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Pt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Pt},transmissionSamplerSize:{value:new It},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Pt},attenuationDistance:{value:0},attenuationColor:{value:new zt(0)},specularColor:{value:new zt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Pt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Pt},anisotropyVector:{value:new It},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Pt}}]),vertexShader:Ct.meshphysical_vert,fragmentShader:Ct.meshphysical_frag};var ts={r:0,b:0,g:0},Tn=new on,Qd=new ee;function tf(i,t,e,n,s,r,a){let o=new zt(0),l=r===!0?0:1,c,h,p=null,f=0,m=null;function x(w){let S=w.isScene===!0?w.background:null;return S&&S.isTexture&&(S=(w.backgroundBlurriness>0?e:t).get(S)),S}function y(w){let S=!1,E=x(w);E===null?u(o,l):E&&E.isColor&&(u(E,1),S=!0);let O=i.xr.getEnvironmentBlendMode();O==="additive"?n.buffers.color.setClear(0,0,0,1,a):O==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||S)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function d(w,S){let E=x(S);E&&(E.isCubeTexture||E.mapping===Os)?(h===void 0&&(h=new Ie(new Ii(1,1,1),new Ge({name:"BackgroundCubeMaterial",uniforms:mi(Ye.backgroundCube.uniforms),vertexShader:Ye.backgroundCube.vertexShader,fragmentShader:Ye.backgroundCube.fragmentShader,side:ve,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(O,C,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),Tn.copy(S.backgroundRotation),Tn.x*=-1,Tn.y*=-1,Tn.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(Tn.y*=-1,Tn.z*=-1),h.material.uniforms.envMap.value=E,h.material.uniforms.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=S.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(Qd.makeRotationFromEuler(Tn)),h.material.toneMapped=Wt.getTransfer(E.colorSpace)!==jt,(p!==E||f!==E.version||m!==i.toneMapping)&&(h.material.needsUpdate=!0,p=E,f=E.version,m=i.toneMapping),h.layers.enableAll(),w.unshift(h,h.geometry,h.material,0,0,null)):E&&E.isTexture&&(c===void 0&&(c=new Ie(new Cs(2,2),new Ge({name:"BackgroundMaterial",uniforms:mi(Ye.background.uniforms),vertexShader:Ye.background.vertexShader,fragmentShader:Ye.background.fragmentShader,side:xn,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(c)),c.material.uniforms.t2D.value=E,c.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,c.material.toneMapped=Wt.getTransfer(E.colorSpace)!==jt,E.matrixAutoUpdate===!0&&E.updateMatrix(),c.material.uniforms.uvTransform.value.copy(E.matrix),(p!==E||f!==E.version||m!==i.toneMapping)&&(c.material.needsUpdate=!0,p=E,f=E.version,m=i.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null))}function u(w,S){w.getRGB(ts,Ll(i)),n.buffers.color.setClear(ts.r,ts.g,ts.b,S,a)}return{getClearColor:function(){return o},setClearColor:function(w,S=1){o.set(w),l=S,u(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(w){l=w,u(o,l)},render:y,addToRenderList:d}}function ef(i,t){let e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=f(null),r=s,a=!1;function o(g,M,H,z,G){let J=!1,B=p(z,H,M);r!==B&&(r=B,c(r.object)),J=m(g,z,H,G),J&&x(g,z,H,G),G!==null&&t.update(G,i.ELEMENT_ARRAY_BUFFER),(J||a)&&(a=!1,E(g,M,H,z),G!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(G).buffer))}function l(){return i.createVertexArray()}function c(g){return i.bindVertexArray(g)}function h(g){return i.deleteVertexArray(g)}function p(g,M,H){let z=H.wireframe===!0,G=n[g.id];G===void 0&&(G={},n[g.id]=G);let J=G[M.id];J===void 0&&(J={},G[M.id]=J);let B=J[z];return B===void 0&&(B=f(l()),J[z]=B),B}function f(g){let M=[],H=[],z=[];for(let G=0;G<e;G++)M[G]=0,H[G]=0,z[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:M,enabledAttributes:H,attributeDivisors:z,object:g,attributes:{},index:null}}function m(g,M,H,z){let G=r.attributes,J=M.attributes,B=0,j=H.getAttributes();for(let V in j)if(j[V].location>=0){let lt=G[V],gt=J[V];if(gt===void 0&&(V==="instanceMatrix"&&g.instanceMatrix&&(gt=g.instanceMatrix),V==="instanceColor"&&g.instanceColor&&(gt=g.instanceColor)),lt===void 0||lt.attribute!==gt||gt&&lt.data!==gt.data)return!0;B++}return r.attributesNum!==B||r.index!==z}function x(g,M,H,z){let G={},J=M.attributes,B=0,j=H.getAttributes();for(let V in j)if(j[V].location>=0){let lt=J[V];lt===void 0&&(V==="instanceMatrix"&&g.instanceMatrix&&(lt=g.instanceMatrix),V==="instanceColor"&&g.instanceColor&&(lt=g.instanceColor));let gt={};gt.attribute=lt,lt&&lt.data&&(gt.data=lt.data),G[V]=gt,B++}r.attributes=G,r.attributesNum=B,r.index=z}function y(){let g=r.newAttributes;for(let M=0,H=g.length;M<H;M++)g[M]=0}function d(g){u(g,0)}function u(g,M){let H=r.newAttributes,z=r.enabledAttributes,G=r.attributeDivisors;H[g]=1,z[g]===0&&(i.enableVertexAttribArray(g),z[g]=1),G[g]!==M&&(i.vertexAttribDivisor(g,M),G[g]=M)}function w(){let g=r.newAttributes,M=r.enabledAttributes;for(let H=0,z=M.length;H<z;H++)M[H]!==g[H]&&(i.disableVertexAttribArray(H),M[H]=0)}function S(g,M,H,z,G,J,B){B===!0?i.vertexAttribIPointer(g,M,H,G,J):i.vertexAttribPointer(g,M,H,z,G,J)}function E(g,M,H,z){y();let G=z.attributes,J=H.getAttributes(),B=M.defaultAttributeValues;for(let j in J){let V=J[j];if(V.location>=0){let ot=G[j];if(ot===void 0&&(j==="instanceMatrix"&&g.instanceMatrix&&(ot=g.instanceMatrix),j==="instanceColor"&&g.instanceColor&&(ot=g.instanceColor)),ot!==void 0){let lt=ot.normalized,gt=ot.itemSize,kt=t.get(ot);if(kt===void 0)continue;let Xt=kt.buffer,W=kt.type,K=kt.bytesPerElement,pt=W===i.INT||W===i.UNSIGNED_INT||ot.gpuType===Wa;if(ot.isInterleavedBufferAttribute){let ct=ot.data,At=ct.stride,Mt=ot.offset;if(ct.isInstancedInterleavedBuffer){for(let Ut=0;Ut<V.locationSize;Ut++)u(V.location+Ut,ct.meshPerAttribute);g.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=ct.meshPerAttribute*ct.count)}else for(let Ut=0;Ut<V.locationSize;Ut++)d(V.location+Ut);i.bindBuffer(i.ARRAY_BUFFER,Xt);for(let Ut=0;Ut<V.locationSize;Ut++)S(V.location+Ut,gt/V.locationSize,W,lt,At*K,(Mt+gt/V.locationSize*Ut)*K,pt)}else{if(ot.isInstancedBufferAttribute){for(let ct=0;ct<V.locationSize;ct++)u(V.location+ct,ot.meshPerAttribute);g.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=ot.meshPerAttribute*ot.count)}else for(let ct=0;ct<V.locationSize;ct++)d(V.location+ct);i.bindBuffer(i.ARRAY_BUFFER,Xt);for(let ct=0;ct<V.locationSize;ct++)S(V.location+ct,gt/V.locationSize,W,lt,gt*K,gt/V.locationSize*ct*K,pt)}}else if(B!==void 0){let lt=B[j];if(lt!==void 0)switch(lt.length){case 2:i.vertexAttrib2fv(V.location,lt);break;case 3:i.vertexAttrib3fv(V.location,lt);break;case 4:i.vertexAttrib4fv(V.location,lt);break;default:i.vertexAttrib1fv(V.location,lt)}}}}w()}function O(){F();for(let g in n){let M=n[g];for(let H in M){let z=M[H];for(let G in z)h(z[G].object),delete z[G];delete M[H]}delete n[g]}}function C(g){if(n[g.id]===void 0)return;let M=n[g.id];for(let H in M){let z=M[H];for(let G in z)h(z[G].object),delete z[G];delete M[H]}delete n[g.id]}function T(g){for(let M in n){let H=n[M];if(H[g.id]===void 0)continue;let z=H[g.id];for(let G in z)h(z[G].object),delete z[G];delete H[g.id]}}function F(){tt(),a=!0,r!==s&&(r=s,c(r.object))}function tt(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:F,resetDefaultState:tt,dispose:O,releaseStatesOfGeometry:C,releaseStatesOfProgram:T,initAttributes:y,enableAttribute:d,disableUnusedAttributes:w}}function nf(i,t,e){let n;function s(c){n=c}function r(c,h){i.drawArrays(n,c,h),e.update(h,n,1)}function a(c,h,p){p!==0&&(i.drawArraysInstanced(n,c,h,p),e.update(h,n,p))}function o(c,h,p){if(p===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,p);let m=0;for(let x=0;x<p;x++)m+=h[x];e.update(m,n,1)}function l(c,h,p,f){if(p===0)return;let m=t.get("WEBGL_multi_draw");if(m===null)for(let x=0;x<c.length;x++)a(c[x],h[x],f[x]);else{m.multiDrawArraysInstancedWEBGL(n,c,0,h,0,f,0,p);let x=0;for(let y=0;y<p;y++)x+=h[y];for(let y=0;y<f.length;y++)e.update(x,n,f[y])}}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function sf(i,t,e,n){let s;function r(){if(s!==void 0)return s;if(t.has("EXT_texture_filter_anisotropic")===!0){let T=t.get("EXT_texture_filter_anisotropic");s=i.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(T){return!(T!==ze&&n.convert(T)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(T){let F=T===Di&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(T!==sn&&n.convert(T)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&T!==en&&!F)}function l(T){if(T==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp",h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);let p=e.logarithmicDepthBuffer===!0,f=e.reverseDepthBuffer===!0&&t.has("EXT_clip_control");if(f===!0){let T=t.get("EXT_clip_control");T.clipControlEXT(T.LOWER_LEFT_EXT,T.ZERO_TO_ONE_EXT)}let m=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=i.getParameter(i.MAX_TEXTURE_SIZE),d=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),u=i.getParameter(i.MAX_VERTEX_ATTRIBS),w=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),S=i.getParameter(i.MAX_VARYING_VECTORS),E=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),O=x>0,C=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:p,reverseDepthBuffer:f,maxTextures:m,maxVertexTextures:x,maxTextureSize:y,maxCubemapSize:d,maxAttributes:u,maxVertexUniforms:w,maxVaryings:S,maxFragmentUniforms:E,vertexTextures:O,maxSamples:C}}function rf(i){let t=this,e=null,n=0,s=!1,r=!1,a=new Fe,o=new Pt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(p,f){let m=p.length!==0||f||n!==0||s;return s=f,n=p.length,m},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(p,f){e=h(p,f,0)},this.setState=function(p,f,m){let x=p.clippingPlanes,y=p.clipIntersection,d=p.clipShadows,u=i.get(p);if(!s||x===null||x.length===0||r&&!d)r?h(null):c();else{let w=r?0:n,S=w*4,E=u.clippingState||null;l.value=E,E=h(x,f,S,m);for(let O=0;O!==S;++O)E[O]=e[O];u.clippingState=E,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=w}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(p,f,m,x){let y=p!==null?p.length:0,d=null;if(y!==0){if(d=l.value,x!==!0||d===null){let u=m+y*4,w=f.matrixWorldInverse;o.getNormalMatrix(w),(d===null||d.length<u)&&(d=new Float32Array(u));for(let S=0,E=m;S!==y;++S,E+=4)a.copy(p[S]).applyMatrix4(w,o),a.normal.toArray(d,E),d[E+3]=a.constant}l.value=d,l.needsUpdate=!0}return t.numPlanes=y,t.numIntersection=0,d}}function af(i){let t=new WeakMap;function e(a,o){return o===Pr?a.mapping=ui:o===Ir&&(a.mapping=di),a}function n(a){if(a&&a.isTexture){let o=a.mapping;if(o===Pr||o===Ir)if(t.has(a)){let l=t.get(a).texture;return e(l,a.mapping)}else{let l=a.image;if(l&&l.height>0){let c=new ua(l.height);return c.fromEquirectangularTexture(i,a),t.set(a,c),a.addEventListener("dispose",s),e(c.texture,a.mapping)}else return null}}return a}function s(a){let o=a.target;o.removeEventListener("dispose",s);let l=t.get(o);l!==void 0&&(t.delete(o),l.dispose())}function r(){t=new WeakMap}return{get:n,dispose:r}}var da=class extends Ts{constructor(t=-1,e=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,s,r,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-t,a=n+t,o=s+e,l=s-e;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}},ri=4,ko=[.125,.215,.35,.446,.526,.582],In=20,fr=new da,Vo=new zt,pr=null,mr=0,gr=0,_r=!1,Rn=(1+Math.sqrt(5))/2,ii=1/Rn,Ho=[new L(-Rn,ii,0),new L(Rn,ii,0),new L(-ii,0,Rn),new L(ii,0,Rn),new L(0,Rn,-ii),new L(0,Rn,ii),new L(-1,1,-1),new L(1,1,-1),new L(-1,1,1),new L(1,1,1)],Ps=class{constructor(t){this._renderer=t,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(t,e=0,n=.1,s=100){pr=this._renderer.getRenderTarget(),mr=this._renderer.getActiveCubeFace(),gr=this._renderer.getActiveMipmapLevel(),_r=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);let r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,s,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Xo(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Wo(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(pr,mr,gr),this._renderer.xr.enabled=_r,t.scissorTest=!1,es(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===ui||t.mapping===di?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),pr=this._renderer.getRenderTarget(),mr=this._renderer.getActiveCubeFace(),gr=this._renderer.getActiveMipmapLevel(),_r=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Be,minFilter:Be,generateMipmaps:!1,type:Di,format:ze,colorSpace:yn,depthBuffer:!1},s=Go(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Go(t,e,n);let{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=of(r)),this._blurMaterial=lf(r,t,e)}return s}_compileMaterial(t){let e=new Ie(this._lodPlanes[0],t);this._renderer.compile(e,fr)}_sceneToCubeUV(t,e,n,s){let o=new xe(90,1,e,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,p=h.autoClear,f=h.toneMapping;h.getClearColor(Vo),h.toneMapping=_n,h.autoClear=!1;let m=new bs({name:"PMREM.Background",side:ve,depthWrite:!1,depthTest:!1}),x=new Ie(new Ii,m),y=!1,d=t.background;d?d.isColor&&(m.color.copy(d),t.background=null,y=!0):(m.color.copy(Vo),y=!0);for(let u=0;u<6;u++){let w=u%3;w===0?(o.up.set(0,l[u],0),o.lookAt(c[u],0,0)):w===1?(o.up.set(0,0,l[u]),o.lookAt(0,c[u],0)):(o.up.set(0,l[u],0),o.lookAt(0,0,c[u]));let S=this._cubeSize;es(s,w*S,u>2?S:0,S,S),h.setRenderTarget(s),y&&h.render(x,o),h.render(t,o)}x.geometry.dispose(),x.material.dispose(),h.toneMapping=f,h.autoClear=p,t.background=d}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===ui||t.mapping===di;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Xo()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Wo());let r=s?this._cubemapMaterial:this._equirectMaterial,a=new Ie(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=t;let l=this._cubeSize;es(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(a,fr)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let s=this._lodPlanes.length;for(let r=1;r<s;r++){let a=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),o=Ho[(s-r-1)%Ho.length];this._blur(t,r-1,r,a,o)}e.autoClear=n}_blur(t,e,n,s,r){let a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,s,"latitudinal",r),this._halfBlur(a,t,n,n,s,"longitudinal",r)}_halfBlur(t,e,n,s,r,a,o){let l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let h=3,p=new Ie(this._lodPlanes[s],c),f=c.uniforms,m=this._sizeLods[n]-1,x=isFinite(r)?Math.PI/(2*m):2*Math.PI/(2*In-1),y=r/x,d=isFinite(r)?1+Math.floor(h*y):In;d>In&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${d} samples when the maximum is set to ${In}`);let u=[],w=0;for(let T=0;T<In;++T){let F=T/y,tt=Math.exp(-F*F/2);u.push(tt),T===0?w+=tt:T<d&&(w+=2*tt)}for(let T=0;T<u.length;T++)u[T]=u[T]/w;f.envMap.value=t.texture,f.samples.value=d,f.weights.value=u,f.latitudinal.value=a==="latitudinal",o&&(f.poleAxis.value=o);let{_lodMax:S}=this;f.dTheta.value=x,f.mipInt.value=S-n;let E=this._sizeLods[s],O=3*E*(s>S-ri?s-S+ri:0),C=4*(this._cubeSize-E);es(e,O,C,3*E,2*E),l.setRenderTarget(e),l.render(p,fr)}};function of(i){let t=[],e=[],n=[],s=i,r=i-ri+1+ko.length;for(let a=0;a<r;a++){let o=Math.pow(2,s);e.push(o);let l=1/o;a>i-ri?l=ko[a-i+ri-1]:a===0&&(l=0),n.push(l);let c=1/(o-2),h=-c,p=1+c,f=[h,h,p,h,p,p,h,h,p,p,h,p],m=6,x=6,y=3,d=2,u=1,w=new Float32Array(y*x*m),S=new Float32Array(d*x*m),E=new Float32Array(u*x*m);for(let C=0;C<m;C++){let T=C%3*2/3-1,F=C>2?0:-1,tt=[T,F,0,T+2/3,F,0,T+2/3,F+1,0,T,F,0,T+2/3,F+1,0,T,F+1,0];w.set(tt,y*x*C),S.set(f,d*x*C);let g=[C,C,C,C,C,C];E.set(g,u*x*C)}let O=new He;O.setAttribute("position",new ye(w,y)),O.setAttribute("uv",new ye(S,d)),O.setAttribute("faceIndex",new ye(E,u)),t.push(O),s>ri&&s--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function Go(i,t,e){let n=new an(i,t,e);return n.texture.mapping=Os,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function es(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function lf(i,t,e){let n=new Float32Array(In),s=new L(0,1,0);return new Ge({name:"SphericalGaussianBlur",defines:{n:In,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:ja(),fragmentShader:`
3584
+
3585
+ precision mediump float;
3586
+ precision mediump int;
3587
+
3588
+ varying vec3 vOutputDirection;
3589
+
3590
+ uniform sampler2D envMap;
3591
+ uniform int samples;
3592
+ uniform float weights[ n ];
3593
+ uniform bool latitudinal;
3594
+ uniform float dTheta;
3595
+ uniform float mipInt;
3596
+ uniform vec3 poleAxis;
3597
+
3598
+ #define ENVMAP_TYPE_CUBE_UV
3599
+ #include <cube_uv_reflection_fragment>
3600
+
3601
+ vec3 getSample( float theta, vec3 axis ) {
3602
+
3603
+ float cosTheta = cos( theta );
3604
+ // Rodrigues' axis-angle rotation
3605
+ vec3 sampleDirection = vOutputDirection * cosTheta
3606
+ + cross( axis, vOutputDirection ) * sin( theta )
3607
+ + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
3608
+
3609
+ return bilinearCubeUV( envMap, sampleDirection, mipInt );
3610
+
3611
+ }
3612
+
3613
+ void main() {
3614
+
3615
+ vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
3616
+
3617
+ if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
3618
+
3619
+ axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
3620
+
3621
+ }
3622
+
3623
+ axis = normalize( axis );
3624
+
3625
+ gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
3626
+ gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
3627
+
3628
+ for ( int i = 1; i < n; i++ ) {
3629
+
3630
+ if ( i >= samples ) {
3631
+
3632
+ break;
3633
+
3634
+ }
3635
+
3636
+ float theta = dTheta * float( i );
3637
+ gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
3638
+ gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
3639
+
3640
+ }
3641
+
3642
+ }
3643
+ `,blending:gn,depthTest:!1,depthWrite:!1})}function Wo(){return new Ge({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ja(),fragmentShader:`
3644
+
3645
+ precision mediump float;
3646
+ precision mediump int;
3647
+
3648
+ varying vec3 vOutputDirection;
3649
+
3650
+ uniform sampler2D envMap;
3651
+
3652
+ #include <common>
3653
+
3654
+ void main() {
3655
+
3656
+ vec3 outputDirection = normalize( vOutputDirection );
3657
+ vec2 uv = equirectUv( outputDirection );
3658
+
3659
+ gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3660
+
3661
+ }
3662
+ `,blending:gn,depthTest:!1,depthWrite:!1})}function Xo(){return new Ge({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ja(),fragmentShader:`
3663
+
3664
+ precision mediump float;
3665
+ precision mediump int;
3666
+
3667
+ uniform float flipEnvMap;
3668
+
3669
+ varying vec3 vOutputDirection;
3670
+
3671
+ uniform samplerCube envMap;
3672
+
3673
+ void main() {
3674
+
3675
+ gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3676
+
3677
+ }
3678
+ `,blending:gn,depthTest:!1,depthWrite:!1})}function ja(){return`
3679
+
3680
+ precision mediump float;
3681
+ precision mediump int;
3682
+
3683
+ attribute float faceIndex;
3684
+
3685
+ varying vec3 vOutputDirection;
3686
+
3687
+ // RH coordinate system; PMREM face-indexing convention
3688
+ vec3 getDirection( vec2 uv, float face ) {
3689
+
3690
+ uv = 2.0 * uv - 1.0;
3691
+
3692
+ vec3 direction = vec3( uv, 1.0 );
3693
+
3694
+ if ( face == 0.0 ) {
3695
+
3696
+ direction = direction.zyx; // ( 1, v, u ) pos x
3697
+
3698
+ } else if ( face == 1.0 ) {
3699
+
3700
+ direction = direction.xzy;
3701
+ direction.xz *= -1.0; // ( -u, 1, -v ) pos y
3702
+
3703
+ } else if ( face == 2.0 ) {
3704
+
3705
+ direction.x *= -1.0; // ( -u, v, 1 ) pos z
3706
+
3707
+ } else if ( face == 3.0 ) {
3708
+
3709
+ direction = direction.zyx;
3710
+ direction.xz *= -1.0; // ( -1, v, -u ) neg x
3711
+
3712
+ } else if ( face == 4.0 ) {
3713
+
3714
+ direction = direction.xzy;
3715
+ direction.xy *= -1.0; // ( -u, -1, v ) neg y
3716
+
3717
+ } else if ( face == 5.0 ) {
3718
+
3719
+ direction.z *= -1.0; // ( u, v, -1 ) neg z
3720
+
3721
+ }
3722
+
3723
+ return direction;
3724
+
3725
+ }
3726
+
3727
+ void main() {
3728
+
3729
+ vOutputDirection = getDirection( uv, faceIndex );
3730
+ gl_Position = vec4( position, 1.0 );
3731
+
3732
+ }
3733
+ `}function cf(i){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){let l=o.mapping,c=l===Pr||l===Ir,h=l===ui||l===di;if(c||h){let p=t.get(o),f=p!==void 0?p.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==f)return e===null&&(e=new Ps(i)),p=c?e.fromEquirectangular(o,p):e.fromCubemap(o,p),p.texture.pmremVersion=o.pmremVersion,t.set(o,p),p.texture;if(p!==void 0)return p.texture;{let m=o.image;return c&&m&&m.height>0||h&&m&&s(m)?(e===null&&(e=new Ps(i)),p=c?e.fromEquirectangular(o):e.fromCubemap(o),p.texture.pmremVersion=o.pmremVersion,t.set(o,p),o.addEventListener("dispose",r),p.texture):null}}}return o}function s(o){let l=0,c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function r(o){let l=o.target;l.removeEventListener("dispose",r);let c=t.get(l);c!==void 0&&(t.delete(l),c.dispose())}function a(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:a}}function hf(i){let t={};function e(n){if(t[n]!==void 0)return t[n];let s;switch(n){case"WEBGL_depth_texture":s=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=i.getExtension(n)}return t[n]=s,s}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){let s=e(n);return s===null&&fs("THREE.WebGLRenderer: "+n+" extension not supported."),s}}}function uf(i,t,e,n){let s={},r=new WeakMap;function a(p){let f=p.target;f.index!==null&&t.remove(f.index);for(let x in f.attributes)t.remove(f.attributes[x]);for(let x in f.morphAttributes){let y=f.morphAttributes[x];for(let d=0,u=y.length;d<u;d++)t.remove(y[d])}f.removeEventListener("dispose",a),delete s[f.id];let m=r.get(f);m&&(t.remove(m),r.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,e.memory.geometries--}function o(p,f){return s[f.id]===!0||(f.addEventListener("dispose",a),s[f.id]=!0,e.memory.geometries++),f}function l(p){let f=p.attributes;for(let x in f)t.update(f[x],i.ARRAY_BUFFER);let m=p.morphAttributes;for(let x in m){let y=m[x];for(let d=0,u=y.length;d<u;d++)t.update(y[d],i.ARRAY_BUFFER)}}function c(p){let f=[],m=p.index,x=p.attributes.position,y=0;if(m!==null){let w=m.array;y=m.version;for(let S=0,E=w.length;S<E;S+=3){let O=w[S+0],C=w[S+1],T=w[S+2];f.push(O,C,C,T,T,O)}}else if(x!==void 0){let w=x.array;y=x.version;for(let S=0,E=w.length/3-1;S<E;S+=3){let O=S+0,C=S+1,T=S+2;f.push(O,C,C,T,T,O)}}else return;let d=new(Pl(f)?ws:Es)(f,1);d.version=y;let u=r.get(p);u&&t.remove(u),r.set(p,d)}function h(p){let f=r.get(p);if(f){let m=p.index;m!==null&&f.version<m.version&&c(p)}else c(p);return r.get(p)}return{get:o,update:l,getWireframeAttribute:h}}function df(i,t,e){let n;function s(f){n=f}let r,a;function o(f){r=f.type,a=f.bytesPerElement}function l(f,m){i.drawElements(n,m,r,f*a),e.update(m,n,1)}function c(f,m,x){x!==0&&(i.drawElementsInstanced(n,m,r,f*a,x),e.update(m,n,x))}function h(f,m,x){if(x===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,m,0,r,f,0,x);let d=0;for(let u=0;u<x;u++)d+=m[u];e.update(d,n,1)}function p(f,m,x,y){if(x===0)return;let d=t.get("WEBGL_multi_draw");if(d===null)for(let u=0;u<f.length;u++)c(f[u]/a,m[u],y[u]);else{d.multiDrawElementsInstancedWEBGL(n,m,0,r,f,0,y,0,x);let u=0;for(let w=0;w<x;w++)u+=m[w];for(let w=0;w<y.length;w++)e.update(u,n,y[w])}}this.setMode=s,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=p}function ff(i){let t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(e.calls++,a){case i.TRIANGLES:e.triangles+=o*(r/3);break;case i.LINES:e.lines+=o*(r/2);break;case i.LINE_STRIP:e.lines+=o*(r-1);break;case i.LINE_LOOP:e.lines+=o*r;break;case i.POINTS:e.points+=o*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function s(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:s,update:n}}function pf(i,t,e){let n=new WeakMap,s=new ie;function r(a,o,l){let c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,p=h!==void 0?h.length:0,f=n.get(o);if(f===void 0||f.count!==p){let tt=function(){T.dispose(),n.delete(o),o.removeEventListener("dispose",tt)};f!==void 0&&f.texture.dispose();let m=o.morphAttributes.position!==void 0,x=o.morphAttributes.normal!==void 0,y=o.morphAttributes.color!==void 0,d=o.morphAttributes.position||[],u=o.morphAttributes.normal||[],w=o.morphAttributes.color||[],S=0;m===!0&&(S=1),x===!0&&(S=2),y===!0&&(S=3);let E=o.attributes.position.count*S,O=1;E>t.maxTextureSize&&(O=Math.ceil(E/t.maxTextureSize),E=t.maxTextureSize);let C=new Float32Array(E*O*4*p),T=new Ms(C,E,O,p);T.type=en,T.needsUpdate=!0;let F=S*4;for(let g=0;g<p;g++){let M=d[g],H=u[g],z=w[g],G=E*O*4*g;for(let J=0;J<M.count;J++){let B=J*F;m===!0&&(s.fromBufferAttribute(M,J),C[G+B+0]=s.x,C[G+B+1]=s.y,C[G+B+2]=s.z,C[G+B+3]=0),x===!0&&(s.fromBufferAttribute(H,J),C[G+B+4]=s.x,C[G+B+5]=s.y,C[G+B+6]=s.z,C[G+B+7]=0),y===!0&&(s.fromBufferAttribute(z,J),C[G+B+8]=s.x,C[G+B+9]=s.y,C[G+B+10]=s.z,C[G+B+11]=z.itemSize===4?s.w:1)}}f={count:p,texture:T,size:new It(E,O)},n.set(o,f),o.addEventListener("dispose",tt)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",a.morphTexture,e);else{let m=0;for(let y=0;y<c.length;y++)m+=c[y];let x=o.morphTargetsRelative?1:1-m;l.getUniforms().setValue(i,"morphTargetBaseInfluence",x),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",f.texture,e),l.getUniforms().setValue(i,"morphTargetsTextureSize",f.size)}return{update:r}}function mf(i,t,e,n){let s=new WeakMap;function r(l){let c=n.render.frame,h=l.geometry,p=t.get(l,h);if(s.get(p)!==c&&(t.update(p),s.set(p,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),s.get(l)!==c&&(e.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&e.update(l.instanceColor,i.ARRAY_BUFFER),s.set(l,c))),l.isSkinnedMesh){let f=l.skeleton;s.get(f)!==c&&(f.update(),s.set(f,c))}return p}function a(){s=new WeakMap}function o(l){let c=l.target;c.removeEventListener("dispose",o),e.remove(c.instanceMatrix),c.instanceColor!==null&&e.remove(c.instanceColor)}return{update:r,dispose:a}}var Is=class extends Le{constructor(t,e,n,s,r,a,o,l,c,h=oi){if(h!==oi&&h!==pi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===oi&&(n=Nn),n===void 0&&h===pi&&(n=fi),super(null,s,r,a,o,l,h,n,c),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=o!==void 0?o:Pe,this.minFilter=l!==void 0?l:Pe,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}},Ul=new Le,Yo=new Is(1,1),Nl=new Ms,Ol=new ca,Fl=new As,qo=[],Zo=[],Jo=new Float32Array(16),Ko=new Float32Array(9),$o=new Float32Array(4);function xi(i,t,e){let n=i[0];if(n<=0||n>0)return i;let s=t*e,r=qo[s];if(r===void 0&&(r=new Float32Array(s),qo[s]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,i[a].toArray(r,o)}return r}function ae(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function oe(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function Bs(i,t){let e=Zo[t];e===void 0&&(e=new Int32Array(t),Zo[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function gf(i,t){let e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function _f(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ae(e,t))return;i.uniform2fv(this.addr,t),oe(e,t)}}function xf(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(ae(e,t))return;i.uniform3fv(this.addr,t),oe(e,t)}}function vf(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ae(e,t))return;i.uniform4fv(this.addr,t),oe(e,t)}}function yf(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(ae(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),oe(e,t)}else{if(ae(e,n))return;$o.set(n),i.uniformMatrix2fv(this.addr,!1,$o),oe(e,n)}}function Mf(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(ae(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),oe(e,t)}else{if(ae(e,n))return;Ko.set(n),i.uniformMatrix3fv(this.addr,!1,Ko),oe(e,n)}}function Sf(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(ae(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),oe(e,t)}else{if(ae(e,n))return;Jo.set(n),i.uniformMatrix4fv(this.addr,!1,Jo),oe(e,n)}}function bf(i,t){let e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function Ef(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ae(e,t))return;i.uniform2iv(this.addr,t),oe(e,t)}}function wf(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(ae(e,t))return;i.uniform3iv(this.addr,t),oe(e,t)}}function Tf(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ae(e,t))return;i.uniform4iv(this.addr,t),oe(e,t)}}function Af(i,t){let e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function Rf(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ae(e,t))return;i.uniform2uiv(this.addr,t),oe(e,t)}}function Cf(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(ae(e,t))return;i.uniform3uiv(this.addr,t),oe(e,t)}}function Pf(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ae(e,t))return;i.uniform4uiv(this.addr,t),oe(e,t)}}function If(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(Yo.compareFunction=Rl,r=Yo):r=Ul,e.setTexture2D(t||r,s)}function Lf(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture3D(t||Ol,s)}function Df(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTextureCube(t||Fl,s)}function Uf(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture2DArray(t||Nl,s)}function Nf(i){switch(i){case 5126:return gf;case 35664:return _f;case 35665:return xf;case 35666:return vf;case 35674:return yf;case 35675:return Mf;case 35676:return Sf;case 5124:case 35670:return bf;case 35667:case 35671:return Ef;case 35668:case 35672:return wf;case 35669:case 35673:return Tf;case 5125:return Af;case 36294:return Rf;case 36295:return Cf;case 36296:return Pf;case 35678:case 36198:case 36298:case 36306:case 35682:return If;case 35679:case 36299:case 36307:return Lf;case 35680:case 36300:case 36308:case 36293:return Df;case 36289:case 36303:case 36311:case 36292:return Uf}}function Of(i,t){i.uniform1fv(this.addr,t)}function Ff(i,t){let e=xi(t,this.size,2);i.uniform2fv(this.addr,e)}function Bf(i,t){let e=xi(t,this.size,3);i.uniform3fv(this.addr,e)}function zf(i,t){let e=xi(t,this.size,4);i.uniform4fv(this.addr,e)}function kf(i,t){let e=xi(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function Vf(i,t){let e=xi(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function Hf(i,t){let e=xi(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function Gf(i,t){i.uniform1iv(this.addr,t)}function Wf(i,t){i.uniform2iv(this.addr,t)}function Xf(i,t){i.uniform3iv(this.addr,t)}function Yf(i,t){i.uniform4iv(this.addr,t)}function qf(i,t){i.uniform1uiv(this.addr,t)}function Zf(i,t){i.uniform2uiv(this.addr,t)}function Jf(i,t){i.uniform3uiv(this.addr,t)}function Kf(i,t){i.uniform4uiv(this.addr,t)}function $f(i,t,e){let n=this.cache,s=t.length,r=Bs(e,s);ae(n,r)||(i.uniform1iv(this.addr,r),oe(n,r));for(let a=0;a!==s;++a)e.setTexture2D(t[a]||Ul,r[a])}function jf(i,t,e){let n=this.cache,s=t.length,r=Bs(e,s);ae(n,r)||(i.uniform1iv(this.addr,r),oe(n,r));for(let a=0;a!==s;++a)e.setTexture3D(t[a]||Ol,r[a])}function Qf(i,t,e){let n=this.cache,s=t.length,r=Bs(e,s);ae(n,r)||(i.uniform1iv(this.addr,r),oe(n,r));for(let a=0;a!==s;++a)e.setTextureCube(t[a]||Fl,r[a])}function tp(i,t,e){let n=this.cache,s=t.length,r=Bs(e,s);ae(n,r)||(i.uniform1iv(this.addr,r),oe(n,r));for(let a=0;a!==s;++a)e.setTexture2DArray(t[a]||Nl,r[a])}function ep(i){switch(i){case 5126:return Of;case 35664:return Ff;case 35665:return Bf;case 35666:return zf;case 35674:return kf;case 35675:return Vf;case 35676:return Hf;case 5124:case 35670:return Gf;case 35667:case 35671:return Wf;case 35668:case 35672:return Xf;case 35669:case 35673:return Yf;case 5125:return qf;case 36294:return Zf;case 36295:return Jf;case 36296:return Kf;case 35678:case 36198:case 36298:case 36306:case 35682:return $f;case 35679:case 36299:case 36307:return jf;case 35680:case 36300:case 36308:case 36293:return Qf;case 36289:case 36303:case 36311:case 36292:return tp}}var fa=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=Nf(e.type)}},pa=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=ep(e.type)}},ma=class{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){let s=this.seq;for(let r=0,a=s.length;r!==a;++r){let o=s[r];o.setValue(t,e[o.id],n)}}},xr=/(\w+)(\])?(\[|\.)?/g;function jo(i,t){i.seq.push(t),i.map[t.id]=t}function np(i,t,e){let n=i.name,s=n.length;for(xr.lastIndex=0;;){let r=xr.exec(n),a=xr.lastIndex,o=r[1],l=r[2]==="]",c=r[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===s){jo(e,c===void 0?new fa(o,i,t):new pa(o,i,t));break}else{let p=e.map[o];p===void 0&&(p=new ma(o),jo(e,p)),e=p}}}var ci=class{constructor(t,e){this.seq=[],this.map={};let n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let r=t.getActiveUniform(e,s),a=t.getUniformLocation(e,r.name);np(r,a,this)}}setValue(t,e,n,s){let r=this.map[e];r!==void 0&&r.setValue(t,n,s)}setOptional(t,e,n){let s=e[n];s!==void 0&&this.setValue(t,n,s)}static upload(t,e,n,s){for(let r=0,a=e.length;r!==a;++r){let o=e[r],l=n[o.id];l.needsUpdate!==!1&&o.setValue(t,l.value,s)}}static seqWithValue(t,e){let n=[];for(let s=0,r=t.length;s!==r;++s){let a=t[s];a.id in e&&n.push(a)}return n}};function Qo(i,t,e){let n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}var ip=37297,sp=0;function rp(i,t){let e=i.split(`
3734
+ `),n=[],s=Math.max(t-6,0),r=Math.min(t+6,e.length);for(let a=s;a<r;a++){let o=a+1;n.push(`${o===t?">":" "} ${o}: ${e[a]}`)}return n.join(`
3735
+ `)}function ap(i){let t=Wt.getPrimaries(Wt.workingColorSpace),e=Wt.getPrimaries(i),n;switch(t===e?n="":t===_s&&e===gs?n="LinearDisplayP3ToLinearSRGB":t===gs&&e===_s&&(n="LinearSRGBToLinearDisplayP3"),i){case yn:case Fs:return[n,"LinearTransferOETF"];case Xe:case Ka:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",i),[n,"LinearTransferOETF"]}}function tl(i,t,e){let n=i.getShaderParameter(t,i.COMPILE_STATUS),s=i.getShaderInfoLog(t).trim();if(n&&s==="")return"";let r=/ERROR: 0:(\d+)/.exec(s);if(r){let a=parseInt(r[1]);return e.toUpperCase()+`
3736
+
3737
+ `+s+`
3738
+
3739
+ `+rp(i.getShaderSource(t),a)}else return s}function op(i,t){let e=ap(t);return`vec4 ${i}( vec4 value ) { return ${e[0]}( ${e[1]}( value ) ); }`}function lp(i,t){let e;switch(t){case pc:e="Linear";break;case mc:e="Reinhard";break;case gc:e="Cineon";break;case _c:e="ACESFilmic";break;case vc:e="AgX";break;case yc:e="Neutral";break;case xc:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}var ns=new L;function cp(){Wt.getLuminanceCoefficients(ns);let i=ns.x.toFixed(4),t=ns.y.toFixed(4),e=ns.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
3740
+ `)}function hp(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(wi).join(`
3741
+ `)}function up(i){let t=[];for(let e in i){let n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
3742
+ `)}function dp(i,t){let e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let r=i.getActiveAttrib(t,s),a=r.name,o=1;r.type===i.FLOAT_MAT2&&(o=2),r.type===i.FLOAT_MAT3&&(o=3),r.type===i.FLOAT_MAT4&&(o=4),e[a]={type:r.type,location:i.getAttribLocation(t,a),locationSize:o}}return e}function wi(i){return i!==""}function el(i,t){let e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function nl(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var fp=/^[ \t]*#include +<([\w\d./]+)>/gm;function ga(i){return i.replace(fp,mp)}var pp=new Map;function mp(i,t){let e=Ct[t];if(e===void 0){let n=pp.get(t);if(n!==void 0)e=Ct[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return ga(e)}var gp=/#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 il(i){return i.replace(gp,_p)}function _p(i,t,e,n){let s="";for(let r=parseInt(t);r<parseInt(e);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function sl(i){let t=`precision ${i.precision} float;
3743
+ precision ${i.precision} int;
3744
+ precision ${i.precision} sampler2D;
3745
+ precision ${i.precision} samplerCube;
3746
+ precision ${i.precision} sampler3D;
3747
+ precision ${i.precision} sampler2DArray;
3748
+ precision ${i.precision} sampler2DShadow;
3749
+ precision ${i.precision} samplerCubeShadow;
3750
+ precision ${i.precision} sampler2DArrayShadow;
3751
+ precision ${i.precision} isampler2D;
3752
+ precision ${i.precision} isampler3D;
3753
+ precision ${i.precision} isamplerCube;
3754
+ precision ${i.precision} isampler2DArray;
3755
+ precision ${i.precision} usampler2D;
3756
+ precision ${i.precision} usampler3D;
3757
+ precision ${i.precision} usamplerCube;
3758
+ precision ${i.precision} usampler2DArray;
3759
+ `;return i.precision==="highp"?t+=`
3760
+ #define HIGH_PRECISION`:i.precision==="mediump"?t+=`
3761
+ #define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`
3762
+ #define LOW_PRECISION`),t}function xp(i){let t="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===ml?t="SHADOWMAP_TYPE_PCF":i.shadowMapType===ql?t="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===Qe&&(t="SHADOWMAP_TYPE_VSM"),t}function vp(i){let t="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case ui:case di:t="ENVMAP_TYPE_CUBE";break;case Os:t="ENVMAP_TYPE_CUBE_UV";break}return t}function yp(i){let t="ENVMAP_MODE_REFLECTION";return i.envMap&&i.envMapMode===di&&(t="ENVMAP_MODE_REFRACTION"),t}function Mp(i){let t="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case gl:t="ENVMAP_BLENDING_MULTIPLY";break;case dc:t="ENVMAP_BLENDING_MIX";break;case fc:t="ENVMAP_BLENDING_ADD";break}return t}function Sp(i){let t=i.envMapCubeUVHeight;if(t===null)return null;let e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:n,maxMip:e}}function bp(i,t,e,n){let s=i.getContext(),r=e.defines,a=e.vertexShader,o=e.fragmentShader,l=xp(e),c=vp(e),h=yp(e),p=Mp(e),f=Sp(e),m=hp(e),x=up(r),y=s.createProgram(),d,u,w=e.glslVersion?"#version "+e.glslVersion+`
3763
+ `:"";e.isRawShaderMaterial?(d=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,x].filter(wi).join(`
3764
+ `),d.length>0&&(d+=`
3765
+ `),u=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,x].filter(wi).join(`
3766
+ `),u.length>0&&(u+=`
3767
+ `)):(d=[sl(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,x,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","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","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
3768
+ `].filter(wi).join(`
3769
+ `),u=[sl(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,x,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+h:"",e.envMap?"#define "+p:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor||e.batchingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==_n?"#define TONE_MAPPING":"",e.toneMapping!==_n?Ct.tonemapping_pars_fragment:"",e.toneMapping!==_n?lp("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Ct.colorspace_pars_fragment,op("linearToOutputTexel",e.outputColorSpace),cp(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
3770
+ `].filter(wi).join(`
3771
+ `)),a=ga(a),a=el(a,e),a=nl(a,e),o=ga(o),o=el(o,e),o=nl(o,e),a=il(a),o=il(o),e.isRawShaderMaterial!==!0&&(w=`#version 300 es
3772
+ `,d=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3773
+ `)+`
3774
+ `+d,u=["#define varying in",e.glslVersion===Mo?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Mo?"":"#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(`
3775
+ `)+`
3776
+ `+u);let S=w+d+a,E=w+u+o,O=Qo(s,s.VERTEX_SHADER,S),C=Qo(s,s.FRAGMENT_SHADER,E);s.attachShader(y,O),s.attachShader(y,C),e.index0AttributeName!==void 0?s.bindAttribLocation(y,0,e.index0AttributeName):e.morphTargets===!0&&s.bindAttribLocation(y,0,"position"),s.linkProgram(y);function T(M){if(i.debug.checkShaderErrors){let H=s.getProgramInfoLog(y).trim(),z=s.getShaderInfoLog(O).trim(),G=s.getShaderInfoLog(C).trim(),J=!0,B=!0;if(s.getProgramParameter(y,s.LINK_STATUS)===!1)if(J=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,y,O,C);else{let j=tl(s,O,"vertex"),V=tl(s,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(y,s.VALIDATE_STATUS)+`
3777
+
3778
+ Material Name: `+M.name+`
3779
+ Material Type: `+M.type+`
3780
+
3781
+ Program Info Log: `+H+`
3782
+ `+j+`
3783
+ `+V)}else H!==""?console.warn("THREE.WebGLProgram: Program Info Log:",H):(z===""||G==="")&&(B=!1);B&&(M.diagnostics={runnable:J,programLog:H,vertexShader:{log:z,prefix:d},fragmentShader:{log:G,prefix:u}})}s.deleteShader(O),s.deleteShader(C),F=new ci(s,y),tt=dp(s,y)}let F;this.getUniforms=function(){return F===void 0&&T(this),F};let tt;this.getAttributes=function(){return tt===void 0&&T(this),tt};let g=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return g===!1&&(g=s.getProgramParameter(y,ip)),g},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(y),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=sp++,this.cacheKey=t,this.usedTimes=1,this.program=y,this.vertexShader=O,this.fragmentShader=C,this}var Ep=0,_a=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,n=t.fragmentShader,s=this._getShaderStage(e),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(s)===!1&&(a.add(s),s.usedTimes++),a.has(r)===!1&&(a.add(r),r.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);return n===void 0&&(n=new xa(t),e.set(t,n)),n}},xa=class{constructor(t){this.id=Ep++,this.code=t,this.usedTimes=0}};function wp(i,t,e,n,s,r,a){let o=new Ss,l=new _a,c=new Set,h=[],p=s.logarithmicDepthBuffer,f=s.reverseDepthBuffer,m=s.vertexTextures,x=s.precision,y={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 d(g){return c.add(g),g===0?"uv":`uv${g}`}function u(g,M,H,z,G){let J=z.fog,B=G.geometry,j=g.isMeshStandardMaterial?z.environment:null,V=(g.isMeshStandardMaterial?e:t).get(g.envMap||j),ot=V&&V.mapping===Os?V.image.height:null,lt=y[g.type];g.precision!==null&&(x=s.getMaxPrecision(g.precision),x!==g.precision&&console.warn("THREE.WebGLProgram.getParameters:",g.precision,"not supported, using",x,"instead."));let gt=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,kt=gt!==void 0?gt.length:0,Xt=0;B.morphAttributes.position!==void 0&&(Xt=1),B.morphAttributes.normal!==void 0&&(Xt=2),B.morphAttributes.color!==void 0&&(Xt=3);let W,K,pt,ct;if(lt){let _e=Ye[lt];W=_e.vertexShader,K=_e.fragmentShader}else W=g.vertexShader,K=g.fragmentShader,l.update(g),pt=l.getVertexShaderID(g),ct=l.getFragmentShaderID(g);let At=i.getRenderTarget(),Mt=G.isInstancedMesh===!0,Ut=G.isBatchedMesh===!0,qt=!!g.map,Nt=!!g.matcap,A=!!V,Se=!!g.aoMap,Lt=!!g.lightMap,Ft=!!g.bumpMap,bt=!!g.normalMap,Kt=!!g.displacementMap,Tt=!!g.emissiveMap,b=!!g.metalnessMap,_=!!g.roughnessMap,D=g.anisotropy>0,Y=g.clearcoat>0,Z=g.dispersion>0,X=g.iridescence>0,_t=g.sheen>0,nt=g.transmission>0,ht=D&&!!g.anisotropyMap,Bt=Y&&!!g.clearcoatMap,$=Y&&!!g.clearcoatNormalMap,ut=Y&&!!g.clearcoatRoughnessMap,Et=X&&!!g.iridescenceMap,wt=X&&!!g.iridescenceThicknessMap,dt=_t&&!!g.sheenColorMap,Dt=_t&&!!g.sheenRoughnessMap,Rt=!!g.specularMap,Jt=!!g.specularColorMap,R=!!g.specularIntensityMap,rt=nt&&!!g.transmissionMap,k=nt&&!!g.thicknessMap,q=!!g.gradientMap,it=!!g.alphaMap,at=g.alphaTest>0,Ot=!!g.alphaHash,se=!!g.extensions,ge=_n;g.toneMapped&&(At===null||At.isXRRenderTarget===!0)&&(ge=i.toneMapping);let Vt={shaderID:lt,shaderType:g.type,shaderName:g.name,vertexShader:W,fragmentShader:K,defines:g.defines,customVertexShaderID:pt,customFragmentShaderID:ct,isRawShaderMaterial:g.isRawShaderMaterial===!0,glslVersion:g.glslVersion,precision:x,batching:Ut,batchingColor:Ut&&G._colorsTexture!==null,instancing:Mt,instancingColor:Mt&&G.instanceColor!==null,instancingMorph:Mt&&G.morphTexture!==null,supportsVertexTextures:m,outputColorSpace:At===null?i.outputColorSpace:At.isXRRenderTarget===!0?At.texture.colorSpace:yn,alphaToCoverage:!!g.alphaToCoverage,map:qt,matcap:Nt,envMap:A,envMapMode:A&&V.mapping,envMapCubeUVHeight:ot,aoMap:Se,lightMap:Lt,bumpMap:Ft,normalMap:bt,displacementMap:m&&Kt,emissiveMap:Tt,normalMapObjectSpace:bt&&g.normalMapType===wc,normalMapTangentSpace:bt&&g.normalMapType===Ec,metalnessMap:b,roughnessMap:_,anisotropy:D,anisotropyMap:ht,clearcoat:Y,clearcoatMap:Bt,clearcoatNormalMap:$,clearcoatRoughnessMap:ut,dispersion:Z,iridescence:X,iridescenceMap:Et,iridescenceThicknessMap:wt,sheen:_t,sheenColorMap:dt,sheenRoughnessMap:Dt,specularMap:Rt,specularColorMap:Jt,specularIntensityMap:R,transmission:nt,transmissionMap:rt,thicknessMap:k,gradientMap:q,opaque:g.transparent===!1&&g.blending===Un&&g.alphaToCoverage===!1,alphaMap:it,alphaTest:at,alphaHash:Ot,combine:g.combine,mapUv:qt&&d(g.map.channel),aoMapUv:Se&&d(g.aoMap.channel),lightMapUv:Lt&&d(g.lightMap.channel),bumpMapUv:Ft&&d(g.bumpMap.channel),normalMapUv:bt&&d(g.normalMap.channel),displacementMapUv:Kt&&d(g.displacementMap.channel),emissiveMapUv:Tt&&d(g.emissiveMap.channel),metalnessMapUv:b&&d(g.metalnessMap.channel),roughnessMapUv:_&&d(g.roughnessMap.channel),anisotropyMapUv:ht&&d(g.anisotropyMap.channel),clearcoatMapUv:Bt&&d(g.clearcoatMap.channel),clearcoatNormalMapUv:$&&d(g.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ut&&d(g.clearcoatRoughnessMap.channel),iridescenceMapUv:Et&&d(g.iridescenceMap.channel),iridescenceThicknessMapUv:wt&&d(g.iridescenceThicknessMap.channel),sheenColorMapUv:dt&&d(g.sheenColorMap.channel),sheenRoughnessMapUv:Dt&&d(g.sheenRoughnessMap.channel),specularMapUv:Rt&&d(g.specularMap.channel),specularColorMapUv:Jt&&d(g.specularColorMap.channel),specularIntensityMapUv:R&&d(g.specularIntensityMap.channel),transmissionMapUv:rt&&d(g.transmissionMap.channel),thicknessMapUv:k&&d(g.thicknessMap.channel),alphaMapUv:it&&d(g.alphaMap.channel),vertexTangents:!!B.attributes.tangent&&(bt||D),vertexColors:g.vertexColors,vertexAlphas:g.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,pointsUvs:G.isPoints===!0&&!!B.attributes.uv&&(qt||it),fog:!!J,useFog:g.fog===!0,fogExp2:!!J&&J.isFogExp2,flatShading:g.flatShading===!0,sizeAttenuation:g.sizeAttenuation===!0,logarithmicDepthBuffer:p,reverseDepthBuffer:f,skinning:G.isSkinnedMesh===!0,morphTargets:B.morphAttributes.position!==void 0,morphNormals:B.morphAttributes.normal!==void 0,morphColors:B.morphAttributes.color!==void 0,morphTargetsCount:kt,morphTextureStride:Xt,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:g.dithering,shadowMapEnabled:i.shadowMap.enabled&&H.length>0,shadowMapType:i.shadowMap.type,toneMapping:ge,decodeVideoTexture:qt&&g.map.isVideoTexture===!0&&Wt.getTransfer(g.map.colorSpace)===jt,premultipliedAlpha:g.premultipliedAlpha,doubleSided:g.side===tn,flipSided:g.side===ve,useDepthPacking:g.depthPacking>=0,depthPacking:g.depthPacking||0,index0AttributeName:g.index0AttributeName,extensionClipCullDistance:se&&g.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(se&&g.extensions.multiDraw===!0||Ut)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:g.customProgramCacheKey()};return Vt.vertexUv1s=c.has(1),Vt.vertexUv2s=c.has(2),Vt.vertexUv3s=c.has(3),c.clear(),Vt}function w(g){let M=[];if(g.shaderID?M.push(g.shaderID):(M.push(g.customVertexShaderID),M.push(g.customFragmentShaderID)),g.defines!==void 0)for(let H in g.defines)M.push(H),M.push(g.defines[H]);return g.isRawShaderMaterial===!1&&(S(M,g),E(M,g),M.push(i.outputColorSpace)),M.push(g.customProgramCacheKey),M.join()}function S(g,M){g.push(M.precision),g.push(M.outputColorSpace),g.push(M.envMapMode),g.push(M.envMapCubeUVHeight),g.push(M.mapUv),g.push(M.alphaMapUv),g.push(M.lightMapUv),g.push(M.aoMapUv),g.push(M.bumpMapUv),g.push(M.normalMapUv),g.push(M.displacementMapUv),g.push(M.emissiveMapUv),g.push(M.metalnessMapUv),g.push(M.roughnessMapUv),g.push(M.anisotropyMapUv),g.push(M.clearcoatMapUv),g.push(M.clearcoatNormalMapUv),g.push(M.clearcoatRoughnessMapUv),g.push(M.iridescenceMapUv),g.push(M.iridescenceThicknessMapUv),g.push(M.sheenColorMapUv),g.push(M.sheenRoughnessMapUv),g.push(M.specularMapUv),g.push(M.specularColorMapUv),g.push(M.specularIntensityMapUv),g.push(M.transmissionMapUv),g.push(M.thicknessMapUv),g.push(M.combine),g.push(M.fogExp2),g.push(M.sizeAttenuation),g.push(M.morphTargetsCount),g.push(M.morphAttributeCount),g.push(M.numDirLights),g.push(M.numPointLights),g.push(M.numSpotLights),g.push(M.numSpotLightMaps),g.push(M.numHemiLights),g.push(M.numRectAreaLights),g.push(M.numDirLightShadows),g.push(M.numPointLightShadows),g.push(M.numSpotLightShadows),g.push(M.numSpotLightShadowsWithMaps),g.push(M.numLightProbes),g.push(M.shadowMapType),g.push(M.toneMapping),g.push(M.numClippingPlanes),g.push(M.numClipIntersection),g.push(M.depthPacking)}function E(g,M){o.disableAll(),M.supportsVertexTextures&&o.enable(0),M.instancing&&o.enable(1),M.instancingColor&&o.enable(2),M.instancingMorph&&o.enable(3),M.matcap&&o.enable(4),M.envMap&&o.enable(5),M.normalMapObjectSpace&&o.enable(6),M.normalMapTangentSpace&&o.enable(7),M.clearcoat&&o.enable(8),M.iridescence&&o.enable(9),M.alphaTest&&o.enable(10),M.vertexColors&&o.enable(11),M.vertexAlphas&&o.enable(12),M.vertexUv1s&&o.enable(13),M.vertexUv2s&&o.enable(14),M.vertexUv3s&&o.enable(15),M.vertexTangents&&o.enable(16),M.anisotropy&&o.enable(17),M.alphaHash&&o.enable(18),M.batching&&o.enable(19),M.dispersion&&o.enable(20),M.batchingColor&&o.enable(21),g.push(o.mask),o.disableAll(),M.fog&&o.enable(0),M.useFog&&o.enable(1),M.flatShading&&o.enable(2),M.logarithmicDepthBuffer&&o.enable(3),M.reverseDepthBuffer&&o.enable(4),M.skinning&&o.enable(5),M.morphTargets&&o.enable(6),M.morphNormals&&o.enable(7),M.morphColors&&o.enable(8),M.premultipliedAlpha&&o.enable(9),M.shadowMapEnabled&&o.enable(10),M.doubleSided&&o.enable(11),M.flipSided&&o.enable(12),M.useDepthPacking&&o.enable(13),M.dithering&&o.enable(14),M.transmission&&o.enable(15),M.sheen&&o.enable(16),M.opaque&&o.enable(17),M.pointsUvs&&o.enable(18),M.decodeVideoTexture&&o.enable(19),M.alphaToCoverage&&o.enable(20),g.push(o.mask)}function O(g){let M=y[g.type],H;if(M){let z=Ye[M];H=ph.clone(z.uniforms)}else H=g.uniforms;return H}function C(g,M){let H;for(let z=0,G=h.length;z<G;z++){let J=h[z];if(J.cacheKey===M){H=J,++H.usedTimes;break}}return H===void 0&&(H=new bp(i,M,g,r),h.push(H)),H}function T(g){if(--g.usedTimes===0){let M=h.indexOf(g);h[M]=h[h.length-1],h.pop(),g.destroy()}}function F(g){l.remove(g)}function tt(){l.dispose()}return{getParameters:u,getProgramCacheKey:w,getUniforms:O,acquireProgram:C,releaseProgram:T,releaseShaderCache:F,programs:h,dispose:tt}}function Tp(){let i=new WeakMap;function t(a){return i.has(a)}function e(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,l){i.get(a)[o]=l}function r(){i=new WeakMap}return{has:t,get:e,remove:n,update:s,dispose:r}}function Ap(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.z!==t.z?i.z-t.z:i.id-t.id}function rl(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function al(){let i=[],t=0,e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function a(p,f,m,x,y,d){let u=i[t];return u===void 0?(u={id:p.id,object:p,geometry:f,material:m,groupOrder:x,renderOrder:p.renderOrder,z:y,group:d},i[t]=u):(u.id=p.id,u.object=p,u.geometry=f,u.material=m,u.groupOrder=x,u.renderOrder=p.renderOrder,u.z=y,u.group=d),t++,u}function o(p,f,m,x,y,d){let u=a(p,f,m,x,y,d);m.transmission>0?n.push(u):m.transparent===!0?s.push(u):e.push(u)}function l(p,f,m,x,y,d){let u=a(p,f,m,x,y,d);m.transmission>0?n.unshift(u):m.transparent===!0?s.unshift(u):e.unshift(u)}function c(p,f){e.length>1&&e.sort(p||Ap),n.length>1&&n.sort(f||rl),s.length>1&&s.sort(f||rl)}function h(){for(let p=t,f=i.length;p<f;p++){let m=i[p];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:e,transmissive:n,transparent:s,init:r,push:o,unshift:l,finish:h,sort:c}}function Rp(){let i=new WeakMap;function t(n,s){let r=i.get(n),a;return r===void 0?(a=new al,i.set(n,[a])):s>=r.length?(a=new al,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function Cp(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new L,color:new zt};break;case"SpotLight":e={position:new L,direction:new L,color:new zt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new L,color:new zt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new L,skyColor:new zt,groundColor:new zt};break;case"RectAreaLight":e={color:new zt,position:new L,halfWidth:new L,halfHeight:new L};break}return i[t.id]=e,e}}}function Pp(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new It};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new It};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new It,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var Ip=0;function Lp(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Dp(i){let t=new Cp,e=Pp(),n={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 c=0;c<9;c++)n.probe.push(new L);let s=new L,r=new ee,a=new ee;function o(c){let h=0,p=0,f=0;for(let tt=0;tt<9;tt++)n.probe[tt].set(0,0,0);let m=0,x=0,y=0,d=0,u=0,w=0,S=0,E=0,O=0,C=0,T=0;c.sort(Lp);for(let tt=0,g=c.length;tt<g;tt++){let M=c[tt],H=M.color,z=M.intensity,G=M.distance,J=M.shadow&&M.shadow.map?M.shadow.map.texture:null;if(M.isAmbientLight)h+=H.r*z,p+=H.g*z,f+=H.b*z;else if(M.isLightProbe){for(let B=0;B<9;B++)n.probe[B].addScaledVector(M.sh.coefficients[B],z);T++}else if(M.isDirectionalLight){let B=t.get(M);if(B.color.copy(M.color).multiplyScalar(M.intensity),M.castShadow){let j=M.shadow,V=e.get(M);V.shadowIntensity=j.intensity,V.shadowBias=j.bias,V.shadowNormalBias=j.normalBias,V.shadowRadius=j.radius,V.shadowMapSize=j.mapSize,n.directionalShadow[m]=V,n.directionalShadowMap[m]=J,n.directionalShadowMatrix[m]=M.shadow.matrix,w++}n.directional[m]=B,m++}else if(M.isSpotLight){let B=t.get(M);B.position.setFromMatrixPosition(M.matrixWorld),B.color.copy(H).multiplyScalar(z),B.distance=G,B.coneCos=Math.cos(M.angle),B.penumbraCos=Math.cos(M.angle*(1-M.penumbra)),B.decay=M.decay,n.spot[y]=B;let j=M.shadow;if(M.map&&(n.spotLightMap[O]=M.map,O++,j.updateMatrices(M),M.castShadow&&C++),n.spotLightMatrix[y]=j.matrix,M.castShadow){let V=e.get(M);V.shadowIntensity=j.intensity,V.shadowBias=j.bias,V.shadowNormalBias=j.normalBias,V.shadowRadius=j.radius,V.shadowMapSize=j.mapSize,n.spotShadow[y]=V,n.spotShadowMap[y]=J,E++}y++}else if(M.isRectAreaLight){let B=t.get(M);B.color.copy(H).multiplyScalar(z),B.halfWidth.set(M.width*.5,0,0),B.halfHeight.set(0,M.height*.5,0),n.rectArea[d]=B,d++}else if(M.isPointLight){let B=t.get(M);if(B.color.copy(M.color).multiplyScalar(M.intensity),B.distance=M.distance,B.decay=M.decay,M.castShadow){let j=M.shadow,V=e.get(M);V.shadowIntensity=j.intensity,V.shadowBias=j.bias,V.shadowNormalBias=j.normalBias,V.shadowRadius=j.radius,V.shadowMapSize=j.mapSize,V.shadowCameraNear=j.camera.near,V.shadowCameraFar=j.camera.far,n.pointShadow[x]=V,n.pointShadowMap[x]=J,n.pointShadowMatrix[x]=M.shadow.matrix,S++}n.point[x]=B,x++}else if(M.isHemisphereLight){let B=t.get(M);B.skyColor.copy(M.color).multiplyScalar(z),B.groundColor.copy(M.groundColor).multiplyScalar(z),n.hemi[u]=B,u++}}d>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=et.LTC_FLOAT_1,n.rectAreaLTC2=et.LTC_FLOAT_2):(n.rectAreaLTC1=et.LTC_HALF_1,n.rectAreaLTC2=et.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=p,n.ambient[2]=f;let F=n.hash;(F.directionalLength!==m||F.pointLength!==x||F.spotLength!==y||F.rectAreaLength!==d||F.hemiLength!==u||F.numDirectionalShadows!==w||F.numPointShadows!==S||F.numSpotShadows!==E||F.numSpotMaps!==O||F.numLightProbes!==T)&&(n.directional.length=m,n.spot.length=y,n.rectArea.length=d,n.point.length=x,n.hemi.length=u,n.directionalShadow.length=w,n.directionalShadowMap.length=w,n.pointShadow.length=S,n.pointShadowMap.length=S,n.spotShadow.length=E,n.spotShadowMap.length=E,n.directionalShadowMatrix.length=w,n.pointShadowMatrix.length=S,n.spotLightMatrix.length=E+O-C,n.spotLightMap.length=O,n.numSpotLightShadowsWithMaps=C,n.numLightProbes=T,F.directionalLength=m,F.pointLength=x,F.spotLength=y,F.rectAreaLength=d,F.hemiLength=u,F.numDirectionalShadows=w,F.numPointShadows=S,F.numSpotShadows=E,F.numSpotMaps=O,F.numLightProbes=T,n.version=Ip++)}function l(c,h){let p=0,f=0,m=0,x=0,y=0,d=h.matrixWorldInverse;for(let u=0,w=c.length;u<w;u++){let S=c[u];if(S.isDirectionalLight){let E=n.directional[p];E.direction.setFromMatrixPosition(S.matrixWorld),s.setFromMatrixPosition(S.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(d),p++}else if(S.isSpotLight){let E=n.spot[m];E.position.setFromMatrixPosition(S.matrixWorld),E.position.applyMatrix4(d),E.direction.setFromMatrixPosition(S.matrixWorld),s.setFromMatrixPosition(S.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(d),m++}else if(S.isRectAreaLight){let E=n.rectArea[x];E.position.setFromMatrixPosition(S.matrixWorld),E.position.applyMatrix4(d),a.identity(),r.copy(S.matrixWorld),r.premultiply(d),a.extractRotation(r),E.halfWidth.set(S.width*.5,0,0),E.halfHeight.set(0,S.height*.5,0),E.halfWidth.applyMatrix4(a),E.halfHeight.applyMatrix4(a),x++}else if(S.isPointLight){let E=n.point[f];E.position.setFromMatrixPosition(S.matrixWorld),E.position.applyMatrix4(d),f++}else if(S.isHemisphereLight){let E=n.hemi[y];E.direction.setFromMatrixPosition(S.matrixWorld),E.direction.transformDirection(d),y++}}}return{setup:o,setupView:l,state:n}}function ol(i){let t=new Dp(i),e=[],n=[];function s(h){c.camera=h,e.length=0,n.length=0}function r(h){e.push(h)}function a(h){n.push(h)}function o(){t.setup(e)}function l(h){t.setupView(e,h)}let c={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:s,state:c,setupLights:o,setupLightsView:l,pushLight:r,pushShadow:a}}function Up(i){let t=new WeakMap;function e(s,r=0){let a=t.get(s),o;return a===void 0?(o=new ol(i),t.set(s,[o])):r>=a.length?(o=new ol(i),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}var va=class extends vn{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Sc,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},ya=class extends vn{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}},Np=`void main() {
3784
+ gl_Position = vec4( position, 1.0 );
3785
+ }`,Op=`uniform sampler2D shadow_pass;
3786
+ uniform vec2 resolution;
3787
+ uniform float radius;
3788
+ #include <packing>
3789
+ void main() {
3790
+ const float samples = float( VSM_SAMPLES );
3791
+ float mean = 0.0;
3792
+ float squared_mean = 0.0;
3793
+ float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
3794
+ float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
3795
+ for ( float i = 0.0; i < samples; i ++ ) {
3796
+ float uvOffset = uvStart + i * uvStride;
3797
+ #ifdef HORIZONTAL_PASS
3798
+ vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
3799
+ mean += distribution.x;
3800
+ squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
3801
+ #else
3802
+ float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
3803
+ mean += depth;
3804
+ squared_mean += depth * depth;
3805
+ #endif
3806
+ }
3807
+ mean = mean / samples;
3808
+ squared_mean = squared_mean / samples;
3809
+ float std_dev = sqrt( squared_mean - mean * mean );
3810
+ gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3811
+ }`;function Fp(i,t,e){let n=new Rs,s=new It,r=new It,a=new ie,o=new va({depthPacking:bc}),l=new ya,c={},h=e.maxTextureSize,p={[xn]:ve,[ve]:xn,[tn]:tn},f=new Ge({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new It},radius:{value:4}},vertexShader:Np,fragmentShader:Op}),m=f.clone();m.defines.HORIZONTAL_PASS=1;let x=new He;x.setAttribute("position",new ye(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new Ie(x,f),d=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ml;let u=this.type;this.render=function(C,T,F){if(d.enabled===!1||d.autoUpdate===!1&&d.needsUpdate===!1||C.length===0)return;let tt=i.getRenderTarget(),g=i.getActiveCubeFace(),M=i.getActiveMipmapLevel(),H=i.state;H.setBlending(gn),H.buffers.color.setClear(1,1,1,1),H.buffers.depth.setTest(!0),H.setScissorTest(!1);let z=u!==Qe&&this.type===Qe,G=u===Qe&&this.type!==Qe;for(let J=0,B=C.length;J<B;J++){let j=C[J],V=j.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",j,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;s.copy(V.mapSize);let ot=V.getFrameExtents();if(s.multiply(ot),r.copy(V.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/ot.x),s.x=r.x*ot.x,V.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/ot.y),s.y=r.y*ot.y,V.mapSize.y=r.y)),V.map===null||z===!0||G===!0){let gt=this.type!==Qe?{minFilter:Pe,magFilter:Pe}:{};V.map!==null&&V.map.dispose(),V.map=new an(s.x,s.y,gt),V.map.texture.name=j.name+".shadowMap",V.camera.updateProjectionMatrix()}i.setRenderTarget(V.map),i.clear();let lt=V.getViewportCount();for(let gt=0;gt<lt;gt++){let kt=V.getViewport(gt);a.set(r.x*kt.x,r.y*kt.y,r.x*kt.z,r.y*kt.w),H.viewport(a),V.updateMatrices(j,gt),n=V.getFrustum(),E(T,F,V.camera,j,this.type)}V.isPointLightShadow!==!0&&this.type===Qe&&w(V,F),V.needsUpdate=!1}u=this.type,d.needsUpdate=!1,i.setRenderTarget(tt,g,M)};function w(C,T){let F=t.update(y);f.defines.VSM_SAMPLES!==C.blurSamples&&(f.defines.VSM_SAMPLES=C.blurSamples,m.defines.VSM_SAMPLES=C.blurSamples,f.needsUpdate=!0,m.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new an(s.x,s.y)),f.uniforms.shadow_pass.value=C.map.texture,f.uniforms.resolution.value=C.mapSize,f.uniforms.radius.value=C.radius,i.setRenderTarget(C.mapPass),i.clear(),i.renderBufferDirect(T,null,F,f,y,null),m.uniforms.shadow_pass.value=C.mapPass.texture,m.uniforms.resolution.value=C.mapSize,m.uniforms.radius.value=C.radius,i.setRenderTarget(C.map),i.clear(),i.renderBufferDirect(T,null,F,m,y,null)}function S(C,T,F,tt){let g=null,M=F.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(M!==void 0)g=M;else if(g=F.isPointLight===!0?l:o,i.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0){let H=g.uuid,z=T.uuid,G=c[H];G===void 0&&(G={},c[H]=G);let J=G[z];J===void 0&&(J=g.clone(),G[z]=J,T.addEventListener("dispose",O)),g=J}if(g.visible=T.visible,g.wireframe=T.wireframe,tt===Qe?g.side=T.shadowSide!==null?T.shadowSide:T.side:g.side=T.shadowSide!==null?T.shadowSide:p[T.side],g.alphaMap=T.alphaMap,g.alphaTest=T.alphaTest,g.map=T.map,g.clipShadows=T.clipShadows,g.clippingPlanes=T.clippingPlanes,g.clipIntersection=T.clipIntersection,g.displacementMap=T.displacementMap,g.displacementScale=T.displacementScale,g.displacementBias=T.displacementBias,g.wireframeLinewidth=T.wireframeLinewidth,g.linewidth=T.linewidth,F.isPointLight===!0&&g.isMeshDistanceMaterial===!0){let H=i.properties.get(g);H.light=F}return g}function E(C,T,F,tt,g){if(C.visible===!1)return;if(C.layers.test(T.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&g===Qe)&&(!C.frustumCulled||n.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,C.matrixWorld);let z=t.update(C),G=C.material;if(Array.isArray(G)){let J=z.groups;for(let B=0,j=J.length;B<j;B++){let V=J[B],ot=G[V.materialIndex];if(ot&&ot.visible){let lt=S(C,ot,tt,g);C.onBeforeShadow(i,C,T,F,z,lt,V),i.renderBufferDirect(F,null,z,lt,C,V),C.onAfterShadow(i,C,T,F,z,lt,V)}}}else if(G.visible){let J=S(C,G,tt,g);C.onBeforeShadow(i,C,T,F,z,J,null),i.renderBufferDirect(F,null,z,J,C,null),C.onAfterShadow(i,C,T,F,z,J,null)}}let H=C.children;for(let z=0,G=H.length;z<G;z++)E(H[z],T,F,tt,g)}function O(C){C.target.removeEventListener("dispose",O);for(let F in c){let tt=c[F],g=C.target.uuid;g in tt&&(tt[g].dispose(),delete tt[g])}}}var Bp={[br]:Er,[wr]:Rr,[Tr]:Cr,[hi]:Ar,[Er]:br,[Rr]:wr,[Cr]:Tr,[Ar]:hi};function zp(i){function t(){let R=!1,rt=new ie,k=null,q=new ie(0,0,0,0);return{setMask:function(it){k!==it&&!R&&(i.colorMask(it,it,it,it),k=it)},setLocked:function(it){R=it},setClear:function(it,at,Ot,se,ge){ge===!0&&(it*=se,at*=se,Ot*=se),rt.set(it,at,Ot,se),q.equals(rt)===!1&&(i.clearColor(it,at,Ot,se),q.copy(rt))},reset:function(){R=!1,k=null,q.set(-1,0,0,0)}}}function e(){let R=!1,rt=!1,k=null,q=null,it=null;return{setReversed:function(at){rt=at},setTest:function(at){at?pt(i.DEPTH_TEST):ct(i.DEPTH_TEST)},setMask:function(at){k!==at&&!R&&(i.depthMask(at),k=at)},setFunc:function(at){if(rt&&(at=Bp[at]),q!==at){switch(at){case br:i.depthFunc(i.NEVER);break;case Er:i.depthFunc(i.ALWAYS);break;case wr:i.depthFunc(i.LESS);break;case hi:i.depthFunc(i.LEQUAL);break;case Tr:i.depthFunc(i.EQUAL);break;case Ar:i.depthFunc(i.GEQUAL);break;case Rr:i.depthFunc(i.GREATER);break;case Cr:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}q=at}},setLocked:function(at){R=at},setClear:function(at){it!==at&&(i.clearDepth(at),it=at)},reset:function(){R=!1,k=null,q=null,it=null}}}function n(){let R=!1,rt=null,k=null,q=null,it=null,at=null,Ot=null,se=null,ge=null;return{setTest:function(Vt){R||(Vt?pt(i.STENCIL_TEST):ct(i.STENCIL_TEST))},setMask:function(Vt){rt!==Vt&&!R&&(i.stencilMask(Vt),rt=Vt)},setFunc:function(Vt,_e,qe){(k!==Vt||q!==_e||it!==qe)&&(i.stencilFunc(Vt,_e,qe),k=Vt,q=_e,it=qe)},setOp:function(Vt,_e,qe){(at!==Vt||Ot!==_e||se!==qe)&&(i.stencilOp(Vt,_e,qe),at=Vt,Ot=_e,se=qe)},setLocked:function(Vt){R=Vt},setClear:function(Vt){ge!==Vt&&(i.clearStencil(Vt),ge=Vt)},reset:function(){R=!1,rt=null,k=null,q=null,it=null,at=null,Ot=null,se=null,ge=null}}}let s=new t,r=new e,a=new n,o=new WeakMap,l=new WeakMap,c={},h={},p=new WeakMap,f=[],m=null,x=!1,y=null,d=null,u=null,w=null,S=null,E=null,O=null,C=new zt(0,0,0),T=0,F=!1,tt=null,g=null,M=null,H=null,z=null,G=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),J=!1,B=0,j=i.getParameter(i.VERSION);j.indexOf("WebGL")!==-1?(B=parseFloat(/^WebGL (\d)/.exec(j)[1]),J=B>=1):j.indexOf("OpenGL ES")!==-1&&(B=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),J=B>=2);let V=null,ot={},lt=i.getParameter(i.SCISSOR_BOX),gt=i.getParameter(i.VIEWPORT),kt=new ie().fromArray(lt),Xt=new ie().fromArray(gt);function W(R,rt,k,q){let it=new Uint8Array(4),at=i.createTexture();i.bindTexture(R,at),i.texParameteri(R,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(R,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Ot=0;Ot<k;Ot++)R===i.TEXTURE_3D||R===i.TEXTURE_2D_ARRAY?i.texImage3D(rt,0,i.RGBA,1,1,q,0,i.RGBA,i.UNSIGNED_BYTE,it):i.texImage2D(rt+Ot,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,it);return at}let K={};K[i.TEXTURE_2D]=W(i.TEXTURE_2D,i.TEXTURE_2D,1),K[i.TEXTURE_CUBE_MAP]=W(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),K[i.TEXTURE_2D_ARRAY]=W(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),K[i.TEXTURE_3D]=W(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),r.setClear(1),a.setClear(0),pt(i.DEPTH_TEST),r.setFunc(hi),Lt(!1),Ft(fo),pt(i.CULL_FACE),A(gn);function pt(R){c[R]!==!0&&(i.enable(R),c[R]=!0)}function ct(R){c[R]!==!1&&(i.disable(R),c[R]=!1)}function At(R,rt){return h[R]!==rt?(i.bindFramebuffer(R,rt),h[R]=rt,R===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=rt),R===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=rt),!0):!1}function Mt(R,rt){let k=f,q=!1;if(R){k=p.get(rt),k===void 0&&(k=[],p.set(rt,k));let it=R.textures;if(k.length!==it.length||k[0]!==i.COLOR_ATTACHMENT0){for(let at=0,Ot=it.length;at<Ot;at++)k[at]=i.COLOR_ATTACHMENT0+at;k.length=it.length,q=!0}}else k[0]!==i.BACK&&(k[0]=i.BACK,q=!0);q&&i.drawBuffers(k)}function Ut(R){return m!==R?(i.useProgram(R),m=R,!0):!1}let qt={[Cn]:i.FUNC_ADD,[Jl]:i.FUNC_SUBTRACT,[Kl]:i.FUNC_REVERSE_SUBTRACT};qt[$l]=i.MIN,qt[jl]=i.MAX;let Nt={[Ql]:i.ZERO,[tc]:i.ONE,[ec]:i.SRC_COLOR,[Mr]:i.SRC_ALPHA,[oc]:i.SRC_ALPHA_SATURATE,[rc]:i.DST_COLOR,[ic]:i.DST_ALPHA,[nc]:i.ONE_MINUS_SRC_COLOR,[Sr]:i.ONE_MINUS_SRC_ALPHA,[ac]:i.ONE_MINUS_DST_COLOR,[sc]:i.ONE_MINUS_DST_ALPHA,[lc]:i.CONSTANT_COLOR,[cc]:i.ONE_MINUS_CONSTANT_COLOR,[hc]:i.CONSTANT_ALPHA,[uc]:i.ONE_MINUS_CONSTANT_ALPHA};function A(R,rt,k,q,it,at,Ot,se,ge,Vt){if(R===gn){x===!0&&(ct(i.BLEND),x=!1);return}if(x===!1&&(pt(i.BLEND),x=!0),R!==Zl){if(R!==y||Vt!==F){if((d!==Cn||S!==Cn)&&(i.blendEquation(i.FUNC_ADD),d=Cn,S=Cn),Vt)switch(R){case Un:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case yr:i.blendFunc(i.ONE,i.ONE);break;case po:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case mo:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",R);break}else switch(R){case Un:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case yr:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case po:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case mo:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",R);break}u=null,w=null,E=null,O=null,C.set(0,0,0),T=0,y=R,F=Vt}return}it=it||rt,at=at||k,Ot=Ot||q,(rt!==d||it!==S)&&(i.blendEquationSeparate(qt[rt],qt[it]),d=rt,S=it),(k!==u||q!==w||at!==E||Ot!==O)&&(i.blendFuncSeparate(Nt[k],Nt[q],Nt[at],Nt[Ot]),u=k,w=q,E=at,O=Ot),(se.equals(C)===!1||ge!==T)&&(i.blendColor(se.r,se.g,se.b,ge),C.copy(se),T=ge),y=R,F=!1}function Se(R,rt){R.side===tn?ct(i.CULL_FACE):pt(i.CULL_FACE);let k=R.side===ve;rt&&(k=!k),Lt(k),R.blending===Un&&R.transparent===!1?A(gn):A(R.blending,R.blendEquation,R.blendSrc,R.blendDst,R.blendEquationAlpha,R.blendSrcAlpha,R.blendDstAlpha,R.blendColor,R.blendAlpha,R.premultipliedAlpha),r.setFunc(R.depthFunc),r.setTest(R.depthTest),r.setMask(R.depthWrite),s.setMask(R.colorWrite);let q=R.stencilWrite;a.setTest(q),q&&(a.setMask(R.stencilWriteMask),a.setFunc(R.stencilFunc,R.stencilRef,R.stencilFuncMask),a.setOp(R.stencilFail,R.stencilZFail,R.stencilZPass)),Kt(R.polygonOffset,R.polygonOffsetFactor,R.polygonOffsetUnits),R.alphaToCoverage===!0?pt(i.SAMPLE_ALPHA_TO_COVERAGE):ct(i.SAMPLE_ALPHA_TO_COVERAGE)}function Lt(R){tt!==R&&(R?i.frontFace(i.CW):i.frontFace(i.CCW),tt=R)}function Ft(R){R!==Xl?(pt(i.CULL_FACE),R!==g&&(R===fo?i.cullFace(i.BACK):R===Yl?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):ct(i.CULL_FACE),g=R}function bt(R){R!==M&&(J&&i.lineWidth(R),M=R)}function Kt(R,rt,k){R?(pt(i.POLYGON_OFFSET_FILL),(H!==rt||z!==k)&&(i.polygonOffset(rt,k),H=rt,z=k)):ct(i.POLYGON_OFFSET_FILL)}function Tt(R){R?pt(i.SCISSOR_TEST):ct(i.SCISSOR_TEST)}function b(R){R===void 0&&(R=i.TEXTURE0+G-1),V!==R&&(i.activeTexture(R),V=R)}function _(R,rt,k){k===void 0&&(V===null?k=i.TEXTURE0+G-1:k=V);let q=ot[k];q===void 0&&(q={type:void 0,texture:void 0},ot[k]=q),(q.type!==R||q.texture!==rt)&&(V!==k&&(i.activeTexture(k),V=k),i.bindTexture(R,rt||K[R]),q.type=R,q.texture=rt)}function D(){let R=ot[V];R!==void 0&&R.type!==void 0&&(i.bindTexture(R.type,null),R.type=void 0,R.texture=void 0)}function Y(){try{i.compressedTexImage2D.apply(i,arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function Z(){try{i.compressedTexImage3D.apply(i,arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function X(){try{i.texSubImage2D.apply(i,arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function _t(){try{i.texSubImage3D.apply(i,arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function nt(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function ht(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function Bt(){try{i.texStorage2D.apply(i,arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function $(){try{i.texStorage3D.apply(i,arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function ut(){try{i.texImage2D.apply(i,arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function Et(){try{i.texImage3D.apply(i,arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function wt(R){kt.equals(R)===!1&&(i.scissor(R.x,R.y,R.z,R.w),kt.copy(R))}function dt(R){Xt.equals(R)===!1&&(i.viewport(R.x,R.y,R.z,R.w),Xt.copy(R))}function Dt(R,rt){let k=l.get(rt);k===void 0&&(k=new WeakMap,l.set(rt,k));let q=k.get(R);q===void 0&&(q=i.getUniformBlockIndex(rt,R.name),k.set(R,q))}function Rt(R,rt){let q=l.get(rt).get(R);o.get(rt)!==q&&(i.uniformBlockBinding(rt,q,R.__bindingPointIndex),o.set(rt,q))}function Jt(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),c={},V=null,ot={},h={},p=new WeakMap,f=[],m=null,x=!1,y=null,d=null,u=null,w=null,S=null,E=null,O=null,C=new zt(0,0,0),T=0,F=!1,tt=null,g=null,M=null,H=null,z=null,kt.set(0,0,i.canvas.width,i.canvas.height),Xt.set(0,0,i.canvas.width,i.canvas.height),s.reset(),r.reset(),a.reset()}return{buffers:{color:s,depth:r,stencil:a},enable:pt,disable:ct,bindFramebuffer:At,drawBuffers:Mt,useProgram:Ut,setBlending:A,setMaterial:Se,setFlipSided:Lt,setCullFace:Ft,setLineWidth:bt,setPolygonOffset:Kt,setScissorTest:Tt,activeTexture:b,bindTexture:_,unbindTexture:D,compressedTexImage2D:Y,compressedTexImage3D:Z,texImage2D:ut,texImage3D:Et,updateUBOMapping:Dt,uniformBlockBinding:Rt,texStorage2D:Bt,texStorage3D:$,texSubImage2D:X,texSubImage3D:_t,compressedTexSubImage2D:nt,compressedTexSubImage3D:ht,scissor:wt,viewport:dt,reset:Jt}}function ll(i,t,e,n){let s=kp(n);switch(e){case Ml:return i*t;case bl:return i*t;case El:return i*t*2;case wl:return i*t/s.components*s.byteLength;case qa:return i*t/s.components*s.byteLength;case Tl:return i*t*2/s.components*s.byteLength;case Za:return i*t*2/s.components*s.byteLength;case Sl:return i*t*3/s.components*s.byteLength;case ze:return i*t*4/s.components*s.byteLength;case Ja:return i*t*4/s.components*s.byteLength;case ls:case cs:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case hs:case us:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Nr:case Fr:return Math.max(i,16)*Math.max(t,8)/4;case Ur:case Or:return Math.max(i,8)*Math.max(t,8)/2;case Br:case zr:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case kr:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Vr:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Hr:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case Gr:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case Wr:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case Xr:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case Yr:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case qr:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case Zr:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case Jr:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case Kr:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case $r:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case jr:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case Qr:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case ta:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case ds:case ea:case na:return Math.ceil(i/4)*Math.ceil(t/4)*16;case Al:case ia:return Math.ceil(i/4)*Math.ceil(t/4)*8;case sa:case ra:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function kp(i){switch(i){case sn:case xl:return{byteLength:1,components:1};case Ci:case vl:case Di:return{byteLength:2,components:1};case Xa:case Ya:return{byteLength:2,components:4};case Nn:case Wa:case en:return{byteLength:4,components:1};case yl:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}function Vp(i,t,e,n,s,r,a){let o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new It,h=new WeakMap,p,f=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(b,_){return m?new OffscreenCanvas(b,_):vs("canvas")}function y(b,_,D){let Y=1,Z=Tt(b);if((Z.width>D||Z.height>D)&&(Y=D/Math.max(Z.width,Z.height)),Y<1)if(typeof HTMLImageElement<"u"&&b instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&b instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&b instanceof ImageBitmap||typeof VideoFrame<"u"&&b instanceof VideoFrame){let X=Math.floor(Y*Z.width),_t=Math.floor(Y*Z.height);p===void 0&&(p=x(X,_t));let nt=_?x(X,_t):p;return nt.width=X,nt.height=_t,nt.getContext("2d").drawImage(b,0,0,X,_t),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Z.width+"x"+Z.height+") to ("+X+"x"+_t+")."),nt}else return"data"in b&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Z.width+"x"+Z.height+")."),b;return b}function d(b){return b.generateMipmaps&&b.minFilter!==Pe&&b.minFilter!==Be}function u(b){i.generateMipmap(b)}function w(b,_,D,Y,Z=!1){if(b!==null){if(i[b]!==void 0)return i[b];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+b+"'")}let X=_;if(_===i.RED&&(D===i.FLOAT&&(X=i.R32F),D===i.HALF_FLOAT&&(X=i.R16F),D===i.UNSIGNED_BYTE&&(X=i.R8)),_===i.RED_INTEGER&&(D===i.UNSIGNED_BYTE&&(X=i.R8UI),D===i.UNSIGNED_SHORT&&(X=i.R16UI),D===i.UNSIGNED_INT&&(X=i.R32UI),D===i.BYTE&&(X=i.R8I),D===i.SHORT&&(X=i.R16I),D===i.INT&&(X=i.R32I)),_===i.RG&&(D===i.FLOAT&&(X=i.RG32F),D===i.HALF_FLOAT&&(X=i.RG16F),D===i.UNSIGNED_BYTE&&(X=i.RG8)),_===i.RG_INTEGER&&(D===i.UNSIGNED_BYTE&&(X=i.RG8UI),D===i.UNSIGNED_SHORT&&(X=i.RG16UI),D===i.UNSIGNED_INT&&(X=i.RG32UI),D===i.BYTE&&(X=i.RG8I),D===i.SHORT&&(X=i.RG16I),D===i.INT&&(X=i.RG32I)),_===i.RGB_INTEGER&&(D===i.UNSIGNED_BYTE&&(X=i.RGB8UI),D===i.UNSIGNED_SHORT&&(X=i.RGB16UI),D===i.UNSIGNED_INT&&(X=i.RGB32UI),D===i.BYTE&&(X=i.RGB8I),D===i.SHORT&&(X=i.RGB16I),D===i.INT&&(X=i.RGB32I)),_===i.RGBA_INTEGER&&(D===i.UNSIGNED_BYTE&&(X=i.RGBA8UI),D===i.UNSIGNED_SHORT&&(X=i.RGBA16UI),D===i.UNSIGNED_INT&&(X=i.RGBA32UI),D===i.BYTE&&(X=i.RGBA8I),D===i.SHORT&&(X=i.RGBA16I),D===i.INT&&(X=i.RGBA32I)),_===i.RGB&&D===i.UNSIGNED_INT_5_9_9_9_REV&&(X=i.RGB9_E5),_===i.RGBA){let _t=Z?ms:Wt.getTransfer(Y);D===i.FLOAT&&(X=i.RGBA32F),D===i.HALF_FLOAT&&(X=i.RGBA16F),D===i.UNSIGNED_BYTE&&(X=_t===jt?i.SRGB8_ALPHA8:i.RGBA8),D===i.UNSIGNED_SHORT_4_4_4_4&&(X=i.RGBA4),D===i.UNSIGNED_SHORT_5_5_5_1&&(X=i.RGB5_A1)}return(X===i.R16F||X===i.R32F||X===i.RG16F||X===i.RG32F||X===i.RGBA16F||X===i.RGBA32F)&&t.get("EXT_color_buffer_float"),X}function S(b,_){let D;return b?_===null||_===Nn||_===fi?D=i.DEPTH24_STENCIL8:_===en?D=i.DEPTH32F_STENCIL8:_===Ci&&(D=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===Nn||_===fi?D=i.DEPTH_COMPONENT24:_===en?D=i.DEPTH_COMPONENT32F:_===Ci&&(D=i.DEPTH_COMPONENT16),D}function E(b,_){return d(b)===!0||b.isFramebufferTexture&&b.minFilter!==Pe&&b.minFilter!==Be?Math.log2(Math.max(_.width,_.height))+1:b.mipmaps!==void 0&&b.mipmaps.length>0?b.mipmaps.length:b.isCompressedTexture&&Array.isArray(b.image)?_.mipmaps.length:1}function O(b){let _=b.target;_.removeEventListener("dispose",O),T(_),_.isVideoTexture&&h.delete(_)}function C(b){let _=b.target;_.removeEventListener("dispose",C),tt(_)}function T(b){let _=n.get(b);if(_.__webglInit===void 0)return;let D=b.source,Y=f.get(D);if(Y){let Z=Y[_.__cacheKey];Z.usedTimes--,Z.usedTimes===0&&F(b),Object.keys(Y).length===0&&f.delete(D)}n.remove(b)}function F(b){let _=n.get(b);i.deleteTexture(_.__webglTexture);let D=b.source,Y=f.get(D);delete Y[_.__cacheKey],a.memory.textures--}function tt(b){let _=n.get(b);if(b.depthTexture&&b.depthTexture.dispose(),b.isWebGLCubeRenderTarget)for(let Y=0;Y<6;Y++){if(Array.isArray(_.__webglFramebuffer[Y]))for(let Z=0;Z<_.__webglFramebuffer[Y].length;Z++)i.deleteFramebuffer(_.__webglFramebuffer[Y][Z]);else i.deleteFramebuffer(_.__webglFramebuffer[Y]);_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer[Y])}else{if(Array.isArray(_.__webglFramebuffer))for(let Y=0;Y<_.__webglFramebuffer.length;Y++)i.deleteFramebuffer(_.__webglFramebuffer[Y]);else i.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&i.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let Y=0;Y<_.__webglColorRenderbuffer.length;Y++)_.__webglColorRenderbuffer[Y]&&i.deleteRenderbuffer(_.__webglColorRenderbuffer[Y]);_.__webglDepthRenderbuffer&&i.deleteRenderbuffer(_.__webglDepthRenderbuffer)}let D=b.textures;for(let Y=0,Z=D.length;Y<Z;Y++){let X=n.get(D[Y]);X.__webglTexture&&(i.deleteTexture(X.__webglTexture),a.memory.textures--),n.remove(D[Y])}n.remove(b)}let g=0;function M(){g=0}function H(){let b=g;return b>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+b+" texture units while this GPU supports only "+s.maxTextures),g+=1,b}function z(b){let _=[];return _.push(b.wrapS),_.push(b.wrapT),_.push(b.wrapR||0),_.push(b.magFilter),_.push(b.minFilter),_.push(b.anisotropy),_.push(b.internalFormat),_.push(b.format),_.push(b.type),_.push(b.generateMipmaps),_.push(b.premultiplyAlpha),_.push(b.flipY),_.push(b.unpackAlignment),_.push(b.colorSpace),_.join()}function G(b,_){let D=n.get(b);if(b.isVideoTexture&&bt(b),b.isRenderTargetTexture===!1&&b.version>0&&D.__version!==b.version){let Y=b.image;if(Y===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Y.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Xt(D,b,_);return}}e.bindTexture(i.TEXTURE_2D,D.__webglTexture,i.TEXTURE0+_)}function J(b,_){let D=n.get(b);if(b.version>0&&D.__version!==b.version){Xt(D,b,_);return}e.bindTexture(i.TEXTURE_2D_ARRAY,D.__webglTexture,i.TEXTURE0+_)}function B(b,_){let D=n.get(b);if(b.version>0&&D.__version!==b.version){Xt(D,b,_);return}e.bindTexture(i.TEXTURE_3D,D.__webglTexture,i.TEXTURE0+_)}function j(b,_){let D=n.get(b);if(b.version>0&&D.__version!==b.version){W(D,b,_);return}e.bindTexture(i.TEXTURE_CUBE_MAP,D.__webglTexture,i.TEXTURE0+_)}let V={[Lr]:i.REPEAT,[Ln]:i.CLAMP_TO_EDGE,[Dr]:i.MIRRORED_REPEAT},ot={[Pe]:i.NEAREST,[Mc]:i.NEAREST_MIPMAP_NEAREST,[Oi]:i.NEAREST_MIPMAP_LINEAR,[Be]:i.LINEAR,[Ws]:i.LINEAR_MIPMAP_NEAREST,[Dn]:i.LINEAR_MIPMAP_LINEAR},lt={[Tc]:i.NEVER,[Lc]:i.ALWAYS,[Ac]:i.LESS,[Rl]:i.LEQUAL,[Rc]:i.EQUAL,[Ic]:i.GEQUAL,[Cc]:i.GREATER,[Pc]:i.NOTEQUAL};function gt(b,_){if(_.type===en&&t.has("OES_texture_float_linear")===!1&&(_.magFilter===Be||_.magFilter===Ws||_.magFilter===Oi||_.magFilter===Dn||_.minFilter===Be||_.minFilter===Ws||_.minFilter===Oi||_.minFilter===Dn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(b,i.TEXTURE_WRAP_S,V[_.wrapS]),i.texParameteri(b,i.TEXTURE_WRAP_T,V[_.wrapT]),(b===i.TEXTURE_3D||b===i.TEXTURE_2D_ARRAY)&&i.texParameteri(b,i.TEXTURE_WRAP_R,V[_.wrapR]),i.texParameteri(b,i.TEXTURE_MAG_FILTER,ot[_.magFilter]),i.texParameteri(b,i.TEXTURE_MIN_FILTER,ot[_.minFilter]),_.compareFunction&&(i.texParameteri(b,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(b,i.TEXTURE_COMPARE_FUNC,lt[_.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===Pe||_.minFilter!==Oi&&_.minFilter!==Dn||_.type===en&&t.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||n.get(_).__currentAnisotropy){let D=t.get("EXT_texture_filter_anisotropic");i.texParameterf(b,D.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,s.getMaxAnisotropy())),n.get(_).__currentAnisotropy=_.anisotropy}}}function kt(b,_){let D=!1;b.__webglInit===void 0&&(b.__webglInit=!0,_.addEventListener("dispose",O));let Y=_.source,Z=f.get(Y);Z===void 0&&(Z={},f.set(Y,Z));let X=z(_);if(X!==b.__cacheKey){Z[X]===void 0&&(Z[X]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,D=!0),Z[X].usedTimes++;let _t=Z[b.__cacheKey];_t!==void 0&&(Z[b.__cacheKey].usedTimes--,_t.usedTimes===0&&F(_)),b.__cacheKey=X,b.__webglTexture=Z[X].texture}return D}function Xt(b,_,D){let Y=i.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(Y=i.TEXTURE_2D_ARRAY),_.isData3DTexture&&(Y=i.TEXTURE_3D);let Z=kt(b,_),X=_.source;e.bindTexture(Y,b.__webglTexture,i.TEXTURE0+D);let _t=n.get(X);if(X.version!==_t.__version||Z===!0){e.activeTexture(i.TEXTURE0+D);let nt=Wt.getPrimaries(Wt.workingColorSpace),ht=_.colorSpace===mn?null:Wt.getPrimaries(_.colorSpace),Bt=_.colorSpace===mn||nt===ht?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Bt);let $=y(_.image,!1,s.maxTextureSize);$=Kt(_,$);let ut=r.convert(_.format,_.colorSpace),Et=r.convert(_.type),wt=w(_.internalFormat,ut,Et,_.colorSpace,_.isVideoTexture);gt(Y,_);let dt,Dt=_.mipmaps,Rt=_.isVideoTexture!==!0,Jt=_t.__version===void 0||Z===!0,R=X.dataReady,rt=E(_,$);if(_.isDepthTexture)wt=S(_.format===pi,_.type),Jt&&(Rt?e.texStorage2D(i.TEXTURE_2D,1,wt,$.width,$.height):e.texImage2D(i.TEXTURE_2D,0,wt,$.width,$.height,0,ut,Et,null));else if(_.isDataTexture)if(Dt.length>0){Rt&&Jt&&e.texStorage2D(i.TEXTURE_2D,rt,wt,Dt[0].width,Dt[0].height);for(let k=0,q=Dt.length;k<q;k++)dt=Dt[k],Rt?R&&e.texSubImage2D(i.TEXTURE_2D,k,0,0,dt.width,dt.height,ut,Et,dt.data):e.texImage2D(i.TEXTURE_2D,k,wt,dt.width,dt.height,0,ut,Et,dt.data);_.generateMipmaps=!1}else Rt?(Jt&&e.texStorage2D(i.TEXTURE_2D,rt,wt,$.width,$.height),R&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,$.width,$.height,ut,Et,$.data)):e.texImage2D(i.TEXTURE_2D,0,wt,$.width,$.height,0,ut,Et,$.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){Rt&&Jt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,rt,wt,Dt[0].width,Dt[0].height,$.depth);for(let k=0,q=Dt.length;k<q;k++)if(dt=Dt[k],_.format!==ze)if(ut!==null)if(Rt){if(R)if(_.layerUpdates.size>0){let it=ll(dt.width,dt.height,_.format,_.type);for(let at of _.layerUpdates){let Ot=dt.data.subarray(at*it/dt.data.BYTES_PER_ELEMENT,(at+1)*it/dt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,k,0,0,at,dt.width,dt.height,1,ut,Ot,0,0)}_.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,k,0,0,0,dt.width,dt.height,$.depth,ut,dt.data,0,0)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,k,wt,dt.width,dt.height,$.depth,0,dt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Rt?R&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,k,0,0,0,dt.width,dt.height,$.depth,ut,Et,dt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,k,wt,dt.width,dt.height,$.depth,0,ut,Et,dt.data)}else{Rt&&Jt&&e.texStorage2D(i.TEXTURE_2D,rt,wt,Dt[0].width,Dt[0].height);for(let k=0,q=Dt.length;k<q;k++)dt=Dt[k],_.format!==ze?ut!==null?Rt?R&&e.compressedTexSubImage2D(i.TEXTURE_2D,k,0,0,dt.width,dt.height,ut,dt.data):e.compressedTexImage2D(i.TEXTURE_2D,k,wt,dt.width,dt.height,0,dt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Rt?R&&e.texSubImage2D(i.TEXTURE_2D,k,0,0,dt.width,dt.height,ut,Et,dt.data):e.texImage2D(i.TEXTURE_2D,k,wt,dt.width,dt.height,0,ut,Et,dt.data)}else if(_.isDataArrayTexture)if(Rt){if(Jt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,rt,wt,$.width,$.height,$.depth),R)if(_.layerUpdates.size>0){let k=ll($.width,$.height,_.format,_.type);for(let q of _.layerUpdates){let it=$.data.subarray(q*k/$.data.BYTES_PER_ELEMENT,(q+1)*k/$.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,q,$.width,$.height,1,ut,Et,it)}_.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,$.width,$.height,$.depth,ut,Et,$.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,wt,$.width,$.height,$.depth,0,ut,Et,$.data);else if(_.isData3DTexture)Rt?(Jt&&e.texStorage3D(i.TEXTURE_3D,rt,wt,$.width,$.height,$.depth),R&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,$.width,$.height,$.depth,ut,Et,$.data)):e.texImage3D(i.TEXTURE_3D,0,wt,$.width,$.height,$.depth,0,ut,Et,$.data);else if(_.isFramebufferTexture){if(Jt)if(Rt)e.texStorage2D(i.TEXTURE_2D,rt,wt,$.width,$.height);else{let k=$.width,q=$.height;for(let it=0;it<rt;it++)e.texImage2D(i.TEXTURE_2D,it,wt,k,q,0,ut,Et,null),k>>=1,q>>=1}}else if(Dt.length>0){if(Rt&&Jt){let k=Tt(Dt[0]);e.texStorage2D(i.TEXTURE_2D,rt,wt,k.width,k.height)}for(let k=0,q=Dt.length;k<q;k++)dt=Dt[k],Rt?R&&e.texSubImage2D(i.TEXTURE_2D,k,0,0,ut,Et,dt):e.texImage2D(i.TEXTURE_2D,k,wt,ut,Et,dt);_.generateMipmaps=!1}else if(Rt){if(Jt){let k=Tt($);e.texStorage2D(i.TEXTURE_2D,rt,wt,k.width,k.height)}R&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,ut,Et,$)}else e.texImage2D(i.TEXTURE_2D,0,wt,ut,Et,$);d(_)&&u(Y),_t.__version=X.version,_.onUpdate&&_.onUpdate(_)}b.__version=_.version}function W(b,_,D){if(_.image.length!==6)return;let Y=kt(b,_),Z=_.source;e.bindTexture(i.TEXTURE_CUBE_MAP,b.__webglTexture,i.TEXTURE0+D);let X=n.get(Z);if(Z.version!==X.__version||Y===!0){e.activeTexture(i.TEXTURE0+D);let _t=Wt.getPrimaries(Wt.workingColorSpace),nt=_.colorSpace===mn?null:Wt.getPrimaries(_.colorSpace),ht=_.colorSpace===mn||_t===nt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,ht);let Bt=_.isCompressedTexture||_.image[0].isCompressedTexture,$=_.image[0]&&_.image[0].isDataTexture,ut=[];for(let q=0;q<6;q++)!Bt&&!$?ut[q]=y(_.image[q],!0,s.maxCubemapSize):ut[q]=$?_.image[q].image:_.image[q],ut[q]=Kt(_,ut[q]);let Et=ut[0],wt=r.convert(_.format,_.colorSpace),dt=r.convert(_.type),Dt=w(_.internalFormat,wt,dt,_.colorSpace),Rt=_.isVideoTexture!==!0,Jt=X.__version===void 0||Y===!0,R=Z.dataReady,rt=E(_,Et);gt(i.TEXTURE_CUBE_MAP,_);let k;if(Bt){Rt&&Jt&&e.texStorage2D(i.TEXTURE_CUBE_MAP,rt,Dt,Et.width,Et.height);for(let q=0;q<6;q++){k=ut[q].mipmaps;for(let it=0;it<k.length;it++){let at=k[it];_.format!==ze?wt!==null?Rt?R&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,it,0,0,at.width,at.height,wt,at.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,it,Dt,at.width,at.height,0,at.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Rt?R&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,it,0,0,at.width,at.height,wt,dt,at.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,it,Dt,at.width,at.height,0,wt,dt,at.data)}}}else{if(k=_.mipmaps,Rt&&Jt){k.length>0&&rt++;let q=Tt(ut[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,rt,Dt,q.width,q.height)}for(let q=0;q<6;q++)if($){Rt?R&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,0,0,ut[q].width,ut[q].height,wt,dt,ut[q].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,Dt,ut[q].width,ut[q].height,0,wt,dt,ut[q].data);for(let it=0;it<k.length;it++){let Ot=k[it].image[q].image;Rt?R&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,it+1,0,0,Ot.width,Ot.height,wt,dt,Ot.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,it+1,Dt,Ot.width,Ot.height,0,wt,dt,Ot.data)}}else{Rt?R&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,0,0,wt,dt,ut[q]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,Dt,wt,dt,ut[q]);for(let it=0;it<k.length;it++){let at=k[it];Rt?R&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,it+1,0,0,wt,dt,at.image[q]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,it+1,Dt,wt,dt,at.image[q])}}}d(_)&&u(i.TEXTURE_CUBE_MAP),X.__version=Z.version,_.onUpdate&&_.onUpdate(_)}b.__version=_.version}function K(b,_,D,Y,Z,X){let _t=r.convert(D.format,D.colorSpace),nt=r.convert(D.type),ht=w(D.internalFormat,_t,nt,D.colorSpace);if(!n.get(_).__hasExternalTextures){let $=Math.max(1,_.width>>X),ut=Math.max(1,_.height>>X);Z===i.TEXTURE_3D||Z===i.TEXTURE_2D_ARRAY?e.texImage3D(Z,X,ht,$,ut,_.depth,0,_t,nt,null):e.texImage2D(Z,X,ht,$,ut,0,_t,nt,null)}e.bindFramebuffer(i.FRAMEBUFFER,b),Ft(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Y,Z,n.get(D).__webglTexture,0,Lt(_)):(Z===i.TEXTURE_2D||Z>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Z<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Y,Z,n.get(D).__webglTexture,X),e.bindFramebuffer(i.FRAMEBUFFER,null)}function pt(b,_,D){if(i.bindRenderbuffer(i.RENDERBUFFER,b),_.depthBuffer){let Y=_.depthTexture,Z=Y&&Y.isDepthTexture?Y.type:null,X=S(_.stencilBuffer,Z),_t=_.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,nt=Lt(_);Ft(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,nt,X,_.width,_.height):D?i.renderbufferStorageMultisample(i.RENDERBUFFER,nt,X,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,X,_.width,_.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,_t,i.RENDERBUFFER,b)}else{let Y=_.textures;for(let Z=0;Z<Y.length;Z++){let X=Y[Z],_t=r.convert(X.format,X.colorSpace),nt=r.convert(X.type),ht=w(X.internalFormat,_t,nt,X.colorSpace),Bt=Lt(_);D&&Ft(_)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Bt,ht,_.width,_.height):Ft(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Bt,ht,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,ht,_.width,_.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function ct(b,_){if(_&&_.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(i.FRAMEBUFFER,b),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(_.depthTexture).__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),G(_.depthTexture,0);let Y=n.get(_.depthTexture).__webglTexture,Z=Lt(_);if(_.depthTexture.format===oi)Ft(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Y,0,Z):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Y,0);else if(_.depthTexture.format===pi)Ft(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Y,0,Z):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Y,0);else throw new Error("Unknown depthTexture format")}function At(b){let _=n.get(b),D=b.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==b.depthTexture){let Y=b.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),Y){let Z=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,Y.removeEventListener("dispose",Z)};Y.addEventListener("dispose",Z),_.__depthDisposeCallback=Z}_.__boundDepthTexture=Y}if(b.depthTexture&&!_.__autoAllocateDepthBuffer){if(D)throw new Error("target.depthTexture not supported in Cube render targets");ct(_.__webglFramebuffer,b)}else if(D){_.__webglDepthbuffer=[];for(let Y=0;Y<6;Y++)if(e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[Y]),_.__webglDepthbuffer[Y]===void 0)_.__webglDepthbuffer[Y]=i.createRenderbuffer(),pt(_.__webglDepthbuffer[Y],b,!1);else{let Z=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,X=_.__webglDepthbuffer[Y];i.bindRenderbuffer(i.RENDERBUFFER,X),i.framebufferRenderbuffer(i.FRAMEBUFFER,Z,i.RENDERBUFFER,X)}}else if(e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=i.createRenderbuffer(),pt(_.__webglDepthbuffer,b,!1);else{let Y=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Z=_.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,Z),i.framebufferRenderbuffer(i.FRAMEBUFFER,Y,i.RENDERBUFFER,Z)}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Mt(b,_,D){let Y=n.get(b);_!==void 0&&K(Y.__webglFramebuffer,b,b.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),D!==void 0&&At(b)}function Ut(b){let _=b.texture,D=n.get(b),Y=n.get(_);b.addEventListener("dispose",C);let Z=b.textures,X=b.isWebGLCubeRenderTarget===!0,_t=Z.length>1;if(_t||(Y.__webglTexture===void 0&&(Y.__webglTexture=i.createTexture()),Y.__version=_.version,a.memory.textures++),X){D.__webglFramebuffer=[];for(let nt=0;nt<6;nt++)if(_.mipmaps&&_.mipmaps.length>0){D.__webglFramebuffer[nt]=[];for(let ht=0;ht<_.mipmaps.length;ht++)D.__webglFramebuffer[nt][ht]=i.createFramebuffer()}else D.__webglFramebuffer[nt]=i.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){D.__webglFramebuffer=[];for(let nt=0;nt<_.mipmaps.length;nt++)D.__webglFramebuffer[nt]=i.createFramebuffer()}else D.__webglFramebuffer=i.createFramebuffer();if(_t)for(let nt=0,ht=Z.length;nt<ht;nt++){let Bt=n.get(Z[nt]);Bt.__webglTexture===void 0&&(Bt.__webglTexture=i.createTexture(),a.memory.textures++)}if(b.samples>0&&Ft(b)===!1){D.__webglMultisampledFramebuffer=i.createFramebuffer(),D.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,D.__webglMultisampledFramebuffer);for(let nt=0;nt<Z.length;nt++){let ht=Z[nt];D.__webglColorRenderbuffer[nt]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,D.__webglColorRenderbuffer[nt]);let Bt=r.convert(ht.format,ht.colorSpace),$=r.convert(ht.type),ut=w(ht.internalFormat,Bt,$,ht.colorSpace,b.isXRRenderTarget===!0),Et=Lt(b);i.renderbufferStorageMultisample(i.RENDERBUFFER,Et,ut,b.width,b.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+nt,i.RENDERBUFFER,D.__webglColorRenderbuffer[nt])}i.bindRenderbuffer(i.RENDERBUFFER,null),b.depthBuffer&&(D.__webglDepthRenderbuffer=i.createRenderbuffer(),pt(D.__webglDepthRenderbuffer,b,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(X){e.bindTexture(i.TEXTURE_CUBE_MAP,Y.__webglTexture),gt(i.TEXTURE_CUBE_MAP,_);for(let nt=0;nt<6;nt++)if(_.mipmaps&&_.mipmaps.length>0)for(let ht=0;ht<_.mipmaps.length;ht++)K(D.__webglFramebuffer[nt][ht],b,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+nt,ht);else K(D.__webglFramebuffer[nt],b,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+nt,0);d(_)&&u(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(_t){for(let nt=0,ht=Z.length;nt<ht;nt++){let Bt=Z[nt],$=n.get(Bt);e.bindTexture(i.TEXTURE_2D,$.__webglTexture),gt(i.TEXTURE_2D,Bt),K(D.__webglFramebuffer,b,Bt,i.COLOR_ATTACHMENT0+nt,i.TEXTURE_2D,0),d(Bt)&&u(i.TEXTURE_2D)}e.unbindTexture()}else{let nt=i.TEXTURE_2D;if((b.isWebGL3DRenderTarget||b.isWebGLArrayRenderTarget)&&(nt=b.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(nt,Y.__webglTexture),gt(nt,_),_.mipmaps&&_.mipmaps.length>0)for(let ht=0;ht<_.mipmaps.length;ht++)K(D.__webglFramebuffer[ht],b,_,i.COLOR_ATTACHMENT0,nt,ht);else K(D.__webglFramebuffer,b,_,i.COLOR_ATTACHMENT0,nt,0);d(_)&&u(nt),e.unbindTexture()}b.depthBuffer&&At(b)}function qt(b){let _=b.textures;for(let D=0,Y=_.length;D<Y;D++){let Z=_[D];if(d(Z)){let X=b.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:i.TEXTURE_2D,_t=n.get(Z).__webglTexture;e.bindTexture(X,_t),u(X),e.unbindTexture()}}}let Nt=[],A=[];function Se(b){if(b.samples>0){if(Ft(b)===!1){let _=b.textures,D=b.width,Y=b.height,Z=i.COLOR_BUFFER_BIT,X=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,_t=n.get(b),nt=_.length>1;if(nt)for(let ht=0;ht<_.length;ht++)e.bindFramebuffer(i.FRAMEBUFFER,_t.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ht,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,_t.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ht,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,_t.__webglMultisampledFramebuffer),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,_t.__webglFramebuffer);for(let ht=0;ht<_.length;ht++){if(b.resolveDepthBuffer&&(b.depthBuffer&&(Z|=i.DEPTH_BUFFER_BIT),b.stencilBuffer&&b.resolveStencilBuffer&&(Z|=i.STENCIL_BUFFER_BIT)),nt){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,_t.__webglColorRenderbuffer[ht]);let Bt=n.get(_[ht]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Bt,0)}i.blitFramebuffer(0,0,D,Y,0,0,D,Y,Z,i.NEAREST),l===!0&&(Nt.length=0,A.length=0,Nt.push(i.COLOR_ATTACHMENT0+ht),b.depthBuffer&&b.resolveDepthBuffer===!1&&(Nt.push(X),A.push(X),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,A)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Nt))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),nt)for(let ht=0;ht<_.length;ht++){e.bindFramebuffer(i.FRAMEBUFFER,_t.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ht,i.RENDERBUFFER,_t.__webglColorRenderbuffer[ht]);let Bt=n.get(_[ht]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,_t.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ht,i.TEXTURE_2D,Bt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,_t.__webglMultisampledFramebuffer)}else if(b.depthBuffer&&b.resolveDepthBuffer===!1&&l){let _=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[_])}}}function Lt(b){return Math.min(s.maxSamples,b.samples)}function Ft(b){let _=n.get(b);return b.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function bt(b){let _=a.render.frame;h.get(b)!==_&&(h.set(b,_),b.update())}function Kt(b,_){let D=b.colorSpace,Y=b.format,Z=b.type;return b.isCompressedTexture===!0||b.isVideoTexture===!0||D!==yn&&D!==mn&&(Wt.getTransfer(D)===jt?(Y!==ze||Z!==sn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",D)),_}function Tt(b){return typeof HTMLImageElement<"u"&&b instanceof HTMLImageElement?(c.width=b.naturalWidth||b.width,c.height=b.naturalHeight||b.height):typeof VideoFrame<"u"&&b instanceof VideoFrame?(c.width=b.displayWidth,c.height=b.displayHeight):(c.width=b.width,c.height=b.height),c}this.allocateTextureUnit=H,this.resetTextureUnits=M,this.setTexture2D=G,this.setTexture2DArray=J,this.setTexture3D=B,this.setTextureCube=j,this.rebindTextures=Mt,this.setupRenderTarget=Ut,this.updateRenderTargetMipmap=qt,this.updateMultisampleRenderTarget=Se,this.setupDepthRenderbuffer=At,this.setupFrameBufferTexture=K,this.useMultisampledRTT=Ft}function Hp(i,t){function e(n,s=mn){let r,a=Wt.getTransfer(s);if(n===sn)return i.UNSIGNED_BYTE;if(n===Xa)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Ya)return i.UNSIGNED_SHORT_5_5_5_1;if(n===yl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===xl)return i.BYTE;if(n===vl)return i.SHORT;if(n===Ci)return i.UNSIGNED_SHORT;if(n===Wa)return i.INT;if(n===Nn)return i.UNSIGNED_INT;if(n===en)return i.FLOAT;if(n===Di)return i.HALF_FLOAT;if(n===Ml)return i.ALPHA;if(n===Sl)return i.RGB;if(n===ze)return i.RGBA;if(n===bl)return i.LUMINANCE;if(n===El)return i.LUMINANCE_ALPHA;if(n===oi)return i.DEPTH_COMPONENT;if(n===pi)return i.DEPTH_STENCIL;if(n===wl)return i.RED;if(n===qa)return i.RED_INTEGER;if(n===Tl)return i.RG;if(n===Za)return i.RG_INTEGER;if(n===Ja)return i.RGBA_INTEGER;if(n===ls||n===cs||n===hs||n===us)if(a===jt)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===ls)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===cs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===hs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===us)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===ls)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===cs)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===hs)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===us)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ur||n===Nr||n===Or||n===Fr)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Ur)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Nr)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Or)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Fr)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Br||n===zr||n===kr)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Br||n===zr)return a===jt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===kr)return a===jt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Vr||n===Hr||n===Gr||n===Wr||n===Xr||n===Yr||n===qr||n===Zr||n===Jr||n===Kr||n===$r||n===jr||n===Qr||n===ta)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Vr)return a===jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Hr)return a===jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Gr)return a===jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Wr)return a===jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Xr)return a===jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Yr)return a===jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===qr)return a===jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Zr)return a===jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Jr)return a===jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Kr)return a===jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===$r)return a===jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===jr)return a===jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Qr)return a===jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ta)return a===jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===ds||n===ea||n===na)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===ds)return a===jt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ea)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===na)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Al||n===ia||n===sa||n===ra)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===ds)return r.COMPRESSED_RED_RGTC1_EXT;if(n===ia)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===sa)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ra)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===fi?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}var Ma=class extends xe{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},ai=class extends Ae{constructor(){super(),this.isGroup=!0,this.type="Group"}},Gp={type:"move"},Ri=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ai,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 ai,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new L,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new L),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ai,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new L,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new L),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let s=null,r=null,a=null,o=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){a=!0;for(let y of t.hand.values()){let d=e.getJointPose(y,n),u=this._getHandJoint(c,y);d!==null&&(u.matrix.fromArray(d.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,u.jointRadius=d.radius),u.visible=d!==null}let h=c.joints["index-finger-tip"],p=c.joints["thumb-tip"],f=h.position.distanceTo(p.position),m=.02,x=.005;c.inputState.pinching&&f>m+x?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&f<=m-x&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Gp)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new ai;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},Wp=`
3812
+ void main() {
3813
+
3814
+ gl_Position = vec4( position, 1.0 );
3815
+
3816
+ }`,Xp=`
3817
+ uniform sampler2DArray depthColor;
3818
+ uniform float depthWidth;
3819
+ uniform float depthHeight;
3820
+
3821
+ void main() {
3822
+
3823
+ vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
3824
+
3825
+ if ( coord.x >= 1.0 ) {
3826
+
3827
+ gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
3828
+
3829
+ } else {
3830
+
3831
+ gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
3832
+
3833
+ }
3834
+
3835
+ }`,Sa=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){let s=new Le,r=t.properties.get(s);r.__webglTexture=e.texture,(e.depthNear!=n.depthNear||e.depthFar!=n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=s}}getMesh(t){if(this.texture!==null&&this.mesh===null){let e=t.cameras[0].viewport,n=new Ge({vertexShader:Wp,fragmentShader:Xp,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Ie(new Cs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},ba=class extends rn{constructor(t,e){super();let n=this,s=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,p=null,f=null,m=null,x=null,y=new Sa,d=e.getContextAttributes(),u=null,w=null,S=[],E=[],O=new It,C=null,T=new xe;T.layers.enable(1),T.viewport=new ie;let F=new xe;F.layers.enable(2),F.viewport=new ie;let tt=[T,F],g=new Ma;g.layers.enable(1),g.layers.enable(2);let M=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(W){let K=S[W];return K===void 0&&(K=new Ri,S[W]=K),K.getTargetRaySpace()},this.getControllerGrip=function(W){let K=S[W];return K===void 0&&(K=new Ri,S[W]=K),K.getGripSpace()},this.getHand=function(W){let K=S[W];return K===void 0&&(K=new Ri,S[W]=K),K.getHandSpace()};function z(W){let K=E.indexOf(W.inputSource);if(K===-1)return;let pt=S[K];pt!==void 0&&(pt.update(W.inputSource,W.frame,c||a),pt.dispatchEvent({type:W.type,data:W.inputSource}))}function G(){s.removeEventListener("select",z),s.removeEventListener("selectstart",z),s.removeEventListener("selectend",z),s.removeEventListener("squeeze",z),s.removeEventListener("squeezestart",z),s.removeEventListener("squeezeend",z),s.removeEventListener("end",G),s.removeEventListener("inputsourceschange",J);for(let W=0;W<S.length;W++){let K=E[W];K!==null&&(E[W]=null,S[W].disconnect(K))}M=null,H=null,y.reset(),t.setRenderTarget(u),m=null,f=null,p=null,s=null,w=null,Xt.stop(),n.isPresenting=!1,t.setPixelRatio(C),t.setSize(O.width,O.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(W){r=W,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(W){o=W,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(W){c=W},this.getBaseLayer=function(){return f!==null?f:m},this.getBinding=function(){return p},this.getFrame=function(){return x},this.getSession=function(){return s},this.setSession=async function(W){if(s=W,s!==null){if(u=t.getRenderTarget(),s.addEventListener("select",z),s.addEventListener("selectstart",z),s.addEventListener("selectend",z),s.addEventListener("squeeze",z),s.addEventListener("squeezestart",z),s.addEventListener("squeezeend",z),s.addEventListener("end",G),s.addEventListener("inputsourceschange",J),d.xrCompatible!==!0&&await e.makeXRCompatible(),C=t.getPixelRatio(),t.getSize(O),s.renderState.layers===void 0){let K={antialias:d.antialias,alpha:!0,depth:d.depth,stencil:d.stencil,framebufferScaleFactor:r};m=new XRWebGLLayer(s,e,K),s.updateRenderState({baseLayer:m}),t.setPixelRatio(1),t.setSize(m.framebufferWidth,m.framebufferHeight,!1),w=new an(m.framebufferWidth,m.framebufferHeight,{format:ze,type:sn,colorSpace:t.outputColorSpace,stencilBuffer:d.stencil})}else{let K=null,pt=null,ct=null;d.depth&&(ct=d.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,K=d.stencil?pi:oi,pt=d.stencil?fi:Nn);let At={colorFormat:e.RGBA8,depthFormat:ct,scaleFactor:r};p=new XRWebGLBinding(s,e),f=p.createProjectionLayer(At),s.updateRenderState({layers:[f]}),t.setPixelRatio(1),t.setSize(f.textureWidth,f.textureHeight,!1),w=new an(f.textureWidth,f.textureHeight,{format:ze,type:sn,depthTexture:new Is(f.textureWidth,f.textureHeight,pt,void 0,void 0,void 0,void 0,void 0,void 0,K),stencilBuffer:d.stencil,colorSpace:t.outputColorSpace,samples:d.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1})}w.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await s.requestReferenceSpace(o),Xt.setContext(s),Xt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return y.getDepthTexture()};function J(W){for(let K=0;K<W.removed.length;K++){let pt=W.removed[K],ct=E.indexOf(pt);ct>=0&&(E[ct]=null,S[ct].disconnect(pt))}for(let K=0;K<W.added.length;K++){let pt=W.added[K],ct=E.indexOf(pt);if(ct===-1){for(let Mt=0;Mt<S.length;Mt++)if(Mt>=E.length){E.push(pt),ct=Mt;break}else if(E[Mt]===null){E[Mt]=pt,ct=Mt;break}if(ct===-1)break}let At=S[ct];At&&At.connect(pt)}}let B=new L,j=new L;function V(W,K,pt){B.setFromMatrixPosition(K.matrixWorld),j.setFromMatrixPosition(pt.matrixWorld);let ct=B.distanceTo(j),At=K.projectionMatrix.elements,Mt=pt.projectionMatrix.elements,Ut=At[14]/(At[10]-1),qt=At[14]/(At[10]+1),Nt=(At[9]+1)/At[5],A=(At[9]-1)/At[5],Se=(At[8]-1)/At[0],Lt=(Mt[8]+1)/Mt[0],Ft=Ut*Se,bt=Ut*Lt,Kt=ct/(-Se+Lt),Tt=Kt*-Se;if(K.matrixWorld.decompose(W.position,W.quaternion,W.scale),W.translateX(Tt),W.translateZ(Kt),W.matrixWorld.compose(W.position,W.quaternion,W.scale),W.matrixWorldInverse.copy(W.matrixWorld).invert(),At[10]===-1)W.projectionMatrix.copy(K.projectionMatrix),W.projectionMatrixInverse.copy(K.projectionMatrixInverse);else{let b=Ut+Kt,_=qt+Kt,D=Ft-Tt,Y=bt+(ct-Tt),Z=Nt*qt/_*b,X=A*qt/_*b;W.projectionMatrix.makePerspective(D,Y,Z,X,b,_),W.projectionMatrixInverse.copy(W.projectionMatrix).invert()}}function ot(W,K){K===null?W.matrixWorld.copy(W.matrix):W.matrixWorld.multiplyMatrices(K.matrixWorld,W.matrix),W.matrixWorldInverse.copy(W.matrixWorld).invert()}this.updateCamera=function(W){if(s===null)return;let K=W.near,pt=W.far;y.texture!==null&&(y.depthNear>0&&(K=y.depthNear),y.depthFar>0&&(pt=y.depthFar)),g.near=F.near=T.near=K,g.far=F.far=T.far=pt,(M!==g.near||H!==g.far)&&(s.updateRenderState({depthNear:g.near,depthFar:g.far}),M=g.near,H=g.far);let ct=W.parent,At=g.cameras;ot(g,ct);for(let Mt=0;Mt<At.length;Mt++)ot(At[Mt],ct);At.length===2?V(g,T,F):g.projectionMatrix.copy(T.projectionMatrix),lt(W,g,ct)};function lt(W,K,pt){pt===null?W.matrix.copy(K.matrixWorld):(W.matrix.copy(pt.matrixWorld),W.matrix.invert(),W.matrix.multiply(K.matrixWorld)),W.matrix.decompose(W.position,W.quaternion,W.scale),W.updateMatrixWorld(!0),W.projectionMatrix.copy(K.projectionMatrix),W.projectionMatrixInverse.copy(K.projectionMatrixInverse),W.isPerspectiveCamera&&(W.fov=Pi*2*Math.atan(1/W.projectionMatrix.elements[5]),W.zoom=1)}this.getCamera=function(){return g},this.getFoveation=function(){if(!(f===null&&m===null))return l},this.setFoveation=function(W){l=W,f!==null&&(f.fixedFoveation=W),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=W)},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(g)};let gt=null;function kt(W,K){if(h=K.getViewerPose(c||a),x=K,h!==null){let pt=h.views;m!==null&&(t.setRenderTargetFramebuffer(w,m.framebuffer),t.setRenderTarget(w));let ct=!1;pt.length!==g.cameras.length&&(g.cameras.length=0,ct=!0);for(let Mt=0;Mt<pt.length;Mt++){let Ut=pt[Mt],qt=null;if(m!==null)qt=m.getViewport(Ut);else{let A=p.getViewSubImage(f,Ut);qt=A.viewport,Mt===0&&(t.setRenderTargetTextures(w,A.colorTexture,f.ignoreDepthValues?void 0:A.depthStencilTexture),t.setRenderTarget(w))}let Nt=tt[Mt];Nt===void 0&&(Nt=new xe,Nt.layers.enable(Mt),Nt.viewport=new ie,tt[Mt]=Nt),Nt.matrix.fromArray(Ut.transform.matrix),Nt.matrix.decompose(Nt.position,Nt.quaternion,Nt.scale),Nt.projectionMatrix.fromArray(Ut.projectionMatrix),Nt.projectionMatrixInverse.copy(Nt.projectionMatrix).invert(),Nt.viewport.set(qt.x,qt.y,qt.width,qt.height),Mt===0&&(g.matrix.copy(Nt.matrix),g.matrix.decompose(g.position,g.quaternion,g.scale)),ct===!0&&g.cameras.push(Nt)}let At=s.enabledFeatures;if(At&&At.includes("depth-sensing")){let Mt=p.getDepthInformation(pt[0]);Mt&&Mt.isValid&&Mt.texture&&y.init(t,Mt,s.renderState)}}for(let pt=0;pt<S.length;pt++){let ct=E[pt],At=S[pt];ct!==null&&At!==void 0&&At.update(ct,K,c||a)}gt&&gt(W,K),K.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:K}),x=null}let Xt=new Dl;Xt.setAnimationLoop(kt),this.setAnimationLoop=function(W){gt=W},this.dispose=function(){}}},An=new on,Yp=new ee;function qp(i,t){function e(d,u){d.matrixAutoUpdate===!0&&d.updateMatrix(),u.value.copy(d.matrix)}function n(d,u){u.color.getRGB(d.fogColor.value,Ll(i)),u.isFog?(d.fogNear.value=u.near,d.fogFar.value=u.far):u.isFogExp2&&(d.fogDensity.value=u.density)}function s(d,u,w,S,E){u.isMeshBasicMaterial||u.isMeshLambertMaterial?r(d,u):u.isMeshToonMaterial?(r(d,u),p(d,u)):u.isMeshPhongMaterial?(r(d,u),h(d,u)):u.isMeshStandardMaterial?(r(d,u),f(d,u),u.isMeshPhysicalMaterial&&m(d,u,E)):u.isMeshMatcapMaterial?(r(d,u),x(d,u)):u.isMeshDepthMaterial?r(d,u):u.isMeshDistanceMaterial?(r(d,u),y(d,u)):u.isMeshNormalMaterial?r(d,u):u.isLineBasicMaterial?(a(d,u),u.isLineDashedMaterial&&o(d,u)):u.isPointsMaterial?l(d,u,w,S):u.isSpriteMaterial?c(d,u):u.isShadowMaterial?(d.color.value.copy(u.color),d.opacity.value=u.opacity):u.isShaderMaterial&&(u.uniformsNeedUpdate=!1)}function r(d,u){d.opacity.value=u.opacity,u.color&&d.diffuse.value.copy(u.color),u.emissive&&d.emissive.value.copy(u.emissive).multiplyScalar(u.emissiveIntensity),u.map&&(d.map.value=u.map,e(u.map,d.mapTransform)),u.alphaMap&&(d.alphaMap.value=u.alphaMap,e(u.alphaMap,d.alphaMapTransform)),u.bumpMap&&(d.bumpMap.value=u.bumpMap,e(u.bumpMap,d.bumpMapTransform),d.bumpScale.value=u.bumpScale,u.side===ve&&(d.bumpScale.value*=-1)),u.normalMap&&(d.normalMap.value=u.normalMap,e(u.normalMap,d.normalMapTransform),d.normalScale.value.copy(u.normalScale),u.side===ve&&d.normalScale.value.negate()),u.displacementMap&&(d.displacementMap.value=u.displacementMap,e(u.displacementMap,d.displacementMapTransform),d.displacementScale.value=u.displacementScale,d.displacementBias.value=u.displacementBias),u.emissiveMap&&(d.emissiveMap.value=u.emissiveMap,e(u.emissiveMap,d.emissiveMapTransform)),u.specularMap&&(d.specularMap.value=u.specularMap,e(u.specularMap,d.specularMapTransform)),u.alphaTest>0&&(d.alphaTest.value=u.alphaTest);let w=t.get(u),S=w.envMap,E=w.envMapRotation;S&&(d.envMap.value=S,An.copy(E),An.x*=-1,An.y*=-1,An.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(An.y*=-1,An.z*=-1),d.envMapRotation.value.setFromMatrix4(Yp.makeRotationFromEuler(An)),d.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,d.reflectivity.value=u.reflectivity,d.ior.value=u.ior,d.refractionRatio.value=u.refractionRatio),u.lightMap&&(d.lightMap.value=u.lightMap,d.lightMapIntensity.value=u.lightMapIntensity,e(u.lightMap,d.lightMapTransform)),u.aoMap&&(d.aoMap.value=u.aoMap,d.aoMapIntensity.value=u.aoMapIntensity,e(u.aoMap,d.aoMapTransform))}function a(d,u){d.diffuse.value.copy(u.color),d.opacity.value=u.opacity,u.map&&(d.map.value=u.map,e(u.map,d.mapTransform))}function o(d,u){d.dashSize.value=u.dashSize,d.totalSize.value=u.dashSize+u.gapSize,d.scale.value=u.scale}function l(d,u,w,S){d.diffuse.value.copy(u.color),d.opacity.value=u.opacity,d.size.value=u.size*w,d.scale.value=S*.5,u.map&&(d.map.value=u.map,e(u.map,d.uvTransform)),u.alphaMap&&(d.alphaMap.value=u.alphaMap,e(u.alphaMap,d.alphaMapTransform)),u.alphaTest>0&&(d.alphaTest.value=u.alphaTest)}function c(d,u){d.diffuse.value.copy(u.color),d.opacity.value=u.opacity,d.rotation.value=u.rotation,u.map&&(d.map.value=u.map,e(u.map,d.mapTransform)),u.alphaMap&&(d.alphaMap.value=u.alphaMap,e(u.alphaMap,d.alphaMapTransform)),u.alphaTest>0&&(d.alphaTest.value=u.alphaTest)}function h(d,u){d.specular.value.copy(u.specular),d.shininess.value=Math.max(u.shininess,1e-4)}function p(d,u){u.gradientMap&&(d.gradientMap.value=u.gradientMap)}function f(d,u){d.metalness.value=u.metalness,u.metalnessMap&&(d.metalnessMap.value=u.metalnessMap,e(u.metalnessMap,d.metalnessMapTransform)),d.roughness.value=u.roughness,u.roughnessMap&&(d.roughnessMap.value=u.roughnessMap,e(u.roughnessMap,d.roughnessMapTransform)),u.envMap&&(d.envMapIntensity.value=u.envMapIntensity)}function m(d,u,w){d.ior.value=u.ior,u.sheen>0&&(d.sheenColor.value.copy(u.sheenColor).multiplyScalar(u.sheen),d.sheenRoughness.value=u.sheenRoughness,u.sheenColorMap&&(d.sheenColorMap.value=u.sheenColorMap,e(u.sheenColorMap,d.sheenColorMapTransform)),u.sheenRoughnessMap&&(d.sheenRoughnessMap.value=u.sheenRoughnessMap,e(u.sheenRoughnessMap,d.sheenRoughnessMapTransform))),u.clearcoat>0&&(d.clearcoat.value=u.clearcoat,d.clearcoatRoughness.value=u.clearcoatRoughness,u.clearcoatMap&&(d.clearcoatMap.value=u.clearcoatMap,e(u.clearcoatMap,d.clearcoatMapTransform)),u.clearcoatRoughnessMap&&(d.clearcoatRoughnessMap.value=u.clearcoatRoughnessMap,e(u.clearcoatRoughnessMap,d.clearcoatRoughnessMapTransform)),u.clearcoatNormalMap&&(d.clearcoatNormalMap.value=u.clearcoatNormalMap,e(u.clearcoatNormalMap,d.clearcoatNormalMapTransform),d.clearcoatNormalScale.value.copy(u.clearcoatNormalScale),u.side===ve&&d.clearcoatNormalScale.value.negate())),u.dispersion>0&&(d.dispersion.value=u.dispersion),u.iridescence>0&&(d.iridescence.value=u.iridescence,d.iridescenceIOR.value=u.iridescenceIOR,d.iridescenceThicknessMinimum.value=u.iridescenceThicknessRange[0],d.iridescenceThicknessMaximum.value=u.iridescenceThicknessRange[1],u.iridescenceMap&&(d.iridescenceMap.value=u.iridescenceMap,e(u.iridescenceMap,d.iridescenceMapTransform)),u.iridescenceThicknessMap&&(d.iridescenceThicknessMap.value=u.iridescenceThicknessMap,e(u.iridescenceThicknessMap,d.iridescenceThicknessMapTransform))),u.transmission>0&&(d.transmission.value=u.transmission,d.transmissionSamplerMap.value=w.texture,d.transmissionSamplerSize.value.set(w.width,w.height),u.transmissionMap&&(d.transmissionMap.value=u.transmissionMap,e(u.transmissionMap,d.transmissionMapTransform)),d.thickness.value=u.thickness,u.thicknessMap&&(d.thicknessMap.value=u.thicknessMap,e(u.thicknessMap,d.thicknessMapTransform)),d.attenuationDistance.value=u.attenuationDistance,d.attenuationColor.value.copy(u.attenuationColor)),u.anisotropy>0&&(d.anisotropyVector.value.set(u.anisotropy*Math.cos(u.anisotropyRotation),u.anisotropy*Math.sin(u.anisotropyRotation)),u.anisotropyMap&&(d.anisotropyMap.value=u.anisotropyMap,e(u.anisotropyMap,d.anisotropyMapTransform))),d.specularIntensity.value=u.specularIntensity,d.specularColor.value.copy(u.specularColor),u.specularColorMap&&(d.specularColorMap.value=u.specularColorMap,e(u.specularColorMap,d.specularColorMapTransform)),u.specularIntensityMap&&(d.specularIntensityMap.value=u.specularIntensityMap,e(u.specularIntensityMap,d.specularIntensityMapTransform))}function x(d,u){u.matcap&&(d.matcap.value=u.matcap)}function y(d,u){let w=t.get(u).light;d.referencePosition.value.setFromMatrixPosition(w.matrixWorld),d.nearDistance.value=w.shadow.camera.near,d.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Zp(i,t,e,n){let s={},r={},a=[],o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(w,S){let E=S.program;n.uniformBlockBinding(w,E)}function c(w,S){let E=s[w.id];E===void 0&&(x(w),E=h(w),s[w.id]=E,w.addEventListener("dispose",d));let O=S.program;n.updateUBOMapping(w,O);let C=t.render.frame;r[w.id]!==C&&(f(w),r[w.id]=C)}function h(w){let S=p();w.__bindingPointIndex=S;let E=i.createBuffer(),O=w.__size,C=w.usage;return i.bindBuffer(i.UNIFORM_BUFFER,E),i.bufferData(i.UNIFORM_BUFFER,O,C),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,S,E),E}function p(){for(let w=0;w<o;w++)if(a.indexOf(w)===-1)return a.push(w),w;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(w){let S=s[w.id],E=w.uniforms,O=w.__cache;i.bindBuffer(i.UNIFORM_BUFFER,S);for(let C=0,T=E.length;C<T;C++){let F=Array.isArray(E[C])?E[C]:[E[C]];for(let tt=0,g=F.length;tt<g;tt++){let M=F[tt];if(m(M,C,tt,O)===!0){let H=M.__offset,z=Array.isArray(M.value)?M.value:[M.value],G=0;for(let J=0;J<z.length;J++){let B=z[J],j=y(B);typeof B=="number"||typeof B=="boolean"?(M.__data[0]=B,i.bufferSubData(i.UNIFORM_BUFFER,H+G,M.__data)):B.isMatrix3?(M.__data[0]=B.elements[0],M.__data[1]=B.elements[1],M.__data[2]=B.elements[2],M.__data[3]=0,M.__data[4]=B.elements[3],M.__data[5]=B.elements[4],M.__data[6]=B.elements[5],M.__data[7]=0,M.__data[8]=B.elements[6],M.__data[9]=B.elements[7],M.__data[10]=B.elements[8],M.__data[11]=0):(B.toArray(M.__data,G),G+=j.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,H,M.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function m(w,S,E,O){let C=w.value,T=S+"_"+E;if(O[T]===void 0)return typeof C=="number"||typeof C=="boolean"?O[T]=C:O[T]=C.clone(),!0;{let F=O[T];if(typeof C=="number"||typeof C=="boolean"){if(F!==C)return O[T]=C,!0}else if(F.equals(C)===!1)return F.copy(C),!0}return!1}function x(w){let S=w.uniforms,E=0,O=16;for(let T=0,F=S.length;T<F;T++){let tt=Array.isArray(S[T])?S[T]:[S[T]];for(let g=0,M=tt.length;g<M;g++){let H=tt[g],z=Array.isArray(H.value)?H.value:[H.value];for(let G=0,J=z.length;G<J;G++){let B=z[G],j=y(B),V=E%O,ot=V%j.boundary,lt=V+ot;E+=ot,lt!==0&&O-lt<j.storage&&(E+=O-lt),H.__data=new Float32Array(j.storage/Float32Array.BYTES_PER_ELEMENT),H.__offset=E,E+=j.storage}}}let C=E%O;return C>0&&(E+=O-C),w.__size=E,w.__cache={},this}function y(w){let S={boundary:0,storage:0};return typeof w=="number"||typeof w=="boolean"?(S.boundary=4,S.storage=4):w.isVector2?(S.boundary=8,S.storage=8):w.isVector3||w.isColor?(S.boundary=16,S.storage=12):w.isVector4?(S.boundary=16,S.storage=16):w.isMatrix3?(S.boundary=48,S.storage=48):w.isMatrix4?(S.boundary=64,S.storage=64):w.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",w),S}function d(w){let S=w.target;S.removeEventListener("dispose",d);let E=a.indexOf(S.__bindingPointIndex);a.splice(E,1),i.deleteBuffer(s[S.id]),delete s[S.id],delete r[S.id]}function u(){for(let w in s)i.deleteBuffer(s[w]);a=[],s={},r={}}return{bind:l,update:c,dispose:u}}var Ea=class{constructor(t={}){let{canvas:e=Kc(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:p=!1}=t;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=a;let m=new Uint32Array(4),x=new Int32Array(4),y=null,d=null,u=[],w=[];this.domElement=e,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=Xe,this.toneMapping=_n,this.toneMappingExposure=1;let S=this,E=!1,O=0,C=0,T=null,F=-1,tt=null,g=new ie,M=new ie,H=null,z=new zt(0),G=0,J=e.width,B=e.height,j=1,V=null,ot=null,lt=new ie(0,0,J,B),gt=new ie(0,0,J,B),kt=!1,Xt=new Rs,W=!1,K=!1,pt=new ee,ct=new ee,At=new L,Mt=new ie,Ut={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},qt=!1;function Nt(){return T===null?j:1}let A=n;function Se(v,P){return e.getContext(v,P)}try{let v={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:p};if("setAttribute"in e&&e.setAttribute("data-engine","three.js r169"),e.addEventListener("webglcontextlost",q,!1),e.addEventListener("webglcontextrestored",it,!1),e.addEventListener("webglcontextcreationerror",at,!1),A===null){let P="webgl2";if(A=Se(P,v),A===null)throw Se(P)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(v){throw console.error("THREE.WebGLRenderer: "+v.message),v}let Lt,Ft,bt,Kt,Tt,b,_,D,Y,Z,X,_t,nt,ht,Bt,$,ut,Et,wt,dt,Dt,Rt,Jt,R;function rt(){Lt=new hf(A),Lt.init(),Rt=new Hp(A,Lt),Ft=new sf(A,Lt,t,Rt),bt=new zp(A),Ft.reverseDepthBuffer&&bt.buffers.depth.setReversed(!0),Kt=new ff(A),Tt=new Tp,b=new Vp(A,Lt,bt,Tt,Ft,Rt,Kt),_=new af(S),D=new cf(S),Y=new vh(A),Jt=new ef(A,Y),Z=new uf(A,Y,Kt,Jt),X=new mf(A,Z,Y,Kt),wt=new pf(A,Ft,b),$=new rf(Tt),_t=new wp(S,_,D,Lt,Ft,Jt,$),nt=new qp(S,Tt),ht=new Rp,Bt=new Up(Lt),Et=new tf(S,_,D,bt,X,f,l),ut=new Fp(S,X,Ft),R=new Zp(A,Kt,Ft,bt),dt=new nf(A,Lt,Kt),Dt=new df(A,Lt,Kt),Kt.programs=_t.programs,S.capabilities=Ft,S.extensions=Lt,S.properties=Tt,S.renderLists=ht,S.shadowMap=ut,S.state=bt,S.info=Kt}rt();let k=new ba(S,A);this.xr=k,this.getContext=function(){return A},this.getContextAttributes=function(){return A.getContextAttributes()},this.forceContextLoss=function(){let v=Lt.get("WEBGL_lose_context");v&&v.loseContext()},this.forceContextRestore=function(){let v=Lt.get("WEBGL_lose_context");v&&v.restoreContext()},this.getPixelRatio=function(){return j},this.setPixelRatio=function(v){v!==void 0&&(j=v,this.setSize(J,B,!1))},this.getSize=function(v){return v.set(J,B)},this.setSize=function(v,P,U=!0){if(k.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}J=v,B=P,e.width=Math.floor(v*j),e.height=Math.floor(P*j),U===!0&&(e.style.width=v+"px",e.style.height=P+"px"),this.setViewport(0,0,v,P)},this.getDrawingBufferSize=function(v){return v.set(J*j,B*j).floor()},this.setDrawingBufferSize=function(v,P,U){J=v,B=P,j=U,e.width=Math.floor(v*U),e.height=Math.floor(P*U),this.setViewport(0,0,v,P)},this.getCurrentViewport=function(v){return v.copy(g)},this.getViewport=function(v){return v.copy(lt)},this.setViewport=function(v,P,U,N){v.isVector4?lt.set(v.x,v.y,v.z,v.w):lt.set(v,P,U,N),bt.viewport(g.copy(lt).multiplyScalar(j).round())},this.getScissor=function(v){return v.copy(gt)},this.setScissor=function(v,P,U,N){v.isVector4?gt.set(v.x,v.y,v.z,v.w):gt.set(v,P,U,N),bt.scissor(M.copy(gt).multiplyScalar(j).round())},this.getScissorTest=function(){return kt},this.setScissorTest=function(v){bt.setScissorTest(kt=v)},this.setOpaqueSort=function(v){V=v},this.setTransparentSort=function(v){ot=v},this.getClearColor=function(v){return v.copy(Et.getClearColor())},this.setClearColor=function(){Et.setClearColor.apply(Et,arguments)},this.getClearAlpha=function(){return Et.getClearAlpha()},this.setClearAlpha=function(){Et.setClearAlpha.apply(Et,arguments)},this.clear=function(v=!0,P=!0,U=!0){let N=0;if(v){let I=!1;if(T!==null){let Q=T.texture.format;I=Q===Ja||Q===Za||Q===qa}if(I){let Q=T.texture.type,st=Q===sn||Q===Nn||Q===Ci||Q===fi||Q===Xa||Q===Ya,ft=Et.getClearColor(),mt=Et.getClearAlpha(),yt=ft.r,St=ft.g,xt=ft.b;st?(m[0]=yt,m[1]=St,m[2]=xt,m[3]=mt,A.clearBufferuiv(A.COLOR,0,m)):(x[0]=yt,x[1]=St,x[2]=xt,x[3]=mt,A.clearBufferiv(A.COLOR,0,x))}else N|=A.COLOR_BUFFER_BIT}P&&(N|=A.DEPTH_BUFFER_BIT,A.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),U&&(N|=A.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),A.clear(N)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",q,!1),e.removeEventListener("webglcontextrestored",it,!1),e.removeEventListener("webglcontextcreationerror",at,!1),ht.dispose(),Bt.dispose(),Tt.dispose(),_.dispose(),D.dispose(),X.dispose(),Jt.dispose(),R.dispose(),_t.dispose(),k.dispose(),k.removeEventListener("sessionstart",so),k.removeEventListener("sessionend",ro),Mn.stop()};function q(v){v.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),E=!0}function it(){console.log("THREE.WebGLRenderer: Context Restored."),E=!1;let v=Kt.autoReset,P=ut.enabled,U=ut.autoUpdate,N=ut.needsUpdate,I=ut.type;rt(),Kt.autoReset=v,ut.enabled=P,ut.autoUpdate=U,ut.needsUpdate=N,ut.type=I}function at(v){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",v.statusMessage)}function Ot(v){let P=v.target;P.removeEventListener("dispose",Ot),se(P)}function se(v){ge(v),Tt.remove(v)}function ge(v){let P=Tt.get(v).programs;P!==void 0&&(P.forEach(function(U){_t.releaseProgram(U)}),v.isShaderMaterial&&_t.releaseShaderCache(v))}this.renderBufferDirect=function(v,P,U,N,I,Q){P===null&&(P=Ut);let st=I.isMesh&&I.matrixWorld.determinant()<0,ft=Vl(v,P,U,N,I);bt.setMaterial(N,st);let mt=U.index,yt=1;if(N.wireframe===!0){if(mt=Z.getWireframeAttribute(U),mt===void 0)return;yt=2}let St=U.drawRange,xt=U.attributes.position,Yt=St.start*yt,$t=(St.start+St.count)*yt;Q!==null&&(Yt=Math.max(Yt,Q.start*yt),$t=Math.min($t,(Q.start+Q.count)*yt)),mt!==null?(Yt=Math.max(Yt,0),$t=Math.min($t,mt.count)):xt!=null&&(Yt=Math.max(Yt,0),$t=Math.min($t,xt.count));let te=$t-Yt;if(te<0||te===1/0)return;Jt.setup(I,N,ft,U,mt);let be,Ht=dt;if(mt!==null&&(be=Y.get(mt),Ht=Dt,Ht.setIndex(be)),I.isMesh)N.wireframe===!0?(bt.setLineWidth(N.wireframeLinewidth*Nt()),Ht.setMode(A.LINES)):Ht.setMode(A.TRIANGLES);else if(I.isLine){let vt=N.linewidth;vt===void 0&&(vt=1),bt.setLineWidth(vt*Nt()),I.isLineSegments?Ht.setMode(A.LINES):I.isLineLoop?Ht.setMode(A.LINE_LOOP):Ht.setMode(A.LINE_STRIP)}else I.isPoints?Ht.setMode(A.POINTS):I.isSprite&&Ht.setMode(A.TRIANGLES);if(I.isBatchedMesh)if(I._multiDrawInstances!==null)Ht.renderMultiDrawInstances(I._multiDrawStarts,I._multiDrawCounts,I._multiDrawCount,I._multiDrawInstances);else if(Lt.get("WEBGL_multi_draw"))Ht.renderMultiDraw(I._multiDrawStarts,I._multiDrawCounts,I._multiDrawCount);else{let vt=I._multiDrawStarts,he=I._multiDrawCounts,Gt=I._multiDrawCount,De=mt?Y.get(mt).bytesPerElement:1,Gn=Tt.get(N).currentProgram.getUniforms();for(let Ee=0;Ee<Gt;Ee++)Gn.setValue(A,"_gl_DrawID",Ee),Ht.render(vt[Ee]/De,he[Ee])}else if(I.isInstancedMesh)Ht.renderInstances(Yt,te,I.count);else if(U.isInstancedBufferGeometry){let vt=U._maxInstanceCount!==void 0?U._maxInstanceCount:1/0,he=Math.min(U.instanceCount,vt);Ht.renderInstances(Yt,te,he)}else Ht.render(Yt,te)};function Vt(v,P,U){v.transparent===!0&&v.side===tn&&v.forceSinglePass===!1?(v.side=ve,v.needsUpdate=!0,Ni(v,P,U),v.side=xn,v.needsUpdate=!0,Ni(v,P,U),v.side=tn):Ni(v,P,U)}this.compile=function(v,P,U=null){U===null&&(U=v),d=Bt.get(U),d.init(P),w.push(d),U.traverseVisible(function(I){I.isLight&&I.layers.test(P.layers)&&(d.pushLight(I),I.castShadow&&d.pushShadow(I))}),v!==U&&v.traverseVisible(function(I){I.isLight&&I.layers.test(P.layers)&&(d.pushLight(I),I.castShadow&&d.pushShadow(I))}),d.setupLights();let N=new Set;return v.traverse(function(I){if(!(I.isMesh||I.isPoints||I.isLine||I.isSprite))return;let Q=I.material;if(Q)if(Array.isArray(Q))for(let st=0;st<Q.length;st++){let ft=Q[st];Vt(ft,U,I),N.add(ft)}else Vt(Q,U,I),N.add(Q)}),w.pop(),d=null,N},this.compileAsync=function(v,P,U=null){let N=this.compile(v,P,U);return new Promise(I=>{function Q(){if(N.forEach(function(st){Tt.get(st).currentProgram.isReady()&&N.delete(st)}),N.size===0){I(v);return}setTimeout(Q,10)}Lt.get("KHR_parallel_shader_compile")!==null?Q():setTimeout(Q,10)})};let _e=null;function qe(v){_e&&_e(v)}function so(){Mn.stop()}function ro(){Mn.start()}let Mn=new Dl;Mn.setAnimationLoop(qe),typeof self<"u"&&Mn.setContext(self),this.setAnimationLoop=function(v){_e=v,k.setAnimationLoop(v),v===null?Mn.stop():Mn.start()},k.addEventListener("sessionstart",so),k.addEventListener("sessionend",ro),this.render=function(v,P){if(P!==void 0&&P.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(E===!0)return;if(v.matrixWorldAutoUpdate===!0&&v.updateMatrixWorld(),P.parent===null&&P.matrixWorldAutoUpdate===!0&&P.updateMatrixWorld(),k.enabled===!0&&k.isPresenting===!0&&(k.cameraAutoUpdate===!0&&k.updateCamera(P),P=k.getCamera()),v.isScene===!0&&v.onBeforeRender(S,v,P,T),d=Bt.get(v,w.length),d.init(P),w.push(d),ct.multiplyMatrices(P.projectionMatrix,P.matrixWorldInverse),Xt.setFromProjectionMatrix(ct),K=this.localClippingEnabled,W=$.init(this.clippingPlanes,K),y=ht.get(v,u.length),y.init(),u.push(y),k.enabled===!0&&k.isPresenting===!0){let Q=S.xr.getDepthSensingMesh();Q!==null&&ks(Q,P,-1/0,S.sortObjects)}ks(v,P,0,S.sortObjects),y.finish(),S.sortObjects===!0&&y.sort(V,ot),qt=k.enabled===!1||k.isPresenting===!1||k.hasDepthSensing()===!1,qt&&Et.addToRenderList(y,v),this.info.render.frame++,W===!0&&$.beginShadows();let U=d.state.shadowsArray;ut.render(U,v,P),W===!0&&$.endShadows(),this.info.autoReset===!0&&this.info.reset();let N=y.opaque,I=y.transmissive;if(d.setupLights(),P.isArrayCamera){let Q=P.cameras;if(I.length>0)for(let st=0,ft=Q.length;st<ft;st++){let mt=Q[st];oo(N,I,v,mt)}qt&&Et.render(v);for(let st=0,ft=Q.length;st<ft;st++){let mt=Q[st];ao(y,v,mt,mt.viewport)}}else I.length>0&&oo(N,I,v,P),qt&&Et.render(v),ao(y,v,P);T!==null&&(b.updateMultisampleRenderTarget(T),b.updateRenderTargetMipmap(T)),v.isScene===!0&&v.onAfterRender(S,v,P),Jt.resetDefaultState(),F=-1,tt=null,w.pop(),w.length>0?(d=w[w.length-1],W===!0&&$.setGlobalState(S.clippingPlanes,d.state.camera)):d=null,u.pop(),u.length>0?y=u[u.length-1]:y=null};function ks(v,P,U,N){if(v.visible===!1)return;if(v.layers.test(P.layers)){if(v.isGroup)U=v.renderOrder;else if(v.isLOD)v.autoUpdate===!0&&v.update(P);else if(v.isLight)d.pushLight(v),v.castShadow&&d.pushShadow(v);else if(v.isSprite){if(!v.frustumCulled||Xt.intersectsSprite(v)){N&&Mt.setFromMatrixPosition(v.matrixWorld).applyMatrix4(ct);let st=X.update(v),ft=v.material;ft.visible&&y.push(v,st,ft,U,Mt.z,null)}}else if((v.isMesh||v.isLine||v.isPoints)&&(!v.frustumCulled||Xt.intersectsObject(v))){let st=X.update(v),ft=v.material;if(N&&(v.boundingSphere!==void 0?(v.boundingSphere===null&&v.computeBoundingSphere(),Mt.copy(v.boundingSphere.center)):(st.boundingSphere===null&&st.computeBoundingSphere(),Mt.copy(st.boundingSphere.center)),Mt.applyMatrix4(v.matrixWorld).applyMatrix4(ct)),Array.isArray(ft)){let mt=st.groups;for(let yt=0,St=mt.length;yt<St;yt++){let xt=mt[yt],Yt=ft[xt.materialIndex];Yt&&Yt.visible&&y.push(v,st,Yt,U,Mt.z,xt)}}else ft.visible&&y.push(v,st,ft,U,Mt.z,null)}}let Q=v.children;for(let st=0,ft=Q.length;st<ft;st++)ks(Q[st],P,U,N)}function ao(v,P,U,N){let I=v.opaque,Q=v.transmissive,st=v.transparent;d.setupLightsView(U),W===!0&&$.setGlobalState(S.clippingPlanes,U),N&&bt.viewport(g.copy(N)),I.length>0&&Ui(I,P,U),Q.length>0&&Ui(Q,P,U),st.length>0&&Ui(st,P,U),bt.buffers.depth.setTest(!0),bt.buffers.depth.setMask(!0),bt.buffers.color.setMask(!0),bt.setPolygonOffset(!1)}function oo(v,P,U,N){if((U.isScene===!0?U.overrideMaterial:null)!==null)return;d.state.transmissionRenderTarget[N.id]===void 0&&(d.state.transmissionRenderTarget[N.id]=new an(1,1,{generateMipmaps:!0,type:Lt.has("EXT_color_buffer_half_float")||Lt.has("EXT_color_buffer_float")?Di:sn,minFilter:Dn,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Wt.workingColorSpace}));let Q=d.state.transmissionRenderTarget[N.id],st=N.viewport||g;Q.setSize(st.z,st.w);let ft=S.getRenderTarget();S.setRenderTarget(Q),S.getClearColor(z),G=S.getClearAlpha(),G<1&&S.setClearColor(16777215,.5),S.clear(),qt&&Et.render(U);let mt=S.toneMapping;S.toneMapping=_n;let yt=N.viewport;if(N.viewport!==void 0&&(N.viewport=void 0),d.setupLightsView(N),W===!0&&$.setGlobalState(S.clippingPlanes,N),Ui(v,U,N),b.updateMultisampleRenderTarget(Q),b.updateRenderTargetMipmap(Q),Lt.has("WEBGL_multisampled_render_to_texture")===!1){let St=!1;for(let xt=0,Yt=P.length;xt<Yt;xt++){let $t=P[xt],te=$t.object,be=$t.geometry,Ht=$t.material,vt=$t.group;if(Ht.side===tn&&te.layers.test(N.layers)){let he=Ht.side;Ht.side=ve,Ht.needsUpdate=!0,lo(te,U,N,be,Ht,vt),Ht.side=he,Ht.needsUpdate=!0,St=!0}}St===!0&&(b.updateMultisampleRenderTarget(Q),b.updateRenderTargetMipmap(Q))}S.setRenderTarget(ft),S.setClearColor(z,G),yt!==void 0&&(N.viewport=yt),S.toneMapping=mt}function Ui(v,P,U){let N=P.isScene===!0?P.overrideMaterial:null;for(let I=0,Q=v.length;I<Q;I++){let st=v[I],ft=st.object,mt=st.geometry,yt=N===null?st.material:N,St=st.group;ft.layers.test(U.layers)&&lo(ft,P,U,mt,yt,St)}}function lo(v,P,U,N,I,Q){v.onBeforeRender(S,P,U,N,I,Q),v.modelViewMatrix.multiplyMatrices(U.matrixWorldInverse,v.matrixWorld),v.normalMatrix.getNormalMatrix(v.modelViewMatrix),I.onBeforeRender(S,P,U,N,v,Q),I.transparent===!0&&I.side===tn&&I.forceSinglePass===!1?(I.side=ve,I.needsUpdate=!0,S.renderBufferDirect(U,P,N,I,v,Q),I.side=xn,I.needsUpdate=!0,S.renderBufferDirect(U,P,N,I,v,Q),I.side=tn):S.renderBufferDirect(U,P,N,I,v,Q),v.onAfterRender(S,P,U,N,I,Q)}function Ni(v,P,U){P.isScene!==!0&&(P=Ut);let N=Tt.get(v),I=d.state.lights,Q=d.state.shadowsArray,st=I.state.version,ft=_t.getParameters(v,I.state,Q,P,U),mt=_t.getProgramCacheKey(ft),yt=N.programs;N.environment=v.isMeshStandardMaterial?P.environment:null,N.fog=P.fog,N.envMap=(v.isMeshStandardMaterial?D:_).get(v.envMap||N.environment),N.envMapRotation=N.environment!==null&&v.envMap===null?P.environmentRotation:v.envMapRotation,yt===void 0&&(v.addEventListener("dispose",Ot),yt=new Map,N.programs=yt);let St=yt.get(mt);if(St!==void 0){if(N.currentProgram===St&&N.lightsStateVersion===st)return ho(v,ft),St}else ft.uniforms=_t.getUniforms(v),v.onBeforeCompile(ft,S),St=_t.acquireProgram(ft,mt),yt.set(mt,St),N.uniforms=ft.uniforms;let xt=N.uniforms;return(!v.isShaderMaterial&&!v.isRawShaderMaterial||v.clipping===!0)&&(xt.clippingPlanes=$.uniform),ho(v,ft),N.needsLights=Gl(v),N.lightsStateVersion=st,N.needsLights&&(xt.ambientLightColor.value=I.state.ambient,xt.lightProbe.value=I.state.probe,xt.directionalLights.value=I.state.directional,xt.directionalLightShadows.value=I.state.directionalShadow,xt.spotLights.value=I.state.spot,xt.spotLightShadows.value=I.state.spotShadow,xt.rectAreaLights.value=I.state.rectArea,xt.ltc_1.value=I.state.rectAreaLTC1,xt.ltc_2.value=I.state.rectAreaLTC2,xt.pointLights.value=I.state.point,xt.pointLightShadows.value=I.state.pointShadow,xt.hemisphereLights.value=I.state.hemi,xt.directionalShadowMap.value=I.state.directionalShadowMap,xt.directionalShadowMatrix.value=I.state.directionalShadowMatrix,xt.spotShadowMap.value=I.state.spotShadowMap,xt.spotLightMatrix.value=I.state.spotLightMatrix,xt.spotLightMap.value=I.state.spotLightMap,xt.pointShadowMap.value=I.state.pointShadowMap,xt.pointShadowMatrix.value=I.state.pointShadowMatrix),N.currentProgram=St,N.uniformsList=null,St}function co(v){if(v.uniformsList===null){let P=v.currentProgram.getUniforms();v.uniformsList=ci.seqWithValue(P.seq,v.uniforms)}return v.uniformsList}function ho(v,P){let U=Tt.get(v);U.outputColorSpace=P.outputColorSpace,U.batching=P.batching,U.batchingColor=P.batchingColor,U.instancing=P.instancing,U.instancingColor=P.instancingColor,U.instancingMorph=P.instancingMorph,U.skinning=P.skinning,U.morphTargets=P.morphTargets,U.morphNormals=P.morphNormals,U.morphColors=P.morphColors,U.morphTargetsCount=P.morphTargetsCount,U.numClippingPlanes=P.numClippingPlanes,U.numIntersection=P.numClipIntersection,U.vertexAlphas=P.vertexAlphas,U.vertexTangents=P.vertexTangents,U.toneMapping=P.toneMapping}function Vl(v,P,U,N,I){P.isScene!==!0&&(P=Ut),b.resetTextureUnits();let Q=P.fog,st=N.isMeshStandardMaterial?P.environment:null,ft=T===null?S.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:yn,mt=(N.isMeshStandardMaterial?D:_).get(N.envMap||st),yt=N.vertexColors===!0&&!!U.attributes.color&&U.attributes.color.itemSize===4,St=!!U.attributes.tangent&&(!!N.normalMap||N.anisotropy>0),xt=!!U.morphAttributes.position,Yt=!!U.morphAttributes.normal,$t=!!U.morphAttributes.color,te=_n;N.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(te=S.toneMapping);let be=U.morphAttributes.position||U.morphAttributes.normal||U.morphAttributes.color,Ht=be!==void 0?be.length:0,vt=Tt.get(N),he=d.state.lights;if(W===!0&&(K===!0||v!==tt)){let Re=v===tt&&N.id===F;$.setState(N,v,Re)}let Gt=!1;N.version===vt.__version?(vt.needsLights&&vt.lightsStateVersion!==he.state.version||vt.outputColorSpace!==ft||I.isBatchedMesh&&vt.batching===!1||!I.isBatchedMesh&&vt.batching===!0||I.isBatchedMesh&&vt.batchingColor===!0&&I.colorTexture===null||I.isBatchedMesh&&vt.batchingColor===!1&&I.colorTexture!==null||I.isInstancedMesh&&vt.instancing===!1||!I.isInstancedMesh&&vt.instancing===!0||I.isSkinnedMesh&&vt.skinning===!1||!I.isSkinnedMesh&&vt.skinning===!0||I.isInstancedMesh&&vt.instancingColor===!0&&I.instanceColor===null||I.isInstancedMesh&&vt.instancingColor===!1&&I.instanceColor!==null||I.isInstancedMesh&&vt.instancingMorph===!0&&I.morphTexture===null||I.isInstancedMesh&&vt.instancingMorph===!1&&I.morphTexture!==null||vt.envMap!==mt||N.fog===!0&&vt.fog!==Q||vt.numClippingPlanes!==void 0&&(vt.numClippingPlanes!==$.numPlanes||vt.numIntersection!==$.numIntersection)||vt.vertexAlphas!==yt||vt.vertexTangents!==St||vt.morphTargets!==xt||vt.morphNormals!==Yt||vt.morphColors!==$t||vt.toneMapping!==te||vt.morphTargetsCount!==Ht)&&(Gt=!0):(Gt=!0,vt.__version=N.version);let De=vt.currentProgram;Gt===!0&&(De=Ni(N,P,I));let Gn=!1,Ee=!1,Vs=!1,ne=De.getUniforms(),ln=vt.uniforms;if(bt.useProgram(De.program)&&(Gn=!0,Ee=!0,Vs=!0),N.id!==F&&(F=N.id,Ee=!0),Gn||tt!==v){Ft.reverseDepthBuffer?(pt.copy(v.projectionMatrix),jc(pt),Qc(pt),ne.setValue(A,"projectionMatrix",pt)):ne.setValue(A,"projectionMatrix",v.projectionMatrix),ne.setValue(A,"viewMatrix",v.matrixWorldInverse);let Re=ne.map.cameraPosition;Re!==void 0&&Re.setValue(A,At.setFromMatrixPosition(v.matrixWorld)),Ft.logarithmicDepthBuffer&&ne.setValue(A,"logDepthBufFC",2/(Math.log(v.far+1)/Math.LN2)),(N.isMeshPhongMaterial||N.isMeshToonMaterial||N.isMeshLambertMaterial||N.isMeshBasicMaterial||N.isMeshStandardMaterial||N.isShaderMaterial)&&ne.setValue(A,"isOrthographic",v.isOrthographicCamera===!0),tt!==v&&(tt=v,Ee=!0,Vs=!0)}if(I.isSkinnedMesh){ne.setOptional(A,I,"bindMatrix"),ne.setOptional(A,I,"bindMatrixInverse");let Re=I.skeleton;Re&&(Re.boneTexture===null&&Re.computeBoneTexture(),ne.setValue(A,"boneTexture",Re.boneTexture,b))}I.isBatchedMesh&&(ne.setOptional(A,I,"batchingTexture"),ne.setValue(A,"batchingTexture",I._matricesTexture,b),ne.setOptional(A,I,"batchingIdTexture"),ne.setValue(A,"batchingIdTexture",I._indirectTexture,b),ne.setOptional(A,I,"batchingColorTexture"),I._colorsTexture!==null&&ne.setValue(A,"batchingColorTexture",I._colorsTexture,b));let Hs=U.morphAttributes;if((Hs.position!==void 0||Hs.normal!==void 0||Hs.color!==void 0)&&wt.update(I,U,De),(Ee||vt.receiveShadow!==I.receiveShadow)&&(vt.receiveShadow=I.receiveShadow,ne.setValue(A,"receiveShadow",I.receiveShadow)),N.isMeshGouraudMaterial&&N.envMap!==null&&(ln.envMap.value=mt,ln.flipEnvMap.value=mt.isCubeTexture&&mt.isRenderTargetTexture===!1?-1:1),N.isMeshStandardMaterial&&N.envMap===null&&P.environment!==null&&(ln.envMapIntensity.value=P.environmentIntensity),Ee&&(ne.setValue(A,"toneMappingExposure",S.toneMappingExposure),vt.needsLights&&Hl(ln,Vs),Q&&N.fog===!0&&nt.refreshFogUniforms(ln,Q),nt.refreshMaterialUniforms(ln,N,j,B,d.state.transmissionRenderTarget[v.id]),ci.upload(A,co(vt),ln,b)),N.isShaderMaterial&&N.uniformsNeedUpdate===!0&&(ci.upload(A,co(vt),ln,b),N.uniformsNeedUpdate=!1),N.isSpriteMaterial&&ne.setValue(A,"center",I.center),ne.setValue(A,"modelViewMatrix",I.modelViewMatrix),ne.setValue(A,"normalMatrix",I.normalMatrix),ne.setValue(A,"modelMatrix",I.matrixWorld),N.isShaderMaterial||N.isRawShaderMaterial){let Re=N.uniformsGroups;for(let Gs=0,Wl=Re.length;Gs<Wl;Gs++){let uo=Re[Gs];R.update(uo,De),R.bind(uo,De)}}return De}function Hl(v,P){v.ambientLightColor.needsUpdate=P,v.lightProbe.needsUpdate=P,v.directionalLights.needsUpdate=P,v.directionalLightShadows.needsUpdate=P,v.pointLights.needsUpdate=P,v.pointLightShadows.needsUpdate=P,v.spotLights.needsUpdate=P,v.spotLightShadows.needsUpdate=P,v.rectAreaLights.needsUpdate=P,v.hemisphereLights.needsUpdate=P}function Gl(v){return v.isMeshLambertMaterial||v.isMeshToonMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isShadowMaterial||v.isShaderMaterial&&v.lights===!0}this.getActiveCubeFace=function(){return O},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(v,P,U){Tt.get(v.texture).__webglTexture=P,Tt.get(v.depthTexture).__webglTexture=U;let N=Tt.get(v);N.__hasExternalTextures=!0,N.__autoAllocateDepthBuffer=U===void 0,N.__autoAllocateDepthBuffer||Lt.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),N.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(v,P){let U=Tt.get(v);U.__webglFramebuffer=P,U.__useDefaultFramebuffer=P===void 0},this.setRenderTarget=function(v,P=0,U=0){T=v,O=P,C=U;let N=!0,I=null,Q=!1,st=!1;if(v){let mt=Tt.get(v);if(mt.__useDefaultFramebuffer!==void 0)bt.bindFramebuffer(A.FRAMEBUFFER,null),N=!1;else if(mt.__webglFramebuffer===void 0)b.setupRenderTarget(v);else if(mt.__hasExternalTextures)b.rebindTextures(v,Tt.get(v.texture).__webglTexture,Tt.get(v.depthTexture).__webglTexture);else if(v.depthBuffer){let xt=v.depthTexture;if(mt.__boundDepthTexture!==xt){if(xt!==null&&Tt.has(xt)&&(v.width!==xt.image.width||v.height!==xt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");b.setupDepthRenderbuffer(v)}}let yt=v.texture;(yt.isData3DTexture||yt.isDataArrayTexture||yt.isCompressedArrayTexture)&&(st=!0);let St=Tt.get(v).__webglFramebuffer;v.isWebGLCubeRenderTarget?(Array.isArray(St[P])?I=St[P][U]:I=St[P],Q=!0):v.samples>0&&b.useMultisampledRTT(v)===!1?I=Tt.get(v).__webglMultisampledFramebuffer:Array.isArray(St)?I=St[U]:I=St,g.copy(v.viewport),M.copy(v.scissor),H=v.scissorTest}else g.copy(lt).multiplyScalar(j).floor(),M.copy(gt).multiplyScalar(j).floor(),H=kt;if(bt.bindFramebuffer(A.FRAMEBUFFER,I)&&N&&bt.drawBuffers(v,I),bt.viewport(g),bt.scissor(M),bt.setScissorTest(H),Q){let mt=Tt.get(v.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_CUBE_MAP_POSITIVE_X+P,mt.__webglTexture,U)}else if(st){let mt=Tt.get(v.texture),yt=P||0;A.framebufferTextureLayer(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,mt.__webglTexture,U||0,yt)}F=-1},this.readRenderTargetPixels=function(v,P,U,N,I,Q,st){if(!(v&&v.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ft=Tt.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&st!==void 0&&(ft=ft[st]),ft){bt.bindFramebuffer(A.FRAMEBUFFER,ft);try{let mt=v.texture,yt=mt.format,St=mt.type;if(!Ft.textureFormatReadable(yt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ft.textureTypeReadable(St)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}P>=0&&P<=v.width-N&&U>=0&&U<=v.height-I&&A.readPixels(P,U,N,I,Rt.convert(yt),Rt.convert(St),Q)}finally{let mt=T!==null?Tt.get(T).__webglFramebuffer:null;bt.bindFramebuffer(A.FRAMEBUFFER,mt)}}},this.readRenderTargetPixelsAsync=async function(v,P,U,N,I,Q,st){if(!(v&&v.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ft=Tt.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&st!==void 0&&(ft=ft[st]),ft){let mt=v.texture,yt=mt.format,St=mt.type;if(!Ft.textureFormatReadable(yt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ft.textureTypeReadable(St))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(P>=0&&P<=v.width-N&&U>=0&&U<=v.height-I){bt.bindFramebuffer(A.FRAMEBUFFER,ft);let xt=A.createBuffer();A.bindBuffer(A.PIXEL_PACK_BUFFER,xt),A.bufferData(A.PIXEL_PACK_BUFFER,Q.byteLength,A.STREAM_READ),A.readPixels(P,U,N,I,Rt.convert(yt),Rt.convert(St),0);let Yt=T!==null?Tt.get(T).__webglFramebuffer:null;bt.bindFramebuffer(A.FRAMEBUFFER,Yt);let $t=A.fenceSync(A.SYNC_GPU_COMMANDS_COMPLETE,0);return A.flush(),await $c(A,$t,4),A.bindBuffer(A.PIXEL_PACK_BUFFER,xt),A.getBufferSubData(A.PIXEL_PACK_BUFFER,0,Q),A.deleteBuffer(xt),A.deleteSync($t),Q}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(v,P=null,U=0){v.isTexture!==!0&&(fs("WebGLRenderer: copyFramebufferToTexture function signature has changed."),P=arguments[0]||null,v=arguments[1]);let N=Math.pow(2,-U),I=Math.floor(v.image.width*N),Q=Math.floor(v.image.height*N),st=P!==null?P.x:0,ft=P!==null?P.y:0;b.setTexture2D(v,0),A.copyTexSubImage2D(A.TEXTURE_2D,U,0,0,st,ft,I,Q),bt.unbindTexture()},this.copyTextureToTexture=function(v,P,U=null,N=null,I=0){v.isTexture!==!0&&(fs("WebGLRenderer: copyTextureToTexture function signature has changed."),N=arguments[0]||null,v=arguments[1],P=arguments[2],I=arguments[3]||0,U=null);let Q,st,ft,mt,yt,St;U!==null?(Q=U.max.x-U.min.x,st=U.max.y-U.min.y,ft=U.min.x,mt=U.min.y):(Q=v.image.width,st=v.image.height,ft=0,mt=0),N!==null?(yt=N.x,St=N.y):(yt=0,St=0);let xt=Rt.convert(P.format),Yt=Rt.convert(P.type);b.setTexture2D(P,0),A.pixelStorei(A.UNPACK_FLIP_Y_WEBGL,P.flipY),A.pixelStorei(A.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),A.pixelStorei(A.UNPACK_ALIGNMENT,P.unpackAlignment);let $t=A.getParameter(A.UNPACK_ROW_LENGTH),te=A.getParameter(A.UNPACK_IMAGE_HEIGHT),be=A.getParameter(A.UNPACK_SKIP_PIXELS),Ht=A.getParameter(A.UNPACK_SKIP_ROWS),vt=A.getParameter(A.UNPACK_SKIP_IMAGES),he=v.isCompressedTexture?v.mipmaps[I]:v.image;A.pixelStorei(A.UNPACK_ROW_LENGTH,he.width),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,he.height),A.pixelStorei(A.UNPACK_SKIP_PIXELS,ft),A.pixelStorei(A.UNPACK_SKIP_ROWS,mt),v.isDataTexture?A.texSubImage2D(A.TEXTURE_2D,I,yt,St,Q,st,xt,Yt,he.data):v.isCompressedTexture?A.compressedTexSubImage2D(A.TEXTURE_2D,I,yt,St,he.width,he.height,xt,he.data):A.texSubImage2D(A.TEXTURE_2D,I,yt,St,Q,st,xt,Yt,he),A.pixelStorei(A.UNPACK_ROW_LENGTH,$t),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,te),A.pixelStorei(A.UNPACK_SKIP_PIXELS,be),A.pixelStorei(A.UNPACK_SKIP_ROWS,Ht),A.pixelStorei(A.UNPACK_SKIP_IMAGES,vt),I===0&&P.generateMipmaps&&A.generateMipmap(A.TEXTURE_2D),bt.unbindTexture()},this.copyTextureToTexture3D=function(v,P,U=null,N=null,I=0){v.isTexture!==!0&&(fs("WebGLRenderer: copyTextureToTexture3D function signature has changed."),U=arguments[0]||null,N=arguments[1]||null,v=arguments[2],P=arguments[3],I=arguments[4]||0);let Q,st,ft,mt,yt,St,xt,Yt,$t,te=v.isCompressedTexture?v.mipmaps[I]:v.image;U!==null?(Q=U.max.x-U.min.x,st=U.max.y-U.min.y,ft=U.max.z-U.min.z,mt=U.min.x,yt=U.min.y,St=U.min.z):(Q=te.width,st=te.height,ft=te.depth,mt=0,yt=0,St=0),N!==null?(xt=N.x,Yt=N.y,$t=N.z):(xt=0,Yt=0,$t=0);let be=Rt.convert(P.format),Ht=Rt.convert(P.type),vt;if(P.isData3DTexture)b.setTexture3D(P,0),vt=A.TEXTURE_3D;else if(P.isDataArrayTexture||P.isCompressedArrayTexture)b.setTexture2DArray(P,0),vt=A.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}A.pixelStorei(A.UNPACK_FLIP_Y_WEBGL,P.flipY),A.pixelStorei(A.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),A.pixelStorei(A.UNPACK_ALIGNMENT,P.unpackAlignment);let he=A.getParameter(A.UNPACK_ROW_LENGTH),Gt=A.getParameter(A.UNPACK_IMAGE_HEIGHT),De=A.getParameter(A.UNPACK_SKIP_PIXELS),Gn=A.getParameter(A.UNPACK_SKIP_ROWS),Ee=A.getParameter(A.UNPACK_SKIP_IMAGES);A.pixelStorei(A.UNPACK_ROW_LENGTH,te.width),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,te.height),A.pixelStorei(A.UNPACK_SKIP_PIXELS,mt),A.pixelStorei(A.UNPACK_SKIP_ROWS,yt),A.pixelStorei(A.UNPACK_SKIP_IMAGES,St),v.isDataTexture||v.isData3DTexture?A.texSubImage3D(vt,I,xt,Yt,$t,Q,st,ft,be,Ht,te.data):P.isCompressedArrayTexture?A.compressedTexSubImage3D(vt,I,xt,Yt,$t,Q,st,ft,be,te.data):A.texSubImage3D(vt,I,xt,Yt,$t,Q,st,ft,be,Ht,te),A.pixelStorei(A.UNPACK_ROW_LENGTH,he),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,Gt),A.pixelStorei(A.UNPACK_SKIP_PIXELS,De),A.pixelStorei(A.UNPACK_SKIP_ROWS,Gn),A.pixelStorei(A.UNPACK_SKIP_IMAGES,Ee),I===0&&P.generateMipmaps&&A.generateMipmap(vt),bt.unbindTexture()},this.initRenderTarget=function(v){Tt.get(v).__webglFramebuffer===void 0&&b.setupRenderTarget(v)},this.initTexture=function(v){v.isCubeTexture?b.setTextureCube(v,0):v.isData3DTexture?b.setTexture3D(v,0):v.isDataArrayTexture||v.isCompressedArrayTexture?b.setTexture2DArray(v,0):b.setTexture2D(v,0),bt.unbindTexture()},this.resetState=function(){O=0,C=0,T=null,bt.reset(),Jt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return nn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=t===Ka?"display-p3":"srgb",e.unpackColorSpace=Wt.workingColorSpace===Fs?"display-p3":"srgb"}};var wa=class extends Ae{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 on,this.environmentIntensity=1,this.environmentRotation=new on,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}};var Ta=class extends ye{constructor(t,e,n,s=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}};var Aa=class extends vn{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new zt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},Ls=new L,Ds=new L,cl=new ee,Ei=new Bn,is=new Fn,vr=new L,hl=new L,Ra=class extends Ae{constructor(t=new He,e=new Aa){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let s=1,r=e.count;s<r;s++)Ls.fromBufferAttribute(e,s-1),Ds.fromBufferAttribute(e,s),n[s]=n[s-1],n[s]+=Ls.distanceTo(Ds);t.setAttribute("lineDistance",new ke(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,s=this.matrixWorld,r=t.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),is.copy(n.boundingSphere),is.applyMatrix4(s),is.radius+=r,t.ray.intersectsSphere(is)===!1)return;cl.copy(s).invert(),Ei.copy(t.ray).applyMatrix4(cl);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=n.index,f=n.attributes.position;if(h!==null){let m=Math.max(0,a.start),x=Math.min(h.count,a.start+a.count);for(let y=m,d=x-1;y<d;y+=c){let u=h.getX(y),w=h.getX(y+1),S=ss(this,t,Ei,l,u,w);S&&e.push(S)}if(this.isLineLoop){let y=h.getX(x-1),d=h.getX(m),u=ss(this,t,Ei,l,y,d);u&&e.push(u)}}else{let m=Math.max(0,a.start),x=Math.min(f.count,a.start+a.count);for(let y=m,d=x-1;y<d;y+=c){let u=ss(this,t,Ei,l,y,y+1);u&&e.push(u)}if(this.isLineLoop){let y=ss(this,t,Ei,l,x-1,m);y&&e.push(y)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}};function ss(i,t,e,n,s,r){let a=i.geometry.attributes.position;if(Ls.fromBufferAttribute(a,s),Ds.fromBufferAttribute(a,r),e.distanceSqToSegment(Ls,Ds,vr,hl)>n)return;vr.applyMatrix4(i.matrixWorld);let l=t.ray.origin.distanceTo(vr);if(!(l<t.near||l>t.far))return{distance:l,point:hl.clone().applyMatrix4(i.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:i}}var ul=new L,dl=new L,Ca=class extends Ra{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let s=0,r=e.count;s<r;s+=2)ul.fromBufferAttribute(e,s),dl.fromBufferAttribute(e,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+ul.distanceTo(dl);t.setAttribute("lineDistance",new ke(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Pa=class extends vn{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new zt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}},fl=new ee,Ia=new Bn,rs=new Fn,as=new L,La=class extends Ae{constructor(t=new He,e=new Pa){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){let n=this.geometry,s=this.matrixWorld,r=t.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),rs.copy(n.boundingSphere),rs.applyMatrix4(s),rs.radius+=r,t.ray.intersectsSphere(rs)===!1)return;fl.copy(s).invert(),Ia.copy(t.ray).applyMatrix4(fl);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,p=n.attributes.position;if(c!==null){let f=Math.max(0,a.start),m=Math.min(c.count,a.start+a.count);for(let x=f,y=m;x<y;x++){let d=c.getX(x);as.fromBufferAttribute(p,d),pl(as,d,l,s,t,e,this)}}else{let f=Math.max(0,a.start),m=Math.min(p.count,a.start+a.count);for(let x=f,y=m;x<y;x++)as.fromBufferAttribute(p,x),pl(as,x,l,s,t,e,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}};function pl(i,t,e,n,s,r,a){let o=Ia.distanceSqToPoint(i);if(o<e){let l=new L;Ia.closestPointToPoint(i,l),l.applyMatrix4(n);let c=s.ray.origin.distanceTo(l);if(c<s.near||c>s.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}function os(i,t,e){return!i||!e&&i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function Jp(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}var gi=class{constructor(t,e,n,s){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,s=e[n],r=e[n-1];n:{t:{let a;e:{i:if(!(t<s)){for(let o=n+2;;){if(s===void 0){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=s,s=e[++n],t<s)break t}a=e.length;break e}if(!(t>=r)){let o=e[1];t<o&&(n=2,r=o);for(let l=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(s=r,r=e[--n-1],t>=r)break t}a=n,n=0;break e}break n}for(;n<a;){let o=n+a>>>1;t<e[o]?a=o:n=o+1}if(s=e[n],r=e[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,t,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=t*s;for(let a=0;a!==s;++a)e[a]=n[r+a];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Da=class extends gi{constructor(t,e,n,s){super(t,e,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:go,endingEnd:go}}intervalChanged_(t,e,n){let s=this.parameterPositions,r=t-2,a=t+1,o=s[r],l=s[a];if(o===void 0)switch(this.getSettings_().endingStart){case _o:r=t,o=2*e-n;break;case xo:r=s.length-2,o=e+s[r]-s[r+1];break;default:r=t,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case _o:a=t,l=2*n-e;break;case xo:a=1,l=n+s[1]-s[0];break;default:a=t-1,l=e}let c=(n-e)*.5,h=this.valueSize;this._weightPrev=c/(e-o),this._weightNext=c/(l-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=t*o,c=l-o,h=this._offsetPrev,p=this._offsetNext,f=this._weightPrev,m=this._weightNext,x=(n-e)/(s-e),y=x*x,d=y*x,u=-f*d+2*f*y-f*x,w=(1+f)*d+(-1.5-2*f)*y+(-.5+f)*x+1,S=(-1-m)*d+(1.5+m)*y+.5*x,E=m*d-m*y;for(let O=0;O!==o;++O)r[O]=u*a[h+O]+w*a[c+O]+S*a[l+O]+E*a[p+O];return r}},Ua=class extends gi{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=t*o,c=l-o,h=(n-e)/(s-e),p=1-h;for(let f=0;f!==o;++f)r[f]=a[c+f]*p+a[l+f]*h;return r}},Na=class extends gi{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t){return this.copySampleValue_(t-1)}},We=class{constructor(t,e,n,s){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=os(e,this.TimeBufferType),this.values=os(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:os(t.times,Array),values:os(t.values,Array)};let s=t.getInterpolation();s!==t.DefaultInterpolation&&(n.interpolation=s)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new Na(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Ua(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Da(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case ps:e=this.InterpolantFactoryMethodDiscrete;break;case aa:e=this.InterpolantFactoryMethodLinear;break;case Xs:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ps;case this.InterpolantFactoryMethodLinear:return aa;case this.InterpolantFactoryMethodSmooth:return Xs}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,s=e.length;n!==s;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,s=e.length;n!==s;++n)e[n]*=t}return this}trim(t,e){let n=this.times,s=n.length,r=0,a=s-1;for(;r!==s&&n[r]<t;)++r;for(;a!==-1&&n[a]>e;)--a;if(++a,r!==0||a!==s){r>=a&&(a=Math.max(a,1),r=a-1);let o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,s=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==r;o++){let l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),t=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),t=!1;break}a=l}if(s!==void 0&&Jp(s))for(let o=0,l=s.length;o!==l;++o){let c=s[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===Xs,r=t.length-1,a=1;for(let o=1;o<r;++o){let l=!1,c=t[o],h=t[o+1];if(c!==h&&(o!==1||c!==t[0]))if(s)l=!0;else{let p=o*n,f=p-n,m=p+n;for(let x=0;x!==n;++x){let y=e[p+x];if(y!==e[f+x]||y!==e[m+x]){l=!0;break}}}if(l){if(o!==a){t[a]=t[o];let p=o*n,f=a*n;for(let m=0;m!==n;++m)e[f+m]=e[p+m]}++a}}if(r>0){t[a]=t[r];for(let o=r*n,l=a*n,c=0;c!==n;++c)e[l+c]=e[o+c];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,s=new n(this.name,t,e);return s.createInterpolant=this.createInterpolant,s}};We.prototype.TimeBufferType=Float32Array;We.prototype.ValueBufferType=Float32Array;We.prototype.DefaultInterpolation=aa;var zn=class extends We{constructor(t,e,n){super(t,e,n)}};zn.prototype.ValueTypeName="bool";zn.prototype.ValueBufferType=Array;zn.prototype.DefaultInterpolation=ps;zn.prototype.InterpolantFactoryMethodLinear=void 0;zn.prototype.InterpolantFactoryMethodSmooth=void 0;var Oa=class extends We{};Oa.prototype.ValueTypeName="color";var Fa=class extends We{};Fa.prototype.ValueTypeName="number";var Ba=class extends gi{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-e)/(s-e),c=t*o;for(let h=c+o;c!==h;c+=4)Ve.slerpFlat(r,0,a,c-o,a,c,l);return r}},Us=class extends We{InterpolantFactoryMethodLinear(t){return new Ba(this.times,this.values,this.getValueSize(),t)}};Us.prototype.ValueTypeName="quaternion";Us.prototype.InterpolantFactoryMethodSmooth=void 0;var kn=class extends We{constructor(t,e,n){super(t,e,n)}};kn.prototype.ValueTypeName="string";kn.prototype.ValueBufferType=Array;kn.prototype.DefaultInterpolation=ps;kn.prototype.InterpolantFactoryMethodLinear=void 0;kn.prototype.InterpolantFactoryMethodSmooth=void 0;var za=class extends We{};za.prototype.ValueTypeName="vector";var ka=class{constructor(t,e,n){let s=this,r=!1,a=0,o=0,l,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(h){o++,r===!1&&s.onStart!==void 0&&s.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,s.onProgress!==void 0&&s.onProgress(h,a,o),a===o&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,p){return c.push(h,p),this},this.removeHandler=function(h){let p=c.indexOf(h);return p!==-1&&c.splice(p,2),this},this.getHandler=function(h){for(let p=0,f=c.length;p<f;p+=2){let m=c[p],x=c[p+1];if(m.global&&(m.lastIndex=0),m.test(h))return x}return null}}},Kp=new ka,Va=class{constructor(t){this.manager=t!==void 0?t:Kp,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(s,r){n.load(t,s,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};Va.DEFAULT_MATERIAL_NAME="__DEFAULT";var Ha=class extends He{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}};var Qa="\\[\\]\\.:\\/",$p=new RegExp("["+Qa+"]","g"),to="[^"+Qa+"]",jp="[^"+Qa.replace("\\.","")+"]",Qp=/((?:WC+[\/:])*)/.source.replace("WC",to),tm=/(WCOD+)?/.source.replace("WCOD",jp),em=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",to),nm=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",to),im=new RegExp("^"+Qp+tm+em+nm+"$"),sm=["material","materials","bones","map"],Ga=class{constructor(t,e,n){let s=n||Qt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,s)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},Qt=class i{constructor(t,e,n){this.path=e,this.parsedPath=n||i.parseTrackName(e),this.node=i.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new i.Composite(t,e,n):new i(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace($p,"")}static parseTrackName(t){let e=im.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);sm.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(r){for(let a=0;a<r.length;a++){let o=r[a];if(o.name===e||o.uuid===e)return o;let l=n(o.children);if(l)return l}return null},s=n(t.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)t[e++]=n[s]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,s=e.propertyName,r=e.propertyIndex;if(t||(t=i.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===c){c=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(c!==void 0){if(t[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[c]}}let a=t[s];if(a===void 0){let c=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+s+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[r]!==void 0&&(r=t.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=s;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Qt.Composite=Ga;Qt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Qt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Qt.prototype.GetterByBindingType=[Qt.prototype._getValue_direct,Qt.prototype._getValue_array,Qt.prototype._getValue_arrayElement,Qt.prototype._getValue_toArray];Qt.prototype.SetterByBindingTypeAndVersioning=[[Qt.prototype._setValue_direct,Qt.prototype._setValue_direct_setNeedsUpdate,Qt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Qt.prototype._setValue_array,Qt.prototype._setValue_array_setNeedsUpdate,Qt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Qt.prototype._setValue_arrayElement,Qt.prototype._setValue_arrayElement_setNeedsUpdate,Qt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Qt.prototype._setValue_fromArray,Qt.prototype._setValue_fromArray_setNeedsUpdate,Qt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var xm=new Float32Array(1);var Li=class{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(fe(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var Ns=class extends rn{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"169"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="169");var Bl={type:"change"},io={type:"start"},kl={type:"end"},zs=new Bn,zl=new Fe,rm=Math.cos(70*Cl.DEG2RAD),le=new L,Me=2*Math.PI,Zt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},eo=1e-6,no=class extends Ns{constructor(t,e=null){super(t,e),this.state=Zt.NONE,this.enabled=!0,this.target=new L,this.cursor=new L,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Vn.ROTATE,MIDDLE:Vn.DOLLY,RIGHT:Vn.PAN},this.touches={ONE:Hn.ROTATE,TWO:Hn.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new L,this._lastQuaternion=new Ve,this._lastTargetPosition=new L,this._quat=new Ve().setFromUnitVectors(t.up,new L(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Li,this._sphericalDelta=new Li,this._scale=1,this._panOffset=new L,this._rotateStart=new It,this._rotateEnd=new It,this._rotateDelta=new It,this._panStart=new It,this._panEnd=new It,this._panDelta=new It,this._dollyStart=new It,this._dollyEnd=new It,this._dollyDelta=new It,this._dollyDirection=new L,this._mouse=new It,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=om.bind(this),this._onPointerDown=am.bind(this),this._onPointerUp=lm.bind(this),this._onContextMenu=mm.bind(this),this._onMouseWheel=um.bind(this),this._onKeyDown=dm.bind(this),this._onTouchStart=fm.bind(this),this._onTouchMove=pm.bind(this),this._onMouseDown=cm.bind(this),this._onMouseMove=hm.bind(this),this._interceptControlDown=gm.bind(this),this._interceptControlUp=_m.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Bl),this.update(),this.state=Zt.NONE}update(t=null){let e=this.object.position;le.copy(e).sub(this.target),le.applyQuaternion(this._quat),this._spherical.setFromVector3(le),this.autoRotate&&this.state===Zt.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=Me:n>Math.PI&&(n-=Me),s<-Math.PI?s+=Me:s>Math.PI&&(s-=Me),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(le.setFromSpherical(this._spherical),le.applyQuaternion(this._quatInverse),e.copy(this.target).add(le),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){let o=le.length();a=this._clampDistance(o*this._scale);let l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){let o=new L(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;let c=new L(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=le.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(zs.origin.copy(this.object.position),zs.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(zs.direction))<rm?this.object.lookAt(this.target):(zl.setFromNormalAndCoplanarPoint(this.object.up,this.target),zs.intersectPlane(zl,this.target))))}else if(this.object.isOrthographicCamera){let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>eo||8*(1-this._lastQuaternion.dot(this.object.quaternion))>eo||this._lastTargetPosition.distanceToSquared(this.target)>eo?(this.dispatchEvent(Bl),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?Me/60*this.autoRotateSpeed*t:Me/60/60*this.autoRotateSpeed}_getZoomScale(t){let e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){le.setFromMatrixColumn(e,0),le.multiplyScalar(-t),this._panOffset.add(le)}_panUp(t,e){this.screenSpacePanning===!0?le.setFromMatrixColumn(e,1):(le.setFromMatrixColumn(e,0),le.crossVectors(this.object.up,le)),le.multiplyScalar(t),this._panOffset.add(le)}_pan(t,e){let n=this.domElement;if(this.object.isPerspectiveCamera){let s=this.object.position;le.copy(s).sub(this.target);let r=le.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/n.clientHeight,this.object.matrix),this._panUp(2*e*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),s=t-n.left,r=e-n.top,a=n.width,o=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let e=this.domElement;this._rotateLeft(Me*this._rotateDelta.x/e.clientHeight),this._rotateUp(Me*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(Me*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(-Me*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(Me*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(-Me*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panStart.set(n,s)}}_handleTouchStartDolly(t){let e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{let n=this._getSecondPointerPosition(t),s=.5*(t.pageX+n.x),r=.5*(t.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let e=this.domElement;this._rotateLeft(Me*this._rotateDelta.x/e.clientHeight),this._rotateUp(Me*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){let e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(t.pageX+e.x)*.5,o=(t.pageY+e.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new It,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){let e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){let e=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function am(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function om(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function lm(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(kl),this.state=Zt.NONE;break;case 1:let t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function cm(i){let t;switch(i.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Vn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=Zt.DOLLY;break;case Vn.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Zt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Zt.ROTATE}break;case Vn.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Zt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Zt.PAN}break;default:this.state=Zt.NONE}this.state!==Zt.NONE&&this.dispatchEvent(io)}function hm(i){switch(this.state){case Zt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case Zt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case Zt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function um(i){this.enabled===!1||this.enableZoom===!1||this.state!==Zt.NONE||(i.preventDefault(),this.dispatchEvent(io),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(kl))}function dm(i){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(i)}function fm(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case Hn.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=Zt.TOUCH_ROTATE;break;case Hn.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=Zt.TOUCH_PAN;break;default:this.state=Zt.NONE}break;case 2:switch(this.touches.TWO){case Hn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=Zt.TOUCH_DOLLY_PAN;break;case Hn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=Zt.TOUCH_DOLLY_ROTATE;break;default:this.state=Zt.NONE}break;default:this.state=Zt.NONE}this.state!==Zt.NONE&&this.dispatchEvent(io)}function pm(i){switch(this._trackPointer(i),this.state){case Zt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case Zt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case Zt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case Zt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=Zt.NONE}}function mm(i){this.enabled!==!1&&i.preventDefault()}function gm(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function _m(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}export{yr as AdditiveBlending,ye as BufferAttribute,He as BufferGeometry,Dc as DynamicDrawUsage,Ta as InstancedBufferAttribute,Ha as InstancedBufferGeometry,Ca as LineSegments,ee as Matrix4,Ie as Mesh,Un as NormalBlending,no as OrbitControls,xe as PerspectiveCamera,La as Points,wa as Scene,Ge as ShaderMaterial,It as Vector2,L as Vector3,Ea as WebGLRenderer};
3836
+ /*! Bundled license information:
3837
+
3838
+ three/build/three.module.js:
3839
+ (**
3840
+ * @license
3841
+ * Copyright 2010-2024 Three.js Authors
3842
+ * SPDX-License-Identifier: MIT
3843
+ *)
3844
+ */