three-stdlib 2.25.0 → 2.25.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (539) hide show
  1. package/index.cjs +116401 -611
  2. package/index.js +116037 -263
  3. package/package.json +17 -4
  4. package/_polyfill/CapsuleGeometry.cjs +0 -22
  5. package/_polyfill/CapsuleGeometry.js +0 -22
  6. package/_polyfill/CompressedArrayTexture.cjs +0 -12
  7. package/_polyfill/CompressedArrayTexture.js +0 -12
  8. package/_polyfill/Data3DTexture.cjs +0 -17
  9. package/_polyfill/Data3DTexture.js +0 -17
  10. package/animation/AnimationClipCreator.cjs +0 -56
  11. package/animation/AnimationClipCreator.js +0 -56
  12. package/animation/CCDIKSolver.cjs +0 -269
  13. package/animation/CCDIKSolver.js +0 -269
  14. package/animation/MMDAnimationHelper.cjs +0 -688
  15. package/animation/MMDAnimationHelper.js +0 -688
  16. package/animation/MMDPhysics.cjs +0 -830
  17. package/animation/MMDPhysics.js +0 -830
  18. package/cameras/CinematicCamera.cjs +0 -131
  19. package/cameras/CinematicCamera.js +0 -131
  20. package/controls/ArcballControls.cjs +0 -2033
  21. package/controls/ArcballControls.js +0 -2033
  22. package/controls/DeviceOrientationControls.cjs +0 -85
  23. package/controls/DeviceOrientationControls.js +0 -85
  24. package/controls/DragControls.cjs +0 -182
  25. package/controls/DragControls.js +0 -182
  26. package/controls/FirstPersonControls.cjs +0 -229
  27. package/controls/FirstPersonControls.js +0 -229
  28. package/controls/FlyControls.cjs +0 -248
  29. package/controls/FlyControls.js +0 -248
  30. package/controls/OrbitControls.cjs +0 -791
  31. package/controls/OrbitControls.js +0 -791
  32. package/controls/PointerLockControls.cjs +0 -103
  33. package/controls/PointerLockControls.js +0 -103
  34. package/controls/TrackballControls.cjs +0 -502
  35. package/controls/TrackballControls.js +0 -502
  36. package/controls/TransformControls.cjs +0 -1089
  37. package/controls/TransformControls.js +0 -1089
  38. package/controls/experimental/CameraControls.cjs +0 -736
  39. package/controls/experimental/CameraControls.js +0 -736
  40. package/csm/CSM.cjs +0 -244
  41. package/csm/CSM.js +0 -244
  42. package/csm/CSMFrustum.cjs +0 -75
  43. package/csm/CSMFrustum.js +0 -75
  44. package/csm/CSMHelper.cjs +0 -114
  45. package/csm/CSMHelper.js +0 -114
  46. package/csm/CSMShader.cjs +0 -261
  47. package/csm/CSMShader.js +0 -261
  48. package/curves/CurveExtras.cjs +0 -214
  49. package/curves/CurveExtras.js +0 -214
  50. package/curves/NURBSCurve.cjs +0 -35
  51. package/curves/NURBSCurve.js +0 -35
  52. package/curves/NURBSSurface.cjs +0 -28
  53. package/curves/NURBSSurface.js +0 -28
  54. package/curves/NURBSUtils.cjs +0 -226
  55. package/curves/NURBSUtils.js +0 -226
  56. package/deprecated/Geometry.cjs +0 -971
  57. package/deprecated/Geometry.js +0 -971
  58. package/effects/AnaglyphEffect.cjs +0 -102
  59. package/effects/AnaglyphEffect.js +0 -102
  60. package/effects/AsciiEffect.cjs +0 -155
  61. package/effects/AsciiEffect.js +0 -155
  62. package/effects/OutlineEffect.cjs +0 -275
  63. package/effects/OutlineEffect.js +0 -275
  64. package/effects/ParallaxBarrierEffect.cjs +0 -65
  65. package/effects/ParallaxBarrierEffect.js +0 -65
  66. package/effects/PeppersGhostEffect.cjs +0 -88
  67. package/effects/PeppersGhostEffect.js +0 -88
  68. package/effects/StereoEffect.cjs +0 -35
  69. package/effects/StereoEffect.js +0 -35
  70. package/environments/RoomEnvironment.cjs +0 -95
  71. package/environments/RoomEnvironment.js +0 -78
  72. package/exporters/ColladaExporter.cjs +0 -331
  73. package/exporters/ColladaExporter.js +0 -331
  74. package/exporters/DRACOExporter.cjs +0 -141
  75. package/exporters/DRACOExporter.js +0 -141
  76. package/exporters/GLTFExporter.cjs +0 -1909
  77. package/exporters/GLTFExporter.js +0 -1909
  78. package/exporters/MMDExporter.cjs +0 -131
  79. package/exporters/MMDExporter.js +0 -131
  80. package/exporters/OBJExporter.cjs +0 -181
  81. package/exporters/OBJExporter.js +0 -181
  82. package/exporters/PLYExporter.cjs +0 -280
  83. package/exporters/PLYExporter.js +0 -280
  84. package/exporters/STLExporter.cjs +0 -146
  85. package/exporters/STLExporter.js +0 -146
  86. package/exporters/USDZExporter.cjs +0 -340
  87. package/exporters/USDZExporter.js +0 -340
  88. package/geometries/BoxLineGeometry.cjs +0 -45
  89. package/geometries/BoxLineGeometry.js +0 -45
  90. package/geometries/ConvexGeometry.cjs +0 -26
  91. package/geometries/ConvexGeometry.js +0 -26
  92. package/geometries/DecalGeometry.cjs +0 -184
  93. package/geometries/DecalGeometry.js +0 -184
  94. package/geometries/LightningStrike.cjs +0 -553
  95. package/geometries/LightningStrike.js +0 -553
  96. package/geometries/ParametricGeometries.cjs +0 -130
  97. package/geometries/ParametricGeometries.js +0 -130
  98. package/geometries/ParametricGeometry.cjs +0 -63
  99. package/geometries/ParametricGeometry.js +0 -63
  100. package/geometries/RoundedBoxGeometry.cjs +0 -91
  101. package/geometries/RoundedBoxGeometry.js +0 -91
  102. package/geometries/TeapotGeometry.cjs +0 -1563
  103. package/geometries/TeapotGeometry.js +0 -1563
  104. package/geometries/TextGeometry.cjs +0 -27
  105. package/geometries/TextGeometry.js +0 -27
  106. package/helpers/LightProbeHelper.cjs +0 -73
  107. package/helpers/LightProbeHelper.js +0 -73
  108. package/helpers/PositionalAudioHelper.cjs +0 -68
  109. package/helpers/PositionalAudioHelper.js +0 -68
  110. package/helpers/RectAreaLightHelper.cjs +0 -44
  111. package/helpers/RectAreaLightHelper.js +0 -44
  112. package/helpers/VertexNormalsHelper.cjs +0 -47
  113. package/helpers/VertexNormalsHelper.js +0 -47
  114. package/helpers/VertexTangentsHelper.cjs +0 -43
  115. package/helpers/VertexTangentsHelper.js +0 -43
  116. package/interactive/HTMLMesh.cjs +0 -325
  117. package/interactive/HTMLMesh.js +0 -325
  118. package/interactive/InteractiveGroup.cjs +0 -68
  119. package/interactive/InteractiveGroup.js +0 -68
  120. package/interactive/SelectionBox.cjs +0 -134
  121. package/interactive/SelectionBox.js +0 -134
  122. package/interactive/SelectionHelper.cjs +0 -51
  123. package/interactive/SelectionHelper.js +0 -51
  124. package/libs/MeshoptDecoder.cjs +0 -221
  125. package/libs/MeshoptDecoder.js +0 -221
  126. package/libs/MotionControllers.cjs +0 -325
  127. package/libs/MotionControllers.js +0 -325
  128. package/lights/LightProbeGenerator.cjs +0 -145
  129. package/lights/LightProbeGenerator.js +0 -145
  130. package/lights/RectAreaLightUniformsLib.cjs +0 -32846
  131. package/lights/RectAreaLightUniformsLib.js +0 -32846
  132. package/lines/Line2.cjs +0 -13
  133. package/lines/Line2.js +0 -13
  134. package/lines/LineGeometry.cjs +0 -44
  135. package/lines/LineGeometry.js +0 -44
  136. package/lines/LineMaterial.cjs +0 -547
  137. package/lines/LineMaterial.js +0 -547
  138. package/lines/LineSegments2.cjs +0 -203
  139. package/lines/LineSegments2.js +0 -203
  140. package/lines/LineSegmentsGeometry.cjs +0 -124
  141. package/lines/LineSegmentsGeometry.js +0 -124
  142. package/lines/Wireframe.cjs +0 -32
  143. package/lines/Wireframe.js +0 -32
  144. package/lines/WireframeGeometry2.cjs +0 -13
  145. package/lines/WireframeGeometry2.js +0 -13
  146. package/loaders/3DMLoader.cjs +0 -803
  147. package/loaders/3DMLoader.js +0 -803
  148. package/loaders/3MFLoader.cjs +0 -854
  149. package/loaders/3MFLoader.js +0 -854
  150. package/loaders/AMFLoader.cjs +0 -284
  151. package/loaders/AMFLoader.js +0 -284
  152. package/loaders/AssimpLoader.cjs +0 -1434
  153. package/loaders/AssimpLoader.js +0 -1434
  154. package/loaders/BVHLoader.cjs +0 -207
  155. package/loaders/BVHLoader.js +0 -207
  156. package/loaders/BasisTextureLoader.cjs +0 -489
  157. package/loaders/BasisTextureLoader.js +0 -489
  158. package/loaders/ColladaLoader.cjs +0 -2405
  159. package/loaders/ColladaLoader.js +0 -2405
  160. package/loaders/DDSLoader.cjs +0 -148
  161. package/loaders/DDSLoader.js +0 -148
  162. package/loaders/DRACOLoader.cjs +0 -341
  163. package/loaders/DRACOLoader.js +0 -341
  164. package/loaders/EXRLoader.cjs +0 -1356
  165. package/loaders/EXRLoader.js +0 -1356
  166. package/loaders/FBXLoader.cjs +0 -2457
  167. package/loaders/FBXLoader.js +0 -2457
  168. package/loaders/FontLoader.cjs +0 -123
  169. package/loaders/FontLoader.js +0 -123
  170. package/loaders/GCodeLoader.cjs +0 -141
  171. package/loaders/GCodeLoader.js +0 -141
  172. package/loaders/GLTFLoader.cjs +0 -2504
  173. package/loaders/GLTFLoader.js +0 -2504
  174. package/loaders/HDRCubeTextureLoader.cjs +0 -75
  175. package/loaders/HDRCubeTextureLoader.js +0 -75
  176. package/loaders/KMZLoader.cjs +0 -75
  177. package/loaders/KMZLoader.js +0 -75
  178. package/loaders/KTX2Loader.cjs +0 -480
  179. package/loaders/KTX2Loader.js +0 -480
  180. package/loaders/KTXLoader.cjs +0 -93
  181. package/loaders/KTXLoader.js +0 -93
  182. package/loaders/LDrawLoader.cjs +0 -1424
  183. package/loaders/LDrawLoader.js +0 -1424
  184. package/loaders/LUT3dlLoader.cjs +0 -103
  185. package/loaders/LUT3dlLoader.js +0 -103
  186. package/loaders/LUTCubeLoader.cjs +0 -107
  187. package/loaders/LUTCubeLoader.js +0 -107
  188. package/loaders/LWOLoader.cjs +0 -645
  189. package/loaders/LWOLoader.js +0 -645
  190. package/loaders/LottieLoader.cjs +0 -47
  191. package/loaders/LottieLoader.js +0 -47
  192. package/loaders/MD2Loader.cjs +0 -359
  193. package/loaders/MD2Loader.js +0 -359
  194. package/loaders/MDDLoader.cjs +0 -58
  195. package/loaders/MDDLoader.js +0 -58
  196. package/loaders/MMDLoader.cjs +0 -1121
  197. package/loaders/MMDLoader.js +0 -1121
  198. package/loaders/MTLLoader.cjs +0 -304
  199. package/loaders/MTLLoader.js +0 -304
  200. package/loaders/NRRDLoader.cjs +0 -401
  201. package/loaders/NRRDLoader.js +0 -401
  202. package/loaders/OBJLoader.cjs +0 -487
  203. package/loaders/OBJLoader.js +0 -487
  204. package/loaders/PCDLoader.cjs +0 -248
  205. package/loaders/PCDLoader.js +0 -248
  206. package/loaders/PDBLoader.cjs +0 -247
  207. package/loaders/PDBLoader.js +0 -247
  208. package/loaders/PLYLoader.cjs +0 -317
  209. package/loaders/PLYLoader.js +0 -317
  210. package/loaders/PRWMLoader.cjs +0 -160
  211. package/loaders/PRWMLoader.js +0 -160
  212. package/loaders/PVRLoader.cjs +0 -131
  213. package/loaders/PVRLoader.js +0 -131
  214. package/loaders/RGBELoader.cjs +0 -252
  215. package/loaders/RGBELoader.js +0 -252
  216. package/loaders/RGBMLoader.cjs +0 -1004
  217. package/loaders/RGBMLoader.js +0 -1004
  218. package/loaders/STLLoader.cjs +0 -190
  219. package/loaders/STLLoader.js +0 -190
  220. package/loaders/SVGLoader.cjs +0 -1712
  221. package/loaders/SVGLoader.js +0 -1712
  222. package/loaders/TDSLoader.cjs +0 -650
  223. package/loaders/TDSLoader.js +0 -650
  224. package/loaders/TGALoader.cjs +0 -285
  225. package/loaders/TGALoader.js +0 -285
  226. package/loaders/TTFLoader.cjs +0 -131
  227. package/loaders/TTFLoader.js +0 -131
  228. package/loaders/TiltLoader.cjs +0 -375
  229. package/loaders/TiltLoader.js +0 -375
  230. package/loaders/VOXLoader.cjs +0 -432
  231. package/loaders/VOXLoader.js +0 -432
  232. package/loaders/VRMLLoader.cjs +0 -2105
  233. package/loaders/VRMLLoader.js +0 -2105
  234. package/loaders/VRMLoader.cjs +0 -38
  235. package/loaders/VRMLoader.js +0 -38
  236. package/loaders/VTKLoader.cjs +0 -648
  237. package/loaders/VTKLoader.js +0 -648
  238. package/loaders/XLoader.cjs +0 -1258
  239. package/loaders/XLoader.js +0 -1258
  240. package/loaders/XYZLoader.cjs +0 -60
  241. package/loaders/XYZLoader.js +0 -60
  242. package/loaders/lwo/IFFParser.cjs +0 -743
  243. package/loaders/lwo/IFFParser.js +0 -743
  244. package/loaders/lwo/LWO2Parser.cjs +0 -312
  245. package/loaders/lwo/LWO2Parser.js +0 -312
  246. package/loaders/lwo/LWO3Parser.cjs +0 -282
  247. package/loaders/lwo/LWO3Parser.js +0 -282
  248. package/math/Capsule.cjs +0 -98
  249. package/math/Capsule.js +0 -98
  250. package/math/ColorConverter.cjs +0 -42
  251. package/math/ColorConverter.js +0 -42
  252. package/math/ConvexHull.cjs +0 -596
  253. package/math/ConvexHull.js +0 -596
  254. package/math/ImprovedNoise.cjs +0 -304
  255. package/math/ImprovedNoise.js +0 -304
  256. package/math/Lut.cjs +0 -137
  257. package/math/Lut.js +0 -137
  258. package/math/MeshSurfaceSampler.cjs +0 -103
  259. package/math/MeshSurfaceSampler.js +0 -103
  260. package/math/OBB.cjs +0 -242
  261. package/math/OBB.js +0 -242
  262. package/math/Octree.cjs +0 -273
  263. package/math/Octree.js +0 -273
  264. package/math/SimplexNoise.cjs +0 -440
  265. package/math/SimplexNoise.js +0 -440
  266. package/misc/ConvexObjectBreaker.cjs +0 -292
  267. package/misc/ConvexObjectBreaker.js +0 -292
  268. package/misc/GPUComputationRenderer.cjs +0 -205
  269. package/misc/GPUComputationRenderer.js +0 -205
  270. package/misc/Gyroscope.cjs +0 -33
  271. package/misc/Gyroscope.js +0 -33
  272. package/misc/MD2Character.cjs +0 -167
  273. package/misc/MD2Character.js +0 -167
  274. package/misc/MD2CharacterComplex.cjs +0 -332
  275. package/misc/MD2CharacterComplex.js +0 -332
  276. package/misc/MorphAnimMesh.cjs +0 -40
  277. package/misc/MorphAnimMesh.js +0 -40
  278. package/misc/MorphBlendMesh.cjs +0 -179
  279. package/misc/MorphBlendMesh.js +0 -179
  280. package/misc/ProgressiveLightmap.cjs +0 -186
  281. package/misc/ProgressiveLightmap.js +0 -186
  282. package/misc/RollerCoaster.cjs +0 -353
  283. package/misc/RollerCoaster.js +0 -353
  284. package/misc/Timer.cjs +0 -101
  285. package/misc/Timer.js +0 -101
  286. package/misc/TubePainter.cjs +0 -123
  287. package/misc/TubePainter.js +0 -123
  288. package/misc/Volume.cjs +0 -305
  289. package/misc/Volume.js +0 -305
  290. package/misc/VolumeSlice.cjs +0 -114
  291. package/misc/VolumeSlice.js +0 -114
  292. package/misc/WebGL.cjs +0 -74
  293. package/misc/WebGL.js +0 -74
  294. package/modifiers/CurveModifier.cjs +0 -232
  295. package/modifiers/CurveModifier.js +0 -232
  296. package/modifiers/EdgeSplitModifier.cjs +0 -167
  297. package/modifiers/EdgeSplitModifier.js +0 -168
  298. package/modifiers/SimplifyModifier.cjs +0 -301
  299. package/modifiers/SimplifyModifier.js +0 -301
  300. package/modifiers/TessellateModifier.cjs +0 -214
  301. package/modifiers/TessellateModifier.js +0 -214
  302. package/objects/GroundProjectedEnv.cjs +0 -134
  303. package/objects/GroundProjectedEnv.js +0 -134
  304. package/objects/Lensflare.cjs +0 -291
  305. package/objects/Lensflare.js +0 -291
  306. package/objects/LightningStorm.cjs +0 -110
  307. package/objects/LightningStorm.js +0 -110
  308. package/objects/MarchingCubes.cjs +0 -4809
  309. package/objects/MarchingCubes.js +0 -4809
  310. package/objects/Reflector.cjs +0 -202
  311. package/objects/Reflector.js +0 -202
  312. package/objects/ReflectorForSSRPass.cjs +0 -260
  313. package/objects/ReflectorForSSRPass.js +0 -260
  314. package/objects/ReflectorRTT.cjs +0 -10
  315. package/objects/ReflectorRTT.js +0 -10
  316. package/objects/Refractor.cjs +0 -215
  317. package/objects/Refractor.js +0 -215
  318. package/objects/ShadowMesh.cjs +0 -45
  319. package/objects/ShadowMesh.js +0 -45
  320. package/objects/Sky.cjs +0 -200
  321. package/objects/Sky.js +0 -200
  322. package/objects/Water.cjs +0 -242
  323. package/objects/Water.js +0 -242
  324. package/objects/Water2.cjs +0 -256
  325. package/objects/Water2.js +0 -256
  326. package/physics/AmmoPhysics.cjs +0 -166
  327. package/physics/AmmoPhysics.js +0 -166
  328. package/postprocessing/AdaptiveToneMappingPass.cjs +0 -218
  329. package/postprocessing/AdaptiveToneMappingPass.js +0 -218
  330. package/postprocessing/AfterimagePass.cjs +0 -68
  331. package/postprocessing/AfterimagePass.js +0 -68
  332. package/postprocessing/BloomPass.cjs +0 -109
  333. package/postprocessing/BloomPass.js +0 -109
  334. package/postprocessing/BokehPass.cjs +0 -90
  335. package/postprocessing/BokehPass.js +0 -90
  336. package/postprocessing/ClearPass.cjs +0 -36
  337. package/postprocessing/ClearPass.js +0 -36
  338. package/postprocessing/CubeTexturePass.cjs +0 -53
  339. package/postprocessing/CubeTexturePass.js +0 -53
  340. package/postprocessing/DotScreenPass.cjs +0 -49
  341. package/postprocessing/DotScreenPass.js +0 -49
  342. package/postprocessing/EffectComposer.cjs +0 -157
  343. package/postprocessing/EffectComposer.js +0 -157
  344. package/postprocessing/FilmPass.cjs +0 -51
  345. package/postprocessing/FilmPass.js +0 -51
  346. package/postprocessing/GlitchPass.cjs +0 -84
  347. package/postprocessing/GlitchPass.js +0 -84
  348. package/postprocessing/HalftonePass.cjs +0 -53
  349. package/postprocessing/HalftonePass.js +0 -53
  350. package/postprocessing/LUTPass.cjs +0 -142
  351. package/postprocessing/LUTPass.js +0 -142
  352. package/postprocessing/MaskPass.cjs +0 -69
  353. package/postprocessing/MaskPass.js +0 -69
  354. package/postprocessing/OutlinePass.cjs +0 -479
  355. package/postprocessing/OutlinePass.js +0 -479
  356. package/postprocessing/Pass.cjs +0 -48
  357. package/postprocessing/Pass.js +0 -48
  358. package/postprocessing/RenderPass.cjs +0 -59
  359. package/postprocessing/RenderPass.js +0 -59
  360. package/postprocessing/RenderPixelatedPass.cjs +0 -199
  361. package/postprocessing/RenderPixelatedPass.js +0 -199
  362. package/postprocessing/SAOPass.cjs +0 -288
  363. package/postprocessing/SAOPass.js +0 -288
  364. package/postprocessing/SMAAPass.cjs +0 -112
  365. package/postprocessing/SMAAPass.js +0 -112
  366. package/postprocessing/SSAARenderPass.cjs +0 -189
  367. package/postprocessing/SSAARenderPass.js +0 -189
  368. package/postprocessing/SSAOPass.cjs +0 -272
  369. package/postprocessing/SSAOPass.js +0 -272
  370. package/postprocessing/SSRPass.cjs +0 -411
  371. package/postprocessing/SSRPass.js +0 -411
  372. package/postprocessing/SavePass.cjs +0 -38
  373. package/postprocessing/SavePass.js +0 -38
  374. package/postprocessing/ShaderPass.cjs +0 -49
  375. package/postprocessing/ShaderPass.js +0 -49
  376. package/postprocessing/TAARenderPass.cjs +0 -174
  377. package/postprocessing/TAARenderPass.js +0 -174
  378. package/postprocessing/TexturePass.cjs +0 -42
  379. package/postprocessing/TexturePass.js +0 -42
  380. package/postprocessing/UnrealBloomPass.cjs +0 -277
  381. package/postprocessing/UnrealBloomPass.js +0 -277
  382. package/postprocessing/WaterPass.cjs +0 -72
  383. package/postprocessing/WaterPass.js +0 -72
  384. package/renderers/CSS2DRenderer.cjs +0 -122
  385. package/renderers/CSS2DRenderer.js +0 -122
  386. package/renderers/CSS3DRenderer.cjs +0 -167
  387. package/renderers/CSS3DRenderer.js +0 -167
  388. package/renderers/Projector.cjs +0 -499
  389. package/renderers/Projector.js +0 -499
  390. package/renderers/SVGRenderer.cjs +0 -311
  391. package/renderers/SVGRenderer.js +0 -311
  392. package/shaders/ACESFilmicToneMappingShader.cjs +0 -55
  393. package/shaders/ACESFilmicToneMappingShader.js +0 -55
  394. package/shaders/AfterimageShader.cjs +0 -32
  395. package/shaders/AfterimageShader.js +0 -32
  396. package/shaders/BasicShader.cjs +0 -12
  397. package/shaders/BasicShader.js +0 -12
  398. package/shaders/BleachBypassShader.cjs +0 -35
  399. package/shaders/BleachBypassShader.js +0 -35
  400. package/shaders/BlendShader.cjs +0 -30
  401. package/shaders/BlendShader.js +0 -30
  402. package/shaders/BokehShader.cjs +0 -109
  403. package/shaders/BokehShader.js +0 -109
  404. package/shaders/BokehShader2.cjs +0 -269
  405. package/shaders/BokehShader2.js +0 -269
  406. package/shaders/BrightnessContrastShader.cjs +0 -32
  407. package/shaders/BrightnessContrastShader.js +0 -32
  408. package/shaders/ColorCorrectionShader.cjs +0 -30
  409. package/shaders/ColorCorrectionShader.js +0 -30
  410. package/shaders/ColorifyShader.cjs +0 -28
  411. package/shaders/ColorifyShader.js +0 -28
  412. package/shaders/ConvolutionShader.cjs +0 -55
  413. package/shaders/ConvolutionShader.js +0 -55
  414. package/shaders/CopyShader.cjs +0 -25
  415. package/shaders/CopyShader.js +0 -25
  416. package/shaders/DOFMipMapShader.cjs +0 -32
  417. package/shaders/DOFMipMapShader.js +0 -32
  418. package/shaders/DepthLimitedBlurShader.cjs +0 -114
  419. package/shaders/DepthLimitedBlurShader.js +0 -114
  420. package/shaders/DigitalGlitch.cjs +0 -85
  421. package/shaders/DigitalGlitch.js +0 -85
  422. package/shaders/DotScreenShader.cjs +0 -39
  423. package/shaders/DotScreenShader.js +0 -39
  424. package/shaders/FXAAShader.cjs +0 -1098
  425. package/shaders/FXAAShader.js +0 -1098
  426. package/shaders/FilmShader.cjs +0 -53
  427. package/shaders/FilmShader.js +0 -53
  428. package/shaders/FocusShader.cjs +0 -55
  429. package/shaders/FocusShader.js +0 -55
  430. package/shaders/FreiChenShader.cjs +0 -64
  431. package/shaders/FreiChenShader.js +0 -64
  432. package/shaders/FresnelShader.cjs +0 -47
  433. package/shaders/FresnelShader.js +0 -47
  434. package/shaders/GammaCorrectionShader.cjs +0 -23
  435. package/shaders/GammaCorrectionShader.js +0 -23
  436. package/shaders/GodRaysShader.cjs +0 -183
  437. package/shaders/GodRaysShader.js +0 -183
  438. package/shaders/HalftoneShader.cjs +0 -228
  439. package/shaders/HalftoneShader.js +0 -228
  440. package/shaders/HorizontalBlurShader.cjs +0 -49
  441. package/shaders/HorizontalBlurShader.js +0 -49
  442. package/shaders/HorizontalTiltShiftShader.cjs +0 -37
  443. package/shaders/HorizontalTiltShiftShader.js +0 -37
  444. package/shaders/HueSaturationShader.cjs +0 -43
  445. package/shaders/HueSaturationShader.js +0 -43
  446. package/shaders/KaleidoShader.cjs +0 -34
  447. package/shaders/KaleidoShader.js +0 -34
  448. package/shaders/LuminosityHighPassShader.cjs +0 -37
  449. package/shaders/LuminosityHighPassShader.js +0 -37
  450. package/shaders/LuminosityShader.cjs +0 -25
  451. package/shaders/LuminosityShader.js +0 -25
  452. package/shaders/MirrorShader.cjs +0 -35
  453. package/shaders/MirrorShader.js +0 -35
  454. package/shaders/NormalMapShader.cjs +0 -31
  455. package/shaders/NormalMapShader.js +0 -31
  456. package/shaders/ParallaxShader.cjs +0 -133
  457. package/shaders/ParallaxShader.js +0 -133
  458. package/shaders/PixelShader.cjs +0 -28
  459. package/shaders/PixelShader.js +0 -28
  460. package/shaders/RGBShiftShader.cjs +0 -30
  461. package/shaders/RGBShiftShader.js +0 -30
  462. package/shaders/SAOShader.cjs +0 -144
  463. package/shaders/SAOShader.js +0 -144
  464. package/shaders/SMAAShader.cjs +0 -358
  465. package/shaders/SMAAShader.js +0 -358
  466. package/shaders/SSAOShader.cjs +0 -182
  467. package/shaders/SSAOShader.js +0 -182
  468. package/shaders/SSRShader.cjs +0 -342
  469. package/shaders/SSRShader.js +0 -342
  470. package/shaders/SepiaShader.cjs +0 -29
  471. package/shaders/SepiaShader.js +0 -29
  472. package/shaders/SobelOperatorShader.cjs +0 -54
  473. package/shaders/SobelOperatorShader.js +0 -54
  474. package/shaders/SubsurfaceScatteringShader.cjs +0 -98
  475. package/shaders/SubsurfaceScatteringShader.js +0 -98
  476. package/shaders/TechnicolorShader.cjs +0 -24
  477. package/shaders/TechnicolorShader.js +0 -24
  478. package/shaders/ToneMapShader.cjs +0 -51
  479. package/shaders/ToneMapShader.js +0 -51
  480. package/shaders/ToonShader.cjs +0 -188
  481. package/shaders/ToonShader.js +0 -188
  482. package/shaders/TriangleBlurShader.cjs +0 -37
  483. package/shaders/TriangleBlurShader.js +0 -37
  484. package/shaders/UnpackDepthRGBAShader.cjs +0 -26
  485. package/shaders/UnpackDepthRGBAShader.js +0 -26
  486. package/shaders/VerticalBlurShader.cjs +0 -50
  487. package/shaders/VerticalBlurShader.js +0 -50
  488. package/shaders/VerticalTiltShiftShader.cjs +0 -37
  489. package/shaders/VerticalTiltShiftShader.js +0 -37
  490. package/shaders/VignetteShader.cjs +0 -38
  491. package/shaders/VignetteShader.js +0 -38
  492. package/shaders/VolumeShader.cjs +0 -225
  493. package/shaders/VolumeShader.js +0 -225
  494. package/shaders/WaterRefractionShader.cjs +0 -59
  495. package/shaders/WaterRefractionShader.js +0 -59
  496. package/shaders/types.cjs +0 -1
  497. package/shaders/types.js +0 -1
  498. package/textures/FlakesTexture.cjs +0 -30
  499. package/textures/FlakesTexture.js +0 -30
  500. package/types/helpers.cjs +0 -4
  501. package/types/helpers.js +0 -4
  502. package/utils/BufferGeometryUtils.cjs +0 -636
  503. package/utils/BufferGeometryUtils.js +0 -636
  504. package/utils/GeometryCompressionUtils.cjs +0 -573
  505. package/utils/GeometryCompressionUtils.js +0 -573
  506. package/utils/GeometryUtils.cjs +0 -109
  507. package/utils/GeometryUtils.js +0 -109
  508. package/utils/RoughnessMipmapper.cjs +0 -223
  509. package/utils/RoughnessMipmapper.js +0 -223
  510. package/utils/SceneUtils.cjs +0 -36
  511. package/utils/SceneUtils.js +0 -36
  512. package/utils/ShadowMapViewer.cjs +0 -111
  513. package/utils/ShadowMapViewer.js +0 -111
  514. package/utils/SkeletonUtils.cjs +0 -211
  515. package/utils/SkeletonUtils.js +0 -211
  516. package/utils/UVsDebug.cjs +0 -80
  517. package/utils/UVsDebug.js +0 -80
  518. package/utils/WorkerPool.cjs +0 -62
  519. package/utils/WorkerPool.js +0 -62
  520. package/webxr/ARButton.cjs +0 -119
  521. package/webxr/ARButton.js +0 -119
  522. package/webxr/OculusHandModel.cjs +0 -82
  523. package/webxr/OculusHandModel.js +0 -82
  524. package/webxr/OculusHandPointerModel.cjs +0 -241
  525. package/webxr/OculusHandPointerModel.js +0 -224
  526. package/webxr/Text2D.cjs +0 -48
  527. package/webxr/Text2D.js +0 -31
  528. package/webxr/VRButton.cjs +0 -111
  529. package/webxr/VRButton.js +0 -111
  530. package/webxr/XRControllerModelFactory.cjs +0 -174
  531. package/webxr/XRControllerModelFactory.js +0 -174
  532. package/webxr/XREstimatedLight.cjs +0 -126
  533. package/webxr/XREstimatedLight.js +0 -126
  534. package/webxr/XRHandMeshModel.cjs +0 -82
  535. package/webxr/XRHandMeshModel.js +0 -82
  536. package/webxr/XRHandModelFactory.cjs +0 -61
  537. package/webxr/XRHandModelFactory.js +0 -61
  538. package/webxr/XRHandPrimitiveModel.cjs +0 -68
  539. package/webxr/XRHandPrimitiveModel.js +0 -68
