x_ite 8.4.3 → 8.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (568) hide show
  1. package/.vscode/settings.json +5 -1
  2. package/Makefile +0 -3
  3. package/build/bin/components.js +173 -0
  4. package/build/bin/tags.pl +28 -0
  5. package/build/bin/tests.pl +80 -2
  6. package/build/bin/version.pl +12 -7
  7. package/dist/assets/components/Annotation.js +13 -13
  8. package/dist/assets/components/Annotation.min.js +1 -1
  9. package/dist/assets/components/CADGeometry.js +13 -13
  10. package/dist/assets/components/CADGeometry.min.js +1 -1
  11. package/dist/assets/components/CubeMapTexturing.js +28 -29
  12. package/dist/assets/components/CubeMapTexturing.min.js +1 -1
  13. package/dist/assets/components/DIS.js +13 -13
  14. package/dist/assets/components/DIS.min.js +1 -1
  15. package/dist/assets/components/EventUtilities.js +9 -9
  16. package/dist/assets/components/EventUtilities.min.js +1 -1
  17. package/dist/assets/components/Geometry2D.js +19 -19
  18. package/dist/assets/components/Geometry2D.min.js +1 -1
  19. package/dist/assets/components/Geospatial.js +33 -33
  20. package/dist/assets/components/Geospatial.min.js +1 -1
  21. package/dist/assets/components/HAnim.js +63 -42
  22. package/dist/assets/components/HAnim.min.js +1 -1
  23. package/dist/assets/components/KeyDeviceSensor.js +8 -8
  24. package/dist/assets/components/KeyDeviceSensor.min.js +1 -1
  25. package/dist/assets/components/Layout.js +37 -29
  26. package/dist/assets/components/Layout.min.js +1 -1
  27. package/dist/assets/components/NURBS.js +29 -31
  28. package/dist/assets/components/NURBS.min.js +1 -1
  29. package/dist/assets/components/ParticleSystems.js +23 -23
  30. package/dist/assets/components/ParticleSystems.min.js +1 -1
  31. package/dist/assets/components/Picking.js +19 -19
  32. package/dist/assets/components/Picking.min.js +1 -1
  33. package/dist/assets/components/RigidBodyPhysics.js +24 -19
  34. package/dist/assets/components/RigidBodyPhysics.min.js +1 -1
  35. package/dist/assets/components/Scripting.js +30 -30
  36. package/dist/assets/components/Scripting.min.js +1 -1
  37. package/dist/assets/components/Text.js +172 -594
  38. package/dist/assets/components/Text.min.js +1 -1
  39. package/dist/assets/components/TextureProjector.js +31 -47
  40. package/dist/assets/components/TextureProjector.min.js +1 -1
  41. package/dist/assets/components/Texturing3D.js +367 -346
  42. package/dist/assets/components/Texturing3D.min.js +1 -1
  43. package/dist/assets/components/VolumeRendering.js +19 -19
  44. package/dist/assets/components/VolumeRendering.min.js +1 -1
  45. package/dist/assets/components/X_ITE.js +9 -9
  46. package/dist/assets/components/X_ITE.min.js +1 -1
  47. package/dist/x_ite.css +1 -1
  48. package/dist/x_ite.js +12174 -3553
  49. package/dist/x_ite.min.js +1 -1
  50. package/dist/x_ite.zip +0 -0
  51. package/docs/_config.yml +5 -136
  52. package/docs/_data/nav/components-CADGeometry.yml +14 -0
  53. package/docs/_data/nav/components-Core.yml +16 -0
  54. package/docs/_data/nav/components-CubeMapTexturing.yml +8 -0
  55. package/docs/_data/nav/components-DIS.yml +14 -0
  56. package/docs/_data/nav/components-EnvironmentalEffects.yml +12 -0
  57. package/docs/_data/nav/components-EnvironmentalSensor.yml +8 -0
  58. package/docs/_data/nav/components-EventUtilities.yml +16 -0
  59. package/docs/_data/nav/components-Followers.yml +30 -0
  60. package/docs/_data/nav/components-Geometry2D.yml +18 -0
  61. package/docs/_data/nav/components-Geometry3D.yml +16 -0
  62. package/docs/_data/nav/components-Geospatial.yml +24 -0
  63. package/docs/_data/nav/components-Grouping.yml +10 -0
  64. package/docs/_data/nav/components-HAnim.yml +14 -0
  65. package/docs/_data/nav/components-Interpolation.yml +28 -0
  66. package/docs/_data/nav/components-KeyDeviceSensor.yml +6 -0
  67. package/docs/_data/nav/components-Layering.yml +8 -0
  68. package/docs/_data/nav/components-Layout.yml +12 -0
  69. package/docs/_data/nav/components-Lighting.yml +10 -0
  70. package/docs/_data/nav/components-NURBS.yml +30 -0
  71. package/docs/_data/nav/components-Navigation.yml +16 -0
  72. package/docs/_data/nav/components-Networking.yml +8 -0
  73. package/docs/_data/nav/components-ParticleSystems.yml +22 -0
  74. package/docs/_data/nav/components-Picking.yml +12 -0
  75. package/docs/_data/nav/components-PointingDeviceSensor.yml +10 -0
  76. package/docs/_data/nav/components-Rendering.yml +30 -0
  77. package/docs/_data/nav/components-RigidBodyPhysics.yml +30 -0
  78. package/docs/_data/nav/components-Scripting.yml +4 -0
  79. package/docs/_data/nav/components-Shaders.yml +18 -0
  80. package/docs/_data/nav/components-Shape.yml +22 -0
  81. package/docs/_data/nav/components-Sound.yml +44 -0
  82. package/docs/_data/nav/components-Text.yml +6 -0
  83. package/docs/_data/nav/components-TextureProjector.yml +6 -0
  84. package/docs/_data/nav/components-Texturing.yml +22 -0
  85. package/docs/_data/nav/components-Texturing3D.yml +18 -0
  86. package/docs/_data/nav/components-Time.yml +4 -0
  87. package/docs/_data/nav/components-VolumeRendering.yml +28 -0
  88. package/docs/_data/nav/components-X_ITE.yml +4 -0
  89. package/docs/_data/nav/main.yml +26 -0
  90. package/docs/_data/nav/reference.yml +18 -0
  91. package/docs/_data/nav/tutorials-animation-sensors-and-geometry.yml +18 -0
  92. package/docs/_data/nav/tutorials-basic.yml +6 -0
  93. package/docs/_data/nav/tutorials-optimize-your-scene.yml +6 -0
  94. package/docs/_data/nav/tutorials-scripts-and-prototypes.yml +12 -0
  95. package/docs/_data/nav/tutorials-shapes-geometry-and-appearance.yml +16 -0
  96. package/docs/_data/nav/tutorials-textures-lights-and-environment.yml +20 -0
  97. package/docs/_includes/nav.html +2 -2
  98. package/docs/_includes/scripts.html +2 -1
  99. package/docs/_posts/accessing-the-external-browser.md +1 -1
  100. package/docs/_posts/browser-support.md +1 -1
  101. package/docs/_posts/components/CADGeometry/CADAssembly.md +83 -0
  102. package/docs/_posts/components/CADGeometry/CADFace.md +70 -0
  103. package/docs/_posts/components/CADGeometry/CADLayer.md +84 -0
  104. package/docs/_posts/components/CADGeometry/CADPart.md +117 -0
  105. package/docs/_posts/components/CADGeometry/IndexedQuadSet.md +125 -0
  106. package/docs/_posts/components/CADGeometry/QuadSet.md +113 -0
  107. package/docs/_posts/components/Core/MetadataBoolean.md +90 -0
  108. package/docs/_posts/components/Core/MetadataDouble.md +67 -0
  109. package/docs/_posts/components/Core/MetadataFloat.md +67 -0
  110. package/docs/_posts/components/Core/MetadataInteger.md +66 -0
  111. package/docs/_posts/components/Core/MetadataSet.md +63 -0
  112. package/docs/_posts/components/Core/MetadataString.md +66 -0
  113. package/docs/_posts/components/Core/WorldInfo.md +54 -0
  114. package/docs/_posts/components/CubeMapTexturing/ComposedCubeMapTexture.md +76 -0
  115. package/docs/_posts/components/CubeMapTexturing/GeneratedCubeMapTexture.md +65 -0
  116. package/docs/_posts/components/CubeMapTexturing/ImageCubeMapTexture.md +66 -0
  117. package/docs/_posts/components/DIS/DISEntityManager.md +73 -0
  118. package/docs/_posts/components/DIS/DISEntityTypeMapping.md +88 -0
  119. package/docs/_posts/components/DIS/EspduTransform.md +416 -0
  120. package/docs/_posts/components/DIS/ReceiverPdu.md +168 -0
  121. package/docs/_posts/components/DIS/SignalPdu.md +168 -0
  122. package/docs/_posts/components/DIS/TransmitterPdu.md +232 -0
  123. package/docs/_posts/components/EnvironmentalEffects/Background.md +189 -0
  124. package/docs/_posts/components/EnvironmentalEffects/Fog.md +97 -0
  125. package/docs/_posts/components/EnvironmentalEffects/FogCoordinate.md +40 -0
  126. package/docs/_posts/components/EnvironmentalEffects/LocalFog.md +84 -0
  127. package/docs/_posts/components/EnvironmentalEffects/TextureBackground.md +142 -0
  128. package/docs/_posts/components/EnvironmentalSensor/ProximitySensor.md +90 -0
  129. package/docs/_posts/components/EnvironmentalSensor/TransformSensor.md +91 -0
  130. package/docs/_posts/components/EnvironmentalSensor/VisibilitySensor.md +73 -0
  131. package/docs/_posts/components/EventUtilities/BooleanFilter.md +62 -0
  132. package/docs/_posts/components/EventUtilities/BooleanSequencer.md +86 -0
  133. package/docs/_posts/components/EventUtilities/BooleanToggle.md +46 -0
  134. package/docs/_posts/components/EventUtilities/BooleanTrigger.md +47 -0
  135. package/docs/_posts/components/EventUtilities/IntegerSequencer.md +90 -0
  136. package/docs/_posts/components/EventUtilities/IntegerTrigger.md +51 -0
  137. package/docs/_posts/components/EventUtilities/TimeTrigger.md +47 -0
  138. package/docs/_posts/components/Followers/ColorChaser.md +77 -0
  139. package/docs/_posts/components/Followers/ColorDamper.md +85 -0
  140. package/docs/_posts/components/Followers/CoordinateChaser.md +76 -0
  141. package/docs/_posts/components/Followers/CoordinateDamper.md +80 -0
  142. package/docs/_posts/components/Followers/OrientationChaser.md +72 -0
  143. package/docs/_posts/components/Followers/OrientationDamper.md +80 -0
  144. package/docs/_posts/components/Followers/PositionChaser.md +72 -0
  145. package/docs/_posts/components/Followers/PositionChaser2D.md +72 -0
  146. package/docs/_posts/components/Followers/PositionDamper.md +80 -0
  147. package/docs/_posts/components/Followers/PositionDamper2D.md +80 -0
  148. package/docs/_posts/components/Followers/ScalarChaser.md +76 -0
  149. package/docs/_posts/components/Followers/ScalarDamper.md +80 -0
  150. package/docs/_posts/components/Followers/TexCoordChaser2D.md +72 -0
  151. package/docs/_posts/components/Followers/TexCoordDamper2D.md +80 -0
  152. package/docs/_posts/components/Geometry2D/Arc2D.md +71 -0
  153. package/docs/_posts/components/Geometry2D/ArcClose2D.md +91 -0
  154. package/docs/_posts/components/Geometry2D/Circle2D.md +55 -0
  155. package/docs/_posts/components/Geometry2D/Disk2D.md +75 -0
  156. package/docs/_posts/components/Geometry2D/Polyline2D.md +54 -0
  157. package/docs/_posts/components/Geometry2D/Polypoint2D.md +54 -0
  158. package/docs/_posts/components/Geometry2D/Rectangle2D.md +66 -0
  159. package/docs/_posts/components/Geometry2D/TriangleSet2D.md +66 -0
  160. package/docs/_posts/components/Geometry3D/Box.md +66 -0
  161. package/docs/_posts/components/Geometry3D/Cone.md +90 -0
  162. package/docs/_posts/components/Geometry3D/Cylinder.md +98 -0
  163. package/docs/_posts/components/Geometry3D/ElevationGrid.md +162 -0
  164. package/docs/_posts/components/Geometry3D/Extrusion.md +170 -0
  165. package/docs/_posts/components/Geometry3D/IndexedFaceSet.md +208 -0
  166. package/docs/_posts/components/Geometry3D/Sphere.md +66 -0
  167. package/docs/_posts/components/Geospatial/GeoCoordinate.md +65 -0
  168. package/docs/_posts/components/Geospatial/GeoElevationGrid.md +180 -0
  169. package/docs/_posts/components/Geospatial/GeoLOD.md +128 -0
  170. package/docs/_posts/components/Geospatial/GeoLocation.md +93 -0
  171. package/docs/_posts/components/Geospatial/GeoMetadata.md +75 -0
  172. package/docs/_posts/components/Geospatial/GeoOrigin.md +69 -0
  173. package/docs/_posts/components/Geospatial/GeoPositionInterpolator.md +95 -0
  174. package/docs/_posts/components/Geospatial/GeoProximitySensor.md +109 -0
  175. package/docs/_posts/components/Geospatial/GeoTouchSensor.md +108 -0
  176. package/docs/_posts/components/Geospatial/GeoTransform.md +121 -0
  177. package/docs/_posts/components/Geospatial/GeoViewpoint.md +126 -0
  178. package/docs/_posts/components/Grouping/Group.md +75 -0
  179. package/docs/_posts/components/Grouping/StaticGroup.md +65 -0
  180. package/docs/_posts/components/Grouping/Switch.md +89 -0
  181. package/docs/_posts/components/Grouping/Transform.md +126 -0
  182. package/docs/_posts/components/HAnim/HAnimDisplacer.md +89 -0
  183. package/docs/_posts/components/HAnim/HAnimHumanoid.md +136 -0
  184. package/docs/_posts/components/HAnim/HAnimJoint.md +165 -0
  185. package/docs/_posts/components/HAnim/HAnimMotion.md +68 -0
  186. package/docs/_posts/components/HAnim/HAnimSegment.md +107 -0
  187. package/docs/_posts/components/HAnim/HAnimSite.md +108 -0
  188. package/docs/_posts/components/Interpolation/ColorInterpolator.md +73 -0
  189. package/docs/_posts/components/Interpolation/CoordinateInterpolator.md +76 -0
  190. package/docs/_posts/components/Interpolation/CoordinateInterpolator2D.md +73 -0
  191. package/docs/_posts/components/Interpolation/EaseInEaseOut.md +67 -0
  192. package/docs/_posts/components/Interpolation/NormalInterpolator.md +68 -0
  193. package/docs/_posts/components/Interpolation/OrientationInterpolator.md +72 -0
  194. package/docs/_posts/components/Interpolation/PositionInterpolator.md +72 -0
  195. package/docs/_posts/components/Interpolation/PositionInterpolator2D.md +77 -0
  196. package/docs/_posts/components/Interpolation/ScalarInterpolator.md +76 -0
  197. package/docs/_posts/components/Interpolation/SplinePositionInterpolator.md +93 -0
  198. package/docs/_posts/components/Interpolation/SplinePositionInterpolator2D.md +93 -0
  199. package/docs/_posts/components/Interpolation/SplineScalarInterpolator.md +106 -0
  200. package/docs/_posts/components/Interpolation/SquadOrientationInterpolator.md +78 -0
  201. package/docs/_posts/components/KeyDeviceSensor/KeySensor.md +78 -0
  202. package/docs/_posts/components/KeyDeviceSensor/StringSensor.md +70 -0
  203. package/docs/_posts/components/Layering/Layer.md +67 -0
  204. package/docs/_posts/components/Layering/LayerSet.md +78 -0
  205. package/docs/_posts/components/Layering/Viewport.md +80 -0
  206. package/docs/_posts/components/Layout/Layout.md +107 -0
  207. package/docs/_posts/components/Layout/LayoutGroup.md +85 -0
  208. package/docs/_posts/components/Layout/LayoutLayer.md +74 -0
  209. package/docs/_posts/components/Layout/ScreenFontStyle.md +137 -0
  210. package/docs/_posts/components/Layout/ScreenGroup.md +71 -0
  211. package/docs/_posts/components/Lighting/DirectionalLight.md +100 -0
  212. package/docs/_posts/components/Lighting/EnvironmentLight.md +91 -0
  213. package/docs/_posts/components/Lighting/PointLight.md +103 -0
  214. package/docs/_posts/components/Lighting/SpotLight.md +132 -0
  215. package/docs/_posts/components/NURBS/Contour2D.md +57 -0
  216. package/docs/_posts/components/NURBS/ContourPolyline2D.md +46 -0
  217. package/docs/_posts/components/NURBS/CoordinateDouble.md +47 -0
  218. package/docs/_posts/components/NURBS/NurbsCurve.md +71 -0
  219. package/docs/_posts/components/NURBS/NurbsCurve2D.md +66 -0
  220. package/docs/_posts/components/NURBS/NurbsOrientationInterpolator.md +70 -0
  221. package/docs/_posts/components/NURBS/NurbsPatchSurface.md +106 -0
  222. package/docs/_posts/components/NURBS/NurbsPositionInterpolator.md +70 -0
  223. package/docs/_posts/components/NURBS/NurbsSet.md +66 -0
  224. package/docs/_posts/components/NURBS/NurbsSurfaceInterpolator.md +90 -0
  225. package/docs/_posts/components/NURBS/NurbsSweptSurface.md +69 -0
  226. package/docs/_posts/components/NURBS/NurbsSwungSurface.md +65 -0
  227. package/docs/_posts/components/NURBS/NurbsTextureCoordinate.md +77 -0
  228. package/docs/_posts/components/NURBS/NurbsTrimmedSurface.md +114 -0
  229. package/docs/_posts/components/Navigation/Billboard.md +88 -0
  230. package/docs/_posts/components/Navigation/Collision.md +102 -0
  231. package/docs/_posts/components/Navigation/LOD.md +99 -0
  232. package/docs/_posts/components/Navigation/NavigationInfo.md +122 -0
  233. package/docs/_posts/components/Navigation/OrthoViewpoint.md +117 -0
  234. package/docs/_posts/components/Navigation/Viewpoint.md +117 -0
  235. package/docs/_posts/components/Navigation/ViewpointGroup.md +80 -0
  236. package/docs/_posts/components/Networking/Anchor.md +111 -0
  237. package/docs/_posts/components/Networking/Inline.md +115 -0
  238. package/docs/_posts/components/Networking/LoadSensor.md +91 -0
  239. package/docs/_posts/components/ParticleSystems/BoundedPhysicsModel.md +54 -0
  240. package/docs/_posts/components/ParticleSystems/ConeEmitter.md +76 -0
  241. package/docs/_posts/components/ParticleSystems/ExplosionEmitter.md +72 -0
  242. package/docs/_posts/components/ParticleSystems/ForcePhysicsModel.md +58 -0
  243. package/docs/_posts/components/ParticleSystems/ParticleSystem.md +177 -0
  244. package/docs/_posts/components/ParticleSystems/PointEmitter.md +76 -0
  245. package/docs/_posts/components/ParticleSystems/PolylineEmitter.md +94 -0
  246. package/docs/_posts/components/ParticleSystems/SurfaceEmitter.md +90 -0
  247. package/docs/_posts/components/ParticleSystems/VolumeEmitter.md +90 -0
  248. package/docs/_posts/components/ParticleSystems/WindPhysicsModel.md +68 -0
  249. package/docs/_posts/components/Picking/LinePickSensor.md +125 -0
  250. package/docs/_posts/components/Picking/PickableGroup.md +93 -0
  251. package/docs/_posts/components/Picking/PointPickSensor.md +112 -0
  252. package/docs/_posts/components/Picking/PrimitivePickSensor.md +114 -0
  253. package/docs/_posts/components/Picking/VolumePickSensor.md +107 -0
  254. package/docs/_posts/components/PointingDeviceSensor/CylinderSensor.md +122 -0
  255. package/docs/_posts/components/PointingDeviceSensor/PlaneSensor.md +114 -0
  256. package/docs/_posts/components/PointingDeviceSensor/SphereSensor.md +89 -0
  257. package/docs/_posts/components/PointingDeviceSensor/TouchSensor.md +87 -0
  258. package/docs/_posts/components/Rendering/ClipPlane.md +67 -0
  259. package/docs/_posts/components/Rendering/Color.md +56 -0
  260. package/docs/_posts/components/Rendering/ColorRGBA.md +61 -0
  261. package/docs/_posts/components/Rendering/Coordinate.md +45 -0
  262. package/docs/_posts/components/Rendering/IndexedLineSet.md +128 -0
  263. package/docs/_posts/components/Rendering/IndexedTriangleFanSet.md +128 -0
  264. package/docs/_posts/components/Rendering/IndexedTriangleSet.md +128 -0
  265. package/docs/_posts/components/Rendering/IndexedTriangleStripSet.md +116 -0
  266. package/docs/_posts/components/Rendering/LineSet.md +85 -0
  267. package/docs/_posts/components/Rendering/Normal.md +41 -0
  268. package/docs/_posts/components/Rendering/PointSet.md +76 -0
  269. package/docs/_posts/components/Rendering/TriangleFanSet.md +112 -0
  270. package/docs/_posts/components/Rendering/TriangleSet.md +108 -0
  271. package/docs/_posts/components/Rendering/TriangleStripSet.md +116 -0
  272. package/docs/_posts/components/RigidBodyPhysics/BallJoint.md +78 -0
  273. package/docs/_posts/components/RigidBodyPhysics/CollidableOffset.md +75 -0
  274. package/docs/_posts/components/RigidBodyPhysics/CollidableShape.md +83 -0
  275. package/docs/_posts/components/RigidBodyPhysics/CollisionCollection.md +90 -0
  276. package/docs/_posts/components/RigidBodyPhysics/CollisionSensor.md +65 -0
  277. package/docs/_posts/components/RigidBodyPhysics/CollisionSpace.md +70 -0
  278. package/docs/_posts/components/RigidBodyPhysics/Contact.md +117 -0
  279. package/docs/_posts/components/RigidBodyPhysics/DoubleAxisHingeJoint.md +162 -0
  280. package/docs/_posts/components/RigidBodyPhysics/MotorJoint.md +183 -0
  281. package/docs/_posts/components/RigidBodyPhysics/RigidBody.md +175 -0
  282. package/docs/_posts/components/RigidBodyPhysics/RigidBodyCollection.md +120 -0
  283. package/docs/_posts/components/RigidBodyPhysics/SingleAxisHingeJoint.md +108 -0
  284. package/docs/_posts/components/RigidBodyPhysics/SliderJoint.md +106 -0
  285. package/docs/_posts/components/RigidBodyPhysics/UniversalJoint.md +119 -0
  286. package/docs/_posts/components/Scripting/Script.md +81 -0
  287. package/docs/_posts/components/Shaders/ComposedShader.md +81 -0
  288. package/docs/_posts/components/Shaders/FloatVertexAttribute.md +65 -0
  289. package/docs/_posts/components/Shaders/Matrix3VertexAttribute.md +53 -0
  290. package/docs/_posts/components/Shaders/Matrix4VertexAttribute.md +53 -0
  291. package/docs/_posts/components/Shaders/PackagedShader.md +77 -0
  292. package/docs/_posts/components/Shaders/ProgramShader.md +71 -0
  293. package/docs/_posts/components/Shaders/ShaderPart.md +76 -0
  294. package/docs/_posts/components/Shaders/ShaderProgram.md +68 -0
  295. package/docs/_posts/components/Shape/AcousticProperties.md +52 -0
  296. package/docs/_posts/components/Shape/Appearance.md +123 -0
  297. package/docs/_posts/components/Shape/FillProperties.md +67 -0
  298. package/docs/_posts/components/Shape/LineProperties.md +63 -0
  299. package/docs/_posts/components/Shape/Material.md +217 -0
  300. package/docs/_posts/components/Shape/PhysicalMaterial.md +173 -0
  301. package/docs/_posts/components/Shape/PointProperties.md +84 -0
  302. package/docs/_posts/components/Shape/Shape.md +63 -0
  303. package/docs/_posts/components/Shape/TwoSidedMaterial.md +149 -0
  304. package/docs/_posts/components/Shape/UnlitMaterial.md +115 -0
  305. package/docs/_posts/components/Sound/Analyser.md +72 -0
  306. package/docs/_posts/components/Sound/AudioClip.md +139 -0
  307. package/docs/_posts/components/Sound/AudioDestination.md +52 -0
  308. package/docs/_posts/components/Sound/BiquadFilter.md +70 -0
  309. package/docs/_posts/components/Sound/BufferAudioSource.md +86 -0
  310. package/docs/_posts/components/Sound/ChannelMerger.md +46 -0
  311. package/docs/_posts/components/Sound/ChannelSelector.md +48 -0
  312. package/docs/_posts/components/Sound/ChannelSplitter.md +48 -0
  313. package/docs/_posts/components/Sound/Convolver.md +66 -0
  314. package/docs/_posts/components/Sound/Delay.md +66 -0
  315. package/docs/_posts/components/Sound/DynamicsCompressor.md +74 -0
  316. package/docs/_posts/components/Sound/Gain.md +62 -0
  317. package/docs/_posts/components/Sound/ListenerPointSource.md +62 -0
  318. package/docs/_posts/components/Sound/MicrophoneSource.md +54 -0
  319. package/docs/_posts/components/Sound/OscillatorSource.md +58 -0
  320. package/docs/_posts/components/Sound/PeriodicWave.md +42 -0
  321. package/docs/_posts/components/Sound/Sound.md +92 -0
  322. package/docs/_posts/components/Sound/SpatialSound.md +68 -0
  323. package/docs/_posts/components/Sound/StreamAudioDestination.md +52 -0
  324. package/docs/_posts/components/Sound/StreamAudioSource.md +54 -0
  325. package/docs/_posts/components/Sound/WaveShaper.md +66 -0
  326. package/docs/_posts/components/Text/FontStyle.md +145 -0
  327. package/docs/_posts/components/Text/Text.md +102 -0
  328. package/docs/_posts/components/TextureProjector/TextureProjector.md +52 -0
  329. package/docs/_posts/components/TextureProjector/TextureProjectorParallel.md +52 -0
  330. package/docs/_posts/components/Texturing/ImageTexture.md +134 -0
  331. package/docs/_posts/components/Texturing/MovieTexture.md +221 -0
  332. package/docs/_posts/components/Texturing/MultiTexture.md +100 -0
  333. package/docs/_posts/components/Texturing/MultiTextureCoordinate.md +47 -0
  334. package/docs/_posts/components/Texturing/MultiTextureTransform.md +47 -0
  335. package/docs/_posts/components/Texturing/PixelTexture.md +80 -0
  336. package/docs/_posts/components/Texturing/TextureCoordinate.md +52 -0
  337. package/docs/_posts/components/Texturing/TextureCoordinateGenerator.md +64 -0
  338. package/docs/_posts/components/Texturing/TextureProperties.md +137 -0
  339. package/docs/_posts/components/Texturing/TextureTransform.md +73 -0
  340. package/docs/_posts/components/Texturing3D/ComposedTexture3D.md +76 -0
  341. package/docs/_posts/components/Texturing3D/ImageTexture3D.md +132 -0
  342. package/docs/_posts/components/Texturing3D/ImageTextureAtlas.md +131 -0
  343. package/docs/_posts/components/Texturing3D/PixelTexture3D.md +75 -0
  344. package/docs/_posts/components/Texturing3D/TextureCoordinate3D.md +53 -0
  345. package/docs/_posts/components/Texturing3D/TextureCoordinate4D.md +52 -0
  346. package/docs/_posts/components/Texturing3D/TextureTransform3D.md +69 -0
  347. package/docs/_posts/components/Texturing3D/TextureTransformMatrix3D.md +57 -0
  348. package/docs/_posts/components/Time/TimeSensor.md +136 -0
  349. package/docs/_posts/components/VolumeRendering/BlendedVolumeStyle.md +92 -0
  350. package/docs/_posts/components/VolumeRendering/BoundaryEnhancementVolumeStyle.md +53 -0
  351. package/docs/_posts/components/VolumeRendering/CartoonVolumeStyle.md +83 -0
  352. package/docs/_posts/components/VolumeRendering/ComposedVolumeStyle.md +51 -0
  353. package/docs/_posts/components/VolumeRendering/EdgeEnhancementVolumeStyle.md +67 -0
  354. package/docs/_posts/components/VolumeRendering/IsoSurfaceVolumeData.md +99 -0
  355. package/docs/_posts/components/VolumeRendering/OpacityMapVolumeStyle.md +51 -0
  356. package/docs/_posts/components/VolumeRendering/ProjectionVolumeStyle.md +48 -0
  357. package/docs/_posts/components/VolumeRendering/SegmentedVolumeData.md +80 -0
  358. package/docs/_posts/components/VolumeRendering/ShadedVolumeStyle.md +75 -0
  359. package/docs/_posts/components/VolumeRendering/SilhouetteEnhancementVolumeStyle.md +63 -0
  360. package/docs/_posts/components/VolumeRendering/ToneMappedVolumeStyle.md +71 -0
  361. package/docs/_posts/components/VolumeRendering/VolumeData.md +71 -0
  362. package/docs/_posts/components/X_ITE/BlendMode.md +94 -0
  363. package/docs/_posts/custom-shaders.md +9 -4
  364. package/docs/_posts/dom-integration.md +1 -6
  365. package/docs/_posts/features.md +2 -2
  366. package/docs/_posts/getting-started.md +100 -57
  367. package/docs/_posts/glossary.md +1 -1
  368. package/docs/_posts/how-to-configure-your-web-server.md +1 -1
  369. package/docs/_posts/reference/browser-services.md +78 -18
  370. package/docs/_posts/reference/constants-services.md +1 -1
  371. package/docs/_posts/reference/ecmascript-object-and-function-definitions.md +1 -1
  372. package/docs/_posts/reference/field-services-and-objects.md +8 -8
  373. package/docs/_posts/reference/prototype-services.md +7 -7
  374. package/docs/_posts/reference/route-services.md +1 -1
  375. package/docs/_posts/reference/scene-services.md +5 -5
  376. package/docs/_posts/reference/script-node-authoring-interface.md +1 -1
  377. package/docs/_posts/report-a-bug.md +1 -1
  378. package/docs/_posts/setup-a-localhost-server.md +5 -1
  379. package/docs/_posts/supported-nodes.md +239 -238
  380. package/docs/_posts/tutorials/adding-backgrounds.md +3 -3
  381. package/docs/_posts/tutorials/adding-fog.md +2 -2
  382. package/docs/_posts/tutorials/adding-sound.md +19 -19
  383. package/docs/_posts/tutorials/animating-transforms.md +17 -17
  384. package/docs/_posts/tutorials/basic-nodes.md +30 -30
  385. package/docs/_posts/tutorials/building-a-x3d-world.md +3 -3
  386. package/docs/_posts/tutorials/building-elevation-grids.md +7 -7
  387. package/docs/_posts/tutorials/building-extruded-shapes.md +7 -7
  388. package/docs/_posts/tutorials/building-primitive-shapes.md +13 -13
  389. package/docs/_posts/tutorials/building-shapes-out-of-points-lines-and-faces.md +21 -21
  390. package/docs/_posts/tutorials/controlling-appearance-with-materials.md +7 -7
  391. package/docs/_posts/tutorials/controlling-color-on-coordinate-based-geometry.md +11 -11
  392. package/docs/_posts/tutorials/controlling-detail.md +4 -4
  393. package/docs/_posts/tutorials/controlling-how-textures-are-mapped.md +7 -7
  394. package/docs/_posts/tutorials/controlling-navigation.md +3 -3
  395. package/docs/_posts/tutorials/controlling-shading-on-coordinate-based-geometry.md +13 -13
  396. package/docs/_posts/tutorials/controlling-the-viewpoint.md +3 -3
  397. package/docs/_posts/tutorials/creating-new-node-types.md +4 -4
  398. package/docs/_posts/tutorials/grouping-nodes.md +13 -13
  399. package/docs/_posts/tutorials/hello-world.md +1 -1
  400. package/docs/_posts/tutorials/improving-performance.md +1 -1
  401. package/docs/_posts/tutorials/increasing-rendering-speed.md +1 -1
  402. package/docs/_posts/tutorials/introducing-animation.md +10 -10
  403. package/docs/_posts/tutorials/introducing-script-use.md +3 -3
  404. package/docs/_posts/tutorials/introducing-x3d.md +1 -1
  405. package/docs/_posts/tutorials/lighting-your-world.md +4 -4
  406. package/docs/_posts/tutorials/mapping-textures.md +7 -7
  407. package/docs/_posts/tutorials/naming-nodes.md +1 -1
  408. package/docs/_posts/tutorials/overview.md +1 -1
  409. package/docs/_posts/tutorials/providing-information-about-your-world.md +2 -2
  410. package/docs/_posts/tutorials/sensing-the-viewer.md +15 -15
  411. package/docs/_posts/tutorials/sensing-viewer-actions.md +10 -10
  412. package/docs/_posts/tutorials/transforming-shapes.md +4 -4
  413. package/docs/_posts/tutorials/writing-program-scripts-with-ecmascript.md +5 -5
  414. package/docs/_posts/what's-new.md +40 -2
  415. package/docs/_tabs/components.md +383 -0
  416. package/docs/_tabs/imprint.md +1 -1
  417. package/docs/_tabs/laboratory.md +38 -6
  418. package/docs/_tabs/playground.html +22 -66
  419. package/docs/_tabs/reference.md +2 -1
  420. package/docs/_tabs/tags.md +1 -1
  421. package/docs/_tabs/tutorials.md +1 -1
  422. package/docs/assets/X3D/Michroma-Regular.ttf +0 -0
  423. package/docs/assets/X3D/peakpx.jpg +0 -0
  424. package/docs/assets/X3D/teaser.x3d +55 -0
  425. package/docs/assets/css/style.scss +120 -11
  426. package/docs/assets/img/laboratory/blend-mode.png +0 -0
  427. package/docs/assets/img/laboratory/dicom-nrrd.png +0 -0
  428. package/docs/assets/img/laboratory/earthquake.png +0 -0
  429. package/docs/assets/img/laboratory/gltf.png +0 -0
  430. package/docs/assets/img/laboratory/l-system.png +0 -0
  431. package/docs/assets/js/autoupdate.js +25 -0
  432. package/docs/laboratory/gltf-sample-viewer.html +318 -0
  433. package/docs/laboratory/x3d-visual-blend-mode-editor.html +1 -0
  434. package/package.json +9 -2
  435. package/src/assets/components/Texturing3D.js +5 -3
  436. package/src/assets/shaders/Types.glsl.js +5 -5
  437. package/src/assets/shaders/webgl1/PBR.fs.js +1 -1
  438. package/src/assets/shaders/webgl1/include/Colors.glsl.js +5 -7
  439. package/src/assets/shaders/webgl1/include/Fragment.glsl.js +4 -0
  440. package/src/assets/shaders/webgl1/include/Hatch.glsl.js +1 -1
  441. package/src/assets/shaders/webgl1/include/Texture.glsl.js +3 -3
  442. package/src/assets/shaders/webgl2/include/Colors.glsl.js +5 -7
  443. package/src/assets/shaders/webgl2/include/Hatch.glsl.js +1 -1
  444. package/src/assets/shaders/webgl2/include/Particle.glsl.js +2 -2
  445. package/src/assets/shaders/webgl2/include/Texture.glsl.js +2 -2
  446. package/src/bookmarks.js +12 -8
  447. package/src/examples.js +3 -0
  448. package/src/lib/jquery.js +20 -0
  449. package/src/lib/libgif/libgif.js +1004 -0
  450. package/src/lib/libtess.js +1 -0
  451. package/src/lib/nurbs/extras/sample.js +5 -7
  452. package/src/standard/Math/Algorithms/Bezier.js +175 -33
  453. package/src/standard/Math/Geometry/Box2.js +15 -55
  454. package/src/standard/Math/Geometry/Box3.js +19 -66
  455. package/src/standard/Math/Geometry/Triangle3.js +14 -79
  456. package/src/standard/Math/Numbers/Color3.js +4 -0
  457. package/src/standard/Math/Numbers/Color4.js +4 -0
  458. package/src/standard/Math/Numbers/Matrix3.js +11 -3
  459. package/src/standard/Math/Numbers/Matrix4.js +9 -6
  460. package/src/standard/Math/Numbers/Rotation4.js +72 -65
  461. package/src/tests.js +3 -0
  462. package/src/x_ite/Base/X3DArrayField.js +0 -2
  463. package/src/x_ite/Base/X3DInfoArray.js +2 -2
  464. package/src/x_ite/Base/X3DObjectArrayField.js +19 -0
  465. package/src/x_ite/Base/X3DTypedArrayField.js +149 -0
  466. package/src/x_ite/Browser/Core/BrowserOptions.js +108 -64
  467. package/src/x_ite/Browser/Core/Context.js +1 -1
  468. package/src/x_ite/Browser/Core/ContextMenu.js +2 -2
  469. package/src/x_ite/Browser/Core/Notification.js +1 -1
  470. package/src/x_ite/Browser/Core/RenderingProperties.js +4 -0
  471. package/src/x_ite/Browser/Core/X3DCoreContext.js +99 -54
  472. package/src/x_ite/Browser/Navigation/ExamineViewer.js +4 -14
  473. package/src/x_ite/Browser/Navigation/LookAtViewer.js +3 -13
  474. package/src/x_ite/Browser/Navigation/PlaneViewer.js +3 -12
  475. package/src/x_ite/Browser/Navigation/X3DFlyViewer.js +25 -22
  476. package/src/x_ite/Browser/Navigation/X3DViewer.js +12 -3
  477. package/src/x_ite/Browser/Networking/X3DNetworkingContext.js +2 -2
  478. package/src/x_ite/Browser/PointingDeviceSensor/PointingDevice.js +19 -15
  479. package/src/x_ite/Browser/Rendering/X3DRenderingContext.js +30 -10
  480. package/src/x_ite/Browser/Shaders/X3DShadersContext.js +1 -1
  481. package/src/x_ite/Browser/Shape/X3DShapeContext.js +30 -3
  482. package/src/x_ite/Browser/Text/PolygonText.js +137 -134
  483. package/src/x_ite/Browser/Texturing/GifMedia.js +113 -0
  484. package/src/x_ite/Browser/Texturing3D/DICOMParser.js +1 -6
  485. package/src/x_ite/Browser/Texturing3D/NRRDParser.js +81 -310
  486. package/src/x_ite/Browser/VERSION.js +1 -1
  487. package/src/x_ite/Browser/X3DBrowser.js +162 -122
  488. package/src/x_ite/Browser/X3DBrowserContext.js +7 -5
  489. package/src/x_ite/Components/Core/WorldInfo.js +3 -3
  490. package/src/x_ite/Components/Core/X3DNode.js +7 -7
  491. package/src/x_ite/Components/Core/X3DPrototypeInstance.js +1 -1
  492. package/src/x_ite/Components/CubeMapTexturing/ImageCubeMapTexture.js +2 -3
  493. package/src/x_ite/Components/Geometry3D/Extrusion.js +27 -23
  494. package/src/x_ite/Components/Geometry3D/IndexedFaceSet.js +10 -19
  495. package/src/x_ite/Components/Grouping/X3DBoundedObject.js +1 -3
  496. package/src/x_ite/Components/HAnim/HAnimHumanoid.js +39 -15
  497. package/src/x_ite/Components/HAnim/HAnimJoint.js +6 -9
  498. package/src/x_ite/Components/Layering/X3DLayerNode.js +21 -2
  499. package/src/x_ite/Components/Layout/Layout.js +4 -2
  500. package/src/x_ite/Components/Layout/ScreenFontStyle.js +6 -0
  501. package/src/x_ite/Components/Lighting/DirectionalLight.js +4 -11
  502. package/src/x_ite/Components/Lighting/EnvironmentLight.js +1 -1
  503. package/src/x_ite/Components/Lighting/PointLight.js +4 -11
  504. package/src/x_ite/Components/Lighting/SpotLight.js +4 -11
  505. package/src/x_ite/Components/Lighting/X3DLightNode.js +7 -9
  506. package/src/x_ite/Components/Navigation/OrthoViewpoint.js +2 -2
  507. package/src/x_ite/Components/Navigation/X3DViewpointNode.js +14 -6
  508. package/src/x_ite/Components/Networking/Inline.js +48 -59
  509. package/src/x_ite/Components/Networking/X3DUrlObject.js +1 -1
  510. package/src/x_ite/Components/PointingDeviceSensor/CylinderSensor.js +2 -2
  511. package/src/x_ite/Components/Rendering/X3DLineGeometryNode.js +7 -13
  512. package/src/x_ite/Components/Rendering/X3DPointGeometryNode.js +4 -2
  513. package/src/x_ite/Components/RigidBodyPhysics/RigidBody.js +4 -2
  514. package/src/x_ite/Components/Scripting/Script.js +2 -2
  515. package/src/x_ite/Components/Shaders/ShaderPart.js +1 -1
  516. package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +1 -3
  517. package/src/x_ite/Components/Shape/Appearance.js +27 -1
  518. package/src/x_ite/Components/Shape/FillProperties.js +1 -0
  519. package/src/x_ite/Components/Shape/LineProperties.js +15 -9
  520. package/src/x_ite/Components/Shape/Material.js +33 -22
  521. package/src/x_ite/Components/Shape/PhysicalMaterial.js +22 -15
  522. package/src/x_ite/Components/Shape/PointProperties.js +23 -7
  523. package/src/x_ite/Components/Shape/UnlitMaterial.js +3 -2
  524. package/src/x_ite/Components/Shape/X3DOneSidedMaterialNode.js +25 -19
  525. package/src/x_ite/Components/Sound/AudioClip.js +5 -5
  526. package/src/x_ite/Components/Sound/X3DSoundSourceNode.js +26 -34
  527. package/src/x_ite/Components/Text/X3DFontStyleNode.js +1 -1
  528. package/src/x_ite/Components/TextureProjector/TextureProjector.js +4 -12
  529. package/src/x_ite/Components/TextureProjector/TextureProjectorParallel.js +6 -14
  530. package/src/x_ite/Components/TextureProjector/X3DTextureProjectorNode.js +7 -7
  531. package/src/x_ite/Components/Texturing/ImageTexture.js +15 -10
  532. package/src/x_ite/Components/Texturing/MovieTexture.js +51 -11
  533. package/src/x_ite/Components/Texturing3D/ImageTexture3D.js +2 -2
  534. package/src/x_ite/Components/Texturing3D/ImageTextureAtlas.js +230 -0
  535. package/src/x_ite/Components/Time/X3DTimeDependentNode.js +12 -10
  536. package/src/x_ite/Execution/BindableList.js +35 -37
  537. package/src/x_ite/Execution/BindableStack.js +25 -7
  538. package/src/x_ite/Execution/X3DScene.js +2 -2
  539. package/src/x_ite/Execution/X3DWorld.js +1 -1
  540. package/src/x_ite/Fields/SFRotation.js +2 -1
  541. package/src/x_ite/Fields/SFString.js +1 -1
  542. package/src/x_ite/InputOutput/FileLoader.js +105 -236
  543. package/src/x_ite/InputOutput/Generator.js +12 -8
  544. package/src/x_ite/Parser/Expressions.js +85 -0
  545. package/src/x_ite/Parser/GLB2Parser.js +147 -0
  546. package/src/x_ite/Parser/GLTF2Parser.js +2221 -0
  547. package/src/x_ite/Parser/GoldenGate.js +64 -13
  548. package/src/x_ite/Parser/JSONParser.js +7 -36
  549. package/src/x_ite/Parser/OBJParser.js +1076 -0
  550. package/src/x_ite/Parser/STLAParser.js +376 -0
  551. package/src/x_ite/Parser/STLBParser.js +156 -0
  552. package/src/x_ite/Parser/SVGParser.js +2476 -0
  553. package/src/x_ite/Parser/VRMLParser.js +127 -183
  554. package/src/x_ite/Parser/X3DOptimizer.js +191 -0
  555. package/src/x_ite/Parser/X3DParser.js +34 -0
  556. package/src/x_ite/Parser/XMLParser.js +11 -109
  557. package/src/x_ite/Prototype/X3DExternProtoDeclaration.js +2 -2
  558. package/src/x_ite/Prototype/X3DProtoDeclaration.js +3 -3
  559. package/src/x_ite/Rendering/DependentRenderer.js +1 -1
  560. package/src/x_ite/Rendering/MultiSampleFrameBuffer.js +150 -0
  561. package/src/x_ite/Rendering/TextureBuffer.js +3 -5
  562. package/src/x_ite/Rendering/X3DRenderObject.js +2 -7
  563. package/src/x_ite/X3D.js +1 -0
  564. package/src/x_ite/X3DCanvas.js +10 -0
  565. package/src/x_ite.html +39 -17
  566. package/webpack.config.js +1 -0
  567. package/x_ite.min.html +38 -17
  568. package/src/standard/Networking/BinaryTransport.js +0 -116
