@realsee/five-webgpu 1.0.0-alpha.6 → 1.0.0-alpha.8

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 (218) hide show
  1. package/ai_guides/features/five.md +70 -1
  2. package/ai_guides/features/material.md +35 -8
  3. package/ai_guides/features/mode.md +23 -6
  4. package/docs/assets/hierarchy.js +1 -1
  5. package/docs/assets/navigation.js +1 -1
  6. package/docs/assets/search.js +1 -1
  7. package/docs/classes/index.AdaptiveLuminancePass.html +1 -1
  8. package/docs/classes/index.BoundingMesh.html +1 -1
  9. package/docs/classes/index.Camera.html +1 -1
  10. package/docs/classes/index.EyeDomeLightingPass.html +1 -1
  11. package/docs/classes/index.Five.html +60 -59
  12. package/docs/classes/index.FivePass.html +1 -1
  13. package/docs/classes/index.FiveRenderer.html +1 -1
  14. package/docs/classes/index.FlowingFireworks3DPass.html +1 -1
  15. package/docs/classes/index.FlowingLight2DPass.html +1 -1
  16. package/docs/classes/index.FlowingLight3DPass.html +2 -2
  17. package/docs/classes/index.GaussianBlurPass.html +1 -1
  18. package/docs/classes/index.InternalWebGPURenderer.html +8 -5
  19. package/docs/classes/index.Model.html +1 -1
  20. package/docs/classes/index.ModelScene.html +1 -1
  21. package/docs/classes/index.NetworkSubscribe.html +1 -1
  22. package/docs/classes/index.PBMCustomNode.html +8 -8
  23. package/docs/classes/index.PBMGaussianSplattingNodeMaterial.html +2 -2
  24. package/docs/classes/index.PBMGaussianSplattingObject.html +1 -1
  25. package/docs/classes/index.PBMGaussianSplattingRenderMesh.html +1 -1
  26. package/docs/classes/index.PBMGroup.html +1 -1
  27. package/docs/classes/index.PBMMesh.html +1 -1
  28. package/docs/classes/index.PBMMeshBasicMaterial.html +7 -6
  29. package/docs/classes/index.PBMMeshBasicNodeMaterial.html +9 -8
  30. package/docs/classes/index.PBMMeshPanoOnlyMaterial.html +7 -6
  31. package/docs/classes/index.PBMMeshPanoOnlyNodeMaterial.html +7 -6
  32. package/docs/classes/index.PBMMeshPhongMaterial.html +7 -6
  33. package/docs/classes/index.PBMMeshPhongNodeMaterial.html +9 -8
  34. package/docs/classes/index.PBMMeshPhysicalMaterial.html +7 -6
  35. package/docs/classes/index.PBMMeshPhysicalNodeMaterial.html +9 -8
  36. package/docs/classes/index.PBMPanoFilter.html +8 -8
  37. package/docs/classes/index.PBMPointCloud.html +6 -7
  38. package/docs/classes/index.PBMPointCloudMaterial.html +83 -0
  39. package/docs/classes/index.PBMSkinnedMesh.html +1 -1
  40. package/docs/classes/index.PBMUpdateable.html +1 -1
  41. package/docs/classes/index.PanoCircleMesh.html +1 -1
  42. package/docs/classes/index.PanoCircleMeshCustom.html +1 -1
  43. package/docs/classes/index.PanoCircleMeshSolid.html +1 -1
  44. package/docs/classes/index.Parameter.html +57 -56
  45. package/docs/classes/index.Scene.html +1 -1
  46. package/docs/classes/index.Subscribe.html +1 -1
  47. package/docs/classes/index.Tile3D.html +1 -1
  48. package/docs/classes/index.TileNode.html +1 -1
  49. package/docs/classes/index.TrajectoryNode.html +1 -1
  50. package/docs/classes/index.WorkResolvedObserver.html +1 -1
  51. package/docs/classes/index.XRButton.html +3 -0
  52. package/docs/documents/features_five.html +45 -3
  53. package/docs/documents/features_material.html +20 -9
  54. package/docs/documents/features_mode.html +27 -2
  55. package/docs/functions/index.customNodesCacheKey.html +1 -1
  56. package/docs/hierarchy.html +1 -1
  57. package/docs/interfaces/index.AddableObject.html +1 -1
  58. package/docs/interfaces/index.AjaxOptions.html +1 -1
  59. package/docs/interfaces/index.BaseEvent.html +1 -1
  60. package/docs/interfaces/index.Clock.html +1 -1
  61. package/docs/interfaces/index.DeviceProfile.html +8 -0
  62. package/docs/interfaces/index.EventCallback.html +3 -3
  63. package/docs/interfaces/index.FiveInitArgs.html +40 -25
  64. package/docs/interfaces/index.GestureEvent.html +1 -1
  65. package/docs/interfaces/index.IPBMMaterial.html +6 -5
  66. package/docs/interfaces/index.ImageOptions.html +1 -1
  67. package/docs/interfaces/index.IntersectEvent.html +1 -1
  68. package/docs/interfaces/index.IntersectMesh.html +1 -1
  69. package/docs/interfaces/index.IntersectMeshInterface.html +1 -1
  70. package/docs/interfaces/index.Intersection.html +1 -1
  71. package/docs/interfaces/index.LooseWorkWithExtrinsics.html +1 -1
  72. package/docs/interfaces/index.ModeChangeEvent.html +2 -2
  73. package/docs/interfaces/index.ModelControllerCustomInitArgs.html +1 -1
  74. package/docs/interfaces/index.ModelEvent.html +2 -2
  75. package/docs/interfaces/index.ModelSceneEvent.html +2 -2
  76. package/docs/interfaces/index.ModelTileEvent.html +2 -2
  77. package/docs/interfaces/index.MovePanoOptions.html +1 -1
  78. package/docs/interfaces/index.NetworkAbortError.html +1 -1
  79. package/docs/interfaces/index.NetworkFirbiddenError.html +1 -1
  80. package/docs/interfaces/index.NetworkOptions.html +1 -1
  81. package/docs/interfaces/index.NetworkProxyError.html +1 -1
  82. package/docs/interfaces/index.NetworkResourceEvent.html +2 -2
  83. package/docs/interfaces/index.NetworkResponseError.html +1 -1
  84. package/docs/interfaces/index.NetworkTimeoutError.html +1 -1
  85. package/docs/interfaces/index.ObjectEvent.html +2 -2
  86. package/docs/interfaces/index.PBMClipperParameter.html +2 -2
  87. package/docs/interfaces/index.PBMCustomNodeContext.html +30 -30
  88. package/docs/interfaces/index.PBMCustomNodeOptions.html +4 -4
  89. package/docs/interfaces/index.PBMCustomNodePanoContext.html +6 -6
  90. package/docs/interfaces/index.PBMCustomNodeSlots.html +6 -6
  91. package/docs/interfaces/index.PBMGaussianSplattingNodeMaterialOptions.html +4 -0
  92. package/docs/interfaces/index.PBMPanoDepth.html +5 -5
  93. package/docs/interfaces/index.PBMPanoFilterValue.html +2 -2
  94. package/docs/interfaces/index.PBMPanoGainmap.html +3 -3
  95. package/docs/interfaces/index.PBMPanoPicture.html +8 -8
  96. package/docs/interfaces/index.PBMRefinedScreen.html +2 -2
  97. package/docs/interfaces/index.PanoCircleMeshInterface.html +1 -1
  98. package/docs/interfaces/index.PanoEvent.html +1 -1
  99. package/docs/interfaces/index.PanoPrepareEvent.html +15 -0
  100. package/docs/interfaces/index.PanoTextureEvent.html +1 -1
  101. package/docs/interfaces/index.PanoramaControllerCustomInitArgs.html +1 -1
  102. package/docs/interfaces/index.PanoramaLikeControllerCustomInitArgs.html +1 -1
  103. package/docs/interfaces/index.ParameterMaterialValue.html +42 -41
  104. package/docs/interfaces/index.ParameterTilesetValue.html +15 -15
  105. package/docs/interfaces/index.ParameterValue.html +56 -55
  106. package/docs/interfaces/index.Pose.html +1 -1
  107. package/docs/interfaces/index.RenderEvent.html +2 -2
  108. package/docs/interfaces/index.ResolvedParameterValue.html +56 -55
  109. package/docs/interfaces/index.State.html +1 -1
  110. package/docs/interfaces/index.StateEvent.html +1 -1
  111. package/docs/interfaces/index.TextureOptions.html +1 -1
  112. package/docs/interfaces/index.TopviewControllerCustomInitArgs.html +1 -1
  113. package/docs/interfaces/index.VRPanoramaControllerCustomInitArgs.html +1 -1
  114. package/docs/interfaces/index.ViewLayer.html +1 -1
  115. package/docs/interfaces/index.WorkCubeHdrGainmapImage.html +1 -1
  116. package/docs/interfaces/index.WorkCubeImage.html +1 -1
  117. package/docs/interfaces/index.WorkImage.html +1 -1
  118. package/docs/interfaces/index.WorkObserver.html +1 -1
  119. package/docs/interfaces/index.WorkTile.html +1 -1
  120. package/docs/interfaces/index.WorksEvent.html +2 -2
  121. package/docs/interfaces/index.XRControllerEvent.html +2 -2
  122. package/docs/interfaces/index.XRGestureEvent.html +2 -2
  123. package/docs/interfaces/index.XRPanoramaControllerCustomInitArgs.html +52 -0
  124. package/docs/interfaces/index.XRSessionEvent.html +2 -2
  125. package/docs/modules/index.html +1 -1
  126. package/docs/types/index.ControllerCustomInitTypes.html +3 -2
  127. package/docs/types/index.ControllerEventTypes.html +3 -3
  128. package/docs/types/index.DeviceProfileOverride.html +5 -0
  129. package/docs/types/index.FlowingLightLineInput.html +11 -0
  130. package/docs/types/index.Mode.html +6 -4
  131. package/docs/types/index.OutputTextureDataType.html +1 -1
  132. package/docs/types/index.PBMCustomNodeTargetType.html +1 -1
  133. package/docs/types/index.ParseOptions.html +1 -1
  134. package/docs/types/index.XRMachineType.html +7 -0
  135. package/docs/variables/index.PBMVertexMarkFlag.html +4 -0
  136. package/docs/variables/index.controllersDefaultInitArgs.html +1 -1
  137. package/five/application/controllers.d.ts +4 -0
  138. package/five/application/five.d.ts +3 -1
  139. package/five/application/fiveInitArgs.d.ts +19 -1
  140. package/five/application/mode.d.ts +7 -2
  141. package/five/controllers/xrPanorama.d.ts +506 -0
  142. package/five/core/internalWebGPURenderer.d.ts +7 -1
  143. package/five/core/webglAsyncReadFix.d.ts +25 -0
  144. package/five/index.d.ts +4 -1
  145. package/five/index.js +29 -29
  146. package/five/index.mjs +5220 -3680
  147. package/five/model/index.d.ts +3 -2
  148. package/five/model/materials/pbmMaterial.d.ts +13 -1
  149. package/five/model/materials/pbmMeshMaterial.d.ts +0 -9
  150. package/five/model/materials/pbmPointCloudNodeMaterial.d.ts +1 -1
  151. package/five/model/objects/pbmPointCloud.d.ts +0 -1
  152. package/five/model/objects/pbmPointCloudObject.d.ts +1 -1
  153. package/five/model/parameter.d.ts +5 -4
  154. package/five/renderer/compute-renderers/pointcloud-compute-renderer.d.ts +2 -0
  155. package/five/renderer/index.d.ts +1 -1
  156. package/five/renderer/postprocessing/index.d.ts +1 -1
  157. package/five/utils/event.d.ts +9 -2
  158. package/five/webxr/XRControllerModelFactory.d.ts +55 -0
  159. package/five/webxr/buttonStateMachine.d.ts +31 -0
  160. package/five/webxr/deviceProfile.d.ts +70 -0
  161. package/five/webxr/inputSourceTracker.d.ts +59 -0
  162. package/five/webxr/referenceSpace.d.ts +60 -0
  163. package/five/webxr/renderTargetBridge.d.ts +45 -0
  164. package/five/webxr/xrButton.d.ts +4 -0
  165. package/five/webxr/xrManager.d.ts +174 -0
  166. package/gltf-loader/index.js +3 -3
  167. package/gltf-loader/index.mjs +3 -3
  168. package/line/circle_png.d.ts +1 -0
  169. package/line/index.d.ts +49 -0
  170. package/line/index.js +255 -0
  171. package/line/index.mjs +340 -0
  172. package/package.json +25 -5
  173. package/plugins/FloorplanPlugin/index.d.ts +1 -0
  174. package/plugins/FloorplanPlugin/typings/floorplanJson.d.ts +167 -0
  175. package/plugins/FloorplanPlugin/typings/index.d.ts +1 -0
  176. package/plugins/FloorplanPlugin/utils/formatFloorplanJson.d.ts +20 -0
  177. package/plugins/FloorplanPlugin/utils/polylabel.d.ts +8 -0
  178. package/plugins/index.js +361 -6
  179. package/plugins/index.mjs +25707 -363
  180. package/plugins/thirdParty/doctorstrange-model.d.ts +92 -0
  181. package/react/index.js +2 -2
  182. package/react/index.mjs +2 -2
  183. package/sticker/geometry.d.ts +3 -0
  184. package/sticker/index.d.ts +68 -0
  185. package/sticker/index.js +255 -0
  186. package/sticker/index.mjs +358 -0
  187. package/umd/five-gltf-loader.js +3 -3
  188. package/umd/five-line.js +322 -0
  189. package/umd/five-plugins.js +370 -15
  190. package/umd/five-react.js +2 -2
  191. package/umd/five-sticker.js +255 -0
  192. package/umd/five-vfx.js +323 -0
  193. package/umd/five.js +68 -68
  194. package/vfx/airflow/airflow.d.ts +18 -0
  195. package/vfx/common/simplex-noise.d.ts +2 -0
  196. package/vfx/frame/frame.d.ts +27 -0
  197. package/vfx/index.d.ts +7 -0
  198. package/vfx/index.js +255 -0
  199. package/vfx/index.mjs +738 -0
  200. package/vfx/particle/instance.d.ts +36 -0
  201. package/vfx/particle/particle.d.ts +119 -0
  202. package/vfx/particle/utils.d.ts +11 -0
  203. package/vfx/particle-gpu/particle.d.ts +75 -0
  204. package/vfx/particle-gpu/utils.d.ts +11 -0
  205. package/vfx/spotLight/spotLight.d.ts +15 -0
  206. package/work-downloader/components/model-3d-tile.d.ts +2 -0
  207. package/work-downloader/components/model.d.ts +3 -0
  208. package/work-downloader/components/observer.d.ts +9 -0
  209. package/work-downloader/download.d.ts +16 -0
  210. package/work-downloader/index.d.ts +2 -0
  211. package/work-downloader/index.js +255 -0
  212. package/work-downloader/index.mjs +595 -0
  213. package/work-downloader/type.d.ts +28 -0
  214. package/work-downloader/utils/download-to-file.d.ts +1 -0
  215. package/work-downloader/utils/image-processing.d.ts +7 -0
  216. package/work-downloader/utils/join-url.d.ts +2 -0
  217. package/work-downloader/utils/log.d.ts +1 -0
  218. package/work-downloader/utils/relative-url.d.ts +1 -0
