@gnsx/three 0.184.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1182) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +85 -0
  3. package/build/three.cjs +79695 -0
  4. package/build/three.core.js +59732 -0
  5. package/build/three.core.min.js +6 -0
  6. package/build/three.module.js +19552 -0
  7. package/build/three.module.min.js +6 -0
  8. package/build/three.tsl.js +654 -0
  9. package/build/three.tsl.min.js +6 -0
  10. package/build/three.webgpu.js +83969 -0
  11. package/build/three.webgpu.min.js +6 -0
  12. package/build/three.webgpu.nodes.js +83702 -0
  13. package/build/three.webgpu.nodes.min.js +6 -0
  14. package/examples/fonts/LICENSE +13 -0
  15. package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
  16. package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
  17. package/examples/fonts/README.md +11 -0
  18. package/examples/fonts/droid/NOTICE +190 -0
  19. package/examples/fonts/droid/README.txt +18 -0
  20. package/examples/fonts/droid/droid_sans_bold.typeface.json +1 -0
  21. package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +1 -0
  22. package/examples/fonts/droid/droid_sans_regular.typeface.json +1 -0
  23. package/examples/fonts/droid/droid_serif_bold.typeface.json +1 -0
  24. package/examples/fonts/droid/droid_serif_regular.typeface.json +1 -0
  25. package/examples/fonts/gentilis_bold.typeface.json +1 -0
  26. package/examples/fonts/gentilis_regular.typeface.json +1 -0
  27. package/examples/fonts/helvetiker_bold.typeface.json +1 -0
  28. package/examples/fonts/helvetiker_regular.typeface.json +1 -0
  29. package/examples/fonts/optimer_bold.typeface.json +1 -0
  30. package/examples/fonts/optimer_regular.typeface.json +1 -0
  31. package/examples/fonts/ttf/README.md +9 -0
  32. package/examples/fonts/ttf/kenpixel.ttf +0 -0
  33. package/examples/jsm/Addons.js +293 -0
  34. package/examples/jsm/animation/AnimationClipCreator.js +168 -0
  35. package/examples/jsm/animation/CCDIKSolver.js +595 -0
  36. package/examples/jsm/capabilities/WebGL.js +113 -0
  37. package/examples/jsm/capabilities/WebGPU.js +59 -0
  38. package/examples/jsm/controls/ArcballControls.js +3539 -0
  39. package/examples/jsm/controls/DragControls.js +452 -0
  40. package/examples/jsm/controls/FirstPersonControls.js +451 -0
  41. package/examples/jsm/controls/FlyControls.js +384 -0
  42. package/examples/jsm/controls/MapControls.js +116 -0
  43. package/examples/jsm/controls/OrbitControls.js +1963 -0
  44. package/examples/jsm/controls/PointerLockControls.js +264 -0
  45. package/examples/jsm/controls/TrackballControls.js +1001 -0
  46. package/examples/jsm/controls/TransformControls.js +1950 -0
  47. package/examples/jsm/csm/CSM.js +598 -0
  48. package/examples/jsm/csm/CSMFrustum.js +209 -0
  49. package/examples/jsm/csm/CSMHelper.js +243 -0
  50. package/examples/jsm/csm/CSMShader.js +307 -0
  51. package/examples/jsm/csm/CSMShadowNode.js +603 -0
  52. package/examples/jsm/curves/CurveExtras.js +694 -0
  53. package/examples/jsm/curves/NURBSCurve.js +155 -0
  54. package/examples/jsm/curves/NURBSSurface.js +98 -0
  55. package/examples/jsm/curves/NURBSUtils.js +532 -0
  56. package/examples/jsm/curves/NURBSVolume.js +82 -0
  57. package/examples/jsm/effects/AnaglyphEffect.js +274 -0
  58. package/examples/jsm/effects/AsciiEffect.js +310 -0
  59. package/examples/jsm/effects/OutlineEffect.js +489 -0
  60. package/examples/jsm/effects/ParallaxBarrierEffect.js +155 -0
  61. package/examples/jsm/effects/StereoEffect.js +91 -0
  62. package/examples/jsm/environments/ColorEnvironment.js +59 -0
  63. package/examples/jsm/environments/DebugEnvironment.js +102 -0
  64. package/examples/jsm/environments/RoomEnvironment.js +185 -0
  65. package/examples/jsm/exporters/DRACOExporter.js +311 -0
  66. package/examples/jsm/exporters/EXRExporter.js +618 -0
  67. package/examples/jsm/exporters/GLTFExporter.js +3738 -0
  68. package/examples/jsm/exporters/KTX2Exporter.js +347 -0
  69. package/examples/jsm/exporters/OBJExporter.js +308 -0
  70. package/examples/jsm/exporters/PLYExporter.js +562 -0
  71. package/examples/jsm/exporters/STLExporter.js +221 -0
  72. package/examples/jsm/exporters/USDZExporter.js +1254 -0
  73. package/examples/jsm/geometries/BoxLineGeometry.js +92 -0
  74. package/examples/jsm/geometries/ConvexGeometry.js +72 -0
  75. package/examples/jsm/geometries/DecalGeometry.js +420 -0
  76. package/examples/jsm/geometries/ParametricFunctions.js +100 -0
  77. package/examples/jsm/geometries/ParametricGeometry.js +172 -0
  78. package/examples/jsm/geometries/RoundedBoxGeometry.js +216 -0
  79. package/examples/jsm/geometries/TeapotGeometry.js +689 -0
  80. package/examples/jsm/geometries/TextGeometry.js +102 -0
  81. package/examples/jsm/gpgpu/BitonicSort.js +715 -0
  82. package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
  83. package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
  84. package/examples/jsm/helpers/LightProbeHelper.js +165 -0
  85. package/examples/jsm/helpers/LightProbeHelperGPU.js +102 -0
  86. package/examples/jsm/helpers/OctreeHelper.js +109 -0
  87. package/examples/jsm/helpers/PositionalAudioHelper.js +169 -0
  88. package/examples/jsm/helpers/RapierHelper.js +59 -0
  89. package/examples/jsm/helpers/RectAreaLightHelper.js +118 -0
  90. package/examples/jsm/helpers/TextureHelper.js +265 -0
  91. package/examples/jsm/helpers/TextureHelperGPU.js +214 -0
  92. package/examples/jsm/helpers/VertexNormalsHelper.js +155 -0
  93. package/examples/jsm/helpers/VertexTangentsHelper.js +133 -0
  94. package/examples/jsm/helpers/ViewHelper.js +519 -0
  95. package/examples/jsm/inspector/Extension.js +13 -0
  96. package/examples/jsm/inspector/Inspector.js +542 -0
  97. package/examples/jsm/inspector/RendererInspector.js +425 -0
  98. package/examples/jsm/inspector/extensions/extensions.json +6 -0
  99. package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
  100. package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
  101. package/examples/jsm/inspector/tabs/Console.js +238 -0
  102. package/examples/jsm/inspector/tabs/Memory.js +128 -0
  103. package/examples/jsm/inspector/tabs/Parameters.js +380 -0
  104. package/examples/jsm/inspector/tabs/Performance.js +268 -0
  105. package/examples/jsm/inspector/tabs/Settings.js +264 -0
  106. package/examples/jsm/inspector/tabs/Timeline.js +1611 -0
  107. package/examples/jsm/inspector/tabs/Viewer.js +268 -0
  108. package/examples/jsm/inspector/ui/Graph.js +95 -0
  109. package/examples/jsm/inspector/ui/Item.js +170 -0
  110. package/examples/jsm/inspector/ui/List.js +75 -0
  111. package/examples/jsm/inspector/ui/Profiler.js +2072 -0
  112. package/examples/jsm/inspector/ui/Style.js +1667 -0
  113. package/examples/jsm/inspector/ui/Tab.js +265 -0
  114. package/examples/jsm/inspector/ui/Values.js +476 -0
  115. package/examples/jsm/inspector/ui/utils.js +69 -0
  116. package/examples/jsm/interaction/InteractionManager.js +226 -0
  117. package/examples/jsm/interactive/HTMLMesh.js +601 -0
  118. package/examples/jsm/interactive/InteractiveGroup.js +224 -0
  119. package/examples/jsm/interactive/SelectionBox.js +324 -0
  120. package/examples/jsm/interactive/SelectionHelper.js +150 -0
  121. package/examples/jsm/libs/ammo.wasm.js +822 -0
  122. package/examples/jsm/libs/ammo.wasm.wasm +0 -0
  123. package/examples/jsm/libs/basis/README.md +46 -0
  124. package/examples/jsm/libs/basis/basis_transcoder.js +19 -0
  125. package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
  126. package/examples/jsm/libs/chevrotain.module.min.js +141 -0
  127. package/examples/jsm/libs/demuxer_mp4.js +109 -0
  128. package/examples/jsm/libs/draco/README.md +32 -0
  129. package/examples/jsm/libs/draco/draco_decoder.js +34 -0
  130. package/examples/jsm/libs/draco/draco_decoder.wasm +0 -0
  131. package/examples/jsm/libs/draco/draco_encoder.js +33 -0
  132. package/examples/jsm/libs/draco/draco_wasm_wrapper.js +117 -0
  133. package/examples/jsm/libs/draco/gltf/draco_decoder.js +33 -0
  134. package/examples/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
  135. package/examples/jsm/libs/draco/gltf/draco_encoder.js +33 -0
  136. package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
  137. package/examples/jsm/libs/ecsy.module.js +1792 -0
  138. package/examples/jsm/libs/fflate.module.js +2672 -0
  139. package/examples/jsm/libs/ktx-parse.module.js +1 -0
  140. package/examples/jsm/libs/lil-gui.module.min.js +8 -0
  141. package/examples/jsm/libs/lottie_canvas.module.js +14849 -0
  142. package/examples/jsm/libs/meshopt_decoder.module.js +196 -0
  143. package/examples/jsm/libs/mikktspace.module.js +128 -0
  144. package/examples/jsm/libs/motion-controllers.module.js +397 -0
  145. package/examples/jsm/libs/opentype.module.js +14506 -0
  146. package/examples/jsm/libs/potpack.module.js +125 -0
  147. package/examples/jsm/libs/rhino3dm/rhino3dm.js +21 -0
  148. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +16 -0
  149. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  150. package/examples/jsm/libs/stats.module.js +167 -0
  151. package/examples/jsm/libs/surfaceNet.js +201 -0
  152. package/examples/jsm/libs/tween.module.js +876 -0
  153. package/examples/jsm/libs/utif.module.js +1665 -0
  154. package/examples/jsm/libs/zstddec.module.js +1 -0
  155. package/examples/jsm/lighting/DynamicLighting.js +82 -0
  156. package/examples/jsm/lighting/LightProbeGrid.js +651 -0
  157. package/examples/jsm/lighting/TiledLighting.js +42 -0
  158. package/examples/jsm/lights/LightProbeGenerator.js +337 -0
  159. package/examples/jsm/lights/RectAreaLightTexturesLib.js +127 -0
  160. package/examples/jsm/lights/RectAreaLightUniformsLib.js +40 -0
  161. package/examples/jsm/lines/Line2.js +56 -0
  162. package/examples/jsm/lines/LineGeometry.js +157 -0
  163. package/examples/jsm/lines/LineMaterial.js +703 -0
  164. package/examples/jsm/lines/LineSegments2.js +426 -0
  165. package/examples/jsm/lines/LineSegmentsGeometry.js +298 -0
  166. package/examples/jsm/lines/Wireframe.js +108 -0
  167. package/examples/jsm/lines/WireframeGeometry2.js +49 -0
  168. package/examples/jsm/lines/webgpu/Line2.js +46 -0
  169. package/examples/jsm/lines/webgpu/LineSegments2.js +411 -0
  170. package/examples/jsm/lines/webgpu/Wireframe.js +86 -0
  171. package/examples/jsm/loaders/3DMLoader.js +1836 -0
  172. package/examples/jsm/loaders/3MFLoader.js +1621 -0
  173. package/examples/jsm/loaders/AMFLoader.js +541 -0
  174. package/examples/jsm/loaders/BVHLoader.js +484 -0
  175. package/examples/jsm/loaders/ColladaLoader.js +153 -0
  176. package/examples/jsm/loaders/DDSLoader.js +385 -0
  177. package/examples/jsm/loaders/DRACOLoader.js +739 -0
  178. package/examples/jsm/loaders/EXRLoader.js +3423 -0
  179. package/examples/jsm/loaders/FBXLoader.js +4580 -0
  180. package/examples/jsm/loaders/FontLoader.js +260 -0
  181. package/examples/jsm/loaders/GCodeLoader.js +318 -0
  182. package/examples/jsm/loaders/GLTFLoader.js +4860 -0
  183. package/examples/jsm/loaders/HDRCubeTextureLoader.js +164 -0
  184. package/examples/jsm/loaders/HDRLoader.js +485 -0
  185. package/examples/jsm/loaders/IESLoader.js +379 -0
  186. package/examples/jsm/loaders/KMZLoader.js +163 -0
  187. package/examples/jsm/loaders/KTX2Loader.js +1257 -0
  188. package/examples/jsm/loaders/KTXLoader.js +197 -0
  189. package/examples/jsm/loaders/LDrawLoader.js +2510 -0
  190. package/examples/jsm/loaders/LUT3dlLoader.js +205 -0
  191. package/examples/jsm/loaders/LUTCubeLoader.js +190 -0
  192. package/examples/jsm/loaders/LUTImageLoader.js +190 -0
  193. package/examples/jsm/loaders/LWOLoader.js +1047 -0
  194. package/examples/jsm/loaders/LottieLoader.js +130 -0
  195. package/examples/jsm/loaders/MD2Loader.js +435 -0
  196. package/examples/jsm/loaders/MDDLoader.js +147 -0
  197. package/examples/jsm/loaders/MTLLoader.js +593 -0
  198. package/examples/jsm/loaders/MaterialXLoader.js +1104 -0
  199. package/examples/jsm/loaders/NRRDLoader.js +718 -0
  200. package/examples/jsm/loaders/OBJLoader.js +955 -0
  201. package/examples/jsm/loaders/PCDLoader.js +620 -0
  202. package/examples/jsm/loaders/PDBLoader.js +272 -0
  203. package/examples/jsm/loaders/PLYLoader.js +805 -0
  204. package/examples/jsm/loaders/PVRLoader.js +270 -0
  205. package/examples/jsm/loaders/RGBELoader.js +18 -0
  206. package/examples/jsm/loaders/STLLoader.js +421 -0
  207. package/examples/jsm/loaders/SVGLoader.js +3267 -0
  208. package/examples/jsm/loaders/TDSLoader.js +1142 -0
  209. package/examples/jsm/loaders/TGALoader.js +538 -0
  210. package/examples/jsm/loaders/TIFFLoader.js +59 -0
  211. package/examples/jsm/loaders/TTFLoader.js +261 -0
  212. package/examples/jsm/loaders/USDLoader.js +279 -0
  213. package/examples/jsm/loaders/USDZLoader.js +16 -0
  214. package/examples/jsm/loaders/UltraHDRLoader.js +755 -0
  215. package/examples/jsm/loaders/VOXLoader.js +919 -0
  216. package/examples/jsm/loaders/VRMLLoader.js +3646 -0
  217. package/examples/jsm/loaders/VTKLoader.js +1293 -0
  218. package/examples/jsm/loaders/XYZLoader.js +143 -0
  219. package/examples/jsm/loaders/collada/ColladaComposer.js +3044 -0
  220. package/examples/jsm/loaders/collada/ColladaParser.js +1977 -0
  221. package/examples/jsm/loaders/lwo/IFFParser.js +1217 -0
  222. package/examples/jsm/loaders/lwo/LWO2Parser.js +414 -0
  223. package/examples/jsm/loaders/lwo/LWO3Parser.js +373 -0
  224. package/examples/jsm/loaders/usd/USDAParser.js +828 -0
  225. package/examples/jsm/loaders/usd/USDCParser.js +1878 -0
  226. package/examples/jsm/loaders/usd/USDComposer.js +4594 -0
  227. package/examples/jsm/materials/LDrawConditionalLineMaterial.js +183 -0
  228. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +154 -0
  229. package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
  230. package/examples/jsm/math/Capsule.js +159 -0
  231. package/examples/jsm/math/ColorConverter.js +58 -0
  232. package/examples/jsm/math/ColorSpaces.js +147 -0
  233. package/examples/jsm/math/ConvexHull.js +1695 -0
  234. package/examples/jsm/math/ImprovedNoise.js +88 -0
  235. package/examples/jsm/math/Lut.js +317 -0
  236. package/examples/jsm/math/MeshSurfaceSampler.js +315 -0
  237. package/examples/jsm/math/OBB.js +535 -0
  238. package/examples/jsm/math/Octree.js +822 -0
  239. package/examples/jsm/math/SimplexNoise.js +470 -0
  240. package/examples/jsm/misc/ConvexObjectBreaker.js +539 -0
  241. package/examples/jsm/misc/GPUComputationRenderer.js +508 -0
  242. package/examples/jsm/misc/Gyroscope.js +78 -0
  243. package/examples/jsm/misc/MD2Character.js +391 -0
  244. package/examples/jsm/misc/MD2CharacterComplex.js +740 -0
  245. package/examples/jsm/misc/MorphAnimMesh.js +119 -0
  246. package/examples/jsm/misc/MorphBlendMesh.js +425 -0
  247. package/examples/jsm/misc/ProgressiveLightMap.js +370 -0
  248. package/examples/jsm/misc/ProgressiveLightMapGPU.js +322 -0
  249. package/examples/jsm/misc/RollerCoaster.js +661 -0
  250. package/examples/jsm/misc/TubePainter.js +599 -0
  251. package/examples/jsm/misc/Volume.js +520 -0
  252. package/examples/jsm/misc/VolumeSlice.js +275 -0
  253. package/examples/jsm/modifiers/CurveModifier.js +374 -0
  254. package/examples/jsm/modifiers/CurveModifierGPU.js +256 -0
  255. package/examples/jsm/modifiers/EdgeSplitModifier.js +299 -0
  256. package/examples/jsm/modifiers/SimplifyModifier.js +632 -0
  257. package/examples/jsm/modifiers/TessellateModifier.js +340 -0
  258. package/examples/jsm/objects/GroundedSkybox.js +69 -0
  259. package/examples/jsm/objects/Lensflare.js +489 -0
  260. package/examples/jsm/objects/LensflareMesh.js +376 -0
  261. package/examples/jsm/objects/MarchingCubes.js +1261 -0
  262. package/examples/jsm/objects/Reflector.js +386 -0
  263. package/examples/jsm/objects/ReflectorForSSRPass.js +393 -0
  264. package/examples/jsm/objects/Refractor.js +389 -0
  265. package/examples/jsm/objects/ShadowMesh.js +130 -0
  266. package/examples/jsm/objects/Sky.js +321 -0
  267. package/examples/jsm/objects/SkyMesh.js +377 -0
  268. package/examples/jsm/objects/Water.js +374 -0
  269. package/examples/jsm/objects/Water2.js +403 -0
  270. package/examples/jsm/objects/Water2Mesh.js +199 -0
  271. package/examples/jsm/objects/WaterMesh.js +194 -0
  272. package/examples/jsm/offscreen/jank.js +45 -0
  273. package/examples/jsm/offscreen/offscreen.js +8 -0
  274. package/examples/jsm/offscreen/scene.js +86 -0
  275. package/examples/jsm/physics/AmmoPhysics.js +359 -0
  276. package/examples/jsm/physics/JoltPhysics.js +334 -0
  277. package/examples/jsm/physics/RapierPhysics.js +436 -0
  278. package/examples/jsm/postprocessing/AfterimagePass.js +185 -0
  279. package/examples/jsm/postprocessing/BloomPass.js +274 -0
  280. package/examples/jsm/postprocessing/BokehPass.js +218 -0
  281. package/examples/jsm/postprocessing/ClearPass.js +97 -0
  282. package/examples/jsm/postprocessing/CubeTexturePass.js +146 -0
  283. package/examples/jsm/postprocessing/DotScreenPass.js +114 -0
  284. package/examples/jsm/postprocessing/EffectComposer.js +365 -0
  285. package/examples/jsm/postprocessing/FXAAPass.js +40 -0
  286. package/examples/jsm/postprocessing/FilmPass.js +113 -0
  287. package/examples/jsm/postprocessing/GTAOPass.js +727 -0
  288. package/examples/jsm/postprocessing/GlitchPass.js +177 -0
  289. package/examples/jsm/postprocessing/HalftonePass.js +134 -0
  290. package/examples/jsm/postprocessing/LUTPass.js +138 -0
  291. package/examples/jsm/postprocessing/MaskPass.js +195 -0
  292. package/examples/jsm/postprocessing/OutlinePass.js +776 -0
  293. package/examples/jsm/postprocessing/OutputPass.js +148 -0
  294. package/examples/jsm/postprocessing/Pass.js +191 -0
  295. package/examples/jsm/postprocessing/RenderPass.js +193 -0
  296. package/examples/jsm/postprocessing/RenderPixelatedPass.js +314 -0
  297. package/examples/jsm/postprocessing/RenderTransitionPass.js +267 -0
  298. package/examples/jsm/postprocessing/SAOPass.js +407 -0
  299. package/examples/jsm/postprocessing/SMAAPass.js +230 -0
  300. package/examples/jsm/postprocessing/SSAARenderPass.js +313 -0
  301. package/examples/jsm/postprocessing/SSAOPass.js +527 -0
  302. package/examples/jsm/postprocessing/SSRPass.js +856 -0
  303. package/examples/jsm/postprocessing/SavePass.js +132 -0
  304. package/examples/jsm/postprocessing/ShaderPass.js +135 -0
  305. package/examples/jsm/postprocessing/TAARenderPass.js +243 -0
  306. package/examples/jsm/postprocessing/TexturePass.js +131 -0
  307. package/examples/jsm/postprocessing/UnrealBloomPass.js +524 -0
  308. package/examples/jsm/renderers/CSS2DRenderer.js +328 -0
  309. package/examples/jsm/renderers/CSS3DRenderer.js +454 -0
  310. package/examples/jsm/renderers/Projector.js +1154 -0
  311. package/examples/jsm/renderers/SVGRenderer.js +799 -0
  312. package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +96 -0
  313. package/examples/jsm/shaders/AfterimageShader.js +63 -0
  314. package/examples/jsm/shaders/BasicShader.js +36 -0
  315. package/examples/jsm/shaders/BleachBypassShader.js +68 -0
  316. package/examples/jsm/shaders/BlendShader.js +56 -0
  317. package/examples/jsm/shaders/BokehShader.js +151 -0
  318. package/examples/jsm/shaders/BokehShader2.js +404 -0
  319. package/examples/jsm/shaders/BrightnessContrastShader.js +62 -0
  320. package/examples/jsm/shaders/ColorCorrectionShader.js +59 -0
  321. package/examples/jsm/shaders/ColorifyShader.js +57 -0
  322. package/examples/jsm/shaders/ConvolutionShader.js +74 -0
  323. package/examples/jsm/shaders/CopyShader.js +52 -0
  324. package/examples/jsm/shaders/DOFMipMapShader.js +63 -0
  325. package/examples/jsm/shaders/DepthLimitedBlurShader.js +180 -0
  326. package/examples/jsm/shaders/DigitalGlitch.js +104 -0
  327. package/examples/jsm/shaders/DotScreenShader.js +75 -0
  328. package/examples/jsm/shaders/ExposureShader.js +51 -0
  329. package/examples/jsm/shaders/FXAAShader.js +298 -0
  330. package/examples/jsm/shaders/FilmShader.js +72 -0
  331. package/examples/jsm/shaders/FocusShader.js +94 -0
  332. package/examples/jsm/shaders/FreiChenShader.js +103 -0
  333. package/examples/jsm/shaders/GTAOShader.js +434 -0
  334. package/examples/jsm/shaders/GammaCorrectionShader.js +52 -0
  335. package/examples/jsm/shaders/HalftoneShader.js +332 -0
  336. package/examples/jsm/shaders/HorizontalBlurShader.js +68 -0
  337. package/examples/jsm/shaders/HorizontalTiltShiftShader.js +70 -0
  338. package/examples/jsm/shaders/HueSaturationShader.js +74 -0
  339. package/examples/jsm/shaders/KaleidoShader.js +65 -0
  340. package/examples/jsm/shaders/LuminosityHighPassShader.js +68 -0
  341. package/examples/jsm/shaders/LuminosityShader.js +54 -0
  342. package/examples/jsm/shaders/MirrorShader.js +62 -0
  343. package/examples/jsm/shaders/NormalMapShader.js +60 -0
  344. package/examples/jsm/shaders/OutputShader.js +103 -0
  345. package/examples/jsm/shaders/PoissonDenoiseShader.js +239 -0
  346. package/examples/jsm/shaders/RGBShiftShader.js +61 -0
  347. package/examples/jsm/shaders/SAOShader.js +201 -0
  348. package/examples/jsm/shaders/SMAAShader.js +489 -0
  349. package/examples/jsm/shaders/SSAOShader.js +331 -0
  350. package/examples/jsm/shaders/SSRShader.js +396 -0
  351. package/examples/jsm/shaders/SepiaShader.js +57 -0
  352. package/examples/jsm/shaders/SobelOperatorShader.js +98 -0
  353. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +95 -0
  354. package/examples/jsm/shaders/TechnicolorShader.js +51 -0
  355. package/examples/jsm/shaders/ToonShader.js +349 -0
  356. package/examples/jsm/shaders/TriangleBlurShader.js +79 -0
  357. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +60 -0
  358. package/examples/jsm/shaders/VelocityShader.js +137 -0
  359. package/examples/jsm/shaders/VerticalBlurShader.js +66 -0
  360. package/examples/jsm/shaders/VerticalTiltShiftShader.js +70 -0
  361. package/examples/jsm/shaders/VignetteShader.js +56 -0
  362. package/examples/jsm/shaders/VolumeShader.js +298 -0
  363. package/examples/jsm/shaders/WaterRefractionShader.js +106 -0
  364. package/examples/jsm/textures/FlakesTexture.js +54 -0
  365. package/examples/jsm/transpiler/AST.js +675 -0
  366. package/examples/jsm/transpiler/GLSLDecoder.js +1228 -0
  367. package/examples/jsm/transpiler/Linker.js +327 -0
  368. package/examples/jsm/transpiler/ShaderToyDecoder.js +51 -0
  369. package/examples/jsm/transpiler/TSLEncoder.js +983 -0
  370. package/examples/jsm/transpiler/Transpiler.js +67 -0
  371. package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
  372. package/examples/jsm/transpiler/WGSLEncoder.js +839 -0
  373. package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
  374. package/examples/jsm/tsl/display/AfterImageNode.js +254 -0
  375. package/examples/jsm/tsl/display/AnaglyphPassNode.js +549 -0
  376. package/examples/jsm/tsl/display/AnamorphicNode.js +293 -0
  377. package/examples/jsm/tsl/display/BilateralBlurNode.js +374 -0
  378. package/examples/jsm/tsl/display/BleachBypass.js +33 -0
  379. package/examples/jsm/tsl/display/BloomNode.js +534 -0
  380. package/examples/jsm/tsl/display/CRT.js +150 -0
  381. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +174 -0
  382. package/examples/jsm/tsl/display/DenoiseNode.js +334 -0
  383. package/examples/jsm/tsl/display/DepthOfFieldNode.js +554 -0
  384. package/examples/jsm/tsl/display/DotScreenNode.js +104 -0
  385. package/examples/jsm/tsl/display/FSR1Node.js +477 -0
  386. package/examples/jsm/tsl/display/FXAANode.js +365 -0
  387. package/examples/jsm/tsl/display/FilmNode.js +101 -0
  388. package/examples/jsm/tsl/display/GTAONode.js +572 -0
  389. package/examples/jsm/tsl/display/GaussianBlurNode.js +399 -0
  390. package/examples/jsm/tsl/display/GodraysNode.js +615 -0
  391. package/examples/jsm/tsl/display/LensflareNode.js +279 -0
  392. package/examples/jsm/tsl/display/Lut3DNode.js +109 -0
  393. package/examples/jsm/tsl/display/MotionBlur.js +33 -0
  394. package/examples/jsm/tsl/display/OutlineNode.js +812 -0
  395. package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +89 -0
  396. package/examples/jsm/tsl/display/PixelationPassNode.js +335 -0
  397. package/examples/jsm/tsl/display/RGBShiftNode.js +96 -0
  398. package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
  399. package/examples/jsm/tsl/display/SMAANode.js +768 -0
  400. package/examples/jsm/tsl/display/SSAAPassNode.js +358 -0
  401. package/examples/jsm/tsl/display/SSGINode.js +638 -0
  402. package/examples/jsm/tsl/display/SSRNode.js +656 -0
  403. package/examples/jsm/tsl/display/SSSNode.js +490 -0
  404. package/examples/jsm/tsl/display/Sepia.js +24 -0
  405. package/examples/jsm/tsl/display/Shape.js +29 -0
  406. package/examples/jsm/tsl/display/SharpenNode.js +283 -0
  407. package/examples/jsm/tsl/display/SobelOperatorNode.js +168 -0
  408. package/examples/jsm/tsl/display/StereoCompositePassNode.js +192 -0
  409. package/examples/jsm/tsl/display/StereoPassNode.js +119 -0
  410. package/examples/jsm/tsl/display/TAAUNode.js +835 -0
  411. package/examples/jsm/tsl/display/TRAANode.js +767 -0
  412. package/examples/jsm/tsl/display/TransitionNode.js +141 -0
  413. package/examples/jsm/tsl/display/boxBlur.js +65 -0
  414. package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
  415. package/examples/jsm/tsl/display/hashBlur.js +54 -0
  416. package/examples/jsm/tsl/display/radialBlur.js +68 -0
  417. package/examples/jsm/tsl/lighting/DynamicLightsNode.js +300 -0
  418. package/examples/jsm/tsl/lighting/TiledLightsNode.js +442 -0
  419. package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
  420. package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
  421. package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
  422. package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
  423. package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
  424. package/examples/jsm/tsl/math/Bayer.js +84 -0
  425. package/examples/jsm/tsl/shadows/TileShadowNode.js +456 -0
  426. package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +212 -0
  427. package/examples/jsm/tsl/utils/Raymarching.js +70 -0
  428. package/examples/jsm/utils/BufferGeometryUtils.js +1434 -0
  429. package/examples/jsm/utils/CameraUtils.js +82 -0
  430. package/examples/jsm/utils/ColorUtils.js +76 -0
  431. package/examples/jsm/utils/GeometryCompressionUtils.js +547 -0
  432. package/examples/jsm/utils/GeometryUtils.js +226 -0
  433. package/examples/jsm/utils/LDrawUtils.js +211 -0
  434. package/examples/jsm/utils/SceneOptimizer.js +458 -0
  435. package/examples/jsm/utils/SceneUtils.js +363 -0
  436. package/examples/jsm/utils/ShadowMapViewer.js +244 -0
  437. package/examples/jsm/utils/ShadowMapViewerGPU.js +233 -0
  438. package/examples/jsm/utils/SkeletonUtils.js +496 -0
  439. package/examples/jsm/utils/SortUtils.js +175 -0
  440. package/examples/jsm/utils/UVsDebug.js +173 -0
  441. package/examples/jsm/utils/WebGLTextureUtils.js +115 -0
  442. package/examples/jsm/utils/WebGPUTextureUtils.js +81 -0
  443. package/examples/jsm/utils/WorkerPool.js +167 -0
  444. package/examples/jsm/webxr/ARButton.js +251 -0
  445. package/examples/jsm/webxr/OculusHandModel.js +194 -0
  446. package/examples/jsm/webxr/OculusHandPointerModel.js +539 -0
  447. package/examples/jsm/webxr/Text2D.js +52 -0
  448. package/examples/jsm/webxr/VRButton.js +264 -0
  449. package/examples/jsm/webxr/XRButton.js +246 -0
  450. package/examples/jsm/webxr/XRControllerModelFactory.js +403 -0
  451. package/examples/jsm/webxr/XREstimatedLight.js +254 -0
  452. package/examples/jsm/webxr/XRHandMeshModel.js +177 -0
  453. package/examples/jsm/webxr/XRHandModelFactory.js +198 -0
  454. package/examples/jsm/webxr/XRHandPrimitiveModel.js +147 -0
  455. package/examples/jsm/webxr/XRPlanes.js +118 -0
  456. package/package.json +123 -0
  457. package/src/Three.Core.js +187 -0
  458. package/src/Three.Legacy.js +0 -0
  459. package/src/Three.TSL.js +647 -0
  460. package/src/Three.WebGPU.Nodes.js +31 -0
  461. package/src/Three.WebGPU.js +37 -0
  462. package/src/Three.js +10 -0
  463. package/src/animation/AnimationAction.js +942 -0
  464. package/src/animation/AnimationClip.js +628 -0
  465. package/src/animation/AnimationMixer.js +860 -0
  466. package/src/animation/AnimationObjectGroup.js +411 -0
  467. package/src/animation/AnimationUtils.js +495 -0
  468. package/src/animation/KeyframeTrack.js +636 -0
  469. package/src/animation/PropertyBinding.js +794 -0
  470. package/src/animation/PropertyMixer.js +385 -0
  471. package/src/animation/tracks/BooleanKeyframeTrack.js +55 -0
  472. package/src/animation/tracks/ColorKeyframeTrack.js +36 -0
  473. package/src/animation/tracks/NumberKeyframeTrack.js +36 -0
  474. package/src/animation/tracks/QuaternionKeyframeTrack.js +51 -0
  475. package/src/animation/tracks/StringKeyframeTrack.js +55 -0
  476. package/src/animation/tracks/VectorKeyframeTrack.js +36 -0
  477. package/src/audio/Audio.js +778 -0
  478. package/src/audio/AudioAnalyser.js +97 -0
  479. package/src/audio/AudioContext.js +40 -0
  480. package/src/audio/AudioListener.js +218 -0
  481. package/src/audio/PositionalAudio.js +253 -0
  482. package/src/cameras/ArrayCamera.js +54 -0
  483. package/src/cameras/Camera.js +160 -0
  484. package/src/cameras/CubeCamera.js +259 -0
  485. package/src/cameras/OrthographicCamera.js +245 -0
  486. package/src/cameras/PerspectiveCamera.js +407 -0
  487. package/src/cameras/StereoCamera.js +146 -0
  488. package/src/constants.js +1760 -0
  489. package/src/core/BufferAttribute.js +1056 -0
  490. package/src/core/BufferGeometry.js +1458 -0
  491. package/src/core/Clock.js +135 -0
  492. package/src/core/EventDispatcher.js +131 -0
  493. package/src/core/GLBufferAttribute.js +171 -0
  494. package/src/core/InstancedBufferAttribute.js +68 -0
  495. package/src/core/InstancedBufferGeometry.js +60 -0
  496. package/src/core/InstancedInterleavedBuffer.js +74 -0
  497. package/src/core/InterleavedBuffer.js +291 -0
  498. package/src/core/InterleavedBufferAttribute.js +549 -0
  499. package/src/core/Layers.js +121 -0
  500. package/src/core/Object3D.js +1667 -0
  501. package/src/core/Raycaster.js +262 -0
  502. package/src/core/RenderTarget.js +392 -0
  503. package/src/core/RenderTarget3D.js +48 -0
  504. package/src/core/Timer.js +184 -0
  505. package/src/core/Uniform.js +46 -0
  506. package/src/core/UniformsGroup.js +180 -0
  507. package/src/extras/Controls.js +120 -0
  508. package/src/extras/DataUtils.js +217 -0
  509. package/src/extras/Earcut.js +28 -0
  510. package/src/extras/ImageUtils.js +137 -0
  511. package/src/extras/PMREMGenerator.js +1167 -0
  512. package/src/extras/ShapeUtils.js +114 -0
  513. package/src/extras/TextureUtils.js +297 -0
  514. package/src/extras/core/Curve.js +517 -0
  515. package/src/extras/core/CurvePath.js +296 -0
  516. package/src/extras/core/Interpolations.js +111 -0
  517. package/src/extras/core/Path.js +329 -0
  518. package/src/extras/core/Shape.js +165 -0
  519. package/src/extras/core/ShapePath.js +367 -0
  520. package/src/extras/curves/ArcCurve.js +39 -0
  521. package/src/extras/curves/CatmullRomCurve3.js +327 -0
  522. package/src/extras/curves/CubicBezierCurve.js +145 -0
  523. package/src/extras/curves/CubicBezierCurve3.js +129 -0
  524. package/src/extras/curves/Curves.js +10 -0
  525. package/src/extras/curves/EllipseCurve.js +258 -0
  526. package/src/extras/curves/LineCurve.js +128 -0
  527. package/src/extras/curves/LineCurve3.js +128 -0
  528. package/src/extras/curves/QuadraticBezierCurve.js +133 -0
  529. package/src/extras/curves/QuadraticBezierCurve3.js +118 -0
  530. package/src/extras/curves/SplineCurve.js +145 -0
  531. package/src/extras/lib/earcut.js +685 -0
  532. package/src/geometries/BoxGeometry.js +219 -0
  533. package/src/geometries/CapsuleGeometry.js +218 -0
  534. package/src/geometries/CircleGeometry.js +142 -0
  535. package/src/geometries/ConeGeometry.js +70 -0
  536. package/src/geometries/CylinderGeometry.js +333 -0
  537. package/src/geometries/DodecahedronGeometry.js +99 -0
  538. package/src/geometries/EdgesGeometry.js +180 -0
  539. package/src/geometries/ExtrudeGeometry.js +910 -0
  540. package/src/geometries/Geometries.js +21 -0
  541. package/src/geometries/IcosahedronGeometry.js +75 -0
  542. package/src/geometries/LatheGeometry.js +230 -0
  543. package/src/geometries/OctahedronGeometry.js +70 -0
  544. package/src/geometries/PlaneGeometry.js +133 -0
  545. package/src/geometries/PolyhedronGeometry.js +348 -0
  546. package/src/geometries/RingGeometry.js +165 -0
  547. package/src/geometries/ShapeGeometry.js +233 -0
  548. package/src/geometries/SphereGeometry.js +175 -0
  549. package/src/geometries/TetrahedronGeometry.js +67 -0
  550. package/src/geometries/TorusGeometry.js +161 -0
  551. package/src/geometries/TorusKnotGeometry.js +206 -0
  552. package/src/geometries/TubeGeometry.js +253 -0
  553. package/src/geometries/WireframeGeometry.js +179 -0
  554. package/src/helpers/ArrowHelper.js +171 -0
  555. package/src/helpers/AxesHelper.js +96 -0
  556. package/src/helpers/Box3Helper.js +83 -0
  557. package/src/helpers/BoxHelper.js +149 -0
  558. package/src/helpers/CameraHelper.js +345 -0
  559. package/src/helpers/DirectionalLightHelper.js +148 -0
  560. package/src/helpers/GridHelper.js +82 -0
  561. package/src/helpers/HemisphereLightHelper.js +130 -0
  562. package/src/helpers/PlaneHelper.js +96 -0
  563. package/src/helpers/PointLightHelper.js +111 -0
  564. package/src/helpers/PolarGridHelper.js +126 -0
  565. package/src/helpers/SkeletonHelper.js +194 -0
  566. package/src/helpers/SpotLightHelper.js +154 -0
  567. package/src/lights/AmbientLight.js +42 -0
  568. package/src/lights/DirectionalLight.js +113 -0
  569. package/src/lights/DirectionalLightShadow.js +31 -0
  570. package/src/lights/HemisphereLight.js +76 -0
  571. package/src/lights/Light.js +85 -0
  572. package/src/lights/LightProbe.js +75 -0
  573. package/src/lights/LightShadow.js +347 -0
  574. package/src/lights/PointLight.js +131 -0
  575. package/src/lights/PointLightShadow.js +31 -0
  576. package/src/lights/RectAreaLight.js +115 -0
  577. package/src/lights/SpotLight.js +194 -0
  578. package/src/lights/SpotLightShadow.js +80 -0
  579. package/src/lights/webgpu/IESSpotLight.js +47 -0
  580. package/src/lights/webgpu/ProjectorLight.js +46 -0
  581. package/src/loaders/AnimationLoader.js +98 -0
  582. package/src/loaders/AudioLoader.js +108 -0
  583. package/src/loaders/BufferGeometryLoader.js +242 -0
  584. package/src/loaders/Cache.js +115 -0
  585. package/src/loaders/CompressedTextureLoader.js +167 -0
  586. package/src/loaders/CubeTextureLoader.js +103 -0
  587. package/src/loaders/DataTextureLoader.js +174 -0
  588. package/src/loaders/FileLoader.js +367 -0
  589. package/src/loaders/ImageBitmapLoader.js +223 -0
  590. package/src/loaders/ImageLoader.js +168 -0
  591. package/src/loaders/Loader.js +222 -0
  592. package/src/loaders/LoaderUtils.js +59 -0
  593. package/src/loaders/LoadingManager.js +329 -0
  594. package/src/loaders/MaterialLoader.js +439 -0
  595. package/src/loaders/ObjectLoader.js +1304 -0
  596. package/src/loaders/TextureLoader.js +74 -0
  597. package/src/loaders/nodes/NodeLoader.js +194 -0
  598. package/src/loaders/nodes/NodeMaterialLoader.js +108 -0
  599. package/src/loaders/nodes/NodeObjectLoader.js +169 -0
  600. package/src/materials/LineBasicMaterial.js +122 -0
  601. package/src/materials/LineDashedMaterial.js +86 -0
  602. package/src/materials/Material.js +1017 -0
  603. package/src/materials/Materials.js +39 -0
  604. package/src/materials/MeshBasicMaterial.js +250 -0
  605. package/src/materials/MeshDepthMaterial.js +148 -0
  606. package/src/materials/MeshDistanceMaterial.js +119 -0
  607. package/src/materials/MeshLambertMaterial.js +402 -0
  608. package/src/materials/MeshMatcapMaterial.js +245 -0
  609. package/src/materials/MeshNormalMaterial.js +175 -0
  610. package/src/materials/MeshPhongMaterial.js +421 -0
  611. package/src/materials/MeshPhysicalMaterial.js +536 -0
  612. package/src/materials/MeshStandardMaterial.js +425 -0
  613. package/src/materials/MeshToonMaterial.js +321 -0
  614. package/src/materials/PointsMaterial.js +139 -0
  615. package/src/materials/RawShaderMaterial.js +42 -0
  616. package/src/materials/ShaderMaterial.js +413 -0
  617. package/src/materials/ShadowMaterial.js +91 -0
  618. package/src/materials/SpriteMaterial.js +136 -0
  619. package/src/materials/nodes/Line2NodeMaterial.js +569 -0
  620. package/src/materials/nodes/LineBasicNodeMaterial.js +46 -0
  621. package/src/materials/nodes/LineDashedNodeMaterial.js +132 -0
  622. package/src/materials/nodes/MeshBasicNodeMaterial.js +134 -0
  623. package/src/materials/nodes/MeshLambertNodeMaterial.js +82 -0
  624. package/src/materials/nodes/MeshMatcapNodeMaterial.js +77 -0
  625. package/src/materials/nodes/MeshNormalNodeMaterial.js +67 -0
  626. package/src/materials/nodes/MeshPhongNodeMaterial.js +141 -0
  627. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +521 -0
  628. package/src/materials/nodes/MeshSSSNodeMaterial.js +175 -0
  629. package/src/materials/nodes/MeshStandardNodeMaterial.js +187 -0
  630. package/src/materials/nodes/MeshToonNodeMaterial.js +66 -0
  631. package/src/materials/nodes/NodeMaterial.js +1330 -0
  632. package/src/materials/nodes/NodeMaterials.js +21 -0
  633. package/src/materials/nodes/PointsNodeMaterial.js +211 -0
  634. package/src/materials/nodes/ShadowNodeMaterial.js +76 -0
  635. package/src/materials/nodes/SpriteNodeMaterial.js +186 -0
  636. package/src/materials/nodes/VolumeNodeMaterial.js +81 -0
  637. package/src/materials/nodes/manager/NodeMaterialObserver.js +718 -0
  638. package/src/math/Box2.js +381 -0
  639. package/src/math/Box3.js +805 -0
  640. package/src/math/Color.js +967 -0
  641. package/src/math/ColorManagement.js +215 -0
  642. package/src/math/Cylindrical.js +120 -0
  643. package/src/math/Euler.js +449 -0
  644. package/src/math/Frustum.js +285 -0
  645. package/src/math/FrustumArray.js +258 -0
  646. package/src/math/Interpolant.js +320 -0
  647. package/src/math/Line3.js +337 -0
  648. package/src/math/MathUtils.js +751 -0
  649. package/src/math/Matrix2.js +128 -0
  650. package/src/math/Matrix3.js +617 -0
  651. package/src/math/Matrix4.js +1314 -0
  652. package/src/math/Plane.js +368 -0
  653. package/src/math/Quaternion.js +918 -0
  654. package/src/math/Ray.js +655 -0
  655. package/src/math/Sphere.js +420 -0
  656. package/src/math/Spherical.js +147 -0
  657. package/src/math/SphericalHarmonics3.js +341 -0
  658. package/src/math/Triangle.js +539 -0
  659. package/src/math/Vector2.js +870 -0
  660. package/src/math/Vector3.js +1263 -0
  661. package/src/math/Vector4.js +1067 -0
  662. package/src/math/interpolants/BezierInterpolant.js +108 -0
  663. package/src/math/interpolants/CubicInterpolant.js +159 -0
  664. package/src/math/interpolants/DiscreteInterpolant.js +34 -0
  665. package/src/math/interpolants/LinearInterpolant.js +51 -0
  666. package/src/math/interpolants/QuaternionLinearInterpolant.js +48 -0
  667. package/src/nodes/Nodes.js +166 -0
  668. package/src/nodes/TSL.js +173 -0
  669. package/src/nodes/accessors/AccessorsUtils.js +53 -0
  670. package/src/nodes/accessors/Arrays.js +68 -0
  671. package/src/nodes/accessors/BatchNode.js +163 -0
  672. package/src/nodes/accessors/Bitangent.js +82 -0
  673. package/src/nodes/accessors/BufferAttributeNode.js +432 -0
  674. package/src/nodes/accessors/BufferNode.js +128 -0
  675. package/src/nodes/accessors/BuiltinNode.js +63 -0
  676. package/src/nodes/accessors/Camera.js +403 -0
  677. package/src/nodes/accessors/ClippingNode.js +255 -0
  678. package/src/nodes/accessors/CubeTextureNode.js +215 -0
  679. package/src/nodes/accessors/InstanceNode.js +349 -0
  680. package/src/nodes/accessors/InstancedMeshNode.js +50 -0
  681. package/src/nodes/accessors/Lights.js +139 -0
  682. package/src/nodes/accessors/MaterialNode.js +783 -0
  683. package/src/nodes/accessors/MaterialProperties.js +56 -0
  684. package/src/nodes/accessors/MaterialReferenceNode.js +84 -0
  685. package/src/nodes/accessors/ModelNode.js +184 -0
  686. package/src/nodes/accessors/ModelViewProjectionNode.js +13 -0
  687. package/src/nodes/accessors/MorphNode.js +310 -0
  688. package/src/nodes/accessors/Normal.js +243 -0
  689. package/src/nodes/accessors/Object3DNode.js +268 -0
  690. package/src/nodes/accessors/PointUVNode.js +55 -0
  691. package/src/nodes/accessors/Position.js +122 -0
  692. package/src/nodes/accessors/ReferenceBaseNode.js +357 -0
  693. package/src/nodes/accessors/ReferenceNode.js +424 -0
  694. package/src/nodes/accessors/ReflectVector.js +36 -0
  695. package/src/nodes/accessors/RendererReferenceNode.js +78 -0
  696. package/src/nodes/accessors/SceneProperties.js +47 -0
  697. package/src/nodes/accessors/SkinningNode.js +328 -0
  698. package/src/nodes/accessors/StorageBufferNode.js +405 -0
  699. package/src/nodes/accessors/StorageTextureNode.js +295 -0
  700. package/src/nodes/accessors/Tangent.js +60 -0
  701. package/src/nodes/accessors/TangentUtils.js +46 -0
  702. package/src/nodes/accessors/Texture3DNode.js +196 -0
  703. package/src/nodes/accessors/TextureBicubic.js +92 -0
  704. package/src/nodes/accessors/TextureNode.js +971 -0
  705. package/src/nodes/accessors/TextureSizeNode.js +77 -0
  706. package/src/nodes/accessors/UV.js +11 -0
  707. package/src/nodes/accessors/UniformArrayNode.js +350 -0
  708. package/src/nodes/accessors/UserDataNode.js +76 -0
  709. package/src/nodes/accessors/VelocityNode.js +224 -0
  710. package/src/nodes/accessors/VertexColorNode.js +109 -0
  711. package/src/nodes/code/CodeNode.js +181 -0
  712. package/src/nodes/code/ExpressionNode.js +68 -0
  713. package/src/nodes/code/FunctionCallNode.js +187 -0
  714. package/src/nodes/code/FunctionNode.js +182 -0
  715. package/src/nodes/core/ArrayNode.js +174 -0
  716. package/src/nodes/core/AssignNode.js +202 -0
  717. package/src/nodes/core/AttributeNode.js +168 -0
  718. package/src/nodes/core/BypassNode.js +93 -0
  719. package/src/nodes/core/ConstNode.js +67 -0
  720. package/src/nodes/core/ContextNode.js +283 -0
  721. package/src/nodes/core/IndexNode.js +165 -0
  722. package/src/nodes/core/InputNode.js +136 -0
  723. package/src/nodes/core/InspectorNode.js +128 -0
  724. package/src/nodes/core/IsolateNode.js +133 -0
  725. package/src/nodes/core/LightingModel.js +77 -0
  726. package/src/nodes/core/MRTNode.js +196 -0
  727. package/src/nodes/core/Node.js +1180 -0
  728. package/src/nodes/core/NodeAttribute.js +53 -0
  729. package/src/nodes/core/NodeBuilder.js +3299 -0
  730. package/src/nodes/core/NodeCache.js +75 -0
  731. package/src/nodes/core/NodeCode.js +46 -0
  732. package/src/nodes/core/NodeError.js +28 -0
  733. package/src/nodes/core/NodeFrame.js +314 -0
  734. package/src/nodes/core/NodeFunction.js +69 -0
  735. package/src/nodes/core/NodeFunctionInput.js +61 -0
  736. package/src/nodes/core/NodeParser.js +23 -0
  737. package/src/nodes/core/NodeUniform.js +91 -0
  738. package/src/nodes/core/NodeUtils.js +408 -0
  739. package/src/nodes/core/NodeVar.js +60 -0
  740. package/src/nodes/core/NodeVarying.js +63 -0
  741. package/src/nodes/core/OutputStructNode.js +105 -0
  742. package/src/nodes/core/ParameterNode.js +94 -0
  743. package/src/nodes/core/PropertyNode.js +367 -0
  744. package/src/nodes/core/StackNode.js +426 -0
  745. package/src/nodes/core/StackTrace.js +139 -0
  746. package/src/nodes/core/StructNode.js +134 -0
  747. package/src/nodes/core/StructType.js +13 -0
  748. package/src/nodes/core/StructTypeNode.js +148 -0
  749. package/src/nodes/core/SubBuildNode.js +89 -0
  750. package/src/nodes/core/TempNode.js +88 -0
  751. package/src/nodes/core/UniformGroupNode.js +167 -0
  752. package/src/nodes/core/UniformNode.js +259 -0
  753. package/src/nodes/core/VarNode.js +367 -0
  754. package/src/nodes/core/VaryingNode.js +210 -0
  755. package/src/nodes/core/constants.js +68 -0
  756. package/src/nodes/display/BlendModes.js +171 -0
  757. package/src/nodes/display/BumpMapNode.js +117 -0
  758. package/src/nodes/display/ColorAdjustment.js +158 -0
  759. package/src/nodes/display/ColorSpaceFunctions.js +54 -0
  760. package/src/nodes/display/ColorSpaceNode.js +164 -0
  761. package/src/nodes/display/FrontFacingNode.js +102 -0
  762. package/src/nodes/display/NormalMapNode.js +153 -0
  763. package/src/nodes/display/PassNode.js +1055 -0
  764. package/src/nodes/display/RenderOutputNode.js +150 -0
  765. package/src/nodes/display/ScreenNode.js +292 -0
  766. package/src/nodes/display/ToneMappingFunctions.js +242 -0
  767. package/src/nodes/display/ToneMappingNode.js +147 -0
  768. package/src/nodes/display/ToonOutlinePassNode.js +191 -0
  769. package/src/nodes/display/ViewportDepthNode.js +342 -0
  770. package/src/nodes/display/ViewportDepthTextureNode.js +63 -0
  771. package/src/nodes/display/ViewportSharedTextureNode.js +73 -0
  772. package/src/nodes/display/ViewportTextureNode.js +256 -0
  773. package/src/nodes/fog/Fog.js +97 -0
  774. package/src/nodes/functions/BSDF/BRDF_GGX.js +55 -0
  775. package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
  776. package/src/nodes/functions/BSDF/BRDF_Lambert.js +9 -0
  777. package/src/nodes/functions/BSDF/BRDF_Sheen.js +57 -0
  778. package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
  779. package/src/nodes/functions/BSDF/D_GGX.js +23 -0
  780. package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
  781. package/src/nodes/functions/BSDF/EnvironmentBRDF.js +13 -0
  782. package/src/nodes/functions/BSDF/F_Schlick.js +16 -0
  783. package/src/nodes/functions/BSDF/LTC.js +175 -0
  784. package/src/nodes/functions/BSDF/Schlick_to_F0.js +21 -0
  785. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +26 -0
  786. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
  787. package/src/nodes/functions/BasicLightingModel.js +100 -0
  788. package/src/nodes/functions/PhongLightingModel.js +99 -0
  789. package/src/nodes/functions/PhysicalLightingModel.js +878 -0
  790. package/src/nodes/functions/ShadowMaskModel.js +58 -0
  791. package/src/nodes/functions/ToonLightingModel.js +70 -0
  792. package/src/nodes/functions/VolumetricLightingModel.js +183 -0
  793. package/src/nodes/functions/material/getAlphaHashThreshold.js +68 -0
  794. package/src/nodes/functions/material/getGeometryRoughness.js +19 -0
  795. package/src/nodes/functions/material/getParallaxCorrectNormal.js +37 -0
  796. package/src/nodes/functions/material/getRoughness.js +18 -0
  797. package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
  798. package/src/nodes/geometry/RangeNode.js +210 -0
  799. package/src/nodes/gpgpu/AtomicFunctionNode.js +274 -0
  800. package/src/nodes/gpgpu/BarrierNode.js +98 -0
  801. package/src/nodes/gpgpu/ComputeBuiltinNode.js +227 -0
  802. package/src/nodes/gpgpu/ComputeNode.js +310 -0
  803. package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
  804. package/src/nodes/gpgpu/WorkgroupInfoNode.js +234 -0
  805. package/src/nodes/lighting/AONode.js +45 -0
  806. package/src/nodes/lighting/AmbientLightNode.js +35 -0
  807. package/src/nodes/lighting/AnalyticLightNode.js +309 -0
  808. package/src/nodes/lighting/BasicEnvironmentNode.js +49 -0
  809. package/src/nodes/lighting/BasicLightMapNode.js +49 -0
  810. package/src/nodes/lighting/DirectionalLightNode.js +39 -0
  811. package/src/nodes/lighting/EnvironmentNode.js +178 -0
  812. package/src/nodes/lighting/HemisphereLightNode.js +87 -0
  813. package/src/nodes/lighting/IESSpotLightNode.js +49 -0
  814. package/src/nodes/lighting/IrradianceNode.js +44 -0
  815. package/src/nodes/lighting/LightProbeNode.js +73 -0
  816. package/src/nodes/lighting/LightUtils.js +25 -0
  817. package/src/nodes/lighting/LightingContextNode.js +115 -0
  818. package/src/nodes/lighting/LightingNode.js +36 -0
  819. package/src/nodes/lighting/LightsNode.js +432 -0
  820. package/src/nodes/lighting/PointLightNode.js +102 -0
  821. package/src/nodes/lighting/PointShadowNode.js +325 -0
  822. package/src/nodes/lighting/ProjectorLightNode.js +91 -0
  823. package/src/nodes/lighting/RectAreaLightNode.js +133 -0
  824. package/src/nodes/lighting/ShadowBaseNode.js +81 -0
  825. package/src/nodes/lighting/ShadowFilterNode.js +264 -0
  826. package/src/nodes/lighting/ShadowNode.js +889 -0
  827. package/src/nodes/lighting/SpotLightNode.js +168 -0
  828. package/src/nodes/materialx/DISCLAIMER.md +199 -0
  829. package/src/nodes/materialx/MaterialXNodes.js +197 -0
  830. package/src/nodes/materialx/lib/mx_hsv.js +127 -0
  831. package/src/nodes/materialx/lib/mx_noise.js +1491 -0
  832. package/src/nodes/materialx/lib/mx_transform_color.js +23 -0
  833. package/src/nodes/math/BitcastNode.js +156 -0
  834. package/src/nodes/math/BitcountNode.js +433 -0
  835. package/src/nodes/math/ConditionalNode.js +245 -0
  836. package/src/nodes/math/Hash.js +21 -0
  837. package/src/nodes/math/MathNode.js +1202 -0
  838. package/src/nodes/math/MathUtils.js +54 -0
  839. package/src/nodes/math/OperatorNode.js +752 -0
  840. package/src/nodes/math/PackFloatNode.js +98 -0
  841. package/src/nodes/math/TriNoise3D.js +71 -0
  842. package/src/nodes/math/UnpackFloatNode.js +96 -0
  843. package/src/nodes/parsers/GLSLNodeFunction.js +168 -0
  844. package/src/nodes/parsers/GLSLNodeParser.js +25 -0
  845. package/src/nodes/pmrem/PMREMNode.js +397 -0
  846. package/src/nodes/pmrem/PMREMUtils.js +397 -0
  847. package/src/nodes/procedural/Checker.js +22 -0
  848. package/src/nodes/shapes/Shapes.js +33 -0
  849. package/src/nodes/tsl/TSLBase.js +36 -0
  850. package/src/nodes/tsl/TSLCore.js +1250 -0
  851. package/src/nodes/utils/ArrayElementNode.js +90 -0
  852. package/src/nodes/utils/ConvertNode.js +100 -0
  853. package/src/nodes/utils/CubeMapNode.js +237 -0
  854. package/src/nodes/utils/DebugNode.js +83 -0
  855. package/src/nodes/utils/Discard.js +24 -0
  856. package/src/nodes/utils/EquirectUV.js +27 -0
  857. package/src/nodes/utils/EventNode.js +148 -0
  858. package/src/nodes/utils/FlipNode.js +106 -0
  859. package/src/nodes/utils/FunctionOverloadingNode.js +170 -0
  860. package/src/nodes/utils/JoinNode.js +117 -0
  861. package/src/nodes/utils/LoopNode.js +349 -0
  862. package/src/nodes/utils/MatcapUV.js +22 -0
  863. package/src/nodes/utils/MaxMipLevelNode.js +103 -0
  864. package/src/nodes/utils/MemberNode.js +120 -0
  865. package/src/nodes/utils/Oscillators.js +41 -0
  866. package/src/nodes/utils/Packing.js +33 -0
  867. package/src/nodes/utils/PostProcessingUtils.js +154 -0
  868. package/src/nodes/utils/RTTNode.js +289 -0
  869. package/src/nodes/utils/ReflectorNode.js +629 -0
  870. package/src/nodes/utils/Remap.js +48 -0
  871. package/src/nodes/utils/RotateNode.js +103 -0
  872. package/src/nodes/utils/SampleNode.js +91 -0
  873. package/src/nodes/utils/SetNode.js +108 -0
  874. package/src/nodes/utils/SplitNode.js +179 -0
  875. package/src/nodes/utils/SpriteSheetUV.js +35 -0
  876. package/src/nodes/utils/SpriteUtils.js +63 -0
  877. package/src/nodes/utils/StorageArrayElementNode.js +143 -0
  878. package/src/nodes/utils/Timer.js +26 -0
  879. package/src/nodes/utils/TriplanarTextures.js +65 -0
  880. package/src/nodes/utils/UVUtils.js +67 -0
  881. package/src/nodes/utils/ViewportUtils.js +26 -0
  882. package/src/objects/BatchedMesh.js +1682 -0
  883. package/src/objects/Bone.js +41 -0
  884. package/src/objects/ClippingGroup.js +68 -0
  885. package/src/objects/Group.js +41 -0
  886. package/src/objects/InstancedMesh.js +422 -0
  887. package/src/objects/LOD.js +329 -0
  888. package/src/objects/Line.js +329 -0
  889. package/src/objects/LineLoop.js +37 -0
  890. package/src/objects/LineSegments.js +74 -0
  891. package/src/objects/Mesh.js +496 -0
  892. package/src/objects/Points.js +228 -0
  893. package/src/objects/Skeleton.js +392 -0
  894. package/src/objects/SkinnedMesh.js +370 -0
  895. package/src/objects/Sprite.js +245 -0
  896. package/src/renderers/WebGL3DRenderTarget.js +48 -0
  897. package/src/renderers/WebGLArrayRenderTarget.js +48 -0
  898. package/src/renderers/WebGLCubeRenderTarget.js +182 -0
  899. package/src/renderers/WebGLRenderTarget.js +34 -0
  900. package/src/renderers/WebGLRenderer.js +3699 -0
  901. package/src/renderers/common/Animation.js +159 -0
  902. package/src/renderers/common/Attributes.js +132 -0
  903. package/src/renderers/common/Backend.js +769 -0
  904. package/src/renderers/common/Background.js +225 -0
  905. package/src/renderers/common/BindGroup.js +46 -0
  906. package/src/renderers/common/Binding.js +71 -0
  907. package/src/renderers/common/Bindings.js +394 -0
  908. package/src/renderers/common/BlendMode.js +143 -0
  909. package/src/renderers/common/Buffer.js +127 -0
  910. package/src/renderers/common/BufferUtils.js +58 -0
  911. package/src/renderers/common/BundleGroup.js +83 -0
  912. package/src/renderers/common/CanvasTarget.js +341 -0
  913. package/src/renderers/common/ChainMap.js +122 -0
  914. package/src/renderers/common/ClippingContext.js +262 -0
  915. package/src/renderers/common/Color4.js +77 -0
  916. package/src/renderers/common/ComputePipeline.js +41 -0
  917. package/src/renderers/common/Constants.js +15 -0
  918. package/src/renderers/common/CubeRenderTarget.js +147 -0
  919. package/src/renderers/common/DataMap.js +90 -0
  920. package/src/renderers/common/Geometries.js +396 -0
  921. package/src/renderers/common/IndirectStorageBufferAttribute.js +38 -0
  922. package/src/renderers/common/Info.js +501 -0
  923. package/src/renderers/common/InspectorBase.js +151 -0
  924. package/src/renderers/common/Lighting.js +57 -0
  925. package/src/renderers/common/Pipeline.js +35 -0
  926. package/src/renderers/common/Pipelines.js +498 -0
  927. package/src/renderers/common/PostProcessing.js +28 -0
  928. package/src/renderers/common/ProgrammableStage.js +78 -0
  929. package/src/renderers/common/QuadMesh.js +112 -0
  930. package/src/renderers/common/ReadbackBuffer.js +78 -0
  931. package/src/renderers/common/RenderBundle.js +26 -0
  932. package/src/renderers/common/RenderBundles.js +71 -0
  933. package/src/renderers/common/RenderContext.js +281 -0
  934. package/src/renderers/common/RenderContexts.js +100 -0
  935. package/src/renderers/common/RenderList.js +404 -0
  936. package/src/renderers/common/RenderLists.js +78 -0
  937. package/src/renderers/common/RenderObject.js +915 -0
  938. package/src/renderers/common/RenderObjectPipeline.js +40 -0
  939. package/src/renderers/common/RenderObjects.js +218 -0
  940. package/src/renderers/common/RenderPipeline.js +255 -0
  941. package/src/renderers/common/Renderer.js +3654 -0
  942. package/src/renderers/common/RendererUtils.js +200 -0
  943. package/src/renderers/common/SampledTexture.js +152 -0
  944. package/src/renderers/common/Sampler.js +165 -0
  945. package/src/renderers/common/Storage3DTexture.js +100 -0
  946. package/src/renderers/common/StorageArrayTexture.js +84 -0
  947. package/src/renderers/common/StorageBuffer.js +53 -0
  948. package/src/renderers/common/StorageBufferAttribute.js +46 -0
  949. package/src/renderers/common/StorageInstancedBufferAttribute.js +46 -0
  950. package/src/renderers/common/StorageTexture.js +86 -0
  951. package/src/renderers/common/Textures.js +629 -0
  952. package/src/renderers/common/TimestampQueryPool.js +163 -0
  953. package/src/renderers/common/Uniform.js +375 -0
  954. package/src/renderers/common/UniformBuffer.js +34 -0
  955. package/src/renderers/common/UniformsGroup.js +548 -0
  956. package/src/renderers/common/XRManager.js +1684 -0
  957. package/src/renderers/common/XRRenderTarget.js +91 -0
  958. package/src/renderers/common/extras/PMREMGenerator.js +1042 -0
  959. package/src/renderers/common/nodes/NodeBuilderState.js +152 -0
  960. package/src/renderers/common/nodes/NodeLibrary.js +196 -0
  961. package/src/renderers/common/nodes/NodeManager.js +983 -0
  962. package/src/renderers/common/nodes/NodeSampledTexture.js +140 -0
  963. package/src/renderers/common/nodes/NodeSampler.js +62 -0
  964. package/src/renderers/common/nodes/NodeStorageBuffer.js +72 -0
  965. package/src/renderers/common/nodes/NodeUniform.js +418 -0
  966. package/src/renderers/common/nodes/NodeUniformBuffer.js +105 -0
  967. package/src/renderers/common/nodes/NodeUniformsGroup.js +51 -0
  968. package/src/renderers/shaders/DFGLUTData.js +49 -0
  969. package/src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js +7 -0
  970. package/src/renderers/shaders/ShaderChunk/alphahash_pars_fragment.glsl.js +68 -0
  971. package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +7 -0
  972. package/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js +7 -0
  973. package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +16 -0
  974. package/src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js +5 -0
  975. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +26 -0
  976. package/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js +8 -0
  977. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +49 -0
  978. package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -0
  979. package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +9 -0
  980. package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -0
  981. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +33 -0
  982. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +43 -0
  983. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +7 -0
  984. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +10 -0
  985. package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +21 -0
  986. package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +78 -0
  987. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js +9 -0
  988. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js +7 -0
  989. package/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js +7 -0
  990. package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +7 -0
  991. package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +7 -0
  992. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +7 -0
  993. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +29 -0
  994. package/src/renderers/shaders/ShaderChunk/colorspace_fragment.glsl.js +3 -0
  995. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +15 -0
  996. package/src/renderers/shaders/ShaderChunk/common.glsl.js +125 -0
  997. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +186 -0
  998. package/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js +5 -0
  999. package/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js +5 -0
  1000. package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +63 -0
  1001. package/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js +9 -0
  1002. package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +7 -0
  1003. package/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js +7 -0
  1004. package/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js +20 -0
  1005. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +17 -0
  1006. package/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js +7 -0
  1007. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +14 -0
  1008. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +58 -0
  1009. package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +21 -0
  1010. package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +22 -0
  1011. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +69 -0
  1012. package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +37 -0
  1013. package/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js +17 -0
  1014. package/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js +19 -0
  1015. package/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js +7 -0
  1016. package/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js +7 -0
  1017. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +27 -0
  1018. package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +120 -0
  1019. package/src/renderers/shaders/ShaderChunk/iridescence_pars_fragment.glsl.js +14 -0
  1020. package/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js +8 -0
  1021. package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
  1022. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +213 -0
  1023. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +19 -0
  1024. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +44 -0
  1025. package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
  1026. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +28 -0
  1027. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +216 -0
  1028. package/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js +7 -0
  1029. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +32 -0
  1030. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +161 -0
  1031. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +656 -0
  1032. package/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js +4 -0
  1033. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +26 -0
  1034. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +9 -0
  1035. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +9 -0
  1036. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +8 -0
  1037. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +8 -0
  1038. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +17 -0
  1039. package/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js +7 -0
  1040. package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +27 -0
  1041. package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +27 -0
  1042. package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +12 -0
  1043. package/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js +7 -0
  1044. package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +24 -0
  1045. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
  1046. package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +16 -0
  1047. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +26 -0
  1048. package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +16 -0
  1049. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +76 -0
  1050. package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +40 -0
  1051. package/src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js +14 -0
  1052. package/src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js +14 -0
  1053. package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +14 -0
  1054. package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +43 -0
  1055. package/src/renderers/shaders/ShaderChunk/opaque_fragment.glsl.js +11 -0
  1056. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +116 -0
  1057. package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +7 -0
  1058. package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +19 -0
  1059. package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +12 -0
  1060. package/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js +7 -0
  1061. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +376 -0
  1062. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +71 -0
  1063. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +78 -0
  1064. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +66 -0
  1065. package/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js +10 -0
  1066. package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +25 -0
  1067. package/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js +15 -0
  1068. package/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js +20 -0
  1069. package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +14 -0
  1070. package/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js +7 -0
  1071. package/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js +7 -0
  1072. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +200 -0
  1073. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +36 -0
  1074. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +235 -0
  1075. package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +119 -0
  1076. package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +145 -0
  1077. package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +122 -0
  1078. package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +21 -0
  1079. package/src/renderers/shaders/ShaderChunk.js +272 -0
  1080. package/src/renderers/shaders/ShaderLib/background.glsl.js +40 -0
  1081. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
  1082. package/src/renderers/shaders/ShaderLib/cube.glsl.js +36 -0
  1083. package/src/renderers/shaders/ShaderLib/depth.glsl.js +117 -0
  1084. package/src/renderers/shaders/ShaderLib/distance.glsl.js +77 -0
  1085. package/src/renderers/shaders/ShaderLib/equirect.glsl.js +35 -0
  1086. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +76 -0
  1087. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +116 -0
  1088. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +126 -0
  1089. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +112 -0
  1090. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +86 -0
  1091. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +128 -0
  1092. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +224 -0
  1093. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +118 -0
  1094. package/src/renderers/shaders/ShaderLib/points.glsl.js +87 -0
  1095. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +58 -0
  1096. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +79 -0
  1097. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +51 -0
  1098. package/src/renderers/shaders/ShaderLib.js +362 -0
  1099. package/src/renderers/shaders/UniformsLib.js +234 -0
  1100. package/src/renderers/shaders/UniformsUtils.js +154 -0
  1101. package/src/renderers/webgl/WebGLAnimation.js +54 -0
  1102. package/src/renderers/webgl/WebGLAttributes.js +237 -0
  1103. package/src/renderers/webgl/WebGLBackground.js +303 -0
  1104. package/src/renderers/webgl/WebGLBindingStates.js +666 -0
  1105. package/src/renderers/webgl/WebGLBufferRenderer.js +57 -0
  1106. package/src/renderers/webgl/WebGLCapabilities.js +150 -0
  1107. package/src/renderers/webgl/WebGLClipping.js +171 -0
  1108. package/src/renderers/webgl/WebGLEnvironments.js +228 -0
  1109. package/src/renderers/webgl/WebGLExtensions.js +61 -0
  1110. package/src/renderers/webgl/WebGLGeometries.js +186 -0
  1111. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +68 -0
  1112. package/src/renderers/webgl/WebGLInfo.js +73 -0
  1113. package/src/renderers/webgl/WebGLLights.js +584 -0
  1114. package/src/renderers/webgl/WebGLMaterials.js +602 -0
  1115. package/src/renderers/webgl/WebGLMorphtargets.js +168 -0
  1116. package/src/renderers/webgl/WebGLObjects.js +94 -0
  1117. package/src/renderers/webgl/WebGLOutput.js +270 -0
  1118. package/src/renderers/webgl/WebGLProgram.js +1031 -0
  1119. package/src/renderers/webgl/WebGLPrograms.js +679 -0
  1120. package/src/renderers/webgl/WebGLProperties.js +55 -0
  1121. package/src/renderers/webgl/WebGLRenderLists.js +253 -0
  1122. package/src/renderers/webgl/WebGLRenderStates.js +124 -0
  1123. package/src/renderers/webgl/WebGLShader.js +12 -0
  1124. package/src/renderers/webgl/WebGLShaderCache.js +124 -0
  1125. package/src/renderers/webgl/WebGLShadowMap.js +600 -0
  1126. package/src/renderers/webgl/WebGLState.js +1370 -0
  1127. package/src/renderers/webgl/WebGLTextures.js +2506 -0
  1128. package/src/renderers/webgl/WebGLUniforms.js +1203 -0
  1129. package/src/renderers/webgl/WebGLUniformsGroups.js +413 -0
  1130. package/src/renderers/webgl/WebGLUtils.js +217 -0
  1131. package/src/renderers/webgl-fallback/WebGLBackend.js +2783 -0
  1132. package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +99 -0
  1133. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +1676 -0
  1134. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +359 -0
  1135. package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +89 -0
  1136. package/src/renderers/webgl-fallback/utils/WebGLConstants.js +13 -0
  1137. package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +83 -0
  1138. package/src/renderers/webgl-fallback/utils/WebGLState.js +1361 -0
  1139. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +1324 -0
  1140. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +396 -0
  1141. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +317 -0
  1142. package/src/renderers/webgpu/WebGPUBackend.js +2602 -0
  1143. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +69 -0
  1144. package/src/renderers/webgpu/WebGPURenderer.js +107 -0
  1145. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +66 -0
  1146. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +100 -0
  1147. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +2523 -0
  1148. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +187 -0
  1149. package/src/renderers/webgpu/nodes/WGSLNodeParser.js +25 -0
  1150. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +522 -0
  1151. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +642 -0
  1152. package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
  1153. package/src/renderers/webgpu/utils/WebGPUConstants.js +354 -0
  1154. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +846 -0
  1155. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +389 -0
  1156. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +1673 -0
  1157. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +310 -0
  1158. package/src/renderers/webgpu/utils/WebGPUUtils.js +269 -0
  1159. package/src/renderers/webxr/WebXRController.js +440 -0
  1160. package/src/renderers/webxr/WebXRDepthSensing.js +155 -0
  1161. package/src/renderers/webxr/WebXRManager.js +1103 -0
  1162. package/src/scenes/Fog.js +98 -0
  1163. package/src/scenes/FogExp2.js +86 -0
  1164. package/src/scenes/Scene.js +165 -0
  1165. package/src/textures/CanvasTexture.js +45 -0
  1166. package/src/textures/CompressedArrayTexture.js +89 -0
  1167. package/src/textures/CompressedCubeTexture.js +48 -0
  1168. package/src/textures/CompressedTexture.js +86 -0
  1169. package/src/textures/CubeDepthTexture.js +76 -0
  1170. package/src/textures/CubeTexture.js +81 -0
  1171. package/src/textures/Data3DTexture.js +112 -0
  1172. package/src/textures/DataArrayTexture.js +134 -0
  1173. package/src/textures/DataTexture.js +87 -0
  1174. package/src/textures/DepthTexture.js +104 -0
  1175. package/src/textures/ExternalTexture.js +56 -0
  1176. package/src/textures/FramebufferTexture.js +85 -0
  1177. package/src/textures/HTMLTexture.js +74 -0
  1178. package/src/textures/Source.js +230 -0
  1179. package/src/textures/Texture.js +812 -0
  1180. package/src/textures/VideoFrameTexture.js +72 -0
  1181. package/src/textures/VideoTexture.js +127 -0
  1182. package/src/utils.js +493 -0