@@ -0,0 +1,2476 @@
1
+ /*******************************************************************************
2
+ *
3
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
+ *
5
+ * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022.
6
+ *
7
+ * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
8
+ *
9
+ * The copyright notice above does not evidence any actual of intended
10
+ * publication of such source code, and is an unpublished work by create3000.
11
+ * This material contains CONFIDENTIAL INFORMATION that is the property of
12
+ * create3000.
13
+ *
14
+ * No permission is granted to copy, distribute, or create derivative works from
15
+ * the contents of this software, in whole or in part, without the prior written
16
+ * permission of create3000.
17
+ *
18
+ * NON-MILITARY USE ONLY
19
+ *
20
+ * All create3000 software are effectively free software with a non-military use
21
+ * restriction. It is free. Well commented source is provided. You may reuse the
22
+ * source in any way you please with the exception anything that uses it must be
23
+ * marked to indicate is contains 'non-military use only' components.
24
+ *
25
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
26
+ *
27
+ * Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>.
28
+ *
29
+ * This file is part of the X_ITE Project.
30
+ *
31
+ * X_ITE is free software: you can redistribute it and/or modify it under the
32
+ * terms of the GNU General Public License version 3 only, as published by the
33
+ * Free Software Foundation.
34
+ *
35
+ * X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
36
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
37
+ * A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
38
+ * details (a copy is included in the LICENSE file that accompanied this code).
39
+ *
40
+ * You should have received a copy of the GNU General Public License version 3
41
+ * along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a
42
+ * copy of the GPLv3 License.
43
+ *
44
+ * For Silvio, Joy and Adi.
45
+ *
46
+ ******************************************************************************/
47
+
48
+ import X3DParser from "./X3DParser.js";
49
+ import X3DOptimizer from "./X3DOptimizer.js";
50
+ import Expressions from "./Expressions.js";
51
+ import Algorithm from "../../standard/Math/Algorithm.js";
52
+ import Color3 from "../../standard/Math/Numbers/Color3.js";
53
+ import Color4 from "../../standard/Math/Numbers/Color4.js";
54
+ import Vector2 from "../../standard/Math/Numbers/Vector2.js";
55
+ import Vector3 from "../../standard/Math/Numbers/Vector3.js";
56
+ import Vector4 from "../../standard/Math/Numbers/Vector4.js";
57
+ import Rotation4 from "../../standard/Math/Numbers/Rotation4.js";
58
+ import Matrix3 from "../../standard/Math/Numbers/Matrix3.js";
59
+ import Matrix4 from "../../standard/Math/Numbers/Matrix4.js";
60
+ import Box2 from "../../standard/Math/Geometry/Box2.js"
61
+ import Bezier from "../../standard/Math/Algorithms/Bezier.js";
62
+
63
+ /*
64
+ * Grammar
65
+ */
66
+
67
+ // Lexical elements
68
+ const Grammar = Expressions ({
69
+ // General
70
+ whitespaces: /[\x20\n\t\r]+/gy,
71
+ comma: /,/gy,
72
+ openParenthesis: /\(/gy,
73
+ closeParenthesis: /\)/gy,
74
+
75
+ // Units
76
+ length: /(em|ex|px|in|cm|mm|pt|pc)/gy,
77
+ percent: /%/gy,
78
+
79
+ // Values
80
+ int32: /((?:0[xX][\da-fA-F]+)|(?:[+-]?\d+))/gy,
81
+ double: /([+-]?(?:(?:(?:\d*\.\d+)|(?:\d+(?:\.)?))(?:[eE][+-]?\d+)?))/gy,
82
+ constants: /([+-])((?:NAN|INF|INFINITY))/igy,
83
+ matrix: /matrix/gy,
84
+ translate: /translate/gy,
85
+ rotate: /rotate/gy,
86
+ scale: /scale/gy,
87
+ skewX: /skewX/gy,
88
+ skewY: /skewY/gy,
89
+ color: /([a-zA-Z]+|#[\da-fA-F]+|rgba?\(.*?\))/gy,
90
+ url: /url\("?(.*?)"?\)/gy,
91
+ path: /([mMlLhHvVqQtTcCsSaAzZ])/gy,
92
+ });
93
+
94
+ /*
95
+ * Constants
96
+ */
97
+
98
+ const
99
+ MM = 0.001, // One mm in meters.
100
+ CM = 0.01, // One cm in meters.
101
+ INCH = 0.0254, // One inch in meters.
102
+ POINT = INCH / 72, // One point in meters.
103
+ PICA = INCH / 6, // One pica in meters.
104
+ PIXEL = INCH / 90, // One pixel in meters.
105
+ EM = 16, // One em in pixels,
106
+ BEZIER_STEPS = 10,
107
+ CIRCLE_STEPS = 64,
108
+ GRADIENT_SIZE = 256; // In pixels.
109
+
110
+ /*
111
+ * Parser
112
+ */
113
+
114
+ function SVGParser (scene)
115
+ {
116
+ X3DParser .call (this, scene);
117
+ X3DOptimizer .call (this);
118
+
119
+ // Optimizer
120
+
121
+ this .removeGroups = true;
122
+ this .removeEmptyGroups = true;
123
+ this .combineGroupingNodes = false;
124
+
125
+ // Options
126
+
127
+ this .solid = false;
128
+
129
+ // Globals
130
+
131
+ this .nodes = new Map ();
132
+ this .tessy = this .createTesselator ();
133
+ this .canvas = document .createElement ("canvas");
134
+ this .context = this .canvas .getContext ("2d");
135
+
136
+ this .canvas .width = GRADIENT_SIZE;
137
+ this .canvas .height = GRADIENT_SIZE;
138
+
139
+ this .styles = [{
140
+ display: "inline",
141
+ fillType: "COLOR",
142
+ fillColor: Color4 .Black,
143
+ fillURL: "",
144
+ fillOpacity: 1,
145
+ fillRule: "nonzero",
146
+ strokeType: "NONE",
147
+ strokeColor: Color4 .Black,
148
+ strokeURL: "",
149
+ strokeOpacity: 1,
150
+ strokeWidth: 1,
151
+ opacity: 1,
152
+ stopColor: Color4 .Black,
153
+ stopOpacity: 1,
154
+ }];
155
+ }
156
+
157
+ SVGParser .prototype = Object .assign (Object .create (X3DParser .prototype),
158
+ X3DOptimizer .prototype,
159
+ {
160
+ constructor: SVGParser,
161
+ CONSTANTS: new Map ([
162
+ ["NAN", NaN],
163
+ ["INF", Infinity],
164
+ ["INFINITY", Infinity],
165
+ ]),
166
+ getEncoding: function ()
167
+ {
168
+ return "XML";
169
+ },
170
+ isValid: function ()
171
+ {
172
+ if (!(this .input instanceof XMLDocument))
173
+ return false;
174
+
175
+ if ($(this .input) .children ("svg") .length)
176
+ return true;
177
+
178
+ if (this .input .nodeName === "svg")
179
+ return true;
180
+
181
+ return false;
182
+ },
183
+ setInput (xmlElement)
184
+ {
185
+ try
186
+ {
187
+ if (typeof xmlElement === "string")
188
+ xmlElement = $.parseXML (xmlElement);
189
+
190
+ this .input = xmlElement;
191
+ }
192
+ catch (error)
193
+ {
194
+ this .input = undefined;
195
+ }
196
+ },
197
+ parseIntoScene: function (success, error)
198
+ {
199
+ this .xmlElement (this .input)
200
+ .then (success)
201
+ .catch (error);
202
+ },
203
+ xmlElement: async function (xmlElement)
204
+ {
205
+ switch (xmlElement .nodeName)
206
+ {
207
+ case "#document":
208
+ {
209
+ const svg = $(xmlElement) .children ("svg");
210
+
211
+ for (const xmlElement of svg)
212
+ await this .svgElement (xmlElement);
213
+
214
+ break;
215
+ }
216
+ case "svg":
217
+ {
218
+ await this .svgElement (xmlElement);
219
+ break;
220
+ }
221
+ }
222
+
223
+ return this .getScene ();
224
+ },
225
+ svgElement: async function (xmlElement)
226
+ {
227
+ const
228
+ browser = this .getBrowser (),
229
+ scene = this .getScene ();
230
+
231
+ scene .setEncoding ("SVG");
232
+ scene .setProfile (browser .getProfile ("Interchange"));
233
+ scene .addComponent (browser .getComponent ("Geometry2D", 2));
234
+
235
+ await this .loadComponents ();
236
+
237
+ // Init nodes.
238
+
239
+ this .document = this .input;
240
+ this .rootTransform = scene .createNode ("Transform");
241
+ this .groupNodes = [this .rootTransform];
242
+ this .texturePropertiesNode = this .createTextureProperties ();
243
+
244
+ // Create background.
245
+
246
+ const background = scene .createNode ("Background");
247
+
248
+ background .skyColor = [1, 1, 1];
249
+
250
+ scene .getRootNodes () .push (background);
251
+
252
+ // Create navigation info.
253
+
254
+ const navigationInfo = scene .createNode ("NavigationInfo");
255
+
256
+ navigationInfo .type = ["PLANE_create3000.github.io", "PLANE", "EXAMINE", "ANY"];
257
+
258
+ scene .getRootNodes () .push (navigationInfo);
259
+
260
+ // Get attributes of svg element.
261
+
262
+ const
263
+ viewBox = this .viewBoxAttribute (xmlElement .getAttribute ("viewBox"), new Vector4 (0, 0, 100, 100)),
264
+ width = this .lengthAttribute (xmlElement .getAttribute ("width", viewBox [2])),
265
+ height = this .lengthAttribute (xmlElement .getAttribute ("height", viewBox [3]));
266
+
267
+ // Create viewpoint.
268
+
269
+ const
270
+ viewpoint = scene .createNode ("OrthoViewpoint",),
271
+ x = (viewBox .x + width / 2) * PIXEL,
272
+ y = -(viewBox .y + height / 2) * PIXEL;
273
+
274
+ viewpoint .position = new Vector3 (x, y, 10);
275
+ viewpoint .centerOfRotation = new Vector3 (x, y, 0);
276
+
277
+ viewpoint .fieldOfView = [
278
+ -width / 2 * PIXEL,
279
+ -height / 2 * PIXEL,
280
+ width / 2 * PIXEL,
281
+ height / 2 * PIXEL,
282
+ ];
283
+
284
+ scene .getRootNodes () .push (viewpoint);
285
+
286
+ // Create view matrix.
287
+
288
+ const
289
+ scale = new Vector3 (width * PIXEL / viewBox [2], -height * PIXEL / viewBox [3], 1),
290
+ translation = new Vector3 (-viewBox .x, viewBox .y, 0) .multVec (scale);
291
+
292
+ this .rootTransform .translation = translation;
293
+ this .rootTransform .scale = scale;
294
+
295
+ // Parse elements.
296
+
297
+ this .elements (xmlElement);
298
+
299
+ // Add root Transform node.
300
+
301
+ scene .addNamedNode (scene .getUniqueName ("ViewBox"), this .rootTransform);
302
+ scene .getRootNodes () .push (this .rootTransform);
303
+
304
+ // Optimize scene graph.
305
+
306
+ this .optimizeSceneGraph (scene .getRootNodes ());
307
+ },
308
+ elements: function (xmlElement)
309
+ {
310
+ for (const childNode of xmlElement .childNodes)
311
+ this .element (childNode);
312
+ },
313
+ element: function (xmlElement)
314
+ {
315
+ if (this .used (xmlElement))
316
+ return;
317
+
318
+ switch (xmlElement .nodeName)
319
+ {
320
+ case "use":
321
+ return this .useElement (xmlElement);
322
+ case "g":
323
+ return this .gElement (xmlElement);
324
+ case "switch":
325
+ return this .switchElement (xmlElement);
326
+ case "a":
327
+ return this .aElement (xmlElement);
328
+ case "rect":
329
+ return this .rectElement (xmlElement);
330
+ case "circle":
331
+ return this .circleElement (xmlElement);
332
+ case "ellipse":
333
+ return this .ellipseElement (xmlElement);
334
+ case "text":
335
+ return this .textElement (xmlElement);
336
+ case "image":
337
+ return this .imageElement (xmlElement);
338
+ case "polyline":
339
+ return this .polylineElement (xmlElement);
340
+ case "polygon":
341
+ return this .polygonElement (xmlElement);
342
+ case "path":
343
+ return this .pathElement (xmlElement);
344
+ }
345
+ },
346
+ used: function (xmlElement)
347
+ {
348
+ const node = this .nodes .get (xmlElement);
349
+
350
+ if (!node)
351
+ return false;
352
+
353
+ this .groupNodes .at (-1) .children .push (node);
354
+
355
+ return true;
356
+ },
357
+ useElement: function (xmlElement)
358
+ {
359
+ // Get href.
360
+
361
+ const usedElement = this .hrefAttribute (xmlElement .getAttribute ("xlink:href"));
362
+
363
+ if (!usedElement)
364
+ return;
365
+
366
+ // Determine style.
367
+
368
+ if (!this .styleAttributes (xmlElement))
369
+ return;
370
+
371
+ // Create Transform node.
372
+
373
+ const
374
+ x = this .lengthAttribute (xmlElement .getAttribute ("x"), 0),
375
+ y = this .lengthAttribute (xmlElement .getAttribute ("y"), 0),
376
+ width = this .lengthAttribute (xmlElement .getAttribute ("width"), 0),
377
+ height = this .lengthAttribute (xmlElement .getAttribute ("height"), 0);
378
+
379
+ const transformNode = this .createTransform (xmlElement, new Vector2 (x, y));
380
+
381
+ this .groupNodes .push (transformNode);
382
+
383
+ this .element (usedElement);
384
+
385
+ this .styles .pop ();
386
+ this .groupNodes .pop ();
387
+
388
+ // Add node.
389
+
390
+ this .groupNodes .at (-1) .children .push (transformNode);
391
+ },
392
+ gElement: function (xmlElement)
393
+ {
394
+ // Determine style.
395
+
396
+ if (!this .styleAttributes (xmlElement))
397
+ return;
398
+
399
+ // Create Transform node.
400
+
401
+ const transformNode = this .createTransform (xmlElement);
402
+
403
+ // Get child elements.
404
+
405
+ this .groupNodes .push (transformNode);
406
+
407
+ this .elements (xmlElement);
408
+
409
+ this .styles .pop ();
410
+ this .groupNodes .pop ();
411
+
412
+ // Add node.
413
+
414
+ this .groupNodes .at (-1) .children .push (transformNode);
415
+ },
416
+ switchElement: function (xmlElement)
417
+ {
418
+ // Determine style.
419
+
420
+ if (!this .styleAttributes (xmlElement))
421
+ return;
422
+
423
+ // Create Transform node.
424
+
425
+ const
426
+ scene = this .getExecutionContext (),
427
+ transformNode = this .createTransform (xmlElement),
428
+ switchNode = scene .createNode ("Switch");
429
+
430
+ transformNode .children .push (switchNode);
431
+ switchNode .whichChoice = 0;
432
+
433
+ // Get child elements.
434
+
435
+ this .groupNodes .push (switchNode);
436
+
437
+ this .elements (xmlElement);
438
+
439
+ this .styles .pop ();
440
+ this .groupNodes .pop ();
441
+
442
+ // Add node.
443
+
444
+ this .groupNodes .at (-1) .children .push (transformNode);
445
+ },
446
+ aElement: function (xmlElement)
447
+ {
448
+ // Determine style.
449
+
450
+ if (!this .styleAttributes (xmlElement))
451
+ return;
452
+
453
+ // Get attributes.
454
+
455
+ const
456
+ href = xmlElement .getAttribute ("xlink:href"),
457
+ title = xmlElement .getAttribute ("xlink:title"),
458
+ target = xmlElement .getAttribute ("target");
459
+
460
+ // Create Transform node.
461
+
462
+ const
463
+ scene = this .getExecutionContext (),
464
+ transformNode = this .createTransform (xmlElement),
465
+ anchorNode = scene .createNode ("Anchor");
466
+
467
+ transformNode .children .push (anchorNode);
468
+
469
+ anchorNode .description = title;
470
+ anchorNode .url = [href];
471
+
472
+ if (target)
473
+ anchorNode .parameter = ["target=" + target];
474
+
475
+ // Get child elements.
476
+
477
+ this .groupNodes .push (anchorNode);
478
+
479
+ this .elements (xmlElement);
480
+
481
+ this .groupNodes .pop ();
482
+ this .styles .pop ();
483
+
484
+ this .groupNodes .at (-1) .children .push (transformNode);
485
+ },
486
+ rectElement: function (xmlElement)
487
+ {
488
+ // Determine style.
489
+
490
+ if (!this .styleAttributes (xmlElement))
491
+ return;
492
+
493
+ // Create Transform node.
494
+
495
+ const
496
+ x = this .lengthAttribute (xmlElement .getAttribute ("x"), 0),
497
+ y = this .lengthAttribute (xmlElement .getAttribute ("y"), 0),
498
+ width = this .lengthAttribute (xmlElement .getAttribute ("width"), 0),
499
+ height = this .lengthAttribute (xmlElement .getAttribute ("height"), 0);
500
+
501
+ const
502
+ scene = this .getExecutionContext (),
503
+ size = new Vector2 (width, height),
504
+ center = new Vector2 (x + width / 2, y + height / 2),
505
+ bbox = new Box2 (size, center),
506
+ transformNode = this .createTransform (xmlElement, center);
507
+
508
+ this .groupNodes .push (transformNode);
509
+
510
+ // Create nodes.
511
+
512
+ if (this .style .fillType !== "NONE")
513
+ {
514
+ const
515
+ shapeNode = scene .createNode ("Shape"),
516
+ rectangleNode = scene .createNode ("Rectangle2D");
517
+
518
+ shapeNode .appearance = this .createFillAppearance (bbox);
519
+ shapeNode .geometry = rectangleNode;
520
+ rectangleNode .solid = this .solid;
521
+ rectangleNode .size = size;
522
+
523
+ transformNode .children .push (shapeNode);
524
+ }
525
+
526
+ if (this .style .strokeType !== "NONE")
527
+ {
528
+ const
529
+ shapeNode = scene .createNode ("Shape"),
530
+ polylineNode = scene .createNode ("Polyline2D"),
531
+ width1_2 = width / 2,
532
+ height1_2 = height / 2;
533
+
534
+ shapeNode .appearance = this .createStrokeAppearance ();
535
+ shapeNode .geometry = polylineNode;
536
+
537
+ polylineNode .lineSegments = [ width1_2, height1_2,
538
+ -width1_2, height1_2,
539
+ -width1_2, -height1_2,
540
+ width1_2, -height1_2,
541
+ width1_2, height1_2];
542
+
543
+ transformNode .children .push (shapeNode);
544
+ }
545
+
546
+ this .groupNodes .pop ();
547
+ this .styles .pop ();
548
+
549
+ this .groupNodes .at (-1) .children .push (transformNode);
550
+ },
551
+ circleElement: function (xmlElement)
552
+ {
553
+ // Determine style.
554
+
555
+ if (!this .styleAttributes (xmlElement))
556
+ return;
557
+
558
+ // Create Transform node.
559
+
560
+ const
561
+ cx = this .lengthAttribute (xmlElement .getAttribute ("cx"), 0),
562
+ cy = this .lengthAttribute (xmlElement .getAttribute ("cy"), 0),
563
+ r = this .lengthAttribute (xmlElement .getAttribute ("r"), 0);
564
+
565
+ const
566
+ scene = this .getExecutionContext (),
567
+ bbox = new Box2 (new Vector2 (r * 2, r * 2), new Vector2 (cx, cy)),
568
+ transformNode = this .createTransform (xmlElement, new Vector2 (cx, cy));
569
+
570
+ this .groupNodes .push (transformNode);
571
+
572
+ // Create nodes.
573
+
574
+ if (this .style .fillType !== "NONE")
575
+ {
576
+ const
577
+ shapeNode = scene .createNode ("Shape"),
578
+ diskNode = scene .createNode ("Disk2D");
579
+
580
+ shapeNode .appearance = this .createFillAppearance (bbox);
581
+ shapeNode .geometry = diskNode;
582
+ diskNode .solid = this .solid;
583
+ diskNode .outerRadius = r;
584
+
585
+ transformNode .children .push (shapeNode);
586
+ }
587
+
588
+ if (this .style .strokeType !== "NONE")
589
+ {
590
+ const
591
+ shapeNode = scene .createNode ("Shape"),
592
+ circleNode = scene .createNode ("Circle2D");
593
+
594
+ shapeNode .appearance = this .createStrokeAppearance ();
595
+ shapeNode .geometry = circleNode;
596
+ circleNode .radius = r;
597
+
598
+ transformNode .children .push (shapeNode);
599
+ }
600
+
601
+ this .groupNodes .pop ();
602
+ this .styles .pop ();
603
+
604
+ this .groupNodes .at (-1) .children .push (transformNode);
605
+ },
606
+ ellipseElement: function (xmlElement)
607
+ {
608
+ // Determine style.
609
+
610
+ if (!this .styleAttributes (xmlElement))
611
+ return;
612
+
613
+ // Create Transform node.
614
+
615
+ const
616
+ cx = this .lengthAttribute (xmlElement .getAttribute ("cx"), 0),
617
+ cy = this .lengthAttribute (xmlElement .getAttribute ("cy"), 0),
618
+ rx = this .lengthAttribute (xmlElement .getAttribute ("rx"), 0),
619
+ ry = this .lengthAttribute (xmlElement .getAttribute ("ry"), 0);
620
+
621
+ const
622
+ scene = this .getExecutionContext (),
623
+ rMin = Math .min (rx, ry),
624
+ bbox = new Box2 (new Vector2 (rx * 2, ry * 2), new Vector2 (cx, cy)),
625
+ transformNode = this .createTransform (xmlElement, new Vector2 (cx, cy), new Vector2 (rx / rMin, ry / rMin));
626
+
627
+ this .groupNodes .push (transformNode);
628
+
629
+ // Create nodes.
630
+
631
+ if (this .style .fillType !== "NONE")
632
+ {
633
+ const
634
+ shapeNode = scene .createNode ("Shape"),
635
+ diskNode = scene .createNode ("Disk2D");
636
+
637
+ shapeNode .appearance = this .createFillAppearance (bbox);
638
+ shapeNode .geometry = diskNode;
639
+ diskNode .solid = this .solid;
640
+ diskNode .outerRadius = rMin;
641
+
642
+ transformNode .children .push (shapeNode);
643
+ }
644
+
645
+ if (this .style .strokeType !== "NONE")
646
+ {
647
+ const
648
+ shapeNode = scene .createNode ("Shape"),
649
+ circleNode = scene .createNode ("Circle2D");
650
+
651
+ shapeNode .appearance = this .createStrokeAppearance ();
652
+ shapeNode .geometry = circleNode;
653
+ circleNode .radius = rMin;
654
+
655
+ transformNode .children .push (shapeNode);
656
+ }
657
+
658
+ this .groupNodes .pop ();
659
+ this .styles .pop ();
660
+
661
+ this .groupNodes .at (-1) .children .push (transformNode);
662
+ },
663
+ textElement: function (xmlElement)
664
+ {
665
+
666
+ },
667
+ imageElement: function (xmlElement)
668
+ {
669
+ // Create Transform node.
670
+
671
+ const
672
+ x = this .lengthAttribute (xmlElement .getAttribute ("x"), 0),
673
+ y = this .lengthAttribute (xmlElement .getAttribute ("y"), 0),
674
+ width = this .lengthAttribute (xmlElement .getAttribute ("width"), 0),
675
+ height = this .lengthAttribute (xmlElement .getAttribute ("height"), 0),
676
+ href = xmlElement .getAttribute ("xlink:href");
677
+
678
+ const
679
+ scene = this .getExecutionContext (),
680
+ transformNode = this .createTransform (xmlElement, new Vector2 (x + width / 2, y + height / 2), new Vector2 (1, -1));
681
+
682
+ this .groupNodes .push (transformNode);
683
+
684
+ // Create nodes.
685
+
686
+ const
687
+ shapeNode = scene .createNode ("Shape"),
688
+ appearanceNode = scene .createNode ("Appearance"),
689
+ textureNode = scene .createNode ("ImageTexture"),
690
+ rectangleNode = scene .createNode ("Rectangle2D");
691
+
692
+ shapeNode .appearance = appearanceNode;
693
+ shapeNode .geometry = rectangleNode;
694
+ appearanceNode .texture = textureNode;
695
+ textureNode .url = [href];
696
+ textureNode .textureProperties = this .texturePropertiesNode;
697
+ rectangleNode .solid = this .solid;
698
+ rectangleNode .size = new Vector2 (width, height);
699
+
700
+ transformNode .children .push (shapeNode);
701
+
702
+ this .groupNodes .pop ();
703
+ this .groupNodes .at (-1) .children .push (transformNode);
704
+ },
705
+ polylineElement: function (xmlElement, closed = false)
706
+ {
707
+ const points = Object .assign ([ ], { index: 0 });
708
+
709
+ if (!this .pointsAttribute (xmlElement .getAttribute ("points"), points))
710
+ return;
711
+
712
+ // Determine style.
713
+
714
+ if (!this .styleAttributes (xmlElement))
715
+ return;
716
+
717
+ // Create Transform node.
718
+
719
+ const
720
+ scene = this .getExecutionContext (),
721
+ transformNode = this .createTransform (xmlElement),
722
+ bbox = new Box2 (Vector2 .min (... points), Vector2 .max (... points), true);
723
+
724
+ this .groupNodes .push (transformNode);
725
+
726
+ // Create nodes.
727
+
728
+ const coordinateNode = scene .createNode ("Coordinate");
729
+
730
+ for (const point of points)
731
+ coordinateNode .point .push (new Vector3 (point .x, point .y, 0));
732
+
733
+ if (this .style .fillType !== "NONE")
734
+ {
735
+ const
736
+ shapeNode = scene .createNode ("Shape"),
737
+ geometryNode = scene .createNode ("IndexedTriangleSet");
738
+
739
+ shapeNode .appearance = this .createFillAppearance (bbox);
740
+ shapeNode .geometry = geometryNode;
741
+ geometryNode .solid = this .solid;
742
+ geometryNode .index = this .triangulatePolygon ([points], coordinateNode);
743
+ geometryNode .texCoord = this .createTextureCoordinate (coordinateNode, bbox);
744
+ geometryNode .coord = coordinateNode;
745
+
746
+ transformNode .children .push (shapeNode);
747
+ }
748
+
749
+ if (this .style .strokeType !== "NONE")
750
+ {
751
+ const
752
+ shapeNode = scene .createNode ("Shape"),
753
+ geometryNode = scene .createNode ("IndexedLineSet");
754
+
755
+ shapeNode .appearance = this .createStrokeAppearance ();
756
+ shapeNode .geometry = geometryNode;
757
+ geometryNode .coordIndex = [... points .keys (), ... (closed ? [points [0]] : [ ]), -1];
758
+ geometryNode .coord = coordinateNode;
759
+
760
+ transformNode .children .push (shapeNode);
761
+ }
762
+
763
+ this .groupNodes .pop ();
764
+ this .styles .pop ();
765
+
766
+ this .groupNodes .at (-1) .children .push (transformNode);
767
+ },
768
+ polygonElement: function (xmlElement)
769
+ {
770
+ this .polylineElement (xmlElement, true);
771
+ },
772
+ pathElement: function (xmlElement)
773
+ {
774
+ // Get path points.
775
+
776
+ const contours = [ ];
777
+
778
+ if (!this .dAttribute (xmlElement .getAttribute ("d"), contours))
779
+ return;
780
+
781
+ // Determine style.
782
+
783
+ if (!this .styleAttributes (xmlElement))
784
+ return;
785
+
786
+ // Create Transform node.
787
+
788
+ const
789
+ scene = this .getExecutionContext (),
790
+ transformNode = this .createTransform (xmlElement),
791
+ bbox = new Box2 ();
792
+
793
+ for (const points of contours)
794
+ bbox .add (new Box2 (Vector2 .min (... points), Vector2 .max (... points), true));
795
+
796
+ this .groupNodes .push (transformNode);
797
+
798
+ // Create nodes.
799
+
800
+ const coordinateNode = scene .createNode ("Coordinate");
801
+
802
+ for (const points of contours)
803
+ {
804
+ for (const point of points)
805
+ coordinateNode .point .push (new Vector3 (point .x, point .y, 0));
806
+ }
807
+
808
+ if (this .style .fillType !== "NONE")
809
+ {
810
+ const
811
+ shapeNode = scene .createNode ("Shape"),
812
+ geometryNode = scene .createNode ("IndexedTriangleSet");
813
+
814
+ shapeNode .appearance = this .createFillAppearance (bbox);
815
+ shapeNode .geometry = geometryNode;
816
+ geometryNode .solid = this .solid;
817
+ geometryNode .index = this .triangulatePolygon (contours, coordinateNode);
818
+ geometryNode .texCoord = this .createTextureCoordinate (coordinateNode, bbox);
819
+ geometryNode .coord = coordinateNode;
820
+
821
+ transformNode .children .push (shapeNode);
822
+ }
823
+
824
+ if (this .style .strokeType !== "NONE")
825
+ {
826
+ const
827
+ shapeNode = scene .createNode ("Shape"),
828
+ geometryNode = scene .createNode ("IndexedLineSet");
829
+
830
+ shapeNode .appearance = this .createStrokeAppearance ();
831
+ shapeNode .geometry = geometryNode;
832
+ geometryNode .coord = coordinateNode;
833
+
834
+ for (const points of contours)
835
+ {
836
+ for (const i of points .keys ())
837
+ geometryNode .coordIndex .push (points .index + i);
838
+
839
+ if (points .closed)
840
+ geometryNode .coordIndex .push (points .index);
841
+
842
+ geometryNode .coordIndex .push (-1);
843
+ }
844
+
845
+ transformNode .children .push (shapeNode);
846
+ }
847
+
848
+ this .groupNodes .pop ();
849
+ this .styles .pop ();
850
+
851
+ this .groupNodes .at (-1) .children .push (transformNode);
852
+ },
853
+ linearGradientElementURL: function (xmlElement, bbox)
854
+ {
855
+ const
856
+ g = this .linearGradientElement (xmlElement, { stops: [ ] }),
857
+ gradient = this .context .createLinearGradient (g .x1, g .y1, g .x2, g .y2);
858
+
859
+ for (const [o, c, a] of g .stops)
860
+ gradient .addColorStop (o, `rgba(${c .r * 255},${c .g * 255},${c .b * 255},${a})`);
861
+
862
+ return this .drawGradient (gradient, g .transform, bbox);
863
+ },
864
+ linearGradientElement: function (xmlElement, gradient)
865
+ {
866
+ if (xmlElement .nodeName !== "linearGradient")
867
+ return;
868
+
869
+ // Attribute xlink:href
870
+
871
+ const refElement = this .hrefAttribute (xmlElement .getAttribute ("xlink:href"));
872
+
873
+ if (refElement)
874
+ this .gradientElement (refElement, gradient);
875
+
876
+ // Attributes
877
+
878
+ gradient .x1 = this .lengthAttribute (xmlElement .getAttribute ("x1"), gradient .x1 || 0);
879
+ gradient .y1 = this .lengthAttribute (xmlElement .getAttribute ("y1"), gradient .y1 || 0);
880
+ gradient .x2 = this .lengthAttribute (xmlElement .getAttribute ("x2"), gradient .x2 || 0);
881
+ gradient .y2 = this .lengthAttribute (xmlElement .getAttribute ("y2"), gradient .y2 || 0);
882
+ gradient .units = xmlElement .getAttribute ("gradientUnits");
883
+ gradient .transform = this .transformAttribute (xmlElement .getAttribute ("gradientTransform"));
884
+
885
+ // Stops
886
+
887
+ for (const childNode of xmlElement .childNodes)
888
+ this .gradientChild (childNode, gradient);
889
+
890
+ return gradient;
891
+ },
892
+ radialGradientElementURL: function (xmlElement, bbox)
893
+ {
894
+ const
895
+ g = this .radialGradientElement (xmlElement, { stops: [ ] }),
896
+ gradient = this .context .createRadialGradient (g .fx, g .fy, 0, g .cx, g .cy, g .r);
897
+
898
+ for (const [o, c, a] of g .stops)
899
+ gradient .addColorStop (o, `rgba(${c .r * 255},${c .g * 255},${c .b * 255},${a})`);
900
+
901
+ return this .drawGradient (gradient, g .transform, bbox);
902
+ },
903
+ radialGradientElement: function (xmlElement, gradient)
904
+ {
905
+ // Attribute xlink:href
906
+
907
+ const refElement = this .hrefAttribute (xmlElement .getAttribute ("xlink:href"));
908
+
909
+ if (refElement)
910
+ this .gradientElement (refElement, gradient);
911
+
912
+ // Attributes
913
+
914
+ gradient .cx = this .lengthAttribute (xmlElement .getAttribute ("cx"), gradient .cx || 0),
915
+ gradient .cy = this .lengthAttribute (xmlElement .getAttribute ("cy"), gradient .cy || 0),
916
+ gradient .x2 = this .lengthAttribute (xmlElement .getAttribute ("x2"), gradient .x2 || 0),
917
+ gradient .y2 = this .lengthAttribute (xmlElement .getAttribute ("y2"), gradient .y2 || 0),
918
+ gradient .r = this .lengthAttribute (xmlElement .getAttribute ("r"), gradient .cx),
919
+ gradient .fx = this .lengthAttribute (xmlElement .getAttribute ("fx"), gradient .cx),
920
+ gradient .fy = this .lengthAttribute (xmlElement .getAttribute ("fy"), gradient .cy),
921
+ gradient .units = xmlElement .getAttribute ("gradientUnits");
922
+ gradient .spreadMethod = xmlElement .getAttribute ("spreadMethod");
923
+ gradient .transform = this .transformAttribute (xmlElement .getAttribute ("gradientTransform"));
924
+
925
+ // Stops
926
+
927
+ for (const childNode of xmlElement .childNodes)
928
+ this .gradientChild (childNode, gradient);
929
+
930
+ return gradient;
931
+ },
932
+ gradientElement: function (xmlElement, gradient)
933
+ {
934
+ if (!xmlElement)
935
+ return;
936
+
937
+ switch (xmlElement .nodeName)
938
+ {
939
+ case "linearGradient":
940
+ return this .linearGradientElement (xmlElement, gradient);
941
+ case "radialGradient":
942
+ return this .radialGradientElement (xmlElement, gradient);
943
+ }
944
+ },
945
+ gradientChild: function (xmlElement, gradient)
946
+ {
947
+ if (xmlElement .nodeName === "stop")
948
+ return this .stopElement (xmlElement, gradient);
949
+ },
950
+ stopElement: function (xmlElement, gradient)
951
+ {
952
+ if (!this .styleAttributes (xmlElement))
953
+ return;
954
+
955
+ const offset = this .percentAttribute (xmlElement .getAttribute ("offset"), 0);
956
+
957
+ const { stopColor, stopOpacity } = this .style;
958
+
959
+ gradient .stops .push ([offset, stopColor, stopOpacity]);
960
+
961
+ this .styles .pop ();
962
+ },
963
+ drawGradient: function (gradient, transform, bbox)
964
+ {
965
+ const m = new Matrix3 ();
966
+
967
+ m .scale (new Vector2 (GRADIENT_SIZE / 2, GRADIENT_SIZE / 2));
968
+ m .translate (Vector2 .One);
969
+ m .scale (new Vector2 (1, -1));
970
+ m .multLeft (Matrix3 .inverse (bbox .matrix));
971
+ m .multLeft (transform);
972
+
973
+ // Paint.
974
+
975
+ const cx = this .context;
976
+
977
+ cx .fillStyle = gradient;
978
+ cx .save ();
979
+ cx .clearRect (0, 0, GRADIENT_SIZE, GRADIENT_SIZE);
980
+ cx .rect (0, 0, GRADIENT_SIZE, GRADIENT_SIZE);
981
+ cx .transform (m [0], m [1], m [3], m [4], m [6], m [7]);
982
+ cx .fill ();
983
+ cx .restore ();
984
+
985
+ // Use PNG because image can have alpha channel.
986
+ return this .canvas .toDataURL ("image/png");
987
+ },
988
+ idAttribute: function (attribute, node)
989
+ {
990
+ if (attribute === null)
991
+ return;
992
+
993
+ const
994
+ scene = this .getExecutionContext (),
995
+ name = this .sanitizeName (attribute);
996
+
997
+ if (name)
998
+ scene .addNamedNode (scene .getUniqueName (name), node);
999
+ },
1000
+ viewBoxAttribute: function (attribute, defaultValue)
1001
+ {
1002
+ if (attribute === null)
1003
+ return defaultValue;
1004
+
1005
+ this .parseValue (attribute);
1006
+
1007
+ if (this .double ())
1008
+ {
1009
+ const x = this .value;
1010
+
1011
+ if (this .double ())
1012
+ {
1013
+ const y = this .value;
1014
+
1015
+ if (this .double ())
1016
+ {
1017
+ const width = this .value;
1018
+
1019
+ if (this .double ())
1020
+ {
1021
+ const height = this .value;
1022
+
1023
+ return new Vector4 (x, y, width, height);
1024
+ }
1025
+ }
1026
+ }
1027
+ }
1028
+
1029
+ return defaultValue;
1030
+ },
1031
+ hrefAttribute: function (attribute)
1032
+ {
1033
+ const
1034
+ scene = this .getExecutionContext (),
1035
+ hash = new URL (attribute, scene .getWorldURL ()) .hash .slice (1);
1036
+
1037
+ return this .document .getElementById (hash);
1038
+ },
1039
+ lengthAttribute: function (attribute, defaultValue)
1040
+ {
1041
+ // Returns length in pixel.
1042
+
1043
+ if (attribute === null)
1044
+ return defaultValue;
1045
+
1046
+ this .parseValue (attribute);
1047
+
1048
+ if (this .double ())
1049
+ {
1050
+ let value = this .value;
1051
+
1052
+ // Parse unit
1053
+
1054
+ if (Grammar .length .parse (this))
1055
+ {
1056
+ switch (this .result [1])
1057
+ {
1058
+ case "em":
1059
+ value *= EM;
1060
+ break;
1061
+ case "ex":
1062
+ // TODO
1063
+ break;
1064
+ case "px":
1065
+ // We are pixels :)
1066
+ break;
1067
+ case "in":
1068
+ value *= INCH / PIXEL;
1069
+ break;
1070
+ case "cm":
1071
+ value *= CM / PIXEL;
1072
+ break;
1073
+ case "mm":
1074
+ value *= MM / PIXEL;
1075
+ break;
1076
+ case "pt":
1077
+ value *= POINT / PIXEL;
1078
+ break;
1079
+ case "pc":
1080
+ value *= PICA / PIXEL;
1081
+ break;
1082
+ }
1083
+ }
1084
+
1085
+ return value;
1086
+ }
1087
+
1088
+ return defaultValue;
1089
+ },
1090
+ percentAttribute: function (attribute, defaultValue)
1091
+ {
1092
+ this .parseValue (attribute);
1093
+
1094
+ if (this .double ())
1095
+ {
1096
+ let value = this .value;
1097
+
1098
+ // Parse unit
1099
+
1100
+ if (Grammar .percent .parse (this))
1101
+ value /= 100;
1102
+
1103
+ return Algorithm .clamp (value, 0, 1);
1104
+ }
1105
+
1106
+ return defaultValue;
1107
+ },
1108
+ pointsAttribute: function (attribute, points)
1109
+ {
1110
+ if (attribute === null)
1111
+ return false;
1112
+
1113
+ this .parseValue (attribute);
1114
+
1115
+ while (true)
1116
+ {
1117
+ if (this .double ())
1118
+ {
1119
+ const x = this .value;
1120
+
1121
+ if (this .comma ())
1122
+ {
1123
+ if (this .double ())
1124
+ {
1125
+ const y = this .value;
1126
+
1127
+ points .push (new Vector2 (x, y));
1128
+
1129
+ if (this .comma ())
1130
+ continue;
1131
+ }
1132
+ }
1133
+ }
1134
+
1135
+ break;
1136
+ }
1137
+
1138
+ return !! points .length;
1139
+ },
1140
+ dAttribute: function (attribute, contours)
1141
+ {
1142
+ if (attribute === null)
1143
+ return false;
1144
+
1145
+ this .parseValue (attribute);
1146
+
1147
+ let
1148
+ points = [ ],
1149
+ index = 0,
1150
+ previous = "",
1151
+ command = "",
1152
+ relative = false,
1153
+ ax = 0,
1154
+ ay = 0,
1155
+ px = 0,
1156
+ py = 0;
1157
+
1158
+ while (true)
1159
+ {
1160
+ this .whitespaces ();
1161
+
1162
+ if (!Grammar .path .parse (this))
1163
+ break;
1164
+
1165
+ previous = command;
1166
+ command = this .result [1];
1167
+ relative = command === command .toLowerCase ();
1168
+
1169
+ switch (command)
1170
+ {
1171
+ case "m":
1172
+ case "M":
1173
+ {
1174
+ // moveto
1175
+
1176
+ points = this .removeConsecutiveIdenticalPoints (points);
1177
+
1178
+ if (points .length > 2)
1179
+ {
1180
+ contours .push (Object .assign (points, { index: index, closed: false }));
1181
+
1182
+ index += points .length;
1183
+ }
1184
+
1185
+ points = [ ];
1186
+
1187
+ while (true)
1188
+ {
1189
+ if (this .double ())
1190
+ {
1191
+ let x = this .value;
1192
+
1193
+ this .comma ();
1194
+
1195
+ if (this .double ())
1196
+ {
1197
+ let y = this .value;
1198
+
1199
+ if (relative)
1200
+ {
1201
+ x += ax;
1202
+ y += ay;
1203
+ }
1204
+
1205
+ points .push (new Vector2 (x, y));
1206
+
1207
+ ax = x;
1208
+ ay = y;
1209
+
1210
+ this .comma ();
1211
+ continue;
1212
+ }
1213
+ }
1214
+
1215
+ break;
1216
+ }
1217
+
1218
+ continue;
1219
+ }
1220
+ case "l":
1221
+ case "L":
1222
+ {
1223
+ // lineto
1224
+
1225
+ while (true)
1226
+ {
1227
+ if (this .double ())
1228
+ {
1229
+ let x = this .value;
1230
+
1231
+ this .comma ();
1232
+
1233
+ if (this .double ())
1234
+ {
1235
+ let y = this .value;
1236
+
1237
+ if (relative)
1238
+ {
1239
+ x += ax;
1240
+ y += ay;
1241
+ }
1242
+
1243
+ points .push (new Vector2 (x, y));
1244
+
1245
+ ax = x;
1246
+ ay = y;
1247
+
1248
+ this .comma ();
1249
+ continue;
1250
+ }
1251
+ }
1252
+
1253
+ break;
1254
+ }
1255
+
1256
+ continue;
1257
+ }
1258
+ case "h":
1259
+ case "H":
1260
+ {
1261
+ // horizontal lineto
1262
+
1263
+ while (true)
1264
+ {
1265
+ if (this .double ())
1266
+ {
1267
+ let x = this .value;
1268
+
1269
+ if (relative)
1270
+ x += ax;
1271
+
1272
+ points .push (new Vector2 (x, ay));
1273
+
1274
+ ax = x;
1275
+
1276
+ this .comma ();
1277
+ continue;
1278
+ }
1279
+
1280
+ break;
1281
+ }
1282
+
1283
+ continue;
1284
+ }
1285
+ case "v":
1286
+ case "V":
1287
+ {
1288
+ // vertical lineto
1289
+
1290
+ while (this)
1291
+ {
1292
+ if (this .double ())
1293
+ {
1294
+ let y = this .value;
1295
+
1296
+ if (relative)
1297
+ y += ay;
1298
+
1299
+ points .push (new Vector2 (ax, y));
1300
+
1301
+ ay = y;
1302
+
1303
+ this .comma ();
1304
+ continue;
1305
+ }
1306
+
1307
+ break;
1308
+ }
1309
+
1310
+ continue;
1311
+ }
1312
+ case "q":
1313
+ case "Q":
1314
+ {
1315
+ // quadratic Bézier curveto
1316
+
1317
+ while (true)
1318
+ {
1319
+ if (this .double ())
1320
+ {
1321
+ let x1 = this .value;
1322
+
1323
+ this .comma ();
1324
+
1325
+ if (this .double ())
1326
+ {
1327
+ let y1 = this .value;
1328
+
1329
+ this .comma ();
1330
+
1331
+ if (this .double ())
1332
+ {
1333
+ let x = this .value;
1334
+
1335
+ this .comma ();
1336
+
1337
+ if (this .double ())
1338
+ {
1339
+ let y = this .value;
1340
+
1341
+ if (relative)
1342
+ {
1343
+ x1 += ax;
1344
+ y1 += ay;
1345
+ x += ax;
1346
+ y += ay;
1347
+ }
1348
+
1349
+ const curve = new Bezier (ax, ay, x1, y1, x, y);
1350
+
1351
+ points .push (... curve .getPoints ("quadric", BEZIER_STEPS));
1352
+
1353
+ ax = x;
1354
+ ay = y;
1355
+ px = x1;
1356
+ py = y1;
1357
+
1358
+ this .comma ();
1359
+ continue;
1360
+ }
1361
+ }
1362
+ }
1363
+ }
1364
+
1365
+ break;
1366
+ }
1367
+
1368
+ continue;
1369
+ }
1370
+ case "t":
1371
+ case "T":
1372
+ {
1373
+ // Shorthand/smooth quadratic Bézier curveto
1374
+
1375
+ while (true)
1376
+ {
1377
+ if (this .double ())
1378
+ {
1379
+ let x = this .value;
1380
+
1381
+ this .comma ();
1382
+
1383
+ if (this .double ())
1384
+ {
1385
+ let y = this .value;
1386
+
1387
+ if (relative)
1388
+ {
1389
+ x += ax;
1390
+ y += ay;
1391
+ }
1392
+
1393
+ switch (previous)
1394
+ {
1395
+ case 'Q':
1396
+ case 'q':
1397
+ case 'T':
1398
+ case 't':
1399
+ {
1400
+ x1 = ax + (ax - px);
1401
+ y1 = ay + (ay - py);
1402
+ break;
1403
+ }
1404
+ default:
1405
+ {
1406
+ x1 = ax;
1407
+ y1 = ay;
1408
+ break;
1409
+ }
1410
+ }
1411
+
1412
+ const curve = new Bezier (ax, ay, x1, y1, x, y);
1413
+
1414
+ points .push (... curve .getPoints ("quadric", BEZIER_STEPS));
1415
+
1416
+ ax = x;
1417
+ ay = y;
1418
+
1419
+ this .comma ();
1420
+ continue;
1421
+ }
1422
+ }
1423
+
1424
+ break;
1425
+ }
1426
+
1427
+ continue;
1428
+ }
1429
+ case "c":
1430
+ case "C":
1431
+ {
1432
+ // curveto, cubic Bézier curve
1433
+
1434
+ while (true)
1435
+ {
1436
+ if (this .double ())
1437
+ {
1438
+ let x1 = this .value;
1439
+
1440
+ this .comma ();
1441
+
1442
+ if (this .double ())
1443
+ {
1444
+ let y1 = this .value;
1445
+
1446
+ this .comma ();
1447
+
1448
+ if (this .double ())
1449
+ {
1450
+ let x2 = this .value;
1451
+
1452
+ this .comma ();
1453
+
1454
+ if (this .double ())
1455
+ {
1456
+ let y2 = this .value;
1457
+
1458
+ this .comma ();
1459
+
1460
+ if (this .double ())
1461
+ {
1462
+ let x = this .value;
1463
+
1464
+ this .comma ();
1465
+
1466
+ if (this .double ())
1467
+ {
1468
+ let y = this .value;
1469
+
1470
+ if (relative)
1471
+ {
1472
+ x1 += ax;
1473
+ y1 += ay;
1474
+ x2 += ax;
1475
+ y2 += ay;
1476
+ x += ax;
1477
+ y += ay;
1478
+ }
1479
+
1480
+ const curve = new Bezier (ax, ay, x1, y1, x2, y2, x, y);
1481
+
1482
+ points .push (... curve .getPoints ("cubic", BEZIER_STEPS));
1483
+
1484
+ ax = x;
1485
+ ay = y;
1486
+ px = x2;
1487
+ py = y2;
1488
+
1489
+ this .comma ();
1490
+ continue;
1491
+ }
1492
+ }
1493
+ }
1494
+ }
1495
+ }
1496
+ }
1497
+
1498
+ break;
1499
+ }
1500
+
1501
+ continue;
1502
+ }
1503
+ case "s":
1504
+ case "S":
1505
+ {
1506
+ // shorthand/smooth curveto, cubic Bézier curve
1507
+
1508
+ while (true)
1509
+ {
1510
+ if (this .double ())
1511
+ {
1512
+ let x2 = this .value;
1513
+
1514
+ this .comma ();
1515
+
1516
+ if (this .double ())
1517
+ {
1518
+ let y2 = this .value;
1519
+
1520
+ this .comma ();
1521
+
1522
+ if (this .double ())
1523
+ {
1524
+ let x = this .value;
1525
+
1526
+ this .comma ();
1527
+
1528
+ if (this .double ())
1529
+ {
1530
+ let y = this .value;
1531
+
1532
+ if (relative)
1533
+ {
1534
+ x2 += ax;
1535
+ y2 += ay;
1536
+ x += ax;
1537
+ y += ay;
1538
+ }
1539
+
1540
+ switch (previous)
1541
+ {
1542
+ case 'C':
1543
+ case 'c':
1544
+ case 'S':
1545
+ case 's':
1546
+ {
1547
+ x1 = ax + (ax - px);
1548
+ y1 = ay + (ay - py);
1549
+ break;
1550
+ }
1551
+ default:
1552
+ {
1553
+ x1 = ax;
1554
+ y1 = ay;
1555
+ break;
1556
+ }
1557
+ }
1558
+
1559
+ const curve = new Bezier (ax, ay, x1, y1, x2, y2, x, y);
1560
+
1561
+ points .push (... curve .getPoints ("cubic", BEZIER_STEPS));
1562
+
1563
+ ax = x;
1564
+ ay = y;
1565
+ px = x2;
1566
+ py = y2;
1567
+
1568
+ this .comma ();
1569
+ continue;
1570
+ }
1571
+ }
1572
+ }
1573
+ }
1574
+
1575
+ break;
1576
+ }
1577
+
1578
+ continue;
1579
+ }
1580
+ case "a":
1581
+ case "A":
1582
+ {
1583
+ // elliptical arc
1584
+
1585
+ while (true)
1586
+ {
1587
+ if (this .double ())
1588
+ {
1589
+ let rx = this .value;
1590
+
1591
+ this .comma ();
1592
+
1593
+ if (this .double ())
1594
+ {
1595
+ let ry = this .value;
1596
+
1597
+ this .comma ();
1598
+
1599
+ if (this .double ())
1600
+ {
1601
+ let xAxisRotation = this .value;
1602
+
1603
+ this .comma ();
1604
+
1605
+ if (this .int32 ())
1606
+ {
1607
+ let largeArcFlag = this .value;
1608
+
1609
+ this .comma ();
1610
+
1611
+ if (this .int32 ())
1612
+ {
1613
+ let sweepFlag = this .value;
1614
+
1615
+ this .comma ();
1616
+
1617
+ if (this .double ())
1618
+ {
1619
+ let x = this .value;
1620
+
1621
+ this .comma ();
1622
+
1623
+ if (this .double ())
1624
+ {
1625
+ let y = this .value;
1626
+
1627
+ if (relative)
1628
+ {
1629
+ x += ax;
1630
+ y += ay;
1631
+ }
1632
+
1633
+ const curve = new Bezier (ax, ay, rx, ry, Algorithm .radians (xAxisRotation), largeArcFlag, sweepFlag, x, y);
1634
+
1635
+ points .push (... curve .getPoints ("arc", CIRCLE_STEPS));
1636
+
1637
+ ax = x;
1638
+ ay = y;
1639
+
1640
+ this .comma ();
1641
+ continue;
1642
+ }
1643
+ }
1644
+ }
1645
+ }
1646
+ }
1647
+ }
1648
+ }
1649
+
1650
+ break;
1651
+ }
1652
+
1653
+ continue;
1654
+ }
1655
+ case "z":
1656
+ case "Z":
1657
+ {
1658
+ // closepath
1659
+
1660
+ points = this .removeConsecutiveIdenticalPoints (points);
1661
+
1662
+ if (points .length > 2)
1663
+ {
1664
+ ax = points [0] .x;
1665
+ ay = points [0] .y;
1666
+
1667
+ contours .push (Object .assign (points, { index: index, closed: true }));
1668
+
1669
+ index += points .length;
1670
+ }
1671
+
1672
+ points = [ ];
1673
+
1674
+ this .comma ();
1675
+ continue;
1676
+ }
1677
+ }
1678
+
1679
+ break;
1680
+ }
1681
+
1682
+ points = this .removeConsecutiveIdenticalPoints (points);
1683
+
1684
+ if (points .length > 2)
1685
+ contours .push (Object .assign (points, { index: index, closed: false }));
1686
+
1687
+ return !! contours .length;
1688
+ },
1689
+ removeConsecutiveIdenticalPoints: function (points)
1690
+ {
1691
+ return points .filter ((p, i, a) => !p .equals (a [(i + 1) % a .length]));
1692
+ },
1693
+ transformAttribute: function (attribute)
1694
+ {
1695
+ const matrix = new Matrix3 ();
1696
+
1697
+ if (attribute === null)
1698
+ return matrix;
1699
+
1700
+ this .parseValue (attribute);
1701
+
1702
+ while (true)
1703
+ {
1704
+ this .comma ();
1705
+ this .whitespaces ();
1706
+
1707
+ if (Grammar .matrix .parse (this))
1708
+ {
1709
+ this .whitespaces ();
1710
+
1711
+ if (Grammar .openParenthesis .parse (this))
1712
+ {
1713
+ if (this .double ())
1714
+ {
1715
+ const a = this .value;
1716
+
1717
+ if (this .comma ())
1718
+ {
1719
+ if (this .double ())
1720
+ {
1721
+ const b = this .value;
1722
+
1723
+ if (this .comma ())
1724
+ {
1725
+ if (this .double ())
1726
+ {
1727
+ const c = this .value;
1728
+
1729
+ if (this .comma ())
1730
+ {
1731
+ if (this .double ())
1732
+ {
1733
+ const d = this .value;
1734
+
1735
+ if (this .comma ())
1736
+ {
1737
+ if (this .double ())
1738
+ {
1739
+ const e = this .value;
1740
+
1741
+ if (this .comma ())
1742
+ {
1743
+ if (this .double ())
1744
+ {
1745
+ const f = this .value;
1746
+
1747
+ this .whitespaces ();
1748
+
1749
+ if (Grammar .closeParenthesis .parse (this))
1750
+ {
1751
+ matrix .multLeft (new Matrix3 (a, b, 0, c, d, 0, e, f, 1));
1752
+ continue;
1753
+ }
1754
+ }
1755
+ }
1756
+ }
1757
+ }
1758
+ }
1759
+ }
1760
+ }
1761
+ }
1762
+ }
1763
+ }
1764
+ }
1765
+ }
1766
+ }
1767
+ else if (Grammar .translate .parse (this))
1768
+ {
1769
+ this .whitespaces ();
1770
+
1771
+ if (Grammar .openParenthesis .parse (this))
1772
+ {
1773
+ if (this .double ())
1774
+ {
1775
+ const tx = this .value;
1776
+
1777
+ if (this .comma ())
1778
+ {
1779
+ if (this .double ())
1780
+ {
1781
+ const ty = this .value;
1782
+
1783
+ this .whitespaces ();
1784
+
1785
+ if (Grammar .closeParenthesis .parse (this))
1786
+ {
1787
+ matrix .translate (new Vector2 (tx, ty));
1788
+ continue;
1789
+ }
1790
+ }
1791
+ }
1792
+ }
1793
+ }
1794
+ }
1795
+ else if (Grammar .rotate .parse (this))
1796
+ {
1797
+ this .whitespaces ();
1798
+
1799
+ if (Grammar .openParenthesis .parse (this))
1800
+ {
1801
+ if (this .double ())
1802
+ {
1803
+ const angle = this .value;
1804
+
1805
+ this .whitespaces ();
1806
+
1807
+ if (Grammar .closeParenthesis .parse (this))
1808
+ {
1809
+ matrix .rotate (Algorithm .radians (angle));
1810
+ continue;
1811
+ }
1812
+ else
1813
+ {
1814
+ if (this .comma ())
1815
+ {
1816
+ if (this .double ())
1817
+ {
1818
+ const cx = this .value;
1819
+
1820
+ if (this .comma ())
1821
+ {
1822
+ if (this .double ())
1823
+ {
1824
+ const cy = this .value;
1825
+
1826
+ this .whitespaces ();
1827
+
1828
+ if (Grammar .closeParenthesis .parse (this))
1829
+ {
1830
+ matrix .translate (new Vector2 (cx, cy));
1831
+ matrix .rotate (Algorithm .radians (angle));
1832
+ matrix .translate (new Vector2 (-cx, -cy));
1833
+ continue;
1834
+ }
1835
+ }
1836
+ }
1837
+ }
1838
+ }
1839
+ }
1840
+ }
1841
+ }
1842
+ }
1843
+ else if (Grammar .scale .parse (this))
1844
+ {
1845
+ this .whitespaces ();
1846
+
1847
+ if (Grammar .openParenthesis .parse (this))
1848
+ {
1849
+ if (this .double ())
1850
+ {
1851
+ const sx = this .value;
1852
+
1853
+ if (this .comma ())
1854
+ {
1855
+ if (this .double ())
1856
+ {
1857
+ const sy = this .value;
1858
+
1859
+ this .whitespaces ();
1860
+
1861
+ if (Grammar .closeParenthesis .parse (this))
1862
+ {
1863
+ matrix .scale (new Vector2 (sx, sy));
1864
+ continue;
1865
+ }
1866
+ }
1867
+ }
1868
+ }
1869
+ }
1870
+ }
1871
+ else if (Grammar .skewX .parse (this))
1872
+ {
1873
+ this .whitespaces ();
1874
+
1875
+ if (Grammar .openParenthesis .parse (this))
1876
+ {
1877
+ if (this .double ())
1878
+ {
1879
+ const angle = this .value;
1880
+
1881
+ this .whitespaces ();
1882
+
1883
+ if (Grammar .closeParenthesis .parse (this))
1884
+ {
1885
+ matrix .skewX (Algorithm .radians (angle));
1886
+ continue;
1887
+ }
1888
+ }
1889
+ }
1890
+ }
1891
+ else if (Grammar .skewY .parse (this))
1892
+ {
1893
+ this .whitespaces ();
1894
+
1895
+ if (Grammar .openParenthesis .parse (this))
1896
+ {
1897
+ if (this .double ())
1898
+ {
1899
+ const angle = this .value;
1900
+
1901
+ this .whitespaces ();
1902
+
1903
+ if (Grammar .closeParenthesis .parse (this))
1904
+ {
1905
+ matrix .skewY (Algorithm .radians (angle));
1906
+ continue;
1907
+ }
1908
+ }
1909
+ }
1910
+ }
1911
+
1912
+ break;
1913
+ }
1914
+
1915
+ return matrix;
1916
+ },
1917
+ styleAttributes: (function ()
1918
+ {
1919
+ const Styles = [
1920
+ "display",
1921
+ "fill",
1922
+ "fill-opacity",
1923
+ "fill-rule",
1924
+ "stroke",
1925
+ "stroke-opacity",
1926
+ "stroke-width",
1927
+ "opacity",
1928
+ "stop-color",
1929
+ "stop-opacity",
1930
+ ];
1931
+
1932
+ return function (xmlElement)
1933
+ {
1934
+ const style = Object .assign ({ }, this .styles [0]);
1935
+
1936
+ if (this .style .display === "none")
1937
+ return false;
1938
+
1939
+ this .styles .push (style);
1940
+
1941
+ for (const style of Styles)
1942
+ {
1943
+ const attribute = xmlElement .getAttribute (style);
1944
+
1945
+ this .parseStyle (style, attribute ?? "default");
1946
+ }
1947
+
1948
+ // Style attribute has higher precedence.
1949
+
1950
+ this .styleAttribute (xmlElement .getAttribute ("style"));
1951
+
1952
+ return true;
1953
+ };
1954
+ })(),
1955
+ styleAttribute: function (attribute)
1956
+ {
1957
+ if (attribute === null)
1958
+ return;
1959
+
1960
+ const values = attribute .split (";");
1961
+
1962
+ for (const value of values)
1963
+ {
1964
+ const pair = value .split (":");
1965
+
1966
+ if (pair .length !== 2)
1967
+ continue;
1968
+
1969
+ this .parseStyle (pair [0] .trim (), pair [1] .trim ());
1970
+ }
1971
+ },
1972
+ parseStyle: function (style, value)
1973
+ {
1974
+ this .parseValue (value);
1975
+
1976
+ switch (style)
1977
+ {
1978
+ case "display":
1979
+ this .displayStyle (value);
1980
+ break;
1981
+ case "fill":
1982
+ this .fillStyle (value);
1983
+ break;
1984
+ case "fill-opacity":
1985
+ this .fillOpacityStyle (value);
1986
+ break;
1987
+ case "fill-rule":
1988
+ this .fillRuleStyle (value);
1989
+ break;
1990
+ case "stroke":
1991
+ this .strokeStyle (value);
1992
+ break;
1993
+ case "stroke-opacity":
1994
+ this .strokeOpacityStyle (value);
1995
+ break;
1996
+ case "stroke-width":
1997
+ this .strokeWidthStyle (value);
1998
+ break;
1999
+ case "opacity":
2000
+ this .opacityStyle (value);
2001
+ break;
2002
+ case "stop-color":
2003
+ this .stopColorStyle (value);
2004
+ break;
2005
+ case "stop-opacity":
2006
+ this .stopOpacityStyle (value);
2007
+ break;
2008
+ }
2009
+ },
2010
+ displayStyle: function (value)
2011
+ {
2012
+ if (value === null)
2013
+ return;
2014
+
2015
+ if (value === "default")
2016
+ return;
2017
+
2018
+ if (value === "inherit")
2019
+ {
2020
+ this .style .display = styles .at (-1) .display;
2021
+ return;
2022
+ }
2023
+
2024
+ this .style .display = value;
2025
+ },
2026
+ fillStyle: function (value)
2027
+ {
2028
+ if (this .urlValue ())
2029
+ {
2030
+ this .style .fillType = "URL";
2031
+ this .style .fillURL = this .result [1] .trim ();
2032
+ return;
2033
+ }
2034
+
2035
+ if (value === "transparent")
2036
+ {
2037
+ this .style .fillType = "NONE";
2038
+ return;
2039
+ }
2040
+
2041
+ if (value === "none")
2042
+ {
2043
+ this .style .fillType ="NONE";
2044
+ return;
2045
+ }
2046
+
2047
+ if (!value .match (/^(?:inherit|unset|default)$/))
2048
+ {
2049
+ if (this .colorValue ())
2050
+ {
2051
+ this .style .fillType = "COLOR";
2052
+ this .style .fillColor = this .value .copy ();
2053
+ return;
2054
+ }
2055
+ }
2056
+
2057
+ // inherit
2058
+
2059
+ this .style .fillType = this .styles .at (-1) .fillType;
2060
+ this .style .fillColor = this .styles .at (-1) .fillColor;
2061
+ this .style .fillURL = this .styles .at (-1) .fillURL;
2062
+ },
2063
+ fillOpacityStyle: function (value)
2064
+ {
2065
+ if (this .double ())
2066
+ {
2067
+ this .style .fillOpacity = Algorithm .clamp (this .value, 0, 1);
2068
+ return;
2069
+ }
2070
+
2071
+ if (value === "transparent")
2072
+ {
2073
+ this .style .fillOpacity = 0;
2074
+ return;
2075
+ }
2076
+
2077
+ // inherit
2078
+
2079
+ this .style .fillOpacity = this .styles .at (-1) .fillOpacity;
2080
+ },
2081
+ fillRuleStyle: function (value)
2082
+ {
2083
+ this .style .fillRule = value;
2084
+ },
2085
+ strokeStyle: function (value)
2086
+ {
2087
+ if (this .urlValue ())
2088
+ {
2089
+ this .style .strokeType = "URL";
2090
+ this .style .strokeURL = this .result [1] .trim ();
2091
+ return;
2092
+ }
2093
+
2094
+ if (value === "transparent")
2095
+ {
2096
+ this .style .strokeType = "NONE";
2097
+ return;
2098
+ }
2099
+
2100
+ if (value === "none")
2101
+ {
2102
+ this .style .strokeType ="NONE";
2103
+ return;
2104
+ }
2105
+
2106
+ if (!value .match (/^(?:inherit|unset|default)$/))
2107
+ {
2108
+ if (this .colorValue ())
2109
+ {
2110
+ this .style .strokeType = "COLOR";
2111
+ this .style .strokeColor = this .value .copy ();
2112
+ return;
2113
+ }
2114
+ }
2115
+
2116
+ // inherit
2117
+
2118
+ this .style .strokeType = this .styles .at (-1) .strokeType;
2119
+ this .style .strokeColor = this .styles .at (-1) .strokeColor;
2120
+ this .style .strokeURL = this .styles .at (-1) .strokeURL;
2121
+ },
2122
+ strokeOpacityStyle: function (value)
2123
+ {
2124
+ if (this .double ())
2125
+ {
2126
+ this .style .strokeOpacity = Algorithm .clamp (this .value, 0, 1);
2127
+ return;
2128
+ }
2129
+
2130
+ if (value === "transparent")
2131
+ {
2132
+ this .style .strokeOpacity = 0;
2133
+ return;
2134
+ }
2135
+
2136
+ // inherit
2137
+
2138
+ this .style .strokeOpacity = this .styles .at (-1) .strokeOpacity;
2139
+ },
2140
+ strokeWidthStyle: function (value)
2141
+ {
2142
+ if (this .double ())
2143
+ {
2144
+ this .style .strokeWidth = this .value / (1000 * PIXEL);
2145
+ return;
2146
+ }
2147
+
2148
+ if (value === "none")
2149
+ {
2150
+ this .style .strokeWidth = 0;
2151
+ return;
2152
+ }
2153
+
2154
+ // inherit
2155
+
2156
+ this .style .strokeWidth = this .styles .at (-1) .strokeWidth;
2157
+ },
2158
+ opacityStyle: function (value)
2159
+ {
2160
+ if (this .double ())
2161
+ {
2162
+ this .style .opacity = Algorithm .clamp (this .value, 0, 1) * this .styles .at (-1) .opacity;
2163
+ return;
2164
+ }
2165
+
2166
+ if (value === "transparent")
2167
+ {
2168
+ this .style .opacity = 0;
2169
+ return;
2170
+ }
2171
+ },
2172
+ stopColorStyle: function (value)
2173
+ {
2174
+ if (this .colorValue ())
2175
+ {
2176
+ this .style .stopColor = this .value .copy ();
2177
+ return;
2178
+ }
2179
+ },
2180
+ stopOpacityStyle: function (value)
2181
+ {
2182
+ if (this .double ())
2183
+ {
2184
+ this .style .stopOpacity = Algorithm .clamp (this .value, 0, 1);
2185
+ return;
2186
+ }
2187
+
2188
+ if (value === "transparent")
2189
+ {
2190
+ this .style .stopOpacity = 0;
2191
+ return;
2192
+ }
2193
+ },
2194
+ parseValue: function (value)
2195
+ {
2196
+ this .input = value;
2197
+ this .lastIndex = 0;
2198
+ this .value = undefined;
2199
+ },
2200
+ whitespaces: function ()
2201
+ {
2202
+ return Grammar .whitespaces .parse (this);
2203
+ },
2204
+ comma: function ()
2205
+ {
2206
+ return !! (this .whitespaces () | Grammar .comma .parse (this));
2207
+ },
2208
+ int32: function ()
2209
+ {
2210
+ this .whitespaces ();
2211
+
2212
+ if (Grammar .int32 .parse (this))
2213
+ {
2214
+ this .value = parseInt (this .result [1]);
2215
+
2216
+ return true;
2217
+ }
2218
+
2219
+ return false;
2220
+ },
2221
+ double: function ()
2222
+ {
2223
+ this .whitespaces ();
2224
+
2225
+ if (Grammar .double .parse (this))
2226
+ {
2227
+ this .value = parseFloat (this .result [1]);
2228
+
2229
+ return true;
2230
+ }
2231
+
2232
+ if (Grammar .constants .parse (this))
2233
+ {
2234
+ this .value = this .CONSTANTS .get (this .result [2] .toUpperCase ());
2235
+
2236
+ if (this .result [1] === "-")
2237
+ this .value = - this .value;
2238
+
2239
+ return true;
2240
+ }
2241
+
2242
+ return false;
2243
+ },
2244
+ colorValue: (function ()
2245
+ {
2246
+ const color = new Color4 (0, 0, 0, 0);
2247
+
2248
+ return function ()
2249
+ {
2250
+ if (!Grammar .color .parse (this))
2251
+ return false;
2252
+
2253
+ this .value = color .set (... this .convertColor (this .result [1]));
2254
+
2255
+ return true;
2256
+ };
2257
+ })(),
2258
+ urlValue: function ()
2259
+ {
2260
+ return Grammar .url .parse (this);
2261
+ },
2262
+ createTransform: function (xmlElement, t = Vector2 .Zero, s = Vector2 .One)
2263
+ {
2264
+ // Determine matrix.
2265
+
2266
+ const
2267
+ scene = this .getExecutionContext (),
2268
+ m = this .transformAttribute (xmlElement .getAttribute ("transform"));
2269
+
2270
+ m .translate (t);
2271
+ m .scale (s);
2272
+
2273
+ // Create node.
2274
+
2275
+ const
2276
+ transformNode = scene .createNode ("Transform"),
2277
+ matrix = new Matrix4 (m [0], m [1], 0, 0, m [3], m [4], 0, 0, 0, 0, 1, 0, m [6], m [7], 0, 1),
2278
+ translation = new Vector3 (0, 0, 0),
2279
+ rotation = new Rotation4 (),
2280
+ scale = new Vector3 (1, 1, 1),
2281
+ scaleOrientation = new Rotation4 ();
2282
+
2283
+ matrix .get (translation, rotation, scale, scaleOrientation);
2284
+
2285
+ transformNode .translation = translation;
2286
+ transformNode .rotation = rotation;
2287
+ transformNode .scale = scale;
2288
+ transformNode .scaleOrientation = scaleOrientation;
2289
+
2290
+ // Set name.
2291
+
2292
+ this .idAttribute (xmlElement .getAttribute ("id"), transformNode);
2293
+
2294
+ // Nodes
2295
+
2296
+ this .nodes .set (xmlElement, transformNode);
2297
+
2298
+ return transformNode;
2299
+ },
2300
+ createFillAppearance: function (bbox)
2301
+ {
2302
+ const
2303
+ scene = this .getExecutionContext (),
2304
+ appearanceNode = scene .createNode ("Appearance");
2305
+
2306
+ switch (this .style .fillType)
2307
+ {
2308
+ case "NONE":
2309
+ {
2310
+ return null;
2311
+ }
2312
+ case "COLOR":
2313
+ {
2314
+ const materialNode = scene .createNode ("UnlitMaterial");
2315
+
2316
+ appearanceNode .material = materialNode;
2317
+ materialNode .emissiveColor = new Color3 (... this .style .fillColor);
2318
+ materialNode .transparency = 1 - this .style .fillOpacity * this .style .opacity;
2319
+
2320
+ break;
2321
+ }
2322
+ case "URL":
2323
+ {
2324
+ // Gradient
2325
+
2326
+ const
2327
+ scene = this .getExecutionContext (),
2328
+ textureNode = scene .createNode ("ImageTexture"),
2329
+ url = this .getFillUrl (this .style .fillURL, bbox);
2330
+
2331
+ // Get image from url.
2332
+
2333
+ if (!url)
2334
+ return null;
2335
+
2336
+ textureNode .url = [url];
2337
+ textureNode .textureProperties = this .texturePropertiesNode;
2338
+ appearanceNode .texture = textureNode;
2339
+
2340
+ break;
2341
+ }
2342
+ }
2343
+
2344
+ return appearanceNode;
2345
+ },
2346
+ getFillUrl: function (fillURL, bbox)
2347
+ {
2348
+ const xmlElement = this .hrefAttribute (fillURL);
2349
+
2350
+ if (!xmlElement)
2351
+ return;
2352
+
2353
+ switch (xmlElement .nodeName)
2354
+ {
2355
+ case "linearGradient":
2356
+ return this .linearGradientElementURL (xmlElement, bbox);
2357
+
2358
+ case "radialGradient":
2359
+ return this .radialGradientElementURL (xmlElement, bbox);
2360
+ }
2361
+ },
2362
+ createStrokeAppearance: function ()
2363
+ {
2364
+ const
2365
+ scene = this .getExecutionContext (),
2366
+ appearanceNode = scene .createNode ("Appearance"),
2367
+ materialNode = scene .createNode ("Material");
2368
+
2369
+ appearanceNode .material = materialNode;
2370
+ materialNode .emissiveColor = new Color3 (... this .style .strokeColor);
2371
+ materialNode .transparency = 1 - this .style .strokeOpacity * this .style .opacity;
2372
+
2373
+ if (this .style .strokeWidth !== 1)
2374
+ {
2375
+ const lineProperties = scene .createNode ("LineProperties");
2376
+
2377
+ appearanceNode .lineProperties = lineProperties;
2378
+ lineProperties .linewidthScaleFactor = this .style .strokeWidth;
2379
+ }
2380
+
2381
+ return appearanceNode;
2382
+ },
2383
+ createTextureProperties: function ()
2384
+ {
2385
+ const
2386
+ scene = this .getExecutionContext (),
2387
+ texturePropertiesNode = scene .createNode ("TextureProperties");
2388
+
2389
+ texturePropertiesNode .generateMipMaps = true;
2390
+ texturePropertiesNode .minificationFilter = "NICEST";
2391
+ texturePropertiesNode .magnificationFilter = "NICEST";
2392
+ texturePropertiesNode .boundaryModeS = "CLAMP_TO_EDGE";
2393
+ texturePropertiesNode .boundaryModeT = "CLAMP_TO_EDGE";
2394
+ texturePropertiesNode .boundaryModeR = "CLAMP_TO_EDGE";
2395
+ texturePropertiesNode .textureCompression = "DEFAULT";
2396
+
2397
+ return texturePropertiesNode;
2398
+ },
2399
+ createTextureCoordinate: function (coordinateNode, bbox)
2400
+ {
2401
+ const
2402
+ scene = this .getExecutionContext (),
2403
+ texCoordNode = scene .createNode ("TextureCoordinate"),
2404
+ invMatrix = Matrix3 .inverse (bbox .matrix);
2405
+
2406
+ for (const point of coordinateNode .point)
2407
+ texCoordNode .point .push (invMatrix .multVecMatrix (new Vector2 (point .x, point .y)) .add (Vector2 .One) .divide (2));
2408
+
2409
+ return texCoordNode;
2410
+ },
2411
+ createTesselator: function ()
2412
+ {
2413
+ // Function called for each vertex of tessellator output.
2414
+
2415
+ function vertexCallback (index, triangles)
2416
+ {
2417
+ triangles .push (index);
2418
+ }
2419
+
2420
+ const tessy = new libtess .GluTesselator ();
2421
+
2422
+ tessy .gluTessCallback (libtess .gluEnum .GLU_TESS_VERTEX_DATA, vertexCallback);
2423
+ tessy .gluTessNormal (0, 0, 1);
2424
+
2425
+ return tessy;
2426
+ },
2427
+ triangulatePolygon: function (contours, coordinateNode)
2428
+ {
2429
+ // Callback for when segments intersect and must be split.
2430
+
2431
+ function combineCallback (coords, data, weight)
2432
+ {
2433
+ const
2434
+ point = new Vector3 (... coords),
2435
+ index = coordinateNode .point .length;
2436
+
2437
+ coordinateNode .point .push (point);
2438
+
2439
+ return index;
2440
+ }
2441
+
2442
+ const
2443
+ tessy = this .tessy,
2444
+ winding = this .style .fillRule === "evenodd" ? "GLU_TESS_WINDING_ODD" : "GLU_TESS_WINDING_NONZERO",
2445
+ triangles = [ ];
2446
+
2447
+ tessy .gluTessProperty (libtess .gluEnum .GLU_TESS_WINDING_RULE, libtess .windingRule [winding]);
2448
+ tessy .gluTessCallback (libtess .gluEnum .GLU_TESS_COMBINE, combineCallback);
2449
+ tessy .gluTessBeginPolygon (triangles);
2450
+
2451
+ for (const points of contours)
2452
+ {
2453
+ tessy .gluTessBeginContour ();
2454
+
2455
+ for (const [i, p] of points .entries ())
2456
+ tessy .gluTessVertex ([p .x, p .y, 0], points .index + i);
2457
+
2458
+ tessy .gluTessEndContour ();
2459
+ }
2460
+
2461
+ tessy .gluTessEndPolygon ();
2462
+
2463
+ // Array of indices of triangles.
2464
+ return triangles;
2465
+ },
2466
+ });
2467
+
2468
+ Object .defineProperty (SVGParser .prototype, "style",
2469
+ {
2470
+ get: function ()
2471
+ {
2472
+ return this .styles .at (-1);
2473
+ },
2474
+ })
2475
+
2476
+ export default SVGParser;