three-stdlib 2.25.0 → 2.26.0

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