opal-js_wrap-three 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (503) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/Gemfile.lock +4 -4
  4. data/lib/opal/js_wrap/three/version.rb +1 -1
  5. data/lib-opal/js_wrap/three/WebGL.js +102 -0
  6. data/lib-opal/js_wrap/three/animation/AnimationClipCreator.js +116 -0
  7. data/lib-opal/js_wrap/three/animation/CCDIKSolver.js +436 -0
  8. data/lib-opal/js_wrap/three/animation/MMDAnimationHelper.js +941 -0
  9. data/lib-opal/js_wrap/three/animation/MMDPhysics.js +1183 -0
  10. data/lib-opal/js_wrap/three/cameras/CinematicCamera.js +204 -0
  11. data/lib-opal/js_wrap/three/controls/ArcballControls.js +2649 -0
  12. data/lib-opal/js_wrap/three/controls/DragControls.js +234 -0
  13. data/lib-opal/js_wrap/three/controls/FirstPersonControls.js +301 -0
  14. data/lib-opal/js_wrap/three/controls/FlyControls.js +357 -0
  15. data/lib-opal/js_wrap/three/controls/OrbitControls.js +908 -0
  16. data/lib-opal/js_wrap/three/controls/PointerLockControls.js +173 -0
  17. data/lib-opal/js_wrap/three/controls/TrackballControls.js +666 -0
  18. data/lib-opal/js_wrap/three/controls/TransformControls.js +1210 -0
  19. data/lib-opal/js_wrap/three/controls/experimental/CameraControls.js +860 -0
  20. data/lib-opal/js_wrap/three/csm/CSM.js +346 -0
  21. data/lib-opal/js_wrap/three/csm/CSMFrustum.js +123 -0
  22. data/lib-opal/js_wrap/three/csm/CSMHelper.js +197 -0
  23. data/lib-opal/js_wrap/three/csm/CSMShader.js +29 -0
  24. data/lib-opal/js_wrap/three/curves/CurveExtras.js +544 -0
  25. data/lib-opal/js_wrap/three/curves/NURBSCurve.js +122 -0
  26. data/lib-opal/js_wrap/three/curves/NURBSSurface.js +78 -0
  27. data/lib-opal/js_wrap/three/curves/NURBSUtils.js +413 -0
  28. data/lib-opal/js_wrap/three/deprecated/Geometry.js +1373 -0
  29. data/lib-opal/js_wrap/three/effects/AnaglyphEffect.js +113 -0
  30. data/lib-opal/js_wrap/three/effects/AsciiEffect.js +267 -0
  31. data/lib-opal/js_wrap/three/effects/OutlineEffect.js +400 -0
  32. data/lib-opal/js_wrap/three/effects/ParallaxBarrierEffect.js +90 -0
  33. data/lib-opal/js_wrap/three/effects/PeppersGhostEffect.js +160 -0
  34. data/lib-opal/js_wrap/three/effects/StereoEffect.js +63 -0
  35. data/lib-opal/js_wrap/three/environments/DebugEnvironment.js +107 -0
  36. data/lib-opal/js_wrap/three/environments/RoomEnvironment.js +166 -0
  37. data/lib-opal/js_wrap/three/exporters/ColladaExporter.js +442 -0
  38. data/lib-opal/js_wrap/three/exporters/DRACOExporter.js +205 -0
  39. data/lib-opal/js_wrap/three/exporters/GLTFExporter.js +2042 -0
  40. data/lib-opal/js_wrap/three/exporters/MMDExporter.js +189 -0
  41. data/lib-opal/js_wrap/three/exporters/OBJExporter.js +241 -0
  42. data/lib-opal/js_wrap/three/exporters/PLYExporter.js +370 -0
  43. data/lib-opal/js_wrap/three/exporters/STLExporter.js +186 -0
  44. data/lib-opal/js_wrap/three/exporters/USDZExporter.js +402 -0
  45. data/lib-opal/js_wrap/three/geometries/BoxLineGeometry.js +106 -0
  46. data/lib-opal/js_wrap/three/geometries/ConvexGeometry.js +88 -0
  47. data/lib-opal/js_wrap/three/geometries/DecalGeometry.js +302 -0
  48. data/lib-opal/js_wrap/three/geometries/LightningStrike.js +817 -0
  49. data/lib-opal/js_wrap/three/geometries/ParametricGeometries.js +280 -0
  50. data/lib-opal/js_wrap/three/geometries/ParametricGeometry.js +146 -0
  51. data/lib-opal/js_wrap/three/geometries/RoundedBoxGeometry.js +183 -0
  52. data/lib-opal/js_wrap/three/geometries/TeapotGeometry.js +352 -0
  53. data/lib-opal/js_wrap/three/geometries/TextGeometry.js +76 -0
  54. data/lib-opal/js_wrap/three/helpers/LightProbeHelper.js +95 -0
  55. data/lib-opal/js_wrap/three/helpers/PositionalAudioHelper.js +138 -0
  56. data/lib-opal/js_wrap/three/helpers/RectAreaLightHelper.js +115 -0
  57. data/lib-opal/js_wrap/three/helpers/VertexNormalsHelper.js +131 -0
  58. data/lib-opal/js_wrap/three/helpers/VertexTangentsHelper.js +118 -0
  59. data/lib-opal/js_wrap/three/interactive/HTMLMesh.js +307 -0
  60. data/lib-opal/js_wrap/three/interactive/InteractiveGroup.js +138 -0
  61. data/lib-opal/js_wrap/three/interactive/SelectionBox.js +264 -0
  62. data/lib-opal/js_wrap/three/interactive/SelectionHelper.js +88 -0
  63. data/lib-opal/js_wrap/three/libs/OimoPhysics/OimoPhysics.js +46059 -0
  64. data/lib-opal/js_wrap/three/libs/OimoPhysics/index.js +92 -0
  65. data/lib-opal/js_wrap/three/libs/chevrotain.module.min.js +6947 -0
  66. data/lib-opal/js_wrap/three/libs/ecsy.module.js +1999 -0
  67. data/lib-opal/js_wrap/three/libs/fflate.module.js +3002 -0
  68. data/lib-opal/js_wrap/three/libs/flow.module.js +3033 -0
  69. data/lib-opal/js_wrap/three/libs/ktx-parse.module.js +392 -0
  70. data/lib-opal/js_wrap/three/libs/lil-gui.module.min.js +821 -0
  71. data/lib-opal/js_wrap/three/libs/meshopt_decoder.module.js +136 -0
  72. data/lib-opal/js_wrap/three/libs/mmdparser.module.js +11022 -0
  73. data/lib-opal/js_wrap/three/libs/motion-controllers.module.js +589 -0
  74. data/lib-opal/js_wrap/three/libs/opentype.module.min.js +6132 -0
  75. data/lib-opal/js_wrap/three/libs/potpack.module.js +171 -0
  76. data/lib-opal/js_wrap/three/libs/rhino3dm/rhino3dm.js +6781 -0
  77. data/lib-opal/js_wrap/three/libs/rhino3dm/rhino3dm.module.js +6783 -0
  78. data/lib-opal/js_wrap/three/libs/stats.module.js +139 -0
  79. data/lib-opal/js_wrap/three/libs/tween.module.min.js +349 -0
  80. data/lib-opal/js_wrap/three/lights/LightProbeGenerator.js +233 -0
  81. data/lib-opal/js_wrap/three/lights/RectAreaLightUniformsLib.js +75 -0
  82. data/lib-opal/js_wrap/three/lines/Line2.js +66 -0
  83. data/lib-opal/js_wrap/three/lines/LineGeometry.js +122 -0
  84. data/lib-opal/js_wrap/three/lines/LineMaterial.js +227 -0
  85. data/lib-opal/js_wrap/three/lines/LineSegments2.js +312 -0
  86. data/lib-opal/js_wrap/three/lines/LineSegmentsGeometry.js +238 -0
  87. data/lib-opal/js_wrap/three/lines/Wireframe.js +98 -0
  88. data/lib-opal/js_wrap/three/lines/WireframeGeometry2.js +65 -0
  89. data/lib-opal/js_wrap/three/loaders/3DMLoader.js +1230 -0
  90. data/lib-opal/js_wrap/three/loaders/3MFLoader.js +1123 -0
  91. data/lib-opal/js_wrap/three/loaders/AMFLoader.js +445 -0
  92. data/lib-opal/js_wrap/three/loaders/BVHLoader.js +365 -0
  93. data/lib-opal/js_wrap/three/loaders/BasisTextureLoader.js +692 -0
  94. data/lib-opal/js_wrap/three/loaders/ColladaLoader.js +3046 -0
  95. data/lib-opal/js_wrap/three/loaders/DDSLoader.js +264 -0
  96. data/lib-opal/js_wrap/three/loaders/DRACOLoader.js +531 -0
  97. data/lib-opal/js_wrap/three/loaders/EXRLoader.js +1834 -0
  98. data/lib-opal/js_wrap/three/loaders/FBXLoader.js +3125 -0
  99. data/lib-opal/js_wrap/three/loaders/FontLoader.js +201 -0
  100. data/lib-opal/js_wrap/three/loaders/GCodeLoader.js +248 -0
  101. data/lib-opal/js_wrap/three/loaders/GLTFLoader.js +3334 -0
  102. data/lib-opal/js_wrap/three/loaders/HDRCubeTextureLoader.js +144 -0
  103. data/lib-opal/js_wrap/three/loaders/IFCLoader.js +2395 -0
  104. data/lib-opal/js_wrap/three/loaders/KMZLoader.js +142 -0
  105. data/lib-opal/js_wrap/three/loaders/KTX2Loader.js +535 -0
  106. data/lib-opal/js_wrap/three/loaders/KTXLoader.js +202 -0
  107. data/lib-opal/js_wrap/three/loaders/LDrawLoader.js +1737 -0
  108. data/lib-opal/js_wrap/three/loaders/LUT3dlLoader.js +163 -0
  109. data/lib-opal/js_wrap/three/loaders/LUTCubeLoader.js +171 -0
  110. data/lib-opal/js_wrap/three/loaders/LWOLoader.js +831 -0
  111. data/lib-opal/js_wrap/three/loaders/LogLuvLoader.js +713 -0
  112. data/lib-opal/js_wrap/three/loaders/LottieLoader.js +103 -0
  113. data/lib-opal/js_wrap/three/loaders/MD2Loader.js +258 -0
  114. data/lib-opal/js_wrap/three/loaders/MDDLoader.js +116 -0
  115. data/lib-opal/js_wrap/three/loaders/MMDLoader.js +1687 -0
  116. data/lib-opal/js_wrap/three/loaders/MTLLoader.js +465 -0
  117. data/lib-opal/js_wrap/three/loaders/NRRDLoader.js +554 -0
  118. data/lib-opal/js_wrap/three/loaders/NodeMaterialLoader.js +248 -0
  119. data/lib-opal/js_wrap/three/loaders/OBJLoader.js +673 -0
  120. data/lib-opal/js_wrap/three/loaders/PCDLoader.js +322 -0
  121. data/lib-opal/js_wrap/three/loaders/PDBLoader.js +318 -0
  122. data/lib-opal/js_wrap/three/loaders/PLYLoader.js +489 -0
  123. data/lib-opal/js_wrap/three/loaders/PRWMLoader.js +247 -0
  124. data/lib-opal/js_wrap/three/loaders/PVRLoader.js +240 -0
  125. data/lib-opal/js_wrap/three/loaders/RGBELoader.js +462 -0
  126. data/lib-opal/js_wrap/three/loaders/RGBMLoader.js +1169 -0
  127. data/lib-opal/js_wrap/three/loaders/STLLoader.js +345 -0
  128. data/lib-opal/js_wrap/three/loaders/SVGLoader.js +2162 -0
  129. data/lib-opal/js_wrap/three/loaders/TDSLoader.js +982 -0
  130. data/lib-opal/js_wrap/three/loaders/TGALoader.js +444 -0
  131. data/lib-opal/js_wrap/three/loaders/TTFLoader.js +210 -0
  132. data/lib-opal/js_wrap/three/loaders/TiltLoader.js +391 -0
  133. data/lib-opal/js_wrap/three/loaders/VOXLoader.js +272 -0
  134. data/lib-opal/js_wrap/three/loaders/VRMLLoader.js +2685 -0
  135. data/lib-opal/js_wrap/three/loaders/VRMLoader.js +103 -0
  136. data/lib-opal/js_wrap/three/loaders/VTKLoader.js +894 -0
  137. data/lib-opal/js_wrap/three/loaders/XYZLoader.js +136 -0
  138. data/lib-opal/js_wrap/three/loaders/ifc/web-ifc-api.js +60504 -0
  139. data/lib-opal/js_wrap/three/loaders/lwo/IFFParser.js +931 -0
  140. data/lib-opal/js_wrap/three/loaders/lwo/LWO2Parser.js +450 -0
  141. data/lib-opal/js_wrap/three/loaders/lwo/LWO3Parser.js +406 -0
  142. data/lib-opal/js_wrap/three/math/Capsule.js +133 -0
  143. data/lib-opal/js_wrap/three/math/ColorConverter.js +104 -0
  144. data/lib-opal/js_wrap/three/math/ConvexHull.js +924 -0
  145. data/lib-opal/js_wrap/three/math/ImprovedNoise.js +86 -0
  146. data/lib-opal/js_wrap/three/math/Lut.js +170 -0
  147. data/lib-opal/js_wrap/three/math/MeshSurfaceSampler.js +187 -0
  148. data/lib-opal/js_wrap/three/math/OBB.js +345 -0
  149. data/lib-opal/js_wrap/three/math/Octree.js +409 -0
  150. data/lib-opal/js_wrap/three/math/SimplexNoise.js +425 -0
  151. data/lib-opal/js_wrap/three/misc/ConvexObjectBreaker.js +447 -0
  152. data/lib-opal/js_wrap/three/misc/GPUComputationRenderer.js +322 -0
  153. data/lib-opal/js_wrap/three/misc/Gyroscope.js +94 -0
  154. data/lib-opal/js_wrap/three/misc/MD2Character.js +225 -0
  155. data/lib-opal/js_wrap/three/misc/MD2CharacterComplex.js +424 -0
  156. data/lib-opal/js_wrap/three/misc/MorphAnimMesh.js +109 -0
  157. data/lib-opal/js_wrap/three/misc/MorphBlendMesh.js +283 -0
  158. data/lib-opal/js_wrap/three/misc/ProgressiveLightMap.js +324 -0
  159. data/lib-opal/js_wrap/three/misc/RollerCoaster.js +489 -0
  160. data/lib-opal/js_wrap/three/misc/TubePainter.js +158 -0
  161. data/lib-opal/js_wrap/three/misc/Volume.js +427 -0
  162. data/lib-opal/js_wrap/three/misc/VolumeSlice.js +210 -0
  163. data/lib-opal/js_wrap/three/modifiers/CurveModifier.js +291 -0
  164. data/lib-opal/js_wrap/three/modifiers/EdgeSplitModifier.js +308 -0
  165. data/lib-opal/js_wrap/three/modifiers/SimplifyModifier.js +435 -0
  166. data/lib-opal/js_wrap/three/modifiers/TessellateModifier.js +264 -0
  167. data/lib-opal/js_wrap/three/node-editor/NodeEditor.js +402 -0
  168. data/lib-opal/js_wrap/three/node-editor/accessors/NormalEditor.js +80 -0
  169. data/lib-opal/js_wrap/three/node-editor/accessors/PositionEditor.js +80 -0
  170. data/lib-opal/js_wrap/three/node-editor/accessors/UVEditor.js +71 -0
  171. data/lib-opal/js_wrap/three/node-editor/display/BlendEditor.js +78 -0
  172. data/lib-opal/js_wrap/three/node-editor/inputs/ColorEditor.js +111 -0
  173. data/lib-opal/js_wrap/three/node-editor/inputs/FloatEditor.js +69 -0
  174. data/lib-opal/js_wrap/three/node-editor/inputs/SliderEditor.js +97 -0
  175. data/lib-opal/js_wrap/three/node-editor/inputs/Vector2Editor.js +73 -0
  176. data/lib-opal/js_wrap/three/node-editor/inputs/Vector3Editor.js +75 -0
  177. data/lib-opal/js_wrap/three/node-editor/inputs/Vector4Editor.js +77 -0
  178. data/lib-opal/js_wrap/three/node-editor/materials/StandardMaterialEditor.js +121 -0
  179. data/lib-opal/js_wrap/three/node-editor/math/DotEditor.js +76 -0
  180. data/lib-opal/js_wrap/three/node-editor/math/InvertEditor.js +80 -0
  181. data/lib-opal/js_wrap/three/node-editor/math/LimiterEditor.js +85 -0
  182. data/lib-opal/js_wrap/three/node-editor/math/NormalizeEditor.js +69 -0
  183. data/lib-opal/js_wrap/three/node-editor/math/OperatorEditor.js +91 -0
  184. data/lib-opal/js_wrap/three/node-editor/math/PowerEditor.js +73 -0
  185. data/lib-opal/js_wrap/three/node-editor/math/TrigonometryEditor.js +83 -0
  186. data/lib-opal/js_wrap/three/node-editor/procedural/CheckerEditor.js +69 -0
  187. data/lib-opal/js_wrap/three/node-editor/utils/OscillatorEditor.js +87 -0
  188. data/lib-opal/js_wrap/three/node-editor/utils/TimerEditor.js +89 -0
  189. data/lib-opal/js_wrap/three/nodes/Nodes.js +481 -0
  190. data/lib-opal/js_wrap/three/nodes/accessors/CameraNode.js +222 -0
  191. data/lib-opal/js_wrap/three/nodes/accessors/ColorsNode.js +99 -0
  192. data/lib-opal/js_wrap/three/nodes/accessors/LightNode.js +100 -0
  193. data/lib-opal/js_wrap/three/nodes/accessors/NormalNode.js +152 -0
  194. data/lib-opal/js_wrap/three/nodes/accessors/PositionNode.js +163 -0
  195. data/lib-opal/js_wrap/three/nodes/accessors/ReflectNode.js +161 -0
  196. data/lib-opal/js_wrap/three/nodes/accessors/ResolutionNode.js +99 -0
  197. data/lib-opal/js_wrap/three/nodes/accessors/ScreenUVNode.js +101 -0
  198. data/lib-opal/js_wrap/three/nodes/accessors/UVNode.js +105 -0
  199. data/lib-opal/js_wrap/three/nodes/core/AttributeNode.js +106 -0
  200. data/lib-opal/js_wrap/three/nodes/core/ConstNode.js +149 -0
  201. data/lib-opal/js_wrap/three/nodes/core/ExpressionNode.js +57 -0
  202. data/lib-opal/js_wrap/three/nodes/core/FunctionCallNode.js +138 -0
  203. data/lib-opal/js_wrap/three/nodes/core/FunctionNode.js +259 -0
  204. data/lib-opal/js_wrap/three/nodes/core/InputNode.js +124 -0
  205. data/lib-opal/js_wrap/three/nodes/core/Node.js +193 -0
  206. data/lib-opal/js_wrap/three/nodes/core/NodeBuilder.js +782 -0
  207. data/lib-opal/js_wrap/three/nodes/core/NodeFrame.js +69 -0
  208. data/lib-opal/js_wrap/three/nodes/core/NodeLib.js +56 -0
  209. data/lib-opal/js_wrap/three/nodes/core/NodeUniform.js +53 -0
  210. data/lib-opal/js_wrap/three/nodes/core/NodeUtils.js +60 -0
  211. data/lib-opal/js_wrap/three/nodes/core/StructNode.js +131 -0
  212. data/lib-opal/js_wrap/three/nodes/core/TempNode.js +160 -0
  213. data/lib-opal/js_wrap/three/nodes/core/VarNode.js +105 -0
  214. data/lib-opal/js_wrap/three/nodes/effects/BlurNode.js +160 -0
  215. data/lib-opal/js_wrap/three/nodes/effects/ColorAdjustmentNode.js +139 -0
  216. data/lib-opal/js_wrap/three/nodes/effects/LuminanceNode.js +106 -0
  217. data/lib-opal/js_wrap/three/nodes/inputs/BoolNode.js +95 -0
  218. data/lib-opal/js_wrap/three/nodes/inputs/ColorNode.js +99 -0
  219. data/lib-opal/js_wrap/three/nodes/inputs/CubeTextureNode.js +136 -0
  220. data/lib-opal/js_wrap/three/nodes/inputs/FloatNode.js +95 -0
  221. data/lib-opal/js_wrap/three/nodes/inputs/IntNode.js +95 -0
  222. data/lib-opal/js_wrap/three/nodes/inputs/Matrix3Node.js +102 -0
  223. data/lib-opal/js_wrap/three/nodes/inputs/Matrix4Node.js +102 -0
  224. data/lib-opal/js_wrap/three/nodes/inputs/PropertyNode.js +85 -0
  225. data/lib-opal/js_wrap/three/nodes/inputs/RTTNode.js +164 -0
  226. data/lib-opal/js_wrap/three/nodes/inputs/ReflectorNode.js +111 -0
  227. data/lib-opal/js_wrap/three/nodes/inputs/ScreenNode.js +69 -0
  228. data/lib-opal/js_wrap/three/nodes/inputs/TextureNode.js +140 -0
  229. data/lib-opal/js_wrap/three/nodes/inputs/Vector2Node.js +98 -0
  230. data/lib-opal/js_wrap/three/nodes/inputs/Vector3Node.js +99 -0
  231. data/lib-opal/js_wrap/three/nodes/inputs/Vector4Node.js +100 -0
  232. data/lib-opal/js_wrap/three/nodes/materials/BasicNodeMaterial.js +63 -0
  233. data/lib-opal/js_wrap/three/nodes/materials/MeshStandardNodeMaterial.js +63 -0
  234. data/lib-opal/js_wrap/three/nodes/materials/NodeMaterial.js +202 -0
  235. data/lib-opal/js_wrap/three/nodes/materials/PhongNodeMaterial.js +63 -0
  236. data/lib-opal/js_wrap/three/nodes/materials/SpriteNodeMaterial.js +63 -0
  237. data/lib-opal/js_wrap/three/nodes/materials/StandardNodeMaterial.js +63 -0
  238. data/lib-opal/js_wrap/three/nodes/materials/nodes/BasicNode.js +146 -0
  239. data/lib-opal/js_wrap/three/nodes/materials/nodes/MeshStandardNode.js +133 -0
  240. data/lib-opal/js_wrap/three/nodes/materials/nodes/PhongNode.js +273 -0
  241. data/lib-opal/js_wrap/three/nodes/materials/nodes/RawNode.js +101 -0
  242. data/lib-opal/js_wrap/three/nodes/materials/nodes/SpriteNode.js +176 -0
  243. data/lib-opal/js_wrap/three/nodes/materials/nodes/StandardNode.js +397 -0
  244. data/lib-opal/js_wrap/three/nodes/math/CondNode.js +151 -0
  245. data/lib-opal/js_wrap/three/nodes/math/MathNode.js +266 -0
  246. data/lib-opal/js_wrap/three/nodes/math/OperatorNode.js +120 -0
  247. data/lib-opal/js_wrap/three/nodes/misc/BumpMapNode.js +139 -0
  248. data/lib-opal/js_wrap/three/nodes/misc/NormalMapNode.js +122 -0
  249. data/lib-opal/js_wrap/three/nodes/misc/TextureCubeNode.js +107 -0
  250. data/lib-opal/js_wrap/three/nodes/misc/TextureCubeUVNode.js +191 -0
  251. data/lib-opal/js_wrap/three/nodes/postprocessing/NodePass.js +117 -0
  252. data/lib-opal/js_wrap/three/nodes/postprocessing/NodePostProcessing.js +128 -0
  253. data/lib-opal/js_wrap/three/nodes/procedural/CheckerNode.js +104 -0
  254. data/lib-opal/js_wrap/three/nodes/procedural/Fractal3DNode.js +121 -0
  255. data/lib-opal/js_wrap/three/nodes/procedural/Noise2DNode.js +115 -0
  256. data/lib-opal/js_wrap/three/nodes/procedural/Noise3DNode.js +112 -0
  257. data/lib-opal/js_wrap/three/nodes/utils/BypassNode.js +115 -0
  258. data/lib-opal/js_wrap/three/nodes/utils/ColorSpaceNode.js +214 -0
  259. data/lib-opal/js_wrap/three/nodes/utils/JoinNode.js +138 -0
  260. data/lib-opal/js_wrap/three/nodes/utils/MaxMIPLevelNode.js +88 -0
  261. data/lib-opal/js_wrap/three/nodes/utils/RemapNode.js +117 -0
  262. data/lib-opal/js_wrap/three/nodes/utils/SpecularMIPLevelNode.js +121 -0
  263. data/lib-opal/js_wrap/three/nodes/utils/SubSlotNode.js +112 -0
  264. data/lib-opal/js_wrap/three/nodes/utils/SwitchNode.js +129 -0
  265. data/lib-opal/js_wrap/three/nodes/utils/TimerNode.js +126 -0
  266. data/lib-opal/js_wrap/three/nodes/utils/UVTransformNode.js +104 -0
  267. data/lib-opal/js_wrap/three/nodes/utils/VelocityNode.js +181 -0
  268. data/lib-opal/js_wrap/three/objects/Lensflare.js +285 -0
  269. data/lib-opal/js_wrap/three/objects/LightningStorm.js +238 -0
  270. data/lib-opal/js_wrap/three/objects/MarchingCubes.js +667 -0
  271. data/lib-opal/js_wrap/three/objects/Reflector.js +205 -0
  272. data/lib-opal/js_wrap/three/objects/ReflectorForSSRPass.js +288 -0
  273. data/lib-opal/js_wrap/three/objects/ReflectorRTT.js +63 -0
  274. data/lib-opal/js_wrap/three/objects/Refractor.js +243 -0
  275. data/lib-opal/js_wrap/three/objects/ShadowMesh.js +100 -0
  276. data/lib-opal/js_wrap/three/objects/Sky.js +107 -0
  277. data/lib-opal/js_wrap/three/objects/Water.js +246 -0
  278. data/lib-opal/js_wrap/three/objects/Water2.js +238 -0
  279. data/lib-opal/js_wrap/three/offscreen/jank.js +51 -0
  280. data/lib-opal/js_wrap/three/offscreen/offscreen.js +24 -0
  281. data/lib-opal/js_wrap/three/offscreen/scene.js +99 -0
  282. data/lib-opal/js_wrap/three/physics/AmmoPhysics.js +266 -0
  283. data/lib-opal/js_wrap/three/physics/OimoPhysics.js +214 -0
  284. data/lib-opal/js_wrap/three/postprocessing/AdaptiveToneMappingPass.js +307 -0
  285. data/lib-opal/js_wrap/three/postprocessing/AfterimagePass.js +116 -0
  286. data/lib-opal/js_wrap/three/postprocessing/BloomPass.js +132 -0
  287. data/lib-opal/js_wrap/three/postprocessing/BokehPass.js +143 -0
  288. data/lib-opal/js_wrap/three/postprocessing/ClearPass.js +85 -0
  289. data/lib-opal/js_wrap/three/postprocessing/CubeTexturePass.js +104 -0
  290. data/lib-opal/js_wrap/three/postprocessing/DotScreenPass.js +90 -0
  291. data/lib-opal/js_wrap/three/postprocessing/EffectComposer.js +272 -0
  292. data/lib-opal/js_wrap/three/postprocessing/FilmPass.js +91 -0
  293. data/lib-opal/js_wrap/three/postprocessing/GlitchPass.js +140 -0
  294. data/lib-opal/js_wrap/three/postprocessing/HalftonePass.js +108 -0
  295. data/lib-opal/js_wrap/three/postprocessing/LUTPass.js +132 -0
  296. data/lib-opal/js_wrap/three/postprocessing/MaskPass.js +142 -0
  297. data/lib-opal/js_wrap/three/postprocessing/OutlinePass.js +480 -0
  298. data/lib-opal/js_wrap/three/postprocessing/Pass.js +101 -0
  299. data/lib-opal/js_wrap/three/postprocessing/RenderPass.js +109 -0
  300. data/lib-opal/js_wrap/three/postprocessing/SAOPass.js +384 -0
  301. data/lib-opal/js_wrap/three/postprocessing/SMAAPass.js +199 -0
  302. data/lib-opal/js_wrap/three/postprocessing/SSAARenderPass.js +186 -0
  303. data/lib-opal/js_wrap/three/postprocessing/SSAOPass.js +388 -0
  304. data/lib-opal/js_wrap/three/postprocessing/SSRPass.js +537 -0
  305. data/lib-opal/js_wrap/three/postprocessing/SSRrPass.js +481 -0
  306. data/lib-opal/js_wrap/three/postprocessing/SavePass.js +96 -0
  307. data/lib-opal/js_wrap/three/postprocessing/ShaderPass.js +98 -0
  308. data/lib-opal/js_wrap/three/postprocessing/TAARenderPass.js +159 -0
  309. data/lib-opal/js_wrap/three/postprocessing/TexturePass.js +91 -0
  310. data/lib-opal/js_wrap/three/postprocessing/UnrealBloomPass.js +335 -0
  311. data/lib-opal/js_wrap/three/renderers/CSS2DRenderer.js +213 -0
  312. data/lib-opal/js_wrap/three/renderers/CSS3DRenderer.js +277 -0
  313. data/lib-opal/js_wrap/three/renderers/Projector.js +733 -0
  314. data/lib-opal/js_wrap/three/renderers/SVGRenderer.js +470 -0
  315. data/lib-opal/js_wrap/three/renderers/nodes/Nodes.js +531 -0
  316. data/lib-opal/js_wrap/three/renderers/nodes/ShaderNode.js +386 -0
  317. data/lib-opal/js_wrap/three/renderers/nodes/accessors/CameraNode.js +114 -0
  318. data/lib-opal/js_wrap/three/renderers/nodes/accessors/MaterialNode.js +140 -0
  319. data/lib-opal/js_wrap/three/renderers/nodes/accessors/MaterialReferenceNode.js +79 -0
  320. data/lib-opal/js_wrap/three/renderers/nodes/accessors/ModelNode.js +62 -0
  321. data/lib-opal/js_wrap/three/renderers/nodes/accessors/ModelViewProjectionNode.js +80 -0
  322. data/lib-opal/js_wrap/three/renderers/nodes/accessors/NormalNode.js +113 -0
  323. data/lib-opal/js_wrap/three/renderers/nodes/accessors/Object3DNode.js +136 -0
  324. data/lib-opal/js_wrap/three/renderers/nodes/accessors/PointUVNode.js +70 -0
  325. data/lib-opal/js_wrap/three/renderers/nodes/accessors/PositionNode.js +117 -0
  326. data/lib-opal/js_wrap/three/renderers/nodes/accessors/ReferenceNode.js +124 -0
  327. data/lib-opal/js_wrap/three/renderers/nodes/accessors/SkinningNode.js +129 -0
  328. data/lib-opal/js_wrap/three/renderers/nodes/accessors/UVNode.js +77 -0
  329. data/lib-opal/js_wrap/three/renderers/nodes/core/ArrayInputNode.js +74 -0
  330. data/lib-opal/js_wrap/three/renderers/nodes/core/AttributeNode.js +97 -0
  331. data/lib-opal/js_wrap/three/renderers/nodes/core/BypassNode.js +84 -0
  332. data/lib-opal/js_wrap/three/renderers/nodes/core/CodeNode.js +131 -0
  333. data/lib-opal/js_wrap/three/renderers/nodes/core/ContextNode.js +84 -0
  334. data/lib-opal/js_wrap/three/renderers/nodes/core/ExpressionNode.js +81 -0
  335. data/lib-opal/js_wrap/three/renderers/nodes/core/FunctionCallNode.js +123 -0
  336. data/lib-opal/js_wrap/three/renderers/nodes/core/FunctionNode.js +126 -0
  337. data/lib-opal/js_wrap/three/renderers/nodes/core/InputNode.js +103 -0
  338. data/lib-opal/js_wrap/three/renderers/nodes/core/Node.js +120 -0
  339. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeAttribute.js +37 -0
  340. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeBuilder.js +650 -0
  341. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeCode.js +42 -0
  342. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFrame.js +70 -0
  343. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFunction.js +55 -0
  344. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFunctionInput.js +44 -0
  345. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeKeywords.js +117 -0
  346. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeParser.js +46 -0
  347. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeUniform.js +55 -0
  348. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeVar.js +37 -0
  349. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeVary.js +37 -0
  350. data/lib-opal/js_wrap/three/renderers/nodes/core/PropertyNode.js +90 -0
  351. data/lib-opal/js_wrap/three/renderers/nodes/core/TempNode.js +89 -0
  352. data/lib-opal/js_wrap/three/renderers/nodes/core/VarNode.js +101 -0
  353. data/lib-opal/js_wrap/three/renderers/nodes/core/VaryNode.js +101 -0
  354. data/lib-opal/js_wrap/three/renderers/nodes/core/constants.js +42 -0
  355. data/lib-opal/js_wrap/three/renderers/nodes/display/ColorSpaceNode.js +165 -0
  356. data/lib-opal/js_wrap/three/renderers/nodes/display/NormalMapNode.js +120 -0
  357. data/lib-opal/js_wrap/three/renderers/nodes/functions/BSDFs.js +133 -0
  358. data/lib-opal/js_wrap/three/renderers/nodes/inputs/BufferNode.js +78 -0
  359. data/lib-opal/js_wrap/three/renderers/nodes/inputs/ColorNode.js +67 -0
  360. data/lib-opal/js_wrap/three/renderers/nodes/inputs/FloatNode.js +67 -0
  361. data/lib-opal/js_wrap/three/renderers/nodes/inputs/IntNode.js +67 -0
  362. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Matrix3Node.js +67 -0
  363. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Matrix4Node.js +67 -0
  364. data/lib-opal/js_wrap/three/renderers/nodes/inputs/TextureNode.js +120 -0
  365. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector2Node.js +67 -0
  366. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector3Node.js +67 -0
  367. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector4Node.js +67 -0
  368. data/lib-opal/js_wrap/three/renderers/nodes/lights/LightContextNode.js +103 -0
  369. data/lib-opal/js_wrap/three/renderers/nodes/lights/LightNode.js +115 -0
  370. data/lib-opal/js_wrap/three/renderers/nodes/lights/LightsNode.js +117 -0
  371. data/lib-opal/js_wrap/three/renderers/nodes/materials/LineBasicNodeMaterial.js +82 -0
  372. data/lib-opal/js_wrap/three/renderers/nodes/materials/Materials.js +49 -0
  373. data/lib-opal/js_wrap/three/renderers/nodes/materials/MeshBasicNodeMaterial.js +82 -0
  374. data/lib-opal/js_wrap/three/renderers/nodes/materials/MeshStandardNodeMaterial.js +96 -0
  375. data/lib-opal/js_wrap/three/renderers/nodes/materials/PointsNodeMaterial.js +84 -0
  376. data/lib-opal/js_wrap/three/renderers/nodes/math/CondNode.js +98 -0
  377. data/lib-opal/js_wrap/three/renderers/nodes/math/MathNode.js +255 -0
  378. data/lib-opal/js_wrap/three/renderers/nodes/math/OperatorNode.js +163 -0
  379. data/lib-opal/js_wrap/three/renderers/nodes/parsers/GLSLNodeFunction.js +158 -0
  380. data/lib-opal/js_wrap/three/renderers/nodes/parsers/GLSLNodeParser.js +68 -0
  381. data/lib-opal/js_wrap/three/renderers/nodes/parsers/WGSLNodeFunction.js +126 -0
  382. data/lib-opal/js_wrap/three/renderers/nodes/parsers/WGSLNodeParser.js +68 -0
  383. data/lib-opal/js_wrap/three/renderers/nodes/procedural/CheckerNode.js +84 -0
  384. data/lib-opal/js_wrap/three/renderers/nodes/utils/ArrayElementNode.js +79 -0
  385. data/lib-opal/js_wrap/three/renderers/nodes/utils/ConvertNode.js +82 -0
  386. data/lib-opal/js_wrap/three/renderers/nodes/utils/JoinNode.js +88 -0
  387. data/lib-opal/js_wrap/three/renderers/nodes/utils/OscNode.js +105 -0
  388. data/lib-opal/js_wrap/three/renderers/nodes/utils/SplitNode.js +96 -0
  389. data/lib-opal/js_wrap/three/renderers/nodes/utils/SpriteSheetUVNode.js +98 -0
  390. data/lib-opal/js_wrap/three/renderers/nodes/utils/TimerNode.js +93 -0
  391. data/lib-opal/js_wrap/three/renderers/webgl/nodes/SlotNode.js +72 -0
  392. data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLNodeBuilder.js +463 -0
  393. data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLNodes.js +62 -0
  394. data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLPhysicalContextNode.js +95 -0
  395. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPU.js +62 -0
  396. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUAttributes.js +118 -0
  397. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBackground.js +109 -0
  398. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBinding.js +52 -0
  399. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBindings.js +254 -0
  400. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBufferUtils.js +39 -0
  401. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUComputePipelines.js +82 -0
  402. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUGeometries.js +84 -0
  403. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUInfo.js +86 -0
  404. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUObjects.js +64 -0
  405. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUProgrammableStage.js +46 -0
  406. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUProperties.js +63 -0
  407. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderLists.js +180 -0
  408. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderPipeline.js +662 -0
  409. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderPipelines.js +275 -0
  410. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderer.js +883 -0
  411. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUSampledTexture.js +139 -0
  412. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUSampler.js +76 -0
  413. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUStorageBuffer.js +69 -0
  414. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextureRenderer.js +64 -0
  415. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextureUtils.js +125 -0
  416. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextures.js +681 -0
  417. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniform.js +237 -0
  418. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniformBuffer.js +90 -0
  419. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniformsGroup.js +294 -0
  420. data/lib-opal/js_wrap/three/renderers/webgpu/constants.js +263 -0
  421. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeBuilder.js +619 -0
  422. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeSampledTexture.js +67 -0
  423. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeSampler.js +71 -0
  424. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeUniform.js +229 -0
  425. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.js +68 -0
  426. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodes.js +106 -0
  427. data/lib-opal/js_wrap/three/shaders/ACESFilmicToneMappingShader.js +45 -0
  428. data/lib-opal/js_wrap/three/shaders/AfterimageShader.js +46 -0
  429. data/lib-opal/js_wrap/three/shaders/BasicShader.js +34 -0
  430. data/lib-opal/js_wrap/three/shaders/BleachBypassShader.js +43 -0
  431. data/lib-opal/js_wrap/three/shaders/BlendShader.js +47 -0
  432. data/lib-opal/js_wrap/three/shaders/BokehShader.js +65 -0
  433. data/lib-opal/js_wrap/three/shaders/BokehShader2.js +125 -0
  434. data/lib-opal/js_wrap/three/shaders/BrightnessContrastShader.js +47 -0
  435. data/lib-opal/js_wrap/three/shaders/ColorCorrectionShader.js +47 -0
  436. data/lib-opal/js_wrap/three/shaders/ColorifyShader.js +41 -0
  437. data/lib-opal/js_wrap/three/shaders/ConvolutionShader.js +75 -0
  438. data/lib-opal/js_wrap/three/shaders/CopyShader.js +41 -0
  439. data/lib-opal/js_wrap/three/shaders/DOFMipMapShader.js +49 -0
  440. data/lib-opal/js_wrap/three/shaders/DepthLimitedBlurShader.js +95 -0
  441. data/lib-opal/js_wrap/three/shaders/DigitalGlitch.js +79 -0
  442. data/lib-opal/js_wrap/three/shaders/DotScreenShader.js +52 -0
  443. data/lib-opal/js_wrap/three/shaders/FXAAShader.js +78 -0
  444. data/lib-opal/js_wrap/three/shaders/FilmShader.js +69 -0
  445. data/lib-opal/js_wrap/three/shaders/FocusShader.js +52 -0
  446. data/lib-opal/js_wrap/three/shaders/FreiChenShader.js +44 -0
  447. data/lib-opal/js_wrap/three/shaders/GammaCorrectionShader.js +39 -0
  448. data/lib-opal/js_wrap/three/shaders/GodRaysShader.js +140 -0
  449. data/lib-opal/js_wrap/three/shaders/HalftoneShader.js +77 -0
  450. data/lib-opal/js_wrap/three/shaders/HorizontalBlurShader.js +47 -0
  451. data/lib-opal/js_wrap/three/shaders/HorizontalTiltShiftShader.js +49 -0
  452. data/lib-opal/js_wrap/three/shaders/HueSaturationShader.js +47 -0
  453. data/lib-opal/js_wrap/three/shaders/KaleidoShader.js +50 -0
  454. data/lib-opal/js_wrap/three/shaders/LuminosityHighPassShader.js +52 -0
  455. data/lib-opal/js_wrap/three/shaders/LuminosityShader.js +39 -0
  456. data/lib-opal/js_wrap/three/shaders/MMDToonShader.js +48 -0
  457. data/lib-opal/js_wrap/three/shaders/MirrorShader.js +44 -0
  458. data/lib-opal/js_wrap/three/shaders/NormalMapShader.js +48 -0
  459. data/lib-opal/js_wrap/three/shaders/PixelShader.js +44 -0
  460. data/lib-opal/js_wrap/three/shaders/RGBShiftShader.js +50 -0
  461. data/lib-opal/js_wrap/three/shaders/SAOShader.js +85 -0
  462. data/lib-opal/js_wrap/three/shaders/SMAAShader.js +95 -0
  463. data/lib-opal/js_wrap/three/shaders/SSAOShader.js +113 -0
  464. data/lib-opal/js_wrap/three/shaders/SSRShader.js +126 -0
  465. data/lib-opal/js_wrap/three/shaders/SSRrShader.js +106 -0
  466. data/lib-opal/js_wrap/three/shaders/SepiaShader.js +43 -0
  467. data/lib-opal/js_wrap/three/shaders/SobelOperatorShader.js +44 -0
  468. data/lib-opal/js_wrap/three/shaders/SubsurfaceScatteringShader.js +64 -0
  469. data/lib-opal/js_wrap/three/shaders/TechnicolorShader.js +41 -0
  470. data/lib-opal/js_wrap/three/shaders/ToneMapShader.js +53 -0
  471. data/lib-opal/js_wrap/three/shaders/ToonShader.js +148 -0
  472. data/lib-opal/js_wrap/three/shaders/TriangleBlurShader.js +47 -0
  473. data/lib-opal/js_wrap/three/shaders/UnpackDepthRGBAShader.js +42 -0
  474. data/lib-opal/js_wrap/three/shaders/VerticalBlurShader.js +47 -0
  475. data/lib-opal/js_wrap/three/shaders/VerticalTiltShiftShader.js +49 -0
  476. data/lib-opal/js_wrap/three/shaders/VignetteShader.js +46 -0
  477. data/lib-opal/js_wrap/three/shaders/VolumeShader.js +55 -0
  478. data/lib-opal/js_wrap/three/shaders/WaterRefractionShader.js +46 -0
  479. data/lib-opal/js_wrap/three/textures/FlakesTexture.js +61 -0
  480. data/lib-opal/js_wrap/three/utils/BufferGeometryUtils.js +683 -0
  481. data/lib-opal/js_wrap/three/utils/CameraUtils.js +97 -0
  482. data/lib-opal/js_wrap/three/utils/GPUStatsPanel.js +154 -0
  483. data/lib-opal/js_wrap/three/utils/GeometryCompressionUtils.js +468 -0
  484. data/lib-opal/js_wrap/three/utils/GeometryUtils.js +192 -0
  485. data/lib-opal/js_wrap/three/utils/PackedPhongMaterial.js +77 -0
  486. data/lib-opal/js_wrap/three/utils/RoughnessMipmapper.js +169 -0
  487. data/lib-opal/js_wrap/three/utils/SceneUtils.js +62 -0
  488. data/lib-opal/js_wrap/three/utils/ShadowMapViewer.js +182 -0
  489. data/lib-opal/js_wrap/three/utils/SkeletonUtils.js +400 -0
  490. data/lib-opal/js_wrap/three/utils/UVsDebug.js +132 -0
  491. data/lib-opal/js_wrap/three/utils/WorkerPool.js +130 -0
  492. data/lib-opal/js_wrap/three/webxr/ARButton.js +203 -0
  493. data/lib-opal/js_wrap/three/webxr/OculusHandModel.js +131 -0
  494. data/lib-opal/js_wrap/three/webxr/OculusHandPointerModel.js +328 -0
  495. data/lib-opal/js_wrap/three/webxr/Text2D.js +54 -0
  496. data/lib-opal/js_wrap/three/webxr/VRButton.js +181 -0
  497. data/lib-opal/js_wrap/three/webxr/XRControllerModelFactory.js +266 -0
  498. data/lib-opal/js_wrap/three/webxr/XREstimatedLight.js +221 -0
  499. data/lib-opal/js_wrap/three/webxr/XRHandMeshModel.js +93 -0
  500. data/lib-opal/js_wrap/three/webxr/XRHandModelFactory.js +127 -0
  501. data/lib-opal/js_wrap/three/webxr/XRHandPrimitiveModel.js +85 -0
  502. data/opal-js_wrap-three.gemspec +4 -4
  503. metadata +502 -5