@@ -1,1712 +0,0 @@
1
- import { Loader, FileLoader, ShapePath, Vector2, Path, Matrix3, Vector3, ShapeUtils, Box2, Shape, BufferGeometry, Float32BufferAttribute } from "three";
2
- class SVGLoader extends Loader {
3
- constructor(manager) {
4
- super(manager);
5
- this.defaultDPI = 90;
6
- this.defaultUnit = "px";
7
- }
8
- load(url, onLoad, onProgress, onError) {
9
- const scope = this;
10
- const loader = new FileLoader(scope.manager);
11
- loader.setPath(scope.path);
12
- loader.setRequestHeader(scope.requestHeader);
13
- loader.setWithCredentials(scope.withCredentials);
14
- loader.load(
15
- url,
16
- function(text) {
17
- try {
18
- onLoad(scope.parse(text));
19
- } catch (e) {
20
- if (onError) {
21
- onError(e);
22
- } else {
23
- console.error(e);
24
- }
25
- scope.manager.itemError(url);
26
- }
27
- },
28
- onProgress,
29
- onError
30
- );
31
- }
32
- parse(text) {
33
- const scope = this;
34
- function parseNode(node, style) {
35
- if (node.nodeType !== 1)
36
- return;
37
- const transform = getNodeTransform(node);
38
- let traverseChildNodes = true;
39
- let path = null;
40
- switch (node.nodeName) {
41
- case "svg":
42
- break;
43
- case "style":
44
- parseCSSStylesheet(node);
45
- break;
46
- case "g":
47
- style = parseStyle(node, style);
48
- break;
49
- case "path":
50
- style = parseStyle(node, style);
51
- if (node.hasAttribute("d"))
52
- path = parsePathNode(node);
53
- break;
54
- case "rect":
55
- style = parseStyle(node, style);
56
- path = parseRectNode(node);
57
- break;
58
- case "polygon":
59
- style = parseStyle(node, style);
60
- path = parsePolygonNode(node);
61
- break;
62
- case "polyline":
63
- style = parseStyle(node, style);
64
- path = parsePolylineNode(node);
65
- break;
66
- case "circle":
67
- style = parseStyle(node, style);
68
- path = parseCircleNode(node);
69
- break;
70
- case "ellipse":
71
- style = parseStyle(node, style);
72
- path = parseEllipseNode(node);
73
- break;
74
- case "line":
75
- style = parseStyle(node, style);
76
- path = parseLineNode(node);
77
- break;
78
- case "defs":
79
- traverseChildNodes = false;
80
- break;
81
- case "mask":
82
- traverseChildNodes = false;
83
- break;
84
- case "use":
85
- style = parseStyle(node, style);
86
- const usedNodeId = node.href.baseVal.substring(1);
87
- const usedNode = node.viewportElement.getElementById(usedNodeId);
88
- if (usedNode) {
89
- parseNode(usedNode, style);
90
- } else {
91
- console.warn("SVGLoader: 'use node' references non-existent node id: " + usedNodeId);
92
- }
93
- break;
94
- default:
95
- }
96
- if (path) {
97
- if (style.fill !== void 0 && style.fill !== "none") {
98
- path.color.setStyle(style.fill);
99
- }
100
- transformPath(path, currentTransform);
101
- paths.push(path);
102
- path.userData = { node, style };
103
- }
104
- if (traverseChildNodes) {
105
- const nodes = node.childNodes;
106
- for (let i = 0; i < nodes.length; i++) {
107
- parseNode(nodes[i], style);
108
- }
109
- }
110
- if (transform) {
111
- transformStack.pop();
112
- if (transformStack.length > 0) {
113
- currentTransform.copy(transformStack[transformStack.length - 1]);
114
- } else {
115
- currentTransform.identity();
116
- }
117
- }
118
- }
119
- function parsePathNode(node) {
120
- const path = new ShapePath();
121
- const point = new Vector2();
122
- const control = new Vector2();
123
- const firstPoint = new Vector2();
124
- let isFirstPoint = true;
125
- let doSetFirstPoint = false;
126
- const d = node.getAttribute("d");
127
- const commands = d.match(/[a-df-z][^a-df-z]*/gi);
128
- for (let i = 0, l = commands.length; i < l; i++) {
129
- const command = commands[i];
130
- const type = command.charAt(0);
131
- const data2 = command.substr(1).trim();
132
- if (isFirstPoint === true) {
133
- doSetFirstPoint = true;
134
- isFirstPoint = false;
135
- }
136
- let numbers;
137
- switch (type) {
138
- case "M":
139
- numbers = parseFloats(data2);
140
- for (let j = 0, jl = numbers.length; j < jl; j += 2) {
141
- point.x = numbers[j + 0];
142
- point.y = numbers[j + 1];
143
- control.x = point.x;
144
- control.y = point.y;
145
- if (j === 0) {
146
- path.moveTo(point.x, point.y);
147
- } else {
148
- path.lineTo(point.x, point.y);
149
- }
150
- if (j === 0)
151
- firstPoint.copy(point);
152
- }
153
- break;
154
- case "H":
155
- numbers = parseFloats(data2);
156
- for (let j = 0, jl = numbers.length; j < jl; j++) {
157
- point.x = numbers[j];
158
- control.x = point.x;
159
- control.y = point.y;
160
- path.lineTo(point.x, point.y);
161
- if (j === 0 && doSetFirstPoint === true)
162
- firstPoint.copy(point);
163
- }
164
- break;
165
- case "V":
166
- numbers = parseFloats(data2);
167
- for (let j = 0, jl = numbers.length; j < jl; j++) {
168
- point.y = numbers[j];
169
- control.x = point.x;
170
- control.y = point.y;
171
- path.lineTo(point.x, point.y);
172
- if (j === 0 && doSetFirstPoint === true)
173
- firstPoint.copy(point);
174
- }
175
- break;
176
- case "L":
177
- numbers = parseFloats(data2);
178
- for (let j = 0, jl = numbers.length; j < jl; j += 2) {
179
- point.x = numbers[j + 0];
180
- point.y = numbers[j + 1];
181
- control.x = point.x;
182
- control.y = point.y;
183
- path.lineTo(point.x, point.y);
184
- if (j === 0 && doSetFirstPoint === true)
185
- firstPoint.copy(point);
186
- }
187
- break;
188
- case "C":
189
- numbers = parseFloats(data2);
190
- for (let j = 0, jl = numbers.length; j < jl; j += 6) {
191
- path.bezierCurveTo(
192
- numbers[j + 0],
193
- numbers[j + 1],
194
- numbers[j + 2],
195
- numbers[j + 3],
196
- numbers[j + 4],
197
- numbers[j + 5]
198
- );
199
- control.x = numbers[j + 2];
200
- control.y = numbers[j + 3];
201
- point.x = numbers[j + 4];
202
- point.y = numbers[j + 5];
203
- if (j === 0 && doSetFirstPoint === true)
204
- firstPoint.copy(point);
205
- }
206
- break;
207
- case "S":
208
- numbers = parseFloats(data2);
209
- for (let j = 0, jl = numbers.length; j < jl; j += 4) {
210
- path.bezierCurveTo(
211
- getReflection(point.x, control.x),
212
- getReflection(point.y, control.y),
213
- numbers[j + 0],
214
- numbers[j + 1],
215
- numbers[j + 2],
216
- numbers[j + 3]
217
- );
218
- control.x = numbers[j + 0];
219
- control.y = numbers[j + 1];
220
- point.x = numbers[j + 2];
221
- point.y = numbers[j + 3];
222
- if (j === 0 && doSetFirstPoint === true)
223
- firstPoint.copy(point);
224
- }
225
- break;
226
- case "Q":
227
- numbers = parseFloats(data2);
228
- for (let j = 0, jl = numbers.length; j < jl; j += 4) {
229
- path.quadraticCurveTo(numbers[j + 0], numbers[j + 1], numbers[j + 2], numbers[j + 3]);
230
- control.x = numbers[j + 0];
231
- control.y = numbers[j + 1];
232
- point.x = numbers[j + 2];
233
- point.y = numbers[j + 3];
234
- if (j === 0 && doSetFirstPoint === true)
235
- firstPoint.copy(point);
236
- }
237
- break;
238
- case "T":
239
- numbers = parseFloats(data2);
240
- for (let j = 0, jl = numbers.length; j < jl; j += 2) {
241
- const rx = getReflection(point.x, control.x);
242
- const ry = getReflection(point.y, control.y);
243
- path.quadraticCurveTo(rx, ry, numbers[j + 0], numbers[j + 1]);
244
- control.x = rx;
245
- control.y = ry;
246
- point.x = numbers[j + 0];
247
- point.y = numbers[j + 1];
248
- if (j === 0 && doSetFirstPoint === true)
249
- firstPoint.copy(point);
250
- }
251
- break;
252
- case "A":
253
- numbers = parseFloats(data2, [3, 4], 7);
254
- for (let j = 0, jl = numbers.length; j < jl; j += 7) {
255
- if (numbers[j + 5] == point.x && numbers[j + 6] == point.y)
256
- continue;
257
- const start = point.clone();
258
- point.x = numbers[j + 5];
259
- point.y = numbers[j + 6];
260
- control.x = point.x;
261
- control.y = point.y;
262
- parseArcCommand(
263
- path,
264
- numbers[j],
265
- numbers[j + 1],
266
- numbers[j + 2],
267
- numbers[j + 3],
268
- numbers[j + 4],
269
- start,
270
- point
271
- );
272
- if (j === 0 && doSetFirstPoint === true)
273
- firstPoint.copy(point);
274
- }
275
- break;
276
- case "m":
277
- numbers = parseFloats(data2);
278
- for (let j = 0, jl = numbers.length; j < jl; j += 2) {
279
- point.x += numbers[j + 0];
280
- point.y += numbers[j + 1];
281
- control.x = point.x;
282
- control.y = point.y;
283
- if (j === 0) {
284
- path.moveTo(point.x, point.y);
285
- } else {
286
- path.lineTo(point.x, point.y);
287
- }
288
- if (j === 0)
289
- firstPoint.copy(point);
290
- }
291
- break;
292
- case "h":
293
- numbers = parseFloats(data2);
294
- for (let j = 0, jl = numbers.length; j < jl; j++) {
295
- point.x += numbers[j];
296
- control.x = point.x;
297
- control.y = point.y;
298
- path.lineTo(point.x, point.y);
299
- if (j === 0 && doSetFirstPoint === true)
300
- firstPoint.copy(point);
301
- }
302
- break;
303
- case "v":
304
- numbers = parseFloats(data2);
305
- for (let j = 0, jl = numbers.length; j < jl; j++) {
306
- point.y += numbers[j];
307
- control.x = point.x;
308
- control.y = point.y;
309
- path.lineTo(point.x, point.y);
310
- if (j === 0 && doSetFirstPoint === true)
311
- firstPoint.copy(point);
312
- }
313
- break;
314
- case "l":
315
- numbers = parseFloats(data2);
316
- for (let j = 0, jl = numbers.length; j < jl; j += 2) {
317
- point.x += numbers[j + 0];
318
- point.y += numbers[j + 1];
319
- control.x = point.x;
320
- control.y = point.y;
321
- path.lineTo(point.x, point.y);
322
- if (j === 0 && doSetFirstPoint === true)
323
- firstPoint.copy(point);
324
- }
325
- break;
326
- case "c":
327
- numbers = parseFloats(data2);
328
- for (let j = 0, jl = numbers.length; j < jl; j += 6) {
329
- path.bezierCurveTo(
330
- point.x + numbers[j + 0],
331
- point.y + numbers[j + 1],
332
- point.x + numbers[j + 2],
333
- point.y + numbers[j + 3],
334
- point.x + numbers[j + 4],
335
- point.y + numbers[j + 5]
336
- );
337
- control.x = point.x + numbers[j + 2];
338
- control.y = point.y + numbers[j + 3];
339
- point.x += numbers[j + 4];
340
- point.y += numbers[j + 5];
341
- if (j === 0 && doSetFirstPoint === true)
342
- firstPoint.copy(point);
343
- }
344
- break;
345
- case "s":
346
- numbers = parseFloats(data2);
347
- for (let j = 0, jl = numbers.length; j < jl; j += 4) {
348
- path.bezierCurveTo(
349
- getReflection(point.x, control.x),
350
- getReflection(point.y, control.y),
351
- point.x + numbers[j + 0],
352
- point.y + numbers[j + 1],
353
- point.x + numbers[j + 2],
354
- point.y + numbers[j + 3]
355
- );
356
- control.x = point.x + numbers[j + 0];
357
- control.y = point.y + numbers[j + 1];
358
- point.x += numbers[j + 2];
359
- point.y += numbers[j + 3];
360
- if (j === 0 && doSetFirstPoint === true)
361
- firstPoint.copy(point);
362
- }
363
- break;
364
- case "q":
365
- numbers = parseFloats(data2);
366
- for (let j = 0, jl = numbers.length; j < jl; j += 4) {
367
- path.quadraticCurveTo(
368
- point.x + numbers[j + 0],
369
- point.y + numbers[j + 1],
370
- point.x + numbers[j + 2],
371
- point.y + numbers[j + 3]
372
- );
373
- control.x = point.x + numbers[j + 0];
374
- control.y = point.y + numbers[j + 1];
375
- point.x += numbers[j + 2];
376
- point.y += numbers[j + 3];
377
- if (j === 0 && doSetFirstPoint === true)
378
- firstPoint.copy(point);
379
- }
380
- break;
381
- case "t":
382
- numbers = parseFloats(data2);
383
- for (let j = 0, jl = numbers.length; j < jl; j += 2) {
384
- const rx = getReflection(point.x, control.x);
385
- const ry = getReflection(point.y, control.y);
386
- path.quadraticCurveTo(rx, ry, point.x + numbers[j + 0], point.y + numbers[j + 1]);
387
- control.x = rx;
388
- control.y = ry;
389
- point.x = point.x + numbers[j + 0];
390
- point.y = point.y + numbers[j + 1];
391
- if (j === 0 && doSetFirstPoint === true)
392
- firstPoint.copy(point);
393
- }
394
- break;
395
- case "a":
396
- numbers = parseFloats(data2, [3, 4], 7);
397
- for (let j = 0, jl = numbers.length; j < jl; j += 7) {
398
- if (numbers[j + 5] == 0 && numbers[j + 6] == 0)
399
- continue;
400
- const start = point.clone();
401
- point.x += numbers[j + 5];
402
- point.y += numbers[j + 6];
403
- control.x = point.x;
404
- control.y = point.y;
405
- parseArcCommand(
406
- path,
407
- numbers[j],
408
- numbers[j + 1],
409
- numbers[j + 2],
410
- numbers[j + 3],
411
- numbers[j + 4],
412
- start,
413
- point
414
- );
415
- if (j === 0 && doSetFirstPoint === true)
416
- firstPoint.copy(point);
417
- }
418
- break;
419
- case "Z":
420
- case "z":
421
- path.currentPath.autoClose = true;
422
- if (path.currentPath.curves.length > 0) {
423
- point.copy(firstPoint);
424
- path.currentPath.currentPoint.copy(point);
425
- isFirstPoint = true;
426
- }
427
- break;
428
- default:
429
- console.warn(command);
430
- }
431
- doSetFirstPoint = false;
432
- }
433
- return path;
434
- }
435
- function parseCSSStylesheet(node) {
436
- if (!node.sheet || !node.sheet.cssRules || !node.sheet.cssRules.length)
437
- return;
438
- for (let i = 0; i < node.sheet.cssRules.length; i++) {
439
- const stylesheet = node.sheet.cssRules[i];
440
- if (stylesheet.type !== 1)
441
- continue;
442
- const selectorList = stylesheet.selectorText.split(/,/gm).filter(Boolean).map((i2) => i2.trim());
443
- for (let j = 0; j < selectorList.length; j++) {
444
- stylesheets[selectorList[j]] = Object.assign(stylesheets[selectorList[j]] || {}, stylesheet.style);
445
- }
446
- }
447
- }
448
- function parseArcCommand(path, rx, ry, x_axis_rotation, large_arc_flag, sweep_flag, start, end) {
449
- if (rx == 0 || ry == 0) {
450
- path.lineTo(end.x, end.y);
451
- return;
452
- }
453
- x_axis_rotation = x_axis_rotation * Math.PI / 180;
454
- rx = Math.abs(rx);
455
- ry = Math.abs(ry);
456
- const dx2 = (start.x - end.x) / 2;
457
- const dy2 = (start.y - end.y) / 2;
458
- const x1p = Math.cos(x_axis_rotation) * dx2 + Math.sin(x_axis_rotation) * dy2;
459
- const y1p = -Math.sin(x_axis_rotation) * dx2 + Math.cos(x_axis_rotation) * dy2;
460
- let rxs = rx * rx;
461
- let rys = ry * ry;
462
- const x1ps = x1p * x1p;
463
- const y1ps = y1p * y1p;
464
- const cr = x1ps / rxs + y1ps / rys;
465
- if (cr > 1) {
466
- const s = Math.sqrt(cr);
467
- rx = s * rx;
468
- ry = s * ry;
469
- rxs = rx * rx;
470
- rys = ry * ry;
471
- }
472
- const dq = rxs * y1ps + rys * x1ps;
473
- const pq = (rxs * rys - dq) / dq;
474
- let q = Math.sqrt(Math.max(0, pq));
475
- if (large_arc_flag === sweep_flag)
476
- q = -q;
477
- const cxp = q * rx * y1p / ry;
478
- const cyp = -q * ry * x1p / rx;
479
- const cx = Math.cos(x_axis_rotation) * cxp - Math.sin(x_axis_rotation) * cyp + (start.x + end.x) / 2;
480
- const cy = Math.sin(x_axis_rotation) * cxp + Math.cos(x_axis_rotation) * cyp + (start.y + end.y) / 2;
481
- const theta = svgAngle(1, 0, (x1p - cxp) / rx, (y1p - cyp) / ry);
482
- const delta = svgAngle((x1p - cxp) / rx, (y1p - cyp) / ry, (-x1p - cxp) / rx, (-y1p - cyp) / ry) % (Math.PI * 2);
483
- path.currentPath.absellipse(cx, cy, rx, ry, theta, theta + delta, sweep_flag === 0, x_axis_rotation);
484
- }
485
- function svgAngle(ux, uy, vx, vy) {
486
- const dot = ux * vx + uy * vy;
487
- const len = Math.sqrt(ux * ux + uy * uy) * Math.sqrt(vx * vx + vy * vy);
488
- let ang = Math.acos(Math.max(-1, Math.min(1, dot / len)));
489
- if (ux * vy - uy * vx < 0)
490
- ang = -ang;
491
- return ang;
492
- }
493
- function parseRectNode(node) {
494
- const x = parseFloatWithUnits(node.getAttribute("x") || 0);
495
- const y = parseFloatWithUnits(node.getAttribute("y") || 0);
496
- const rx = parseFloatWithUnits(node.getAttribute("rx") || node.getAttribute("ry") || 0);
497
- const ry = parseFloatWithUnits(node.getAttribute("ry") || node.getAttribute("rx") || 0);
498
- const w = parseFloatWithUnits(node.getAttribute("width"));
499
- const h = parseFloatWithUnits(node.getAttribute("height"));
500
- const bci = 1 - 0.551915024494;
501
- const path = new ShapePath();
502
- path.moveTo(x + rx, y);
503
- path.lineTo(x + w - rx, y);
504
- if (rx !== 0 || ry !== 0) {
505
- path.bezierCurveTo(x + w - rx * bci, y, x + w, y + ry * bci, x + w, y + ry);
506
- }
507
- path.lineTo(x + w, y + h - ry);
508
- if (rx !== 0 || ry !== 0) {
509
- path.bezierCurveTo(x + w, y + h - ry * bci, x + w - rx * bci, y + h, x + w - rx, y + h);
510
- }
511
- path.lineTo(x + rx, y + h);
512
- if (rx !== 0 || ry !== 0) {
513
- path.bezierCurveTo(x + rx * bci, y + h, x, y + h - ry * bci, x, y + h - ry);
514
- }
515
- path.lineTo(x, y + ry);
516
- if (rx !== 0 || ry !== 0) {
517
- path.bezierCurveTo(x, y + ry * bci, x + rx * bci, y, x + rx, y);
518
- }
519
- return path;
520
- }
521
- function parsePolygonNode(node) {
522
- function iterator(match, a, b) {
523
- const x = parseFloatWithUnits(a);
524
- const y = parseFloatWithUnits(b);
525
- if (index === 0) {
526
- path.moveTo(x, y);
527
- } else {
528
- path.lineTo(x, y);
529
- }
530
- index++;
531
- }
532
- const regex = /(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g;
533
- const path = new ShapePath();
534
- let index = 0;
535
- node.getAttribute("points").replace(regex, iterator);
536
- path.currentPath.autoClose = true;
537
- return path;
538
- }
539
- function parsePolylineNode(node) {
540
- function iterator(match, a, b) {
541
- const x = parseFloatWithUnits(a);
542
- const y = parseFloatWithUnits(b);
543
- if (index === 0) {
544
- path.moveTo(x, y);
545
- } else {
546
- path.lineTo(x, y);
547
- }
548
- index++;
549
- }
550
- const regex = /(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g;
551
- const path = new ShapePath();
552
- let index = 0;
553
- node.getAttribute("points").replace(regex, iterator);
554
- path.currentPath.autoClose = false;
555
- return path;
556
- }
557
- function parseCircleNode(node) {
558
- const x = parseFloatWithUnits(node.getAttribute("cx") || 0);
559
- const y = parseFloatWithUnits(node.getAttribute("cy") || 0);
560
- const r = parseFloatWithUnits(node.getAttribute("r") || 0);
561
- const subpath = new Path();
562
- subpath.absarc(x, y, r, 0, Math.PI * 2);
563
- const path = new ShapePath();
564
- path.subPaths.push(subpath);
565
- return path;
566
- }
567
- function parseEllipseNode(node) {
568
- const x = parseFloatWithUnits(node.getAttribute("cx") || 0);
569
- const y = parseFloatWithUnits(node.getAttribute("cy") || 0);
570
- const rx = parseFloatWithUnits(node.getAttribute("rx") || 0);
571
- const ry = parseFloatWithUnits(node.getAttribute("ry") || 0);
572
- const subpath = new Path();
573
- subpath.absellipse(x, y, rx, ry, 0, Math.PI * 2);
574
- const path = new ShapePath();
575
- path.subPaths.push(subpath);
576
- return path;
577
- }
578
- function parseLineNode(node) {
579
- const x1 = parseFloatWithUnits(node.getAttribute("x1") || 0);
580
- const y1 = parseFloatWithUnits(node.getAttribute("y1") || 0);
581
- const x2 = parseFloatWithUnits(node.getAttribute("x2") || 0);
582
- const y2 = parseFloatWithUnits(node.getAttribute("y2") || 0);
583
- const path = new ShapePath();
584
- path.moveTo(x1, y1);
585
- path.lineTo(x2, y2);
586
- path.currentPath.autoClose = false;
587
- return path;
588
- }
589
- function parseStyle(node, style) {
590
- style = Object.assign({}, style);
591
- let stylesheetStyles = {};
592
- if (node.hasAttribute("class")) {
593
- const classSelectors = node.getAttribute("class").split(/\s/).filter(Boolean).map((i) => i.trim());
594
- for (let i = 0; i < classSelectors.length; i++) {
595
- stylesheetStyles = Object.assign(stylesheetStyles, stylesheets["." + classSelectors[i]]);
596
- }
597
- }
598
- if (node.hasAttribute("id")) {
599
- stylesheetStyles = Object.assign(stylesheetStyles, stylesheets["#" + node.getAttribute("id")]);
600
- }
601
- function addStyle(svgName, jsName, adjustFunction) {
602
- if (adjustFunction === void 0) {
603
- adjustFunction = function copy(v) {
604
- if (v.startsWith("url"))
605
- console.warn("SVGLoader: url access in attributes is not implemented.");
606
- return v;
607
- };
608
- }
609
- if (node.hasAttribute(svgName))
610
- style[jsName] = adjustFunction(node.getAttribute(svgName));
611
- if (stylesheetStyles[svgName])
612
- style[jsName] = adjustFunction(stylesheetStyles[svgName]);
613
- if (node.style && node.style[svgName] !== "")
614
- style[jsName] = adjustFunction(node.style[svgName]);
615
- }
616
- function clamp(v) {
617
- return Math.max(0, Math.min(1, parseFloatWithUnits(v)));
618
- }
619
- function positive(v) {
620
- return Math.max(0, parseFloatWithUnits(v));
621
- }
622
- addStyle("fill", "fill");
623
- addStyle("fill-opacity", "fillOpacity", clamp);
624
- addStyle("fill-rule", "fillRule");
625
- addStyle("opacity", "opacity", clamp);
626
- addStyle("stroke", "stroke");
627
- addStyle("stroke-opacity", "strokeOpacity", clamp);
628
- addStyle("stroke-width", "strokeWidth", positive);
629
- addStyle("stroke-linejoin", "strokeLineJoin");
630
- addStyle("stroke-linecap", "strokeLineCap");
631
- addStyle("stroke-miterlimit", "strokeMiterLimit", positive);
632
- addStyle("visibility", "visibility");
633
- return style;
634
- }
635
- function getReflection(a, b) {
636
- return a - (b - a);
637
- }
638
- function parseFloats(input, flags, stride) {
639
- if (typeof input !== "string") {
640
- throw new TypeError("Invalid input: " + typeof input);
641
- }
642
- const RE = {
643
- SEPARATOR: /[ \t\r\n\,.\-+]/,
644
- WHITESPACE: /[ \t\r\n]/,
645
- DIGIT: /[\d]/,
646
- SIGN: /[-+]/,
647
- POINT: /\./,
648
- COMMA: /,/,
649
- EXP: /e/i,
650
- FLAGS: /[01]/
651
- };
652
- const SEP = 0;
653
- const INT = 1;
654
- const FLOAT = 2;
655
- const EXP = 3;
656
- let state = SEP;
657
- let seenComma = true;
658
- let number = "", exponent = "";
659
- const result = [];
660
- function throwSyntaxError(current2, i, partial) {
661
- const error = new SyntaxError('Unexpected character "' + current2 + '" at index ' + i + ".");
662
- error.partial = partial;
663
- throw error;
664
- }
665
- function newNumber() {
666
- if (number !== "") {
667
- if (exponent === "")
668
- result.push(Number(number));
669
- else
670
- result.push(Number(number) * Math.pow(10, Number(exponent)));
671
- }
672
- number = "";
673
- exponent = "";
674
- }
675
- let current;
676
- const length = input.length;
677
- for (let i = 0; i < length; i++) {
678
- current = input[i];
679
- if (Array.isArray(flags) && flags.includes(result.length % stride) && RE.FLAGS.test(current)) {
680
- state = INT;
681
- number = current;
682
- newNumber();
683
- continue;
684
- }
685
- if (state === SEP) {
686
- if (RE.WHITESPACE.test(current)) {
687
- continue;
688
- }
689
- if (RE.DIGIT.test(current) || RE.SIGN.test(current)) {
690
- state = INT;
691
- number = current;
692
- continue;
693
- }
694
- if (RE.POINT.test(current)) {
695
- state = FLOAT;
696
- number = current;
697
- continue;
698
- }
699
- if (RE.COMMA.test(current)) {
700
- if (seenComma) {
701
- throwSyntaxError(current, i, result);
702
- }
703
- seenComma = true;
704
- }
705
- }
706
- if (state === INT) {
707
- if (RE.DIGIT.test(current)) {
708
- number += current;
709
- continue;
710
- }
711
- if (RE.POINT.test(current)) {
712
- number += current;
713
- state = FLOAT;
714
- continue;
715
- }
716
- if (RE.EXP.test(current)) {
717
- state = EXP;
718
- continue;
719
- }
720
- if (RE.SIGN.test(current) && number.length === 1 && RE.SIGN.test(number[0])) {
721
- throwSyntaxError(current, i, result);
722
- }
723
- }
724
- if (state === FLOAT) {
725
- if (RE.DIGIT.test(current)) {
726
- number += current;
727
- continue;
728
- }
729
- if (RE.EXP.test(current)) {
730
- state = EXP;
731
- continue;
732
- }
733
- if (RE.POINT.test(current) && number[number.length - 1] === ".") {
734
- throwSyntaxError(current, i, result);
735
- }
736
- }
737
- if (state === EXP) {
738
- if (RE.DIGIT.test(current)) {
739
- exponent += current;
740
- continue;
741
- }
742
- if (RE.SIGN.test(current)) {
743
- if (exponent === "") {
744
- exponent += current;
745
- continue;
746
- }
747
- if (exponent.length === 1 && RE.SIGN.test(exponent)) {
748
- throwSyntaxError(current, i, result);
749
- }
750
- }
751
- }
752
- if (RE.WHITESPACE.test(current)) {
753
- newNumber();
754
- state = SEP;
755
- seenComma = false;
756
- } else if (RE.COMMA.test(current)) {
757
- newNumber();
758
- state = SEP;
759
- seenComma = true;
760
- } else if (RE.SIGN.test(current)) {
761
- newNumber();
762
- state = INT;
763
- number = current;
764
- } else if (RE.POINT.test(current)) {
765
- newNumber();
766
- state = FLOAT;
767
- number = current;
768
- } else {
769
- throwSyntaxError(current, i, result);
770
- }
771
- }
772
- newNumber();
773
- return result;
774
- }
775
- const units = ["mm", "cm", "in", "pt", "pc", "px"];
776
- const unitConversion = {
777
- mm: {
778
- mm: 1,
779
- cm: 0.1,
780
- in: 1 / 25.4,
781
- pt: 72 / 25.4,
782
- pc: 6 / 25.4,
783
- px: -1
784
- },
785
- cm: {
786
- mm: 10,
787
- cm: 1,
788
- in: 1 / 2.54,
789
- pt: 72 / 2.54,
790
- pc: 6 / 2.54,
791
- px: -1
792
- },
793
- in: {
794
- mm: 25.4,
795
- cm: 2.54,
796
- in: 1,
797
- pt: 72,
798
- pc: 6,
799
- px: -1
800
- },
801
- pt: {
802
- mm: 25.4 / 72,
803
- cm: 2.54 / 72,
804
- in: 1 / 72,
805
- pt: 1,
806
- pc: 6 / 72,
807
- px: -1
808
- },
809
- pc: {
810
- mm: 25.4 / 6,
811
- cm: 2.54 / 6,
812
- in: 1 / 6,
813
- pt: 72 / 6,
814
- pc: 1,
815
- px: -1
816
- },
817
- px: {
818
- px: 1
819
- }
820
- };
821
- function parseFloatWithUnits(string) {
822
- let theUnit = "px";
823
- if (typeof string === "string" || string instanceof String) {
824
- for (let i = 0, n = units.length; i < n; i++) {
825
- const u = units[i];
826
- if (string.endsWith(u)) {
827
- theUnit = u;
828
- string = string.substring(0, string.length - u.length);
829
- break;
830
- }
831
- }
832
- }
833
- let scale = void 0;
834
- if (theUnit === "px" && scope.defaultUnit !== "px") {
835
- scale = unitConversion["in"][scope.defaultUnit] / scope.defaultDPI;
836
- } else {
837
- scale = unitConversion[theUnit][scope.defaultUnit];
838
- if (scale < 0) {
839
- scale = unitConversion[theUnit]["in"] * scope.defaultDPI;
840
- }
841
- }
842
- return scale * parseFloat(string);
843
- }
844
- function getNodeTransform(node) {
845
- if (!(node.hasAttribute("transform") || node.nodeName === "use" && (node.hasAttribute("x") || node.hasAttribute("y")))) {
846
- return null;
847
- }
848
- const transform = parseNodeTransform(node);
849
- if (transformStack.length > 0) {
850
- transform.premultiply(transformStack[transformStack.length - 1]);
851
- }
852
- currentTransform.copy(transform);
853
- transformStack.push(transform);
854
- return transform;
855
- }
856
- function parseNodeTransform(node) {
857
- const transform = new Matrix3();
858
- const currentTransform2 = tempTransform0;
859
- if (node.nodeName === "use" && (node.hasAttribute("x") || node.hasAttribute("y"))) {
860
- const tx = parseFloatWithUnits(node.getAttribute("x"));
861
- const ty = parseFloatWithUnits(node.getAttribute("y"));
862
- transform.translate(tx, ty);
863
- }
864
- if (node.hasAttribute("transform")) {
865
- const transformsTexts = node.getAttribute("transform").split(")");
866
- for (let tIndex = transformsTexts.length - 1; tIndex >= 0; tIndex--) {
867
- const transformText = transformsTexts[tIndex].trim();
868
- if (transformText === "")
869
- continue;
870
- const openParPos = transformText.indexOf("(");
871
- const closeParPos = transformText.length;
872
- if (openParPos > 0 && openParPos < closeParPos) {
873
- const transformType = transformText.substr(0, openParPos);
874
- const array = parseFloats(transformText.substr(openParPos + 1, closeParPos - openParPos - 1));
875
- currentTransform2.identity();
876
- switch (transformType) {
877
- case "translate":
878
- if (array.length >= 1) {
879
- const tx = array[0];
880
- let ty = tx;
881
- if (array.length >= 2) {
882
- ty = array[1];
883
- }
884
- currentTransform2.translate(tx, ty);
885
- }
886
- break;
887
- case "rotate":
888
- if (array.length >= 1) {
889
- let angle = 0;
890
- let cx = 0;
891
- let cy = 0;
892
- angle = -array[0] * Math.PI / 180;
893
- if (array.length >= 3) {
894
- cx = array[1];
895
- cy = array[2];
896
- }
897
- tempTransform1.identity().translate(-cx, -cy);
898
- tempTransform2.identity().rotate(angle);
899
- tempTransform3.multiplyMatrices(tempTransform2, tempTransform1);
900
- tempTransform1.identity().translate(cx, cy);
901
- currentTransform2.multiplyMatrices(tempTransform1, tempTransform3);
902
- }
903
- break;
904
- case "scale":
905
- if (array.length >= 1) {
906
- const scaleX = array[0];
907
- let scaleY = scaleX;
908
- if (array.length >= 2) {
909
- scaleY = array[1];
910
- }
911
- currentTransform2.scale(scaleX, scaleY);
912
- }
913
- break;
914
- case "skewX":
915
- if (array.length === 1) {
916
- currentTransform2.set(1, Math.tan(array[0] * Math.PI / 180), 0, 0, 1, 0, 0, 0, 1);
917
- }
918
- break;
919
- case "skewY":
920
- if (array.length === 1) {
921
- currentTransform2.set(1, 0, 0, Math.tan(array[0] * Math.PI / 180), 1, 0, 0, 0, 1);
922
- }
923
- break;
924
- case "matrix":
925
- if (array.length === 6) {
926
- currentTransform2.set(array[0], array[2], array[4], array[1], array[3], array[5], 0, 0, 1);
927
- }
928
- break;
929
- }
930
- }
931
- transform.premultiply(currentTransform2);
932
- }
933
- }
934
- return transform;
935
- }
936
- function transformPath(path, m) {
937
- function transfVec2(v2) {
938
- tempV3.set(v2.x, v2.y, 1).applyMatrix3(m);
939
- v2.set(tempV3.x, tempV3.y);
940
- }
941
- const isRotated = isTransformRotated(m);
942
- const subPaths = path.subPaths;
943
- for (let i = 0, n = subPaths.length; i < n; i++) {
944
- const subPath = subPaths[i];
945
- const curves = subPath.curves;
946
- for (let j = 0; j < curves.length; j++) {
947
- const curve = curves[j];
948
- if (curve.isLineCurve) {
949
- transfVec2(curve.v1);
950
- transfVec2(curve.v2);
951
- } else if (curve.isCubicBezierCurve) {
952
- transfVec2(curve.v0);
953
- transfVec2(curve.v1);
954
- transfVec2(curve.v2);
955
- transfVec2(curve.v3);
956
- } else if (curve.isQuadraticBezierCurve) {
957
- transfVec2(curve.v0);
958
- transfVec2(curve.v1);
959
- transfVec2(curve.v2);
960
- } else if (curve.isEllipseCurve) {
961
- if (isRotated) {
962
- console.warn("SVGLoader: Elliptic arc or ellipse rotation or skewing is not implemented.");
963
- }
964
- tempV2.set(curve.aX, curve.aY);
965
- transfVec2(tempV2);
966
- curve.aX = tempV2.x;
967
- curve.aY = tempV2.y;
968
- curve.xRadius *= getTransformScaleX(m);
969
- curve.yRadius *= getTransformScaleY(m);
970
- }
971
- }
972
- }
973
- }
974
- function isTransformRotated(m) {
975
- return m.elements[1] !== 0 || m.elements[3] !== 0;
976
- }
977
- function getTransformScaleX(m) {
978
- const te = m.elements;
979
- return Math.sqrt(te[0] * te[0] + te[1] * te[1]);
980
- }
981
- function getTransformScaleY(m) {
982
- const te = m.elements;
983
- return Math.sqrt(te[3] * te[3] + te[4] * te[4]);
984
- }
985
- const paths = [];
986
- const stylesheets = {};
987
- const transformStack = [];
988
- const tempTransform0 = new Matrix3();
989
- const tempTransform1 = new Matrix3();
990
- const tempTransform2 = new Matrix3();
991
- const tempTransform3 = new Matrix3();
992
- const tempV2 = new Vector2();
993
- const tempV3 = new Vector3();
994
- const currentTransform = new Matrix3();
995
- const xml = new DOMParser().parseFromString(text, "image/svg+xml");
996
- parseNode(xml.documentElement, {
997
- fill: "#000",
998
- fillOpacity: 1,
999
- strokeOpacity: 1,
1000
- strokeWidth: 1,
1001
- strokeLineJoin: "miter",
1002
- strokeLineCap: "butt",
1003
- strokeMiterLimit: 4
1004
- });
1005
- const data = { paths, xml: xml.documentElement };
1006
- return data;
1007
- }
1008
- static createShapes(shapePath) {
1009
- const BIGNUMBER = 999999999;
1010
- const IntersectionLocationType = {
1011
- ORIGIN: 0,
1012
- DESTINATION: 1,
1013
- BETWEEN: 2,
1014
- LEFT: 3,
1015
- RIGHT: 4,
1016
- BEHIND: 5,
1017
- BEYOND: 6
1018
- };
1019
- const classifyResult = {
1020
- loc: IntersectionLocationType.ORIGIN,
1021
- t: 0
1022
- };
1023
- function findEdgeIntersection(a0, a1, b0, b1) {
1024
- const x1 = a0.x;
1025
- const x2 = a1.x;
1026
- const x3 = b0.x;
1027
- const x4 = b1.x;
1028
- const y1 = a0.y;
1029
- const y2 = a1.y;
1030
- const y3 = b0.y;
1031
- const y4 = b1.y;
1032
- const nom1 = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
1033
- const nom2 = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
1034
- const denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
1035
- const t1 = nom1 / denom;
1036
- const t2 = nom2 / denom;
1037
- if (denom === 0 && nom1 !== 0 || t1 <= 0 || t1 >= 1 || t2 < 0 || t2 > 1) {
1038
- return null;
1039
- } else if (nom1 === 0 && denom === 0) {
1040
- for (let i = 0; i < 2; i++) {
1041
- classifyPoint(i === 0 ? b0 : b1, a0, a1);
1042
- if (classifyResult.loc == IntersectionLocationType.ORIGIN) {
1043
- const point = i === 0 ? b0 : b1;
1044
- return { x: point.x, y: point.y, t: classifyResult.t };
1045
- } else if (classifyResult.loc == IntersectionLocationType.BETWEEN) {
1046
- const x = +(x1 + classifyResult.t * (x2 - x1)).toPrecision(10);
1047
- const y = +(y1 + classifyResult.t * (y2 - y1)).toPrecision(10);
1048
- return { x, y, t: classifyResult.t };
1049
- }
1050
- }
1051
- return null;
1052
- } else {
1053
- for (let i = 0; i < 2; i++) {
1054
- classifyPoint(i === 0 ? b0 : b1, a0, a1);
1055
- if (classifyResult.loc == IntersectionLocationType.ORIGIN) {
1056
- const point = i === 0 ? b0 : b1;
1057
- return { x: point.x, y: point.y, t: classifyResult.t };
1058
- }
1059
- }
1060
- const x = +(x1 + t1 * (x2 - x1)).toPrecision(10);
1061
- const y = +(y1 + t1 * (y2 - y1)).toPrecision(10);
1062
- return { x, y, t: t1 };
1063
- }
1064
- }
1065
- function classifyPoint(p, edgeStart, edgeEnd) {
1066
- const ax = edgeEnd.x - edgeStart.x;
1067
- const ay = edgeEnd.y - edgeStart.y;
1068
- const bx = p.x - edgeStart.x;
1069
- const by = p.y - edgeStart.y;
1070
- const sa = ax * by - bx * ay;
1071
- if (p.x === edgeStart.x && p.y === edgeStart.y) {
1072
- classifyResult.loc = IntersectionLocationType.ORIGIN;
1073
- classifyResult.t = 0;
1074
- return;
1075
- }
1076
- if (p.x === edgeEnd.x && p.y === edgeEnd.y) {
1077
- classifyResult.loc = IntersectionLocationType.DESTINATION;
1078
- classifyResult.t = 1;
1079
- return;
1080
- }
1081
- if (sa < -Number.EPSILON) {
1082
- classifyResult.loc = IntersectionLocationType.LEFT;
1083
- return;
1084
- }
1085
- if (sa > Number.EPSILON) {
1086
- classifyResult.loc = IntersectionLocationType.RIGHT;
1087
- return;
1088
- }
1089
- if (ax * bx < 0 || ay * by < 0) {
1090
- classifyResult.loc = IntersectionLocationType.BEHIND;
1091
- return;
1092
- }
1093
- if (Math.sqrt(ax * ax + ay * ay) < Math.sqrt(bx * bx + by * by)) {
1094
- classifyResult.loc = IntersectionLocationType.BEYOND;
1095
- return;
1096
- }
1097
- let t;
1098
- if (ax !== 0) {
1099
- t = bx / ax;
1100
- } else {
1101
- t = by / ay;
1102
- }
1103
- classifyResult.loc = IntersectionLocationType.BETWEEN;
1104
- classifyResult.t = t;
1105
- }
1106
- function getIntersections(path1, path2) {
1107
- const intersectionsRaw = [];
1108
- const intersections = [];
1109
- for (let index = 1; index < path1.length; index++) {
1110
- const path1EdgeStart = path1[index - 1];
1111
- const path1EdgeEnd = path1[index];
1112
- for (let index2 = 1; index2 < path2.length; index2++) {
1113
- const path2EdgeStart = path2[index2 - 1];
1114
- const path2EdgeEnd = path2[index2];
1115
- const intersection = findEdgeIntersection(path1EdgeStart, path1EdgeEnd, path2EdgeStart, path2EdgeEnd);
1116
- if (intersection !== null && intersectionsRaw.find(
1117
- (i) => i.t <= intersection.t + Number.EPSILON && i.t >= intersection.t - Number.EPSILON
1118
- ) === void 0) {
1119
- intersectionsRaw.push(intersection);
1120
- intersections.push(new Vector2(intersection.x, intersection.y));
1121
- }
1122
- }
1123
- }
1124
- return intersections;
1125
- }
1126
- function getScanlineIntersections(scanline, boundingBox, paths) {
1127
- const center = new Vector2();
1128
- boundingBox.getCenter(center);
1129
- const allIntersections = [];
1130
- paths.forEach((path) => {
1131
- if (path.boundingBox.containsPoint(center)) {
1132
- const intersections = getIntersections(scanline, path.points);
1133
- intersections.forEach((p) => {
1134
- allIntersections.push({ identifier: path.identifier, isCW: path.isCW, point: p });
1135
- });
1136
- }
1137
- });
1138
- allIntersections.sort((i1, i2) => {
1139
- return i1.point.x - i2.point.x;
1140
- });
1141
- return allIntersections;
1142
- }
1143
- function isHoleTo(simplePath, allPaths, scanlineMinX2, scanlineMaxX2, _fillRule) {
1144
- if (_fillRule === null || _fillRule === void 0 || _fillRule === "") {
1145
- _fillRule = "nonzero";
1146
- }
1147
- const centerBoundingBox = new Vector2();
1148
- simplePath.boundingBox.getCenter(centerBoundingBox);
1149
- const scanline = [new Vector2(scanlineMinX2, centerBoundingBox.y), new Vector2(scanlineMaxX2, centerBoundingBox.y)];
1150
- const scanlineIntersections = getScanlineIntersections(scanline, simplePath.boundingBox, allPaths);
1151
- scanlineIntersections.sort((i1, i2) => {
1152
- return i1.point.x - i2.point.x;
1153
- });
1154
- const baseIntersections = [];
1155
- const otherIntersections = [];
1156
- scanlineIntersections.forEach((i2) => {
1157
- if (i2.identifier === simplePath.identifier) {
1158
- baseIntersections.push(i2);
1159
- } else {
1160
- otherIntersections.push(i2);
1161
- }
1162
- });
1163
- const firstXOfPath = baseIntersections[0].point.x;
1164
- const stack = [];
1165
- let i = 0;
1166
- while (i < otherIntersections.length && otherIntersections[i].point.x < firstXOfPath) {
1167
- if (stack.length > 0 && stack[stack.length - 1] === otherIntersections[i].identifier) {
1168
- stack.pop();
1169
- } else {
1170
- stack.push(otherIntersections[i].identifier);
1171
- }
1172
- i++;
1173
- }
1174
- stack.push(simplePath.identifier);
1175
- if (_fillRule === "evenodd") {
1176
- const isHole = stack.length % 2 === 0 ? true : false;
1177
- const isHoleFor = stack[stack.length - 2];
1178
- return { identifier: simplePath.identifier, isHole, for: isHoleFor };
1179
- } else if (_fillRule === "nonzero") {
1180
- let isHole = true;
1181
- let isHoleFor = null;
1182
- let lastCWValue = null;
1183
- for (let i2 = 0; i2 < stack.length; i2++) {
1184
- const identifier2 = stack[i2];
1185
- if (isHole) {
1186
- lastCWValue = allPaths[identifier2].isCW;
1187
- isHole = false;
1188
- isHoleFor = identifier2;
1189
- } else if (lastCWValue !== allPaths[identifier2].isCW) {
1190
- lastCWValue = allPaths[identifier2].isCW;
1191
- isHole = true;
1192
- }
1193
- }
1194
- return { identifier: simplePath.identifier, isHole, for: isHoleFor };
1195
- } else {
1196
- console.warn('fill-rule: "' + _fillRule + '" is currently not implemented.');
1197
- }
1198
- }
1199
- let identifier = 0;
1200
- let scanlineMinX = BIGNUMBER;
1201
- let scanlineMaxX = -BIGNUMBER;
1202
- let simplePaths = shapePath.subPaths.map((p) => {
1203
- const points = p.getPoints();
1204
- let maxY = -BIGNUMBER;
1205
- let minY = BIGNUMBER;
1206
- let maxX = -BIGNUMBER;
1207
- let minX = BIGNUMBER;
1208
- for (let i = 0; i < points.length; i++) {
1209
- const p2 = points[i];
1210
- if (p2.y > maxY) {
1211
- maxY = p2.y;
1212
- }
1213
- if (p2.y < minY) {
1214
- minY = p2.y;
1215
- }
1216
- if (p2.x > maxX) {
1217
- maxX = p2.x;
1218
- }
1219
- if (p2.x < minX) {
1220
- minX = p2.x;
1221
- }
1222
- }
1223
- if (scanlineMaxX <= maxX) {
1224
- scanlineMaxX = maxX + 1;
1225
- }
1226
- if (scanlineMinX >= minX) {
1227
- scanlineMinX = minX - 1;
1228
- }
1229
- return {
1230
- curves: p.curves,
1231
- points,
1232
- isCW: ShapeUtils.isClockWise(points),
1233
- identifier: identifier++,
1234
- boundingBox: new Box2(new Vector2(minX, minY), new Vector2(maxX, maxY))
1235
- };
1236
- });
1237
- simplePaths = simplePaths.filter((sp) => sp.points.length > 1);
1238
- const isAHole = simplePaths.map(
1239
- (p) => isHoleTo(p, simplePaths, scanlineMinX, scanlineMaxX, shapePath.userData.style.fillRule)
1240
- );
1241
- const shapesToReturn = [];
1242
- simplePaths.forEach((p) => {
1243
- const amIAHole = isAHole[p.identifier];
1244
- if (!amIAHole.isHole) {
1245
- const shape = new Shape();
1246
- shape.curves = p.curves;
1247
- const holes = isAHole.filter((h) => h.isHole && h.for === p.identifier);
1248
- holes.forEach((h) => {
1249
- const hole = simplePaths[h.identifier];
1250
- const path = new Path();
1251
- path.curves = hole.curves;
1252
- shape.holes.push(path);
1253
- });
1254
- shapesToReturn.push(shape);
1255
- }
1256
- });
1257
- return shapesToReturn;
1258
- }
1259
- static getStrokeStyle(width, color, lineJoin, lineCap, miterLimit) {
1260
- width = width !== void 0 ? width : 1;
1261
- color = color !== void 0 ? color : "#000";
1262
- lineJoin = lineJoin !== void 0 ? lineJoin : "miter";
1263
- lineCap = lineCap !== void 0 ? lineCap : "butt";
1264
- miterLimit = miterLimit !== void 0 ? miterLimit : 4;
1265
- return {
1266
- strokeColor: color,
1267
- strokeWidth: width,
1268
- strokeLineJoin: lineJoin,
1269
- strokeLineCap: lineCap,
1270
- strokeMiterLimit: miterLimit
1271
- };
1272
- }
1273
- static pointsToStroke(points, style, arcDivisions, minDistance) {
1274
- const vertices = [];
1275
- const normals = [];
1276
- const uvs = [];
1277
- if (SVGLoader.pointsToStrokeWithBuffers(points, style, arcDivisions, minDistance, vertices, normals, uvs) === 0) {
1278
- return null;
1279
- }
1280
- const geometry = new BufferGeometry();
1281
- geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
1282
- geometry.setAttribute("normal", new Float32BufferAttribute(normals, 3));
1283
- geometry.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
1284
- return geometry;
1285
- }
1286
- static pointsToStrokeWithBuffers(points, style, arcDivisions, minDistance, vertices, normals, uvs, vertexOffset) {
1287
- const tempV2_1 = new Vector2();
1288
- const tempV2_2 = new Vector2();
1289
- const tempV2_3 = new Vector2();
1290
- const tempV2_4 = new Vector2();
1291
- const tempV2_5 = new Vector2();
1292
- const tempV2_6 = new Vector2();
1293
- const tempV2_7 = new Vector2();
1294
- const lastPointL = new Vector2();
1295
- const lastPointR = new Vector2();
1296
- const point0L = new Vector2();
1297
- const point0R = new Vector2();
1298
- const currentPointL = new Vector2();
1299
- const currentPointR = new Vector2();
1300
- const nextPointL = new Vector2();
1301
- const nextPointR = new Vector2();
1302
- const innerPoint = new Vector2();
1303
- const outerPoint = new Vector2();
1304
- arcDivisions = arcDivisions !== void 0 ? arcDivisions : 12;
1305
- minDistance = minDistance !== void 0 ? minDistance : 1e-3;
1306
- vertexOffset = vertexOffset !== void 0 ? vertexOffset : 0;
1307
- points = removeDuplicatedPoints(points);
1308
- const numPoints = points.length;
1309
- if (numPoints < 2)
1310
- return 0;
1311
- const isClosed = points[0].equals(points[numPoints - 1]);
1312
- let currentPoint;
1313
- let previousPoint = points[0];
1314
- let nextPoint;
1315
- const strokeWidth2 = style.strokeWidth / 2;
1316
- const deltaU = 1 / (numPoints - 1);
1317
- let u0 = 0, u1;
1318
- let innerSideModified;
1319
- let joinIsOnLeftSide;
1320
- let isMiter;
1321
- let initialJoinIsOnLeftSide = false;
1322
- let numVertices = 0;
1323
- let currentCoordinate = vertexOffset * 3;
1324
- let currentCoordinateUV = vertexOffset * 2;
1325
- getNormal(points[0], points[1], tempV2_1).multiplyScalar(strokeWidth2);
1326
- lastPointL.copy(points[0]).sub(tempV2_1);
1327
- lastPointR.copy(points[0]).add(tempV2_1);
1328
- point0L.copy(lastPointL);
1329
- point0R.copy(lastPointR);
1330
- for (let iPoint = 1; iPoint < numPoints; iPoint++) {
1331
- currentPoint = points[iPoint];
1332
- if (iPoint === numPoints - 1) {
1333
- if (isClosed) {
1334
- nextPoint = points[1];
1335
- } else {
1336
- nextPoint = void 0;
1337
- }
1338
- } else {
1339
- nextPoint = points[iPoint + 1];
1340
- }
1341
- const normal1 = tempV2_1;
1342
- getNormal(previousPoint, currentPoint, normal1);
1343
- tempV2_3.copy(normal1).multiplyScalar(strokeWidth2);
1344
- currentPointL.copy(currentPoint).sub(tempV2_3);
1345
- currentPointR.copy(currentPoint).add(tempV2_3);
1346
- u1 = u0 + deltaU;
1347
- innerSideModified = false;
1348
- if (nextPoint !== void 0) {
1349
- getNormal(currentPoint, nextPoint, tempV2_2);
1350
- tempV2_3.copy(tempV2_2).multiplyScalar(strokeWidth2);
1351
- nextPointL.copy(currentPoint).sub(tempV2_3);
1352
- nextPointR.copy(currentPoint).add(tempV2_3);
1353
- joinIsOnLeftSide = true;
1354
- tempV2_3.subVectors(nextPoint, previousPoint);
1355
- if (normal1.dot(tempV2_3) < 0) {
1356
- joinIsOnLeftSide = false;
1357
- }
1358
- if (iPoint === 1)
1359
- initialJoinIsOnLeftSide = joinIsOnLeftSide;
1360
- tempV2_3.subVectors(nextPoint, currentPoint);
1361
- tempV2_3.normalize();
1362
- const dot = Math.abs(normal1.dot(tempV2_3));
1363
- if (dot !== 0) {
1364
- const miterSide = strokeWidth2 / dot;
1365
- tempV2_3.multiplyScalar(-miterSide);
1366
- tempV2_4.subVectors(currentPoint, previousPoint);
1367
- tempV2_5.copy(tempV2_4).setLength(miterSide).add(tempV2_3);
1368
- innerPoint.copy(tempV2_5).negate();
1369
- const miterLength2 = tempV2_5.length();
1370
- const segmentLengthPrev = tempV2_4.length();
1371
- tempV2_4.divideScalar(segmentLengthPrev);
1372
- tempV2_6.subVectors(nextPoint, currentPoint);
1373
- const segmentLengthNext = tempV2_6.length();
1374
- tempV2_6.divideScalar(segmentLengthNext);
1375
- if (tempV2_4.dot(innerPoint) < segmentLengthPrev && tempV2_6.dot(innerPoint) < segmentLengthNext) {
1376
- innerSideModified = true;
1377
- }
1378
- outerPoint.copy(tempV2_5).add(currentPoint);
1379
- innerPoint.add(currentPoint);
1380
- isMiter = false;
1381
- if (innerSideModified) {
1382
- if (joinIsOnLeftSide) {
1383
- nextPointR.copy(innerPoint);
1384
- currentPointR.copy(innerPoint);
1385
- } else {
1386
- nextPointL.copy(innerPoint);
1387
- currentPointL.copy(innerPoint);
1388
- }
1389
- } else {
1390
- makeSegmentTriangles();
1391
- }
1392
- switch (style.strokeLineJoin) {
1393
- case "bevel":
1394
- makeSegmentWithBevelJoin(joinIsOnLeftSide, innerSideModified, u1);
1395
- break;
1396
- case "round":
1397
- createSegmentTrianglesWithMiddleSection(joinIsOnLeftSide, innerSideModified);
1398
- if (joinIsOnLeftSide) {
1399
- makeCircularSector(currentPoint, currentPointL, nextPointL, u1, 0);
1400
- } else {
1401
- makeCircularSector(currentPoint, nextPointR, currentPointR, u1, 1);
1402
- }
1403
- break;
1404
- case "miter":
1405
- case "miter-clip":
1406
- default:
1407
- const miterFraction = strokeWidth2 * style.strokeMiterLimit / miterLength2;
1408
- if (miterFraction < 1) {
1409
- if (style.strokeLineJoin !== "miter-clip") {
1410
- makeSegmentWithBevelJoin(joinIsOnLeftSide, innerSideModified, u1);
1411
- break;
1412
- } else {
1413
- createSegmentTrianglesWithMiddleSection(joinIsOnLeftSide, innerSideModified);
1414
- if (joinIsOnLeftSide) {
1415
- tempV2_6.subVectors(outerPoint, currentPointL).multiplyScalar(miterFraction).add(currentPointL);
1416
- tempV2_7.subVectors(outerPoint, nextPointL).multiplyScalar(miterFraction).add(nextPointL);
1417
- addVertex(currentPointL, u1, 0);
1418
- addVertex(tempV2_6, u1, 0);
1419
- addVertex(currentPoint, u1, 0.5);
1420
- addVertex(currentPoint, u1, 0.5);
1421
- addVertex(tempV2_6, u1, 0);
1422
- addVertex(tempV2_7, u1, 0);
1423
- addVertex(currentPoint, u1, 0.5);
1424
- addVertex(tempV2_7, u1, 0);
1425
- addVertex(nextPointL, u1, 0);
1426
- } else {
1427
- tempV2_6.subVectors(outerPoint, currentPointR).multiplyScalar(miterFraction).add(currentPointR);
1428
- tempV2_7.subVectors(outerPoint, nextPointR).multiplyScalar(miterFraction).add(nextPointR);
1429
- addVertex(currentPointR, u1, 1);
1430
- addVertex(tempV2_6, u1, 1);
1431
- addVertex(currentPoint, u1, 0.5);
1432
- addVertex(currentPoint, u1, 0.5);
1433
- addVertex(tempV2_6, u1, 1);
1434
- addVertex(tempV2_7, u1, 1);
1435
- addVertex(currentPoint, u1, 0.5);
1436
- addVertex(tempV2_7, u1, 1);
1437
- addVertex(nextPointR, u1, 1);
1438
- }
1439
- }
1440
- } else {
1441
- if (innerSideModified) {
1442
- if (joinIsOnLeftSide) {
1443
- addVertex(lastPointR, u0, 1);
1444
- addVertex(lastPointL, u0, 0);
1445
- addVertex(outerPoint, u1, 0);
1446
- addVertex(lastPointR, u0, 1);
1447
- addVertex(outerPoint, u1, 0);
1448
- addVertex(innerPoint, u1, 1);
1449
- } else {
1450
- addVertex(lastPointR, u0, 1);
1451
- addVertex(lastPointL, u0, 0);
1452
- addVertex(outerPoint, u1, 1);
1453
- addVertex(lastPointL, u0, 0);
1454
- addVertex(innerPoint, u1, 0);
1455
- addVertex(outerPoint, u1, 1);
1456
- }
1457
- if (joinIsOnLeftSide) {
1458
- nextPointL.copy(outerPoint);
1459
- } else {
1460
- nextPointR.copy(outerPoint);
1461
- }
1462
- } else {
1463
- if (joinIsOnLeftSide) {
1464
- addVertex(currentPointL, u1, 0);
1465
- addVertex(outerPoint, u1, 0);
1466
- addVertex(currentPoint, u1, 0.5);
1467
- addVertex(currentPoint, u1, 0.5);
1468
- addVertex(outerPoint, u1, 0);
1469
- addVertex(nextPointL, u1, 0);
1470
- } else {
1471
- addVertex(currentPointR, u1, 1);
1472
- addVertex(outerPoint, u1, 1);
1473
- addVertex(currentPoint, u1, 0.5);
1474
- addVertex(currentPoint, u1, 0.5);
1475
- addVertex(outerPoint, u1, 1);
1476
- addVertex(nextPointR, u1, 1);
1477
- }
1478
- }
1479
- isMiter = true;
1480
- }
1481
- break;
1482
- }
1483
- } else {
1484
- makeSegmentTriangles();
1485
- }
1486
- } else {
1487
- makeSegmentTriangles();
1488
- }
1489
- if (!isClosed && iPoint === numPoints - 1) {
1490
- addCapGeometry(points[0], point0L, point0R, joinIsOnLeftSide, true, u0);
1491
- }
1492
- u0 = u1;
1493
- previousPoint = currentPoint;
1494
- lastPointL.copy(nextPointL);
1495
- lastPointR.copy(nextPointR);
1496
- }
1497
- if (!isClosed) {
1498
- addCapGeometry(currentPoint, currentPointL, currentPointR, joinIsOnLeftSide, false, u1);
1499
- } else if (innerSideModified && vertices) {
1500
- let lastOuter = outerPoint;
1501
- let lastInner = innerPoint;
1502
- if (initialJoinIsOnLeftSide !== joinIsOnLeftSide) {
1503
- lastOuter = innerPoint;
1504
- lastInner = outerPoint;
1505
- }
1506
- if (joinIsOnLeftSide) {
1507
- if (isMiter || initialJoinIsOnLeftSide) {
1508
- lastInner.toArray(vertices, 0 * 3);
1509
- lastInner.toArray(vertices, 3 * 3);
1510
- if (isMiter) {
1511
- lastOuter.toArray(vertices, 1 * 3);
1512
- }
1513
- }
1514
- } else {
1515
- if (isMiter || !initialJoinIsOnLeftSide) {
1516
- lastInner.toArray(vertices, 1 * 3);
1517
- lastInner.toArray(vertices, 3 * 3);
1518
- if (isMiter) {
1519
- lastOuter.toArray(vertices, 0 * 3);
1520
- }
1521
- }
1522
- }
1523
- }
1524
- return numVertices;
1525
- function getNormal(p1, p2, result) {
1526
- result.subVectors(p2, p1);
1527
- return result.set(-result.y, result.x).normalize();
1528
- }
1529
- function addVertex(position, u, v) {
1530
- if (vertices) {
1531
- vertices[currentCoordinate] = position.x;
1532
- vertices[currentCoordinate + 1] = position.y;
1533
- vertices[currentCoordinate + 2] = 0;
1534
- if (normals) {
1535
- normals[currentCoordinate] = 0;
1536
- normals[currentCoordinate + 1] = 0;
1537
- normals[currentCoordinate + 2] = 1;
1538
- }
1539
- currentCoordinate += 3;
1540
- if (uvs) {
1541
- uvs[currentCoordinateUV] = u;
1542
- uvs[currentCoordinateUV + 1] = v;
1543
- currentCoordinateUV += 2;
1544
- }
1545
- }
1546
- numVertices += 3;
1547
- }
1548
- function makeCircularSector(center, p1, p2, u, v) {
1549
- tempV2_1.copy(p1).sub(center).normalize();
1550
- tempV2_2.copy(p2).sub(center).normalize();
1551
- let angle = Math.PI;
1552
- const dot = tempV2_1.dot(tempV2_2);
1553
- if (Math.abs(dot) < 1)
1554
- angle = Math.abs(Math.acos(dot));
1555
- angle /= arcDivisions;
1556
- tempV2_3.copy(p1);
1557
- for (let i = 0, il = arcDivisions - 1; i < il; i++) {
1558
- tempV2_4.copy(tempV2_3).rotateAround(center, angle);
1559
- addVertex(tempV2_3, u, v);
1560
- addVertex(tempV2_4, u, v);
1561
- addVertex(center, u, 0.5);
1562
- tempV2_3.copy(tempV2_4);
1563
- }
1564
- addVertex(tempV2_4, u, v);
1565
- addVertex(p2, u, v);
1566
- addVertex(center, u, 0.5);
1567
- }
1568
- function makeSegmentTriangles() {
1569
- addVertex(lastPointR, u0, 1);
1570
- addVertex(lastPointL, u0, 0);
1571
- addVertex(currentPointL, u1, 0);
1572
- addVertex(lastPointR, u0, 1);
1573
- addVertex(currentPointL, u1, 1);
1574
- addVertex(currentPointR, u1, 0);
1575
- }
1576
- function makeSegmentWithBevelJoin(joinIsOnLeftSide2, innerSideModified2, u) {
1577
- if (innerSideModified2) {
1578
- if (joinIsOnLeftSide2) {
1579
- addVertex(lastPointR, u0, 1);
1580
- addVertex(lastPointL, u0, 0);
1581
- addVertex(currentPointL, u1, 0);
1582
- addVertex(lastPointR, u0, 1);
1583
- addVertex(currentPointL, u1, 0);
1584
- addVertex(innerPoint, u1, 1);
1585
- addVertex(currentPointL, u, 0);
1586
- addVertex(nextPointL, u, 0);
1587
- addVertex(innerPoint, u, 0.5);
1588
- } else {
1589
- addVertex(lastPointR, u0, 1);
1590
- addVertex(lastPointL, u0, 0);
1591
- addVertex(currentPointR, u1, 1);
1592
- addVertex(lastPointL, u0, 0);
1593
- addVertex(innerPoint, u1, 0);
1594
- addVertex(currentPointR, u1, 1);
1595
- addVertex(currentPointR, u, 1);
1596
- addVertex(nextPointR, u, 0);
1597
- addVertex(innerPoint, u, 0.5);
1598
- }
1599
- } else {
1600
- if (joinIsOnLeftSide2) {
1601
- addVertex(currentPointL, u, 0);
1602
- addVertex(nextPointL, u, 0);
1603
- addVertex(currentPoint, u, 0.5);
1604
- } else {
1605
- addVertex(currentPointR, u, 1);
1606
- addVertex(nextPointR, u, 0);
1607
- addVertex(currentPoint, u, 0.5);
1608
- }
1609
- }
1610
- }
1611
- function createSegmentTrianglesWithMiddleSection(joinIsOnLeftSide2, innerSideModified2) {
1612
- if (innerSideModified2) {
1613
- if (joinIsOnLeftSide2) {
1614
- addVertex(lastPointR, u0, 1);
1615
- addVertex(lastPointL, u0, 0);
1616
- addVertex(currentPointL, u1, 0);
1617
- addVertex(lastPointR, u0, 1);
1618
- addVertex(currentPointL, u1, 0);
1619
- addVertex(innerPoint, u1, 1);
1620
- addVertex(currentPointL, u0, 0);
1621
- addVertex(currentPoint, u1, 0.5);
1622
- addVertex(innerPoint, u1, 1);
1623
- addVertex(currentPoint, u1, 0.5);
1624
- addVertex(nextPointL, u0, 0);
1625
- addVertex(innerPoint, u1, 1);
1626
- } else {
1627
- addVertex(lastPointR, u0, 1);
1628
- addVertex(lastPointL, u0, 0);
1629
- addVertex(currentPointR, u1, 1);
1630
- addVertex(lastPointL, u0, 0);
1631
- addVertex(innerPoint, u1, 0);
1632
- addVertex(currentPointR, u1, 1);
1633
- addVertex(currentPointR, u0, 1);
1634
- addVertex(innerPoint, u1, 0);
1635
- addVertex(currentPoint, u1, 0.5);
1636
- addVertex(currentPoint, u1, 0.5);
1637
- addVertex(innerPoint, u1, 0);
1638
- addVertex(nextPointR, u0, 1);
1639
- }
1640
- }
1641
- }
1642
- function addCapGeometry(center, p1, p2, joinIsOnLeftSide2, start, u) {
1643
- switch (style.strokeLineCap) {
1644
- case "round":
1645
- if (start) {
1646
- makeCircularSector(center, p2, p1, u, 0.5);
1647
- } else {
1648
- makeCircularSector(center, p1, p2, u, 0.5);
1649
- }
1650
- break;
1651
- case "square":
1652
- if (start) {
1653
- tempV2_1.subVectors(p1, center);
1654
- tempV2_2.set(tempV2_1.y, -tempV2_1.x);
1655
- tempV2_3.addVectors(tempV2_1, tempV2_2).add(center);
1656
- tempV2_4.subVectors(tempV2_2, tempV2_1).add(center);
1657
- if (joinIsOnLeftSide2) {
1658
- tempV2_3.toArray(vertices, 1 * 3);
1659
- tempV2_4.toArray(vertices, 0 * 3);
1660
- tempV2_4.toArray(vertices, 3 * 3);
1661
- } else {
1662
- tempV2_3.toArray(vertices, 1 * 3);
1663
- tempV2_3.toArray(vertices, 3 * 3);
1664
- tempV2_4.toArray(vertices, 0 * 3);
1665
- }
1666
- } else {
1667
- tempV2_1.subVectors(p2, center);
1668
- tempV2_2.set(tempV2_1.y, -tempV2_1.x);
1669
- tempV2_3.addVectors(tempV2_1, tempV2_2).add(center);
1670
- tempV2_4.subVectors(tempV2_2, tempV2_1).add(center);
1671
- const vl = vertices.length;
1672
- if (joinIsOnLeftSide2) {
1673
- tempV2_3.toArray(vertices, vl - 1 * 3);
1674
- tempV2_4.toArray(vertices, vl - 2 * 3);
1675
- tempV2_4.toArray(vertices, vl - 4 * 3);
1676
- } else {
1677
- tempV2_3.toArray(vertices, vl - 2 * 3);
1678
- tempV2_4.toArray(vertices, vl - 1 * 3);
1679
- tempV2_4.toArray(vertices, vl - 4 * 3);
1680
- }
1681
- }
1682
- break;
1683
- case "butt":
1684
- default:
1685
- break;
1686
- }
1687
- }
1688
- function removeDuplicatedPoints(points2) {
1689
- let dupPoints = false;
1690
- for (let i = 1, n = points2.length - 1; i < n; i++) {
1691
- if (points2[i].distanceTo(points2[i + 1]) < minDistance) {
1692
- dupPoints = true;
1693
- break;
1694
- }
1695
- }
1696
- if (!dupPoints)
1697
- return points2;
1698
- const newPoints = [];
1699
- newPoints.push(points2[0]);
1700
- for (let i = 1, n = points2.length - 1; i < n; i++) {
1701
- if (points2[i].distanceTo(points2[i + 1]) >= minDistance) {
1702
- newPoints.push(points2[i]);
1703
- }
1704
- }
1705
- newPoints.push(points2[points2.length - 1]);
1706
- return newPoints;
1707
- }
1708
- }
1709
- }
1710
- export {
1711
- SVGLoader
1712
- };