@@ -0,0 +1,3267 @@
1
+ import {
2
+ Box2,
3
+ BufferGeometry,
4
+ FileLoader,
5
+ Float32BufferAttribute,
6
+ Loader,
7
+ Matrix3,
8
+ Path,
9
+ Shape,
10
+ ShapePath,
11
+ ShapeUtils,
12
+ SRGBColorSpace,
13
+ Vector2,
14
+ Vector3
15
+ } from 'three';
16
+
17
+ const COLOR_SPACE_SVG = SRGBColorSpace;
18
+
19
+ /**
20
+ * A loader for the SVG format.
21
+ *
22
+ * Scalable Vector Graphics is an XML-based vector image format for two-dimensional graphics
23
+ * with support for interactivity and animation.
24
+ *
25
+ * ```js
26
+ * const loader = new SVGLoader();
27
+ * const data = await loader.loadAsync( 'data/svgSample.svg' );
28
+ *
29
+ * const paths = data.paths;
30
+ * const group = new THREE.Group();
31
+ *
32
+ * for ( let i = 0; i < paths.length; i ++ ) {
33
+ *
34
+ * const path = paths[ i ];
35
+ * const material = new THREE.MeshBasicMaterial( {
36
+ * color: path.color,
37
+ * side: THREE.DoubleSide,
38
+ * depthWrite: false
39
+ * } );
40
+ *
41
+ * const shapes = SVGLoader.createShapes( path );
42
+ *
43
+ * for ( let j = 0; j < shapes.length; j ++ ) {
44
+ *
45
+ * const shape = shapes[ j ];
46
+ * const geometry = new THREE.ShapeGeometry( shape );
47
+ * const mesh = new THREE.Mesh( geometry, material );
48
+ * group.add( mesh );
49
+ *
50
+ * }
51
+ *
52
+ * }
53
+ *
54
+ * scene.add( group );
55
+ * ```
56
+ *
57
+ * @augments Loader
58
+ * @three_import import { SVGLoader } from 'three/addons/loaders/SVGLoader.js';
59
+ */
60
+ class SVGLoader extends Loader {
61
+
62
+ /**
63
+ * Constructs a new SVG loader.
64
+ *
65
+ * @param {LoadingManager} [manager] - The loading manager.
66
+ */
67
+ constructor( manager ) {
68
+
69
+ super( manager );
70
+
71
+ /**
72
+ * Default dots per inch.
73
+ *
74
+ * @type {number}
75
+ * @default 90
76
+ */
77
+ this.defaultDPI = 90;
78
+
79
+ /**
80
+ * Default unit.
81
+ *
82
+ * @type {('mm'|'cm'|'in'|'pt'|'pc'|'px')}
83
+ * @default 'px'
84
+ */
85
+ this.defaultUnit = 'px';
86
+
87
+ }
88
+
89
+ /**
90
+ * Starts loading from the given URL and passes the loaded SVG asset
91
+ * to the `onLoad()` callback.
92
+ *
93
+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
94
+ * @param {function({paths:Array<ShapePath>,xml:string})} onLoad - Executed when the loading process has been finished.
95
+ * @param {onProgressCallback} onProgress - Executed while the loading is in progress.
96
+ * @param {onErrorCallback} onError - Executed when errors occur.
97
+ */
98
+ load( url, onLoad, onProgress, onError ) {
99
+
100
+ const scope = this;
101
+
102
+ const loader = new FileLoader( scope.manager );
103
+ loader.setPath( scope.path );
104
+ loader.setRequestHeader( scope.requestHeader );
105
+ loader.setWithCredentials( scope.withCredentials );
106
+ loader.load( url, function ( text ) {
107
+
108
+ try {
109
+
110
+ onLoad( scope.parse( text ) );
111
+
112
+ } catch ( e ) {
113
+
114
+ if ( onError ) {
115
+
116
+ onError( e );
117
+
118
+ } else {
119
+
120
+ console.error( e );
121
+
122
+ }
123
+
124
+ scope.manager.itemError( url );
125
+
126
+ }
127
+
128
+ }, onProgress, onError );
129
+
130
+ }
131
+
132
+ /**
133
+ * Parses the given SVG data and returns the resulting data.
134
+ *
135
+ * @param {string} text - The raw SVG data as a string.
136
+ * @return {{paths:Array<ShapePath>,xml:string}} An object holding an array of shape paths and the
137
+ * SVG XML document.
138
+ */
139
+ parse( text ) {
140
+
141
+ const scope = this;
142
+
143
+ function parseNode( node, style ) {
144
+
145
+ if ( node.nodeType !== 1 ) return;
146
+
147
+ const transform = getNodeTransform( node );
148
+
149
+ let isDefsNode = false;
150
+
151
+ let path = null;
152
+
153
+ switch ( node.nodeName ) {
154
+
155
+ case 'svg':
156
+ style = parseStyle( node, style );
157
+ break;
158
+
159
+ case 'style':
160
+ parseCSSStylesheet( node );
161
+ break;
162
+
163
+ case 'g':
164
+ style = parseStyle( node, style );
165
+ break;
166
+
167
+ case 'path':
168
+ style = parseStyle( node, style );
169
+ if ( node.hasAttribute( 'd' ) ) path = parsePathNode( node );
170
+ break;
171
+
172
+ case 'rect':
173
+ style = parseStyle( node, style );
174
+ path = parseRectNode( node );
175
+ break;
176
+
177
+ case 'polygon':
178
+ style = parseStyle( node, style );
179
+ path = parsePolygonNode( node );
180
+ break;
181
+
182
+ case 'polyline':
183
+ style = parseStyle( node, style );
184
+ path = parsePolylineNode( node );
185
+ break;
186
+
187
+ case 'circle':
188
+ style = parseStyle( node, style );
189
+ path = parseCircleNode( node );
190
+ break;
191
+
192
+ case 'ellipse':
193
+ style = parseStyle( node, style );
194
+ path = parseEllipseNode( node );
195
+ break;
196
+
197
+ case 'line':
198
+ style = parseStyle( node, style );
199
+ path = parseLineNode( node );
200
+ break;
201
+
202
+ case 'defs':
203
+ isDefsNode = true;
204
+ break;
205
+
206
+ case 'use':
207
+ style = parseStyle( node, style );
208
+
209
+ const href = node.getAttributeNS( 'http://www.w3.org/1999/xlink', 'href' ) || '';
210
+ const usedNodeId = href.substring( 1 );
211
+ const usedNode = node.viewportElement.getElementById( usedNodeId );
212
+ if ( usedNode ) {
213
+
214
+ parseNode( usedNode, style );
215
+
216
+ } else {
217
+
218
+ console.warn( 'SVGLoader: \'use node\' references non-existent node id: ' + usedNodeId );
219
+
220
+ }
221
+
222
+ break;
223
+
224
+ default:
225
+ // console.log( node );
226
+
227
+ }
228
+
229
+ if ( path ) {
230
+
231
+ if ( style.fill !== undefined && style.fill !== 'none' ) {
232
+
233
+ path.color.setStyle( style.fill, COLOR_SPACE_SVG );
234
+
235
+ }
236
+
237
+ transformPath( path, currentTransform );
238
+
239
+ paths.push( path );
240
+
241
+ path.userData = { node: node, style: style };
242
+
243
+ }
244
+
245
+ const childNodes = node.childNodes;
246
+
247
+ for ( let i = 0; i < childNodes.length; i ++ ) {
248
+
249
+ const node = childNodes[ i ];
250
+
251
+ if ( isDefsNode && node.nodeName !== 'style' && node.nodeName !== 'defs' ) {
252
+
253
+ // Ignore everything in defs except CSS style definitions
254
+ // and nested defs, because it is OK by the standard to have
255
+ // <style/> there.
256
+ continue;
257
+
258
+ }
259
+
260
+ parseNode( node, style );
261
+
262
+ }
263
+
264
+
265
+ if ( transform ) {
266
+
267
+ transformStack.pop();
268
+
269
+ if ( transformStack.length > 0 ) {
270
+
271
+ currentTransform.copy( transformStack[ transformStack.length - 1 ] );
272
+
273
+ } else {
274
+
275
+ currentTransform.identity();
276
+
277
+ }
278
+
279
+ }
280
+
281
+ }
282
+
283
+ function parsePathNode( node ) {
284
+
285
+ const path = new ShapePath();
286
+
287
+ const point = new Vector2();
288
+ const control = new Vector2();
289
+
290
+ const firstPoint = new Vector2();
291
+ let isFirstPoint = true;
292
+ let doSetFirstPoint = false;
293
+
294
+ const d = node.getAttribute( 'd' );
295
+
296
+ if ( d === '' || d === 'none' ) return null;
297
+
298
+ // console.log( d );
299
+
300
+ const commands = d.match( /[a-df-z][^a-df-z]*/ig );
301
+
302
+ for ( let i = 0, l = commands.length; i < l; i ++ ) {
303
+
304
+ const command = commands[ i ];
305
+
306
+ const type = command.charAt( 0 );
307
+ const data = command.slice( 1 ).trim();
308
+
309
+ if ( isFirstPoint === true ) {
310
+
311
+ doSetFirstPoint = true;
312
+ isFirstPoint = false;
313
+
314
+ }
315
+
316
+ let numbers;
317
+
318
+ switch ( type ) {
319
+
320
+ case 'M':
321
+ numbers = parseFloats( data );
322
+ for ( let j = 0, jl = numbers.length; j < jl; j += 2 ) {
323
+
324
+ point.x = numbers[ j + 0 ];
325
+ point.y = numbers[ j + 1 ];
326
+ control.x = point.x;
327
+ control.y = point.y;
328
+
329
+ if ( j === 0 ) {
330
+
331
+ path.moveTo( point.x, point.y );
332
+
333
+ } else {
334
+
335
+ path.lineTo( point.x, point.y );
336
+
337
+ }
338
+
339
+ if ( j === 0 ) firstPoint.copy( point );
340
+
341
+ }
342
+
343
+ break;
344
+
345
+ case 'H':
346
+ numbers = parseFloats( data );
347
+
348
+ for ( let j = 0, jl = numbers.length; j < jl; j ++ ) {
349
+
350
+ point.x = numbers[ j ];
351
+ control.x = point.x;
352
+ control.y = point.y;
353
+ path.lineTo( point.x, point.y );
354
+
355
+ if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
356
+
357
+ }
358
+
359
+ break;
360
+
361
+ case 'V':
362
+ numbers = parseFloats( data );
363
+
364
+ for ( let j = 0, jl = numbers.length; j < jl; j ++ ) {
365
+
366
+ point.y = numbers[ j ];
367
+ control.x = point.x;
368
+ control.y = point.y;
369
+ path.lineTo( point.x, point.y );
370
+
371
+ if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
372
+
373
+ }
374
+
375
+ break;
376
+
377
+ case 'L':
378
+ numbers = parseFloats( data );
379
+
380
+ for ( let j = 0, jl = numbers.length; j < jl; j += 2 ) {
381
+
382
+ point.x = numbers[ j + 0 ];
383
+ point.y = numbers[ j + 1 ];
384
+ control.x = point.x;
385
+ control.y = point.y;
386
+ path.lineTo( point.x, point.y );
387
+
388
+ if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
389
+
390
+ }
391
+
392
+ break;
393
+
394
+ case 'C':
395
+ numbers = parseFloats( data );
396
+
397
+ for ( let j = 0, jl = numbers.length; j < jl; j += 6 ) {
398
+
399
+ path.bezierCurveTo(
400
+ numbers[ j + 0 ],
401
+ numbers[ j + 1 ],
402
+ numbers[ j + 2 ],
403
+ numbers[ j + 3 ],
404
+ numbers[ j + 4 ],
405
+ numbers[ j + 5 ]
406
+ );
407
+ control.x = numbers[ j + 2 ];
408
+ control.y = numbers[ j + 3 ];
409
+ point.x = numbers[ j + 4 ];
410
+ point.y = numbers[ j + 5 ];
411
+
412
+ if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
413
+
414
+ }
415
+
416
+ break;
417
+
418
+ case 'S':
419
+ numbers = parseFloats( data );
420
+
421
+ for ( let j = 0, jl = numbers.length; j < jl; j += 4 ) {
422
+
423
+ path.bezierCurveTo(
424
+ getReflection( point.x, control.x ),
425
+ getReflection( point.y, control.y ),
426
+ numbers[ j + 0 ],
427
+ numbers[ j + 1 ],
428
+ numbers[ j + 2 ],
429
+ numbers[ j + 3 ]
430
+ );
431
+ control.x = numbers[ j + 0 ];
432
+ control.y = numbers[ j + 1 ];
433
+ point.x = numbers[ j + 2 ];
434
+ point.y = numbers[ j + 3 ];
435
+
436
+ if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
437
+
438
+ }
439
+
440
+ break;
441
+
442
+ case 'Q':
443
+ numbers = parseFloats( data );
444
+
445
+ for ( let j = 0, jl = numbers.length; j < jl; j += 4 ) {
446
+
447
+ path.quadraticCurveTo(
448
+ numbers[ j + 0 ],
449
+ numbers[ j + 1 ],
450
+ numbers[ j + 2 ],
451
+ numbers[ j + 3 ]
452
+ );
453
+ control.x = numbers[ j + 0 ];
454
+ control.y = numbers[ j + 1 ];
455
+ point.x = numbers[ j + 2 ];
456
+ point.y = numbers[ j + 3 ];
457
+
458
+ if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
459
+
460
+ }
461
+
462
+ break;
463
+
464
+ case 'T':
465
+ numbers = parseFloats( data );
466
+
467
+ for ( let j = 0, jl = numbers.length; j < jl; j += 2 ) {
468
+
469
+ const rx = getReflection( point.x, control.x );
470
+ const ry = getReflection( point.y, control.y );
471
+ path.quadraticCurveTo(
472
+ rx,
473
+ ry,
474
+ numbers[ j + 0 ],
475
+ numbers[ j + 1 ]
476
+ );
477
+ control.x = rx;
478
+ control.y = ry;
479
+ point.x = numbers[ j + 0 ];
480
+ point.y = numbers[ j + 1 ];
481
+
482
+ if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
483
+
484
+ }
485
+
486
+ break;
487
+
488
+ case 'A':
489
+ numbers = parseFloats( data, [ 3, 4 ], 7 );
490
+
491
+ for ( let j = 0, jl = numbers.length; j < jl; j += 7 ) {
492
+
493
+ // skip command if start point == end point
494
+ if ( numbers[ j + 5 ] == point.x && numbers[ j + 6 ] == point.y ) continue;
495
+
496
+ const start = point.clone();
497
+ point.x = numbers[ j + 5 ];
498
+ point.y = numbers[ j + 6 ];
499
+ control.x = point.x;
500
+ control.y = point.y;
501
+ parseArcCommand(
502
+ path, numbers[ j ], numbers[ j + 1 ], numbers[ j + 2 ], numbers[ j + 3 ], numbers[ j + 4 ], start, point
503
+ );
504
+
505
+ if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
506
+
507
+ }
508
+
509
+ break;
510
+
511
+ case 'm':
512
+ numbers = parseFloats( data );
513
+
514
+ for ( let j = 0, jl = numbers.length; j < jl; j += 2 ) {
515
+
516
+ point.x += numbers[ j + 0 ];
517
+ point.y += numbers[ j + 1 ];
518
+ control.x = point.x;
519
+ control.y = point.y;
520
+
521
+ if ( j === 0 ) {
522
+
523
+ path.moveTo( point.x, point.y );
524
+
525
+ } else {
526
+
527
+ path.lineTo( point.x, point.y );
528
+
529
+ }
530
+
531
+ if ( j === 0 ) firstPoint.copy( point );
532
+
533
+ }
534
+
535
+ break;
536
+
537
+ case 'h':
538
+ numbers = parseFloats( data );
539
+
540
+ for ( let j = 0, jl = numbers.length; j < jl; j ++ ) {
541
+
542
+ point.x += numbers[ j ];
543
+ control.x = point.x;
544
+ control.y = point.y;
545
+ path.lineTo( point.x, point.y );
546
+
547
+ if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
548
+
549
+ }
550
+
551
+ break;
552
+
553
+ case 'v':
554
+ numbers = parseFloats( data );
555
+
556
+ for ( let j = 0, jl = numbers.length; j < jl; j ++ ) {
557
+
558
+ point.y += numbers[ j ];
559
+ control.x = point.x;
560
+ control.y = point.y;
561
+ path.lineTo( point.x, point.y );
562
+
563
+ if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
564
+
565
+ }
566
+
567
+ break;
568
+
569
+ case 'l':
570
+ numbers = parseFloats( data );
571
+
572
+ for ( let j = 0, jl = numbers.length; j < jl; j += 2 ) {
573
+
574
+ point.x += numbers[ j + 0 ];
575
+ point.y += numbers[ j + 1 ];
576
+ control.x = point.x;
577
+ control.y = point.y;
578
+ path.lineTo( point.x, point.y );
579
+
580
+ if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
581
+
582
+ }
583
+
584
+ break;
585
+
586
+ case 'c':
587
+ numbers = parseFloats( data );
588
+
589
+ for ( let j = 0, jl = numbers.length; j < jl; j += 6 ) {
590
+
591
+ path.bezierCurveTo(
592
+ point.x + numbers[ j + 0 ],
593
+ point.y + numbers[ j + 1 ],
594
+ point.x + numbers[ j + 2 ],
595
+ point.y + numbers[ j + 3 ],
596
+ point.x + numbers[ j + 4 ],
597
+ point.y + numbers[ j + 5 ]
598
+ );
599
+ control.x = point.x + numbers[ j + 2 ];
600
+ control.y = point.y + numbers[ j + 3 ];
601
+ point.x += numbers[ j + 4 ];
602
+ point.y += numbers[ j + 5 ];
603
+
604
+ if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
605
+
606
+ }
607
+
608
+ break;
609
+
610
+ case 's':
611
+ numbers = parseFloats( data );
612
+
613
+ for ( let j = 0, jl = numbers.length; j < jl; j += 4 ) {
614
+
615
+ path.bezierCurveTo(
616
+ getReflection( point.x, control.x ),
617
+ getReflection( point.y, control.y ),
618
+ point.x + numbers[ j + 0 ],
619
+ point.y + numbers[ j + 1 ],
620
+ point.x + numbers[ j + 2 ],
621
+ point.y + numbers[ j + 3 ]
622
+ );
623
+ control.x = point.x + numbers[ j + 0 ];
624
+ control.y = point.y + numbers[ j + 1 ];
625
+ point.x += numbers[ j + 2 ];
626
+ point.y += numbers[ j + 3 ];
627
+
628
+ if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
629
+
630
+ }
631
+
632
+ break;
633
+
634
+ case 'q':
635
+ numbers = parseFloats( data );
636
+
637
+ for ( let j = 0, jl = numbers.length; j < jl; j += 4 ) {
638
+
639
+ path.quadraticCurveTo(
640
+ point.x + numbers[ j + 0 ],
641
+ point.y + numbers[ j + 1 ],
642
+ point.x + numbers[ j + 2 ],
643
+ point.y + numbers[ j + 3 ]
644
+ );
645
+ control.x = point.x + numbers[ j + 0 ];
646
+ control.y = point.y + numbers[ j + 1 ];
647
+ point.x += numbers[ j + 2 ];
648
+ point.y += numbers[ j + 3 ];
649
+
650
+ if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
651
+
652
+ }
653
+
654
+ break;
655
+
656
+ case 't':
657
+ numbers = parseFloats( data );
658
+
659
+ for ( let j = 0, jl = numbers.length; j < jl; j += 2 ) {
660
+
661
+ const rx = getReflection( point.x, control.x );
662
+ const ry = getReflection( point.y, control.y );
663
+ path.quadraticCurveTo(
664
+ rx,
665
+ ry,
666
+ point.x + numbers[ j + 0 ],
667
+ point.y + numbers[ j + 1 ]
668
+ );
669
+ control.x = rx;
670
+ control.y = ry;
671
+ point.x = point.x + numbers[ j + 0 ];
672
+ point.y = point.y + numbers[ j + 1 ];
673
+
674
+ if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
675
+
676
+ }
677
+
678
+ break;
679
+
680
+ case 'a':
681
+ numbers = parseFloats( data, [ 3, 4 ], 7 );
682
+
683
+ for ( let j = 0, jl = numbers.length; j < jl; j += 7 ) {
684
+
685
+ // skip command if no displacement
686
+ if ( numbers[ j + 5 ] == 0 && numbers[ j + 6 ] == 0 ) continue;
687
+
688
+ const start = point.clone();
689
+ point.x += numbers[ j + 5 ];
690
+ point.y += numbers[ j + 6 ];
691
+ control.x = point.x;
692
+ control.y = point.y;
693
+ parseArcCommand(
694
+ path, numbers[ j ], numbers[ j + 1 ], numbers[ j + 2 ], numbers[ j + 3 ], numbers[ j + 4 ], start, point
695
+ );
696
+
697
+ if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
698
+
699
+ }
700
+
701
+ break;
702
+
703
+ case 'Z':
704
+ case 'z':
705
+ path.currentPath.autoClose = true;
706
+
707
+ if ( path.currentPath.curves.length > 0 ) {
708
+
709
+ // Reset point to beginning of Path
710
+ point.copy( firstPoint );
711
+ path.currentPath.currentPoint.copy( point );
712
+ isFirstPoint = true;
713
+
714
+ }
715
+
716
+ break;
717
+
718
+ default:
719
+ console.warn( command );
720
+
721
+ }
722
+
723
+ // console.log( type, parseFloats( data ), parseFloats( data ).length )
724
+
725
+ doSetFirstPoint = false;
726
+
727
+ }
728
+
729
+ return path;
730
+
731
+ }
732
+
733
+ function parseCSSStylesheet( node ) {
734
+
735
+ if ( ! node.sheet || ! node.sheet.cssRules || ! node.sheet.cssRules.length ) return;
736
+
737
+ for ( let i = 0; i < node.sheet.cssRules.length; i ++ ) {
738
+
739
+ const stylesheet = node.sheet.cssRules[ i ];
740
+
741
+ if ( stylesheet.type !== 1 ) continue;
742
+
743
+ const selectorList = stylesheet.selectorText
744
+ .split( /,/gm )
745
+ .filter( Boolean )
746
+ .map( i => i.trim() );
747
+
748
+ for ( let j = 0; j < selectorList.length; j ++ ) {
749
+
750
+ // Remove empty rules
751
+ const definitions = Object.fromEntries(
752
+ Object.entries( stylesheet.style ).filter( ( [ , v ] ) => v !== '' )
753
+ );
754
+
755
+ stylesheets[ selectorList[ j ] ] = Object.assign(
756
+ stylesheets[ selectorList[ j ] ] || {},
757
+ definitions
758
+ );
759
+
760
+ }
761
+
762
+ }
763
+
764
+ }
765
+
766
+ /**
767
+ * https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
768
+ * https://mortoray.com/2017/02/16/rendering-an-svg-elliptical-arc-as-bezier-curves/ Appendix: Endpoint to center arc conversion
769
+ * From
770
+ * rx ry x-axis-rotation large-arc-flag sweep-flag x y
771
+ * To
772
+ * aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation
773
+ */
774
+
775
+ function parseArcCommand( path, rx, ry, x_axis_rotation, large_arc_flag, sweep_flag, start, end ) {
776
+
777
+ if ( rx == 0 || ry == 0 ) {
778
+
779
+ // draw a line if either of the radii == 0
780
+ path.lineTo( end.x, end.y );
781
+ return;
782
+
783
+ }
784
+
785
+ x_axis_rotation = x_axis_rotation * Math.PI / 180;
786
+
787
+ // Ensure radii are positive
788
+ rx = Math.abs( rx );
789
+ ry = Math.abs( ry );
790
+
791
+ // Compute (x1', y1')
792
+ const dx2 = ( start.x - end.x ) / 2.0;
793
+ const dy2 = ( start.y - end.y ) / 2.0;
794
+ const x1p = Math.cos( x_axis_rotation ) * dx2 + Math.sin( x_axis_rotation ) * dy2;
795
+ const y1p = - Math.sin( x_axis_rotation ) * dx2 + Math.cos( x_axis_rotation ) * dy2;
796
+
797
+ // Compute (cx', cy')
798
+ let rxs = rx * rx;
799
+ let rys = ry * ry;
800
+ const x1ps = x1p * x1p;
801
+ const y1ps = y1p * y1p;
802
+
803
+ // Ensure radii are large enough
804
+ const cr = x1ps / rxs + y1ps / rys;
805
+
806
+ if ( cr > 1 ) {
807
+
808
+ // scale up rx,ry equally so cr == 1
809
+ const s = Math.sqrt( cr );
810
+ rx = s * rx;
811
+ ry = s * ry;
812
+ rxs = rx * rx;
813
+ rys = ry * ry;
814
+
815
+ }
816
+
817
+ const dq = ( rxs * y1ps + rys * x1ps );
818
+ const pq = ( rxs * rys - dq ) / dq;
819
+ let q = Math.sqrt( Math.max( 0, pq ) );
820
+ if ( large_arc_flag === sweep_flag ) q = - q;
821
+ const cxp = q * rx * y1p / ry;
822
+ const cyp = - q * ry * x1p / rx;
823
+
824
+ // Step 3: Compute (cx, cy) from (cx', cy')
825
+ const cx = Math.cos( x_axis_rotation ) * cxp - Math.sin( x_axis_rotation ) * cyp + ( start.x + end.x ) / 2;
826
+ const cy = Math.sin( x_axis_rotation ) * cxp + Math.cos( x_axis_rotation ) * cyp + ( start.y + end.y ) / 2;
827
+
828
+ // Step 4: Compute θ1 and Δθ
829
+ const theta = svgAngle( 1, 0, ( x1p - cxp ) / rx, ( y1p - cyp ) / ry );
830
+ const delta = svgAngle( ( x1p - cxp ) / rx, ( y1p - cyp ) / ry, ( - x1p - cxp ) / rx, ( - y1p - cyp ) / ry ) % ( Math.PI * 2 );
831
+
832
+ path.currentPath.absellipse( cx, cy, rx, ry, theta, theta + delta, sweep_flag === 0, x_axis_rotation );
833
+
834
+ }
835
+
836
+ function svgAngle( ux, uy, vx, vy ) {
837
+
838
+ const dot = ux * vx + uy * vy;
839
+ const len = Math.sqrt( ux * ux + uy * uy ) * Math.sqrt( vx * vx + vy * vy );
840
+ let ang = Math.acos( Math.max( - 1, Math.min( 1, dot / len ) ) ); // floating point precision, slightly over values appear
841
+ if ( ( ux * vy - uy * vx ) < 0 ) ang = - ang;
842
+ return ang;
843
+
844
+ }
845
+
846
+ /*
847
+ * According to https://www.w3.org/TR/SVG/shapes.html#RectElementRXAttribute
848
+ * rounded corner should be rendered to elliptical arc, but bezier curve does the job well enough
849
+ */
850
+
851
+ function parseRectNode( node ) {
852
+
853
+ const x = parseFloatWithUnits( node.getAttribute( 'x' ) || 0 );
854
+ const y = parseFloatWithUnits( node.getAttribute( 'y' ) || 0 );
855
+ const rx = parseFloatWithUnits( node.getAttribute( 'rx' ) || node.getAttribute( 'ry' ) || 0 );
856
+ const ry = parseFloatWithUnits( node.getAttribute( 'ry' ) || node.getAttribute( 'rx' ) || 0 );
857
+ const w = parseFloatWithUnits( node.getAttribute( 'width' ) );
858
+ const h = parseFloatWithUnits( node.getAttribute( 'height' ) );
859
+
860
+ // Ellipse arc to Bezier approximation Coefficient (Inversed). See:
861
+ // https://spencermortensen.com/articles/bezier-circle/
862
+ const bci = 1 - 0.551915024494;
863
+
864
+ const path = new ShapePath();
865
+
866
+ // top left
867
+ path.moveTo( x + rx, y );
868
+
869
+ // top right
870
+ path.lineTo( x + w - rx, y );
871
+ if ( rx !== 0 || ry !== 0 ) {
872
+
873
+ path.bezierCurveTo(
874
+ x + w - rx * bci,
875
+ y,
876
+ x + w,
877
+ y + ry * bci,
878
+ x + w,
879
+ y + ry
880
+ );
881
+
882
+ }
883
+
884
+ // bottom right
885
+ path.lineTo( x + w, y + h - ry );
886
+ if ( rx !== 0 || ry !== 0 ) {
887
+
888
+ path.bezierCurveTo(
889
+ x + w,
890
+ y + h - ry * bci,
891
+ x + w - rx * bci,
892
+ y + h,
893
+ x + w - rx,
894
+ y + h
895
+ );
896
+
897
+ }
898
+
899
+ // bottom left
900
+ path.lineTo( x + rx, y + h );
901
+ if ( rx !== 0 || ry !== 0 ) {
902
+
903
+ path.bezierCurveTo(
904
+ x + rx * bci,
905
+ y + h,
906
+ x,
907
+ y + h - ry * bci,
908
+ x,
909
+ y + h - ry
910
+ );
911
+
912
+ }
913
+
914
+ // back to top left
915
+ path.lineTo( x, y + ry );
916
+ if ( rx !== 0 || ry !== 0 ) {
917
+
918
+ path.bezierCurveTo( x, y + ry * bci, x + rx * bci, y, x + rx, y );
919
+
920
+ }
921
+
922
+ return path;
923
+
924
+ }
925
+
926
+ function parsePolygonNode( node ) {
927
+
928
+ function iterator( match, a, b ) {
929
+
930
+ const x = parseFloatWithUnits( a );
931
+ const y = parseFloatWithUnits( b );
932
+
933
+ if ( index === 0 ) {
934
+
935
+ path.moveTo( x, y );
936
+
937
+ } else {
938
+
939
+ path.lineTo( x, y );
940
+
941
+ }
942
+
943
+ index ++;
944
+
945
+ }
946
+
947
+ const regex = /([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;
948
+
949
+ const path = new ShapePath();
950
+
951
+ let index = 0;
952
+
953
+ node.getAttribute( 'points' ).replace( regex, iterator );
954
+
955
+ path.currentPath.autoClose = true;
956
+
957
+ return path;
958
+
959
+ }
960
+
961
+ function parsePolylineNode( node ) {
962
+
963
+ function iterator( match, a, b ) {
964
+
965
+ const x = parseFloatWithUnits( a );
966
+ const y = parseFloatWithUnits( b );
967
+
968
+ if ( index === 0 ) {
969
+
970
+ path.moveTo( x, y );
971
+
972
+ } else {
973
+
974
+ path.lineTo( x, y );
975
+
976
+ }
977
+
978
+ index ++;
979
+
980
+ }
981
+
982
+ const regex = /([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;
983
+
984
+ const path = new ShapePath();
985
+
986
+ let index = 0;
987
+
988
+ node.getAttribute( 'points' ).replace( regex, iterator );
989
+
990
+ path.currentPath.autoClose = false;
991
+
992
+ return path;
993
+
994
+ }
995
+
996
+ function parseCircleNode( node ) {
997
+
998
+ const x = parseFloatWithUnits( node.getAttribute( 'cx' ) || 0 );
999
+ const y = parseFloatWithUnits( node.getAttribute( 'cy' ) || 0 );
1000
+ const r = parseFloatWithUnits( node.getAttribute( 'r' ) || 0 );
1001
+
1002
+ const subpath = new Path();
1003
+ subpath.absarc( x, y, r, 0, Math.PI * 2 );
1004
+
1005
+ const path = new ShapePath();
1006
+ path.subPaths.push( subpath );
1007
+
1008
+ return path;
1009
+
1010
+ }
1011
+
1012
+ function parseEllipseNode( node ) {
1013
+
1014
+ const x = parseFloatWithUnits( node.getAttribute( 'cx' ) || 0 );
1015
+ const y = parseFloatWithUnits( node.getAttribute( 'cy' ) || 0 );
1016
+ const rx = parseFloatWithUnits( node.getAttribute( 'rx' ) || 0 );
1017
+ const ry = parseFloatWithUnits( node.getAttribute( 'ry' ) || 0 );
1018
+
1019
+ const subpath = new Path();
1020
+ subpath.absellipse( x, y, rx, ry, 0, Math.PI * 2 );
1021
+
1022
+ const path = new ShapePath();
1023
+ path.subPaths.push( subpath );
1024
+
1025
+ return path;
1026
+
1027
+ }
1028
+
1029
+ function parseLineNode( node ) {
1030
+
1031
+ const x1 = parseFloatWithUnits( node.getAttribute( 'x1' ) || 0 );
1032
+ const y1 = parseFloatWithUnits( node.getAttribute( 'y1' ) || 0 );
1033
+ const x2 = parseFloatWithUnits( node.getAttribute( 'x2' ) || 0 );
1034
+ const y2 = parseFloatWithUnits( node.getAttribute( 'y2' ) || 0 );
1035
+
1036
+ const path = new ShapePath();
1037
+ path.moveTo( x1, y1 );
1038
+ path.lineTo( x2, y2 );
1039
+ path.currentPath.autoClose = false;
1040
+
1041
+ return path;
1042
+
1043
+ }
1044
+
1045
+ //
1046
+
1047
+ function parseStyle( node, style ) {
1048
+
1049
+ style = Object.assign( {}, style ); // clone style
1050
+
1051
+ let stylesheetStyles = {};
1052
+
1053
+ if ( node.hasAttribute( 'class' ) ) {
1054
+
1055
+ const classSelectors = node.getAttribute( 'class' )
1056
+ .split( /\s/ )
1057
+ .filter( Boolean )
1058
+ .map( i => i.trim() );
1059
+
1060
+ for ( let i = 0; i < classSelectors.length; i ++ ) {
1061
+
1062
+ stylesheetStyles = Object.assign( stylesheetStyles, stylesheets[ '.' + classSelectors[ i ] ] );
1063
+
1064
+ }
1065
+
1066
+ }
1067
+
1068
+ if ( node.hasAttribute( 'id' ) ) {
1069
+
1070
+ stylesheetStyles = Object.assign( stylesheetStyles, stylesheets[ '#' + node.getAttribute( 'id' ) ] );
1071
+
1072
+ }
1073
+
1074
+ function addStyle( svgName, jsName, adjustFunction ) {
1075
+
1076
+ if ( adjustFunction === undefined ) adjustFunction = function copy( v ) {
1077
+
1078
+ if ( v.startsWith( 'url' ) ) console.warn( 'SVGLoader: url access in attributes is not implemented.' );
1079
+
1080
+ return v;
1081
+
1082
+ };
1083
+
1084
+ if ( node.hasAttribute( svgName ) ) style[ jsName ] = adjustFunction( node.getAttribute( svgName ) );
1085
+ if ( stylesheetStyles[ jsName ] ) style[ jsName ] = adjustFunction( stylesheetStyles[ jsName ] );
1086
+ if ( node.style && node.style[ svgName ] !== '' ) style[ jsName ] = adjustFunction( node.style[ svgName ] );
1087
+
1088
+ }
1089
+
1090
+ function clamp( v ) {
1091
+
1092
+ return Math.max( 0, Math.min( 1, parseFloatWithUnits( v ) ) );
1093
+
1094
+ }
1095
+
1096
+ function positive( v ) {
1097
+
1098
+ return Math.max( 0, parseFloatWithUnits( v ) );
1099
+
1100
+ }
1101
+
1102
+ addStyle( 'fill', 'fill' );
1103
+ addStyle( 'fill-opacity', 'fillOpacity', clamp );
1104
+ addStyle( 'fill-rule', 'fillRule' );
1105
+ addStyle( 'opacity', 'opacity', clamp );
1106
+ addStyle( 'stroke', 'stroke' );
1107
+ addStyle( 'stroke-opacity', 'strokeOpacity', clamp );
1108
+ addStyle( 'stroke-width', 'strokeWidth', positive );
1109
+ addStyle( 'stroke-linejoin', 'strokeLineJoin' );
1110
+ addStyle( 'stroke-linecap', 'strokeLineCap' );
1111
+ addStyle( 'stroke-miterlimit', 'strokeMiterLimit', positive );
1112
+ addStyle( 'visibility', 'visibility' );
1113
+
1114
+ return style;
1115
+
1116
+ }
1117
+
1118
+ // http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes
1119
+
1120
+ function getReflection( a, b ) {
1121
+
1122
+ return a - ( b - a );
1123
+
1124
+ }
1125
+
1126
+ // from https://github.com/ppvg/svg-numbers (MIT License)
1127
+
1128
+ function parseFloats( input, flags, stride ) {
1129
+
1130
+ if ( typeof input !== 'string' ) {
1131
+
1132
+ throw new TypeError( 'Invalid input: ' + typeof input );
1133
+
1134
+ }
1135
+
1136
+ // Character groups
1137
+ const RE = {
1138
+ SEPARATOR: /[ \t\r\n\,.\-+]/,
1139
+ WHITESPACE: /[ \t\r\n]/,
1140
+ DIGIT: /[\d]/,
1141
+ SIGN: /[-+]/,
1142
+ POINT: /\./,
1143
+ COMMA: /,/,
1144
+ EXP: /e/i,
1145
+ FLAGS: /[01]/
1146
+ };
1147
+
1148
+ // States
1149
+ const SEP = 0;
1150
+ const INT = 1;
1151
+ const FLOAT = 2;
1152
+ const EXP = 3;
1153
+
1154
+ let state = SEP;
1155
+ let seenComma = true;
1156
+ let number = '', exponent = '';
1157
+ const result = [];
1158
+
1159
+ function throwSyntaxError( current, i, partial ) {
1160
+
1161
+ const error = new SyntaxError( 'Unexpected character "' + current + '" at index ' + i + '.' );
1162
+ error.partial = partial;
1163
+ throw error;
1164
+
1165
+ }
1166
+
1167
+ function newNumber() {
1168
+
1169
+ if ( number !== '' ) {
1170
+
1171
+ if ( exponent === '' ) result.push( Number( number ) );
1172
+ else result.push( Number( number ) * Math.pow( 10, Number( exponent ) ) );
1173
+
1174
+ }
1175
+
1176
+ number = '';
1177
+ exponent = '';
1178
+
1179
+ }
1180
+
1181
+ let current;
1182
+ const length = input.length;
1183
+
1184
+ for ( let i = 0; i < length; i ++ ) {
1185
+
1186
+ current = input[ i ];
1187
+
1188
+ // check for flags
1189
+ if ( Array.isArray( flags ) && flags.includes( result.length % stride ) && RE.FLAGS.test( current ) ) {
1190
+
1191
+ state = INT;
1192
+ number = current;
1193
+ newNumber();
1194
+ continue;
1195
+
1196
+ }
1197
+
1198
+ // parse until next number
1199
+ if ( state === SEP ) {
1200
+
1201
+ // eat whitespace
1202
+ if ( RE.WHITESPACE.test( current ) ) {
1203
+
1204
+ continue;
1205
+
1206
+ }
1207
+
1208
+ // start new number
1209
+ if ( RE.DIGIT.test( current ) || RE.SIGN.test( current ) ) {
1210
+
1211
+ state = INT;
1212
+ number = current;
1213
+ continue;
1214
+
1215
+ }
1216
+
1217
+ if ( RE.POINT.test( current ) ) {
1218
+
1219
+ state = FLOAT;
1220
+ number = current;
1221
+ continue;
1222
+
1223
+ }
1224
+
1225
+ // throw on double commas (e.g. "1, , 2")
1226
+ if ( RE.COMMA.test( current ) ) {
1227
+
1228
+ if ( seenComma ) {
1229
+
1230
+ throwSyntaxError( current, i, result );
1231
+
1232
+ }
1233
+
1234
+ seenComma = true;
1235
+
1236
+ }
1237
+
1238
+ }
1239
+
1240
+ // parse integer part
1241
+ if ( state === INT ) {
1242
+
1243
+ if ( RE.DIGIT.test( current ) ) {
1244
+
1245
+ number += current;
1246
+ continue;
1247
+
1248
+ }
1249
+
1250
+ if ( RE.POINT.test( current ) ) {
1251
+
1252
+ number += current;
1253
+ state = FLOAT;
1254
+ continue;
1255
+
1256
+ }
1257
+
1258
+ if ( RE.EXP.test( current ) ) {
1259
+
1260
+ state = EXP;
1261
+ continue;
1262
+
1263
+ }
1264
+
1265
+ // throw on double signs ("-+1"), but not on sign as separator ("-1-2")
1266
+ if ( RE.SIGN.test( current )
1267
+ && number.length === 1
1268
+ && RE.SIGN.test( number[ 0 ] ) ) {
1269
+
1270
+ throwSyntaxError( current, i, result );
1271
+
1272
+ }
1273
+
1274
+ }
1275
+
1276
+ // parse decimal part
1277
+ if ( state === FLOAT ) {
1278
+
1279
+ if ( RE.DIGIT.test( current ) ) {
1280
+
1281
+ number += current;
1282
+ continue;
1283
+
1284
+ }
1285
+
1286
+ if ( RE.EXP.test( current ) ) {
1287
+
1288
+ state = EXP;
1289
+ continue;
1290
+
1291
+ }
1292
+
1293
+ // throw on double decimal points (e.g. "1..2")
1294
+ if ( RE.POINT.test( current ) && number[ number.length - 1 ] === '.' ) {
1295
+
1296
+ throwSyntaxError( current, i, result );
1297
+
1298
+ }
1299
+
1300
+ }
1301
+
1302
+ // parse exponent part
1303
+ if ( state === EXP ) {
1304
+
1305
+ if ( RE.DIGIT.test( current ) ) {
1306
+
1307
+ exponent += current;
1308
+ continue;
1309
+
1310
+ }
1311
+
1312
+ if ( RE.SIGN.test( current ) ) {
1313
+
1314
+ if ( exponent === '' ) {
1315
+
1316
+ exponent += current;
1317
+ continue;
1318
+
1319
+ }
1320
+
1321
+ if ( exponent.length === 1 && RE.SIGN.test( exponent ) ) {
1322
+
1323
+ throwSyntaxError( current, i, result );
1324
+
1325
+ }
1326
+
1327
+ }
1328
+
1329
+ }
1330
+
1331
+
1332
+ // end of number
1333
+ if ( RE.WHITESPACE.test( current ) ) {
1334
+
1335
+ newNumber();
1336
+ state = SEP;
1337
+ seenComma = false;
1338
+
1339
+ } else if ( RE.COMMA.test( current ) ) {
1340
+
1341
+ newNumber();
1342
+ state = SEP;
1343
+ seenComma = true;
1344
+
1345
+ } else if ( RE.SIGN.test( current ) ) {
1346
+
1347
+ newNumber();
1348
+ state = INT;
1349
+ number = current;
1350
+
1351
+ } else if ( RE.POINT.test( current ) ) {
1352
+
1353
+ newNumber();
1354
+ state = FLOAT;
1355
+ number = current;
1356
+
1357
+ } else {
1358
+
1359
+ throwSyntaxError( current, i, result );
1360
+
1361
+ }
1362
+
1363
+ }
1364
+
1365
+ // add the last number found (if any)
1366
+ newNumber();
1367
+
1368
+ return result;
1369
+
1370
+ }
1371
+
1372
+ // Units
1373
+
1374
+ const units = [ 'mm', 'cm', 'in', 'pt', 'pc', 'px' ];
1375
+
1376
+ // Conversion: [ fromUnit ][ toUnit ] (-1 means dpi dependent)
1377
+ const unitConversion = {
1378
+
1379
+ 'mm': {
1380
+ 'mm': 1,
1381
+ 'cm': 0.1,
1382
+ 'in': 1 / 25.4,
1383
+ 'pt': 72 / 25.4,
1384
+ 'pc': 6 / 25.4,
1385
+ 'px': - 1
1386
+ },
1387
+ 'cm': {
1388
+ 'mm': 10,
1389
+ 'cm': 1,
1390
+ 'in': 1 / 2.54,
1391
+ 'pt': 72 / 2.54,
1392
+ 'pc': 6 / 2.54,
1393
+ 'px': - 1
1394
+ },
1395
+ 'in': {
1396
+ 'mm': 25.4,
1397
+ 'cm': 2.54,
1398
+ 'in': 1,
1399
+ 'pt': 72,
1400
+ 'pc': 6,
1401
+ 'px': - 1
1402
+ },
1403
+ 'pt': {
1404
+ 'mm': 25.4 / 72,
1405
+ 'cm': 2.54 / 72,
1406
+ 'in': 1 / 72,
1407
+ 'pt': 1,
1408
+ 'pc': 6 / 72,
1409
+ 'px': - 1
1410
+ },
1411
+ 'pc': {
1412
+ 'mm': 25.4 / 6,
1413
+ 'cm': 2.54 / 6,
1414
+ 'in': 1 / 6,
1415
+ 'pt': 72 / 6,
1416
+ 'pc': 1,
1417
+ 'px': - 1
1418
+ },
1419
+ 'px': {
1420
+ 'px': 1
1421
+ }
1422
+
1423
+ };
1424
+
1425
+ function parseFloatWithUnits( string ) {
1426
+
1427
+ let theUnit = 'px';
1428
+
1429
+ if ( typeof string === 'string' || string instanceof String ) {
1430
+
1431
+ for ( let i = 0, n = units.length; i < n; i ++ ) {
1432
+
1433
+ const u = units[ i ];
1434
+
1435
+ if ( string.endsWith( u ) ) {
1436
+
1437
+ theUnit = u;
1438
+ string = string.substring( 0, string.length - u.length );
1439
+ break;
1440
+
1441
+ }
1442
+
1443
+ }
1444
+
1445
+ }
1446
+
1447
+ let scale = undefined;
1448
+
1449
+ if ( theUnit === 'px' && scope.defaultUnit !== 'px' ) {
1450
+
1451
+ // Conversion scale from pixels to inches, then to default units
1452
+
1453
+ scale = unitConversion[ 'in' ][ scope.defaultUnit ] / scope.defaultDPI;
1454
+
1455
+ } else {
1456
+
1457
+ scale = unitConversion[ theUnit ][ scope.defaultUnit ];
1458
+
1459
+ if ( scale < 0 ) {
1460
+
1461
+ // Conversion scale to pixels
1462
+
1463
+ scale = unitConversion[ theUnit ][ 'in' ] * scope.defaultDPI;
1464
+
1465
+ }
1466
+
1467
+ }
1468
+
1469
+ return scale * parseFloat( string );
1470
+
1471
+ }
1472
+
1473
+ // Transforms
1474
+
1475
+ function getNodeTransform( node ) {
1476
+
1477
+ if ( ! ( node.hasAttribute( 'transform' ) || ( node.nodeName === 'use' && ( node.hasAttribute( 'x' ) || node.hasAttribute( 'y' ) ) ) ) ) {
1478
+
1479
+ return null;
1480
+
1481
+ }
1482
+
1483
+ const transform = parseNodeTransform( node );
1484
+
1485
+ if ( transformStack.length > 0 ) {
1486
+
1487
+ transform.premultiply( transformStack[ transformStack.length - 1 ] );
1488
+
1489
+ }
1490
+
1491
+ currentTransform.copy( transform );
1492
+ transformStack.push( transform );
1493
+
1494
+ return transform;
1495
+
1496
+ }
1497
+
1498
+ function parseNodeTransform( node ) {
1499
+
1500
+ const transform = new Matrix3();
1501
+ const currentTransform = tempTransform0;
1502
+
1503
+ if ( node.nodeName === 'use' && ( node.hasAttribute( 'x' ) || node.hasAttribute( 'y' ) ) ) {
1504
+
1505
+ const tx = parseFloatWithUnits( node.getAttribute( 'x' ) || 0 );
1506
+ const ty = parseFloatWithUnits( node.getAttribute( 'y' ) || 0 );
1507
+
1508
+ transform.translate( tx, ty );
1509
+
1510
+ }
1511
+
1512
+ if ( node.hasAttribute( 'transform' ) ) {
1513
+
1514
+ const transformsTexts = node.getAttribute( 'transform' ).split( ')' );
1515
+
1516
+ for ( let tIndex = transformsTexts.length - 1; tIndex >= 0; tIndex -- ) {
1517
+
1518
+ const transformText = transformsTexts[ tIndex ].trim();
1519
+
1520
+ if ( transformText === '' ) continue;
1521
+
1522
+ const openParPos = transformText.indexOf( '(' );
1523
+ const closeParPos = transformText.length;
1524
+
1525
+ if ( openParPos > 0 && openParPos < closeParPos ) {
1526
+
1527
+ const transformType = transformText.slice( 0, openParPos );
1528
+
1529
+ const array = parseFloats( transformText.slice( openParPos + 1 ) );
1530
+
1531
+ currentTransform.identity();
1532
+
1533
+ switch ( transformType ) {
1534
+
1535
+ case 'translate':
1536
+
1537
+ if ( array.length >= 1 ) {
1538
+
1539
+ const tx = array[ 0 ];
1540
+ let ty = 0;
1541
+
1542
+ if ( array.length >= 2 ) {
1543
+
1544
+ ty = array[ 1 ];
1545
+
1546
+ }
1547
+
1548
+ currentTransform.translate( tx, ty );
1549
+
1550
+ }
1551
+
1552
+ break;
1553
+
1554
+ case 'rotate':
1555
+
1556
+ if ( array.length >= 1 ) {
1557
+
1558
+ let angle = 0;
1559
+ let cx = 0;
1560
+ let cy = 0;
1561
+
1562
+ // Angle
1563
+ angle = array[ 0 ] * Math.PI / 180;
1564
+
1565
+ if ( array.length >= 3 ) {
1566
+
1567
+ // Center x, y
1568
+ cx = array[ 1 ];
1569
+ cy = array[ 2 ];
1570
+
1571
+ }
1572
+
1573
+ // Rotate around center (cx, cy)
1574
+ tempTransform1.makeTranslation( - cx, - cy );
1575
+ tempTransform2.makeRotation( angle );
1576
+ tempTransform3.multiplyMatrices( tempTransform2, tempTransform1 );
1577
+ tempTransform1.makeTranslation( cx, cy );
1578
+ currentTransform.multiplyMatrices( tempTransform1, tempTransform3 );
1579
+
1580
+ }
1581
+
1582
+ break;
1583
+
1584
+ case 'scale':
1585
+
1586
+ if ( array.length >= 1 ) {
1587
+
1588
+ const scaleX = array[ 0 ];
1589
+ let scaleY = scaleX;
1590
+
1591
+ if ( array.length >= 2 ) {
1592
+
1593
+ scaleY = array[ 1 ];
1594
+
1595
+ }
1596
+
1597
+ currentTransform.scale( scaleX, scaleY );
1598
+
1599
+ }
1600
+
1601
+ break;
1602
+
1603
+ case 'skewX':
1604
+
1605
+ if ( array.length === 1 ) {
1606
+
1607
+ currentTransform.set(
1608
+ 1, Math.tan( array[ 0 ] * Math.PI / 180 ), 0,
1609
+ 0, 1, 0,
1610
+ 0, 0, 1
1611
+ );
1612
+
1613
+ }
1614
+
1615
+ break;
1616
+
1617
+ case 'skewY':
1618
+
1619
+ if ( array.length === 1 ) {
1620
+
1621
+ currentTransform.set(
1622
+ 1, 0, 0,
1623
+ Math.tan( array[ 0 ] * Math.PI / 180 ), 1, 0,
1624
+ 0, 0, 1
1625
+ );
1626
+
1627
+ }
1628
+
1629
+ break;
1630
+
1631
+ case 'matrix':
1632
+
1633
+ if ( array.length === 6 ) {
1634
+
1635
+ currentTransform.set(
1636
+ array[ 0 ], array[ 2 ], array[ 4 ],
1637
+ array[ 1 ], array[ 3 ], array[ 5 ],
1638
+ 0, 0, 1
1639
+ );
1640
+
1641
+ }
1642
+
1643
+ break;
1644
+
1645
+ }
1646
+
1647
+ }
1648
+
1649
+ transform.premultiply( currentTransform );
1650
+
1651
+ }
1652
+
1653
+ }
1654
+
1655
+ return transform;
1656
+
1657
+ }
1658
+
1659
+ function transformPath( path, m ) {
1660
+
1661
+ function transfVec2( v2 ) {
1662
+
1663
+ tempV3.set( v2.x, v2.y, 1 ).applyMatrix3( m );
1664
+
1665
+ v2.set( tempV3.x, tempV3.y );
1666
+
1667
+ }
1668
+
1669
+ function transfEllipseGeneric( curve ) {
1670
+
1671
+ // For math description see:
1672
+ // https://math.stackexchange.com/questions/4544164
1673
+
1674
+ const a = curve.xRadius;
1675
+ const b = curve.yRadius;
1676
+
1677
+ const cosTheta = Math.cos( curve.aRotation );
1678
+ const sinTheta = Math.sin( curve.aRotation );
1679
+
1680
+ const v1 = new Vector3( a * cosTheta, a * sinTheta, 0 );
1681
+ const v2 = new Vector3( - b * sinTheta, b * cosTheta, 0 );
1682
+
1683
+ const f1 = v1.applyMatrix3( m );
1684
+ const f2 = v2.applyMatrix3( m );
1685
+
1686
+ const mF = tempTransform0.set(
1687
+ f1.x, f2.x, 0,
1688
+ f1.y, f2.y, 0,
1689
+ 0, 0, 1,
1690
+ );
1691
+
1692
+ const mFInv = tempTransform1.copy( mF ).invert();
1693
+ const mFInvT = tempTransform2.copy( mFInv ).transpose();
1694
+ const mQ = mFInvT.multiply( mFInv );
1695
+ const mQe = mQ.elements;
1696
+
1697
+ const ed = eigenDecomposition( mQe[ 0 ], mQe[ 1 ], mQe[ 4 ] );
1698
+ const rt1sqrt = Math.sqrt( ed.rt1 );
1699
+ const rt2sqrt = Math.sqrt( ed.rt2 );
1700
+
1701
+ curve.xRadius = 1 / rt1sqrt;
1702
+ curve.yRadius = 1 / rt2sqrt;
1703
+ curve.aRotation = Math.atan2( ed.sn, ed.cs );
1704
+
1705
+ const isFullEllipse =
1706
+ ( curve.aEndAngle - curve.aStartAngle ) % ( 2 * Math.PI ) < Number.EPSILON;
1707
+
1708
+ // Do not touch angles of a full ellipse because after transformation they
1709
+ // would converge to a single value effectively removing the whole curve
1710
+
1711
+ if ( ! isFullEllipse ) {
1712
+
1713
+ const mDsqrt = tempTransform1.set(
1714
+ rt1sqrt, 0, 0,
1715
+ 0, rt2sqrt, 0,
1716
+ 0, 0, 1,
1717
+ );
1718
+
1719
+ const mRT = tempTransform2.set(
1720
+ ed.cs, ed.sn, 0,
1721
+ - ed.sn, ed.cs, 0,
1722
+ 0, 0, 1,
1723
+ );
1724
+
1725
+ const mDRF = mDsqrt.multiply( mRT ).multiply( mF );
1726
+
1727
+ const transformAngle = phi => {
1728
+
1729
+ const { x: cosR, y: sinR } =
1730
+ new Vector3( Math.cos( phi ), Math.sin( phi ), 0 ).applyMatrix3( mDRF );
1731
+
1732
+ return Math.atan2( sinR, cosR );
1733
+
1734
+ };
1735
+
1736
+ curve.aStartAngle = transformAngle( curve.aStartAngle );
1737
+ curve.aEndAngle = transformAngle( curve.aEndAngle );
1738
+
1739
+ if ( isTransformFlipped( m ) ) {
1740
+
1741
+ curve.aClockwise = ! curve.aClockwise;
1742
+
1743
+ }
1744
+
1745
+ }
1746
+
1747
+ }
1748
+
1749
+ function transfEllipseNoSkew( curve ) {
1750
+
1751
+ // Faster shortcut if no skew is applied
1752
+ // (e.g, a euclidean transform of a group containing the ellipse)
1753
+
1754
+ const sx = getTransformScaleX( m );
1755
+ const sy = getTransformScaleY( m );
1756
+
1757
+ curve.xRadius *= sx;
1758
+ curve.yRadius *= sy;
1759
+
1760
+ // Extract rotation angle from the matrix of form:
1761
+ //
1762
+ // | cosθ sx -sinθ sy |
1763
+ // | sinθ sx cosθ sy |
1764
+ //
1765
+ // Remembering that tanθ = sinθ / cosθ; and that
1766
+ // `sx`, `sy`, or both might be zero.
1767
+ const theta =
1768
+ sx > Number.EPSILON
1769
+ ? Math.atan2( m.elements[ 1 ], m.elements[ 0 ] )
1770
+ : Math.atan2( - m.elements[ 3 ], m.elements[ 4 ] );
1771
+
1772
+ curve.aRotation += theta;
1773
+
1774
+ if ( isTransformFlipped( m ) ) {
1775
+
1776
+ curve.aStartAngle *= - 1;
1777
+ curve.aEndAngle *= - 1;
1778
+ curve.aClockwise = ! curve.aClockwise;
1779
+
1780
+ }
1781
+
1782
+ }
1783
+
1784
+ const subPaths = path.subPaths;
1785
+
1786
+ for ( let i = 0, n = subPaths.length; i < n; i ++ ) {
1787
+
1788
+ const subPath = subPaths[ i ];
1789
+ const curves = subPath.curves;
1790
+
1791
+ for ( let j = 0; j < curves.length; j ++ ) {
1792
+
1793
+ const curve = curves[ j ];
1794
+
1795
+ if ( curve.isLineCurve ) {
1796
+
1797
+ transfVec2( curve.v1 );
1798
+ transfVec2( curve.v2 );
1799
+
1800
+ } else if ( curve.isCubicBezierCurve ) {
1801
+
1802
+ transfVec2( curve.v0 );
1803
+ transfVec2( curve.v1 );
1804
+ transfVec2( curve.v2 );
1805
+ transfVec2( curve.v3 );
1806
+
1807
+ } else if ( curve.isQuadraticBezierCurve ) {
1808
+
1809
+ transfVec2( curve.v0 );
1810
+ transfVec2( curve.v1 );
1811
+ transfVec2( curve.v2 );
1812
+
1813
+ } else if ( curve.isEllipseCurve ) {
1814
+
1815
+ // Transform ellipse center point
1816
+
1817
+ tempV2.set( curve.aX, curve.aY );
1818
+ transfVec2( tempV2 );
1819
+ curve.aX = tempV2.x;
1820
+ curve.aY = tempV2.y;
1821
+
1822
+ // Transform ellipse shape parameters
1823
+
1824
+ if ( isTransformSkewed( m ) ) {
1825
+
1826
+ transfEllipseGeneric( curve );
1827
+
1828
+ } else {
1829
+
1830
+ transfEllipseNoSkew( curve );
1831
+
1832
+ }
1833
+
1834
+ }
1835
+
1836
+ }
1837
+
1838
+ }
1839
+
1840
+ }
1841
+
1842
+ function isTransformFlipped( m ) {
1843
+
1844
+ const te = m.elements;
1845
+ return te[ 0 ] * te[ 4 ] - te[ 1 ] * te[ 3 ] < 0;
1846
+
1847
+ }
1848
+
1849
+ function isTransformSkewed( m ) {
1850
+
1851
+ const te = m.elements;
1852
+ const basisDot = te[ 0 ] * te[ 3 ] + te[ 1 ] * te[ 4 ];
1853
+
1854
+ // Shortcut for trivial rotations and transformations
1855
+ if ( basisDot === 0 ) return false;
1856
+
1857
+ const sx = getTransformScaleX( m );
1858
+ const sy = getTransformScaleY( m );
1859
+
1860
+ return Math.abs( basisDot / ( sx * sy ) ) > Number.EPSILON;
1861
+
1862
+ }
1863
+
1864
+ function getTransformScaleX( m ) {
1865
+
1866
+ const te = m.elements;
1867
+ return Math.sqrt( te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] );
1868
+
1869
+ }
1870
+
1871
+ function getTransformScaleY( m ) {
1872
+
1873
+ const te = m.elements;
1874
+ return Math.sqrt( te[ 3 ] * te[ 3 ] + te[ 4 ] * te[ 4 ] );
1875
+
1876
+ }
1877
+
1878
+ // Calculates the eigensystem of a real symmetric 2x2 matrix
1879
+ // [ A B ]
1880
+ // [ B C ]
1881
+ // in the form
1882
+ // [ A B ] = [ cs -sn ] [ rt1 0 ] [ cs sn ]
1883
+ // [ B C ] [ sn cs ] [ 0 rt2 ] [ -sn cs ]
1884
+ // where rt1 >= rt2.
1885
+ //
1886
+ // Adapted from: https://www.mpi-hd.mpg.de/personalhomes/globes/3x3/index.html
1887
+ // -> Algorithms for real symmetric matrices -> Analytical (2x2 symmetric)
1888
+ function eigenDecomposition( A, B, C ) {
1889
+
1890
+ let rt1, rt2, cs, sn, t;
1891
+ const sm = A + C;
1892
+ const df = A - C;
1893
+ const rt = Math.sqrt( df * df + 4 * B * B );
1894
+
1895
+ if ( sm > 0 ) {
1896
+
1897
+ rt1 = 0.5 * ( sm + rt );
1898
+ t = 1 / rt1;
1899
+ rt2 = A * t * C - B * t * B;
1900
+
1901
+ } else if ( sm < 0 ) {
1902
+
1903
+ rt2 = 0.5 * ( sm - rt );
1904
+
1905
+ } else {
1906
+
1907
+ // This case needs to be treated separately to avoid div by 0
1908
+
1909
+ rt1 = 0.5 * rt;
1910
+ rt2 = - 0.5 * rt;
1911
+
1912
+ }
1913
+
1914
+ // Calculate eigenvectors
1915
+
1916
+ if ( df > 0 ) {
1917
+
1918
+ cs = df + rt;
1919
+
1920
+ } else {
1921
+
1922
+ cs = df - rt;
1923
+
1924
+ }
1925
+
1926
+ if ( Math.abs( cs ) > 2 * Math.abs( B ) ) {
1927
+
1928
+ t = - 2 * B / cs;
1929
+ sn = 1 / Math.sqrt( 1 + t * t );
1930
+ cs = t * sn;
1931
+
1932
+ } else if ( Math.abs( B ) === 0 ) {
1933
+
1934
+ cs = 1;
1935
+ sn = 0;
1936
+
1937
+ } else {
1938
+
1939
+ t = - 0.5 * cs / B;
1940
+ cs = 1 / Math.sqrt( 1 + t * t );
1941
+ sn = t * cs;
1942
+
1943
+ }
1944
+
1945
+ if ( df > 0 ) {
1946
+
1947
+ t = cs;
1948
+ cs = - sn;
1949
+ sn = t;
1950
+
1951
+ }
1952
+
1953
+ return { rt1, rt2, cs, sn };
1954
+
1955
+ }
1956
+
1957
+ //
1958
+
1959
+ const paths = [];
1960
+ const stylesheets = {};
1961
+
1962
+ const transformStack = [];
1963
+
1964
+ const tempTransform0 = new Matrix3();
1965
+ const tempTransform1 = new Matrix3();
1966
+ const tempTransform2 = new Matrix3();
1967
+ const tempTransform3 = new Matrix3();
1968
+ const tempV2 = new Vector2();
1969
+ const tempV3 = new Vector3();
1970
+
1971
+ const currentTransform = new Matrix3();
1972
+
1973
+ const xml = new DOMParser().parseFromString( text, 'image/svg+xml' ); // application/xml
1974
+
1975
+ parseNode( xml.documentElement, {
1976
+ fill: '#000',
1977
+ fillOpacity: 1,
1978
+ strokeOpacity: 1,
1979
+ strokeWidth: 1,
1980
+ strokeLineJoin: 'miter',
1981
+ strokeLineCap: 'butt',
1982
+ strokeMiterLimit: 4
1983
+ } );
1984
+
1985
+ const data = { paths: paths, xml: xml.documentElement };
1986
+
1987
+ // console.log( paths );
1988
+ return data;
1989
+
1990
+ }
1991
+
1992
+ /**
1993
+ * Creates from the given shape path and array of shapes.
1994
+ *
1995
+ * @param {ShapePath} shapePath - The shape path.
1996
+ * @return {Array<Shape>} An array of shapes.
1997
+ */
1998
+ static createShapes( shapePath ) {
1999
+
2000
+ const BIGNUMBER = 999999999;
2001
+
2002
+ const IntersectionLocationType = {
2003
+ ORIGIN: 0,
2004
+ DESTINATION: 1,
2005
+ BETWEEN: 2,
2006
+ LEFT: 3,
2007
+ RIGHT: 4,
2008
+ BEHIND: 5,
2009
+ BEYOND: 6
2010
+ };
2011
+
2012
+ const classifyResult = {
2013
+ loc: IntersectionLocationType.ORIGIN,
2014
+ t: 0
2015
+ };
2016
+
2017
+ function findEdgeIntersection( a0, a1, b0, b1 ) {
2018
+
2019
+ const x1 = a0.x;
2020
+ const x2 = a1.x;
2021
+ const x3 = b0.x;
2022
+ const x4 = b1.x;
2023
+ const y1 = a0.y;
2024
+ const y2 = a1.y;
2025
+ const y3 = b0.y;
2026
+ const y4 = b1.y;
2027
+ const nom1 = ( x4 - x3 ) * ( y1 - y3 ) - ( y4 - y3 ) * ( x1 - x3 );
2028
+ const nom2 = ( x2 - x1 ) * ( y1 - y3 ) - ( y2 - y1 ) * ( x1 - x3 );
2029
+ const denom = ( y4 - y3 ) * ( x2 - x1 ) - ( x4 - x3 ) * ( y2 - y1 );
2030
+ const t1 = nom1 / denom;
2031
+ const t2 = nom2 / denom;
2032
+
2033
+ if ( ( ( denom === 0 ) && ( nom1 !== 0 ) ) || ( t1 <= 0 ) || ( t1 >= 1 ) || ( t2 < 0 ) || ( t2 > 1 ) ) {
2034
+
2035
+ //1. lines are parallel or edges don't intersect
2036
+
2037
+ return null;
2038
+
2039
+ } else if ( ( nom1 === 0 ) && ( denom === 0 ) ) {
2040
+
2041
+ //2. lines are colinear
2042
+
2043
+ //check if endpoints of edge2 (b0-b1) lies on edge1 (a0-a1)
2044
+ for ( let i = 0; i < 2; i ++ ) {
2045
+
2046
+ classifyPoint( i === 0 ? b0 : b1, a0, a1 );
2047
+ //find position of this endpoints relatively to edge1
2048
+ if ( classifyResult.loc == IntersectionLocationType.ORIGIN ) {
2049
+
2050
+ const point = ( i === 0 ? b0 : b1 );
2051
+ return { x: point.x, y: point.y, t: classifyResult.t };
2052
+
2053
+ } else if ( classifyResult.loc == IntersectionLocationType.BETWEEN ) {
2054
+
2055
+ const x = + ( ( x1 + classifyResult.t * ( x2 - x1 ) ).toPrecision( 10 ) );
2056
+ const y = + ( ( y1 + classifyResult.t * ( y2 - y1 ) ).toPrecision( 10 ) );
2057
+ return { x: x, y: y, t: classifyResult.t, };
2058
+
2059
+ }
2060
+
2061
+ }
2062
+
2063
+ return null;
2064
+
2065
+ } else {
2066
+
2067
+ //3. edges intersect
2068
+
2069
+ for ( let i = 0; i < 2; i ++ ) {
2070
+
2071
+ classifyPoint( i === 0 ? b0 : b1, a0, a1 );
2072
+
2073
+ if ( classifyResult.loc == IntersectionLocationType.ORIGIN ) {
2074
+
2075
+ const point = ( i === 0 ? b0 : b1 );
2076
+ return { x: point.x, y: point.y, t: classifyResult.t };
2077
+
2078
+ }
2079
+
2080
+ }
2081
+
2082
+ const x = + ( ( x1 + t1 * ( x2 - x1 ) ).toPrecision( 10 ) );
2083
+ const y = + ( ( y1 + t1 * ( y2 - y1 ) ).toPrecision( 10 ) );
2084
+ return { x: x, y: y, t: t1 };
2085
+
2086
+ }
2087
+
2088
+ }
2089
+
2090
+ function classifyPoint( p, edgeStart, edgeEnd ) {
2091
+
2092
+ const ax = edgeEnd.x - edgeStart.x;
2093
+ const ay = edgeEnd.y - edgeStart.y;
2094
+ const bx = p.x - edgeStart.x;
2095
+ const by = p.y - edgeStart.y;
2096
+ const sa = ax * by - bx * ay;
2097
+
2098
+ if ( ( p.x === edgeStart.x ) && ( p.y === edgeStart.y ) ) {
2099
+
2100
+ classifyResult.loc = IntersectionLocationType.ORIGIN;
2101
+ classifyResult.t = 0;
2102
+ return;
2103
+
2104
+ }
2105
+
2106
+ if ( ( p.x === edgeEnd.x ) && ( p.y === edgeEnd.y ) ) {
2107
+
2108
+ classifyResult.loc = IntersectionLocationType.DESTINATION;
2109
+ classifyResult.t = 1;
2110
+ return;
2111
+
2112
+ }
2113
+
2114
+ if ( sa < - Number.EPSILON ) {
2115
+
2116
+ classifyResult.loc = IntersectionLocationType.LEFT;
2117
+ return;
2118
+
2119
+ }
2120
+
2121
+ if ( sa > Number.EPSILON ) {
2122
+
2123
+ classifyResult.loc = IntersectionLocationType.RIGHT;
2124
+ return;
2125
+
2126
+
2127
+ }
2128
+
2129
+ if ( ( ( ax * bx ) < 0 ) || ( ( ay * by ) < 0 ) ) {
2130
+
2131
+ classifyResult.loc = IntersectionLocationType.BEHIND;
2132
+ return;
2133
+
2134
+ }
2135
+
2136
+ if ( ( Math.sqrt( ax * ax + ay * ay ) ) < ( Math.sqrt( bx * bx + by * by ) ) ) {
2137
+
2138
+ classifyResult.loc = IntersectionLocationType.BEYOND;
2139
+ return;
2140
+
2141
+ }
2142
+
2143
+ let t;
2144
+
2145
+ if ( ax !== 0 ) {
2146
+
2147
+ t = bx / ax;
2148
+
2149
+ } else {
2150
+
2151
+ t = by / ay;
2152
+
2153
+ }
2154
+
2155
+ classifyResult.loc = IntersectionLocationType.BETWEEN;
2156
+ classifyResult.t = t;
2157
+
2158
+ }
2159
+
2160
+ function getIntersections( path1, path2 ) {
2161
+
2162
+ const intersectionsRaw = [];
2163
+ const intersections = [];
2164
+
2165
+ for ( let index = 1; index < path1.length; index ++ ) {
2166
+
2167
+ const path1EdgeStart = path1[ index - 1 ];
2168
+ const path1EdgeEnd = path1[ index ];
2169
+
2170
+ for ( let index2 = 1; index2 < path2.length; index2 ++ ) {
2171
+
2172
+ const path2EdgeStart = path2[ index2 - 1 ];
2173
+ const path2EdgeEnd = path2[ index2 ];
2174
+
2175
+ const intersection = findEdgeIntersection( path1EdgeStart, path1EdgeEnd, path2EdgeStart, path2EdgeEnd );
2176
+
2177
+ if ( intersection !== null && intersectionsRaw.find( i => i.t <= intersection.t + Number.EPSILON && i.t >= intersection.t - Number.EPSILON ) === undefined ) {
2178
+
2179
+ intersectionsRaw.push( intersection );
2180
+ intersections.push( new Vector2( intersection.x, intersection.y ) );
2181
+
2182
+ }
2183
+
2184
+ }
2185
+
2186
+ }
2187
+
2188
+ return intersections;
2189
+
2190
+ }
2191
+
2192
+ function getScanlineIntersections( scanline, boundingBox, paths ) {
2193
+
2194
+ const center = new Vector2();
2195
+ boundingBox.getCenter( center );
2196
+
2197
+ const allIntersections = [];
2198
+
2199
+ paths.forEach( path => {
2200
+
2201
+ // check if the center of the bounding box is in the bounding box of the paths.
2202
+ // this is a pruning method to limit the search of intersections in paths that can't envelop of the current path.
2203
+ // if a path envelops another path. The center of that other path, has to be inside the bounding box of the enveloping path.
2204
+ if ( path.boundingBox.containsPoint( center ) ) {
2205
+
2206
+ const intersections = getIntersections( scanline, path.points );
2207
+
2208
+ intersections.forEach( p => {
2209
+
2210
+ allIntersections.push( { identifier: path.identifier, isCW: path.isCW, point: p } );
2211
+
2212
+ } );
2213
+
2214
+ }
2215
+
2216
+ } );
2217
+
2218
+ allIntersections.sort( ( i1, i2 ) => {
2219
+
2220
+ return i1.point.x - i2.point.x;
2221
+
2222
+ } );
2223
+
2224
+ return allIntersections;
2225
+
2226
+ }
2227
+
2228
+ function isHoleTo( simplePath, allPaths, scanlineMinX, scanlineMaxX, _fillRule ) {
2229
+
2230
+ if ( _fillRule === null || _fillRule === undefined || _fillRule === '' ) {
2231
+
2232
+ _fillRule = 'nonzero';
2233
+
2234
+ }
2235
+
2236
+ const centerBoundingBox = new Vector2();
2237
+ simplePath.boundingBox.getCenter( centerBoundingBox );
2238
+
2239
+ const scanline = [ new Vector2( scanlineMinX, centerBoundingBox.y ), new Vector2( scanlineMaxX, centerBoundingBox.y ) ];
2240
+
2241
+ const scanlineIntersections = getScanlineIntersections( scanline, simplePath.boundingBox, allPaths );
2242
+
2243
+ scanlineIntersections.sort( ( i1, i2 ) => {
2244
+
2245
+ return i1.point.x - i2.point.x;
2246
+
2247
+ } );
2248
+
2249
+ const baseIntersections = [];
2250
+ const otherIntersections = [];
2251
+
2252
+ scanlineIntersections.forEach( i => {
2253
+
2254
+ if ( i.identifier === simplePath.identifier ) {
2255
+
2256
+ baseIntersections.push( i );
2257
+
2258
+ } else {
2259
+
2260
+ otherIntersections.push( i );
2261
+
2262
+ }
2263
+
2264
+ } );
2265
+
2266
+ const firstXOfPath = baseIntersections[ 0 ].point.x;
2267
+
2268
+ // build up the path hierarchy
2269
+ const stack = [];
2270
+ let i = 0;
2271
+
2272
+ while ( i < otherIntersections.length && otherIntersections[ i ].point.x < firstXOfPath ) {
2273
+
2274
+ if ( stack.length > 0 && stack[ stack.length - 1 ] === otherIntersections[ i ].identifier ) {
2275
+
2276
+ stack.pop();
2277
+
2278
+ } else {
2279
+
2280
+ stack.push( otherIntersections[ i ].identifier );
2281
+
2282
+ }
2283
+
2284
+ i ++;
2285
+
2286
+ }
2287
+
2288
+ stack.push( simplePath.identifier );
2289
+
2290
+ if ( _fillRule === 'evenodd' ) {
2291
+
2292
+ const isHole = stack.length % 2 === 0 ? true : false;
2293
+ const isHoleFor = stack[ stack.length - 2 ];
2294
+
2295
+ return { identifier: simplePath.identifier, isHole: isHole, for: isHoleFor };
2296
+
2297
+ } else if ( _fillRule === 'nonzero' ) {
2298
+
2299
+ // check if path is a hole by counting the amount of paths with alternating rotations it has to cross.
2300
+ let isHole = true;
2301
+ let isHoleFor = null;
2302
+ let lastCWValue = null;
2303
+
2304
+ for ( let i = 0; i < stack.length; i ++ ) {
2305
+
2306
+ const identifier = stack[ i ];
2307
+ if ( isHole ) {
2308
+
2309
+ lastCWValue = allPaths[ identifier ].isCW;
2310
+ isHole = false;
2311
+ isHoleFor = identifier;
2312
+
2313
+ } else if ( lastCWValue !== allPaths[ identifier ].isCW ) {
2314
+
2315
+ lastCWValue = allPaths[ identifier ].isCW;
2316
+ isHole = true;
2317
+
2318
+ }
2319
+
2320
+ }
2321
+
2322
+ return { identifier: simplePath.identifier, isHole: isHole, for: isHoleFor };
2323
+
2324
+ } else {
2325
+
2326
+ console.warn( 'fill-rule: "' + _fillRule + '" is currently not implemented.' );
2327
+
2328
+ }
2329
+
2330
+ }
2331
+
2332
+ // check for self intersecting paths
2333
+ // TODO
2334
+
2335
+ // check intersecting paths
2336
+ // TODO
2337
+
2338
+ // prepare paths for hole detection
2339
+ let scanlineMinX = BIGNUMBER;
2340
+ let scanlineMaxX = - BIGNUMBER;
2341
+
2342
+ let simplePaths = shapePath.subPaths.map( p => {
2343
+
2344
+ const points = p.getPoints();
2345
+ let maxY = - BIGNUMBER;
2346
+ let minY = BIGNUMBER;
2347
+ let maxX = - BIGNUMBER;
2348
+ let minX = BIGNUMBER;
2349
+
2350
+ //points.forEach(p => p.y *= -1);
2351
+
2352
+ for ( let i = 0; i < points.length; i ++ ) {
2353
+
2354
+ const p = points[ i ];
2355
+
2356
+ if ( p.y > maxY ) {
2357
+
2358
+ maxY = p.y;
2359
+
2360
+ }
2361
+
2362
+ if ( p.y < minY ) {
2363
+
2364
+ minY = p.y;
2365
+
2366
+ }
2367
+
2368
+ if ( p.x > maxX ) {
2369
+
2370
+ maxX = p.x;
2371
+
2372
+ }
2373
+
2374
+ if ( p.x < minX ) {
2375
+
2376
+ minX = p.x;
2377
+
2378
+ }
2379
+
2380
+ }
2381
+
2382
+ //
2383
+ if ( scanlineMaxX <= maxX ) {
2384
+
2385
+ scanlineMaxX = maxX + 1;
2386
+
2387
+ }
2388
+
2389
+ if ( scanlineMinX >= minX ) {
2390
+
2391
+ scanlineMinX = minX - 1;
2392
+
2393
+ }
2394
+
2395
+ return { curves: p.curves, points: points, isCW: ShapeUtils.isClockWise( points ), identifier: - 1, boundingBox: new Box2( new Vector2( minX, minY ), new Vector2( maxX, maxY ) ) };
2396
+
2397
+ } );
2398
+
2399
+ simplePaths = simplePaths.filter( sp => sp.points.length > 1 );
2400
+
2401
+ for ( let identifier = 0; identifier < simplePaths.length; identifier ++ ) {
2402
+
2403
+ simplePaths[ identifier ].identifier = identifier;
2404
+
2405
+ }
2406
+
2407
+ // check if path is solid or a hole
2408
+ const isAHole = simplePaths.map( p => isHoleTo( p, simplePaths, scanlineMinX, scanlineMaxX, ( shapePath.userData ? shapePath.userData.style.fillRule : undefined ) ) );
2409
+
2410
+
2411
+ const shapesToReturn = [];
2412
+ simplePaths.forEach( p => {
2413
+
2414
+ const amIAHole = isAHole[ p.identifier ];
2415
+
2416
+ if ( ! amIAHole.isHole ) {
2417
+
2418
+ const shape = new Shape();
2419
+ shape.curves = p.curves;
2420
+ const holes = isAHole.filter( h => h.isHole && h.for === p.identifier );
2421
+ holes.forEach( h => {
2422
+
2423
+ const hole = simplePaths[ h.identifier ];
2424
+ const path = new Path();
2425
+ path.curves = hole.curves;
2426
+ shape.holes.push( path );
2427
+
2428
+ } );
2429
+ shapesToReturn.push( shape );
2430
+
2431
+ }
2432
+
2433
+ } );
2434
+
2435
+ return shapesToReturn;
2436
+
2437
+ }
2438
+
2439
+ /**
2440
+ * Returns a stroke style object from the given parameters.
2441
+ *
2442
+ * @param {number} [width=1] - The stroke width.
2443
+ * @param {string} [color='#000'] - The stroke color, as returned by {@link Color#getStyle}.
2444
+ * @param {'round'|'bevel'|'miter'|'miter-limit'} [lineJoin='miter'] - The line join style.
2445
+ * @param {'round'|'square'|'butt'} [lineCap='butt'] - The line cap style.
2446
+ * @param {number} [miterLimit=4] - Maximum join length, in multiples of the `width` parameter (join is truncated if it exceeds that distance).
2447
+ * @return {Object} The style object.
2448
+ */
2449
+ static getStrokeStyle( width, color, lineJoin, lineCap, miterLimit ) {
2450
+
2451
+ width = width !== undefined ? width : 1;
2452
+ color = color !== undefined ? color : '#000';
2453
+ lineJoin = lineJoin !== undefined ? lineJoin : 'miter';
2454
+ lineCap = lineCap !== undefined ? lineCap : 'butt';
2455
+ miterLimit = miterLimit !== undefined ? miterLimit : 4;
2456
+
2457
+ return {
2458
+ strokeColor: color,
2459
+ strokeWidth: width,
2460
+ strokeLineJoin: lineJoin,
2461
+ strokeLineCap: lineCap,
2462
+ strokeMiterLimit: miterLimit
2463
+ };
2464
+
2465
+ }
2466
+
2467
+ /**
2468
+ * Creates a stroke from an array of points.
2469
+ *
2470
+ * @param {Array<Vector2>} points - The points in 2D space. Minimum 2 points. The path can be open or closed (last point equals to first point).
2471
+ * @param {Object} style - Object with SVG properties as returned by `SVGLoader.getStrokeStyle()`, or `SVGLoader.parse()` in the `path.userData.style` object.
2472
+ * @param {number} [arcDivisions=12] - Arc divisions for round joins and endcaps.
2473
+ * @param {number} [minDistance=0.001] - Points closer to this distance will be merged.
2474
+ * @return {?BufferGeometry} The stroke geometry. UV coordinates are generated ('u' along path. 'v' across it, from left to right).
2475
+ * Returns `null` if not geometry was generated.
2476
+ */
2477
+ static pointsToStroke( points, style, arcDivisions, minDistance ) {
2478
+
2479
+ const vertices = [];
2480
+ const normals = [];
2481
+ const uvs = [];
2482
+
2483
+ if ( SVGLoader.pointsToStrokeWithBuffers( points, style, arcDivisions, minDistance, vertices, normals, uvs ) === 0 ) {
2484
+
2485
+ return null;
2486
+
2487
+ }
2488
+
2489
+ const geometry = new BufferGeometry();
2490
+ geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
2491
+ geometry.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
2492
+ geometry.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
2493
+
2494
+ return geometry;
2495
+
2496
+ }
2497
+
2498
+ /**
2499
+ * Creates a stroke from an array of points.
2500
+ *
2501
+ * @param {Array<Vector2>} points - The points in 2D space. Minimum 2 points.
2502
+ * @param {Object} style - Object with SVG properties as returned by `SVGLoader.getStrokeStyle()`, or `SVGLoader.parse()` in the `path.userData.style` object.
2503
+ * @param {number} [arcDivisions=12] - Arc divisions for round joins and endcaps.
2504
+ * @param {number} [minDistance=0.001] - Points closer to this distance will be merged.
2505
+ * @param {Array<number>} vertices - An array holding vertices.
2506
+ * @param {Array<number>} normals - An array holding normals.
2507
+ * @param {Array<number>} uvs - An array holding uvs.
2508
+ * @param {number} [vertexOffset=0] - The vertex offset.
2509
+ * @return {number} The number of vertices.
2510
+ */
2511
+ static pointsToStrokeWithBuffers( points, style, arcDivisions, minDistance, vertices, normals, uvs, vertexOffset ) {
2512
+
2513
+ // This function can be called to update existing arrays or buffers.
2514
+ // Accepts same parameters as pointsToStroke, plus the buffers and optional offset.
2515
+ // Param vertexOffset: Offset vertices to start writing in the buffers (3 elements/vertex for vertices and normals, and 2 elements/vertex for uvs)
2516
+ // Returns number of written vertices / normals / uvs pairs
2517
+ // if 'vertices' parameter is undefined no triangles will be generated, but the returned vertices count will still be valid (useful to preallocate the buffers)
2518
+ // 'normals' and 'uvs' buffers are optional
2519
+
2520
+ const tempV2_1 = new Vector2();
2521
+ const tempV2_2 = new Vector2();
2522
+ const tempV2_3 = new Vector2();
2523
+ const tempV2_4 = new Vector2();
2524
+ const tempV2_5 = new Vector2();
2525
+ const tempV2_6 = new Vector2();
2526
+ const tempV2_7 = new Vector2();
2527
+ const lastPointL = new Vector2();
2528
+ const lastPointR = new Vector2();
2529
+ const point0L = new Vector2();
2530
+ const point0R = new Vector2();
2531
+ const currentPointL = new Vector2();
2532
+ const currentPointR = new Vector2();
2533
+ const nextPointL = new Vector2();
2534
+ const nextPointR = new Vector2();
2535
+ const innerPoint = new Vector2();
2536
+ const outerPoint = new Vector2();
2537
+
2538
+ arcDivisions = arcDivisions !== undefined ? arcDivisions : 12;
2539
+ minDistance = minDistance !== undefined ? minDistance : 0.001;
2540
+ vertexOffset = vertexOffset !== undefined ? vertexOffset : 0;
2541
+
2542
+ // First ensure there are no duplicated points
2543
+ points = removeDuplicatedPoints( points );
2544
+
2545
+ const numPoints = points.length;
2546
+
2547
+ if ( numPoints < 2 ) return 0;
2548
+
2549
+ const isClosed = points[ 0 ].equals( points[ numPoints - 1 ] );
2550
+
2551
+ let currentPoint;
2552
+ let previousPoint = points[ 0 ];
2553
+ let nextPoint;
2554
+
2555
+ const strokeWidth2 = style.strokeWidth / 2;
2556
+
2557
+ const deltaU = 1 / ( numPoints - 1 );
2558
+ let u0 = 0, u1;
2559
+
2560
+ let innerSideModified;
2561
+ let joinIsOnLeftSide;
2562
+ let isMiter;
2563
+ let initialJoinIsOnLeftSide = false;
2564
+
2565
+ let numVertices = 0;
2566
+ let currentCoordinate = vertexOffset * 3;
2567
+ let currentCoordinateUV = vertexOffset * 2;
2568
+
2569
+ // Get initial left and right stroke points
2570
+ getNormal( points[ 0 ], points[ 1 ], tempV2_1 ).multiplyScalar( strokeWidth2 );
2571
+ lastPointL.copy( points[ 0 ] ).sub( tempV2_1 );
2572
+ lastPointR.copy( points[ 0 ] ).add( tempV2_1 );
2573
+ point0L.copy( lastPointL );
2574
+ point0R.copy( lastPointR );
2575
+
2576
+ for ( let iPoint = 1; iPoint < numPoints; iPoint ++ ) {
2577
+
2578
+ currentPoint = points[ iPoint ];
2579
+
2580
+ // Get next point
2581
+ if ( iPoint === numPoints - 1 ) {
2582
+
2583
+ if ( isClosed ) {
2584
+
2585
+ // Skip duplicated initial point
2586
+ nextPoint = points[ 1 ];
2587
+
2588
+ } else nextPoint = undefined;
2589
+
2590
+ } else {
2591
+
2592
+ nextPoint = points[ iPoint + 1 ];
2593
+
2594
+ }
2595
+
2596
+ // Normal of previous segment in tempV2_1
2597
+ const normal1 = tempV2_1;
2598
+ getNormal( previousPoint, currentPoint, normal1 );
2599
+
2600
+ tempV2_3.copy( normal1 ).multiplyScalar( strokeWidth2 );
2601
+ currentPointL.copy( currentPoint ).sub( tempV2_3 );
2602
+ currentPointR.copy( currentPoint ).add( tempV2_3 );
2603
+
2604
+ u1 = u0 + deltaU;
2605
+
2606
+ innerSideModified = false;
2607
+
2608
+ if ( nextPoint !== undefined ) {
2609
+
2610
+ // Normal of next segment in tempV2_2
2611
+ getNormal( currentPoint, nextPoint, tempV2_2 );
2612
+
2613
+ tempV2_3.copy( tempV2_2 ).multiplyScalar( strokeWidth2 );
2614
+ nextPointL.copy( currentPoint ).sub( tempV2_3 );
2615
+ nextPointR.copy( currentPoint ).add( tempV2_3 );
2616
+
2617
+ joinIsOnLeftSide = true;
2618
+ tempV2_3.subVectors( nextPoint, previousPoint );
2619
+ if ( normal1.dot( tempV2_3 ) < 0 ) {
2620
+
2621
+ joinIsOnLeftSide = false;
2622
+
2623
+ }
2624
+
2625
+ if ( iPoint === 1 ) initialJoinIsOnLeftSide = joinIsOnLeftSide;
2626
+
2627
+ tempV2_3.subVectors( nextPoint, currentPoint );
2628
+ tempV2_3.normalize();
2629
+ const dot = Math.abs( normal1.dot( tempV2_3 ) );
2630
+
2631
+ // If path is straight, don't create join
2632
+ if ( dot > Number.EPSILON ) {
2633
+
2634
+ // Compute inner and outer segment intersections
2635
+ const miterSide = strokeWidth2 / dot;
2636
+ tempV2_3.multiplyScalar( - miterSide );
2637
+ tempV2_4.subVectors( currentPoint, previousPoint );
2638
+ tempV2_5.copy( tempV2_4 ).setLength( miterSide ).add( tempV2_3 );
2639
+ innerPoint.copy( tempV2_5 ).negate();
2640
+ const miterLength2 = tempV2_5.length();
2641
+ const segmentLengthPrev = tempV2_4.length();
2642
+ tempV2_4.divideScalar( segmentLengthPrev );
2643
+ tempV2_6.subVectors( nextPoint, currentPoint );
2644
+ const segmentLengthNext = tempV2_6.length();
2645
+ tempV2_6.divideScalar( segmentLengthNext );
2646
+ // Check that previous and next segments doesn't overlap with the innerPoint of intersection
2647
+ if ( tempV2_4.dot( innerPoint ) < segmentLengthPrev && tempV2_6.dot( innerPoint ) < segmentLengthNext ) {
2648
+
2649
+ innerSideModified = true;
2650
+
2651
+ }
2652
+
2653
+ outerPoint.copy( tempV2_5 ).add( currentPoint );
2654
+ innerPoint.add( currentPoint );
2655
+
2656
+ isMiter = false;
2657
+
2658
+ if ( innerSideModified ) {
2659
+
2660
+ if ( joinIsOnLeftSide ) {
2661
+
2662
+ nextPointR.copy( innerPoint );
2663
+ currentPointR.copy( innerPoint );
2664
+
2665
+ } else {
2666
+
2667
+ nextPointL.copy( innerPoint );
2668
+ currentPointL.copy( innerPoint );
2669
+
2670
+ }
2671
+
2672
+ } else {
2673
+
2674
+ // The segment triangles are generated here if there was overlapping
2675
+
2676
+ makeSegmentTriangles();
2677
+
2678
+ }
2679
+
2680
+ switch ( style.strokeLineJoin ) {
2681
+
2682
+ case 'bevel':
2683
+
2684
+ makeSegmentWithBevelJoin( joinIsOnLeftSide, innerSideModified, u1 );
2685
+
2686
+ break;
2687
+
2688
+ case 'round':
2689
+
2690
+ // Segment triangles
2691
+
2692
+ createSegmentTrianglesWithMiddleSection( joinIsOnLeftSide, innerSideModified );
2693
+
2694
+ // Join triangles
2695
+
2696
+ if ( joinIsOnLeftSide ) {
2697
+
2698
+ makeCircularSector( currentPoint, currentPointL, nextPointL, u1, 0 );
2699
+
2700
+ } else {
2701
+
2702
+ makeCircularSector( currentPoint, nextPointR, currentPointR, u1, 1 );
2703
+
2704
+ }
2705
+
2706
+ break;
2707
+
2708
+ case 'miter':
2709
+ case 'miter-clip':
2710
+ default:
2711
+
2712
+ const miterFraction = ( strokeWidth2 * style.strokeMiterLimit ) / miterLength2;
2713
+
2714
+ if ( miterFraction < 1 ) {
2715
+
2716
+ // The join miter length exceeds the miter limit
2717
+
2718
+ if ( style.strokeLineJoin !== 'miter-clip' ) {
2719
+
2720
+ makeSegmentWithBevelJoin( joinIsOnLeftSide, innerSideModified, u1 );
2721
+ break;
2722
+
2723
+ } else {
2724
+
2725
+ // Segment triangles
2726
+
2727
+ createSegmentTrianglesWithMiddleSection( joinIsOnLeftSide, innerSideModified );
2728
+
2729
+ // Miter-clip join triangles
2730
+
2731
+ if ( joinIsOnLeftSide ) {
2732
+
2733
+ tempV2_6.subVectors( outerPoint, currentPointL ).multiplyScalar( miterFraction ).add( currentPointL );
2734
+ tempV2_7.subVectors( outerPoint, nextPointL ).multiplyScalar( miterFraction ).add( nextPointL );
2735
+
2736
+ addVertex( currentPointL, u1, 0 );
2737
+ addVertex( tempV2_6, u1, 0 );
2738
+ addVertex( currentPoint, u1, 0.5 );
2739
+
2740
+ addVertex( currentPoint, u1, 0.5 );
2741
+ addVertex( tempV2_6, u1, 0 );
2742
+ addVertex( tempV2_7, u1, 0 );
2743
+
2744
+ addVertex( currentPoint, u1, 0.5 );
2745
+ addVertex( tempV2_7, u1, 0 );
2746
+ addVertex( nextPointL, u1, 0 );
2747
+
2748
+ } else {
2749
+
2750
+ tempV2_6.subVectors( outerPoint, currentPointR ).multiplyScalar( miterFraction ).add( currentPointR );
2751
+ tempV2_7.subVectors( outerPoint, nextPointR ).multiplyScalar( miterFraction ).add( nextPointR );
2752
+
2753
+ addVertex( currentPointR, u1, 1 );
2754
+ addVertex( tempV2_6, u1, 1 );
2755
+ addVertex( currentPoint, u1, 0.5 );
2756
+
2757
+ addVertex( currentPoint, u1, 0.5 );
2758
+ addVertex( tempV2_6, u1, 1 );
2759
+ addVertex( tempV2_7, u1, 1 );
2760
+
2761
+ addVertex( currentPoint, u1, 0.5 );
2762
+ addVertex( tempV2_7, u1, 1 );
2763
+ addVertex( nextPointR, u1, 1 );
2764
+
2765
+ }
2766
+
2767
+ }
2768
+
2769
+ } else {
2770
+
2771
+ // Miter join segment triangles
2772
+
2773
+ if ( innerSideModified ) {
2774
+
2775
+ // Optimized segment + join triangles
2776
+
2777
+ if ( joinIsOnLeftSide ) {
2778
+
2779
+ addVertex( lastPointR, u0, 1 );
2780
+ addVertex( lastPointL, u0, 0 );
2781
+ addVertex( outerPoint, u1, 0 );
2782
+
2783
+ addVertex( lastPointR, u0, 1 );
2784
+ addVertex( outerPoint, u1, 0 );
2785
+ addVertex( innerPoint, u1, 1 );
2786
+
2787
+ } else {
2788
+
2789
+ addVertex( lastPointR, u0, 1 );
2790
+ addVertex( lastPointL, u0, 0 );
2791
+ addVertex( outerPoint, u1, 1 );
2792
+
2793
+ addVertex( lastPointL, u0, 0 );
2794
+ addVertex( innerPoint, u1, 0 );
2795
+ addVertex( outerPoint, u1, 1 );
2796
+
2797
+ }
2798
+
2799
+
2800
+ if ( joinIsOnLeftSide ) {
2801
+
2802
+ nextPointL.copy( outerPoint );
2803
+
2804
+ } else {
2805
+
2806
+ nextPointR.copy( outerPoint );
2807
+
2808
+ }
2809
+
2810
+
2811
+ } else {
2812
+
2813
+ // Add extra miter join triangles
2814
+
2815
+ if ( joinIsOnLeftSide ) {
2816
+
2817
+ addVertex( currentPointL, u1, 0 );
2818
+ addVertex( outerPoint, u1, 0 );
2819
+ addVertex( currentPoint, u1, 0.5 );
2820
+
2821
+ addVertex( currentPoint, u1, 0.5 );
2822
+ addVertex( outerPoint, u1, 0 );
2823
+ addVertex( nextPointL, u1, 0 );
2824
+
2825
+ } else {
2826
+
2827
+ addVertex( currentPointR, u1, 1 );
2828
+ addVertex( outerPoint, u1, 1 );
2829
+ addVertex( currentPoint, u1, 0.5 );
2830
+
2831
+ addVertex( currentPoint, u1, 0.5 );
2832
+ addVertex( outerPoint, u1, 1 );
2833
+ addVertex( nextPointR, u1, 1 );
2834
+
2835
+ }
2836
+
2837
+ }
2838
+
2839
+ isMiter = true;
2840
+
2841
+ }
2842
+
2843
+ break;
2844
+
2845
+ }
2846
+
2847
+ } else {
2848
+
2849
+ // The segment triangles are generated here when two consecutive points are collinear
2850
+
2851
+ makeSegmentTriangles();
2852
+
2853
+ }
2854
+
2855
+ } else {
2856
+
2857
+ // The segment triangles are generated here if it is the ending segment
2858
+
2859
+ makeSegmentTriangles();
2860
+
2861
+ }
2862
+
2863
+ if ( ! isClosed && iPoint === numPoints - 1 ) {
2864
+
2865
+ // Start line endcap
2866
+ addCapGeometry( points[ 0 ], point0L, point0R, joinIsOnLeftSide, true, u0 );
2867
+
2868
+ }
2869
+
2870
+ // Increment loop variables
2871
+
2872
+ u0 = u1;
2873
+
2874
+ previousPoint = currentPoint;
2875
+
2876
+ lastPointL.copy( nextPointL );
2877
+ lastPointR.copy( nextPointR );
2878
+
2879
+ }
2880
+
2881
+ if ( ! isClosed ) {
2882
+
2883
+ // Ending line endcap
2884
+ addCapGeometry( currentPoint, currentPointL, currentPointR, joinIsOnLeftSide, false, u1 );
2885
+
2886
+ } else if ( innerSideModified && vertices ) {
2887
+
2888
+ // Modify path first segment vertices to adjust to the segments inner and outer intersections
2889
+
2890
+ let lastOuter = outerPoint;
2891
+ let lastInner = innerPoint;
2892
+
2893
+ if ( initialJoinIsOnLeftSide !== joinIsOnLeftSide ) {
2894
+
2895
+ lastOuter = innerPoint;
2896
+ lastInner = outerPoint;
2897
+
2898
+ }
2899
+
2900
+ if ( joinIsOnLeftSide ) {
2901
+
2902
+ if ( isMiter || initialJoinIsOnLeftSide ) {
2903
+
2904
+ lastInner.toArray( vertices, 0 * 3 );
2905
+ lastInner.toArray( vertices, 3 * 3 );
2906
+
2907
+ if ( isMiter ) {
2908
+
2909
+ lastOuter.toArray( vertices, 1 * 3 );
2910
+
2911
+ }
2912
+
2913
+ }
2914
+
2915
+ } else {
2916
+
2917
+ if ( isMiter || ! initialJoinIsOnLeftSide ) {
2918
+
2919
+ lastInner.toArray( vertices, 1 * 3 );
2920
+ lastInner.toArray( vertices, 3 * 3 );
2921
+
2922
+ if ( isMiter ) {
2923
+
2924
+ lastOuter.toArray( vertices, 0 * 3 );
2925
+
2926
+ }
2927
+
2928
+ }
2929
+
2930
+ }
2931
+
2932
+ }
2933
+
2934
+ return numVertices;
2935
+
2936
+ // -- End of algorithm
2937
+
2938
+ // -- Functions
2939
+
2940
+ function getNormal( p1, p2, result ) {
2941
+
2942
+ result.subVectors( p2, p1 );
2943
+ return result.set( - result.y, result.x ).normalize();
2944
+
2945
+ }
2946
+
2947
+ function addVertex( position, u, v ) {
2948
+
2949
+ if ( vertices ) {
2950
+
2951
+ vertices[ currentCoordinate ] = position.x;
2952
+ vertices[ currentCoordinate + 1 ] = position.y;
2953
+ vertices[ currentCoordinate + 2 ] = 0;
2954
+
2955
+ if ( normals ) {
2956
+
2957
+ normals[ currentCoordinate ] = 0;
2958
+ normals[ currentCoordinate + 1 ] = 0;
2959
+ normals[ currentCoordinate + 2 ] = 1;
2960
+
2961
+ }
2962
+
2963
+ currentCoordinate += 3;
2964
+
2965
+ if ( uvs ) {
2966
+
2967
+ uvs[ currentCoordinateUV ] = u;
2968
+ uvs[ currentCoordinateUV + 1 ] = v;
2969
+
2970
+ currentCoordinateUV += 2;
2971
+
2972
+ }
2973
+
2974
+ }
2975
+
2976
+ numVertices += 3;
2977
+
2978
+ }
2979
+
2980
+ function makeCircularSector( center, p1, p2, u, v ) {
2981
+
2982
+ // param p1, p2: Points in the circle arc.
2983
+ // p1 and p2 are in clockwise direction.
2984
+
2985
+ tempV2_1.copy( p1 ).sub( center ).normalize();
2986
+ tempV2_2.copy( p2 ).sub( center ).normalize();
2987
+
2988
+ let angle = Math.PI;
2989
+ const dot = tempV2_1.dot( tempV2_2 );
2990
+ if ( Math.abs( dot ) < 1 ) angle = Math.abs( Math.acos( dot ) );
2991
+
2992
+ angle /= arcDivisions;
2993
+
2994
+ tempV2_3.copy( p1 );
2995
+
2996
+ for ( let i = 0, il = arcDivisions - 1; i < il; i ++ ) {
2997
+
2998
+ tempV2_4.copy( tempV2_3 ).rotateAround( center, angle );
2999
+
3000
+ addVertex( tempV2_3, u, v );
3001
+ addVertex( tempV2_4, u, v );
3002
+ addVertex( center, u, 0.5 );
3003
+
3004
+ tempV2_3.copy( tempV2_4 );
3005
+
3006
+ }
3007
+
3008
+ addVertex( tempV2_3, u, v );
3009
+ addVertex( p2, u, v );
3010
+ addVertex( center, u, 0.5 );
3011
+
3012
+ }
3013
+
3014
+ function makeSegmentTriangles() {
3015
+
3016
+ addVertex( lastPointR, u0, 1 );
3017
+ addVertex( lastPointL, u0, 0 );
3018
+ addVertex( currentPointL, u1, 0 );
3019
+
3020
+ addVertex( lastPointR, u0, 1 );
3021
+ addVertex( currentPointL, u1, 0 );
3022
+ addVertex( currentPointR, u1, 1 );
3023
+
3024
+ }
3025
+
3026
+ function makeSegmentWithBevelJoin( joinIsOnLeftSide, innerSideModified, u ) {
3027
+
3028
+ if ( innerSideModified ) {
3029
+
3030
+ // Optimized segment + bevel triangles
3031
+
3032
+ if ( joinIsOnLeftSide ) {
3033
+
3034
+ // Path segments triangles
3035
+
3036
+ addVertex( lastPointR, u0, 1 );
3037
+ addVertex( lastPointL, u0, 0 );
3038
+ addVertex( currentPointL, u1, 0 );
3039
+
3040
+ addVertex( lastPointR, u0, 1 );
3041
+ addVertex( currentPointL, u1, 0 );
3042
+ addVertex( innerPoint, u1, 1 );
3043
+
3044
+ // Bevel join triangle
3045
+
3046
+ addVertex( currentPointL, u, 0 );
3047
+ addVertex( nextPointL, u, 0 );
3048
+ addVertex( innerPoint, u, 0.5 );
3049
+
3050
+ } else {
3051
+
3052
+ // Path segments triangles
3053
+
3054
+ addVertex( lastPointR, u0, 1 );
3055
+ addVertex( lastPointL, u0, 0 );
3056
+ addVertex( currentPointR, u1, 1 );
3057
+
3058
+ addVertex( lastPointL, u0, 0 );
3059
+ addVertex( innerPoint, u1, 0 );
3060
+ addVertex( currentPointR, u1, 1 );
3061
+
3062
+ // Bevel join triangle
3063
+
3064
+ addVertex( currentPointR, u, 1 );
3065
+ addVertex( innerPoint, u, 0 );
3066
+ addVertex( nextPointR, u, 1 );
3067
+
3068
+ }
3069
+
3070
+ } else {
3071
+
3072
+ // Bevel join triangle. The segment triangles are done in the main loop
3073
+
3074
+ if ( joinIsOnLeftSide ) {
3075
+
3076
+ addVertex( currentPointL, u, 0 );
3077
+ addVertex( nextPointL, u, 0 );
3078
+ addVertex( currentPoint, u, 0.5 );
3079
+
3080
+ } else {
3081
+
3082
+ addVertex( currentPointR, u, 1 );
3083
+ addVertex( nextPointR, u, 0 );
3084
+ addVertex( currentPoint, u, 0.5 );
3085
+
3086
+ }
3087
+
3088
+ }
3089
+
3090
+ }
3091
+
3092
+ function createSegmentTrianglesWithMiddleSection( joinIsOnLeftSide, innerSideModified ) {
3093
+
3094
+ if ( innerSideModified ) {
3095
+
3096
+ if ( joinIsOnLeftSide ) {
3097
+
3098
+ addVertex( lastPointR, u0, 1 );
3099
+ addVertex( lastPointL, u0, 0 );
3100
+ addVertex( currentPointL, u1, 0 );
3101
+
3102
+ addVertex( lastPointR, u0, 1 );
3103
+ addVertex( currentPointL, u1, 0 );
3104
+ addVertex( innerPoint, u1, 1 );
3105
+
3106
+ addVertex( currentPointL, u0, 0 );
3107
+ addVertex( currentPoint, u1, 0.5 );
3108
+ addVertex( innerPoint, u1, 1 );
3109
+
3110
+ addVertex( currentPoint, u1, 0.5 );
3111
+ addVertex( nextPointL, u0, 0 );
3112
+ addVertex( innerPoint, u1, 1 );
3113
+
3114
+ } else {
3115
+
3116
+ addVertex( lastPointR, u0, 1 );
3117
+ addVertex( lastPointL, u0, 0 );
3118
+ addVertex( currentPointR, u1, 1 );
3119
+
3120
+ addVertex( lastPointL, u0, 0 );
3121
+ addVertex( innerPoint, u1, 0 );
3122
+ addVertex( currentPointR, u1, 1 );
3123
+
3124
+ addVertex( currentPointR, u0, 1 );
3125
+ addVertex( innerPoint, u1, 0 );
3126
+ addVertex( currentPoint, u1, 0.5 );
3127
+
3128
+ addVertex( currentPoint, u1, 0.5 );
3129
+ addVertex( innerPoint, u1, 0 );
3130
+ addVertex( nextPointR, u0, 1 );
3131
+
3132
+ }
3133
+
3134
+ }
3135
+
3136
+ }
3137
+
3138
+ function addCapGeometry( center, p1, p2, joinIsOnLeftSide, start, u ) {
3139
+
3140
+ // param center: End point of the path
3141
+ // param p1, p2: Left and right cap points
3142
+
3143
+ switch ( style.strokeLineCap ) {
3144
+
3145
+ case 'round':
3146
+
3147
+ if ( start ) {
3148
+
3149
+ makeCircularSector( center, p2, p1, u, 0.5 );
3150
+
3151
+ } else {
3152
+
3153
+ makeCircularSector( center, p1, p2, u, 0.5 );
3154
+
3155
+ }
3156
+
3157
+ break;
3158
+
3159
+ case 'square':
3160
+
3161
+ if ( start ) {
3162
+
3163
+ tempV2_1.subVectors( p1, center );
3164
+ tempV2_2.set( tempV2_1.y, - tempV2_1.x );
3165
+
3166
+ tempV2_3.addVectors( tempV2_1, tempV2_2 ).add( center );
3167
+ tempV2_4.subVectors( tempV2_2, tempV2_1 ).add( center );
3168
+
3169
+ // Modify already existing vertices
3170
+ if ( joinIsOnLeftSide ) {
3171
+
3172
+ tempV2_3.toArray( vertices, 1 * 3 );
3173
+ tempV2_4.toArray( vertices, 0 * 3 );
3174
+ tempV2_4.toArray( vertices, 3 * 3 );
3175
+
3176
+ } else {
3177
+
3178
+ tempV2_3.toArray( vertices, 1 * 3 );
3179
+ // using tempV2_4 to update 3rd vertex if the uv.y of 3rd vertex is 1
3180
+ uvs[ 3 * 2 + 1 ] === 1 ? tempV2_4.toArray( vertices, 3 * 3 ) : tempV2_3.toArray( vertices, 3 * 3 );
3181
+ tempV2_4.toArray( vertices, 0 * 3 );
3182
+
3183
+ }
3184
+
3185
+ } else {
3186
+
3187
+ tempV2_1.subVectors( p2, center );
3188
+ tempV2_2.set( tempV2_1.y, - tempV2_1.x );
3189
+
3190
+ tempV2_3.addVectors( tempV2_1, tempV2_2 ).add( center );
3191
+ tempV2_4.subVectors( tempV2_2, tempV2_1 ).add( center );
3192
+
3193
+ const vl = vertices.length;
3194
+
3195
+ // Modify already existing vertices
3196
+ if ( joinIsOnLeftSide ) {
3197
+
3198
+ tempV2_3.toArray( vertices, vl - 1 * 3 );
3199
+ tempV2_4.toArray( vertices, vl - 2 * 3 );
3200
+ tempV2_4.toArray( vertices, vl - 4 * 3 );
3201
+
3202
+ } else {
3203
+
3204
+ tempV2_4.toArray( vertices, vl - 2 * 3 );
3205
+ tempV2_3.toArray( vertices, vl - 1 * 3 );
3206
+ tempV2_4.toArray( vertices, vl - 4 * 3 );
3207
+
3208
+ }
3209
+
3210
+ }
3211
+
3212
+ break;
3213
+
3214
+ case 'butt':
3215
+ default:
3216
+
3217
+ // Nothing to do here
3218
+ break;
3219
+
3220
+ }
3221
+
3222
+ }
3223
+
3224
+ function removeDuplicatedPoints( points ) {
3225
+
3226
+ // Creates a new array if necessary with duplicated points removed.
3227
+ // This does not remove duplicated initial and ending points of a closed path.
3228
+
3229
+ let dupPoints = false;
3230
+ for ( let i = 1, n = points.length - 1; i < n; i ++ ) {
3231
+
3232
+ if ( points[ i ].distanceTo( points[ i + 1 ] ) < minDistance ) {
3233
+
3234
+ dupPoints = true;
3235
+ break;
3236
+
3237
+ }
3238
+
3239
+ }
3240
+
3241
+ if ( ! dupPoints ) return points;
3242
+
3243
+ const newPoints = [];
3244
+ newPoints.push( points[ 0 ] );
3245
+
3246
+ for ( let i = 1, n = points.length - 1; i < n; i ++ ) {
3247
+
3248
+ if ( points[ i ].distanceTo( points[ i + 1 ] ) >= minDistance ) {
3249
+
3250
+ newPoints.push( points[ i ] );
3251
+
3252
+ }
3253
+
3254
+ }
3255
+
3256
+ newPoints.push( points[ points.length - 1 ] );
3257
+
3258
+ return newPoints;
3259
+
3260
+ }
3261
+
3262
+ }
3263
+
3264
+
3265
+ }
3266
+
3267
+ export { SVGLoader };