@@ -0,0 +1,2162 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "three"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("three"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.three);
11
+ global.SVGLoader = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _three) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.SVGLoader = void 0;
20
+
21
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
+
23
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
24
+
25
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
26
+
27
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
28
+
29
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
30
+
31
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
32
+
33
+ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
34
+
35
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
36
+
37
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
38
+
39
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
40
+
41
+ var SVGLoader = /*#__PURE__*/function (_Loader) {
42
+ _inherits(SVGLoader, _Loader);
43
+
44
+ var _super = _createSuper(SVGLoader);
45
+
46
+ function SVGLoader(manager) {
47
+ var _this;
48
+
49
+ _classCallCheck(this, SVGLoader);
50
+
51
+ _this = _super.call(this, manager); // Default dots per inch
52
+
53
+ _this.defaultDPI = 90; // Accepted units: 'mm', 'cm', 'in', 'pt', 'pc', 'px'
54
+
55
+ _this.defaultUnit = 'px';
56
+ return _this;
57
+ }
58
+
59
+ _createClass(SVGLoader, [{
60
+ key: "load",
61
+ value: function load(url, onLoad, onProgress, onError) {
62
+ var scope = this;
63
+ var loader = new _three.FileLoader(scope.manager);
64
+ loader.setPath(scope.path);
65
+ loader.setRequestHeader(scope.requestHeader);
66
+ loader.setWithCredentials(scope.withCredentials);
67
+ loader.load(url, function (text) {
68
+ try {
69
+ onLoad(scope.parse(text));
70
+ } catch (e) {
71
+ if (onError) {
72
+ onError(e);
73
+ } else {
74
+ console.error(e);
75
+ }
76
+
77
+ scope.manager.itemError(url);
78
+ }
79
+ }, onProgress, onError);
80
+ }
81
+ }, {
82
+ key: "parse",
83
+ value: function parse(text) {
84
+ var scope = this;
85
+
86
+ function parseNode(node, style) {
87
+ if (node.nodeType !== 1) return;
88
+ var transform = getNodeTransform(node);
89
+ var traverseChildNodes = true;
90
+ var path = null;
91
+
92
+ switch (node.nodeName) {
93
+ case 'svg':
94
+ break;
95
+
96
+ case 'style':
97
+ parseCSSStylesheet(node);
98
+ break;
99
+
100
+ case 'g':
101
+ style = parseStyle(node, style);
102
+ break;
103
+
104
+ case 'path':
105
+ style = parseStyle(node, style);
106
+ if (node.hasAttribute('d')) path = parsePathNode(node);
107
+ break;
108
+
109
+ case 'rect':
110
+ style = parseStyle(node, style);
111
+ path = parseRectNode(node);
112
+ break;
113
+
114
+ case 'polygon':
115
+ style = parseStyle(node, style);
116
+ path = parsePolygonNode(node);
117
+ break;
118
+
119
+ case 'polyline':
120
+ style = parseStyle(node, style);
121
+ path = parsePolylineNode(node);
122
+ break;
123
+
124
+ case 'circle':
125
+ style = parseStyle(node, style);
126
+ path = parseCircleNode(node);
127
+ break;
128
+
129
+ case 'ellipse':
130
+ style = parseStyle(node, style);
131
+ path = parseEllipseNode(node);
132
+ break;
133
+
134
+ case 'line':
135
+ style = parseStyle(node, style);
136
+ path = parseLineNode(node);
137
+ break;
138
+
139
+ case 'defs':
140
+ traverseChildNodes = false;
141
+ break;
142
+
143
+ case 'use':
144
+ style = parseStyle(node, style);
145
+ var usedNodeId = node.href.baseVal.substring(1);
146
+ var usedNode = node.viewportElement.getElementById(usedNodeId);
147
+
148
+ if (usedNode) {
149
+ parseNode(usedNode, style);
150
+ } else {
151
+ console.warn('SVGLoader: \'use node\' references non-existent node id: ' + usedNodeId);
152
+ }
153
+
154
+ break;
155
+
156
+ default: // console.log( node );
157
+
158
+ }
159
+
160
+ if (path) {
161
+ if (style.fill !== undefined && style.fill !== 'none') {
162
+ path.color.setStyle(style.fill);
163
+ }
164
+
165
+ transformPath(path, currentTransform);
166
+ paths.push(path);
167
+ path.userData = {
168
+ node: node,
169
+ style: style
170
+ };
171
+ }
172
+
173
+ if (traverseChildNodes) {
174
+ var nodes = node.childNodes;
175
+
176
+ for (var i = 0; i < nodes.length; i++) {
177
+ parseNode(nodes[i], style);
178
+ }
179
+ }
180
+
181
+ if (transform) {
182
+ transformStack.pop();
183
+
184
+ if (transformStack.length > 0) {
185
+ currentTransform.copy(transformStack[transformStack.length - 1]);
186
+ } else {
187
+ currentTransform.identity();
188
+ }
189
+ }
190
+ }
191
+
192
+ function parsePathNode(node) {
193
+ var path = new _three.ShapePath();
194
+ var point = new _three.Vector2();
195
+ var control = new _three.Vector2();
196
+ var firstPoint = new _three.Vector2();
197
+ var isFirstPoint = true;
198
+ var doSetFirstPoint = false;
199
+ var d = node.getAttribute('d'); // console.log( d );
200
+
201
+ var commands = d.match(/[a-df-z][^a-df-z]*/ig);
202
+
203
+ for (var i = 0, l = commands.length; i < l; i++) {
204
+ var command = commands[i];
205
+ var type = command.charAt(0);
206
+
207
+ var _data = command.substr(1).trim();
208
+
209
+ if (isFirstPoint === true) {
210
+ doSetFirstPoint = true;
211
+ isFirstPoint = false;
212
+ }
213
+
214
+ var numbers = void 0;
215
+
216
+ switch (type) {
217
+ case 'M':
218
+ numbers = parseFloats(_data);
219
+
220
+ for (var j = 0, jl = numbers.length; j < jl; j += 2) {
221
+ point.x = numbers[j + 0];
222
+ point.y = numbers[j + 1];
223
+ control.x = point.x;
224
+ control.y = point.y;
225
+
226
+ if (j === 0) {
227
+ path.moveTo(point.x, point.y);
228
+ } else {
229
+ path.lineTo(point.x, point.y);
230
+ }
231
+
232
+ if (j === 0 && doSetFirstPoint === true) firstPoint.copy(point);
233
+ }
234
+
235
+ break;
236
+
237
+ case 'H':
238
+ numbers = parseFloats(_data);
239
+
240
+ for (var _j = 0, _jl = numbers.length; _j < _jl; _j++) {
241
+ point.x = numbers[_j];
242
+ control.x = point.x;
243
+ control.y = point.y;
244
+ path.lineTo(point.x, point.y);
245
+ if (_j === 0 && doSetFirstPoint === true) firstPoint.copy(point);
246
+ }
247
+
248
+ break;
249
+
250
+ case 'V':
251
+ numbers = parseFloats(_data);
252
+
253
+ for (var _j2 = 0, _jl2 = numbers.length; _j2 < _jl2; _j2++) {
254
+ point.y = numbers[_j2];
255
+ control.x = point.x;
256
+ control.y = point.y;
257
+ path.lineTo(point.x, point.y);
258
+ if (_j2 === 0 && doSetFirstPoint === true) firstPoint.copy(point);
259
+ }
260
+
261
+ break;
262
+
263
+ case 'L':
264
+ numbers = parseFloats(_data);
265
+
266
+ for (var _j3 = 0, _jl3 = numbers.length; _j3 < _jl3; _j3 += 2) {
267
+ point.x = numbers[_j3 + 0];
268
+ point.y = numbers[_j3 + 1];
269
+ control.x = point.x;
270
+ control.y = point.y;
271
+ path.lineTo(point.x, point.y);
272
+ if (_j3 === 0 && doSetFirstPoint === true) firstPoint.copy(point);
273
+ }
274
+
275
+ break;
276
+
277
+ case 'C':
278
+ numbers = parseFloats(_data);
279
+
280
+ for (var _j4 = 0, _jl4 = numbers.length; _j4 < _jl4; _j4 += 6) {
281
+ path.bezierCurveTo(numbers[_j4 + 0], numbers[_j4 + 1], numbers[_j4 + 2], numbers[_j4 + 3], numbers[_j4 + 4], numbers[_j4 + 5]);
282
+ control.x = numbers[_j4 + 2];
283
+ control.y = numbers[_j4 + 3];
284
+ point.x = numbers[_j4 + 4];
285
+ point.y = numbers[_j4 + 5];
286
+ if (_j4 === 0 && doSetFirstPoint === true) firstPoint.copy(point);
287
+ }
288
+
289
+ break;
290
+
291
+ case 'S':
292
+ numbers = parseFloats(_data);
293
+
294
+ for (var _j5 = 0, _jl5 = numbers.length; _j5 < _jl5; _j5 += 4) {
295
+ path.bezierCurveTo(getReflection(point.x, control.x), getReflection(point.y, control.y), numbers[_j5 + 0], numbers[_j5 + 1], numbers[_j5 + 2], numbers[_j5 + 3]);
296
+ control.x = numbers[_j5 + 0];
297
+ control.y = numbers[_j5 + 1];
298
+ point.x = numbers[_j5 + 2];
299
+ point.y = numbers[_j5 + 3];
300
+ if (_j5 === 0 && doSetFirstPoint === true) firstPoint.copy(point);
301
+ }
302
+
303
+ break;
304
+
305
+ case 'Q':
306
+ numbers = parseFloats(_data);
307
+
308
+ for (var _j6 = 0, _jl6 = numbers.length; _j6 < _jl6; _j6 += 4) {
309
+ path.quadraticCurveTo(numbers[_j6 + 0], numbers[_j6 + 1], numbers[_j6 + 2], numbers[_j6 + 3]);
310
+ control.x = numbers[_j6 + 0];
311
+ control.y = numbers[_j6 + 1];
312
+ point.x = numbers[_j6 + 2];
313
+ point.y = numbers[_j6 + 3];
314
+ if (_j6 === 0 && doSetFirstPoint === true) firstPoint.copy(point);
315
+ }
316
+
317
+ break;
318
+
319
+ case 'T':
320
+ numbers = parseFloats(_data);
321
+
322
+ for (var _j7 = 0, _jl7 = numbers.length; _j7 < _jl7; _j7 += 2) {
323
+ var rx = getReflection(point.x, control.x);
324
+ var ry = getReflection(point.y, control.y);
325
+ path.quadraticCurveTo(rx, ry, numbers[_j7 + 0], numbers[_j7 + 1]);
326
+ control.x = rx;
327
+ control.y = ry;
328
+ point.x = numbers[_j7 + 0];
329
+ point.y = numbers[_j7 + 1];
330
+ if (_j7 === 0 && doSetFirstPoint === true) firstPoint.copy(point);
331
+ }
332
+
333
+ break;
334
+
335
+ case 'A':
336
+ numbers = parseFloats(_data, [3, 4], 7);
337
+
338
+ for (var _j8 = 0, _jl8 = numbers.length; _j8 < _jl8; _j8 += 7) {
339
+ // skip command if start point == end point
340
+ if (numbers[_j8 + 5] == point.x && numbers[_j8 + 6] == point.y) continue;
341
+ var start = point.clone();
342
+ point.x = numbers[_j8 + 5];
343
+ point.y = numbers[_j8 + 6];
344
+ control.x = point.x;
345
+ control.y = point.y;
346
+ parseArcCommand(path, numbers[_j8], numbers[_j8 + 1], numbers[_j8 + 2], numbers[_j8 + 3], numbers[_j8 + 4], start, point);
347
+ if (_j8 === 0 && doSetFirstPoint === true) firstPoint.copy(point);
348
+ }
349
+
350
+ break;
351
+
352
+ case 'm':
353
+ numbers = parseFloats(_data);
354
+
355
+ for (var _j9 = 0, _jl9 = numbers.length; _j9 < _jl9; _j9 += 2) {
356
+ point.x += numbers[_j9 + 0];
357
+ point.y += numbers[_j9 + 1];
358
+ control.x = point.x;
359
+ control.y = point.y;
360
+
361
+ if (_j9 === 0) {
362
+ path.moveTo(point.x, point.y);
363
+ } else {
364
+ path.lineTo(point.x, point.y);
365
+ }
366
+
367
+ if (_j9 === 0 && doSetFirstPoint === true) firstPoint.copy(point);
368
+ }
369
+
370
+ break;
371
+
372
+ case 'h':
373
+ numbers = parseFloats(_data);
374
+
375
+ for (var _j10 = 0, _jl10 = numbers.length; _j10 < _jl10; _j10++) {
376
+ point.x += numbers[_j10];
377
+ control.x = point.x;
378
+ control.y = point.y;
379
+ path.lineTo(point.x, point.y);
380
+ if (_j10 === 0 && doSetFirstPoint === true) firstPoint.copy(point);
381
+ }
382
+
383
+ break;
384
+
385
+ case 'v':
386
+ numbers = parseFloats(_data);
387
+
388
+ for (var _j11 = 0, _jl11 = numbers.length; _j11 < _jl11; _j11++) {
389
+ point.y += numbers[_j11];
390
+ control.x = point.x;
391
+ control.y = point.y;
392
+ path.lineTo(point.x, point.y);
393
+ if (_j11 === 0 && doSetFirstPoint === true) firstPoint.copy(point);
394
+ }
395
+
396
+ break;
397
+
398
+ case 'l':
399
+ numbers = parseFloats(_data);
400
+
401
+ for (var _j12 = 0, _jl12 = numbers.length; _j12 < _jl12; _j12 += 2) {
402
+ point.x += numbers[_j12 + 0];
403
+ point.y += numbers[_j12 + 1];
404
+ control.x = point.x;
405
+ control.y = point.y;
406
+ path.lineTo(point.x, point.y);
407
+ if (_j12 === 0 && doSetFirstPoint === true) firstPoint.copy(point);
408
+ }
409
+
410
+ break;
411
+
412
+ case 'c':
413
+ numbers = parseFloats(_data);
414
+
415
+ for (var _j13 = 0, _jl13 = numbers.length; _j13 < _jl13; _j13 += 6) {
416
+ path.bezierCurveTo(point.x + numbers[_j13 + 0], point.y + numbers[_j13 + 1], point.x + numbers[_j13 + 2], point.y + numbers[_j13 + 3], point.x + numbers[_j13 + 4], point.y + numbers[_j13 + 5]);
417
+ control.x = point.x + numbers[_j13 + 2];
418
+ control.y = point.y + numbers[_j13 + 3];
419
+ point.x += numbers[_j13 + 4];
420
+ point.y += numbers[_j13 + 5];
421
+ if (_j13 === 0 && doSetFirstPoint === true) firstPoint.copy(point);
422
+ }
423
+
424
+ break;
425
+
426
+ case 's':
427
+ numbers = parseFloats(_data);
428
+
429
+ for (var _j14 = 0, _jl14 = numbers.length; _j14 < _jl14; _j14 += 4) {
430
+ path.bezierCurveTo(getReflection(point.x, control.x), getReflection(point.y, control.y), point.x + numbers[_j14 + 0], point.y + numbers[_j14 + 1], point.x + numbers[_j14 + 2], point.y + numbers[_j14 + 3]);
431
+ control.x = point.x + numbers[_j14 + 0];
432
+ control.y = point.y + numbers[_j14 + 1];
433
+ point.x += numbers[_j14 + 2];
434
+ point.y += numbers[_j14 + 3];
435
+ if (_j14 === 0 && doSetFirstPoint === true) firstPoint.copy(point);
436
+ }
437
+
438
+ break;
439
+
440
+ case 'q':
441
+ numbers = parseFloats(_data);
442
+
443
+ for (var _j15 = 0, _jl15 = numbers.length; _j15 < _jl15; _j15 += 4) {
444
+ path.quadraticCurveTo(point.x + numbers[_j15 + 0], point.y + numbers[_j15 + 1], point.x + numbers[_j15 + 2], point.y + numbers[_j15 + 3]);
445
+ control.x = point.x + numbers[_j15 + 0];
446
+ control.y = point.y + numbers[_j15 + 1];
447
+ point.x += numbers[_j15 + 2];
448
+ point.y += numbers[_j15 + 3];
449
+ if (_j15 === 0 && doSetFirstPoint === true) firstPoint.copy(point);
450
+ }
451
+
452
+ break;
453
+
454
+ case 't':
455
+ numbers = parseFloats(_data);
456
+
457
+ for (var _j16 = 0, _jl16 = numbers.length; _j16 < _jl16; _j16 += 2) {
458
+ var _rx = getReflection(point.x, control.x);
459
+
460
+ var _ry = getReflection(point.y, control.y);
461
+
462
+ path.quadraticCurveTo(_rx, _ry, point.x + numbers[_j16 + 0], point.y + numbers[_j16 + 1]);
463
+ control.x = _rx;
464
+ control.y = _ry;
465
+ point.x = point.x + numbers[_j16 + 0];
466
+ point.y = point.y + numbers[_j16 + 1];
467
+ if (_j16 === 0 && doSetFirstPoint === true) firstPoint.copy(point);
468
+ }
469
+
470
+ break;
471
+
472
+ case 'a':
473
+ numbers = parseFloats(_data, [3, 4], 7);
474
+
475
+ for (var _j17 = 0, _jl17 = numbers.length; _j17 < _jl17; _j17 += 7) {
476
+ // skip command if no displacement
477
+ if (numbers[_j17 + 5] == 0 && numbers[_j17 + 6] == 0) continue;
478
+
479
+ var _start = point.clone();
480
+
481
+ point.x += numbers[_j17 + 5];
482
+ point.y += numbers[_j17 + 6];
483
+ control.x = point.x;
484
+ control.y = point.y;
485
+ parseArcCommand(path, numbers[_j17], numbers[_j17 + 1], numbers[_j17 + 2], numbers[_j17 + 3], numbers[_j17 + 4], _start, point);
486
+ if (_j17 === 0 && doSetFirstPoint === true) firstPoint.copy(point);
487
+ }
488
+
489
+ break;
490
+
491
+ case 'Z':
492
+ case 'z':
493
+ path.currentPath.autoClose = true;
494
+
495
+ if (path.currentPath.curves.length > 0) {
496
+ // Reset point to beginning of Path
497
+ point.copy(firstPoint);
498
+ path.currentPath.currentPoint.copy(point);
499
+ isFirstPoint = true;
500
+ }
501
+
502
+ break;
503
+
504
+ default:
505
+ console.warn(command);
506
+ } // console.log( type, parseFloats( data ), parseFloats( data ).length )
507
+
508
+
509
+ doSetFirstPoint = false;
510
+ }
511
+
512
+ return path;
513
+ }
514
+
515
+ function parseCSSStylesheet(node) {
516
+ if (!node.sheet || !node.sheet.cssRules || !node.sheet.cssRules.length) return;
517
+
518
+ for (var i = 0; i < node.sheet.cssRules.length; i++) {
519
+ var stylesheet = node.sheet.cssRules[i];
520
+ if (stylesheet.type !== 1) continue;
521
+ var selectorList = stylesheet.selectorText.split(/,/gm).filter(Boolean).map(function (i) {
522
+ return i.trim();
523
+ });
524
+
525
+ for (var j = 0; j < selectorList.length; j++) {
526
+ stylesheets[selectorList[j]] = Object.assign(stylesheets[selectorList[j]] || {}, stylesheet.style);
527
+ }
528
+ }
529
+ }
530
+ /**
531
+ * https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
532
+ * https://mortoray.com/2017/02/16/rendering-an-svg-elliptical-arc-as-bezier-curves/ Appendix: Endpoint to center arc conversion
533
+ * From
534
+ * rx ry x-axis-rotation large-arc-flag sweep-flag x y
535
+ * To
536
+ * aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation
537
+ */
538
+
539
+
540
+ function parseArcCommand(path, rx, ry, x_axis_rotation, large_arc_flag, sweep_flag, start, end) {
541
+ if (rx == 0 || ry == 0) {
542
+ // draw a line if either of the radii == 0
543
+ path.lineTo(end.x, end.y);
544
+ return;
545
+ }
546
+
547
+ x_axis_rotation = x_axis_rotation * Math.PI / 180; // Ensure radii are positive
548
+
549
+ rx = Math.abs(rx);
550
+ ry = Math.abs(ry); // Compute (x1', y1')
551
+
552
+ var dx2 = (start.x - end.x) / 2.0;
553
+ var dy2 = (start.y - end.y) / 2.0;
554
+ var x1p = Math.cos(x_axis_rotation) * dx2 + Math.sin(x_axis_rotation) * dy2;
555
+ var y1p = -Math.sin(x_axis_rotation) * dx2 + Math.cos(x_axis_rotation) * dy2; // Compute (cx', cy')
556
+
557
+ var rxs = rx * rx;
558
+ var rys = ry * ry;
559
+ var x1ps = x1p * x1p;
560
+ var y1ps = y1p * y1p; // Ensure radii are large enough
561
+
562
+ var cr = x1ps / rxs + y1ps / rys;
563
+
564
+ if (cr > 1) {
565
+ // scale up rx,ry equally so cr == 1
566
+ var s = Math.sqrt(cr);
567
+ rx = s * rx;
568
+ ry = s * ry;
569
+ rxs = rx * rx;
570
+ rys = ry * ry;
571
+ }
572
+
573
+ var dq = rxs * y1ps + rys * x1ps;
574
+ var pq = (rxs * rys - dq) / dq;
575
+ var q = Math.sqrt(Math.max(0, pq));
576
+ if (large_arc_flag === sweep_flag) q = -q;
577
+ var cxp = q * rx * y1p / ry;
578
+ var cyp = -q * ry * x1p / rx; // Step 3: Compute (cx, cy) from (cx', cy')
579
+
580
+ var cx = Math.cos(x_axis_rotation) * cxp - Math.sin(x_axis_rotation) * cyp + (start.x + end.x) / 2;
581
+ var cy = Math.sin(x_axis_rotation) * cxp + Math.cos(x_axis_rotation) * cyp + (start.y + end.y) / 2; // Step 4: Compute θ1 and Δθ
582
+
583
+ var theta = svgAngle(1, 0, (x1p - cxp) / rx, (y1p - cyp) / ry);
584
+ var delta = svgAngle((x1p - cxp) / rx, (y1p - cyp) / ry, (-x1p - cxp) / rx, (-y1p - cyp) / ry) % (Math.PI * 2);
585
+ path.currentPath.absellipse(cx, cy, rx, ry, theta, theta + delta, sweep_flag === 0, x_axis_rotation);
586
+ }
587
+
588
+ function svgAngle(ux, uy, vx, vy) {
589
+ var dot = ux * vx + uy * vy;
590
+ var len = Math.sqrt(ux * ux + uy * uy) * Math.sqrt(vx * vx + vy * vy);
591
+ var ang = Math.acos(Math.max(-1, Math.min(1, dot / len))); // floating point precision, slightly over values appear
592
+
593
+ if (ux * vy - uy * vx < 0) ang = -ang;
594
+ return ang;
595
+ }
596
+ /*
597
+ * According to https://www.w3.org/TR/SVG/shapes.html#RectElementRXAttribute
598
+ * rounded corner should be rendered to elliptical arc, but bezier curve does the job well enough
599
+ */
600
+
601
+
602
+ function parseRectNode(node) {
603
+ var x = parseFloatWithUnits(node.getAttribute('x') || 0);
604
+ var y = parseFloatWithUnits(node.getAttribute('y') || 0);
605
+ var rx = parseFloatWithUnits(node.getAttribute('rx') || node.getAttribute('ry') || 0);
606
+ var ry = parseFloatWithUnits(node.getAttribute('ry') || node.getAttribute('rx') || 0);
607
+ var w = parseFloatWithUnits(node.getAttribute('width'));
608
+ var h = parseFloatWithUnits(node.getAttribute('height')); // Ellipse arc to Bezier approximation Coefficient (Inversed). See:
609
+ // https://spencermortensen.com/articles/bezier-circle/
610
+
611
+ var bci = 1 - 0.551915024494;
612
+ var path = new _three.ShapePath(); // top left
613
+
614
+ path.moveTo(x + rx, y); // top right
615
+
616
+ path.lineTo(x + w - rx, y);
617
+
618
+ if (rx !== 0 || ry !== 0) {
619
+ path.bezierCurveTo(x + w - rx * bci, y, x + w, y + ry * bci, x + w, y + ry);
620
+ } // bottom right
621
+
622
+
623
+ path.lineTo(x + w, y + h - ry);
624
+
625
+ if (rx !== 0 || ry !== 0) {
626
+ path.bezierCurveTo(x + w, y + h - ry * bci, x + w - rx * bci, y + h, x + w - rx, y + h);
627
+ } // bottom left
628
+
629
+
630
+ path.lineTo(x + rx, y + h);
631
+
632
+ if (rx !== 0 || ry !== 0) {
633
+ path.bezierCurveTo(x + rx * bci, y + h, x, y + h - ry * bci, x, y + h - ry);
634
+ } // back to top left
635
+
636
+
637
+ path.lineTo(x, y + ry);
638
+
639
+ if (rx !== 0 || ry !== 0) {
640
+ path.bezierCurveTo(x, y + ry * bci, x + rx * bci, y, x + rx, y);
641
+ }
642
+
643
+ return path;
644
+ }
645
+
646
+ function parsePolygonNode(node) {
647
+ function iterator(match, a, b) {
648
+ var x = parseFloatWithUnits(a);
649
+ var y = parseFloatWithUnits(b);
650
+
651
+ if (index === 0) {
652
+ path.moveTo(x, y);
653
+ } else {
654
+ path.lineTo(x, y);
655
+ }
656
+
657
+ index++;
658
+ }
659
+
660
+ var regex = /(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g;
661
+ var path = new _three.ShapePath();
662
+ var index = 0;
663
+ node.getAttribute('points').replace(regex, iterator);
664
+ path.currentPath.autoClose = true;
665
+ return path;
666
+ }
667
+
668
+ function parsePolylineNode(node) {
669
+ function iterator(match, a, b) {
670
+ var x = parseFloatWithUnits(a);
671
+ var y = parseFloatWithUnits(b);
672
+
673
+ if (index === 0) {
674
+ path.moveTo(x, y);
675
+ } else {
676
+ path.lineTo(x, y);
677
+ }
678
+
679
+ index++;
680
+ }
681
+
682
+ var regex = /(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g;
683
+ var path = new _three.ShapePath();
684
+ var index = 0;
685
+ node.getAttribute('points').replace(regex, iterator);
686
+ path.currentPath.autoClose = false;
687
+ return path;
688
+ }
689
+
690
+ function parseCircleNode(node) {
691
+ var x = parseFloatWithUnits(node.getAttribute('cx') || 0);
692
+ var y = parseFloatWithUnits(node.getAttribute('cy') || 0);
693
+ var r = parseFloatWithUnits(node.getAttribute('r') || 0);
694
+ var subpath = new _three.Path();
695
+ subpath.absarc(x, y, r, 0, Math.PI * 2);
696
+ var path = new _three.ShapePath();
697
+ path.subPaths.push(subpath);
698
+ return path;
699
+ }
700
+
701
+ function parseEllipseNode(node) {
702
+ var x = parseFloatWithUnits(node.getAttribute('cx') || 0);
703
+ var y = parseFloatWithUnits(node.getAttribute('cy') || 0);
704
+ var rx = parseFloatWithUnits(node.getAttribute('rx') || 0);
705
+ var ry = parseFloatWithUnits(node.getAttribute('ry') || 0);
706
+ var subpath = new _three.Path();
707
+ subpath.absellipse(x, y, rx, ry, 0, Math.PI * 2);
708
+ var path = new _three.ShapePath();
709
+ path.subPaths.push(subpath);
710
+ return path;
711
+ }
712
+
713
+ function parseLineNode(node) {
714
+ var x1 = parseFloatWithUnits(node.getAttribute('x1') || 0);
715
+ var y1 = parseFloatWithUnits(node.getAttribute('y1') || 0);
716
+ var x2 = parseFloatWithUnits(node.getAttribute('x2') || 0);
717
+ var y2 = parseFloatWithUnits(node.getAttribute('y2') || 0);
718
+ var path = new _three.ShapePath();
719
+ path.moveTo(x1, y1);
720
+ path.lineTo(x2, y2);
721
+ path.currentPath.autoClose = false;
722
+ return path;
723
+ } //
724
+
725
+
726
+ function parseStyle(node, style) {
727
+ style = Object.assign({}, style); // clone style
728
+
729
+ var stylesheetStyles = {};
730
+
731
+ if (node.hasAttribute('class')) {
732
+ var classSelectors = node.getAttribute('class').split(/\s/).filter(Boolean).map(function (i) {
733
+ return i.trim();
734
+ });
735
+
736
+ for (var i = 0; i < classSelectors.length; i++) {
737
+ stylesheetStyles = Object.assign(stylesheetStyles, stylesheets['.' + classSelectors[i]]);
738
+ }
739
+ }
740
+
741
+ if (node.hasAttribute('id')) {
742
+ stylesheetStyles = Object.assign(stylesheetStyles, stylesheets['#' + node.getAttribute('id')]);
743
+ }
744
+
745
+ function addStyle(svgName, jsName, adjustFunction) {
746
+ if (adjustFunction === undefined) adjustFunction = function copy(v) {
747
+ if (v.startsWith('url')) console.warn('SVGLoader: url access in attributes is not implemented.');
748
+ return v;
749
+ };
750
+ if (node.hasAttribute(svgName)) style[jsName] = adjustFunction(node.getAttribute(svgName));
751
+ if (stylesheetStyles[svgName]) style[jsName] = adjustFunction(stylesheetStyles[svgName]);
752
+ if (node.style && node.style[svgName] !== '') style[jsName] = adjustFunction(node.style[svgName]);
753
+ }
754
+
755
+ function clamp(v) {
756
+ return Math.max(0, Math.min(1, parseFloatWithUnits(v)));
757
+ }
758
+
759
+ function positive(v) {
760
+ return Math.max(0, parseFloatWithUnits(v));
761
+ }
762
+
763
+ addStyle('fill', 'fill');
764
+ addStyle('fill-opacity', 'fillOpacity', clamp);
765
+ addStyle('fill-rule', 'fillRule');
766
+ addStyle('opacity', 'opacity', clamp);
767
+ addStyle('stroke', 'stroke');
768
+ addStyle('stroke-opacity', 'strokeOpacity', clamp);
769
+ addStyle('stroke-width', 'strokeWidth', positive);
770
+ addStyle('stroke-linejoin', 'strokeLineJoin');
771
+ addStyle('stroke-linecap', 'strokeLineCap');
772
+ addStyle('stroke-miterlimit', 'strokeMiterLimit', positive);
773
+ addStyle('visibility', 'visibility');
774
+ return style;
775
+ } // http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes
776
+
777
+
778
+ function getReflection(a, b) {
779
+ return a - (b - a);
780
+ } // from https://github.com/ppvg/svg-numbers (MIT License)
781
+
782
+
783
+ function parseFloats(input, flags, stride) {
784
+ if (typeof input !== 'string') {
785
+ throw new TypeError('Invalid input: ' + typeof input);
786
+ } // Character groups
787
+
788
+
789
+ var RE = {
790
+ SEPARATOR: /[ \t\r\n\,.\-+]/,
791
+ WHITESPACE: /[ \t\r\n]/,
792
+ DIGIT: /[\d]/,
793
+ SIGN: /[-+]/,
794
+ POINT: /\./,
795
+ COMMA: /,/,
796
+ EXP: /e/i,
797
+ FLAGS: /[01]/
798
+ }; // States
799
+
800
+ var SEP = 0;
801
+ var INT = 1;
802
+ var FLOAT = 2;
803
+ var EXP = 3;
804
+ var state = SEP;
805
+ var seenComma = true;
806
+ var number = '',
807
+ exponent = '';
808
+ var result = [];
809
+
810
+ function throwSyntaxError(current, i, partial) {
811
+ var error = new SyntaxError('Unexpected character "' + current + '" at index ' + i + '.');
812
+ error.partial = partial;
813
+ throw error;
814
+ }
815
+
816
+ function newNumber() {
817
+ if (number !== '') {
818
+ if (exponent === '') result.push(Number(number));else result.push(Number(number) * Math.pow(10, Number(exponent)));
819
+ }
820
+
821
+ number = '';
822
+ exponent = '';
823
+ }
824
+
825
+ var current;
826
+ var length = input.length;
827
+
828
+ for (var i = 0; i < length; i++) {
829
+ current = input[i]; // check for flags
830
+
831
+ if (Array.isArray(flags) && flags.includes(result.length % stride) && RE.FLAGS.test(current)) {
832
+ state = INT;
833
+ number = current;
834
+ newNumber();
835
+ continue;
836
+ } // parse until next number
837
+
838
+
839
+ if (state === SEP) {
840
+ // eat whitespace
841
+ if (RE.WHITESPACE.test(current)) {
842
+ continue;
843
+ } // start new number
844
+
845
+
846
+ if (RE.DIGIT.test(current) || RE.SIGN.test(current)) {
847
+ state = INT;
848
+ number = current;
849
+ continue;
850
+ }
851
+
852
+ if (RE.POINT.test(current)) {
853
+ state = FLOAT;
854
+ number = current;
855
+ continue;
856
+ } // throw on double commas (e.g. "1, , 2")
857
+
858
+
859
+ if (RE.COMMA.test(current)) {
860
+ if (seenComma) {
861
+ throwSyntaxError(current, i, result);
862
+ }
863
+
864
+ seenComma = true;
865
+ }
866
+ } // parse integer part
867
+
868
+
869
+ if (state === INT) {
870
+ if (RE.DIGIT.test(current)) {
871
+ number += current;
872
+ continue;
873
+ }
874
+
875
+ if (RE.POINT.test(current)) {
876
+ number += current;
877
+ state = FLOAT;
878
+ continue;
879
+ }
880
+
881
+ if (RE.EXP.test(current)) {
882
+ state = EXP;
883
+ continue;
884
+ } // throw on double signs ("-+1"), but not on sign as separator ("-1-2")
885
+
886
+
887
+ if (RE.SIGN.test(current) && number.length === 1 && RE.SIGN.test(number[0])) {
888
+ throwSyntaxError(current, i, result);
889
+ }
890
+ } // parse decimal part
891
+
892
+
893
+ if (state === FLOAT) {
894
+ if (RE.DIGIT.test(current)) {
895
+ number += current;
896
+ continue;
897
+ }
898
+
899
+ if (RE.EXP.test(current)) {
900
+ state = EXP;
901
+ continue;
902
+ } // throw on double decimal points (e.g. "1..2")
903
+
904
+
905
+ if (RE.POINT.test(current) && number[number.length - 1] === '.') {
906
+ throwSyntaxError(current, i, result);
907
+ }
908
+ } // parse exponent part
909
+
910
+
911
+ if (state === EXP) {
912
+ if (RE.DIGIT.test(current)) {
913
+ exponent += current;
914
+ continue;
915
+ }
916
+
917
+ if (RE.SIGN.test(current)) {
918
+ if (exponent === '') {
919
+ exponent += current;
920
+ continue;
921
+ }
922
+
923
+ if (exponent.length === 1 && RE.SIGN.test(exponent)) {
924
+ throwSyntaxError(current, i, result);
925
+ }
926
+ }
927
+ } // end of number
928
+
929
+
930
+ if (RE.WHITESPACE.test(current)) {
931
+ newNumber();
932
+ state = SEP;
933
+ seenComma = false;
934
+ } else if (RE.COMMA.test(current)) {
935
+ newNumber();
936
+ state = SEP;
937
+ seenComma = true;
938
+ } else if (RE.SIGN.test(current)) {
939
+ newNumber();
940
+ state = INT;
941
+ number = current;
942
+ } else if (RE.POINT.test(current)) {
943
+ newNumber();
944
+ state = FLOAT;
945
+ number = current;
946
+ } else {
947
+ throwSyntaxError(current, i, result);
948
+ }
949
+ } // add the last number found (if any)
950
+
951
+
952
+ newNumber();
953
+ return result;
954
+ } // Units
955
+
956
+
957
+ var units = ['mm', 'cm', 'in', 'pt', 'pc', 'px']; // Conversion: [ fromUnit ][ toUnit ] (-1 means dpi dependent)
958
+
959
+ var unitConversion = {
960
+ 'mm': {
961
+ 'mm': 1,
962
+ 'cm': 0.1,
963
+ 'in': 1 / 25.4,
964
+ 'pt': 72 / 25.4,
965
+ 'pc': 6 / 25.4,
966
+ 'px': -1
967
+ },
968
+ 'cm': {
969
+ 'mm': 10,
970
+ 'cm': 1,
971
+ 'in': 1 / 2.54,
972
+ 'pt': 72 / 2.54,
973
+ 'pc': 6 / 2.54,
974
+ 'px': -1
975
+ },
976
+ 'in': {
977
+ 'mm': 25.4,
978
+ 'cm': 2.54,
979
+ 'in': 1,
980
+ 'pt': 72,
981
+ 'pc': 6,
982
+ 'px': -1
983
+ },
984
+ 'pt': {
985
+ 'mm': 25.4 / 72,
986
+ 'cm': 2.54 / 72,
987
+ 'in': 1 / 72,
988
+ 'pt': 1,
989
+ 'pc': 6 / 72,
990
+ 'px': -1
991
+ },
992
+ 'pc': {
993
+ 'mm': 25.4 / 6,
994
+ 'cm': 2.54 / 6,
995
+ 'in': 1 / 6,
996
+ 'pt': 72 / 6,
997
+ 'pc': 1,
998
+ 'px': -1
999
+ },
1000
+ 'px': {
1001
+ 'px': 1
1002
+ }
1003
+ };
1004
+
1005
+ function parseFloatWithUnits(string) {
1006
+ var theUnit = 'px';
1007
+
1008
+ if (typeof string === 'string' || string instanceof String) {
1009
+ for (var i = 0, n = units.length; i < n; i++) {
1010
+ var u = units[i];
1011
+
1012
+ if (string.endsWith(u)) {
1013
+ theUnit = u;
1014
+ string = string.substring(0, string.length - u.length);
1015
+ break;
1016
+ }
1017
+ }
1018
+ }
1019
+
1020
+ var scale = undefined;
1021
+
1022
+ if (theUnit === 'px' && scope.defaultUnit !== 'px') {
1023
+ // Conversion scale from pixels to inches, then to default units
1024
+ scale = unitConversion['in'][scope.defaultUnit] / scope.defaultDPI;
1025
+ } else {
1026
+ scale = unitConversion[theUnit][scope.defaultUnit];
1027
+
1028
+ if (scale < 0) {
1029
+ // Conversion scale to pixels
1030
+ scale = unitConversion[theUnit]['in'] * scope.defaultDPI;
1031
+ }
1032
+ }
1033
+
1034
+ return scale * parseFloat(string);
1035
+ } // Transforms
1036
+
1037
+
1038
+ function getNodeTransform(node) {
1039
+ if (!(node.hasAttribute('transform') || node.nodeName === 'use' && (node.hasAttribute('x') || node.hasAttribute('y')))) {
1040
+ return null;
1041
+ }
1042
+
1043
+ var transform = parseNodeTransform(node);
1044
+
1045
+ if (transformStack.length > 0) {
1046
+ transform.premultiply(transformStack[transformStack.length - 1]);
1047
+ }
1048
+
1049
+ currentTransform.copy(transform);
1050
+ transformStack.push(transform);
1051
+ return transform;
1052
+ }
1053
+
1054
+ function parseNodeTransform(node) {
1055
+ var transform = new _three.Matrix3();
1056
+ var currentTransform = tempTransform0;
1057
+
1058
+ if (node.nodeName === 'use' && (node.hasAttribute('x') || node.hasAttribute('y'))) {
1059
+ var tx = parseFloatWithUnits(node.getAttribute('x'));
1060
+ var ty = parseFloatWithUnits(node.getAttribute('y'));
1061
+ transform.translate(tx, ty);
1062
+ }
1063
+
1064
+ if (node.hasAttribute('transform')) {
1065
+ var transformsTexts = node.getAttribute('transform').split(')');
1066
+
1067
+ for (var tIndex = transformsTexts.length - 1; tIndex >= 0; tIndex--) {
1068
+ var transformText = transformsTexts[tIndex].trim();
1069
+ if (transformText === '') continue;
1070
+ var openParPos = transformText.indexOf('(');
1071
+ var closeParPos = transformText.length;
1072
+
1073
+ if (openParPos > 0 && openParPos < closeParPos) {
1074
+ var transformType = transformText.substr(0, openParPos);
1075
+ var array = parseFloats(transformText.substr(openParPos + 1, closeParPos - openParPos - 1));
1076
+ currentTransform.identity();
1077
+
1078
+ switch (transformType) {
1079
+ case 'translate':
1080
+ if (array.length >= 1) {
1081
+ var _tx = array[0];
1082
+ var _ty = _tx;
1083
+
1084
+ if (array.length >= 2) {
1085
+ _ty = array[1];
1086
+ }
1087
+
1088
+ currentTransform.translate(_tx, _ty);
1089
+ }
1090
+
1091
+ break;
1092
+
1093
+ case 'rotate':
1094
+ if (array.length >= 1) {
1095
+ var angle = 0;
1096
+ var cx = 0;
1097
+ var cy = 0; // Angle
1098
+
1099
+ angle = -array[0] * Math.PI / 180;
1100
+
1101
+ if (array.length >= 3) {
1102
+ // Center x, y
1103
+ cx = array[1];
1104
+ cy = array[2];
1105
+ } // Rotate around center (cx, cy)
1106
+
1107
+
1108
+ tempTransform1.identity().translate(-cx, -cy);
1109
+ tempTransform2.identity().rotate(angle);
1110
+ tempTransform3.multiplyMatrices(tempTransform2, tempTransform1);
1111
+ tempTransform1.identity().translate(cx, cy);
1112
+ currentTransform.multiplyMatrices(tempTransform1, tempTransform3);
1113
+ }
1114
+
1115
+ break;
1116
+
1117
+ case 'scale':
1118
+ if (array.length >= 1) {
1119
+ var scaleX = array[0];
1120
+ var scaleY = scaleX;
1121
+
1122
+ if (array.length >= 2) {
1123
+ scaleY = array[1];
1124
+ }
1125
+
1126
+ currentTransform.scale(scaleX, scaleY);
1127
+ }
1128
+
1129
+ break;
1130
+
1131
+ case 'skewX':
1132
+ if (array.length === 1) {
1133
+ currentTransform.set(1, Math.tan(array[0] * Math.PI / 180), 0, 0, 1, 0, 0, 0, 1);
1134
+ }
1135
+
1136
+ break;
1137
+
1138
+ case 'skewY':
1139
+ if (array.length === 1) {
1140
+ currentTransform.set(1, 0, 0, Math.tan(array[0] * Math.PI / 180), 1, 0, 0, 0, 1);
1141
+ }
1142
+
1143
+ break;
1144
+
1145
+ case 'matrix':
1146
+ if (array.length === 6) {
1147
+ currentTransform.set(array[0], array[2], array[4], array[1], array[3], array[5], 0, 0, 1);
1148
+ }
1149
+
1150
+ break;
1151
+ }
1152
+ }
1153
+
1154
+ transform.premultiply(currentTransform);
1155
+ }
1156
+ }
1157
+
1158
+ return transform;
1159
+ }
1160
+
1161
+ function transformPath(path, m) {
1162
+ function transfVec2(v2) {
1163
+ tempV3.set(v2.x, v2.y, 1).applyMatrix3(m);
1164
+ v2.set(tempV3.x, tempV3.y);
1165
+ }
1166
+
1167
+ var isRotated = isTransformRotated(m);
1168
+ var subPaths = path.subPaths;
1169
+
1170
+ for (var i = 0, n = subPaths.length; i < n; i++) {
1171
+ var subPath = subPaths[i];
1172
+ var curves = subPath.curves;
1173
+
1174
+ for (var j = 0; j < curves.length; j++) {
1175
+ var curve = curves[j];
1176
+
1177
+ if (curve.isLineCurve) {
1178
+ transfVec2(curve.v1);
1179
+ transfVec2(curve.v2);
1180
+ } else if (curve.isCubicBezierCurve) {
1181
+ transfVec2(curve.v0);
1182
+ transfVec2(curve.v1);
1183
+ transfVec2(curve.v2);
1184
+ transfVec2(curve.v3);
1185
+ } else if (curve.isQuadraticBezierCurve) {
1186
+ transfVec2(curve.v0);
1187
+ transfVec2(curve.v1);
1188
+ transfVec2(curve.v2);
1189
+ } else if (curve.isEllipseCurve) {
1190
+ if (isRotated) {
1191
+ console.warn('SVGLoader: Elliptic arc or ellipse rotation or skewing is not implemented.');
1192
+ }
1193
+
1194
+ tempV2.set(curve.aX, curve.aY);
1195
+ transfVec2(tempV2);
1196
+ curve.aX = tempV2.x;
1197
+ curve.aY = tempV2.y;
1198
+ curve.xRadius *= getTransformScaleX(m);
1199
+ curve.yRadius *= getTransformScaleY(m);
1200
+ }
1201
+ }
1202
+ }
1203
+ }
1204
+
1205
+ function isTransformRotated(m) {
1206
+ return m.elements[1] !== 0 || m.elements[3] !== 0;
1207
+ }
1208
+
1209
+ function getTransformScaleX(m) {
1210
+ var te = m.elements;
1211
+ return Math.sqrt(te[0] * te[0] + te[1] * te[1]);
1212
+ }
1213
+
1214
+ function getTransformScaleY(m) {
1215
+ var te = m.elements;
1216
+ return Math.sqrt(te[3] * te[3] + te[4] * te[4]);
1217
+ } //
1218
+
1219
+
1220
+ var paths = [];
1221
+ var stylesheets = {};
1222
+ var transformStack = [];
1223
+ var tempTransform0 = new _three.Matrix3();
1224
+ var tempTransform1 = new _three.Matrix3();
1225
+ var tempTransform2 = new _three.Matrix3();
1226
+ var tempTransform3 = new _three.Matrix3();
1227
+ var tempV2 = new _three.Vector2();
1228
+ var tempV3 = new _three.Vector3();
1229
+ var currentTransform = new _three.Matrix3();
1230
+ var xml = new DOMParser().parseFromString(text, 'image/svg+xml'); // application/xml
1231
+
1232
+ parseNode(xml.documentElement, {
1233
+ fill: '#000',
1234
+ fillOpacity: 1,
1235
+ strokeOpacity: 1,
1236
+ strokeWidth: 1,
1237
+ strokeLineJoin: 'miter',
1238
+ strokeLineCap: 'butt',
1239
+ strokeMiterLimit: 4
1240
+ });
1241
+ var data = {
1242
+ paths: paths,
1243
+ xml: xml.documentElement
1244
+ }; // console.log( paths );
1245
+
1246
+ return data;
1247
+ }
1248
+ }], [{
1249
+ key: "createShapes",
1250
+ value: function createShapes(shapePath) {
1251
+ // Param shapePath: a shapepath as returned by the parse function of this class
1252
+ // Returns Shape object
1253
+ var BIGNUMBER = 999999999;
1254
+ var IntersectionLocationType = {
1255
+ ORIGIN: 0,
1256
+ DESTINATION: 1,
1257
+ BETWEEN: 2,
1258
+ LEFT: 3,
1259
+ RIGHT: 4,
1260
+ BEHIND: 5,
1261
+ BEYOND: 6
1262
+ };
1263
+ var classifyResult = {
1264
+ loc: IntersectionLocationType.ORIGIN,
1265
+ t: 0
1266
+ };
1267
+
1268
+ function findEdgeIntersection(a0, a1, b0, b1) {
1269
+ var x1 = a0.x;
1270
+ var x2 = a1.x;
1271
+ var x3 = b0.x;
1272
+ var x4 = b1.x;
1273
+ var y1 = a0.y;
1274
+ var y2 = a1.y;
1275
+ var y3 = b0.y;
1276
+ var y4 = b1.y;
1277
+ var nom1 = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
1278
+ var nom2 = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
1279
+ var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
1280
+ var t1 = nom1 / denom;
1281
+ var t2 = nom2 / denom;
1282
+
1283
+ if (denom === 0 && nom1 !== 0 || t1 <= 0 || t1 >= 1 || t2 < 0 || t2 > 1) {
1284
+ //1. lines are parallel or edges don't intersect
1285
+ return null;
1286
+ } else if (nom1 === 0 && denom === 0) {
1287
+ //2. lines are colinear
1288
+ //check if endpoints of edge2 (b0-b1) lies on edge1 (a0-a1)
1289
+ for (var i = 0; i < 2; i++) {
1290
+ classifyPoint(i === 0 ? b0 : b1, a0, a1); //find position of this endpoints relatively to edge1
1291
+
1292
+ if (classifyResult.loc == IntersectionLocationType.ORIGIN) {
1293
+ var point = i === 0 ? b0 : b1;
1294
+ return {
1295
+ x: point.x,
1296
+ y: point.y,
1297
+ t: classifyResult.t
1298
+ };
1299
+ } else if (classifyResult.loc == IntersectionLocationType.BETWEEN) {
1300
+ var x = +(x1 + classifyResult.t * (x2 - x1)).toPrecision(10);
1301
+ var y = +(y1 + classifyResult.t * (y2 - y1)).toPrecision(10);
1302
+ return {
1303
+ x: x,
1304
+ y: y,
1305
+ t: classifyResult.t
1306
+ };
1307
+ }
1308
+ }
1309
+
1310
+ return null;
1311
+ } else {
1312
+ //3. edges intersect
1313
+ for (var _i = 0; _i < 2; _i++) {
1314
+ classifyPoint(_i === 0 ? b0 : b1, a0, a1);
1315
+
1316
+ if (classifyResult.loc == IntersectionLocationType.ORIGIN) {
1317
+ var _point = _i === 0 ? b0 : b1;
1318
+
1319
+ return {
1320
+ x: _point.x,
1321
+ y: _point.y,
1322
+ t: classifyResult.t
1323
+ };
1324
+ }
1325
+ }
1326
+
1327
+ var _x = +(x1 + t1 * (x2 - x1)).toPrecision(10);
1328
+
1329
+ var _y = +(y1 + t1 * (y2 - y1)).toPrecision(10);
1330
+
1331
+ return {
1332
+ x: _x,
1333
+ y: _y,
1334
+ t: t1
1335
+ };
1336
+ }
1337
+ }
1338
+
1339
+ function classifyPoint(p, edgeStart, edgeEnd) {
1340
+ var ax = edgeEnd.x - edgeStart.x;
1341
+ var ay = edgeEnd.y - edgeStart.y;
1342
+ var bx = p.x - edgeStart.x;
1343
+ var by = p.y - edgeStart.y;
1344
+ var sa = ax * by - bx * ay;
1345
+
1346
+ if (p.x === edgeStart.x && p.y === edgeStart.y) {
1347
+ classifyResult.loc = IntersectionLocationType.ORIGIN;
1348
+ classifyResult.t = 0;
1349
+ return;
1350
+ }
1351
+
1352
+ if (p.x === edgeEnd.x && p.y === edgeEnd.y) {
1353
+ classifyResult.loc = IntersectionLocationType.DESTINATION;
1354
+ classifyResult.t = 1;
1355
+ return;
1356
+ }
1357
+
1358
+ if (sa < -Number.EPSILON) {
1359
+ classifyResult.loc = IntersectionLocationType.LEFT;
1360
+ return;
1361
+ }
1362
+
1363
+ if (sa > Number.EPSILON) {
1364
+ classifyResult.loc = IntersectionLocationType.RIGHT;
1365
+ return;
1366
+ }
1367
+
1368
+ if (ax * bx < 0 || ay * by < 0) {
1369
+ classifyResult.loc = IntersectionLocationType.BEHIND;
1370
+ return;
1371
+ }
1372
+
1373
+ if (Math.sqrt(ax * ax + ay * ay) < Math.sqrt(bx * bx + by * by)) {
1374
+ classifyResult.loc = IntersectionLocationType.BEYOND;
1375
+ return;
1376
+ }
1377
+
1378
+ var t;
1379
+
1380
+ if (ax !== 0) {
1381
+ t = bx / ax;
1382
+ } else {
1383
+ t = by / ay;
1384
+ }
1385
+
1386
+ classifyResult.loc = IntersectionLocationType.BETWEEN;
1387
+ classifyResult.t = t;
1388
+ }
1389
+
1390
+ function getIntersections(path1, path2) {
1391
+ var intersectionsRaw = [];
1392
+ var intersections = [];
1393
+
1394
+ for (var index = 1; index < path1.length; index++) {
1395
+ var path1EdgeStart = path1[index - 1];
1396
+ var path1EdgeEnd = path1[index];
1397
+
1398
+ var _loop = function _loop(index2) {
1399
+ var path2EdgeStart = path2[index2 - 1];
1400
+ var path2EdgeEnd = path2[index2];
1401
+ var intersection = findEdgeIntersection(path1EdgeStart, path1EdgeEnd, path2EdgeStart, path2EdgeEnd);
1402
+
1403
+ if (intersection !== null && intersectionsRaw.find(function (i) {
1404
+ return i.t <= intersection.t + Number.EPSILON && i.t >= intersection.t - Number.EPSILON;
1405
+ }) === undefined) {
1406
+ intersectionsRaw.push(intersection);
1407
+ intersections.push(new _three.Vector2(intersection.x, intersection.y));
1408
+ }
1409
+ };
1410
+
1411
+ for (var index2 = 1; index2 < path2.length; index2++) {
1412
+ _loop(index2);
1413
+ }
1414
+ }
1415
+
1416
+ return intersections;
1417
+ }
1418
+
1419
+ function getScanlineIntersections(scanline, boundingBox, paths) {
1420
+ var center = new _three.Vector2();
1421
+ boundingBox.getCenter(center);
1422
+ var allIntersections = [];
1423
+ paths.forEach(function (path) {
1424
+ // check if the center of the bounding box is in the bounding box of the paths.
1425
+ // this is a pruning method to limit the search of intersections in paths that can't envelop of the current path.
1426
+ // if a path envelops another path. The center of that oter path, has to be inside the bounding box of the enveloping path.
1427
+ if (path.boundingBox.containsPoint(center)) {
1428
+ var intersections = getIntersections(scanline, path.points);
1429
+ intersections.forEach(function (p) {
1430
+ allIntersections.push({
1431
+ identifier: path.identifier,
1432
+ isCW: path.isCW,
1433
+ point: p
1434
+ });
1435
+ });
1436
+ }
1437
+ });
1438
+ allIntersections.sort(function (i1, i2) {
1439
+ return i1.point.x - i2.point.x;
1440
+ });
1441
+ return allIntersections;
1442
+ }
1443
+
1444
+ function isHoleTo(simplePath, allPaths, scanlineMinX, scanlineMaxX, _fillRule) {
1445
+ if (_fillRule === null || _fillRule === undefined || _fillRule === '') {
1446
+ _fillRule = 'nonzero';
1447
+ }
1448
+
1449
+ var centerBoundingBox = new _three.Vector2();
1450
+ simplePath.boundingBox.getCenter(centerBoundingBox);
1451
+ var scanline = [new _three.Vector2(scanlineMinX, centerBoundingBox.y), new _three.Vector2(scanlineMaxX, centerBoundingBox.y)];
1452
+ var scanlineIntersections = getScanlineIntersections(scanline, simplePath.boundingBox, allPaths);
1453
+ scanlineIntersections.sort(function (i1, i2) {
1454
+ return i1.point.x - i2.point.x;
1455
+ });
1456
+ var baseIntersections = [];
1457
+ var otherIntersections = [];
1458
+ scanlineIntersections.forEach(function (i) {
1459
+ if (i.identifier === simplePath.identifier) {
1460
+ baseIntersections.push(i);
1461
+ } else {
1462
+ otherIntersections.push(i);
1463
+ }
1464
+ });
1465
+ var firstXOfPath = baseIntersections[0].point.x; // build up the path hierarchy
1466
+
1467
+ var stack = [];
1468
+ var i = 0;
1469
+
1470
+ while (i < otherIntersections.length && otherIntersections[i].point.x < firstXOfPath) {
1471
+ if (stack.length > 0 && stack[stack.length - 1] === otherIntersections[i].identifier) {
1472
+ stack.pop();
1473
+ } else {
1474
+ stack.push(otherIntersections[i].identifier);
1475
+ }
1476
+
1477
+ i++;
1478
+ }
1479
+
1480
+ stack.push(simplePath.identifier);
1481
+
1482
+ if (_fillRule === 'evenodd') {
1483
+ var isHole = stack.length % 2 === 0 ? true : false;
1484
+ var isHoleFor = stack[stack.length - 2];
1485
+ return {
1486
+ identifier: simplePath.identifier,
1487
+ isHole: isHole,
1488
+ for: isHoleFor
1489
+ };
1490
+ } else if (_fillRule === 'nonzero') {
1491
+ // check if path is a hole by counting the amount of paths with alternating rotations it has to cross.
1492
+ var _isHole = true;
1493
+ var _isHoleFor = null;
1494
+ var lastCWValue = null;
1495
+
1496
+ for (var _i2 = 0; _i2 < stack.length; _i2++) {
1497
+ var _identifier = stack[_i2];
1498
+
1499
+ if (_isHole) {
1500
+ lastCWValue = allPaths[_identifier].isCW;
1501
+ _isHole = false;
1502
+ _isHoleFor = _identifier;
1503
+ } else if (lastCWValue !== allPaths[_identifier].isCW) {
1504
+ lastCWValue = allPaths[_identifier].isCW;
1505
+ _isHole = true;
1506
+ }
1507
+ }
1508
+
1509
+ return {
1510
+ identifier: simplePath.identifier,
1511
+ isHole: _isHole,
1512
+ for: _isHoleFor
1513
+ };
1514
+ } else {
1515
+ console.warn('fill-rule: "' + _fillRule + '" is currently not implemented.');
1516
+ }
1517
+ } // check for self intersecting paths
1518
+ // TODO
1519
+ // check intersecting paths
1520
+ // TODO
1521
+ // prepare paths for hole detection
1522
+
1523
+
1524
+ var identifier = 0;
1525
+ var scanlineMinX = BIGNUMBER;
1526
+ var scanlineMaxX = -BIGNUMBER;
1527
+ var simplePaths = shapePath.subPaths.map(function (p) {
1528
+ var points = p.getPoints();
1529
+ var maxY = -BIGNUMBER;
1530
+ var minY = BIGNUMBER;
1531
+ var maxX = -BIGNUMBER;
1532
+ var minX = BIGNUMBER; //points.forEach(p => p.y *= -1);
1533
+
1534
+ for (var i = 0; i < points.length; i++) {
1535
+ var _p = points[i];
1536
+
1537
+ if (_p.y > maxY) {
1538
+ maxY = _p.y;
1539
+ }
1540
+
1541
+ if (_p.y < minY) {
1542
+ minY = _p.y;
1543
+ }
1544
+
1545
+ if (_p.x > maxX) {
1546
+ maxX = _p.x;
1547
+ }
1548
+
1549
+ if (_p.x < minX) {
1550
+ minX = _p.x;
1551
+ }
1552
+ } //
1553
+
1554
+
1555
+ if (scanlineMaxX <= maxX) {
1556
+ scanlineMaxX = maxX + 1;
1557
+ }
1558
+
1559
+ if (scanlineMinX >= minX) {
1560
+ scanlineMinX = minX - 1;
1561
+ }
1562
+
1563
+ return {
1564
+ curves: p.curves,
1565
+ points: points,
1566
+ isCW: _three.ShapeUtils.isClockWise(points),
1567
+ identifier: identifier++,
1568
+ boundingBox: new _three.Box2(new _three.Vector2(minX, minY), new _three.Vector2(maxX, maxY))
1569
+ };
1570
+ });
1571
+ simplePaths = simplePaths.filter(function (sp) {
1572
+ return sp.points.length > 1;
1573
+ }); // check if path is solid or a hole
1574
+
1575
+ var isAHole = simplePaths.map(function (p) {
1576
+ return isHoleTo(p, simplePaths, scanlineMinX, scanlineMaxX, shapePath.userData.style.fillRule);
1577
+ });
1578
+ var shapesToReturn = [];
1579
+ simplePaths.forEach(function (p) {
1580
+ var amIAHole = isAHole[p.identifier];
1581
+
1582
+ if (!amIAHole.isHole) {
1583
+ var shape = new _three.Shape();
1584
+ shape.curves = p.curves;
1585
+ var holes = isAHole.filter(function (h) {
1586
+ return h.isHole && h.for === p.identifier;
1587
+ });
1588
+ holes.forEach(function (h) {
1589
+ var hole = simplePaths[h.identifier];
1590
+ var path = new _three.Path();
1591
+ path.curves = hole.curves;
1592
+ shape.holes.push(path);
1593
+ });
1594
+ shapesToReturn.push(shape);
1595
+ }
1596
+ });
1597
+ return shapesToReturn;
1598
+ }
1599
+ }, {
1600
+ key: "getStrokeStyle",
1601
+ value: function getStrokeStyle(width, color, lineJoin, lineCap, miterLimit) {
1602
+ // Param width: Stroke width
1603
+ // Param color: As returned by THREE.Color.getStyle()
1604
+ // Param lineJoin: One of "round", "bevel", "miter" or "miter-limit"
1605
+ // Param lineCap: One of "round", "square" or "butt"
1606
+ // Param miterLimit: Maximum join length, in multiples of the "width" parameter (join is truncated if it exceeds that distance)
1607
+ // Returns style object
1608
+ width = width !== undefined ? width : 1;
1609
+ color = color !== undefined ? color : '#000';
1610
+ lineJoin = lineJoin !== undefined ? lineJoin : 'miter';
1611
+ lineCap = lineCap !== undefined ? lineCap : 'butt';
1612
+ miterLimit = miterLimit !== undefined ? miterLimit : 4;
1613
+ return {
1614
+ strokeColor: color,
1615
+ strokeWidth: width,
1616
+ strokeLineJoin: lineJoin,
1617
+ strokeLineCap: lineCap,
1618
+ strokeMiterLimit: miterLimit
1619
+ };
1620
+ }
1621
+ }, {
1622
+ key: "pointsToStroke",
1623
+ value: function pointsToStroke(points, style, arcDivisions, minDistance) {
1624
+ // Generates a stroke with some witdh around the given path.
1625
+ // The path can be open or closed (last point equals to first point)
1626
+ // Param points: Array of Vector2D (the path). Minimum 2 points.
1627
+ // Param style: Object with SVG properties as returned by SVGLoader.getStrokeStyle(), or SVGLoader.parse() in the path.userData.style object
1628
+ // Params arcDivisions: Arc divisions for round joins and endcaps. (Optional)
1629
+ // Param minDistance: Points closer to this distance will be merged. (Optional)
1630
+ // Returns BufferGeometry with stroke triangles (In plane z = 0). UV coordinates are generated ('u' along path. 'v' across it, from left to right)
1631
+ var vertices = [];
1632
+ var normals = [];
1633
+ var uvs = [];
1634
+
1635
+ if (SVGLoader.pointsToStrokeWithBuffers(points, style, arcDivisions, minDistance, vertices, normals, uvs) === 0) {
1636
+ return null;
1637
+ }
1638
+
1639
+ var geometry = new _three.BufferGeometry();
1640
+ geometry.setAttribute('position', new _three.Float32BufferAttribute(vertices, 3));
1641
+ geometry.setAttribute('normal', new _three.Float32BufferAttribute(normals, 3));
1642
+ geometry.setAttribute('uv', new _three.Float32BufferAttribute(uvs, 2));
1643
+ return geometry;
1644
+ }
1645
+ }, {
1646
+ key: "pointsToStrokeWithBuffers",
1647
+ value: function pointsToStrokeWithBuffers(points, style, arcDivisions, minDistance, vertices, normals, uvs, vertexOffset) {
1648
+ // This function can be called to update existing arrays or buffers.
1649
+ // Accepts same parameters as pointsToStroke, plus the buffers and optional offset.
1650
+ // Param vertexOffset: Offset vertices to start writing in the buffers (3 elements/vertex for vertices and normals, and 2 elements/vertex for uvs)
1651
+ // Returns number of written vertices / normals / uvs pairs
1652
+ // if 'vertices' parameter is undefined no triangles will be generated, but the returned vertices count will still be valid (useful to preallocate the buffers)
1653
+ // 'normals' and 'uvs' buffers are optional
1654
+ var tempV2_1 = new _three.Vector2();
1655
+ var tempV2_2 = new _three.Vector2();
1656
+ var tempV2_3 = new _three.Vector2();
1657
+ var tempV2_4 = new _three.Vector2();
1658
+ var tempV2_5 = new _three.Vector2();
1659
+ var tempV2_6 = new _three.Vector2();
1660
+ var tempV2_7 = new _three.Vector2();
1661
+ var lastPointL = new _three.Vector2();
1662
+ var lastPointR = new _three.Vector2();
1663
+ var point0L = new _three.Vector2();
1664
+ var point0R = new _three.Vector2();
1665
+ var currentPointL = new _three.Vector2();
1666
+ var currentPointR = new _three.Vector2();
1667
+ var nextPointL = new _three.Vector2();
1668
+ var nextPointR = new _three.Vector2();
1669
+ var innerPoint = new _three.Vector2();
1670
+ var outerPoint = new _three.Vector2();
1671
+ arcDivisions = arcDivisions !== undefined ? arcDivisions : 12;
1672
+ minDistance = minDistance !== undefined ? minDistance : 0.001;
1673
+ vertexOffset = vertexOffset !== undefined ? vertexOffset : 0; // First ensure there are no duplicated points
1674
+
1675
+ points = removeDuplicatedPoints(points);
1676
+ var numPoints = points.length;
1677
+ if (numPoints < 2) return 0;
1678
+ var isClosed = points[0].equals(points[numPoints - 1]);
1679
+ var currentPoint;
1680
+ var previousPoint = points[0];
1681
+ var nextPoint;
1682
+ var strokeWidth2 = style.strokeWidth / 2;
1683
+ var deltaU = 1 / (numPoints - 1);
1684
+ var u0 = 0,
1685
+ u1;
1686
+ var innerSideModified;
1687
+ var joinIsOnLeftSide;
1688
+ var isMiter;
1689
+ var initialJoinIsOnLeftSide = false;
1690
+ var numVertices = 0;
1691
+ var currentCoordinate = vertexOffset * 3;
1692
+ var currentCoordinateUV = vertexOffset * 2; // Get initial left and right stroke points
1693
+
1694
+ getNormal(points[0], points[1], tempV2_1).multiplyScalar(strokeWidth2);
1695
+ lastPointL.copy(points[0]).sub(tempV2_1);
1696
+ lastPointR.copy(points[0]).add(tempV2_1);
1697
+ point0L.copy(lastPointL);
1698
+ point0R.copy(lastPointR);
1699
+
1700
+ for (var iPoint = 1; iPoint < numPoints; iPoint++) {
1701
+ currentPoint = points[iPoint]; // Get next point
1702
+
1703
+ if (iPoint === numPoints - 1) {
1704
+ if (isClosed) {
1705
+ // Skip duplicated initial point
1706
+ nextPoint = points[1];
1707
+ } else nextPoint = undefined;
1708
+ } else {
1709
+ nextPoint = points[iPoint + 1];
1710
+ } // Normal of previous segment in tempV2_1
1711
+
1712
+
1713
+ var normal1 = tempV2_1;
1714
+ getNormal(previousPoint, currentPoint, normal1);
1715
+ tempV2_3.copy(normal1).multiplyScalar(strokeWidth2);
1716
+ currentPointL.copy(currentPoint).sub(tempV2_3);
1717
+ currentPointR.copy(currentPoint).add(tempV2_3);
1718
+ u1 = u0 + deltaU;
1719
+ innerSideModified = false;
1720
+
1721
+ if (nextPoint !== undefined) {
1722
+ // Normal of next segment in tempV2_2
1723
+ getNormal(currentPoint, nextPoint, tempV2_2);
1724
+ tempV2_3.copy(tempV2_2).multiplyScalar(strokeWidth2);
1725
+ nextPointL.copy(currentPoint).sub(tempV2_3);
1726
+ nextPointR.copy(currentPoint).add(tempV2_3);
1727
+ joinIsOnLeftSide = true;
1728
+ tempV2_3.subVectors(nextPoint, previousPoint);
1729
+
1730
+ if (normal1.dot(tempV2_3) < 0) {
1731
+ joinIsOnLeftSide = false;
1732
+ }
1733
+
1734
+ if (iPoint === 1) initialJoinIsOnLeftSide = joinIsOnLeftSide;
1735
+ tempV2_3.subVectors(nextPoint, currentPoint);
1736
+ tempV2_3.normalize();
1737
+ var dot = Math.abs(normal1.dot(tempV2_3)); // If path is straight, don't create join
1738
+
1739
+ if (dot !== 0) {
1740
+ // Compute inner and outer segment intersections
1741
+ var miterSide = strokeWidth2 / dot;
1742
+ tempV2_3.multiplyScalar(-miterSide);
1743
+ tempV2_4.subVectors(currentPoint, previousPoint);
1744
+ tempV2_5.copy(tempV2_4).setLength(miterSide).add(tempV2_3);
1745
+ innerPoint.copy(tempV2_5).negate();
1746
+ var miterLength2 = tempV2_5.length();
1747
+ var segmentLengthPrev = tempV2_4.length();
1748
+ tempV2_4.divideScalar(segmentLengthPrev);
1749
+ tempV2_6.subVectors(nextPoint, currentPoint);
1750
+ var segmentLengthNext = tempV2_6.length();
1751
+ tempV2_6.divideScalar(segmentLengthNext); // Check that previous and next segments doesn't overlap with the innerPoint of intersection
1752
+
1753
+ if (tempV2_4.dot(innerPoint) < segmentLengthPrev && tempV2_6.dot(innerPoint) < segmentLengthNext) {
1754
+ innerSideModified = true;
1755
+ }
1756
+
1757
+ outerPoint.copy(tempV2_5).add(currentPoint);
1758
+ innerPoint.add(currentPoint);
1759
+ isMiter = false;
1760
+
1761
+ if (innerSideModified) {
1762
+ if (joinIsOnLeftSide) {
1763
+ nextPointR.copy(innerPoint);
1764
+ currentPointR.copy(innerPoint);
1765
+ } else {
1766
+ nextPointL.copy(innerPoint);
1767
+ currentPointL.copy(innerPoint);
1768
+ }
1769
+ } else {
1770
+ // The segment triangles are generated here if there was overlapping
1771
+ makeSegmentTriangles();
1772
+ }
1773
+
1774
+ switch (style.strokeLineJoin) {
1775
+ case 'bevel':
1776
+ makeSegmentWithBevelJoin(joinIsOnLeftSide, innerSideModified, u1);
1777
+ break;
1778
+
1779
+ case 'round':
1780
+ // Segment triangles
1781
+ createSegmentTrianglesWithMiddleSection(joinIsOnLeftSide, innerSideModified); // Join triangles
1782
+
1783
+ if (joinIsOnLeftSide) {
1784
+ makeCircularSector(currentPoint, currentPointL, nextPointL, u1, 0);
1785
+ } else {
1786
+ makeCircularSector(currentPoint, nextPointR, currentPointR, u1, 1);
1787
+ }
1788
+
1789
+ break;
1790
+
1791
+ case 'miter':
1792
+ case 'miter-clip':
1793
+ default:
1794
+ var miterFraction = strokeWidth2 * style.strokeMiterLimit / miterLength2;
1795
+
1796
+ if (miterFraction < 1) {
1797
+ // The join miter length exceeds the miter limit
1798
+ if (style.strokeLineJoin !== 'miter-clip') {
1799
+ makeSegmentWithBevelJoin(joinIsOnLeftSide, innerSideModified, u1);
1800
+ break;
1801
+ } else {
1802
+ // Segment triangles
1803
+ createSegmentTrianglesWithMiddleSection(joinIsOnLeftSide, innerSideModified); // Miter-clip join triangles
1804
+
1805
+ if (joinIsOnLeftSide) {
1806
+ tempV2_6.subVectors(outerPoint, currentPointL).multiplyScalar(miterFraction).add(currentPointL);
1807
+ tempV2_7.subVectors(outerPoint, nextPointL).multiplyScalar(miterFraction).add(nextPointL);
1808
+ addVertex(currentPointL, u1, 0);
1809
+ addVertex(tempV2_6, u1, 0);
1810
+ addVertex(currentPoint, u1, 0.5);
1811
+ addVertex(currentPoint, u1, 0.5);
1812
+ addVertex(tempV2_6, u1, 0);
1813
+ addVertex(tempV2_7, u1, 0);
1814
+ addVertex(currentPoint, u1, 0.5);
1815
+ addVertex(tempV2_7, u1, 0);
1816
+ addVertex(nextPointL, u1, 0);
1817
+ } else {
1818
+ tempV2_6.subVectors(outerPoint, currentPointR).multiplyScalar(miterFraction).add(currentPointR);
1819
+ tempV2_7.subVectors(outerPoint, nextPointR).multiplyScalar(miterFraction).add(nextPointR);
1820
+ addVertex(currentPointR, u1, 1);
1821
+ addVertex(tempV2_6, u1, 1);
1822
+ addVertex(currentPoint, u1, 0.5);
1823
+ addVertex(currentPoint, u1, 0.5);
1824
+ addVertex(tempV2_6, u1, 1);
1825
+ addVertex(tempV2_7, u1, 1);
1826
+ addVertex(currentPoint, u1, 0.5);
1827
+ addVertex(tempV2_7, u1, 1);
1828
+ addVertex(nextPointR, u1, 1);
1829
+ }
1830
+ }
1831
+ } else {
1832
+ // Miter join segment triangles
1833
+ if (innerSideModified) {
1834
+ // Optimized segment + join triangles
1835
+ if (joinIsOnLeftSide) {
1836
+ addVertex(lastPointR, u0, 1);
1837
+ addVertex(lastPointL, u0, 0);
1838
+ addVertex(outerPoint, u1, 0);
1839
+ addVertex(lastPointR, u0, 1);
1840
+ addVertex(outerPoint, u1, 0);
1841
+ addVertex(innerPoint, u1, 1);
1842
+ } else {
1843
+ addVertex(lastPointR, u0, 1);
1844
+ addVertex(lastPointL, u0, 0);
1845
+ addVertex(outerPoint, u1, 1);
1846
+ addVertex(lastPointL, u0, 0);
1847
+ addVertex(innerPoint, u1, 0);
1848
+ addVertex(outerPoint, u1, 1);
1849
+ }
1850
+
1851
+ if (joinIsOnLeftSide) {
1852
+ nextPointL.copy(outerPoint);
1853
+ } else {
1854
+ nextPointR.copy(outerPoint);
1855
+ }
1856
+ } else {
1857
+ // Add extra miter join triangles
1858
+ if (joinIsOnLeftSide) {
1859
+ addVertex(currentPointL, u1, 0);
1860
+ addVertex(outerPoint, u1, 0);
1861
+ addVertex(currentPoint, u1, 0.5);
1862
+ addVertex(currentPoint, u1, 0.5);
1863
+ addVertex(outerPoint, u1, 0);
1864
+ addVertex(nextPointL, u1, 0);
1865
+ } else {
1866
+ addVertex(currentPointR, u1, 1);
1867
+ addVertex(outerPoint, u1, 1);
1868
+ addVertex(currentPoint, u1, 0.5);
1869
+ addVertex(currentPoint, u1, 0.5);
1870
+ addVertex(outerPoint, u1, 1);
1871
+ addVertex(nextPointR, u1, 1);
1872
+ }
1873
+ }
1874
+
1875
+ isMiter = true;
1876
+ }
1877
+
1878
+ break;
1879
+ }
1880
+ } else {
1881
+ // The segment triangles are generated here when two consecutive points are collinear
1882
+ makeSegmentTriangles();
1883
+ }
1884
+ } else {
1885
+ // The segment triangles are generated here if it is the ending segment
1886
+ makeSegmentTriangles();
1887
+ }
1888
+
1889
+ if (!isClosed && iPoint === numPoints - 1) {
1890
+ // Start line endcap
1891
+ addCapGeometry(points[0], point0L, point0R, joinIsOnLeftSide, true, u0);
1892
+ } // Increment loop variables
1893
+
1894
+
1895
+ u0 = u1;
1896
+ previousPoint = currentPoint;
1897
+ lastPointL.copy(nextPointL);
1898
+ lastPointR.copy(nextPointR);
1899
+ }
1900
+
1901
+ if (!isClosed) {
1902
+ // Ending line endcap
1903
+ addCapGeometry(currentPoint, currentPointL, currentPointR, joinIsOnLeftSide, false, u1);
1904
+ } else if (innerSideModified && vertices) {
1905
+ // Modify path first segment vertices to adjust to the segments inner and outer intersections
1906
+ var lastOuter = outerPoint;
1907
+ var lastInner = innerPoint;
1908
+
1909
+ if (initialJoinIsOnLeftSide !== joinIsOnLeftSide) {
1910
+ lastOuter = innerPoint;
1911
+ lastInner = outerPoint;
1912
+ }
1913
+
1914
+ if (joinIsOnLeftSide) {
1915
+ if (isMiter || initialJoinIsOnLeftSide) {
1916
+ lastInner.toArray(vertices, 0 * 3);
1917
+ lastInner.toArray(vertices, 3 * 3);
1918
+
1919
+ if (isMiter) {
1920
+ lastOuter.toArray(vertices, 1 * 3);
1921
+ }
1922
+ }
1923
+ } else {
1924
+ if (isMiter || !initialJoinIsOnLeftSide) {
1925
+ lastInner.toArray(vertices, 1 * 3);
1926
+ lastInner.toArray(vertices, 3 * 3);
1927
+
1928
+ if (isMiter) {
1929
+ lastOuter.toArray(vertices, 0 * 3);
1930
+ }
1931
+ }
1932
+ }
1933
+ }
1934
+
1935
+ return numVertices; // -- End of algorithm
1936
+ // -- Functions
1937
+
1938
+ function getNormal(p1, p2, result) {
1939
+ result.subVectors(p2, p1);
1940
+ return result.set(-result.y, result.x).normalize();
1941
+ }
1942
+
1943
+ function addVertex(position, u, v) {
1944
+ if (vertices) {
1945
+ vertices[currentCoordinate] = position.x;
1946
+ vertices[currentCoordinate + 1] = position.y;
1947
+ vertices[currentCoordinate + 2] = 0;
1948
+
1949
+ if (normals) {
1950
+ normals[currentCoordinate] = 0;
1951
+ normals[currentCoordinate + 1] = 0;
1952
+ normals[currentCoordinate + 2] = 1;
1953
+ }
1954
+
1955
+ currentCoordinate += 3;
1956
+
1957
+ if (uvs) {
1958
+ uvs[currentCoordinateUV] = u;
1959
+ uvs[currentCoordinateUV + 1] = v;
1960
+ currentCoordinateUV += 2;
1961
+ }
1962
+ }
1963
+
1964
+ numVertices += 3;
1965
+ }
1966
+
1967
+ function makeCircularSector(center, p1, p2, u, v) {
1968
+ // param p1, p2: Points in the circle arc.
1969
+ // p1 and p2 are in clockwise direction.
1970
+ tempV2_1.copy(p1).sub(center).normalize();
1971
+ tempV2_2.copy(p2).sub(center).normalize();
1972
+ var angle = Math.PI;
1973
+ var dot = tempV2_1.dot(tempV2_2);
1974
+ if (Math.abs(dot) < 1) angle = Math.abs(Math.acos(dot));
1975
+ angle /= arcDivisions;
1976
+ tempV2_3.copy(p1);
1977
+
1978
+ for (var i = 0, il = arcDivisions - 1; i < il; i++) {
1979
+ tempV2_4.copy(tempV2_3).rotateAround(center, angle);
1980
+ addVertex(tempV2_3, u, v);
1981
+ addVertex(tempV2_4, u, v);
1982
+ addVertex(center, u, 0.5);
1983
+ tempV2_3.copy(tempV2_4);
1984
+ }
1985
+
1986
+ addVertex(tempV2_4, u, v);
1987
+ addVertex(p2, u, v);
1988
+ addVertex(center, u, 0.5);
1989
+ }
1990
+
1991
+ function makeSegmentTriangles() {
1992
+ addVertex(lastPointR, u0, 1);
1993
+ addVertex(lastPointL, u0, 0);
1994
+ addVertex(currentPointL, u1, 0);
1995
+ addVertex(lastPointR, u0, 1);
1996
+ addVertex(currentPointL, u1, 1);
1997
+ addVertex(currentPointR, u1, 0);
1998
+ }
1999
+
2000
+ function makeSegmentWithBevelJoin(joinIsOnLeftSide, innerSideModified, u) {
2001
+ if (innerSideModified) {
2002
+ // Optimized segment + bevel triangles
2003
+ if (joinIsOnLeftSide) {
2004
+ // Path segments triangles
2005
+ addVertex(lastPointR, u0, 1);
2006
+ addVertex(lastPointL, u0, 0);
2007
+ addVertex(currentPointL, u1, 0);
2008
+ addVertex(lastPointR, u0, 1);
2009
+ addVertex(currentPointL, u1, 0);
2010
+ addVertex(innerPoint, u1, 1); // Bevel join triangle
2011
+
2012
+ addVertex(currentPointL, u, 0);
2013
+ addVertex(nextPointL, u, 0);
2014
+ addVertex(innerPoint, u, 0.5);
2015
+ } else {
2016
+ // Path segments triangles
2017
+ addVertex(lastPointR, u0, 1);
2018
+ addVertex(lastPointL, u0, 0);
2019
+ addVertex(currentPointR, u1, 1);
2020
+ addVertex(lastPointL, u0, 0);
2021
+ addVertex(innerPoint, u1, 0);
2022
+ addVertex(currentPointR, u1, 1); // Bevel join triangle
2023
+
2024
+ addVertex(currentPointR, u, 1);
2025
+ addVertex(nextPointR, u, 0);
2026
+ addVertex(innerPoint, u, 0.5);
2027
+ }
2028
+ } else {
2029
+ // Bevel join triangle. The segment triangles are done in the main loop
2030
+ if (joinIsOnLeftSide) {
2031
+ addVertex(currentPointL, u, 0);
2032
+ addVertex(nextPointL, u, 0);
2033
+ addVertex(currentPoint, u, 0.5);
2034
+ } else {
2035
+ addVertex(currentPointR, u, 1);
2036
+ addVertex(nextPointR, u, 0);
2037
+ addVertex(currentPoint, u, 0.5);
2038
+ }
2039
+ }
2040
+ }
2041
+
2042
+ function createSegmentTrianglesWithMiddleSection(joinIsOnLeftSide, innerSideModified) {
2043
+ if (innerSideModified) {
2044
+ if (joinIsOnLeftSide) {
2045
+ addVertex(lastPointR, u0, 1);
2046
+ addVertex(lastPointL, u0, 0);
2047
+ addVertex(currentPointL, u1, 0);
2048
+ addVertex(lastPointR, u0, 1);
2049
+ addVertex(currentPointL, u1, 0);
2050
+ addVertex(innerPoint, u1, 1);
2051
+ addVertex(currentPointL, u0, 0);
2052
+ addVertex(currentPoint, u1, 0.5);
2053
+ addVertex(innerPoint, u1, 1);
2054
+ addVertex(currentPoint, u1, 0.5);
2055
+ addVertex(nextPointL, u0, 0);
2056
+ addVertex(innerPoint, u1, 1);
2057
+ } else {
2058
+ addVertex(lastPointR, u0, 1);
2059
+ addVertex(lastPointL, u0, 0);
2060
+ addVertex(currentPointR, u1, 1);
2061
+ addVertex(lastPointL, u0, 0);
2062
+ addVertex(innerPoint, u1, 0);
2063
+ addVertex(currentPointR, u1, 1);
2064
+ addVertex(currentPointR, u0, 1);
2065
+ addVertex(innerPoint, u1, 0);
2066
+ addVertex(currentPoint, u1, 0.5);
2067
+ addVertex(currentPoint, u1, 0.5);
2068
+ addVertex(innerPoint, u1, 0);
2069
+ addVertex(nextPointR, u0, 1);
2070
+ }
2071
+ }
2072
+ }
2073
+
2074
+ function addCapGeometry(center, p1, p2, joinIsOnLeftSide, start, u) {
2075
+ // param center: End point of the path
2076
+ // param p1, p2: Left and right cap points
2077
+ switch (style.strokeLineCap) {
2078
+ case 'round':
2079
+ if (start) {
2080
+ makeCircularSector(center, p2, p1, u, 0.5);
2081
+ } else {
2082
+ makeCircularSector(center, p1, p2, u, 0.5);
2083
+ }
2084
+
2085
+ break;
2086
+
2087
+ case 'square':
2088
+ if (start) {
2089
+ tempV2_1.subVectors(p1, center);
2090
+ tempV2_2.set(tempV2_1.y, -tempV2_1.x);
2091
+ tempV2_3.addVectors(tempV2_1, tempV2_2).add(center);
2092
+ tempV2_4.subVectors(tempV2_2, tempV2_1).add(center); // Modify already existing vertices
2093
+
2094
+ if (joinIsOnLeftSide) {
2095
+ tempV2_3.toArray(vertices, 1 * 3);
2096
+ tempV2_4.toArray(vertices, 0 * 3);
2097
+ tempV2_4.toArray(vertices, 3 * 3);
2098
+ } else {
2099
+ tempV2_3.toArray(vertices, 1 * 3);
2100
+ tempV2_3.toArray(vertices, 3 * 3);
2101
+ tempV2_4.toArray(vertices, 0 * 3);
2102
+ }
2103
+ } else {
2104
+ tempV2_1.subVectors(p2, center);
2105
+ tempV2_2.set(tempV2_1.y, -tempV2_1.x);
2106
+ tempV2_3.addVectors(tempV2_1, tempV2_2).add(center);
2107
+ tempV2_4.subVectors(tempV2_2, tempV2_1).add(center);
2108
+ var vl = vertices.length; // Modify already existing vertices
2109
+
2110
+ if (joinIsOnLeftSide) {
2111
+ tempV2_3.toArray(vertices, vl - 1 * 3);
2112
+ tempV2_4.toArray(vertices, vl - 2 * 3);
2113
+ tempV2_4.toArray(vertices, vl - 4 * 3);
2114
+ } else {
2115
+ tempV2_3.toArray(vertices, vl - 2 * 3);
2116
+ tempV2_4.toArray(vertices, vl - 1 * 3);
2117
+ tempV2_4.toArray(vertices, vl - 4 * 3);
2118
+ }
2119
+ }
2120
+
2121
+ break;
2122
+
2123
+ case 'butt':
2124
+ default:
2125
+ // Nothing to do here
2126
+ break;
2127
+ }
2128
+ }
2129
+
2130
+ function removeDuplicatedPoints(points) {
2131
+ // Creates a new array if necessary with duplicated points removed.
2132
+ // This does not remove duplicated initial and ending points of a closed path.
2133
+ var dupPoints = false;
2134
+
2135
+ for (var i = 1, n = points.length - 1; i < n; i++) {
2136
+ if (points[i].distanceTo(points[i + 1]) < minDistance) {
2137
+ dupPoints = true;
2138
+ break;
2139
+ }
2140
+ }
2141
+
2142
+ if (!dupPoints) return points;
2143
+ var newPoints = [];
2144
+ newPoints.push(points[0]);
2145
+
2146
+ for (var _i3 = 1, _n = points.length - 1; _i3 < _n; _i3++) {
2147
+ if (points[_i3].distanceTo(points[_i3 + 1]) >= minDistance) {
2148
+ newPoints.push(points[_i3]);
2149
+ }
2150
+ }
2151
+
2152
+ newPoints.push(points[points.length - 1]);
2153
+ return newPoints;
2154
+ }
2155
+ }
2156
+ }]);
2157
+
2158
+ return SVGLoader;
2159
+ }(_three.Loader);
2160
+
2161
+ _exports.SVGLoader = SVGLoader;
2162
+ });