@@ -0,0 +1,322 @@
1
+ /**
2
+ * @license
3
+ * @realsee/five-webgpu
4
+ * Generated: 2026/10/19
5
+ * Version: 1.0.0-alpha.8
6
+ * Terms:
7
+ * Realsee SDK License Agreement
8
+ * Update: July 28, 2021
9
+ * THIS LICENSE AGREEMENT BETWEEN YOU AND 【BEIKE REALSEE TECHNOLOGY (HK)
10
+ * LIMITED】(“Realsee”) FORMS A LEGALLY BINDING CONTRACT BETWEEN YOU AND REALSEE IN
11
+ * RELATION TO YOUR USE OF THE SDK. This License Agreement accompanies the Realsee
12
+ * Software Development Kit(s) for the software and related explanatory materials
13
+ * (the "SDK") and includes any upgrades, modified versions, updates, additions,
14
+ * and copies of the SDK licensed to You by Realsee.
15
+ * BY DOWNLOADING, INSTALLING, OR OTHERWISE ACCESSING OR USING THE SDK, YOU AGREE
16
+ * THAT YOU HAVE READ, UNDERSTOOD, AND AGREE TO BE BOUND BY THIS AGREEMENT. YOU ARE
17
+ * AGREEING ON YOUR OWN BEHALF AND/OR ON BEHALF OF YOUR COMPANY OR ORGANIZATION TO
18
+ * THE TERMS AND CONDITIONS STATED BELOW.
19
+ * This Agreement applies to Your use of the SDK in the country in which You
20
+ * legally install it (“Territory”) and is subject to the laws of such Territory
21
+ * and further subject to Section 12 below. Different terms, conditions, and
22
+ * limitations may apply to the use of the SDK in any additional countries.
23
+ * 1. DEFINITIONS.
24
+ * “Agreement” means this Realsee SDK License Agreement.
25
+ * “Developer”, “You” and “Your” means the person(s) or entity acquiring or using
26
+ * the SDK or otherwise exercising rights under the terms of this Agreement.
27
+ * “Documentation” means the technical or other specifications or documentation
28
+ * that Realsee may provide to You for use in connection with the SDK.
29
+ * “Integrated Product” means any software, website, or on-line service developed
30
+ * by You based on or using the SDK (collectively, the “Integrated Product”).
31
+ * “Intellectual Property” means any patents, patent rights, trademarks, service
32
+ * marks, registered and unregistered designs, applications for any of the
33
+ * foregoing, copyright, and any other similar protected rights in any country and
34
+ * to the extent recognised by any relevant jurisdiction as intellectual property,
35
+ * trade secrets, know-how and confidential information. Realsee reserves all
36
+ * rights not expressly granted to You.
37
+ * “Realsee” means [Beike Realsee Technology (HK) Limited, a company incorporated
38
+ * and validly existing under the laws of Hong Kong].
39
+ * “SDK” means the Realsee-proprietary Software Development Kits (SDK) provided
40
+ * hereunder, includes all development tools (including any compiler and debugger),
41
+ * application programming interfaces (“APIs”), libraries, binary utilities, header
42
+ * files, Documentation, content, data, code samples, and other materials provided
43
+ * to You in connection with this Agreement, whether delivered through a download,
44
+ * or any other media or form, and is licensed, not sold, to You by Realsee for use
45
+ * only under the terms of this Agreement. The terms of this Agreement will govern
46
+ * any updates provided by Realsee that replace and/or supplement the original SDK
47
+ * delivered to You, unless such update is accompanied by a separate license, in
48
+ * which case the terms of such license will govern.
49
+ * 2. LICENSED USES AND RESTRICTIONS.
50
+ * 2.1 Subject to the restrictions contained in this Section 2, Realsee grants to
51
+ * You during the term, a limited, non-exclusive, revocable, non-sublicensable,
52
+ * non-transferable license to install and use the SDK within the Territory only
53
+ * for the purpose of internal development.
54
+ * 2.2 Restrictions. You acknowledge and agree that, You shall not, and shall
55
+ * ensure that Your affiliates, employees, agents, representatives, officers,
56
+ * representatives, and subcontractors do not (directly or indirectly):
57
+ * 2.2.1 decompile, reverse engineer, disassemble or attempt to derive the source
58
+ * code of, those components of the SDK provided in object code form, or any part
59
+ * thereof;
60
+ * 2.2.2 remove, alter, or obscure any copyright notice or other proprietary rights
61
+ * notice on any part of the SDK;
62
+ * 2.2.3 sell, assign, pledge, rent, lease, lend, upload to or host on any website
63
+ * or server for use by any third party except You, redistribute, or sublicense the
64
+ * SDK (or any part thereof), or operate the SDK (or any part thereof) in the
65
+ * capacity of a service bureau or other hosted services provider, in whole or in
66
+ * part, nor may You enable others to do so;
67
+ * 2.2.4 or alter, modify, customize or improve the SDK, or any part thereof;
68
+ * 2.2.5 use the SDK (or any part thereof) for any illegal purpose, in any manner
69
+ * that is inconsistent with the terms of this Agreement, or to engage in any
70
+ * illegal activity;
71
+ * 2.2.6 use the SDK (or any part thereof) in any manner that may damage the
72
+ * operation of Realsee’s products or services; or
73
+ * 2.2.7 use the SDK or any information contained therein or otherwise provided by
74
+ * Realsee for the purpose of developing, or having developed, any product
75
+ * competitive with any Realsee product or service, as determined by Realsee in its
76
+ * sole discretion;
77
+ * 2.2.8 include any portion of the SDK in Your Developer products.
78
+ * 2.3 Realsee has the right to impose reasonable conditions such as a reasonable
79
+ * fee for use of the SDK in Integrated Product in the future.
80
+ * 2.4 You may make a limited number of copies of the SDK to be used by Your
81
+ * employees or consultants as provided herein, and not for general business
82
+ * purposes, and such employees or consultants shall be subject to the obligations
83
+ * and restrictions in this Agreement.
84
+ * 2.5 All licenses not expressly granted in this Agreement are reserved and no
85
+ * other licenses, immunity, or rights, express or implied, are granted by Realsee,
86
+ * by implication, estoppel, or otherwise.
87
+ * 3. CONFIDENTIALITY.
88
+ * The SDK and all source code, Documentation, specifications, engineering details,
89
+ * and related information pertaining to the SDK, whether in oral, written,
90
+ * graphic, or electronic form, are and shall remain the confidential and
91
+ * proprietary information of Realsee or its licensors (collectively, the
92
+ * “Confidential Information”). You shall (i) disclose Confidential Information to
93
+ * only those directors and employees (collectively, “Affiliates”) whose duties
94
+ * justify their need to know such information and who have been clearly informed
95
+ * of their obligation to maintain the confidential, proprietary, and/or trade
96
+ * secret status of such Confidential Information; and (ii) use Confidential
97
+ * Information solely in accordance with the license granted hereunder. In any
98
+ * event, You and Your Affiliates shall treat Confidential Information as strictly
99
+ * confidential and shall use the same care to prevent disclosure of such
100
+ * information as You use with respect to Your own similar confidential and/or
101
+ * proprietary information, which shall not be less than the care a reasonable
102
+ * person would use under similar circumstances. All Confidential Information, and
103
+ * any copies thereof, shall be returned promptly to Realsee upon request. You
104
+ * shall ensure that Your Affiliates comply with the provisions of this Section 3,
105
+ * and You shall be liable for any breach of this Section 3 resulting from the act
106
+ * or omission of any of Your Affiliates. You shall not disclose Confidential
107
+ * Information to any third party, including, without limitation, any of Your
108
+ * subcontractors.
109
+ * 4. PROPRIETARY RIGHTS.
110
+ * 4.1 As between You and Realsee, Realsee and/or its licensors retain ownership of
111
+ * all right, title, and interest in, to, and under the SDK, including, without
112
+ * limitation, all patents, copyrights, trade secrets, trademarks and other
113
+ * intellectual property and other proprietary rights therein, and reserve all
114
+ * rights not expressly granted to You.
115
+ * 4.2 The items contained in the SDK are the intellectual property of Realsee and
116
+ * its licensors and are protected by PRC copyright and patent law, international
117
+ * treaty provisions and applicable laws of the country in which it is being used.
118
+ * You agree to protect all copyright and other ownership interests of Realsee
119
+ * and/or its licensors in all items in the SDK supplied under this License
120
+ * Agreement. You agree that all copies of the items in the SDK, reproduced for any
121
+ * reason by You, contain the same copyright notices, and other proprietary notices
122
+ * as appropriate, as appear on or in the original items delivered by Realsee in
123
+ * the SDK. Realsee and/or its licensors retain title and ownership of the items in
124
+ * the SDK, the media on which it is loaded, and all subsequent copies, regardless
125
+ * of the form or media in or on which the original and other copies may exist.
126
+ * Except as stated above, this Agreement does not grant You any rights to patents,
127
+ * copyrights, trade secrets, trademarks or any other rights in respect to the
128
+ * items in the SDK.
129
+ * 5. TERM AND TERMINATION.
130
+ * 5.1 This Agreement is effective until terminated. Realsee has the right to
131
+ * terminate this Agreement immediately, without judicial intervention, if You fail
132
+ * to comply with any term herein. Upon any such termination You must remove all
133
+ * full and partial copies of the items in the SDK from Your computer and
134
+ * discontinue the use of the items in the SDK.
135
+ * 5.2 Realsee may at any time, terminate the Agreement with You if: (A) You have
136
+ * breached any provision of the Agreement; or (B) Realsee is required to do so by
137
+ * law; or (C) Realsee decides to no longer provide the SDK or certain parts of the
138
+ * SDK to users in the country in which You are resident or from which You use the
139
+ * service, or the provision of the SDK or certain SDK services to You by Realsee
140
+ * is, in Realsee's sole discretion, no longer legally or commercially viable.
141
+ * 5.3 When the Agreement comes to an end, all of the legal rights, obligations and
142
+ * liabilities that You and Realsee have benefited from, been subject to (or which
143
+ * have accrued over time whilst the Agreement has been in force) or which are
144
+ * expressed to continue indefinitely, shall be unaffected by this cessation, and
145
+ * the provisions of Section 3, 4, 6, 7 and 8 shall continue to apply to such
146
+ * rights, obligations and liabilities indefinitely.
147
+ * 6. DISCLAIMER OF WARRANTY.
148
+ * YOU EXPRESSLY ACKNOWLEDGE AND AGREE THAT, TO THE EXTENT PERMITTED BY APPLICABLE
149
+ * LAW, USE OF THE SDK (OR ANY PART THEREOF) IS AT YOUR SOLE RISK AND THAT THE
150
+ * ENTIRE RISK AS TO SATISFACTORY QUALITY, PERFORMANCE, ACCURACY, AND EFFORT IS
151
+ * WITH YOU. REALSEE LICENSES THE SDK TO YOU ONLY ON AN "AS-IS" BASIS. REALSEE
152
+ * MAKES NO REPRESENTATION WITH RESPECT TO THE ADEQUACY OF ANY ITEMS IN THE SDK,
153
+ * WHETHER OR NOT USED BY YOU IN THE DEVELOPMENT OF INTEGRATED PRODUCT, FOR ANY
154
+ * PARTICULAR PURPOSE OR WITH RESPECT TO THEIR ADEQUACY TO PRODUCE ANY PARTICULAR
155
+ * RESULT. REALSEE AND ITS LICENSORS SHALL NOT BE LIABLE FOR LOSS OR DAMAGE ARISING
156
+ * OUT OF THIS AGREEMENT OR FROM THE DISTRIBUTION OR USE OF INTEGRATED PRODUCT
157
+ * CONTAINING PORTIONS OF THE SDK. REALSEE AND ITS LICENSORS DISCLAIM ALL
158
+ * WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED
159
+ * CONDITIONS OR WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
160
+ * OR NONINFRINGEMENT OF ANY THIRD PARTY RIGHT IN RESPECT OF THE ITEMS IN THE SDK
161
+ * OR ANY SERVICES RELATED TO THE SDK.
162
+ * REALSEE IS UNDER NO OBLIGATION TO PROVIDE ANY SUPPORT UNDER THIS LICENSE
163
+ * AGREEMENT, INCLUDING UPGRADES OR FUTURE VERSIONS OF THE SDK OR ANY PORTIONS
164
+ * THEREOF, TO YOU, END USER OR TO ANY OTHER PARTY.
165
+ * 7. LIMITATION OF LIABILITY.
166
+ * TO THE EXTENT NOT PROHIBITED BY APPLICABLE LAW, IN NO EVENT WILL REALSEE OR ITS
167
+ * LICENSORS BE LIABLE FOR ANY DIRECT, INCIDENTAL, SPECIAL, INDIRECT, OR
168
+ * CONSEQUENTIAL DAMAGES, INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF USE,
169
+ * LOSS OF BUSINESS, REVENUE, OR PROFITS, LOSS OF OPPORTUNITY (WHETHER DIRECT OR
170
+ * INDIRECT), CORRUPTION OR LOSS OF DATA, LOSS OF REPUTATION OR SAVINGS, DOWNTIME,
171
+ * OR DAMAGE TO, LOSS OF OR REPLACEMENT OF DATA OR TRANSACTIONS, COST OF
172
+ * PROCUREMENT OF SUBSTITUTE SERVICES, BUSINESS INTERRUPTION, OR ANY OTHER
173
+ * COMMERCIAL DAMAGES OR LOSSES, ARISING OUT OF OR RELATED TO YOUR USE OR INABILITY
174
+ * TO USE THE SDK (OR ANY PART THEREOF), ANY INTEGRATED PRODUCT, OR ANY THIRD PARTY
175
+ * SOFTWARE, APPLICATIONS, OR SERVICES IN CONJUNCTION WITH THE SDK (OR ANY PART
176
+ * THEREOF), HOWEVER CAUSED, REGARDLESS OF THE THEORY OF LIABILITY (CONTRACT, TORT,
177
+ * OR OTHERWISE) AND EVEN IF REALSEE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
178
+ * DAMAGES. IN NO EVENT WILL REALSEE’S TOTAL LIABILITY TO YOU FOR ALL DAMAGES
179
+ * EXCEED ONE HUNDRED DOLLARS ($100.00). THE FOREGOING LIMITATIONS WILL APPLY EVEN
180
+ * IF THE ABOVE STATED REMEDY FAILS OF ITS ESSENTIAL PURPOSE. THE LIMITATIONS
181
+ * CONTAINED IN SECTIONS 6 AND THIS SECTION 7 ARE A FUNDAMENTAL PART OF THE BASIS
182
+ * OF REALSEE’S BARGAIN HEREUNDER, AND REALSEE WOULD NOT ENTER INTO THIS AGREEMENT
183
+ * OR PROVIDE YOU WITH ACCESS TO THE SDK ABSENT SUCH LIMITATIONS.
184
+ * 8. INDEMNIFICATION.
185
+ * To the extent permitted by applicable law, You agree to indemnify, defend and
186
+ * hold harmless Realsee, its affiliates and each of their directors, officers,
187
+ * employees, independent contractors, and agents (each a “Realsee Indemnified
188
+ * Party”) from any and all claims, losses, liabilities, damages, expenses, and
189
+ * costs (including without limitation attorneys’ fees and court costs) incurred by
190
+ * a Realsee Indemnified Party as a result of: (i) Your non-compliance with any
191
+ * terms of this Agreement; (ii) Your use of the SDK (or any part thereof); or
192
+ * (iii) Your use of any Integrated Product, including any claim that Integrated
193
+ * Product infringes the copyright, trademark, trade secret or other intellectual
194
+ * property right of a third party.
195
+ * 9. ACKNOWLEDGEMENTS.
196
+ * Portions of the SDK may utilize or include third party software and other
197
+ * copyrighted material. Acknowledgments, licensing terms, and disclaimers for such
198
+ * material are contained in Documentation for the SDK or may otherwise accompany
199
+ * such material, and Your use of such materials governed by their respective
200
+ * terms. In the event of conflict between the terms of this Agreement and an
201
+ * applicable open source or third party agreement, the open source or third party
202
+ * agreement will control solely with respect to the open source software or third
203
+ * party software. Moreover, You shall not subject any items (including not limited
204
+ * to source code, object code, and any software) included in the SDK to any open
205
+ * source license.
206
+ * 10. NON-BLOCKING OF REALSEE DEVELOPMENT.
207
+ * You acknowledge that Realsee is currently developing or may develop technologies
208
+ * and products in the future that have or may have design and/or functionality
209
+ * similar to Integrated Product that You may develop based on Your license herein.
210
+ * Nothing in this Agreement shall impair, limit or curtail Realsee's right to
211
+ * continue with its development, maintenance and/or distribution of Realsee's
212
+ * technology or products.
213
+ * 11. GENERAL.
214
+ * 11.1 Export Control. You may not use or otherwise export or re-export the SDK
215
+ * (or any part thereof) except as authorized by United States law and the laws of
216
+ * the jurisdiction(s) in which the SDK (or any part thereof) was obtained. In
217
+ * particular, but without limitation, the SDK may not be exported or re-exported
218
+ * (i) into any U.S. embargoed countries or (ii) to anyone on the U.S. Treasury
219
+ * Department's list of Specially Designated Nationals or the U.S. Department of
220
+ * Commerce Denied Person's List or Entity List. By using the SDK (or any part
221
+ * thereof), You represent and warrant that You are not located in any such country
222
+ * or on any such list.
223
+ * 11.2 Governing Law. This Agreement and the rights of the parties hereunder shall
224
+ * be governed by and construed in accordance with the laws of People’s Republic of
225
+ * China (for purpose of this Agreement, excluding Hong Kong, Taiwan, and Macau),
226
+ * without reference to its conflict of laws principles. Any dispute, controversy
227
+ * or claim arising from or in connection with this Agreement, or the breach,
228
+ * termination or invalidity thereof, shall be submitted to China International
229
+ * Economic and Trade Arbitration Commission (“CIETAC”) for arbitration in Beijing
230
+ * which shall be conducted in accordance with the CIETAC's arbitration rules in
231
+ * effect at the time of applying for arbitration. The arbitral award is final and
232
+ * binding upon both parties.
233
+ * 11.3 Severability. If any provision of this Agreement is held by a court of
234
+ * competent jurisdiction to be unenforceable for any reason, the remaining
235
+ * provisions hereof will be unaffected and remain in full force and effect.
236
+ * 11.4. Modifications. Realsee reserves the right, from time to time, with or
237
+ * without notice to You, to make revisions to this Agreement in our sole and
238
+ * absolute discretion. The most current version of this Agreement will supersede
239
+ * all previous versions and shall be made available on the website where the SDK
240
+ * is made available, or by such other means as Realsee may determine in its
241
+ * discretion. Any modified versions of this Agreement hereto shall take effect
242
+ * from the time that it is made available. You shall be responsible for regularly
243
+ * checking for notice of any such modifications. You agree that Your continued use
244
+ * of the SDK constitutes Your agreement to the modified Agreement.
245
+ * 11.5 Relationship of the Parties. This Agreement will not be construed as
246
+ * creating an agency, partnership, joint venture, fiduciary duty, or any other
247
+ * form of legal association between You and Realsee, and You will not represent to
248
+ * the contrary, whether expressly, by implication, appearance, or otherwise.
249
+ * 11.6 Entire Agreement; Governing Language. This Agreement constitutes the entire
250
+ * agreement between You and Realsee with respect to the use of the SDK licensed
251
+ * hereunder and supersedes all prior understandings regarding such subject matter.
252
+ * No amendment to or modification of this Agreement will be binding unless in
253
+ * writing and signed by Realsee. You and Realsee hereto confirm that this
254
+ * Agreement and all related documents shall be drafted in English.
255
+ */(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("three")):typeof define==`function`&&define.amd?define([`exports`,`three`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.FiveSDK_Line={},e.THREE))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}function r(e,t){if(n(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||`default`);if(n(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function i(e){var t=r(e,`string`);return n(t)==`symbol`?t:t+``}function a(e,t,n){return(t=i(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?o(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function c(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function l(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){c(a,r,i,o,s,`next`,e)}function s(e){c(a,r,i,o,s,`throw`,e)}o(void 0)})}}var u=1e3,d=1001,f=1002,p=1003,m=1006,h=1008,g=1009,_=1014,v=1015,y=1016,b=1023,x=1026,S=2300,ee=2301,C=2302,te=2303,ne=2400,re=2401,ie=2402,ae=`srgb`,w=`srgb-linear`,oe=`linear`,se=`srgb`,ce=7680,le=35044,ue=35048,de=2e3,fe={TEXTURE_COMPARE:`depthTextureCompare`};function pe(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function me(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function he(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}var ge={},_e=null;function ve(...e){let t=`THREE.`+e.shift();_e?_e(`log`,t,...e):console.log(t,...e)}function ye(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function T(...e){e=ye(e);let t=`THREE.`+e.shift();if(_e)_e(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function E(...e){e=ye(e);let t=`THREE.`+e.shift();if(_e)_e(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function be(...e){let t=e.join(` `);t in ge||(ge[t]=!0,T(...e))}var xe=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},Se=`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`.split(`.`),Ce=1234567,we=Math.PI/180,Te=180/Math.PI;function Ee(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Se[e&255]+Se[e>>8&255]+Se[e>>16&255]+Se[e>>24&255]+`-`+Se[t&255]+Se[t>>8&255]+`-`+Se[t>>16&15|64]+Se[t>>24&255]+`-`+Se[n&63|128]+Se[n>>8&255]+`-`+Se[n>>16&255]+Se[n>>24&255]+Se[r&255]+Se[r>>8&255]+Se[r>>16&255]+Se[r>>24&255]).toLowerCase()}function D(e,t,n){return Math.max(t,Math.min(n,e))}function De(e,t){return(e%t+t)%t}function Oe(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function ke(e,t,n){return e===t?0:(n-e)/(t-e)}function Ae(e,t,n){return(1-n)*e+n*t}function je(e,t,n,r){return Ae(e,t,1-Math.exp(-n*r))}function Me(e,t=1){return t-Math.abs(De(e,t*2)-t)}function Ne(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function Pe(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function Fe(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Ie(e,t){return e+Math.random()*(t-e)}function Le(e){return e*(.5-Math.random())}function Re(e){e!==void 0&&(Ce=e);let t=Ce+=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 ze(e){return e*we}function Be(e){return e*Te}function Ve(e){return(e&e-1)==0&&e!==0}function He(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Ue(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function We(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:T(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function Ge(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function O(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var Ke={DEG2RAD:we,RAD2DEG:Te,generateUUID:Ee,clamp:D,euclideanModulo:De,mapLinear:Oe,inverseLerp:ke,lerp:Ae,damp:je,pingpong:Me,smoothstep:Ne,smootherstep:Pe,randInt:Fe,randFloat:Ie,randFloatSpread:Le,seededRandom:Re,degToRad:ze,radToDeg:Be,isPowerOfTwo:Ve,ceilPowerOfTwo:He,floorPowerOfTwo:Ue,setQuaternionFromProperEuler:We,normalize:O,denormalize:Ge},qe=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=D(this.x,e.x,t.x),this.y=D(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=D(this.x,e,t),this.y=D(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(D(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(D(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Je=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:T(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(D(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},k=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Xe.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Xe.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=D(this.x,e.x,t.x),this.y=D(this.y,e.y,t.y),this.z=D(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=D(this.x,e,t),this.y=D(this.y,e,t),this.z=D(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(D(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Ye.copy(this).projectOnVector(e),this.sub(Ye)}reflect(e){return this.sub(Ye.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(D(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Ye=new k,Xe=new Je,Ze=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Qe.makeScale(e,t)),this}rotate(e){return this.premultiply(Qe.makeRotation(-e)),this}translate(e,t){return this.premultiply(Qe.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Qe=new Ze,$e=new Ze().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),et=new Ze().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function tt(){let e={enabled:!0,workingColorSpace:w,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=nt(e.r),e.g=nt(e.g),e.b=nt(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=rt(e.r),e.g=rt(e.g),e.b=rt(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?oe:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return be(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return be(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[w]:{primaries:t,whitePoint:r,transfer:oe,toXYZ:$e,fromXYZ:et,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:ae},outputColorSpaceConfig:{drawingBufferColorSpace:ae}},[ae]:{primaries:t,whitePoint:r,transfer:se,toXYZ:$e,fromXYZ:et,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:ae}}}),e}var A=tt();function nt(e){return e<.04045?e*.0773993808:Math.pow(e*.9478672986+.0521327014,2.4)}function rt(e){return e<.0031308?e*12.92:1.055*Math.pow(e,.41666)-.055}var it,at=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{it===void 0&&(it=he(`canvas`)),it.width=e.width,it.height=e.height;let t=it.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=it}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=he(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=nt(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(nt(t[e]/255)*255):t[e]=nt(t[e]);return{data:t,width:e.width,height:e.height}}else return T(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},ot=0,st=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:ot++}),this.uuid=Ee(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(ct(r[t].image)):e.push(ct(r[t]))}else e=ct(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function ct(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?at.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(T(`Texture: Unable to serialize Texture.`),{})}var lt=0,ut=new k,dt=class e extends xe{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=d,i=d,a=m,o=h,s=b,c=g,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:lt++}),this.uuid=Ee(),this.name=``,this.source=new st(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new qe(0,0),this.repeat=new qe(1,1),this.center=new qe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ze,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(ut).x}get height(){return this.source.getSize(ut).y}get depth(){return this.source.getSize(ut).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){T(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){T(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case u:e.x-=Math.floor(e.x);break;case d:e.x=e.x<0?0:1;break;case f:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case u:e.y-=Math.floor(e.y);break;case d:e.y=e.y<0?0:1;break;case f:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};dt.DEFAULT_IMAGE=null,dt.DEFAULT_MAPPING=300,dt.DEFAULT_ANISOTROPY=1;var j=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=D(this.x,e.x,t.x),this.y=D(this.y,e.y,t.y),this.z=D(this.z,e.z,t.z),this.w=D(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=D(this.x,e,t),this.y=D(this.y,e,t),this.z=D(this.z,e,t),this.w=D(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(D(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},ft=class extends xe{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:m,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new j(0,0,e,t),this.scissorTest=!1,this.viewport=new j(0,0,e,t),this.textures=[];let r=new dt({width:e,height:t,depth:n.depth}),i=n.count;for(let e=0;e<i;e++)this.textures[e]=r.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:m,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new st(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:`dispose`})}},pt=class extends dt{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=p,this.minFilter=p,this.wrapR=d,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},mt=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.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,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,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 e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();let t=this.elements,n=e.elements,r=1/ht.setFromMatrixColumn(e,0).length(),i=1/ht.setFromMatrixColumn(e,1).length(),a=1/ht.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(_t,e,vt)}lookAt(e,t,n){let r=this.elements;return xt.subVectors(e,t),xt.lengthSq()===0&&(xt.z=1),xt.normalize(),yt.crossVectors(n,xt),yt.lengthSq()===0&&(Math.abs(n.z)===1?xt.x+=1e-4:xt.z+=1e-4,xt.normalize(),yt.crossVectors(n,xt)),yt.normalize(),bt.crossVectors(xt,yt),r[0]=yt.x,r[4]=bt.x,r[8]=xt.x,r[1]=yt.y,r[5]=bt.y,r[9]=xt.y,r[2]=yt.z,r[6]=bt.z,r[10]=xt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],ee=r[8],C=r[12],te=r[1],ne=r[5],re=r[9],ie=r[13],ae=r[2],w=r[6],oe=r[10],se=r[14],ce=r[3],le=r[7],ue=r[11],de=r[15];return i[0]=a*x+o*te+s*ae+c*ce,i[4]=a*S+o*ne+s*w+c*le,i[8]=a*ee+o*re+s*oe+c*ue,i[12]=a*C+o*ie+s*se+c*de,i[1]=l*x+u*te+d*ae+f*ce,i[5]=l*S+u*ne+d*w+f*le,i[9]=l*ee+u*re+d*oe+f*ue,i[13]=l*C+u*ie+d*se+f*de,i[2]=p*x+m*te+h*ae+g*ce,i[6]=p*S+m*ne+h*w+g*le,i[10]=p*ee+m*re+h*oe+g*ue,i[14]=p*C+m*ie+h*se+g*de,i[3]=_*x+v*te+y*ae+b*ce,i[7]=_*S+v*ne+y*w+b*le,i[11]=_*ee+v*re+y*oe+b*ue,i[15]=_*C+v*ie+y*se+b*de,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,ee=l*m-u*p,C=l*h-d*p,te=l*g-f*p,ne=u*h-d*m,re=u*g-f*m,ie=d*g-f*h,ae=_*ie-v*re+y*ne+b*te-x*C+S*ee;if(ae===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let w=1/ae;return e[0]=(o*ie-s*re+c*ne)*w,e[1]=(r*re-n*ie-i*ne)*w,e[2]=(m*S-h*x+g*b)*w,e[3]=(d*x-u*S-f*b)*w,e[4]=(s*te-a*ie-c*C)*w,e[5]=(t*ie-r*te+i*C)*w,e[6]=(h*y-p*S-g*v)*w,e[7]=(l*S-d*y+f*v)*w,e[8]=(a*re-o*te+c*ee)*w,e[9]=(n*te-t*re-i*ee)*w,e[10]=(p*x-m*y+g*_)*w,e[11]=(u*y-l*x-f*_)*w,e[12]=(o*C-a*ne-s*ee)*w,e[13]=(t*ne-n*C+r*ee)*w,e[14]=(m*v-p*b-h*_)*w,e[15]=(l*b-u*v+d*_)*w,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinant();if(i===0)return n.set(1,1,1),t.identity(),this;let a=ht.set(r[0],r[1],r[2]).length(),o=ht.set(r[4],r[5],r[6]).length(),s=ht.set(r[8],r[9],r[10]).length();i<0&&(a=-a),gt.copy(this);let c=1/a,l=1/o,u=1/s;return gt.elements[0]*=c,gt.elements[1]*=c,gt.elements[2]*=c,gt.elements[4]*=l,gt.elements[5]*=l,gt.elements[6]*=l,gt.elements[8]*=u,gt.elements[9]*=u,gt.elements[10]*=u,t.setFromRotationMatrix(gt),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=de,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=de,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},ht=new k,gt=new mt,_t=new k(0,0,0),vt=new k(1,1,1),yt=new k,bt=new k,xt=new k,St=new mt,Ct=new Je,wt=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(D(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-D(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(D(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-D(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(D(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-D(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:T(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return St.makeRotationFromQuaternion(e),this.setFromRotationMatrix(St,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ct.setFromEuler(this),this.setFromQuaternion(Ct,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};wt.DEFAULT_ORDER=`XYZ`;var Tt=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!=0}},Et=0,Dt=new k,Ot=new Je,kt=new mt,At=new k,jt=new k,Mt=new k,Nt=new Je,Pt=new k(1,0,0),Ft=new k(0,1,0),It=new k(0,0,1),Lt={type:`added`},Rt={type:`removed`},zt={type:`childadded`,child:null},Bt={type:`childremoved`,child:null},Vt=class e extends xe{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Et++}),this.uuid=Ee(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new k,n=new wt,r=new Je,i=new k(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new mt},normalMatrix:{value:new Ze}}),this.matrix=new mt,this.matrixWorld=new mt,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Tt,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ot.setFromAxisAngle(e,t),this.quaternion.multiply(Ot),this}rotateOnWorldAxis(e,t){return Ot.setFromAxisAngle(e,t),this.quaternion.premultiply(Ot),this}rotateX(e){return this.rotateOnAxis(Pt,e)}rotateY(e){return this.rotateOnAxis(Ft,e)}rotateZ(e){return this.rotateOnAxis(It,e)}translateOnAxis(e,t){return Dt.copy(e).applyQuaternion(this.quaternion),this.position.add(Dt.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Pt,e)}translateY(e){return this.translateOnAxis(Ft,e)}translateZ(e){return this.translateOnAxis(It,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(kt.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?At.copy(e):At.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),jt.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?kt.lookAt(jt,At,this.up):kt.lookAt(At,jt,this.up),this.quaternion.setFromRotationMatrix(kt),r&&(kt.extractRotation(r.matrixWorld),Ot.setFromRotationMatrix(kt),this.quaternion.premultiply(Ot.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(E(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Lt),zt.child=e,this.dispatchEvent(zt),zt.child=null):E(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Rt),Bt.child=e,this.dispatchEvent(Bt),Bt.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),kt.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),kt.multiply(e.parent.matrixWorld)),e.applyMatrix4(kt),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Lt),zt.child=e,this.dispatchEvent(zt),zt.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(jt,e,Mt),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(jt,Nt,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!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)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>s(s({},e),{},{boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>s({},e)),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};Vt.DEFAULT_UP=new k(0,1,0),Vt.DEFAULT_MATRIX_AUTO_UPDATE=!0,Vt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Ht={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},Ut={h:0,s:0,l:0},Wt={h:0,s:0,l:0};function Gt(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var Kt=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=ae){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,A.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=A.workingColorSpace){return this.r=e,this.g=t,this.b=n,A.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=A.workingColorSpace){if(e=De(e,1),t=D(t,0,1),n=D(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Gt(i,r,e+1/3),this.g=Gt(i,r,e),this.b=Gt(i,r,e-1/3)}return A.colorSpaceToWorking(this,r),this}setStyle(e,t=ae){function n(t){t!==void 0&&parseFloat(t)<1&&T(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:T(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);T(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=ae){let n=Ht[e.toLowerCase()];return n===void 0?T(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=nt(e.r),this.g=nt(e.g),this.b=nt(e.b),this}copyLinearToSRGB(e){return this.r=rt(e.r),this.g=rt(e.g),this.b=rt(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ae){return A.workingToColorSpace(qt.copy(this),e),Math.round(D(qt.r*255,0,255))*65536+Math.round(D(qt.g*255,0,255))*256+Math.round(D(qt.b*255,0,255))}getHexString(e=ae){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=A.workingColorSpace){A.workingToColorSpace(qt.copy(this),t);let n=qt.r,r=qt.g,i=qt.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=A.workingColorSpace){return A.workingToColorSpace(qt.copy(this),t),e.r=qt.r,e.g=qt.g,e.b=qt.b,e}getStyle(e=ae){A.workingToColorSpace(qt.copy(this),e);let t=qt.r,n=qt.g,r=qt.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(Ut),this.setHSL(Ut.h+e,Ut.s+t,Ut.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Ut),e.getHSL(Wt);let n=Ae(Ut.h,Wt.h,t),r=Ae(Ut.s,Wt.s,t),i=Ae(Ut.l,Wt.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},qt=new Kt;Kt.NAMES=Ht;var Jt=new k,Yt=new k,Xt=new k,Zt=new k,Qt=new k,$t=new k,en=new k,tn=new k,nn=new k,rn=new k,an=new j,on=new j,sn=new j,cn=class e{constructor(e=new k,t=new k,n=new k){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Jt.subVectors(e,t),r.cross(Jt);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Jt.subVectors(r,t),Yt.subVectors(n,t),Xt.subVectors(e,t);let a=Jt.dot(Jt),o=Jt.dot(Yt),s=Jt.dot(Xt),c=Yt.dot(Yt),l=Yt.dot(Xt),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Zt)===null?!1:Zt.x>=0&&Zt.y>=0&&Zt.x+Zt.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Zt)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,Zt.x),s.addScaledVector(a,Zt.y),s.addScaledVector(o,Zt.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return an.setScalar(0),on.setScalar(0),sn.setScalar(0),an.fromBufferAttribute(e,t),on.fromBufferAttribute(e,n),sn.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(an,i.x),a.addScaledVector(on,i.y),a.addScaledVector(sn,i.z),a}static isFrontFacing(e,t,n,r){return Jt.subVectors(n,t),Yt.subVectors(e,t),Jt.cross(Yt).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Jt.subVectors(this.c,this.b),Yt.subVectors(this.a,this.b),Jt.cross(Yt).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Qt.subVectors(r,n),$t.subVectors(i,n),tn.subVectors(e,n);let s=Qt.dot(tn),c=$t.dot(tn);if(s<=0&&c<=0)return t.copy(n);nn.subVectors(e,r);let l=Qt.dot(nn),u=$t.dot(nn);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(Qt,a);rn.subVectors(e,i);let f=Qt.dot(rn),p=$t.dot(rn);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector($t,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return en.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(en,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Qt,a).addScaledVector($t,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},ln=class{constructor(e=new k(1/0,1/0,1/0),t=new k(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(dn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(dn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=dn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,dn):dn.fromBufferAttribute(r,t),dn.applyMatrix4(e.matrixWorld),this.expandByPoint(dn);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),fn.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),fn.copy(e.boundingBox)),fn.applyMatrix4(e.matrixWorld),this.union(fn)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,dn),dn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(yn),bn.subVectors(this.max,yn),pn.subVectors(e.a,yn),mn.subVectors(e.b,yn),hn.subVectors(e.c,yn),gn.subVectors(mn,pn),_n.subVectors(hn,mn),vn.subVectors(pn,hn);let t=[0,-gn.z,gn.y,0,-_n.z,_n.y,0,-vn.z,vn.y,gn.z,0,-gn.x,_n.z,0,-_n.x,vn.z,0,-vn.x,-gn.y,gn.x,0,-_n.y,_n.x,0,-vn.y,vn.x,0];return!Cn(t,pn,mn,hn,bn)||(t=[1,0,0,0,1,0,0,0,1],!Cn(t,pn,mn,hn,bn))?!1:(xn.crossVectors(gn,_n),t=[xn.x,xn.y,xn.z],Cn(t,pn,mn,hn,bn))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,dn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(dn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(un[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),un[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),un[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),un[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),un[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),un[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),un[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),un[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(un),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},un=[new k,new k,new k,new k,new k,new k,new k,new k],dn=new k,fn=new ln,pn=new k,mn=new k,hn=new k,gn=new k,_n=new k,vn=new k,yn=new k,bn=new k,xn=new k,Sn=new k;function Cn(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){Sn.fromArray(e,a);let o=i.x*Math.abs(Sn.x)+i.y*Math.abs(Sn.y)+i.z*Math.abs(Sn.z),s=t.dot(Sn),c=n.dot(Sn),l=r.dot(Sn);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var M=new k,wn=new qe,Tn=0,En=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Tn++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=le,this.updateRanges=[],this.gpuType=v,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)wn.fromBufferAttribute(this,t),wn.applyMatrix3(e),this.setXY(t,wn.x,wn.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)M.fromBufferAttribute(this,t),M.applyMatrix3(e),this.setXYZ(t,M.x,M.y,M.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)M.fromBufferAttribute(this,t),M.applyMatrix4(e),this.setXYZ(t,M.x,M.y,M.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)M.fromBufferAttribute(this,t),M.applyNormalMatrix(e),this.setXYZ(t,M.x,M.y,M.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)M.fromBufferAttribute(this,t),M.transformDirection(e),this.setXYZ(t,M.x,M.y,M.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Ge(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=O(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Ge(t,this.array)),t}setX(e,t){return this.normalized&&(t=O(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Ge(t,this.array)),t}setY(e,t){return this.normalized&&(t=O(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Ge(t,this.array)),t}setZ(e,t){return this.normalized&&(t=O(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Ge(t,this.array)),t}setW(e,t){return this.normalized&&(t=O(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=O(t,this.array),n=O(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=O(t,this.array),n=O(n,this.array),r=O(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=O(t,this.array),n=O(n,this.array),r=O(r,this.array),i=O(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==35044&&(e.usage=this.usage),e}},Dn=class extends En{constructor(e,t,n){super(new Uint16Array(e),t,n)}},On=class extends En{constructor(e,t,n){super(new Uint32Array(e),t,n)}},kn=class extends En{constructor(e,t,n){super(new Float32Array(e),t,n)}},An=new ln,jn=new k,Mn=new k,Nn=class{constructor(e=new k,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?An.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;jn.subVectors(e,this.center);let t=jn.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(jn,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Mn.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(jn.copy(e.center).add(Mn)),this.expandByPoint(jn.copy(e.center).sub(Mn))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Pn=0,Fn=new mt,In=new Vt,Ln=new k,Rn=new ln,zn=new ln,N=new k,Bn=class e extends xe{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Pn++}),this.uuid=Ee(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(pe(e)?On:Dn)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new Ze().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Fn.makeRotationFromQuaternion(e),this.applyMatrix4(Fn),this}rotateX(e){return Fn.makeRotationX(e),this.applyMatrix4(Fn),this}rotateY(e){return Fn.makeRotationY(e),this.applyMatrix4(Fn),this}rotateZ(e){return Fn.makeRotationZ(e),this.applyMatrix4(Fn),this}translate(e,t,n){return Fn.makeTranslation(e,t,n),this.applyMatrix4(Fn),this}scale(e,t,n){return Fn.makeScale(e,t,n),this.applyMatrix4(Fn),this}lookAt(e){return In.lookAt(e),In.updateMatrix(),this.applyMatrix4(In.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ln).negate(),this.translate(Ln.x,Ln.y,Ln.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new kn(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&T(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ln);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){E(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new k(-1/0,-1/0,-1/0),new k(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Rn.setFromBufferAttribute(n),this.morphTargetsRelative?(N.addVectors(this.boundingBox.min,Rn.min),this.boundingBox.expandByPoint(N),N.addVectors(this.boundingBox.max,Rn.max),this.boundingBox.expandByPoint(N)):(this.boundingBox.expandByPoint(Rn.min),this.boundingBox.expandByPoint(Rn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&E(`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 Nn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){E(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new k,1/0);return}if(e){let n=this.boundingSphere.center;if(Rn.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];zn.setFromBufferAttribute(n),this.morphTargetsRelative?(N.addVectors(Rn.min,zn.min),Rn.expandByPoint(N),N.addVectors(Rn.max,zn.max),Rn.expandByPoint(N)):(Rn.expandByPoint(zn.min),Rn.expandByPoint(zn.max))}Rn.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)N.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(N));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)N.fromBufferAttribute(a,t),o&&(Ln.fromBufferAttribute(e,t),N.add(Ln)),r=Math.max(r,n.distanceToSquared(N))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&E(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){E(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new En(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new k,s[e]=new k;let c=new k,l=new k,u=new k,d=new qe,f=new qe,p=new qe,m=new k,h=new k;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new k,y=new k,b=new k,x=new k;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e])<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,n)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new En(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new k,i=new k,a=new k,o=new k,s=new k,c=new k,l=new k,u=new k;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)N.fromBufferAttribute(e,t),N.normalize(),e.setXYZ(t,N.x,N.y,N.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new En(a,r,i)}if(this.index===null)return T(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}},Vn=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=le,this.updateRanges=[],this.version=0,this.uuid=Ee()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ee()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ee()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Hn=new k,Un=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Hn.fromBufferAttribute(this,t),Hn.applyMatrix4(e),this.setXYZ(t,Hn.x,Hn.y,Hn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Hn.fromBufferAttribute(this,t),Hn.applyNormalMatrix(e),this.setXYZ(t,Hn.x,Hn.y,Hn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Hn.fromBufferAttribute(this,t),Hn.transformDirection(e),this.setXYZ(t,Hn.x,Hn.y,Hn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Ge(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=O(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=O(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=O(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=O(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=O(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Ge(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ge(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ge(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ge(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=O(t,this.array),n=O(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=O(t,this.array),n=O(n,this.array),r=O(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=O(t,this.array),n=O(n,this.array),r=O(r,this.array),i=O(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){ve(`InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new En(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){ve(`InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Wn=0,Gn=class extends xe{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Wn++}),this.uuid=Ee(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Kt(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ce,this.stencilZFail=ce,this.stencilZPass=ce,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.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){T(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){T(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),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(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(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!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(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!==3&&(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!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(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.allowOverride===!1&&(n.allowOverride=!1),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 r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},Kn=new k,qn=new k,Jn=new k,Yn=new k,Xn=new k,Zn=new k,Qn=new k,$n=class{constructor(e=new k,t=new k(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Kn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Kn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Kn.copy(this.origin).addScaledVector(this.direction,t),Kn.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){qn.copy(e).add(t).multiplyScalar(.5),Jn.copy(t).sub(e).normalize(),Yn.copy(this.origin).sub(qn);let i=e.distanceTo(t)*.5,a=-this.direction.dot(Jn),o=Yn.dot(this.direction),s=-Yn.dot(Jn),c=Yn.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(qn).addScaledVector(Jn,d),f}intersectSphere(e,t){Kn.subVectors(e.center,this.origin);let n=Kn.dot(this.direction),r=Kn.dot(Kn)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Kn)!==null}intersectTriangle(e,t,n,r,i){Xn.subVectors(t,e),Zn.subVectors(n,e),Qn.crossVectors(Xn,Zn);let a=this.direction.dot(Qn),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Yn.subVectors(this.origin,e);let s=o*this.direction.dot(Zn.crossVectors(Yn,Zn));if(s<0)return null;let c=o*this.direction.dot(Xn.cross(Yn));if(c<0||s+c>a)return null;let l=-o*Yn.dot(Qn);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},er=class extends Gn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new Kt(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 wt,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},tr=new mt,nr=new $n,rr=new Nn,ir=new k,ar=new k,or=new k,sr=new k,cr=new k,lr=new k,ur=new k,dr=new k,fr=class extends Vt{constructor(e=new Bn,t=new er){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){lr.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(cr.fromBufferAttribute(s,e),a?lr.addScaledVector(cr,r):lr.addScaledVector(cr.sub(t),r))}t.add(lr)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),rr.copy(n.boundingSphere),rr.applyMatrix4(i),nr.copy(e.ray).recast(e.near),!(rr.containsPoint(nr.origin)===!1&&(nr.intersectSphere(rr,ir)===null||nr.origin.distanceToSquared(ir)>Math.pow(e.far-e.near,2)))&&(tr.copy(i).invert(),nr.copy(e.ray).applyMatrix4(tr),!(n.boundingBox!==null&&nr.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,nr)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=mr(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=mr(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=mr(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=mr(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function pr(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;dr.copy(s),dr.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(dr);return l<n.near||l>n.far?null:{distance:l,point:dr.clone(),object:e}}function mr(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,ar),e.getVertexPosition(c,or),e.getVertexPosition(l,sr);let u=pr(e,t,n,r,ar,or,sr,ur);if(u){let e=new k;cn.getBarycoord(ur,ar,or,sr,e),i&&(u.uv=cn.getInterpolatedAttribute(i,s,c,l,e,new qe)),a&&(u.uv1=cn.getInterpolatedAttribute(a,s,c,l,e,new qe)),o&&(u.normal=cn.getInterpolatedAttribute(o,s,c,l,e,new k),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new k,materialIndex:0};cn.getNormal(ar,or,sr,t.normal),u.face=t,u.barycoord=e}return u}var hr=class extends En{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},gr=new k,_r=new k,vr=new Ze,yr=class{constructor(e=new k(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=gr.subVectors(n,t).cross(_r.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(gr),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||vr.getNormalMatrix(e),r=this.coplanarPoint(gr).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},br=class extends Gn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new Kt(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},xr=class extends Gn{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new Kt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Sr=new mt,Cr=new $n,wr=new Nn,Tr=new k,Er=class extends Vt{constructor(e=new Bn,t=new xr){super(),this.isPoints=!0,this.type=`Points`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),wr.copy(n.boundingSphere),wr.applyMatrix4(r),wr.radius+=i,e.ray.intersectsSphere(wr)===!1)return;Sr.copy(r).invert(),Cr.copy(e.ray).applyMatrix4(Sr);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=n.index,l=n.attributes.position;if(c!==null){let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let a=n,o=i;a<o;a++){let n=c.getX(a);Tr.fromBufferAttribute(l,n),Dr(Tr,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(l.count,a.start+a.count);for(let a=n,o=i;a<o;a++)Tr.fromBufferAttribute(l,a),Dr(Tr,a,s,r,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function Dr(e,t,n,r,i,a,o){let s=Cr.distanceSqToPoint(e);if(s<n){let n=new k;Cr.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var Or=class extends dt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=p,this.minFilter=p,this.generateMipmaps=!1,this.needsUpdate=!0}},kr=class extends dt{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Ar=class extends dt{constructor(e,t,n=_,r,i,a,o=p,s=p,c,l=x,u=1){if(l!==1026&&l!==1027)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new st(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},jr=class extends br{constructor(e){super(),this.isLineDashedMaterial=!0,this.type=`LineDashedMaterial`,this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};function Mr(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}var Nr=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw Error(`call to abstract method`)}intervalChanged_(){}},Pr=class extends Nr{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ne,endingEnd:ne}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case re:i=e,o=2*t-n;break;case ie:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case re:a=e,s=2*n-t;break;case ie:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}},Fr=class extends Nr{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}},Ir=class extends Nr{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Lr=class extends Nr{interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this.settings||this.DefaultSettings_,u=l.inTangents,d=l.outTangents;if(!u||!d){let e=(n-t)/(r-t),l=1-e;for(let t=0;t!==o;++t)i[t]=a[c+t]*l+a[s+t]*e;return i}let f=o*2,p=e-1;for(let l=0;l!==o;++l){let o=a[c+l],m=a[s+l],h=p*f+l*2,g=d[h],_=d[h+1],v=e*f+l*2,y=u[v],b=u[v+1],x=(n-t)/(r-t),S,ee,C,te,ne;for(let e=0;e<8;e++){S=x*x,ee=S*x,C=1-x,te=C*C,ne=te*C;let e=ne*t+3*te*x*g+3*C*S*y+ee*r-n;if(Math.abs(e)<1e-10)break;let i=3*te*(g-t)+6*C*x*(y-g)+3*S*(r-y);if(Math.abs(i)<1e-10)break;x-=e/i,x=Math.max(0,Math.min(1,x))}i[l]=ne*o+3*te*x*_+3*C*S*b+ee*m}return i}},Rr=class{constructor(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=Mr(t,this.TimeBufferType),this.values=Mr(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Mr(e.times,Array),values:Mr(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Ir(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Fr(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Pr(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Lr(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.settings=this.settings),t}setInterpolation(e){let t;switch(e){case S:t=this.InterpolantFactoryMethodDiscrete;break;case ee:t=this.InterpolantFactoryMethodLinear;break;case C:t=this.InterpolantFactoryMethodSmooth;break;case te:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let t=`unsupported interpolation for `+this.ValueTypeName+` keyframe track named `+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(t);return T(`KeyframeTrack:`,t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return S;case this.InterpolantFactoryMethodLinear:return ee;case this.InterpolantFactoryMethodSmooth:return C;case this.InterpolantFactoryMethodBezier:return te}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(E(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(E(`KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){E(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){E(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&me(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){E(`KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===C,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o];if(s!==e[o+1]&&(o!==1||s!==e[0]))if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Rr.prototype.ValueTypeName=``,Rr.prototype.TimeBufferType=Float32Array,Rr.prototype.ValueBufferType=Float32Array,Rr.prototype.DefaultInterpolation=ee;var zr=class extends Rr{constructor(e,t,n){super(e,t,n)}};zr.prototype.ValueTypeName=`bool`,zr.prototype.ValueBufferType=Array,zr.prototype.DefaultInterpolation=S,zr.prototype.InterpolantFactoryMethodLinear=void 0,zr.prototype.InterpolantFactoryMethodSmooth=void 0;var Br=class extends Rr{constructor(e,t,n,r){super(e,t,n,r)}};Br.prototype.ValueTypeName=`color`;var Vr=class extends Rr{constructor(e,t,n,r){super(e,t,n,r)}};Vr.prototype.ValueTypeName=`number`;var Hr=class extends Nr{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)Je.slerpFlat(i,0,a,c-o,a,c,s);return i}},Ur=class extends Rr{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new Hr(this.times,this.values,this.getValueSize(),e)}};Ur.prototype.ValueTypeName=`quaternion`,Ur.prototype.InterpolantFactoryMethodSmooth=void 0;var Wr=class extends Rr{constructor(e,t,n){super(e,t,n)}};Wr.prototype.ValueTypeName=`string`,Wr.prototype.ValueBufferType=Array,Wr.prototype.DefaultInterpolation=S,Wr.prototype.InterpolantFactoryMethodLinear=void 0,Wr.prototype.InterpolantFactoryMethodSmooth=void 0;var Gr=class extends Rr{constructor(e,t,n,r){super(e,t,n,r)}};Gr.prototype.ValueTypeName=`vector`;var Kr={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(qr(e)||(this.files[e]=t))},get:function(e){if(this.enabled!==!1&&!qr(e))return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function qr(e){try{let t=e.slice(e.indexOf(`:`)+1);return new URL(t).protocol===`blob:`}catch(e){return!1}}var Jr=new class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},Yr=class{constructor(e){this.manager=e===void 0?Jr:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}};Yr.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var Xr=new WeakMap,Zr=class extends Yr{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=Kr.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)i.manager.itemStart(e),setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0);else{let e=Xr.get(a);e===void 0&&(e=[],Xr.set(a,e)),e.push({onLoad:t,onError:r})}return a}let o=he(`img`);function s(){l(),t&&t(this);let n=Xr.get(this)||[];for(let e=0;e<n.length;e++){let t=n[e];t.onLoad&&t.onLoad(this)}Xr.delete(this),i.manager.itemEnd(e)}function c(t){l(),r&&r(t),Kr.remove(`image:${e}`);let n=Xr.get(this)||[];for(let e=0;e<n.length;e++){let r=n[e];r.onError&&r.onError(t)}Xr.delete(this),i.manager.itemError(e),i.manager.itemEnd(e)}function l(){o.removeEventListener(`load`,s,!1),o.removeEventListener(`error`,c,!1)}return o.addEventListener(`load`,s,!1),o.addEventListener(`error`,c,!1),e.slice(0,5)!==`data:`&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Kr.add(`image:${e}`,o),i.manager.itemStart(e),o.src=e,o}},Qr=class extends Yr{constructor(e){super(e)}load(e,t,n,r){let i=new dt,a=new Zr(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(e){i.image=e,i.needsUpdate=!0,t!==void 0&&t(i)},n,r),i}},$r=`\\[\\]\\.:\\/`,ei=RegExp(`[\\[\\]\\.:\\/]`,`g`),ti=`[^\\[\\]\\.:\\/]`,ni=`[^`+$r.replace(`\\.`,``)+`]`,ri=`((?:WC+[\\/:])*)`.replace(`WC`,ti),ii=`(WCOD+)?`.replace(`WCOD`,ni),ai=`(?:\\.(WC+)(?:\\[(.+)\\])?)?`.replace(`WC`,ti),oi=`\\.(WC+)(?:\\[(.+)\\])?`.replace(`WC`,ti),si=RegExp(`^`+ri+ii+ai+oi+`$`),ci=[`material`,`materials`,`bones`,`map`],li=class{constructor(e,t,n){let r=n||P.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},P=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(ei,``)}static parseTrackName(e){let t=si.exec(e);if(t===null)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);ci.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r<e.length;r++){let i=e[r];if(i.name===t||i.uuid===t)return i;let a=n(i.children);if(a)return a}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let t=this.node,n=this.parsedPath,r=n.objectName,i=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){T(`PropertyBinding: No target node found for track: `+this.path+`.`);return}if(r){let e=n.objectIndex;switch(r){case`materials`:if(!t.material){E(`PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.materials){E(`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){E(`PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}t=t.skeleton.bones;for(let n=0;n<t.length;n++)if(t[n].name===e){e=n;break}break;case`map`:if(`map`in t){t=t.map;break}if(!t.material){E(`PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.map){E(`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[r]===void 0){E(`PropertyBinding: Can not bind to objectName of node undefined.`,this);return}t=t[r]}if(e!==void 0){if(t[e]===void 0){E(`PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,t);return}t=t[e]}}let o=t[i];if(o===void 0){let e=n.nodeName;E(`PropertyBinding: Trying to update property for track: `+e+`.`+i+` but it wasn't found.`,t);return}let s=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?s=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(s=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(a!==void 0){if(i===`morphTargetInfluences`){if(!t.geometry){E(`PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(!t.geometry.morphAttributes){E(`PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}t.morphTargetDictionary[a]!==void 0&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=a}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};P.Composite=li,P.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},P.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},P.prototype.GetterByBindingType=[P.prototype._getValue_direct,P.prototype._getValue_array,P.prototype._getValue_arrayElement,P.prototype._getValue_toArray],P.prototype.SetterByBindingTypeAndVersioning=[[P.prototype._setValue_direct,P.prototype._setValue_direct_setNeedsUpdate,P.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[P.prototype._setValue_array,P.prototype._setValue_array_setNeedsUpdate,P.prototype._setValue_array_setMatrixWorldNeedsUpdate],[P.prototype._setValue_arrayElement,P.prototype._setValue_arrayElement_setNeedsUpdate,P.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[P.prototype._setValue_fromArray,P.prototype._setValue_fromArray_setNeedsUpdate,P.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var ui=class extends Vn{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},di=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}},fi=new k,pi=new k,mi=new k,hi=new k,gi=new k,_i=new k,vi=new k,yi=class{constructor(e=new k,t=new k){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){fi.subVectors(e,this.start),pi.subVectors(this.end,this.start);let n=pi.dot(pi),r=pi.dot(fi)/n;return t&&(r=D(r,0,1)),r}closestPointToPoint(e,t,n){let r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}distanceSqToLine3(e,t=_i,n=vi){let r=1e-8*1e-8,i,a,o=this.start,s=e.start,c=this.end,l=e.end;mi.subVectors(c,o),hi.subVectors(l,s),gi.subVectors(o,s);let u=mi.dot(mi),d=hi.dot(hi),f=hi.dot(gi);if(u<=r&&d<=r)return t.copy(o),n.copy(s),t.sub(n),t.dot(t);if(u<=r)i=0,a=f/d,a=D(a,0,1);else{let e=mi.dot(gi);if(d<=r)a=0,i=D(-e/u,0,1);else{let t=mi.dot(hi),n=u*d-t*t;i=n===0?0:D((t*f-e*d)/n,0,1),a=(t*i+f)/d,a<0?(a=0,i=D(-e/u,0,1)):a>1&&(a=1,i=D((t-e)/u,0,1))}}return t.copy(o).addScaledVector(mi,i),n.copy(s).addScaledVector(hi,a),t.distanceToSquared(n)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}};typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:`183`}})),typeof window<`u`&&(window.__THREE__?T(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=`183`);var bi=`alphaMap.alphaTest.anisotropy.anisotropyMap.anisotropyRotation.aoMap.aoMapIntensity.attenuationColor.attenuationDistance.bumpMap.clearcoat.clearcoatMap.clearcoatNormalMap.clearcoatNormalScale.clearcoatRoughness.color.dispersion.displacementMap.emissive.emissiveIntensity.emissiveMap.envMap.envMapIntensity.gradientMap.ior.iridescence.iridescenceIOR.iridescenceMap.iridescenceThicknessMap.lightMap.lightMapIntensity.map.matcap.metalness.metalnessMap.normalMap.normalScale.opacity.roughness.roughnessMap.sheen.sheenColor.sheenColorMap.sheenRoughnessMap.shininess.specular.specularColor.specularColorMap.specularIntensity.specularIntensityMap.specularMap.thickness.transmission.transmissionMap`.split(`.`),xi=new WeakMap,Si=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=bi,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){let t=e.getMRT();return t!==null&&t.has(`velocity`)}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){let{geometry:n,material:r,object:i}=e;if(t={material:this.getMaterialData(r),geometry:{id:n.id,attributes:this.getAttributesData(n.attributes),indexId:n.index?n.index.id:null,indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){let{width:n,height:r}=e.context;t.bufferWidth=n,t.bufferHeight=r}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let n in e){let r=e[n];t[n]={id:r.id,version:r.version}}return t}containsNode(e){let t=e.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getMaterialData(e){let t={};for(let n of this.refreshUniforms){let r=e[n];r!=null&&(typeof r==`object`&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r)}return t}equals(e,t){let{object:n,material:r,geometry:i}=e,a=this.getRenderObjectData(e);if(a.worldMatrix.equals(n.matrixWorld)!==!0)return a.worldMatrix.copy(n.matrixWorld),!1;let o=a.material;for(let e in o){let t=o[e],n=r[e];if(t.equals!==void 0){if(t.equals(n)===!1)return t.copy(n),!1}else if(n.isTexture===!0){if(t.id!==n.id||t.version!==n.version)return t.id=n.id,t.version=n.version,!1}else if(t!==n)return o[e]=n,!1}if(o.transmission>0){let{width:t,height:n}=e.context;if(a.bufferWidth!==t||a.bufferHeight!==n)return a.bufferWidth=t,a.bufferHeight=n,!1}let s=a.geometry,c=i.attributes,l=s.attributes,u=Object.keys(l),d=Object.keys(c);if(s.id!==i.id)return s.id=i.id,!1;if(u.length!==d.length)return a.geometry.attributes=this.getAttributesData(c),!1;for(let e of u){let t=l[e],n=c[e];if(n===void 0)return delete l[e],!1;if(t.id!==n.id||t.version!==n.version)return t.id=n.id,t.version=n.version,!1}let f=i.index,p=s.indexId,m=s.indexVersion,h=f?f.id:null,g=f?f.version:null;if(p!==h||m!==g)return s.indexId=h,s.indexVersion=g,!1;if(s.drawRange.start!==i.drawRange.start||s.drawRange.count!==i.drawRange.count)return s.drawRange.start=i.drawRange.start,s.drawRange.count=i.drawRange.count,!1;if(a.morphTargetInfluences){let e=!1;for(let t=0;t<a.morphTargetInfluences.length;t++)a.morphTargetInfluences[t]!==n.morphTargetInfluences[t]&&(a.morphTargetInfluences[t]=n.morphTargetInfluences[t],e=!0);if(e)return!1}if(a.lights){for(let e=0;e<t.length;e++)if(a.lights[e].map!==t[e].map)return!1}return a.center&&a.center.equals(n.center)===!1?(a.center.copy(n.center),!0):(e.bundle!==null&&(a.version=e.bundle.version),!0)}getLightsData(e){let t=[];for(let n of e)n.isSpotLight===!0&&n.map!==null&&t.push({map:n.map.version});return t}getLights(e,t){if(xi.has(e)){let n=xi.get(e);if(n.renderId===t)return n.lightsData}let n=this.getLightsData(e.getLights());return xi.set(e,{renderId:t,lightsData:n}),n}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;let{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;let r=e.object.static===!0,i=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(r||i)return!1;let a=this.getLights(e.lightsNode,n);return this.equals(e,a)!==!0}},Ci=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/];function wi(e){let t=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return e.split(`
256
+ `).map(e=>{let n=e.match(t);if(!n)return null;let r=n[1]||n[2]||``,i=n[3].split(`?`)[0],a=parseInt(n[4],10),o=parseInt(n[5],10);return{fn:r,file:i.split(`/`).pop(),line:a,column:o}}).filter(e=>e&&!Ci.some(t=>t.test(e.file)))}var Ti=class{constructor(e=null){this.isStackTrace=!0,this.stack=wi(e||Error().stack)}getLocation(){if(this.stack.length===0)return`[Unknown location]`;let e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:``}"${e.file}:${e.line}"`}getError(e){return this.stack.length===0?e:`${e}\n${this.stack.map(e=>{let t=`${e.file}:${e.line}:${e.column}`;return e.fn?` at ${e.fn} (${t})`:` at ${t}`}).join(`
257
+ `)}`}};function Ei(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}var Di=e=>Ei(e),Oi=e=>Ei(e),ki=(...e)=>Ei(e),Ai=new Map([[1,`float`],[2,`vec2`],[3,`vec3`],[4,`vec4`],[9,`mat3`],[16,`mat4`]]);function ji(e){return Ai.get(e)}function Mi(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function Ni(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new Kt(...t):n===`vec2`?new qe(...t):n===`vec3`?new k(...t):n===`vec4`?new j(...t):n===`mat2`?new di(...t):n===`mat3`?new Ze(...t):n===`mat4`?new mt(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?Fi(t[0]):null}function Pi(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function Fi(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}var Ii={VERTEX:`vertex`,FRAGMENT:`fragment`},F={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},Li={READ_ONLY:`readOnly`,WRITE_ONLY:`writeOnly`,READ_WRITE:`readWrite`},Ri=[`x`,`y`,`z`,`w`],zi={analyze:`setup`,generate:`analyze`},Bi=0,I=class e extends xe{static get type(){return`Node`}constructor(t=null){super(),this.nodeType=t,this.updateType=F.NONE,this.updateBeforeType=F.NONE,this.updateAfterType=F.NONE,this.uuid=Ke.generateUUID(),this.version=0,this.name=``,this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Bi++}),this.stackTrace=null,e.captureStackTrace===!0&&(this.stackTrace=new Ti)}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,F.FRAME)}onRenderUpdate(e){return this.onUpdate(e,F.RENDER)}onObjectUpdate(e){return this.onUpdate(e,F.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){let t=[];e.add(this);for(let n of Object.getOwnPropertyNames(this)){let r=this[n];if(!(n.startsWith(`_`)===!0||e.has(r))){if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&i.isNode===!0&&t.push({property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)t.push({property:n,childNode:r});else if(r&&Object.getPrototypeOf(r)===Object.prototype)for(let e in r){if(e.startsWith(`_`)===!0)continue;let i=r[e];i&&i.isNode===!0&&t.push({property:n,index:e,childNode:i})}}}return t}getCacheKey(e=!1,t=null){if(e=e||this.version!==this._cacheKeyVersion,e===!0||this._cacheKey===null){t===null&&(t=new Set);let n=[];for(let{property:r,childNode:i}of this._getChildren(t))n.push(Di(r.slice(0,-4)),i.getCacheKey(e,t));this._cacheKey=ki(Oi(n),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return`void`}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e);return e.getNodeFromHash(t)||this}getArrayCount(){return null}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){T(`Abstract function.`)}updateAfter(){T(`Abstract function.`)}update(){T(`Abstract function.`)}before(e){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(e),this}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);if(this._beforeNodes!==null){let n=this._beforeNodes;this._beforeNodes=null;for(let r of n)r.build(e,t);this._beforeNodes=n}let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=zi[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){e.addNode(this),this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}e.addSequentialNode(this)}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){if(this.generate.length<2){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(T(`Node: Recursion detected.`,this),a=`/* Recursion detected. */`):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``;a===``&&t!==null&&t!==`void`&&t!==`OutputType`&&(E(`TSL: Invalid generated code, expected a "${t}".`),a=e.generateConst(t))}return e.removeChain(this),a}getSerializeChildren(){return this._getChildren()}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n])r[i]=t[e.inputNodes[n][i]];this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}};I.captureStackTrace=!1;var Vi=class extends I{static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){let t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`)} ]`}},Hi=class extends I{static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},Ui=class extends I{static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},Wi=class extends Ui{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){E(`TSL: Length of parameters exceeds maximum length of function '${n}()' type.`,this.stackTrace);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;if(s+c>r&&(E(`TSL: Length of '${n}()' data exceeds maximum length of output type.`,this.stackTrace),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i),e.getComponentType(i)!==a){let t=e.getTypeFromLength(c,a);l=e.format(l,i,t)}o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}},Gi=Ri.join(``),Ki=class extends I{static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(Ri.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let o=n.build(e,a);i=this.components.length===r&&this.components===Gi.slice(0,this.components.length)?e.format(o,a,t):e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},qi=class extends Ui{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=Ri[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},Ji=class extends Ui{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=Ri[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},Yi=class extends I{static get type(){return`InputNode`}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Mi(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Mi(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=Pi(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Ni(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){T(`Abstract function.`)}},Xi=/float|u?int/,Zi=class extends Yi{static get type(){return`ConstNode`}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let n=this.getNodeType(e);return Xi.test(n)&&Xi.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},Qi=class extends I{static get type(){return`MemberNode`}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return this.structNode.isMemberNode&&this.structNode.hasMember(e)===!1?!1:this.structNode.getMemberType(e,this.property)!==`void`}getNodeType(e){return this.hasMember(e)===!1?`float`:this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(this.hasMember(e)===!1)return`float`;let n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}generate(e){if(this.hasMember(e)===!1){T(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);let t=this.getNodeType(e);return e.generateConst(t)}return this.structNode.build(e)+`.`+this.property}},$i=null,ea=new Map;function L(e,t){if(ea.has(e)){T(`TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);ea.set(e,t),e!==`assign`&&(I.prototype[e]=function(...e){return this.isStackNode?this.addToStack(t(...e)):t(this,...e)},I.prototype[e+`Assign`]=function(...e){return this.isStackNode?this.assign(e[0],t(...e)):this.assign(t(this,...e))})}var ta=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),na=e=>ta(e).split(``).sort().join(``);I.prototype.assign=function(...e){if(this.isStackNode!==!0)return $i===null?E(`TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().`,new Ti):$i.assign(this,...e),this;{let t=ea.get(`assign`);return this.addToStack(t(...e))}},I.prototype.toVarIntent=function(){return this},I.prototype.get=function(e){return new Qi(this,e)};var ra={};function ia(e,t,n){ra[e]=ra[t]=ra[n]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===void 0&&(t=new Ki(this,e),this._cache[e]=t),t},set(t){this[e].assign(z(t))}};let r=e.toUpperCase(),i=t.toUpperCase(),a=n.toUpperCase();I.prototype[`set`+r]=I.prototype[`set`+i]=I.prototype[`set`+a]=function(t){let n=na(e);return new qi(this,n,z(t))},I.prototype[`flip`+r]=I.prototype[`flip`+i]=I.prototype[`flip`+a]=function(){let t=na(e);return new Ji(this,t)}}var aa=[`x`,`y`,`z`,`w`],oa=[`r`,`g`,`b`,`a`],sa=[`s`,`t`,`p`,`q`];for(let e=0;e<4;e++){let t=aa[e],n=oa[e],r=sa[e];ia(t,n,r);for(let i=0;i<4;i++){t=aa[e]+aa[i],n=oa[e]+oa[i],r=sa[e]+sa[i],ia(t,n,r);for(let a=0;a<4;a++){t=aa[e]+aa[i]+aa[a],n=oa[e]+oa[i]+oa[a],r=sa[e]+sa[i]+sa[a],ia(t,n,r);for(let o=0;o<4;o++)t=aa[e]+aa[i]+aa[a]+aa[o],n=oa[e]+oa[i]+oa[a]+oa[o],r=sa[e]+sa[i]+sa[a]+sa[o],ia(t,n,r)}}}for(let e=0;e<32;e++)ra[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===void 0&&(t=new Vi(this,new Zi(e,`uint`)),this._cache[e]=t),t},set(t){this[e].assign(z(t))}};Object.defineProperties(I.prototype,ra);var ca=new WeakMap,la=function(e,t=null){let n=Mi(e);return n===`node`?e:t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`?z(Oa(e,t)):n===`shader`?e.isFn?e:U(e):e},ua=function(e,t=null){for(let n in e)e[n]=z(e[n],t);return e},da=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=z(e[r],t);return e},fa=function(e,t=null,n=null,r=null){function i(e){return r===null?e=z(e):(e=z(Object.assign(e,r)),r.intent===!0&&(e=e.toVarIntent())),e}let a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(E(`TSL: "${n}" parameter length is less than minimum required.`,new Ti),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(E(`TSL: "${n}" parameter length exceeds limit.`,new Ti),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...Na(l(t)))):n===null?a=(...n)=>i(new e(t,...Na(l(n)))):(n=z(n),a=(...r)=>i(new e(t,...Na(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a},pa=function(e,...t){return new e(...Na(t))},ma=class extends I{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,rawInputs:n}=this,r=e.getNodeProperties(t),i=e.getClosestSubBuild(t.subBuilds)||``,a=i||`default`;if(r[a])return r[a];let o=e.subBuildFn,s=e.fnCall;e.subBuildFn=i,e.fnCall=this;let c=null;if(t.layout){let r=ca.get(e.constructor);r===void 0&&(r=new WeakMap,ca.set(e.constructor,r));let i=r.get(t);i===void 0&&(i=z(e.buildFunctionNode(t)),r.set(t,i)),e.addInclude(i);let a=n?ha(n):null;c=z(i.call(a))}else{let r=new Proxy(e,{get:(e,t,n)=>{let r;return r=Symbol.iterator===t?function*(){yield void 0}:Reflect.get(e,t,n),r}}),i=n?ga(n):null,a=Array.isArray(n)?n.length>0:n!==null,o=t.jsFunc;c=z(a||o.length>1?o(i,r):o(r))}return e.subBuildFn=o,e.fnCall=s,t.once&&(r[a]=c),c}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getSubBuildOutput(this);return t[n]=t[n]||this.setupOutput(e),t[n].subBuild=e.getClosestSubBuild(this),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getSubBuildOutput(this),o=this.getOutputNode(e),s=e.fnCall;if(e.fnCall=this,r===`setup`){let t=e.getSubBuildProperty(`initialized`,this);if(i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e),this.shaderNode.subBuilds))for(let t of e.chaining){let n=e.getDataFromNode(t,`any`);n.subBuilds=n.subBuilds||new Set;for(let e of this.shaderNode.subBuilds)n.subBuilds.add(e)}n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return e.fnCall=s,n}};function ha(e){let t;return Ma(e),t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0],t}function ga(e){let t=0;return Ma(e),new Proxy(e,{get:(n,r,i)=>{let a;if(r===`length`)return a=e.length,a;if(Symbol.iterator===r)a=function*(){for(let t of e)yield z(t)};else{if(e.length>0)if(Object.getPrototypeOf(e[0])===Object.prototype){let n=e[0];a=n[r]===void 0?n[t++]:Reflect.get(n,r,i)}else e[0]instanceof I&&(a=e[r]===void 0?e[t++]:Reflect.get(e,r,i));else a=Reflect.get(n,r,i);a=z(a)}return a}})}var _a=class extends I{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new ma(this,e)}setup(){return this.call()}},va=[!1,!0],ya=[0,1,2,3],ba=[-1,-2],xa=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],Sa=new Map;for(let e of va)Sa.set(e,new Zi(e));var Ca=new Map;for(let e of ya)Ca.set(e,new Zi(e,`uint`));var wa=new Map([...Ca].map(e=>new Zi(e.value,`int`)));for(let e of ba)wa.set(e,new Zi(e,`int`));var Ta=new Map([...wa].map(e=>new Zi(e.value)));for(let e of xa)Ta.set(e,new Zi(e));for(let e of xa)Ta.set(-e,new Zi(-e));var Ea={bool:Sa,uint:Ca,ints:wa,float:Ta},Da=new Map([...Sa,...Ta]),Oa=(e,t)=>Da.has(e)?Da.get(e):e.isNode===!0?e:new Zi(e,t),R=function(e,t=null){return(...n)=>{for(let t of n)if(t===void 0)return E(`TSL: Invalid parameter for the type "${e}".`,new Ti),new Zi(0,e);if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>{let t=typeof e;return t!==`object`&&t!==`function`}))&&(n=[Ni(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return ja(t.get(n[0]));if(n.length===1){let t=Oa(n[0],e);return t.nodeType===e?ja(t):ja(new Hi(t,e))}return ja(new Wi(n.map(e=>Oa(e)),e))}},ka=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function Aa(e,t){return new _a(e,t)}var z=(e,t=null)=>la(e,t),ja=(e,t=null)=>z(e,t).toVarIntent(),Ma=(e,t=null)=>new ua(e,t),Na=(e,t=null)=>new da(e,t),B=(e,t=null,n=null,r=null)=>new fa(e,t,n,r),V=(e,...t)=>new pa(e,...t),H=(e,t=null,n=null,r={})=>new fa(e,t,n,s(s({},r),{},{intent:!0})),Pa=0,Fa=class extends I{constructor(e,t=null){super();let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:E(`TSL: Invalid layout type.`,new Ti),t=null)),this.shaderNode=new Aa(e,n),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){let t=this.shaderNode.nodeType;if(typeof e.inputs!=`object`){let n={name:`fn`+Pa++,type:t,inputs:[]};for(let t in e)t!==`return`&&n.inputs.push({name:t,type:e[t]});e=n}return this.shaderNode.setLayout(e),this}getNodeType(e){return this.shaderNode.getNodeType(e)||`float`}call(...e){let t=this.shaderNode.call(e);return this.shaderNode.nodeType===`void`&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){let t=this.getNodeType(e);return E(`TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".`,this.stackTrace),e.generateConst(t)}};function U(e,t=null){let n=new Fa(e,t);return new Proxy(()=>{},{apply(e,t,r){return n.call(...r)},get(e,t,r){return Reflect.get(n,t,r)},set(e,t,r,i){return Reflect.set(n,t,r,i)}})}var Ia=(...e)=>$i.If(...e);function La(e){return $i&&$i.addToStack(e),e}L(`toStack`,La);var Ra=new R(`color`),W=new R(`float`,Ea.float),G=new R(`int`,Ea.ints),za=new R(`uint`,Ea.uint),Ba=new R(`bool`,Ea.bool),Va=new R(`vec2`),Ha=new R(`ivec2`),Ua=new R(`uvec2`),Wa=new R(`bvec2`),K=new R(`vec3`),Ga=new R(`ivec3`),Ka=new R(`uvec3`),qa=new R(`bvec3`),q=new R(`vec4`),Ja=new R(`ivec4`),Ya=new R(`uvec4`),Xa=new R(`bvec4`),Za=new R(`mat2`),Qa=new R(`mat3`),$a=new R(`mat4`);L(`toColor`,Ra),L(`toFloat`,W),L(`toInt`,G),L(`toUint`,za),L(`toBool`,Ba),L(`toVec2`,Va),L(`toIVec2`,Ha),L(`toUVec2`,Ua),L(`toBVec2`,Wa),L(`toVec3`,K),L(`toIVec3`,Ga),L(`toUVec3`,Ka),L(`toBVec3`,qa),L(`toVec4`,q),L(`toIVec4`,Ja),L(`toUVec4`,Ya),L(`toBVec4`,Xa),L(`toMat2`,Za),L(`toMat3`,Qa),L(`toMat4`,$a),L(`element`,B(Vi).setParameterLength(2)),L(`convert`,(e,t)=>new Hi(z(e),t)),L(`append`,e=>(T(`TSL: .append() has been renamed to .toStack().`,new Ti),La(e)));var eo=class extends I{static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}customCacheKey(){return Di(this.type+`:`+(this.name||``)+`:`+(this.varying?`1`:`0`))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}},to=(e,t)=>new eo(e,t),no=(e,t)=>new eo(e,t,!0),ro=V(eo,`vec4`,`DiffuseColor`),io=V(eo,`vec3`,`EmissiveColor`),ao=V(eo,`vec4`,`Output`),oo=V(eo,`float`,`dashSize`),so=V(eo,`float`,`gapSize`),co=class extends I{static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}},lo=e=>new co(e),uo=(e,t=0)=>new co(e,!0,t),fo=uo(`render`),po=lo(`object`),mo=class extends Yi{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=po}setName(e){return this.name=e,this}label(e){return T(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new Ti),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(t=>{let n=e(t,this);n!==void 0&&(this.value=n)},t)}getInputType(e){let t=super.getInputType(e);return t===`bool`&&(t=`uint`),t}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.nodeName),s=e.getPropertyName(o);e.context.nodeName!==void 0&&delete e.context.nodeName;let c=s;if(n===`bool`){let t=e.getDataFromNode(this),r=t.propertyName;if(r===void 0){let i=e.getVarFromNode(this,null,`bool`);r=e.getPropertyName(i),t.propertyName=r,c=e.format(s,a,n),e.addLineFlowCode(`${r} = ${c}`,this)}c=r}return e.format(c,n,t)}},J=(e,t)=>{let n=ka(t||e);if(n===e&&(e=Ni(n)),e&&e.isNode===!0){let t=e.value;e.traverse(e=>{e.isConstNode===!0&&(t=e.value)}),e=t}return new mo(e,n)},ho=class extends Ui{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(e){return this.nodeType===null?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}},go=(...e)=>{let t;if(e.length===1){let n=e[0];t=new ho(null,n.length,n)}else{let n=e[0],r=e[1];t=new ho(n,r)}return z(t)};L(`toArray`,(e,t)=>go(Array(t).fill(e))),L(`assign`,B(class extends Ui{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e));return Ri.join(``).slice(0,n)!==t.components}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=t.getScope(),i=e.getDataFromNode(r);i.assign=!0;let a=e.getNodeProperties(this);a.sourceNode=n,a.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.build(e),o=n.getNodeType(e),s=r.build(e,o),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=a);else if(i){let r=e.getVarFromNode(this,null,o),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}).build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${l}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=a)}else u=`${a} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=a));return l.initialized=!0,e.format(u,o,t)}}).setParameterLength(2));var _o=class extends Ui{static get type(){return`FunctionCallNode`}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}generate(e){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)E(`TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(E(`TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(W(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(E(`TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(W(0),e))):t.push(a(n,e))}return`${n.build(e,`property`)}( ${t.join(`, `)} )`}};L(`call`,(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?Na(t):Ma(t[0]),new _o(z(e),t)));var vo={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`},Y=class e extends Ui{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(vo[this.op],t)}getNodeType(e,t=null){let n=this.op,r=this.aNode,i=this.bNode,a=r.getNodeType(e),o=i?i.getNodeType(e):null;if(a===`void`||o===`void`)return t||`void`;if(n===`%`)return a;if(n===`~`||n===`&`||n===`|`||n===`^`||n===`>>`||n===`<<`)return e.getIntegerType(a);if(n===`!`||n===`&&`||n===`||`||n===`^^`)return`bool`;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`){let t=Math.max(e.getTypeLength(a),e.getTypeLength(o));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(a)){if(o===`float`)return a;if(e.isVector(o))return e.getVectorFromMatrix(a);if(e.isMatrix(o))return a}else if(e.isMatrix(o)){if(a===`float`)return o;if(e.isVector(a))return e.getVectorFromMatrix(o)}return e.getTypeLength(o)>e.getTypeLength(a)?o:a}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e,t),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===de;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`||n===`~`)return e.format(`(${n}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}},yo=H(Y,`+`).setParameterLength(2,1/0).setName(`add`),bo=H(Y,`-`).setParameterLength(2,1/0).setName(`sub`),xo=H(Y,`*`).setParameterLength(2,1/0).setName(`mul`),So=H(Y,`/`).setParameterLength(2,1/0).setName(`div`),Co=H(Y,`%`).setParameterLength(2).setName(`mod`),wo=H(Y,`==`).setParameterLength(2).setName(`equal`),To=H(Y,`!=`).setParameterLength(2).setName(`notEqual`),Eo=H(Y,`<`).setParameterLength(2).setName(`lessThan`),Do=H(Y,`>`).setParameterLength(2).setName(`greaterThan`),Oo=H(Y,`<=`).setParameterLength(2).setName(`lessThanEqual`),ko=H(Y,`>=`).setParameterLength(2).setName(`greaterThanEqual`),Ao=H(Y,`&&`).setParameterLength(2,1/0).setName(`and`),jo=H(Y,`||`).setParameterLength(2,1/0).setName(`or`),Mo=H(Y,`!`).setParameterLength(1).setName(`not`),No=H(Y,`^^`).setParameterLength(2).setName(`xor`),Po=H(Y,`&`).setParameterLength(2).setName(`bitAnd`),Fo=H(Y,`~`).setParameterLength(1).setName(`bitNot`),Io=H(Y,`|`).setParameterLength(2).setName(`bitOr`),Lo=H(Y,`^`).setParameterLength(2).setName(`bitXor`),Ro=H(Y,`<<`).setParameterLength(2).setName(`shiftLeft`),zo=H(Y,`>>`).setParameterLength(2).setName(`shiftRight`),Bo=U(([e])=>(e.addAssign(1),e)),Vo=U(([e])=>(e.subAssign(1),e)),Ho=U(([e])=>{let t=G(e).toConst();return e.addAssign(1),t}),Uo=U(([e])=>{let t=G(e).toConst();return e.subAssign(1),t});L(`add`,yo),L(`sub`,bo),L(`mul`,xo),L(`div`,So),L(`mod`,Co),L(`equal`,wo),L(`notEqual`,To),L(`lessThan`,Eo),L(`greaterThan`,Do),L(`lessThanEqual`,Oo),L(`greaterThanEqual`,ko),L(`and`,Ao),L(`or`,jo),L(`not`,Mo),L(`xor`,No),L(`bitAnd`,Po),L(`bitNot`,Fo),L(`bitOr`,Io),L(`bitXor`,Lo),L(`shiftLeft`,Ro),L(`shiftRight`,zo),L(`incrementBefore`,Bo),L(`decrementBefore`,Vo),L(`increment`,Ho),L(`decrement`,Uo),L(`modInt`,(e,t)=>(T(`TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`,new Ti),Co(G(e),G(t))));var X=class e extends Ui{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=2;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=bo(1,n);else if(i===e.RECIPROCAL)a=So(1,n);else if(i===e.DIFFERENCE)a=ds(bo(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=q(K(i),0):e=q(K(e),0);let o=xo(e,i).xyz;a=rs(o)}return a===null?super.setup(t):a}generate(t,n){if(t.getNodeProperties(this).outputNode)return super.generate(t,n);let r=this.method,i=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,s=this.bNode,c=this.cNode,l=t.renderer.coordinateSystem;if(r===e.NEGATE)return t.format(`( - `+o.build(t,a)+` )`,i,n);{let u=[];return r===e.CROSS?u.push(o.build(t,i),s.build(t,i)):l===2e3&&r===e.STEP?u.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?`float`:a),s.build(t,a)):l===2e3&&(r===e.MIN||r===e.MAX)?u.push(o.build(t,a),s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:a)):r===e.REFRACT?u.push(o.build(t,a),s.build(t,a),c.build(t,`float`)):r===e.MIX?u.push(o.build(t,a),s.build(t,a),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:a)):(l===2001&&r===e.ATAN&&s!==null&&(r=`atan2`),t.shaderStage!==`fragment`&&(r===e.DFDX||r===e.DFDY)&&(T(`TSL: '${r}' is not supported in the ${t.shaderStage} stage.`,this.stackTrace),r=`/*`+r+`*/`),u.push(o.build(t,a)),s!==null&&u.push(s.build(t,a)),c!==null&&u.push(c.build(t,a))),t.format(`${t.getMethod(r,i)}( ${u.join(`, `)} )`,i,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};X.ALL=`all`,X.ANY=`any`,X.RADIANS=`radians`,X.DEGREES=`degrees`,X.EXP=`exp`,X.EXP2=`exp2`,X.LOG=`log`,X.LOG2=`log2`,X.SQRT=`sqrt`,X.INVERSE_SQRT=`inversesqrt`,X.FLOOR=`floor`,X.CEIL=`ceil`,X.NORMALIZE=`normalize`,X.FRACT=`fract`,X.SIN=`sin`,X.COS=`cos`,X.TAN=`tan`,X.ASIN=`asin`,X.ACOS=`acos`,X.ATAN=`atan`,X.ABS=`abs`,X.SIGN=`sign`,X.LENGTH=`length`,X.NEGATE=`negate`,X.ONE_MINUS=`oneMinus`,X.DFDX=`dFdx`,X.DFDY=`dFdy`,X.ROUND=`round`,X.RECIPROCAL=`reciprocal`,X.TRUNC=`trunc`,X.FWIDTH=`fwidth`,X.TRANSPOSE=`transpose`,X.DETERMINANT=`determinant`,X.INVERSE=`inverse`,X.EQUALS=`equals`,X.MIN=`min`,X.MAX=`max`,X.STEP=`step`,X.REFLECT=`reflect`,X.DISTANCE=`distance`,X.DIFFERENCE=`difference`,X.DOT=`dot`,X.CROSS=`cross`,X.POW=`pow`,X.TRANSFORM_DIRECTION=`transformDirection`,X.MIX=`mix`,X.CLAMP=`clamp`,X.REFRACT=`refract`,X.SMOOTHSTEP=`smoothstep`,X.FACEFORWARD=`faceforward`;var Wo=W(Math.PI);Math.PI*2,Math.PI*2,Math.PI*.5;var Go=H(X,X.ALL).setParameterLength(1),Ko=H(X,X.ANY).setParameterLength(1),qo=H(X,X.RADIANS).setParameterLength(1),Jo=H(X,X.DEGREES).setParameterLength(1),Yo=H(X,X.EXP).setParameterLength(1),Xo=H(X,X.EXP2).setParameterLength(1),Zo=H(X,X.LOG).setParameterLength(1),Qo=H(X,X.LOG2).setParameterLength(1),$o=H(X,X.SQRT).setParameterLength(1),es=H(X,X.INVERSE_SQRT).setParameterLength(1),ts=H(X,X.FLOOR).setParameterLength(1),ns=H(X,X.CEIL).setParameterLength(1),rs=H(X,X.NORMALIZE).setParameterLength(1),is=H(X,X.FRACT).setParameterLength(1),as=H(X,X.SIN).setParameterLength(1),os=H(X,X.COS).setParameterLength(1),ss=H(X,X.TAN).setParameterLength(1),cs=H(X,X.ASIN).setParameterLength(1),ls=H(X,X.ACOS).setParameterLength(1),us=H(X,X.ATAN).setParameterLength(1,2),ds=H(X,X.ABS).setParameterLength(1),fs=H(X,X.SIGN).setParameterLength(1),ps=H(X,X.LENGTH).setParameterLength(1),ms=H(X,X.NEGATE).setParameterLength(1),hs=H(X,X.ONE_MINUS).setParameterLength(1),gs=H(X,X.DFDX).setParameterLength(1),_s=H(X,X.DFDY).setParameterLength(1),vs=H(X,X.ROUND).setParameterLength(1),ys=H(X,X.RECIPROCAL).setParameterLength(1),bs=H(X,X.TRUNC).setParameterLength(1),xs=H(X,X.FWIDTH).setParameterLength(1),Ss=H(X,X.TRANSPOSE).setParameterLength(1),Cs=H(X,X.DETERMINANT).setParameterLength(1),ws=H(X,X.INVERSE).setParameterLength(1),Ts=H(X,X.MIN).setParameterLength(2,1/0),Es=H(X,X.MAX).setParameterLength(2,1/0),Ds=H(X,X.STEP).setParameterLength(2),Os=H(X,X.REFLECT).setParameterLength(2),ks=H(X,X.DISTANCE).setParameterLength(2),As=H(X,X.DIFFERENCE).setParameterLength(2),js=H(X,X.DOT).setParameterLength(2),Ms=H(X,X.CROSS).setParameterLength(2),Ns=H(X,X.POW).setParameterLength(2),Ps=e=>xo(e,e),Fs=e=>xo(e,e,e),Is=e=>xo(e,e,e,e),Ls=H(X,X.TRANSFORM_DIRECTION).setParameterLength(2),Rs=e=>xo(fs(e),Ns(ds(e),1/3)),zs=e=>js(e,e),Bs=H(X,X.MIX).setParameterLength(3),Vs=(e,t=0,n=1)=>new X(X.CLAMP,z(e),z(t),z(n)),Hs=e=>Vs(e),Us=H(X,X.REFRACT).setParameterLength(3),Ws=H(X,X.SMOOTHSTEP).setParameterLength(3),Gs=H(X,X.FACEFORWARD).setParameterLength(3),Ks=U(([e])=>is(as(Co(js(e.xy,Va(12.9898,78.233)),Wo)).mul(43758.5453)));L(`all`,Go),L(`any`,Ko),L(`radians`,qo),L(`degrees`,Jo),L(`exp`,Yo),L(`exp2`,Xo),L(`log`,Zo),L(`log2`,Qo),L(`sqrt`,$o),L(`inverseSqrt`,es),L(`floor`,ts),L(`ceil`,ns),L(`normalize`,rs),L(`fract`,is),L(`sin`,as),L(`cos`,os),L(`tan`,ss),L(`asin`,cs),L(`acos`,ls),L(`atan`,us),L(`abs`,ds),L(`sign`,fs),L(`length`,ps),L(`lengthSq`,zs),L(`negate`,ms),L(`oneMinus`,hs),L(`dFdx`,gs),L(`dFdy`,_s),L(`round`,vs),L(`reciprocal`,ys),L(`trunc`,bs),L(`fwidth`,xs),L(`min`,Ts),L(`max`,Es),L(`step`,(e,t)=>Ds(t,e)),L(`reflect`,Os),L(`distance`,ks),L(`dot`,js),L(`cross`,Ms),L(`pow`,Ns),L(`pow2`,Ps),L(`pow3`,Fs),L(`pow4`,Is),L(`transformDirection`,Ls),L(`mix`,(e,t,n)=>Bs(t,n,e)),L(`clamp`,Vs),L(`refract`,Us),L(`smoothstep`,(e,t,n)=>Ws(t,n,e)),L(`faceForward`,Gs),L(`difference`,As),L(`saturate`,Hs),L(`cbrt`,Rs),L(`transpose`,Ss),L(`determinant`,Cs),L(`inverse`,ws),L(`rand`,Ks);var qs=B(class extends I{static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,`setup`),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode,n=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.context.uniformFlow,o=e.getNodeProperties(this);o.condNode=t,o.ifNode=a?n:n.context({nodeBlock:n}),o.elseNode=r?a?r:r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?to(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);if(e.context.uniformFlow&&o!==null){let r=a.build(e,n),i=o.build(e,n),s=e.getTernary(u,r,i);return e.format(s,n,t)}e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(T(`TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`,this.stackTrace),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
258
+
259
+ `+e.tab+`}`),o!==null){e.addFlowCode(` else {
260
+
261
+ `).addFlowTab();let t=o.build(e,n);t&&(c?t=l+` = `+t+`;`:(t=`return `+t+`;`,s===null&&(T(`TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`,this.stackTrace),t=`// `+t))),e.removeFlowTab().addFlowCode(e.tab+` `+t+`
262
+
263
+ `+e.tab+`}
264
+
265
+ `)}else e.addFlowCode(`
266
+
267
+ `);return e.format(l,n,t)}}).setParameterLength(2,3);L(`select`,qs);var Js=class extends I{static get type(){return`ContextNode`}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){let e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){let n=e.addContext(this.value),r=this.node.build(e,t);return e.setContext(n),r}},Ys=(e=null,t={})=>{let n=e;return(n===null||n.isNode!==!0)&&(t=n||t,n=null),new Js(n,t)},Xs=e=>Ys(e,{uniformFlow:!0}),Zs=(e,t)=>Ys(e,{nodeName:t});function Qs(e,t,n=null){return Ys(n,{getShadow:({light:n,shadowColorNode:r})=>t===n?r.mul(e):r})}function $s(e,t=null){return Ys(t,{getAO:(t,{material:n})=>n.transparent===!0?t:t===null?e:t.mul(e)})}function ec(e,t){return T(`TSL: "label()" has been deprecated. Use "setName()" instead.`),Zs(e,t)}L(`context`,Ys),L(`label`,ec),L(`uniformFlow`,Xs),L(`setName`,Zs),L(`builtinShadowContext`,(e,t,n)=>Qs(t,n,e)),L(`builtinAOContext`,(e,t)=>$s(t,e));var tc=B(class extends I{static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return e.getDataFromNode(this).forceDeclaration===!0?!1:this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){let t=e[0];if(this._hasStack(t)===!1&&t.buildStage===`setup`&&(t.context.nodeLoop||t.context.nodeBlock)){let e=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){let n=t.getDataFromNode(this);n.forceDeclaration=!0,e=!0}let n=t.getBaseStack();e?n.addToStackBefore(this):n.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=this.getNodeType(e);if(c==`void`)return this.isIntent(e)!==!0&&E(`TSL: ".toVar()" can not be used with void type.`,this.stackTrace),t.build(e);let l=e.getVectorType(c),u=t.build(e,l),d=e.getVarFromNode(this,n,l,void 0,s),f=e.getPropertyName(d),p=f;if(s)if(a)p=o?`const ${f}`:`let ${f}`;else{let n=t.getArrayCount(e);p=`const ${e.getVar(d.type,f,n)}`}return e.addLineFlowCode(`${p} = ${u}`,this),f}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}});L(`toVar`,(e,t=null)=>tc(e,t).toStack()),L(`toConst`,(e,t=null)=>tc(e,t,!0).toStack()),L(`toVarIntent`,e=>tc(e).setIntent(!0).toStack());var nc=class extends I{static get type(){return`SubBuild`}constructor(e,t,n=null){super(n),this.node=e,this.name=t,this.isSubBuildNode=!0}getNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);let t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);let n=this.node.build(e,...t);return e.removeSubBuild(),n}},rc=(e,t,n=null)=>new nc(z(e),t,n),ic=B(class extends I{static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=rc(e,`VERTEX`),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){let t=e.getNodeProperties(this),n=t.varying;if(n===void 0){let r=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,r,i,a,o),t.node=rc(this.node,`VERTEX`)}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage===`fragment`),n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ii.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ii.VERTEX,this.node)}generate(e){let t=e.getSubBuildProperty(`property`,e.currentStack),n=e.getNodeProperties(this),r=this.setupVarying(e);if(n[t]===void 0){let i=this.getNodeType(e),a=e.getPropertyName(r,Ii.VERTEX);e.flowNodeFromShaderStage(Ii.VERTEX,n.node,i,a),n[t]=a}return e.getPropertyName(r)}}).setParameterLength(1,2);L(`toVarying`,ic),L(`toVertexStage`,e=>ic(e));var ac=U(([e])=>Bs(e.mul(.9478672986).add(.0521327014).pow(2.4),e.mul(.0773993808),e.lessThanEqual(.04045))).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),oc=U(([e])=>Bs(e.pow(.41666).mul(1.055).sub(.055),e.mul(12.92),e.lessThanEqual(.0031308))).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),sc=`WorkingColorSpace`,cc=`OutputColorSpace`,lc=class extends Ui{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===sc?A.workingColorSpace:t===cc?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return A.enabled===!1||n===r||!n||!r?i:(A.getTransfer(n)===`srgb`&&(i=q(ac(i.rgb),i.a)),A.getPrimaries(n)!==A.getPrimaries(r)&&(i=q(Qa(A._getMatrix(new Ze,n,r)).mul(i.rgb),i.a)),A.getTransfer(r)===`srgb`&&(i=q(oc(i.rgb),i.a)),i)}},uc=(e,t)=>new lc(z(e),sc,t),dc=(e,t)=>new lc(z(e),t,sc);L(`workingToColorSpace`,uc),L(`colorSpaceToWorking`,dc);var fc=class extends Vi{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},pc=class extends I{static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=F.OBJECT}setGroup(e){return this.group=e,this}element(e){return new fc(this,z(e))}setNodeType(e){let t=J(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},mc=class extends pc{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(fo)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}},hc=(e,t,n=null)=>new mc(e,t,n),gc=class extends Ui{static get type(){return`ToneMappingNode`}constructor(e,t=vc,n=null){super(`vec3`),this._toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return ki(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){let t=this.colorNode||e.context.color,n=this._toneMapping;if(n===0)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(E(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=q(i(t.rgb,this.exposureNode),t.a),r}},_c=(e,t,n)=>new gc(e,z(t),z(n)),vc=hc(`toneMappingExposure`,`float`);L(`toneMapping`,(e,t,n)=>_c(t,n,e));var yc=new WeakMap;function bc(e,t){let n=yc.get(e);return n===void 0&&(n=new Vn(e,t),yc.set(e,n)),n}var xc=class extends Yi{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=le,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),n=e.getTypeLength(t),r=this.value,i=this.bufferStride||n,a=this.bufferOffset,o;o=r.isInterleavedBuffer===!0?r:r.isBufferAttribute===!0?bc(r.array,i):bc(r,i);let s=new Un(o,n,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n),i=null;return e.shaderStage===`vertex`||e.shaderStage===`compute`?(this.name=r,i=r):i=ic(this).build(e,t),i}getInputType(){return`bufferAttribute`}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};function Sc(e,t=null,n=0,r=0,i=le,a=!1){return t===`mat3`||t===null&&e.itemSize===9?Qa(new xc(e,`vec3`,9,0).setUsage(i).setInstanced(a),new xc(e,`vec3`,9,3).setUsage(i).setInstanced(a),new xc(e,`vec3`,9,6).setUsage(i).setInstanced(a)):t===`mat4`||t===null&&e.itemSize===16?$a(new xc(e,`vec4`,16,0).setUsage(i).setInstanced(a),new xc(e,`vec4`,16,4).setUsage(i).setInstanced(a),new xc(e,`vec4`,16,8).setUsage(i).setInstanced(a),new xc(e,`vec4`,16,12).setUsage(i).setInstanced(a)):new xc(e,t,n,r).setUsage(i)}var Cc=(e,t=null,n=0,r=0)=>Sc(e,t,n,r),wc=(e,t=null,n=0,r=0)=>Sc(e,t,n,r,le,!0),Tc=(e,t=null,n=0,r=0)=>Sc(e,t,n,r,ue,!0);L(`toAttribute`,e=>Cc(e.value));var Ec=class extends I{static get type(){return`ComputeNode`}constructor(e,t){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.version=1,this.name=``,this.updateBeforeType=F.OBJECT,this.onInitFunction=null}setCount(e){return this.count=e,this}getCount(){return this.count}dispose(){this.dispatchEvent({type:`dispose`})}setName(e){return this.name=e,this}label(e){return T(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new Ti),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);t!==``&&e.addLineFlowCode(t,this)}else{let n=e.getNodeProperties(this).outputComputeNode;if(n)return n.build(e,t)}}},Dc=(e,t=[64])=>{(t.length===0||t.length>3)&&E(`TSL: compute() workgroupSize must have 1, 2, or 3 elements`,new Ti);for(let e=0;e<t.length;e++){let n=t[e];(typeof n!=`number`||n<=0||!Number.isInteger(n))&&E(`TSL: compute() workgroupSize element at index [ ${e} ] must be a positive integer`,new Ti)}for(;t.length<3;)t.push(1);return new Ec(z(e),t)};L(`compute`,(e,t,n)=>Dc(e,n).setCount(t)),L(`computeKernel`,Dc);var Oc=class extends I{static get type(){return`IsolateNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}getNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}setParent(e){return this.parent=e,this}getParent(){return this.parent}},kc=e=>new Oc(z(e));function Ac(e,t=!0){return T(`TSL: "cache()" has been deprecated. Use "isolate()" instead.`),kc(e).setParent(t)}L(`cache`,Ac),L(`isolate`,kc),L(`bypass`,B(class extends I{static get type(){return`BypassNode`}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}).setParameterLength(2));var jc=class extends I{static get type(){return`RemapNode`}constructor(e,t,n,r=W(0),i=W(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=i,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:i,doClamp:a}=this,o=e.sub(t).div(n.sub(t));return a===!0&&(o=o.clamp()),o.mul(i.sub(r)).add(r)}},Mc=B(jc,null,null,{doClamp:!1}).setParameterLength(3,5),Nc=B(jc).setParameterLength(3,5);L(`remap`,Mc),L(`remapClamp`,Nc);var Pc=B(class extends I{static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}}).setParameterLength(1,2);L(`discard`,e=>(e?qs(e,Pc(`discard`)):Pc(`discard`)).toStack());var Fc=class extends Ui{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color,n=(this._toneMapping===null?e.toneMapping:this._toneMapping)||0,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||``;return n!==0&&(t=t.toneMapping(n)),r!==``&&r!==A.workingColorSpace&&(t=t.workingToColorSpace(r)),t}};L(`renderOutput`,(e,t=null,n=null)=>new Fc(z(e),t,n));var Ic=class extends Ui{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e);if(t!==null)t(e,n);else{let t=`--- TSL debug - `+e.shaderStage+` shader ---`,r=`-`.repeat(t.length),i=``;i+=`// #`+t+`#
268
+ `,i+=e.flow.code.replace(/^\t/gm,``)+`
269
+ `,i+=`/* ... */ `+n+` /* ... */
270
+ `,i+=`// #`+r+`#
271
+ `,ve(i)}return n}};L(`debug`,(e,t=null)=>new Ic(z(e),t).toStack());var Lc=class{constructor(){this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}},Rc=class extends I{static get type(){return`InspectorNode`}constructor(e,t=``,n=null){super(),this.node=e,this.name=t,this.callback=n,this.updateType=F.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}getNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==Lc&&be(`TSL: ".toInspector()" is only available with WebGPU.`),t}};function zc(e,t=``,n=null){return e=z(e),e.before(new Rc(e,t,n))}L(`toInspector`,zc);var Bc=class extends I{static get type(){return`AttributeNode`}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){let n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){let r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t=`float`}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){let r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),a=e.getAttribute(t,i);return e.shaderStage===`vertex`?e.format(a.name,i,n):ic(this).build(e,n)}else return T(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}},Vc=(e,t=null)=>new Bc(e,t),Hc=(e=0)=>Vc(`uv`+(e>0?e:``),`vec2`),Uc=B(class extends I{static get type(){return`TextureSizeNode`}constructor(e,t=null){super(`uvec2`),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let n=this.textureNode.build(e,`property`),r=this.levelNode===null?`0`:this.levelNode.build(e,`int`);return e.format(`${e.getMethod(`textureDimensions`)}( ${n}, ${r} )`,this.getNodeType(e),t)}}).setParameterLength(1,2),Wc=B(class extends mo{static get type(){return`MaxMipLevelNode`}constructor(e){super(0),this._textureNode=e,this.updateType=F.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){let{width:e,height:t}=n;this.value=Math.log2(Math.max(e,t))}}}).setParameterLength(1),Gc=class extends Error{constructor(e,t=null){super(e),this.name=`NodeError`,this.stackTrace=t}},Kc=new dt,qc=class extends mo{static get type(){return`TextureNode`}constructor(e=Kc,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=F.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?`float`:this.value.type===1014?`uvec4`:this.value.type===1013?`ivec4`:`vec4`}getInputType(){return`texture`}getDefaultUV(){return Hc(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=J(this.value.matrix)),this._matrixUniform.mul(K(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=J(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY(G(Uc(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.value;if(!n||n.isTexture!==!0)throw new Gc("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);let r=U(()=>{let t=this.uvNode;return(t===null||e.context.forceUVContext===!0)&&e.context.getUV&&(t=e.context.getUV(this,e)),t||(t=this.getDefaultUV()),this.updateMatrix===!0&&(t=this.getTransformedUV(t)),t=this.setupUV(e,t),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?F.OBJECT:F.NONE,t})(),i=this.levelNode;i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this));let a=null,o=null;if(this.compareNode!==null)if(e.renderer.hasCompatibility(fe.TEXTURE_COMPARE))a=this.compareNode;else{let e=n.compareFunction;e===null||e===513||e===515||e===516||e===518?o=this.compareNode:(a=this.compareNode,be(`TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.`))}t.uvNode=r,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=a,t.compareStepNode=o,t.gradNode=this.gradNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?`vec2`:`ivec2`)}generateOffset(e,t){return t.build(e,`ivec2`)}generateSnippet(e,t,n,r,i,a,o,s,c){let l=this.value,u;return u=i?e.generateTextureBias(l,t,n,i,a,c):s?e.generateTextureGrad(l,t,n,s,a,c):o?e.generateTextureCompare(l,t,n,o,a,c):this.sampler===!1?e.generateTextureLoad(l,t,n,r,a,c):r?e.generateTextureLevel(l,t,n,r,a,c):e.generateTexture(l,t,n,a,c),u}generate(e,t){let n=this.value,r=e.getNodeProperties(this),i=super.generate(e,`property`);if(/^sampler/.test(t))return i+`_sampler`;if(e.isReference(t))return i;{let a=e.getDataFromNode(this),o=this.getNodeType(e),s=a.propertyName;if(s===void 0){let{uvNode:t,levelNode:c,biasNode:l,compareNode:u,compareStepNode:d,depthNode:f,gradNode:p,offsetNode:m}=r,h=this.generateUV(e,t),g=c?c.build(e,`float`):null,_=l?l.build(e,`float`):null,v=f?f.build(e,`int`):null,y=u?u.build(e,`float`):null,b=d?d.build(e,`float`):null,x=p?[p[0].build(e,`vec2`),p[1].build(e,`vec2`)]:null,S=m?this.generateOffset(e,m):null,ee=e.getVarFromNode(this);s=e.getPropertyName(ee);let C=this.generateSnippet(e,i,h,g,_,v,y,x,S);if(b!==null){let t=n.compareFunction;C=t===516||t===518?Ds(Pc(C,o),Pc(b,`float`)).build(e,o):Ds(Pc(b,`float`),Pc(C,o)).build(e,o)}e.addLineFlowCode(`${s} = ${C}`,this),a.snippet=C,a.propertyName=s}let c=s;return e.needsToWorkingColorSpace(n)&&(c=dc(Pc(c,o),n.colorSpace).setup(e).build(e,o)),e.format(c,o,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){let t=this.clone();return t.uvNode=z(e),t.referenceNode=this.getBase(),z(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){let t=this.clone();t.biasNode=z(e).mul(Wc(t)),t.referenceNode=this.getBase();let n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===1003||n.magFilter===1003)&&(T(`TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture.`),t.biasNode=null),z(t)}level(e){let t=this.clone();return t.levelNode=z(e),t.referenceNode=this.getBase(),z(t)}size(e){return Uc(this,e)}bias(e){let t=this.clone();return t.biasNode=z(e),t.referenceNode=this.getBase(),z(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){let t=this.clone();return t.compareNode=z(e),t.referenceNode=this.getBase(),z(t)}grad(e,t){let n=this.clone();return n.gradNode=[z(e),z(t)],n.referenceNode=this.getBase(),z(n)}depth(e){let t=this.clone();return t.depthNode=z(e),t.referenceNode=this.getBase(),z(t)}offset(e){let t=this.clone();return t.offsetNode=z(e),t.referenceNode=this.getBase(),z(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){let e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();let n=this._flipYUniform;n!==null&&(n.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}},Jc=B(qc).setParameterLength(1,4).setName(`texture`),Yc=(e=Kc,t=null,n=null,r=null)=>{let i;return e&&e.isTextureNode===!0?(i=z(e.clone()),i.referenceNode=e.getBase(),t!==null&&(i.uvNode=z(t)),n!==null&&(i.levelNode=z(n)),r!==null&&(i.biasNode=z(r))):i=Jc(e,t,n,r),i},Xc=(...e)=>Yc(...e).setSampler(!1),Zc=class extends mo{static get type(){return`BufferNode`}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return`buffer`}},Qc=(e,t,n)=>new Zc(e,t,n),$c=class extends Vi{static get type(){return`UniformArrayElementNode`}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}},el=class extends Zc{static get type(){return`UniformArrayNode`}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?Mi(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=F.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t=`vec4`;return e===`mat2`?t=`mat2`:/mat/.test(e)===!0?t=`mat4`:e.charAt(0)===`i`?t=`ivec4`:e.charAt(0)===`u`&&(t=`uvec4`),t}update(){let{array:e,value:t}=this,n=this.elementType;if(n===`float`||n===`int`||n===`uint`)for(let n=0;n<e.length;n++){let r=n*4;t[r]=e[n]}else if(n===`color`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.r,t[r+1]=i.g,t[r+2]=i.b||0}else if(n===`mat2`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+3]=i.elements[3]}else if(n===`mat3`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+4]=i.elements[3],t[r+5]=i.elements[4],t[r+6]=i.elements[5],t[r+8]=i.elements[6],t[r+9]=i.elements[7],t[r+10]=i.elements[8],t[r+15]=1}else if(n===`mat4`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];for(let e=0;e<i.elements.length;e++)t[r+e]=i.elements[e]}else for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.x,t[r+1]=i.y,t[r+2]=i.z||0,t[r+3]=i.w||0}}setup(e){let t=this.array.length,n=this.elementType,r=Float32Array,i=this.paddedType,a=e.getTypeLength(i);return n.charAt(0)===`i`&&(r=Int32Array),n.charAt(0)===`u`&&(r=Uint32Array),this.value=new r(t*a),this.bufferCount=t,this.bufferType=i,this.update(),super.setup(e)}element(e){return new $c(this,z(e))}},tl=(e,t)=>new el(e,t),nl=B(class extends I{constructor(e){super(`float`),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),rl,il,al=class e extends I{static get type(){return`ScreenNode`}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===e.DPR?`float`:this.scope===e.VIEWPORT?`vec4`:`vec2`}getUpdateType(){let t=F.NONE;return(this.scope===e.SIZE||this.scope===e.VIEWPORT||this.scope===e.DPR)&&(t=F.RENDER),this.updateType=t,t}update({renderer:t}){let n=t.getRenderTarget();this.scope===e.VIEWPORT?n===null?(t.getViewport(il),il.multiplyScalar(t.getPixelRatio())):il.copy(n.viewport):this.scope===e.DPR?this._output.value=t.getPixelRatio():n===null?t.getDrawingBufferSize(rl):(rl.width=n.width,rl.height=n.height)}setup(){let t=this.scope,n=null;return n=t===e.SIZE?J(rl||(rl=new qe)):t===e.VIEWPORT?J(il||(il=new j)):t===e.DPR?J(1):Va(ll.div(cl)),this._output=n,n}generate(t){if(this.scope===e.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let n=t.getNodeProperties(cl).outputNode.build(t);e=`${t.getType(`vec2`)}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}};al.COORDINATE=`coordinate`,al.VIEWPORT=`viewport`,al.SIZE=`size`,al.UV=`uv`,al.DPR=`dpr`;var ol=V(al,al.DPR),sl=V(al,al.UV),cl=V(al,al.SIZE),ll=V(al,al.COORDINATE),ul=V(al,al.VIEWPORT);ul.zw,ul.xy;var dl=null,fl=null,pl=null,ml=null,hl=null,gl=null,_l=J(0,`uint`).setName(`u_cameraIndex`).setGroup(uo(`cameraIndex`)).toVarying(`v_cameraIndex`),vl=J(`float`).setName(`cameraNear`).setGroup(fo).onRenderUpdate(({camera:e})=>e.near),yl=J(`float`).setName(`cameraFar`).setGroup(fo).onRenderUpdate(({camera:e})=>e.far),bl=U(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrix);fl===null?fl=tl(n).setGroup(fo).setName(`cameraProjectionMatrices`):fl.array=n,t=fl.element(e.isMultiViewCamera?nl(`gl_ViewID_OVR`):_l).toConst(`cameraProjectionMatrix`)}else dl===null&&(dl=J(e.projectionMatrix).setName(`cameraProjectionMatrix`).setGroup(fo).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=dl;return t}).once()(),xl=U(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrixInverse);ml===null?ml=tl(n).setGroup(fo).setName(`cameraProjectionMatricesInverse`):ml.array=n,t=ml.element(e.isMultiViewCamera?nl(`gl_ViewID_OVR`):_l).toConst(`cameraProjectionMatrixInverse`)}else pl===null&&(pl=J(e.projectionMatrixInverse).setName(`cameraProjectionMatrixInverse`).setGroup(fo).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=pl;return t}).once()(),Sl=U(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorldInverse);gl===null?gl=tl(n).setGroup(fo).setName(`cameraViewMatrices`):gl.array=n,t=gl.element(e.isMultiViewCamera?nl(`gl_ViewID_OVR`):_l).toConst(`cameraViewMatrix`)}else hl===null&&(hl=J(e.matrixWorldInverse).setName(`cameraViewMatrix`).setGroup(fo).onRenderUpdate(({camera:e})=>e.matrixWorldInverse)),t=hl;return t}).once()(),Cl=new Nn,wl=class e extends I{static get type(){return`Object3DNode`}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=F.OBJECT,this.uniformNode=new mo(null)}getNodeType(){let t=this.scope;if(t===e.WORLD_MATRIX)return`mat4`;if(t===e.POSITION||t===e.VIEW_POSITION||t===e.DIRECTION||t===e.SCALE)return`vec3`;if(t===e.RADIUS)return`float`}update(t){let n=this.object3d,r=this.uniformNode,i=this.scope;if(i===e.WORLD_MATRIX)r.value=n.matrixWorld;else if(i===e.POSITION)r.value=r.value||new k,r.value.setFromMatrixPosition(n.matrixWorld);else if(i===e.SCALE)r.value=r.value||new k,r.value.setFromMatrixScale(n.matrixWorld);else if(i===e.DIRECTION)r.value=r.value||new k,n.getWorldDirection(r.value);else if(i===e.VIEW_POSITION){let e=t.camera;r.value=r.value||new k,r.value.setFromMatrixPosition(n.matrixWorld),r.value.applyMatrix4(e.matrixWorldInverse)}else if(i===e.RADIUS){let e=t.object.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Cl.copy(e.boundingSphere).applyMatrix4(n.matrixWorld),r.value=Cl.radius}}generate(t){let n=this.scope;return n===e.WORLD_MATRIX?this.uniformNode.nodeType=`mat4`:n===e.POSITION||n===e.VIEW_POSITION||n===e.DIRECTION||n===e.SCALE?this.uniformNode.nodeType=`vec3`:n===e.RADIUS&&(this.uniformNode.nodeType=`float`),this.uniformNode.build(t)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}};wl.WORLD_MATRIX=`worldMatrix`,wl.POSITION=`position`,wl.SCALE=`scale`,wl.VIEW_POSITION=`viewPosition`,wl.DIRECTION=`direction`,wl.RADIUS=`radius`;var Tl=class extends wl{static get type(){return`ModelNode`}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}};Tl.DIRECTION;var El=V(Tl,Tl.WORLD_MATRIX);Tl.POSITION,Tl.SCALE,Tl.VIEW_POSITION,Tl.RADIUS;var Dl=J(new Ze).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),Ol=U(e=>e.context.modelViewMatrix||kl).once()().toVar(`modelViewMatrix`),kl=Sl.mul(El),Al=U(e=>e.shaderStage===`fragment`?e.context.clipSpace.toVarying(`v_clipSpace`):(be("TSL: `clipSpace` is only available in fragment stage."),q())).once()(),jl=Vc(`position`,`vec3`),Ml=jl.toVarying(`positionLocal`),Nl=jl.toVarying(`positionPrevious`),Pl=U(e=>El.mul(Ml).xyz.toVarying(e.getSubBuildProperty(`v_positionWorld`)),`vec3`).once([`POSITION`])(),Z=U(e=>{if(e.shaderStage===`fragment`&&e.material.vertexNode){let e=xl.mul(Al);return e.xyz.div(e.w).toVar(`positionView`)}return e.context.setupPositionView().toVarying(`v_positionView`)},`vec3`).once([`POSITION`,`VERTEX`])(),Fl=U(e=>{let t;return t=e.camera.isOrthographicCamera?K(0,0,1):Z.negate().toVarying(`v_positionViewDirection`).normalize(),t.toVar(`positionViewDirection`)},`vec3`).once([`POSITION`])(),Il=W(V(class extends I{static get type(){return`FrontFacingNode`}constructor(){super(`bool`),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!==`fragment`)return`true`;let{material:t}=e;return t.side===1?`false`:e.getFrontFacing()}})).mul(2).sub(1),Ll=U(([e],{material:t})=>{let n=t.side;return n===1?e=e.mul(-1):n===2&&(e=e.mul(Il)),e}),Rl=Vc(`normal`,`vec3`),zl=U(e=>e.geometry.hasAttribute(`normal`)===!1?(T(`TSL: Vertex attribute "normal" not found on geometry.`),K(0,1,0)):Rl,`vec3`).once()().toVar(`normalLocal`),Bl=Z.dFdx().cross(Z.dFdy()).normalize().toVar(`normalFlat`),Vl=U(e=>{let t;return t=e.isFlatShading()?Bl:Kl(zl).toVarying(`v_normalViewGeometry`).normalize(),t},`vec3`).once()().toVar(`normalViewGeometry`),Hl=U(e=>{let t;return e.subBuildFn===`NORMAL`||e.subBuildFn===`VERTEX`?(t=Vl,e.isFlatShading()!==!0&&(t=Ll(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`normalView`),Ul=Hl.transformDirection(Sl).toVar(`normalWorld`),Wl=U(({subBuildFn:e,context:t})=>{let n;return n=e===`NORMAL`||e===`VERTEX`?Hl:t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),n},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`clearcoatNormalView`),Gl=U(([e,t=El])=>{let n=Qa(t),r=e.div(K(n[0].dot(n[0]),n[1].dot(n[1]),n[2].dot(n[2])));return n.mul(r).xyz}),Kl=U(([e],t)=>{let n=t.context.modelNormalViewMatrix;if(n)return n.transformDirection(e);let r=Dl.mul(e);return Sl.transformDirection(r)});U(()=>(T(`TSL: "transformedNormalView" is deprecated. Use "normalView" instead.`),Hl)).once([`NORMAL`,`VERTEX`])(),U(()=>(T(`TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.`),Ul)).once([`NORMAL`,`VERTEX`])(),U(()=>(T(`TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.`),Wl)).once([`NORMAL`,`VERTEX`])();var ql=new wt,Jl=new mt,Yl=J(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),Xl=J(new mt).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let n=t.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation;return n?(ql.copy(n),Jl.makeRotationFromEuler(ql)):Jl.identity(),Jl}),Zl=Fl.negate().reflect(Hl),Ql=Fl.negate().refract(Hl,Yl),$l=Zl.transformDirection(Sl).toVar(`reflectVector`),eu=Ql.transformDirection(Sl).toVar(`reflectVector`),tu=new kr,nu=B(class extends qc{static get type(){return`CubeTextureNode`}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?`cubeDepthTexture`:`cubeTexture`}getDefaultUV(){let e=this.value;return e.mapping===301?$l:e.mapping===302?eu:(E(`CubeTextureNode: Mapping "%s" not supported.`,e.mapping),K(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return n.isDepthTexture===!0?e.renderer.coordinateSystem===2001?K(t.x,t.y.negate(),t.z):t:((e.renderer.coordinateSystem===2001||!n.isRenderTargetTexture)&&(t=K(t.x.negate(),t.yz)),Xl.mul(t))}generateUV(e,t){return t.build(e,this.sampler===!0?`vec3`:`ivec3`)}}).setParameterLength(1,4).setName(`cubeTexture`),ru=(e=tu,t=null,n=null,r=null)=>{let i;return e&&e.isCubeTextureNode===!0?(i=z(e.clone()),i.referenceNode=e,t!==null&&(i.uvNode=z(t)),n!==null&&(i.levelNode=z(n)),r!==null&&(i.biasNode=z(r))):i=nu(e,t,n,r),i},iu=class extends Vi{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},au=class extends I{static get type(){return`ReferenceNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=F.OBJECT}element(e){return new iu(this,z(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return T(`TSL: "label()" has been deprecated. Use "setName()" instead.`),this.setName(e)}setNodeType(e){let t=null;t=this.count===null?Array.isArray(this.getValueFromReference())?tl(null,e):e===`texture`?Yc(null):e===`cubeTexture`?ru(null):J(null,e):Qc(null,e,this.count),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},ou=(e,t,n)=>new au(e,t,n),su=(e,t,n,r)=>new au(e,t,r,n),cu=class extends au{static get type(){return`MaterialReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material===null?e.material:this.material,this.reference}},lu=(e,t,n=null)=>new cu(e,t,n),uu=Hc(),du=Z.dFdx(),fu=Z.dFdy(),pu=uu.dFdx(),mu=uu.dFdy(),hu=Hl,gu=fu.cross(hu),_u=hu.cross(du),vu=gu.mul(pu.x).add(_u.mul(mu.x)),yu=gu.mul(pu.y).add(_u.mul(mu.y)),bu=vu.dot(vu).max(yu.dot(yu)),xu=bu.equal(0).select(0,bu.inverseSqrt()),Su=vu.mul(xu).toVar(`tangentViewFrame`),Cu=yu.mul(xu).toVar(`bitangentViewFrame`),wu=Vc(`tangent`,`vec4`),Tu=wu.xyz.toVar(`tangentLocal`),Eu=U(e=>{let t;return t=e.subBuildFn===`VERTEX`||e.geometry.hasAttribute(`tangent`)?Ol.mul(q(Tu,0)).xyz.toVarying(`v_tangentView`).normalize():Su,e.isFlatShading()!==!0&&(t=Ll(t)),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`tangentView`),Du=U(([e,t],n)=>{let r=e.mul(wu.w).xyz;return n.subBuildFn===`NORMAL`&&n.isFlatShading()!==!0&&(r=r.toVarying(t)),r}).once([`NORMAL`]),Ou=Qa(Eu,U(e=>{let t;return t=e.subBuildFn===`VERTEX`||e.geometry.hasAttribute(`tangent`)?Du(Hl.cross(Eu),`v_bitangentView`).normalize():Cu,e.isFlatShading()!==!0&&(t=Ll(t)),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`bitangentView`),Hl).toVar(`TBNViewMatrix`),ku=e=>K(e,$o(Hs(W(1).sub(js(e,e))))),Au=B(class extends Ui{static get type(){return`NormalMapNode`}constructor(e,t=null){super(`vec3`),this.node=e,this.scaleNode=t,this.normalMapType=0,this.unpackNormalMode=``}setup(e){let{normalMapType:t,scaleNode:n,unpackNormalMode:r}=this,i=this.node.mul(2).sub(1);if(t===0?r===`rg`?i=ku(i.xy):r===`ga`?i=ku(i.yw):r!==``&&console.error(`THREE.NodeMaterial: Unexpected unpack normal mode: ${r}`):r!==``&&console.error(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${r}'`),n!==null){let t=n;e.isFlatShading()===!0&&(t=Ll(t)),i=K(i.xy.mul(t),i.z)}let a=null;return t===1?a=Kl(i):t===0?a=Ou.mul(i).normalize():(E(`NodeMaterial: Unsupported normal map type: ${t}`),a=Hl),a}}).setParameterLength(1,2),ju=U(({textureNode:e,bumpScale:t})=>{let n=t=>e.isolate().context({getUV:e=>t(e.uvNode||Hc()),forceUVContext:!0}),r=W(n(e=>e));return Va(W(n(e=>e.add(e.dFdx()))).sub(r),W(n(e=>e.add(e.dFdy()))).sub(r)).mul(t)}),Mu=U(e=>{let{surf_pos:t,surf_norm:n,dHdxy:r}=e,i=t.dFdx().normalize(),a=t.dFdy().normalize(),o=n,s=a.cross(o),c=o.cross(i),l=i.dot(s).mul(Il),u=l.sign().mul(r.x.mul(s).add(r.y.mul(c)));return l.abs().mul(n).sub(u).normalize()}),Nu=B(class extends Ui{static get type(){return`BumpMapNode`}constructor(e,t=null){super(`vec3`),this.textureNode=e,this.scaleNode=t}setup(){let e=this.scaleNode===null?1:this.scaleNode;return Mu({surf_pos:Z,surf_norm:Hl,dHdxy:ju({textureNode:this.textureNode,bumpScale:e})})}}).setParameterLength(1,2),Pu=new Map,Q=class e extends I{static get type(){return`MaterialNode`}constructor(e){super(),this.scope=e}getCache(e,t){let n=Pu.get(e);return n===void 0&&(n=lu(e,t),Pu.set(e,n)),n}getFloat(e){return this.getCache(e,`float`)}getColor(e){return this.getCache(e,`color`)}getTexture(e){return this.getCache(e===`map`?`map`:e+`Map`,`texture`)}setup(t){let n=t.context.material,r=this.scope,i=null;if(r===e.COLOR){let e=n.color===void 0?K():this.getColor(r);i=n.map&&n.map.isTexture===!0?e.mul(this.getTexture(`map`)):e}else if(r===e.OPACITY){let e=this.getFloat(r);i=n.alphaMap&&n.alphaMap.isTexture===!0?e.mul(this.getTexture(`alpha`)):e}else if(r===e.SPECULAR_STRENGTH)i=n.specularMap&&n.specularMap.isTexture===!0?this.getTexture(`specular`).r:W(1);else if(r===e.SPECULAR_INTENSITY){let e=this.getFloat(r);i=n.specularIntensityMap&&n.specularIntensityMap.isTexture===!0?e.mul(this.getTexture(r).a):e}else if(r===e.SPECULAR_COLOR){let e=this.getColor(r);i=n.specularColorMap&&n.specularColorMap.isTexture===!0?e.mul(this.getTexture(r).rgb):e}else if(r===e.ROUGHNESS){let e=this.getFloat(r);i=n.roughnessMap&&n.roughnessMap.isTexture===!0?e.mul(this.getTexture(r).g):e}else if(r===e.METALNESS){let e=this.getFloat(r);i=n.metalnessMap&&n.metalnessMap.isTexture===!0?e.mul(this.getTexture(r).b):e}else if(r===e.EMISSIVE){let e=this.getFloat(`emissiveIntensity`),t=this.getColor(r).mul(e);i=n.emissiveMap&&n.emissiveMap.isTexture===!0?t.mul(this.getTexture(r)):t}else if(r===e.NORMAL)n.normalMap?(i=Au(this.getTexture(`normal`),this.getCache(`normalScale`,`vec2`)),i.normalMapType=n.normalMapType,(n.normalMap.format==1030||n.normalMap.format==36285||n.normalMap.format==37490)&&(i.unpackNormalMode=`rg`)):i=n.bumpMap?Nu(this.getTexture(`bump`).r,this.getFloat(`bumpScale`)):Hl;else if(r===e.CLEARCOAT){let e=this.getFloat(r);i=n.clearcoatMap&&n.clearcoatMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=n.clearcoatRoughnessMap&&n.clearcoatRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_NORMAL)i=n.clearcoatNormalMap?Au(this.getTexture(r),this.getCache(r+`Scale`,`vec2`)):Hl;else if(r===e.SHEEN){let e=this.getColor(`sheenColor`).mul(this.getFloat(`sheen`));i=n.sheenColorMap&&n.sheenColorMap.isTexture===!0?e.mul(this.getTexture(`sheenColor`).rgb):e}else if(r===e.SHEEN_ROUGHNESS){let e=this.getFloat(r);i=n.sheenRoughnessMap&&n.sheenRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).a):e,i=i.clamp(1e-4,1)}else if(r===e.ANISOTROPY)if(n.anisotropyMap&&n.anisotropyMap.isTexture===!0){let e=this.getTexture(r);i=Za(qu.x,qu.y,qu.y.negate(),qu.x).mul(e.rg.mul(2).sub(Va(1)).normalize().mul(e.b))}else i=qu;else if(r===e.IRIDESCENCE_THICKNESS){let e=ou(`1`,`float`,n.iridescenceThicknessRange);if(n.iridescenceThicknessMap){let t=ou(`0`,`float`,n.iridescenceThicknessRange);i=e.sub(t).mul(this.getTexture(r).g).add(t)}else i=e}else if(r===e.TRANSMISSION){let e=this.getFloat(r);i=n.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===e.THICKNESS){let e=this.getFloat(r);i=n.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===e.IOR)i=this.getFloat(r);else if(r===e.LIGHT_MAP)i=this.getTexture(r).rgb.mul(this.getFloat(`lightMapIntensity`));else if(r===e.AO)i=this.getTexture(r).r.sub(1).mul(this.getFloat(`aoMapIntensity`)).add(1);else if(r===e.LINE_DASH_OFFSET)i=n.dashOffset?this.getFloat(r):W(0);else{let e=this.getNodeType(t);i=this.getCache(r,e)}return i}};Q.ALPHA_TEST=`alphaTest`,Q.COLOR=`color`,Q.OPACITY=`opacity`,Q.SHININESS=`shininess`,Q.SPECULAR=`specular`,Q.SPECULAR_STRENGTH=`specularStrength`,Q.SPECULAR_INTENSITY=`specularIntensity`,Q.SPECULAR_COLOR=`specularColor`,Q.REFLECTIVITY=`reflectivity`,Q.ROUGHNESS=`roughness`,Q.METALNESS=`metalness`,Q.NORMAL=`normal`,Q.CLEARCOAT=`clearcoat`,Q.CLEARCOAT_ROUGHNESS=`clearcoatRoughness`,Q.CLEARCOAT_NORMAL=`clearcoatNormal`,Q.EMISSIVE=`emissive`,Q.ROTATION=`rotation`,Q.SHEEN=`sheen`,Q.SHEEN_ROUGHNESS=`sheenRoughness`,Q.ANISOTROPY=`anisotropy`,Q.IRIDESCENCE=`iridescence`,Q.IRIDESCENCE_IOR=`iridescenceIOR`,Q.IRIDESCENCE_THICKNESS=`iridescenceThickness`,Q.IOR=`ior`,Q.TRANSMISSION=`transmission`,Q.THICKNESS=`thickness`,Q.ATTENUATION_DISTANCE=`attenuationDistance`,Q.ATTENUATION_COLOR=`attenuationColor`,Q.LINE_SCALE=`scale`,Q.LINE_DASH_SIZE=`dashSize`,Q.LINE_GAP_SIZE=`gapSize`,Q.LINE_WIDTH=`linewidth`,Q.LINE_DASH_OFFSET=`dashOffset`,Q.POINT_SIZE=`size`,Q.DISPERSION=`dispersion`,Q.LIGHT_MAP=`light`,Q.AO=`ao`;var Fu=V(Q,Q.ALPHA_TEST),Iu=V(Q,Q.COLOR);Q.SHININESS;var Lu=V(Q,Q.EMISSIVE),Ru=V(Q,Q.OPACITY);Q.SPECULAR,Q.SPECULAR_INTENSITY,Q.SPECULAR_COLOR,Q.SPECULAR_STRENGTH,Q.REFLECTIVITY,Q.ROUGHNESS,Q.METALNESS;var zu=V(Q,Q.NORMAL);Q.CLEARCOAT,Q.CLEARCOAT_ROUGHNESS,Q.CLEARCOAT_NORMAL,Q.ROTATION,Q.SHEEN,Q.SHEEN_ROUGHNESS,Q.ANISOTROPY,Q.IRIDESCENCE,Q.IRIDESCENCE_IOR,Q.IRIDESCENCE_THICKNESS,Q.TRANSMISSION,Q.THICKNESS,Q.IOR,Q.ATTENUATION_DISTANCE,Q.ATTENUATION_COLOR;var Bu=V(Q,Q.LINE_SCALE),Vu=V(Q,Q.LINE_DASH_SIZE),Hu=V(Q,Q.LINE_GAP_SIZE),Uu=V(Q,Q.LINE_WIDTH),Wu=V(Q,Q.LINE_DASH_OFFSET);Q.POINT_SIZE,Q.DISPERSION;var Gu=V(Q,Q.LIGHT_MAP),Ku=V(Q,Q.AO),qu=J(new qe).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),Ju=U(e=>e.context.setupModelViewProjection(),`vec4`).once()().toVarying(`v_modelViewProjection`),Yu=B(class extends Vi{static get type(){return`StorageArrayElementNode`}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){let n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):`void`}setup(e){return e.isAvailable(`storageBuffer`)===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n,r=e.context.assign;if(n=e.isAvailable(`storageBuffer`)===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!==`compute`)?e.generatePBO(this):this.node.build(e):super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}}).setParameterLength(2),Xu=class extends Zc{static get type(){return`StorageBufferNode`}constructor(e,t=null,n=0){let r,i=null;t&&t.isStruct?(r=`struct`,i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=ji(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=Li.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?`indirectStorageBuffer`:`storageBuffer`}element(e){return Yu(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Li.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=Cc(this.value),this._varying=ic(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.getNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode===null?`void`:this.structTypeNode.getMemberType(e,t)}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generate(e);let{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}},Zu=(e,t=null,n=0)=>new Xu(e,t,n),Qu=class e extends I{static get type(){return`IndexNode`}constructor(e){super(`uint`),this.scope=e,this.isIndexNode=!0}generate(t){let n=this.getNodeType(t),r=this.scope,i;if(r===e.VERTEX)i=t.getVertexIndex();else if(r===e.INSTANCE)i=t.getInstanceIndex();else if(r===e.DRAW)i=t.getDrawIndex();else if(r===e.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(r===e.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(r===e.SUBGROUP)i=t.getSubgroupIndex();else throw Error(`THREE.IndexNode: Unknown scope: `+r);let a;return a=t.shaderStage===`vertex`||t.shaderStage===`compute`?i:ic(this).build(t,n),a}};Qu.VERTEX=`vertex`,Qu.INSTANCE=`instance`,Qu.SUBGROUP=`subgroup`,Qu.INVOCATION_LOCAL=`invocationLocal`,Qu.INVOCATION_SUBGROUP=`invocationSubgroup`,Qu.DRAW=`draw`;var $u=V(Qu,Qu.VERTEX),ed=V(Qu,Qu.INSTANCE);Qu.SUBGROUP,Qu.INVOCATION_SUBGROUP,Qu.INVOCATION_LOCAL;var td=V(Qu,Qu.DRAW),nd=class extends I{static get type(){return`InstanceNode`}constructor(e,t,n=null){super(`void`),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=F.FRAME,this.buffer=null,this.bufferColor=null,this.previousInstanceMatrixNode=null}get isStorageMatrix(){let{instanceMatrix:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}get isStorageColor(){let{instanceColor:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}setup(e){let{instanceMatrixNode:t,instanceColorNode:n}=this;t===null&&(t=this._createInstanceMatrixNode(!0,e),this.instanceMatrixNode=t);let{instanceColor:r,isStorageColor:i}=this;if(r&&n===null){if(i)n=Zu(r,`vec3`,Math.max(r.count,1)).element(ed);else{let e=new hr(r.array,3),t=r.usage===35048?Tc:wc;this.bufferColor=e,n=K(t(e,`vec3`,3,0))}this.instanceColorNode=n}let a=t.mul(Ml).xyz;if(Ml.assign(a),e.needsPreviousData()&&Nl.assign(this.getPreviousInstancedPosition(e)),e.hasGeometryAttribute(`normal`)){let e=Gl(zl,t);zl.assign(e)}this.instanceColorNode!==null&&no(`vec3`,`vInstanceColor`).assign(this.instanceColorNode)}update(e){this.buffer!==null&&this.isStorageMatrix!==!0&&(this.buffer.clearUpdateRanges(),this.buffer.updateRanges.push(...this.instanceMatrix.updateRanges),this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version)),this.instanceColor&&this.bufferColor!==null&&this.isStorageColor!==!0&&(this.bufferColor.clearUpdateRanges(),this.bufferColor.updateRanges.push(...this.instanceColor.updateRanges),this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)),this.previousInstanceMatrixNode!==null&&e.object.previousInstanceMatrix.array.set(this.instanceMatrix.array)}getPreviousInstancedPosition(e){let t=e.object;return this.previousInstanceMatrixNode===null&&(t.previousInstanceMatrix=this.instanceMatrix.clone(),this.previousInstanceMatrixNode=this._createInstanceMatrixNode(!1,e)),this.previousInstanceMatrixNode.mul(Nl).xyz}_createInstanceMatrixNode(e,t){let n,{instanceMatrix:r}=this,{count:i}=r;if(this.isStorageMatrix)n=Zu(r,`mat4`,Math.max(i,1)).element(ed);else if(i*16*4<=t.getUniformBufferLimit())n=Qc(r.array,`mat4`,Math.max(i,1)).element(ed);else{let t=new ui(r.array,16,1);e===!0&&(this.buffer=t);let i=r.usage===35048?Tc:wc;n=$a(i(t,`vec4`,16,0),i(t,`vec4`,16,4),i(t,`vec4`,16,8),i(t,`vec4`,16,12))}return n}},rd=B(class extends nd{static get type(){return`InstancedMeshNode`}constructor(e){let{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}}).setParameterLength(1),id=B(class extends I{static get type(){return`BatchNode`}constructor(e){super(`void`),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=ed:this.batchingIdNode=td);let t=U(([e])=>{let t=G(Uc(Xc(this.batchMesh._indirectTexture),0).x).toConst(),n=G(e).mod(t).toConst(),r=G(e).div(t).toConst();return Xc(this.batchMesh._indirectTexture,Ha(n,r)).x}).setLayout({name:`getIndirectIndex`,type:`uint`,inputs:[{name:`id`,type:`int`}]})(G(this.batchingIdNode)),n=this.batchMesh._matricesTexture,r=G(Uc(Xc(n),0).x).toConst(),i=W(t).mul(4).toInt().toConst(),a=i.mod(r).toConst(),o=i.div(r).toConst(),s=$a(Xc(n,Ha(a,o)),Xc(n,Ha(a.add(1),o)),Xc(n,Ha(a.add(2),o)),Xc(n,Ha(a.add(3),o))),c=this.batchMesh._colorsTexture;if(c!==null){let e=U(([e])=>{let t=G(Uc(Xc(c),0).x).toConst(),n=e;return Xc(c,Ha(n.mod(t).toConst(),n.div(t).toConst())).rgb}).setLayout({name:`getBatchingColor`,type:`vec3`,inputs:[{name:`id`,type:`int`}]})(t);no(`vec3`,`vBatchColor`).assign(e)}let l=Qa(s);Ml.assign(s.mul(Ml));let u=zl.div(K(l[0].dot(l[0]),l[1].dot(l[1]),l[2].dot(l[2]))),d=l.mul(u).xyz;zl.assign(d),e.hasGeometryAttribute(`tangent`)&&Tu.mulAssign(l)}}).setParameterLength(1),ad=new WeakMap,od=class extends I{static get type(){return`SkinningNode`}constructor(e){super(`void`),this.skinnedMesh=e,this.updateType=F.OBJECT,this.skinIndexNode=Vc(`skinIndex`,`uvec4`),this.skinWeightNode=Vc(`skinWeight`,`vec4`),this.bindMatrixNode=ou(`bindMatrix`,`mat4`),this.bindMatrixInverseNode=ou(`bindMatrixInverse`,`mat4`),this.boneMatricesNode=su(`skeleton.boneMatrices`,`mat4`,e.skeleton.bones.length),this.positionNode=Ml,this.toPositionNode=Ml,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=i.mul(t),d=yo(o.mul(r.x).mul(u),s.mul(r.y).mul(u),c.mul(r.z).mul(u),l.mul(r.w).mul(u));return a.mul(d).xyz}getSkinnedNormalAndTangent(e=this.boneMatricesNode,t=zl,n=Tu){let{skinIndexNode:r,skinWeightNode:i,bindMatrixNode:a,bindMatrixInverseNode:o}=this,s=e.element(r.x),c=e.element(r.y),l=e.element(r.z),u=e.element(r.w),d=yo(i.x.mul(s),i.y.mul(c),i.z.mul(l),i.w.mul(u));return d=o.mul(d).mul(a),{skinNormal:d.transformDirection(t).xyz,skinTangent:d.transformDirection(n).xyz}}getPreviousSkinnedPosition(e){let t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=su(`skeleton.previousBoneMatrices`,`mat4`,t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Nl)}setup(e){e.needsPreviousData()&&Nl.assign(this.getPreviousSkinnedPosition(e));let t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute(`normal`)){let{skinNormal:t,skinTangent:n}=this.getSkinnedNormalAndTangent();zl.assign(t),e.hasGeometryAttribute(`tangent`)&&Tu.assign(n)}return t}generate(e,t){if(t!==`void`)return super.generate(e,t)}update(e){let t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;ad.get(t)!==e.frameId&&(ad.set(t,e.frameId),this.previousBoneMatricesNode!==null&&(t.previousBoneMatrices===null&&(t.previousBoneMatrices=new Float32Array(t.boneMatrices)),t.previousBoneMatrices.set(t.boneMatrices)),t.update())}},sd=e=>new od(e),cd=class extends I{static get type(){return`LoopNode`}constructor(e=[]){super(`void`),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){let t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;let n={};for(let e=0,t=this.params.length-1;e<t;e++){let t=this.params[e],r=t.isNode!==!0&&t.name||this.getVarName(e);n[r]=Pc(r,t.isNode!==!0&&t.type||`int`)}let r=e.addStack(),i=this.params[this.params.length-1](n);t.returnsNode=i.context({nodeLoop:i}),t.stackNode=r;let a=this.params[0];if(a.isNode!==!0&&typeof a.update==`function`){let e=U(this.params[0].update)(n);t.updateNode=e.context({nodeLoop:e})}return e.removeStack(),t}setup(e){if(this.getProperties(e),e.fnCall){let t=e.getDataFromNode(e.fnCall.shaderNode);t.hasLoop=!0}}generate(e){let t=this.getProperties(e),n=this.params,r=t.stackNode;for(let r=0,i=n.length-1;r<i;r++){let i=n[r],a=!1,o=null,s=null,c=null,l=null,u=null,d=null;i.isNode?i.getNodeType(e)===`bool`?(a=!0,l=`bool`,s=i.build(e,l)):(l=`int`,c=this.getVarName(r),o=`0`,s=i.build(e,l),u=`<`):(l=i.type||`int`,c=i.name||this.getVarName(r),o=i.start,s=i.end,u=i.condition,d=i.update,typeof o==`number`?o=e.generateConst(l,o):o&&o.isNode&&(o=o.build(e,l)),typeof s==`number`?s=e.generateConst(l,s):s&&s.isNode&&(s=s.build(e,l)),o!==void 0&&s===void 0?(o+=` - 1`,s=`0`,u=`>=`):s!==void 0&&o===void 0&&(o=`0`,u=`<`),u===void 0&&(u=Number(o)>Number(s)?`>=`:`<`));let f;if(a)f=`while ( ${s} )`;else{let n={start:o,end:s},r=n.start,i=n.end,a,p=()=>u.includes(`<`)?`+=`:`-=`;if(d!=null)switch(typeof d){case`function`:a=e.flowStagesNode(t.updateNode,`void`).code.replace(/\t|;/g,``);break;case`number`:a=c+` `+p()+` `+e.generateConst(l,d);break;case`string`:a=c+` `+d;break;default:d.isNode?a=c+` `+p()+` `+d.build(e):(E(`TSL: 'Loop( { update: ... } )' is not a function, string or number.`,this.stackTrace),a=`break /* invalid update */`)}else d=l===`int`||l===`uint`?u.includes(`<`)?`++`:`--`:p()+` 1.`,a=c+` `+d;f=`for ( ${e.getVar(l,c)+` = `+r}; ${c+` `+u+` `+i}; ${a} )`}e.addFlowCode((r===0?`
272
+ `:``)+e.tab+f+` {
273
+
274
+ `).addFlowTab()}let i=r.build(e,`void`);t.returnsNode.build(e,`void`),e.removeFlowTab().addFlowCode(`
275
+ `+e.tab+i);for(let t=0,n=this.params.length-1;t<n;t++)e.addFlowCode((t===0?``:e.tab)+`}
276
+
277
+ `).removeFlowTab();e.addFlowTab()}},ld=(...e)=>new cd(Na(e,`int`)).toStack(),ud=new WeakMap,dd=new j,fd=U(({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:a})=>{let o=G($u).mul(n).add(a),s=o.div(r);return Xc(e,Ha(o.sub(s.mul(r)),s)).depth(i).xyz.mul(t)});function pd(e){let t=e.morphAttributes.position!==void 0,n=e.morphAttributes.normal!==void 0,r=e.morphAttributes.color!==void 0,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=i===void 0?0:i.length,o=ud.get(e);if(o===void 0||o.count!==a){o!==void 0&&o.texture.dispose();let i=e.morphAttributes.position||[],c=e.morphAttributes.normal||[],l=e.morphAttributes.color||[],u=0;t===!0&&(u=1),n===!0&&(u=2),r===!0&&(u=3);let d=e.attributes.position.count*u,f=1,p=4096;d>p&&(f=Math.ceil(d/p),d=p);let m=new Float32Array(d*f*4*a),h=new pt(m,d,f,a);h.type=v,h.needsUpdate=!0;let g=u*4;for(let e=0;e<a;e++){let a=i[e],o=c[e],s=l[e],u=d*f*4*e;for(let e=0;e<a.count;e++){let i=e*g;t===!0&&(dd.fromBufferAttribute(a,e),m[u+i+0]=dd.x,m[u+i+1]=dd.y,m[u+i+2]=dd.z,m[u+i+3]=0),n===!0&&(dd.fromBufferAttribute(o,e),m[u+i+4]=dd.x,m[u+i+5]=dd.y,m[u+i+6]=dd.z,m[u+i+7]=0),r===!0&&(dd.fromBufferAttribute(s,e),m[u+i+8]=dd.x,m[u+i+9]=dd.y,m[u+i+10]=dd.z,m[u+i+11]=s.itemSize===4?dd.w:1)}}o={count:a,texture:h,stride:u,size:new qe(d,f)},ud.set(e,o);function s(){h.dispose(),ud.delete(e),e.removeEventListener(`dispose`,s)}e.addEventListener(`dispose`,s)}return o}var md=B(class extends I{static get type(){return`MorphNode`}constructor(e){super(`void`),this.mesh=e,this.morphBaseInfluence=J(1),this.updateType=F.OBJECT}setup(e){let{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute(`normal`)&&t.morphAttributes.normal!==void 0,i=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=i===void 0?0:i.length,{texture:o,stride:s,size:c}=pd(t);n===!0&&Ml.mulAssign(this.morphBaseInfluence),r===!0&&zl.mulAssign(this.morphBaseInfluence);let l=G(c.width);ld(a,({i:e})=>{let t=W(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?t.assign(Xc(this.mesh.morphTexture,Ha(G(e).add(1),G(ed))).r):t.assign(ou(`morphTargetInfluences`,`float`).element(e).toVar()),Ia(t.notEqual(0),()=>{n===!0&&Ml.addAssign(fd({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:G(0)})),r===!0&&zl.addAssign(fd({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:G(1)}))})})}update(){let e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((e,t)=>e+t,0)}}).setParameterLength(1),hd=class extends I{static get type(){return`LightingNode`}constructor(){super(`vec3`),this.isLightingNode=!0}},gd=class extends hd{static get type(){return`AONode`}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},_d=B(class extends Js{static get type(){return`LightingContextNode`}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){let{backdropNode:e,backdropAlphaNode:t}=this,n={directDiffuse:K().toVar(`directDiffuse`),directSpecular:K().toVar(`directSpecular`),indirectDiffuse:K().toVar(`indirectDiffuse`),indirectSpecular:K().toVar(`indirectSpecular`)};return{radiance:K().toVar(`radiance`),irradiance:K().toVar(`irradiance`),iblIrradiance:K().toVar(`iblIrradiance`),ambientOcclusion:W(1).toVar(`ambientOcclusion`),reflectedLight:n,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}),vd=class extends hd{static get type(){return`IrradianceNode`}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}},yd=new qe,bd=class extends qc{static get type(){return`ViewportTextureNode`}constructor(e=sl,t=null,n=null){let r=null;n===null?(r=new Or,r.minFilter=h,n=r):r=n,super(n,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=r,this.isOutputTextureNode=!0,this.updateBeforeType=F.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,n;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,n=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,n=this._cacheTextures),e===null)return t;if(n.has(e)===!1){let r=t.clone();n.set(e,r)}return n.get(e)}updateReference(e){let t=e.renderer.getRenderTarget();return this.value=this.getTextureForReference(t),this.value}updateBefore(e){let t=e.renderer,n=t.getRenderTarget();n===null?t.getDrawingBufferSize(yd):yd.set(n.width,n.height);let r=this.getTextureForReference(n);(r.image.width!==yd.width||r.image.height!==yd.height)&&(r.image.width=yd.width,r.image.height=yd.height,r.needsUpdate=!0);let i=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=i}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}},xd=B(bd,null,null,{generateMipmaps:!0}).setParameterLength(0,3)(),Sd=(e=sl,t=null)=>xd.sample(e,t),Cd=null,wd=B(class extends bd{static get type(){return`ViewportDepthTextureNode`}constructor(e=sl,t=null){Cd===null&&(Cd=new Ar),super(e,t,Cd)}getTextureForReference(){return Cd}}).setParameterLength(0,2),Td=class e extends I{static get type(){return`ViewportDepthNode`}constructor(e,t=null){super(`float`),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(t){let{scope:n}=this;return n===e.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){let{scope:n}=this,r=this.valueNode,i=null;return n===e.DEPTH_BASE?r!==null&&(i=Ad().assign(r)):n===e.DEPTH?i=t.isPerspectiveCamera?Dd(Z.z,vl,yl):Ed(Z.z,vl,yl):n===e.LINEAR_DEPTH&&(i=r===null?Ed(Z.z,vl,yl):t.isPerspectiveCamera?Ed(Od(r,vl,yl),vl,yl):r),i}};Td.DEPTH_BASE=`depthBase`,Td.DEPTH=`depth`,Td.LINEAR_DEPTH=`linearDepth`;var Ed=(e,t,n)=>e.add(t).div(t.sub(n)),Dd=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),Od=U(([e,t,n],r)=>r.renderer.reversedDepthBuffer===!0?t.mul(n).div(t.sub(n).mul(e).sub(t)):t.mul(n).div(n.sub(t).mul(e).sub(n))),kd=(e,t,n)=>{t=t.max(1e-6).toVar();let r=Qo(e.negate().div(t)),i=Qo(n.div(t));return r.div(i)},Ad=B(Td,Td.DEPTH_BASE),jd=V(Td,Td.DEPTH);wd(),jd.assign=e=>Ad(e);var Md=class e extends I{static get type(){return`ClippingNode`}constructor(t=e.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);let{intersectionPlanes:n,unionPlanes:r}=t.clippingContext;return this.hardwareClipping=t.material.hardwareClipping,this.scope===e.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===e.HARDWARE?this.setupHardwareClipping(r,t):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return U(()=>{let n=W().toVar(`distanceToPlane`),r=W().toVar(`distanceToGradient`),i=W(1).toVar(`clipOpacity`),a=t.length;if(this.hardwareClipping===!1&&a>0){let e=tl(t).setGroup(fo);ld(a,({i:t})=>{let a=e.element(t);n.assign(Z.dot(a.xyz).negate().add(a.w)),r.assign(n.fwidth().div(2)),i.mulAssign(Ws(r.negate(),r,n))})}let o=e.length;if(o>0){let t=tl(e).setGroup(fo),a=W(1).toVar(`intersectionClipOpacity`);ld(o,({i:e})=>{let i=t.element(e);n.assign(Z.dot(i.xyz).negate().add(i.w)),r.assign(n.fwidth().div(2)),a.mulAssign(Ws(r.negate(),r,n).oneMinus())}),i.mulAssign(a.oneMinus())}ro.a.mulAssign(i),ro.a.equal(0).discard()})()}setupDefault(e,t){return U(()=>{let n=t.length;if(this.hardwareClipping===!1&&n>0){let e=tl(t).setGroup(fo);ld(n,({i:t})=>{let n=e.element(t);Z.dot(n.xyz).greaterThan(n.w).discard()})}let r=e.length;if(r>0){let t=tl(e).setGroup(fo),n=Ba(!0).toVar(`clipped`);ld(r,({i:e})=>{let r=t.element(e);n.assign(Z.dot(r.xyz).greaterThan(r.w).and(n))}),n.discard()}})()}setupHardwareClipping(e,t){let n=e.length;return t.enableHardwareClipping(n),U(()=>{let r=tl(e).setGroup(fo),i=nl(t.getClipDistance());ld(n,({i:e})=>{let t=r.element(e),n=Z.dot(t.xyz).sub(t.w).negate();i.element(e).assign(n)})})()}};Md.ALPHA_TO_COVERAGE=`alphaToCoverage`,Md.DEFAULT=`default`,Md.HARDWARE=`hardware`;var Nd=()=>new Md,Pd=()=>new Md(Md.ALPHA_TO_COVERAGE),Fd=()=>new Md(Md.HARDWARE),Id=.05,Ld=U(([e])=>is(xo(1e4,as(xo(17,e.x).add(xo(.1,e.y)))).mul(yo(.1,ds(as(xo(13,e.y).add(e.x))))))),Rd=U(([e])=>Ld(Va(Ld(e.xy),e.z))),zd=U(([e])=>{let t=Es(ps(gs(e.xyz)),ps(_s(e.xyz))),n=W(1).div(W(Id).mul(t)).toVar(`pixScale`),r=Va(Xo(ts(Qo(n))),Xo(ns(Qo(n)))),i=Va(Rd(ts(r.x.mul(e.xyz))),Rd(ts(r.y.mul(e.xyz)))),a=is(Qo(n)),o=yo(xo(a.oneMinus(),i.x),xo(a,i.y)),s=Ts(a,a.oneMinus()),c=K(o.mul(o).div(xo(2,s).mul(bo(1,s))),o.sub(xo(.5,s)).div(bo(1,s)),bo(1,bo(1,o).mul(bo(1,o)).div(xo(2,s).mul(bo(1,s)))));return Vs(o.lessThan(s.oneMinus()).select(o.lessThan(s).select(c.x,c.y),c.z),1e-6,1)}).setLayout({name:`getAlphaHashThreshold`,type:`float`,inputs:[{name:`position`,type:`vec3`}]}),Bd=class extends Bc{static get type(){return`VertexColorNode`}constructor(e){super(null,`vec4`),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return`color`+(e>0?e:``)}generate(e){let t=this.getAttributeName(e),n=e.hasGeometryAttribute(t),r;return r=n===!0?super.generate(e):e.generateConst(this.nodeType,new j(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}},Vd=(e=0)=>new Bd(e),Hd=U(([e])=>q(e.rgb.mul(e.a),e.a),{color:`vec4`,return:`vec4`}),Ud=class extends Gn{static get type(){return`NodeMaterial`}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){let e=[];for(let t of Object.getOwnPropertyNames(this)){if(t.startsWith(`_`)===!0)continue;let n=this[t];n&&n.isNode===!0&&e.push({property:t,childNode:n})}return e}customProgramCacheKey(){let e=[];for(let{property:t,childNode:n}of this._getNodeChildren())e.push(Di(t.slice(0,-4)),n.getCacheKey());return this.type+Oi(e)}build(e){this.setup(e)}setupObserver(e){return new Si(e)}setup(e){e.context.setupNormal=()=>rc(this.setupNormal(e),`NORMAL`,`vec3`),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,n=t.getRenderTarget();t.contextNode.isContextNode===!0?e.context=s(s({},e.context),t.contextNode.getFlowContextData()):E('NodeMaterial: "renderer.contextNode" must be an instance of `context()`.'),this.contextNode!==null&&(this.contextNode.isContextNode===!0?e.context=s(s({},e.context),this.contextNode.getFlowContextData()):E('NodeMaterial: "material.contextNode" must be an instance of `context()`.')),e.addStack();let r=this.setupVertex(e),i=rc(this.vertexNode||r,`VERTEX`);e.context.clipSpace=i,e.stack.outputNode=i,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow(`vertex`,e.removeStack()),e.addStack();let a,o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n===null?t.depth===!0&&this.setupDepth(e):n.depthBuffer===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);let r=this.setupLighting(e);o!==null&&e.stack.addToStack(o);let i=q(r,ro.a).max(0);a=this.setupOutput(e,i),ao.assign(a);let s=this.outputNode!==null;if(s&&(a=this.outputNode),e.context.getOutput&&(a=e.context.getOutput(a,e)),n!==null){let e=t.getMRT(),n=this.mrtNode;e===null?n!==null&&(a=n):(s&&ao.assign(a),a=e,n!==null&&(a=e.merge(n)))}}else{let t=this.fragmentNode;t.isOutputStructNode!==!0&&(t=q(t)),a=this.setupOutput(e,t)}e.stack.outputNode=a,e.addFlow(`fragment`,e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:n}=e.clippingContext,r=null;if(t.length>0||n.length>0){let t=e.renderer.currentSamples;this.alphaToCoverage&&t>1?r=Pd():e.stack.addToStack(Nd())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable(`clipDistance`)&&(e.stack.addToStack(Fd()),this.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:n}=e,r=this.depthNode;if(r===null){let e=t.getMRT();e&&e.has(`depth`)?r=e.get(`depth`):t.logarithmicDepthBuffer===!0&&(r=n.isPerspectiveCamera?kd(Z.z,vl,yl):Ed(Z.z,vl,yl))}r!==null&&jd.assign(r).toStack()}setupPositionView(){return Ol.mul(Ml).xyz}setupModelViewProjection(){return bl.mul(Z)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),Ju}setupPosition(e){let{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&md(t).toStack(),t.isSkinnedMesh===!0&&sd(t).toStack(),this.displacementMap){let e=lu(`displacementMap`,`texture`),t=lu(`displacementScale`,`float`),n=lu(`displacementBias`,`float`);Ml.addAssign(zl.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&id(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&rd(t).toStack(),this.positionNode!==null&&Ml.assign(rc(this.positionNode,`POSITION`,`vec3`)),Ml}setupDiffuseColor(e){let{object:t,geometry:n}=e;this.maskNode!==null&&Ba(this.maskNode).not().discard();let r=this.colorNode?q(this.colorNode):Iu;this.vertexColors===!0&&n.hasAttribute(`color`)&&(r=r.mul(Vd())),t.instanceColor&&(r=no(`vec3`,`vInstanceColor`).mul(r)),t.isBatchedMesh&&t._colorsTexture&&(r=no(`vec3`,`vBatchColor`).mul(r)),ro.assign(r);let i=this.opacityNode?W(this.opacityNode):Ru;ro.a.assign(ro.a.mul(i));let a=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(a=this.alphaTestNode===null?Fu:W(this.alphaTestNode),this.alphaToCoverage===!0?(ro.a=Ws(a,a.add(xs(ro.a)),ro.a),ro.a.lessThanEqual(0).discard()):ro.a.lessThanEqual(a).discard()),this.alphaHash===!0&&ro.a.lessThan(zd(Ml)).discard(),e.isOpaque()&&ro.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?K(0):ro.rgb}setupNormal(){return this.normalNode?K(this.normalNode):zu}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?lu(`envMap`,`cubeTexture`):lu(`envMap`,`texture`)),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new vd(Gu)),t}setupLights(e){let t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);let r=this.setupLightMap(e);r&&r.isLightingNode&&t.push(r);let i=this.aoNode;i===null&&e.material.aoMap&&(i=Ku),e.context.getAO&&(i=e.context.getAO(i,e)),i&&t.push(new gd(i));let a=this.lightsNode||e.lightsNode;return t.length>0&&(a=e.renderer.lighting.createNode([...a.getLights(),...t])),a}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:i}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null,o=this.setupOutgoingLight(e);return a&&a.getScope().hasLights?o=_d(a,this.setupLightingModel(e)||null,n,r):n!==null&&(o=K(r===null?n:Bs(o,n,r))),(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(io.assign(K(i||Lu)),o=o.add(io)),o}setupFog(e,t){let n=e.fogNode;return n&&(ao.assign(t),t=q(n.toVar())),t}setupPremultipliedAlpha(e,t){return Hd(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(let t in e){let n=e[t];this[t]===void 0&&(this[t]=n,n&&n.clone&&(this[t]=n.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let e in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,e)===void 0&&t[e].get!==void 0&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{},nodes:{}});let n=Gn.prototype.toJSON.call(this,e);n.inputNodes={};for(let{property:t,childNode:r}of this._getNodeChildren())n.inputNodes[t]=r.toJSON(e).uuid;function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images),a=r(e.nodes);t.length>0&&(n.textures=t),i.length>0&&(n.images=i),a.length>0&&(n.nodes=a)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.aoNode=e.aoNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.maskShadowNode=e.maskShadowNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,this.contextNode=e.contextNode,super.copy(e)}},Wd=new jr,Gd=class extends Ud{static get type(){return`Line2NodeMaterial`}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(Wd),this.vertexColors=e.vertexColors,this.dashOffset=0,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=0,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){let{renderer:t}=e,n=this._useAlphaToCoverage,r=this.vertexColors,i=this._useDash,a=this._useWorldUnits,o=U(({start:e,end:t})=>{let n=bl.element(2).element(2),r=bl.element(3).element(2).mul(-.5).div(n).sub(e.z).div(t.z.sub(e.z));return q(Bs(e.xyz,t.xyz,r),t.w)}).setLayout({name:`trimSegment`,type:`vec4`,inputs:[{name:`start`,type:`vec4`},{name:`end`,type:`vec4`}]});this.vertexNode=U(()=>{let e=Vc(`instanceStart`),t=Vc(`instanceEnd`),n=q(Ol.mul(q(e,1))).toVar(`start`),r=q(Ol.mul(q(t,1))).toVar(`end`);if(i){let e=this.dashScaleNode?W(this.dashScaleNode):Bu,t=this.offsetNode?W(this.offsetNode):Wu,n=Vc(`instanceDistanceStart`),r=Vc(`instanceDistanceEnd`),i=jl.y.lessThan(.5).select(e.mul(n),e.mul(r));i=i.add(t),no(`float`,`lineDistance`).assign(i)}a&&(no(`vec3`,`worldStart`).assign(n.xyz),no(`vec3`,`worldEnd`).assign(r.xyz));let s=ul.z.div(ul.w);Ia(bl.element(2).element(3).equal(-1),()=>{Ia(n.z.lessThan(0).and(r.z.greaterThan(0)),()=>{r.assign(o({start:n,end:r}))}).ElseIf(r.z.lessThan(0).and(n.z.greaterThanEqual(0)),()=>{n.assign(o({start:r,end:n}))})});let c=bl.mul(n),l=bl.mul(r),u=c.xyz.div(c.w),d=l.xyz.div(l.w),f=d.xy.sub(u.xy).toVar();f.x.assign(f.x.mul(s)),f.assign(f.normalize());let p=q().toVar();if(a){let e=r.xyz.sub(n.xyz).normalize(),t=Bs(n.xyz,r.xyz,.5).normalize(),a=e.cross(t).normalize(),o=e.cross(a),s=no(`vec4`,`worldPos`);s.assign(jl.y.lessThan(.5).select(n,r));let c=Uu.mul(.5);s.addAssign(q(jl.x.lessThan(0).select(a.mul(c),a.mul(c).negate()),0)),i||(s.addAssign(q(jl.y.lessThan(.5).select(e.mul(c).negate(),e.mul(c)),0)),s.addAssign(q(o.mul(c),0)),Ia(jl.y.greaterThan(1).or(jl.y.lessThan(0)),()=>{s.subAssign(q(o.mul(2).mul(c),0))})),p.assign(bl.mul(s));let l=K().toVar();l.assign(jl.y.lessThan(.5).select(u,d)),p.z.assign(l.z.mul(p.w))}else{let e=Va(f.y,f.x.negate()).toVar(`offset`);f.x.assign(f.x.div(s)),e.x.assign(e.x.div(s)),e.assign(jl.x.lessThan(0).select(e.negate(),e)),Ia(jl.y.lessThan(0),()=>{e.assign(e.sub(f))}).ElseIf(jl.y.greaterThan(1),()=>{e.assign(e.add(f))}),e.assign(e.mul(Uu)),e.assign(e.div(ul.w.div(ol))),p.assign(jl.y.lessThan(.5).select(c,l)),e.assign(e.mul(p.w)),p.assign(p.add(q(e,0,0)))}return p})();let s=U(({p1:e,p2:t,p3:n,p4:r})=>{let i=e.sub(n),a=r.sub(n),o=t.sub(e),s=i.dot(a),c=a.dot(o),l=i.dot(o),u=a.dot(a),d=o.dot(o).mul(u).sub(c.mul(c)),f=s.mul(c).sub(l.mul(u)).div(d).clamp();return Va(f,s.add(c.mul(f)).div(u).clamp())});if(this.colorNode=U(()=>{let e=Hc();if(i){let t=this.dashSizeNode?W(this.dashSizeNode):Vu,n=this.gapSizeNode?W(this.gapSizeNode):Hu;oo.assign(t),so.assign(n);let r=no(`float`,`lineDistance`);e.y.lessThan(-1).or(e.y.greaterThan(1)).discard(),r.mod(oo.add(so)).greaterThan(oo).discard()}let o=W(1).toVar(`alpha`);if(a){let e=no(`vec3`,`worldStart`),r=no(`vec3`,`worldEnd`),a=no(`vec4`,`worldPos`).xyz.normalize().mul(1e5),c=r.sub(e),l=s({p1:e,p2:r,p3:K(0,0,0),p4:a}),u=e.add(c.mul(l.x)),d=a.mul(l.y),f=u.sub(d).length().div(Uu);if(!i)if(n&&t.currentSamples>0){let e=f.fwidth();o.assign(Ws(e.negate().add(.5),e.add(.5),f).oneMinus())}else f.greaterThan(.5).discard()}else if(n&&t.currentSamples>0){let t=e.x,n=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1)),r=t.mul(t).add(n.mul(n)),i=W(r.fwidth()).toVar(`dlen`);Ia(e.y.abs().greaterThan(1),()=>{o.assign(Ws(i.oneMinus(),i.add(1),r).oneMinus())})}else Ia(e.y.abs().greaterThan(1),()=>{let t=e.x,n=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1));t.mul(t).add(n.mul(n)).greaterThan(1).discard()});let c;if(this.lineColorNode)c=this.lineColorNode;else if(r){let e=Vc(`instanceColorStart`),t=Vc(`instanceColorEnd`);c=jl.y.lessThan(.5).select(e,t).mul(Iu)}else c=Iu;return q(c,o)})(),this.transparent){let e=this.opacityNode?W(this.opacityNode):Ru;this.outputNode=q(this.colorNode.rgb.mul(e).add(Sd().rgb.mul(e.oneMinus())),this.colorNode.a)}super.setup(e)}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}};1/Math.PI,new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),K(.04),W(1);var Kd=U(([e,t])=>{let n=e.toVar();n.assign(xo(2,n).sub(1));let r=K(n,1).toVar();return Ia(t.equal(0),()=>{r.assign(r.zyx)}).ElseIf(t.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:`getDirection`,type:`vec3`,inputs:[{name:`uv`,type:`vec2`},{name:`face`,type:`float`}]})(Hc(),Vc(`faceIndex`)).normalize();Kd.x,Kd.y,Kd.z,to(`vec3`),to(`vec3`),to(`vec3`);var qd=class{constructor(e=1){this.blending=e,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.premultiplyAlpha=!1}copy(e){return this.blending=e.blending,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.premultiplyAlpha=e.premultiplyAlpha,this}clone(){return new this.constructor().copy(this)}};new qd(0),new qd(6);var Jd=class extends Ui{static get type(){return`BitcastNode`}constructor(e,t,n=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=n,this.isBitcastNode=!0}getNodeType(e){if(this.inputType!==null){let t=this.valueNode.getNodeType(e),n=e.getTypeLength(t);return e.getTypeFromLength(n,this.conversionType)}return this.conversionType}generate(e){let t=this.getNodeType(e),n=``;if(this.inputType!==null){let t=this.valueNode.getNodeType(e);n=e.getTypeLength(t)===1?this.inputType:e.changeComponentType(t,this.inputType)}else n=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(t,n)}( ${this.valueNode.build(e,n)} )`}},Yd=H(Jd).setParameterLength(2),Xd=e=>new Jd(e,`uint`,`float`),Zd={},Qd=class e extends X{static get type(){return`BitcountNode`}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,n){n===`int`?t.assign(Yd(e,`uint`)):t.assign(e)}_returnDataNode(e){switch(e){case`uint`:return za;case`int`:return G;case`uvec2`:return Ua;case`uvec3`:return Ka;case`uvec4`:return Ya;case`ivec2`:return Ha;case`ivec3`:return Ga;case`ivec4`:return Ja}}_createTrailingZerosBaseLayout(e,t){let n=this._returnDataNode(t);return U(([e])=>{let r=za(0);return this._resolveElementType(e,r,t),n(Xd(W(r.bitAnd(ms(r)))).shiftRight(23).sub(127))}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createLeadingZerosBaseLayout(e,t){let n=this._returnDataNode(t);return U(([e])=>{Ia(e.equal(za(0)),()=>za(32));let r=za(0),i=za(0);return this._resolveElementType(e,r,t),Ia(r.shiftRight(16).equal(0),()=>{i.addAssign(16),r.shiftLeftAssign(16)}),Ia(r.shiftRight(24).equal(0),()=>{i.addAssign(8),r.shiftLeftAssign(8)}),Ia(r.shiftRight(28).equal(0),()=>{i.addAssign(4),r.shiftLeftAssign(4)}),Ia(r.shiftRight(30).equal(0),()=>{i.addAssign(2),r.shiftLeftAssign(2)}),Ia(r.shiftRight(31).equal(0),()=>{i.addAssign(1)}),n(i)}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createOneBitsBaseLayout(e,t){let n=this._returnDataNode(t);return U(([e])=>{let r=za(0);return this._resolveElementType(e,r,t),r.assign(r.sub(r.shiftRight(za(1)).bitAnd(za(1431655765)))),r.assign(r.bitAnd(za(858993459)).add(r.shiftRight(za(2)).bitAnd(za(858993459)))),n(r.add(r.shiftRight(za(4))).bitAnd(za(252645135)).mul(za(16843009)).shiftRight(za(24)))}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createMainLayout(e,t,n,r){let i=this._returnDataNode(t);return U(([e])=>{if(n===1)return i(r(e));{let t=i(0),a=[`x`,`y`,`z`,`w`];for(let i=0;i<n;i++){let n=a[i];t[n].assign(r(e[n]))}return t}}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}setup(t){let{method:n,aNode:r}=this,{renderer:i}=t;if(i.backend.isWebGPUBackend)return super.setup(t);let a=this.getInputType(t),o=t.getElementType(a),s=t.getTypeLength(a),c=`${n}_base_${o}`,l=`${n}_${a}`,u=Zd[c];if(u===void 0){switch(n){case e.COUNT_LEADING_ZEROS:u=this._createLeadingZerosBaseLayout(c,o);break;case e.COUNT_TRAILING_ZEROS:u=this._createTrailingZerosBaseLayout(c,o);break;case e.COUNT_ONE_BITS:u=this._createOneBitsBaseLayout(c,o);break}Zd[c]=u}let d=Zd[l];return d===void 0&&(d=this._createMainLayout(l,a,s,u),Zd[l]=d),U(()=>d(r))()}};Qd.COUNT_TRAILING_ZEROS=`countTrailingZeros`,Qd.COUNT_LEADING_ZEROS=`countLeadingZeros`,Qd.COUNT_ONE_BITS=`countOneBits`,new yr,new k,new k,new k,new mt,new k(0,0,-1),new j,new k,new k,new j,new qe;var $d=new ft;sl.flipX(),$d.depthTexture=new Ar(1,1),U(([e])=>is(W(52.9829189).mul(is(js(e,Va(.06711056,.00583715)))))).setLayout({name:`interleavedGradientNoise`,type:`float`,inputs:[{name:`position`,type:`vec2`}]}),U(([e,t,n])=>{let r=W(2.399963229728653),i=$o(W(e).add(.5).div(W(t))),a=W(e).mul(r).add(n);return Va(os(a),as(a)).mul(i)}).setLayout({name:`vogelDiskSample`,type:`vec2`,inputs:[{name:`sampleIndex`,type:`int`},{name:`samplesCount`,type:`int`},{name:`phi`,type:`float`}]});var ef=class e extends I{static get type(){return`EventNode`}constructor(t,n){super(`void`),this.eventType=t,this.callback=n,t===e.OBJECT?this.updateType=F.OBJECT:t===e.MATERIAL?this.updateType=F.RENDER:t===e.BEFORE_OBJECT?this.updateBeforeType=F.OBJECT:t===e.BEFORE_MATERIAL&&(this.updateBeforeType=F.RENDER)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}};ef.OBJECT=`object`,ef.MATERIAL=`material`,ef.BEFORE_OBJECT=`beforeObject`,ef.BEFORE_MATERIAL=`beforeMaterial`,U(({texture:e,uv:t})=>{let n=1e-4,r=K().toVar();return Ia(t.x.lessThan(n),()=>{r.assign(K(1,0,0))}).ElseIf(t.y.lessThan(n),()=>{r.assign(K(0,1,0))}).ElseIf(t.z.lessThan(n),()=>{r.assign(K(0,0,1))}).ElseIf(t.x.greaterThan(1-n),()=>{r.assign(K(-1,0,0))}).ElseIf(t.y.greaterThan(1-n),()=>{r.assign(K(0,-1,0))}).ElseIf(t.z.greaterThan(1-n),()=>{r.assign(K(0,0,-1))}).Else(()=>{let n=.01,i=e.sample(t.add(K(-.01,0,0))).r.sub(e.sample(t.add(K(n,0,0))).r),a=e.sample(t.add(K(0,-.01,0))).r.sub(e.sample(t.add(K(0,n,0))).r),o=e.sample(t.add(K(0,0,-.01))).r.sub(e.sample(t.add(K(0,0,n))).r);r.assign(K(i,a,o))}),r.normalize()}),U(([e,t])=>e.mul(t).floor().div(t));var tf=new qe,nf=class extends qc{static get type(){return`PassTextureNode`}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){let t=e.getNodeProperties(this);return t.passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}},rf=class extends nf{static get type(){return`PassMultipleTextureNode`}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){let e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}},af=class e extends Ui{static get type(){return`PassNode`}constructor(e,t,n,r={}){super(`vec4`),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;let i=new Ar;i.isRenderTargetTexture=!0,i.name=`depth`;let a=new ft(this._width*this._pixelRatio,this._height*this._pixelRatio,s({type:y},r));a.texture.name=`output`,a.depthTexture=i,this.renderTarget=a,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:a.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=J(0),this._cameraFar=J(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=F.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return T(`PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead.`),this.setResolutionScale(e)}getResolution(){return T(`PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead.`),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(t!==void 0){let n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e=`output`){let t=this._textureNodes[e];return t===void 0&&(t=new rf(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e=`output`){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=new rf(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e=`depth`){let t=this._viewZNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=Od(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e=`depth`){let t=this._linearDepthNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=Ed(i,n,r)}return t}compileAsync(e){var t=this;return l(function*(){let n=e.getRenderTarget(),r=e.getMRT();e.setRenderTarget(t.renderTarget),e.setMRT(t._mrt),yield e.compileAsync(t.scene,t.camera),e.setRenderTarget(n),e.setMRT(r)})()}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,this.renderTarget.texture.type=t.getOutputBufferType(),this.scope===e.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let{renderer:t}=e,{scene:n}=this,r,i,a=t.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(i=1,r=t.xr.getCamera(),t.xr.updateCamera(r),tf.set(a.width,a.height)):(r=this.camera,i=t.getPixelRatio(),t.getSize(tf)),this._pixelRatio=i,this.setSize(tf.width,tf.height);let o=t.getRenderTarget(),c=t.getMRT(),l=t.autoClear,u=t.transparent,d=t.opaque,f=r.layers.mask,p=t.contextNode,m=n.overrideMaterial;this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask);for(let e in this._previousTextures)this.toggleTexture(e);this.overrideMaterial!==null&&(n.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:Ys(s(s({},t.contextNode.getFlowContextData()),this.contextNode.getFlowContextData()))}),t.contextNode=this._contextNodeCache.context);let h=n.name;n.name=this.name?this.name:n.name,t.render(n,r),n.name=h,n.overrideMaterial=m,t.setRenderTarget(o),t.setMRT(c),t.autoClear=l,t.transparent=u,t.opaque=d,t.contextNode=p,r.layers.mask=f}setSize(e,t){this._width=e,this._height=t;let n=Math.floor(this._width*this._pixelRatio*this._resolutionScale),r=Math.floor(this._height*this._pixelRatio*this._resolutionScale);this.renderTarget.setSize(n,r),this._scissor!==null&&this.renderTarget.scissor.copy(this._scissor),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport)}setScissor(e,t,n,r){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new j),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,n,r),this._scissor.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setViewport(e,t,n,r){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new j),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,n,r),this._viewport.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}};af.COLOR=`color`,af.DEPTH=`depth`,K(1.6605,-.1246,-.0182),K(-.5876,1.1329,-.1006),K(-.0728,-.0083,1.1187),K(.6274,.0691,.0164),K(.3293,.9195,.088),K(.0433,.0113,.8956);var of=class extends I{static get type(){return`CodeNode`}constructor(e=``,t=[],n=``){super(`code`),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let n of t)n.build(e);let n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}};function sf(e){let t,n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||Z.z).negate()}U(([e,t],n)=>Ws(e,t,sf(n))),U(([e],t)=>{let n=sf(t);return e.mul(e,n,n).negate().exp().oneMinus()}),U(([e,t],n)=>{let r=sf(n),i=t.sub(Pl.y).max(0).toConst().mul(r).toConst();return e.mul(e,i,i).negate().exp().oneMinus()}),U(([e,t])=>q(t.toFloat().mix(ao.rgb,e.toVec3()),ao.a)),B(class extends I{constructor(e){super(),this.scope=e}generate(e){let{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}});var cf=class extends I{static get type(){return`AtomicFunctionNode`}constructor(e,t,n){super(`uint`),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),n=t.parents,r=this.method,i=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,s=this.valueNode,c=[];c.push(`&${o.build(e,a)}`),s!==null&&c.push(s.build(e,a));let l=`${e.getMethod(r,i)}( ${c.join(`, `)} )`;if(n&&n.length===1&&n[0].isStackNode===!0)e.addLineFlowCode(l,this);else return t.constNode===void 0&&(t.constNode=Pc(l,i).toConst()),t.constNode.build(e)}};cf.ATOMIC_LOAD=`atomicLoad`,cf.ATOMIC_STORE=`atomicStore`,cf.ATOMIC_ADD=`atomicAdd`,cf.ATOMIC_SUB=`atomicSub`,cf.ATOMIC_MAX=`atomicMax`,cf.ATOMIC_MIN=`atomicMin`,cf.ATOMIC_AND=`atomicAnd`,cf.ATOMIC_OR=`atomicOr`,cf.ATOMIC_XOR=`atomicXor`,B(cf);var $=class e extends Ui{static get type(){return`SubgroupFunctionNode`}constructor(e,t=null,n=null){super(),this.method=e,this.aNode=t,this.bNode=n}getInputType(e){let t=this.aNode?this.aNode.getNodeType(e):null,n=this.bNode?this.bNode.getNodeType(e):null;return(e.isMatrix(t)?0:e.getTypeLength(t))>(e.isMatrix(n)?0:e.getTypeLength(n))?t:n}getNodeType(t){let n=this.method;return n===e.SUBGROUP_ELECT?`bool`:n===e.SUBGROUP_BALLOT?`uvec4`:this.getInputType(t)}generate(t,n){let r=this.method,i=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,s=this.bNode,c=[];if(r===e.SUBGROUP_BROADCAST||r===e.SUBGROUP_SHUFFLE||r===e.QUAD_BROADCAST){let e=s.getNodeType(t);c.push(o.build(t,i),s.build(t,e===`float`?`int`:i))}else r===e.SUBGROUP_SHUFFLE_XOR||r===e.SUBGROUP_SHUFFLE_DOWN||r===e.SUBGROUP_SHUFFLE_UP?c.push(o.build(t,i),s.build(t,`uint`)):(o!==null&&c.push(o.build(t,a)),s!==null&&c.push(s.build(t,a)));let l=c.length===0?`()`:`( ${c.join(`, `)} )`;return t.format(`${t.getMethod(r,i)}${l}`,i,n)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};$.SUBGROUP_ELECT=`subgroupElect`,$.SUBGROUP_BALLOT=`subgroupBallot`,$.SUBGROUP_ADD=`subgroupAdd`,$.SUBGROUP_INCLUSIVE_ADD=`subgroupInclusiveAdd`,$.SUBGROUP_EXCLUSIVE_AND=`subgroupExclusiveAdd`,$.SUBGROUP_MUL=`subgroupMul`,$.SUBGROUP_INCLUSIVE_MUL=`subgroupInclusiveMul`,$.SUBGROUP_EXCLUSIVE_MUL=`subgroupExclusiveMul`,$.SUBGROUP_AND=`subgroupAnd`,$.SUBGROUP_OR=`subgroupOr`,$.SUBGROUP_XOR=`subgroupXor`,$.SUBGROUP_MIN=`subgroupMin`,$.SUBGROUP_MAX=`subgroupMax`,$.SUBGROUP_ALL=`subgroupAll`,$.SUBGROUP_ANY=`subgroupAny`,$.SUBGROUP_BROADCAST_FIRST=`subgroupBroadcastFirst`,$.QUAD_SWAP_X=`quadSwapX`,$.QUAD_SWAP_Y=`quadSwapY`,$.QUAD_SWAP_DIAGONAL=`quadSwapDiagonal`,$.SUBGROUP_BROADCAST=`subgroupBroadcast`,$.SUBGROUP_SHUFFLE=`subgroupShuffle`,$.SUBGROUP_SHUFFLE_XOR=`subgroupShuffleXor`,$.SUBGROUP_SHUFFLE_UP=`subgroupShuffleUp`,$.SUBGROUP_SHUFFLE_DOWN=`subgroupShuffleDown`,$.QUAD_BROADCAST=`quadBroadcast`,U(([e=Hc()],{renderer:t,material:n})=>{let r=zs(e.mul(2).sub(1)),i;if(n.alphaToCoverage&&t.currentSamples>0){let e=W(r.fwidth()).toVar();i=Ws(e.oneMinus(),e.add(1),r).oneMinus()}else i=qs(r.greaterThan(1),0,1);return i});var lf=class{constructor(e,t,n=null,r=``,i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}};lf.isNodeFunctionInput=!0;var uf=class{constructor(e,t,n=``,r=``){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){T(`Abstract function.`)}};uf.isNodeFunction=!0,new of(`uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }`),new of(`uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }`);var df=typeof self<`u`&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4};Li.READ_ONLY,Li.WRITE_ONLY,Li.READ_WRITE,df.VERTEX,df.FRAGMENT,df.COMPUTE,new of(`fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }`),new of(`fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }`),new of(`fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }`),new of(`fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }`),new of(`fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }`),new of(`fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }`),new of(`fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }`),new of(`fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }`),new of(`fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }`),new of(`fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }`),new of(`fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }`),new of(`fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }`),new of(`
278
+ fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
279
+
280
+ let res = vec2f( iRes );
281
+
282
+ let uvScaled = coord * res;
283
+ let uvWrapping = ( ( uvScaled % res ) + res ) % res;
284
+
285
+ // https://www.shadertoy.com/view/WtyXRy
286
+
287
+ let uv = uvWrapping - 0.5;
288
+ let iuv = floor( uv );
289
+ let f = fract( uv );
290
+
291
+ let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
292
+ let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
293
+ let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
294
+ let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
295
+
296
+ return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
297
+
298
+ }
299
+ `),new of(`
300
+ fn tsl_biquadraticTexture_array( map : texture_2d_array<f32>, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f {
301
+
302
+ let res = vec2f( iRes );
303
+
304
+ let uvScaled = coord * res;
305
+ let uvWrapping = ( ( uvScaled % res ) + res ) % res;
306
+
307
+ // https://www.shadertoy.com/view/WtyXRy
308
+
309
+ let uv = uvWrapping - 0.5;
310
+ let iuv = floor( uv );
311
+ let f = fract( uv );
312
+
313
+ let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level );
314
+ let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level );
315
+ let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level );
316
+ let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level );
317
+
318
+ return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
319
+
320
+ }
321
+ `);var ff=``;(typeof navigator<`u`&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(ff+=`diagnostic( off, derivative_uniformity );
322
+ `);var pf=new Map([[Int8Array,[`sint8`,`snorm8`]],[Uint8Array,[`uint8`,`unorm8`]],[Int16Array,[`sint16`,`snorm16`]],[Uint16Array,[`uint16`,`unorm16`]],[Int32Array,[`sint32`,`snorm32`]],[Uint32Array,[`uint32`,`unorm32`]],[Float32Array,[`float32`]]]);typeof Float16Array<`u`&&pf.set(Float16Array,[`float16`]);var mf=new t.Box3,hf=new t.Vector3,gf=class extends t.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type=`LineSegmentsGeometry`,this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute(`position`,new t.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute(`uv`,new t.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));let r=new t.InstancedInterleavedBuffer(n,6,1);return this.setAttribute(`instanceStart`,new t.InterleavedBufferAttribute(r,3,0)),this.setAttribute(`instanceEnd`,new t.InterleavedBufferAttribute(r,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));let r=new t.InstancedInterleavedBuffer(n,6,1);return this.setAttribute(`instanceColorStart`,new t.InterleavedBufferAttribute(r,3,0)),this.setAttribute(`instanceColorEnd`,new t.InterleavedBufferAttribute(r,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new t.WireframeGeometry(e.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new t.Box3);let e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),mf.setFromBufferAttribute(n),this.boundingBox.union(mf))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new t.Sphere),this.boundingBox===null&&this.computeBoundingBox();let e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){let t=this.boundingSphere.center;this.boundingBox.getCenter(t);let r=0;for(let i=0,a=e.count;i<a;i++)hf.fromBufferAttribute(e,i),r=Math.max(r,t.distanceToSquared(hf)),hf.fromBufferAttribute(n,i),r=Math.max(r,t.distanceToSquared(hf));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.`,this)}}toJSON(){}},_f=new k,vf=new k,yf=new j,bf=new j,xf=new j,Sf=new k,Cf=new mt,wf=new yi,Tf=new k,Ef=new ln,Df=new Nn,Of=new j,kf=new j,Af,jf;function Mf(e,t,n){return Of.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),Of.multiplyScalar(1/Of.w),Of.x=jf/n.width,Of.y=jf/n.height,Of.applyMatrix4(e.projectionMatrixInverse),Of.multiplyScalar(1/Of.w),Math.abs(Math.max(Of.x,Of.y))}function Nf(e,t){let n=e.matrixWorld,r=e.geometry,i=r.attributes.instanceStart,a=r.attributes.instanceEnd,o=Math.min(r.instanceCount,i.count);for(let r=0,s=o;r<s;r++){wf.start.fromBufferAttribute(i,r),wf.end.fromBufferAttribute(a,r),wf.applyMatrix4(n);let o=new k,s=new k;Af.distanceSqToSegment(wf.start,wf.end,s,o),s.distanceTo(o)<jf*.5&&t.push({point:s,pointOnLine:o,distance:Af.origin.distanceTo(s),object:e,face:null,faceIndex:r,uv:null,uv1:null})}}function Pf(e,t,n){let r=t.projectionMatrix,i=e.matrixWorld,a=e._resolution,o=e.geometry,s=o.attributes.instanceStart,c=o.attributes.instanceEnd,l=Math.min(o.instanceCount,s.count),u=-t.near;Af.at(1,xf),xf.w=1,xf.applyMatrix4(t.matrixWorldInverse),xf.applyMatrix4(r),xf.multiplyScalar(1/xf.w),xf.x*=a.x/2,xf.y*=a.y/2,xf.z=0,Sf.copy(xf),Cf.multiplyMatrices(t.matrixWorldInverse,i);for(let t=0,o=l;t<o;t++){if(yf.fromBufferAttribute(s,t),bf.fromBufferAttribute(c,t),yf.w=1,bf.w=1,yf.applyMatrix4(Cf),bf.applyMatrix4(Cf),yf.z>u&&bf.z>u)continue;if(yf.z>u){let e=yf.z-bf.z,t=(yf.z-u)/e;yf.lerp(bf,t)}else if(bf.z>u){let e=bf.z-yf.z,t=(bf.z-u)/e;bf.lerp(yf,t)}yf.applyMatrix4(r),bf.applyMatrix4(r),yf.multiplyScalar(1/yf.w),bf.multiplyScalar(1/bf.w),yf.x*=a.x/2,yf.y*=a.y/2,bf.x*=a.x/2,bf.y*=a.y/2,wf.start.copy(yf),wf.start.z=0,wf.end.copy(bf),wf.end.z=0;let o=wf.closestPointToPointParameter(Sf,!0);wf.at(o,Tf);let l=Ke.lerp(yf.z,bf.z,o),d=l>=-1&&l<=1,f=Sf.distanceTo(Tf)<jf*.5;if(d&&f){wf.start.fromBufferAttribute(s,t),wf.end.fromBufferAttribute(c,t),wf.start.applyMatrix4(i),wf.end.applyMatrix4(i);let r=new k,a=new k;Af.distanceSqToSegment(wf.start,wf.end,a,r),n.push({point:a,pointOnLine:r,distance:Af.origin.distanceTo(a),object:e,face:null,faceIndex:t,uv:null,uv1:null})}}}var Ff=class extends fr{constructor(e=new gf,t=new Gd({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type=`LineSegments2`,this._resolution=new qe}computeLineDistances(){let e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let e=0,i=0,a=t.count;e<a;e++,i+=2)_f.fromBufferAttribute(t,e),vf.fromBufferAttribute(n,e),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+_f.distanceTo(vf);let i=new ui(r,2,1);return e.setAttribute(`instanceDistanceStart`,new Un(i,1,0)),e.setAttribute(`instanceDistanceEnd`,new Un(i,1,1)),this}onBeforeRender(e){e.getViewport(kf),this._resolution.set(kf.z,kf.w)}raycast(e,t){let n=this.material.worldUnits,r=e.camera;r===null&&!n&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.`);let i=e.params.Line2===void 0?0:e.params.Line2.threshold||0;Af=e.ray;let a=this.matrixWorld,o=this.geometry;jf=this.material.linewidth+i,o.boundingSphere===null&&o.computeBoundingSphere(),Df.copy(o.boundingSphere).applyMatrix4(a);let s;if(s=n?jf*.5:Mf(r,Math.max(r.near,Df.distanceToPoint(Af.origin)),this._resolution),Df.radius+=s,Af.intersectsSphere(Df)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),Ef.copy(o.boundingBox).applyMatrix4(a);let c;c=n?jf*.5:Mf(r,Math.max(r.near,Ef.distanceToPoint(Af.origin)),this._resolution),Ef.expandByScalar(c),Af.intersectsBox(Ef)!==!1&&(n?Nf(this,t):Pf(this,r,t))}},If=class extends gf{constructor(){super(),this.isLineGeometry=!0,this.type=`LineGeometry`}setPositions(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setPositions(n),this}setColors(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setColors(n),this}setFromPoints(e){let t=e.length-1,n=new Float32Array(6*t);for(let r=0;r<t;r++)n[6*r]=e[r].x,n[6*r+1]=e[r].y,n[6*r+2]=e[r].z||0,n[6*r+3]=e[r+1].x,n[6*r+4]=e[r+1].y,n[6*r+5]=e[r+1].z||0;return super.setPositions(n),this}fromLine(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}},Lf=class extends Ff{constructor(e=new If,t=new Gd({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type=`Line2`}},Rf=14467195,zf=8,Bf=2,Vf=20,Hf=null;function Uf(e,t){t instanceof k?e.color.setRGB(t.x,t.y,t.z):e.color.set(t)}var Wf=class extends Vt{static get version(){return`1.0.0-alpha.8`}constructor(e=new k,t=new k){super(),this.type=`FiveLine`,this.needsRender=!0;let n=new If,r=new Gd({color:Rf,linewidth:Bf,dashed:!1});r.scale=Vf,this.line=new Lf(n,r);let i=new Bn,a=new xr({color:Rf,size:zf,map:Hf||(Hf=new Qr().load(`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==`)),sizeAttenuation:!1,transparent:!0});this.points=new Er(i,a),this.points.renderOrder=11,this.points.frustumCulled=!1,this.setPoints(e,t),this.add(this.line,this.points)}setPoints(e,t){let n=[].concat(e.toArray(),t.toArray());this.updatePointsPositions(n),this.updateLinePositions(n),this.needsRender=!0}updatePointsPositions(e){let t=this.points.geometry,n=t.getAttribute(`position`);n&&n.array.length===e.length?(n.array.set(e),n.needsUpdate=!0):t.setAttribute(`position`,new En(new Float32Array(e),3))}updateLinePositions(e){let t=this.line.geometry,n=t.getAttribute(`instanceStart`);if(!n||n.data.array.length!==e.length){t.setPositions(e),this.line.computeLineDistances();return}let r=n.data;r.array.set(e),r.needsUpdate=!0,t.computeBoundingBox(),t.computeBoundingSphere(),this.updateLineDistances()}updateLineDistances(){let e=this.line.geometry,t=e.getAttribute(`instanceDistanceStart`);if(!t){this.line.computeLineDistances();return}let n=e.getAttribute(`instanceStart`),r=e.getAttribute(`instanceEnd`),i=n.count,a=t.data,o=a.array,s=new k,c=new k;for(let e=0,t=0;e<i;e++,t+=2)s.fromBufferAttribute(n,e),c.fromBufferAttribute(r,e),o[t]=t===0?0:o[t-1],o[t+1]=o[t]+s.distanceTo(c);a.needsUpdate=!0}getPoints(){let e=this.points.geometry.attributes.position.array;return[new k(e[0],e[1],e[2]),new k(e[3],e[4],e[5])]}setMaterial(e){let t=this.line.material;for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;let r=e[n];if(n===`color`)Uf(t,r);else if(n===`dashed`)t.dashed=r;else if(n===`dashScale`)t.scale=r;else if(n===`resolution`){let e=r;this.setResolution(e.x,e.y)}else t[n]=r}this.needsRender=!0}setResolution(e,t){let n=this.line._resolution;n&&(n.x!==e||n.y!==t)&&(n.set(e,t),this.needsRender=!0)}};Object.assign(Wf.prototype,{isFiveLine:!0}),e.Line=Wf,e.LineGeometry=If,e.LineSegmentsGeometry=gf,e.THREE_Line2=Lf,e.THREE_LineSegments2=Ff});