x_ite 8.6.0 → 8.6.2

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 (117) hide show
  1. package/.vscode/settings.json +7 -7
  2. package/dist/assets/components/Annotation.js +13 -13
  3. package/dist/assets/components/Annotation.min.js +1 -1
  4. package/dist/assets/components/CADGeometry.js +13 -13
  5. package/dist/assets/components/CADGeometry.min.js +1 -1
  6. package/dist/assets/components/CubeMapTexturing.js +25 -25
  7. package/dist/assets/components/CubeMapTexturing.min.js +1 -1
  8. package/dist/assets/components/DIS.js +13 -13
  9. package/dist/assets/components/DIS.min.js +1 -1
  10. package/dist/assets/components/EventUtilities.js +9 -9
  11. package/dist/assets/components/EventUtilities.min.js +1 -1
  12. package/dist/assets/components/Geometry2D.js +19 -19
  13. package/dist/assets/components/Geometry2D.min.js +1 -1
  14. package/dist/assets/components/Geospatial.js +33 -33
  15. package/dist/assets/components/Geospatial.min.js +1 -1
  16. package/dist/assets/components/HAnim.js +18 -18
  17. package/dist/assets/components/HAnim.min.js +1 -1
  18. package/dist/assets/components/KeyDeviceSensor.js +8 -8
  19. package/dist/assets/components/KeyDeviceSensor.min.js +1 -1
  20. package/dist/assets/components/Layout.js +27 -27
  21. package/dist/assets/components/Layout.min.js +1 -1
  22. package/dist/assets/components/NURBS.js +24 -24
  23. package/dist/assets/components/NURBS.min.js +1 -1
  24. package/dist/assets/components/ParticleSystems.js +23 -23
  25. package/dist/assets/components/ParticleSystems.min.js +1 -1
  26. package/dist/assets/components/Picking.js +19 -19
  27. package/dist/assets/components/Picking.min.js +1 -1
  28. package/dist/assets/components/RigidBodyPhysics.js +18 -18
  29. package/dist/assets/components/RigidBodyPhysics.min.js +1 -1
  30. package/dist/assets/components/Scripting.js +28 -28
  31. package/dist/assets/components/Scripting.min.js +1 -1
  32. package/dist/assets/components/Text.js +39 -48
  33. package/dist/assets/components/Text.min.js +1 -1
  34. package/dist/assets/components/TextureProjector.js +14 -14
  35. package/dist/assets/components/TextureProjector.min.js +1 -1
  36. package/dist/assets/components/Texturing3D.js +32 -32
  37. package/dist/assets/components/Texturing3D.min.js +1 -1
  38. package/dist/assets/components/VolumeRendering.js +19 -19
  39. package/dist/assets/components/VolumeRendering.min.js +1 -1
  40. package/dist/assets/components/X_ITE.js +9 -9
  41. package/dist/assets/components/X_ITE.min.js +1 -1
  42. package/dist/x_ite.css +1 -1
  43. package/dist/x_ite.js +690 -936
  44. package/dist/x_ite.min.js +1 -1
  45. package/dist/x_ite.zip +0 -0
  46. package/docs/_config.yml +2 -2
  47. package/docs/_includes/scripts.html +2 -2
  48. package/docs/_posts/components/CADGeometry/IndexedQuadSet.md +1 -1
  49. package/docs/_posts/components/CADGeometry/QuadSet.md +1 -1
  50. package/docs/_posts/components/Geometry3D/ElevationGrid.md +1 -1
  51. package/docs/_posts/components/Geometry3D/Extrusion.md +1 -1
  52. package/docs/_posts/components/Geometry3D/IndexedFaceSet.md +1 -1
  53. package/docs/_posts/components/Geospatial/GeoElevationGrid.md +1 -1
  54. package/docs/_posts/components/NURBS/NurbsSweptSurface.md +1 -1
  55. package/docs/_posts/components/NURBS/NurbsSwungSurface.md +1 -1
  56. package/docs/_posts/components/Rendering/IndexedTriangleFanSet.md +1 -1
  57. package/docs/_posts/components/Rendering/IndexedTriangleSet.md +1 -1
  58. package/docs/_posts/components/Rendering/IndexedTriangleStripSet.md +1 -1
  59. package/docs/_posts/components/Rendering/TriangleFanSet.md +1 -1
  60. package/docs/_posts/components/Rendering/TriangleSet.md +1 -1
  61. package/docs/_posts/components/Rendering/TriangleStripSet.md +1 -1
  62. package/docs/_posts/components/Shape/Material.md +1 -1
  63. package/docs/_posts/getting-started.md +1 -1
  64. package/docs/_posts/laboratory/x3d-file-converter.md +178 -0
  65. package/docs/_tabs/playground.html +80 -133
  66. package/docs/assets/css/style.scss +2 -42
  67. package/docs/laboratory/3d-l-system-generator.html +1 -1
  68. package/docs/laboratory/gltf-sample-viewer.html +1 -1
  69. package/docs/laboratory/online-dicom-and-nrrd-file-viewer.html +1 -1
  70. package/docs/laboratory/real-time-earth-quake-information.html +1 -1
  71. package/docs/laboratory/x3d-visual-blend-mode-editor.html +1 -1
  72. package/package.json +1 -1
  73. package/src/standard/Math/Algorithms/Bezier.js +133 -182
  74. package/src/standard/Math/Geometry/Box2.js +0 -1
  75. package/src/standard/Math/Geometry/Box3.js +0 -1
  76. package/src/standard/Math/Geometry/Cylinder3.js +1 -1
  77. package/src/standard/Math/Geometry/Line2.js +2 -4
  78. package/src/standard/Math/Geometry/Line3.js +2 -4
  79. package/src/standard/Math/Geometry/Plane3.js +1 -3
  80. package/src/standard/Math/Geometry/Sphere3.js +8 -12
  81. package/src/standard/Math/Geometry/Triangle3.js +8 -0
  82. package/src/standard/Math/Geometry/ViewVolume.js +17 -27
  83. package/src/standard/Math/Numbers/Color3.js +4 -7
  84. package/src/standard/Math/Numbers/Complex.js +8 -9
  85. package/src/standard/Math/Numbers/Matrix2.js +31 -42
  86. package/src/standard/Math/Numbers/Matrix3.js +54 -97
  87. package/src/standard/Math/Numbers/Matrix4.js +49 -160
  88. package/src/standard/Math/Numbers/Quaternion.js +20 -24
  89. package/src/standard/Math/Numbers/Rotation4.js +1 -2
  90. package/src/standard/Math/Numbers/Vector2.js +4 -12
  91. package/src/standard/Math/Numbers/Vector3.js +6 -18
  92. package/src/standard/Math/Numbers/Vector4.js +4 -20
  93. package/src/standard/Time/StopWatch.js +9 -14
  94. package/src/tests.js +11 -0
  95. package/src/x_ite/Browser/Core/BrowserTimings.js +10 -10
  96. package/src/x_ite/Browser/Core/X3DCoreContext.js +4 -6
  97. package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolator.js +94 -88
  98. package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolator1.js +2 -3
  99. package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolatorTemplate.js +17 -14
  100. package/src/x_ite/Browser/Text/PolygonText.js +15 -24
  101. package/src/x_ite/Browser/VERSION.js +1 -1
  102. package/src/x_ite/Components/Core/X3DNode.js +12 -0
  103. package/src/x_ite/Components/Core/X3DPrototypeInstance.js +18 -0
  104. package/src/x_ite/Components/Interpolation/SquadOrientationInterpolator.js +8 -7
  105. package/src/x_ite/Configuration/UnitInfo.js +2 -0
  106. package/src/x_ite/Execution/X3DExportedNode.js +4 -0
  107. package/src/x_ite/Execution/X3DImportedNode.js +14 -0
  108. package/src/x_ite/Execution/X3DScene.js +4 -0
  109. package/src/x_ite/Fields/SFString.js +4 -6
  110. package/src/x_ite/InputOutput/FileLoader.js +1 -1
  111. package/src/x_ite/InputOutput/Generator.js +35 -55
  112. package/src/x_ite/Parser/GLTF2Parser.js +4 -4
  113. package/src/x_ite/Parser/SVGParser.js +24 -47
  114. package/src/x_ite/Parser/X3DParser.js +1 -1
  115. package/src/x_ite/Prototype/X3DExternProtoDeclaration.js +4 -0
  116. package/src/x_ite/Prototype/X3DProtoDeclaration.js +4 -0
  117. package/src/x_ite/Routing/X3DRoute.js +8 -0
@@ -23,6 +23,7 @@ $tab-count: {{ site.tabs | size | plus: 1 }}; // plus 1 for home tab
23
23
  --system-yellow: rgb(255, 214, 10);
24
24
  --system-blue: rgb(10, 132, 255);
25
25
  --system-green: rgb(48, 209, 88);
26
+ --playground-editor-background: rgba(0, 0, 0, 0.2);
26
27
  }
27
28
 
28
29
  @mixin x_ite-light-scheme {
@@ -36,67 +37,26 @@ $tab-count: {{ site.tabs | size | plus: 1 }}; // plus 1 for home tab
36
37
  --system-yellow: rgb(255, 204, 0);
37
38
  --system-blue: rgb(0, 122, 255);
38
39
  --system-green: rgb(52, 199, 89);
39
- }
40
-
41
- @mixin playground-dark-scheme {
42
- --playground-editor-background: rgba(0, 0, 0, 0.2);
43
- --playground-editor-gutter: rgba(255, 255, 255, 0.05);
44
- --playground-editor-active-line: rgb(32, 45, 64);
45
- --playground-editor-selected-word: rgb(39, 79, 121);
46
- --playground-xml-tag: var(--text-color);
47
- --playground-xml-tag-name: rgb(90, 156, 216);
48
- --playground-xml-attribute-name: rgb(159, 220, 254);
49
- --playground-xml-attribute-equals: rgb(212, 212, 212);
50
- --playground-xml-attribute-value: rgb(205, 145, 119);
51
- --playground-json-parenthesis: rgb(253, 214, 1);
52
- --playground-json-identifier: rgb(159, 220, 254);
53
- --playground-json-variable: rgb(159, 220, 254);
54
- --playground-json-numeric: rgb(183, 206, 165);
55
- --playground-json-string: rgb(205, 145, 119);
56
- --playground-json-boolean: rgb(90, 156, 216);
57
- --playground-json-punctuation: rgb(212, 212, 212);
58
- }
59
-
60
- @mixin playground-light-scheme {
61
- --playground-editor-background: rgba(0, 0, 0, 0.01);
62
- --playground-editor-gutter: rgb(243, 243, 243);
63
- --playground-editor-active-line: rgb(215, 229, 248);
64
- --playground-editor-selected-word: rgb(174, 214, 255);
65
- --playground-xml-tag: var(--text-color);
66
- --playground-xml-tag-name: rgb(126, 0, 0);
67
- --playground-xml-attribute-name: rgb(226, 2, 0);
68
- --playground-xml-attribute-equals: rgb(0, 0, 0);
69
- --playground-xml-attribute-value: rgb(16, 0, 255);
70
- --playground-json-parenthesis: rgb(54, 147, 39);
71
- --playground-json-identifier: rgb(18, 81, 166);
72
- --playground-json-variable: rgb(18, 81, 166);
73
- --playground-json-numeric: rgb(30, 134, 87);
74
- --playground-json-string: rgb(160, 21, 21);
75
- --playground-json-boolean: rgb(16, 0, 255);
76
- --playground-json-punctuation: rgb(0, 0, 0);
40
+ --playground-editor-background: rgba(0, 0, 0, 0.03);
77
41
  }
78
42
 
79
43
  @media (prefers-color-scheme: dark) {
80
44
  html:not([data-mode]), html[data-mode=dark] {
81
45
  @include x_ite-dark-scheme;
82
- @include playground-dark-scheme;
83
46
  }
84
47
 
85
48
  html[data-mode=light] {
86
49
  @include x_ite-light-scheme;
87
- @include playground-light-scheme;
88
50
  }
89
51
  }
90
52
 
91
53
  @media (prefers-color-scheme: light) {
92
54
  html[data-mode=dark] {
93
55
  @include x_ite-dark-scheme;
94
- @include playground-dark-scheme;
95
56
  }
96
57
 
97
58
  html:not([data-mode]), html[data-mode=light] {
98
59
  @include x_ite-light-scheme;
99
- @include playground-light-scheme;
100
60
  }
101
61
  }
102
62
 
@@ -3,7 +3,7 @@ title: 3D L-System Generator
3
3
  layout: wide
4
4
  collection: tabs
5
5
  categories: [Laboratory]
6
- tags: [3D, l-system, generator]
6
+ tags: [3D, L-System, Generator]
7
7
  ---
8
8
  <style>
9
9
  .row, .post, .post-content {
@@ -3,7 +3,7 @@ title: glTF Sample Viewer
3
3
  layout: wide
4
4
  collection: tabs
5
5
  categories: [Laboratory]
6
- tags: [glTF, sample, viewer]
6
+ tags: [glTF, Sample, Viewer]
7
7
  ---
8
8
  <style>
9
9
  .post, .post-content {
@@ -3,7 +3,7 @@ title: Online DICOM and NRRD file Viewer
3
3
  layout: wide
4
4
  collection: tabs
5
5
  categories: [Laboratory]
6
- tags: [online, dicom, nrrd, file, viewer]
6
+ tags: [Online, DICOM, NRRD, File, Viewer]
7
7
  ---
8
8
  <style>
9
9
  .row, .post, .post-content {
@@ -3,7 +3,7 @@ title: Real Time Earth Quake Information
3
3
  layout: wide
4
4
  collection: tabs
5
5
  categories: [Laboratory]
6
- tags: [real time, earth quake]
6
+ tags: [Real Time, Earth Quake]
7
7
  ---
8
8
  <style>
9
9
  /* Table */
@@ -3,7 +3,7 @@ title: X3D Visual Blend Mode Editor
3
3
  layout: wide
4
4
  collection: tabs
5
5
  categories: [Laboratory]
6
- tags: [X3D, visual, blend mode, editor]
6
+ tags: [X3D, Visual, Blend Mode, Editor]
7
7
  ---
8
8
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/cferdinandi/tabby@12.0.0/dist/css/tabby-ui.min.css">
9
9
  <script src="https://cdn.jsdelivr.net/gh/cferdinandi/tabby@12.0.0/dist/js/tabby.polyfills.min.js"></script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x_ite",
3
- "version": "8.6.0",
3
+ "version": "8.6.2",
4
4
  "description": "X_ITE X3D Browser, view and manipulate X3D and VRML scenes in HTML.",
5
5
  "homepage": "https://create3000.github.io/x_ite/",
6
6
  "author": "Holger Seelig <holger.seelig@gmail.com>",
@@ -47,235 +47,186 @@
47
47
 
48
48
  import Algorithm from "../Algorithm.js";
49
49
  import Vector2 from "../Numbers/Vector2.js";
50
+ import Vector3 from "../Numbers/Vector3.js";
51
+ import Vector4 from "../Numbers/Vector4.js";
52
+ import Matrix3 from "../Numbers/Matrix3.js";
53
+ import Matrix4 from "../Numbers/Matrix4.js";
50
54
 
51
- const lerp = Algorithm .lerp;
55
+ const { interval } = Algorithm;
52
56
 
53
- function Bezier (/*x0, y0, x1, y1, x2, y2, x3, y3*/)
54
- {
55
- this .args = arguments;
56
- }
57
+ // https://pomax.github.io/bezierinfo/
57
58
 
58
- Bezier .prototype =
59
+ const Bezier =
59
60
  {
60
- getPoints: function (type, steps)
61
+ quadric: (function ()
61
62
  {
62
- const points = [ ];
63
+ const
64
+ c = new Matrix3 (1, 0, 0, -2, 2, 0, 1, -2, 1),
65
+ p = new Matrix3 ();
63
66
 
64
- switch (type)
67
+ return function (x0, y0, z0, x1, y1, z1, x2, y2, z2, steps, points)
65
68
  {
66
- case "quadric":
67
- {
68
- const
69
- x0 = this .args [0],
70
- y0 = this .args [1],
71
- x1 = this .args [2],
72
- y1 = this .args [3],
73
- x2 = this .args [4],
74
- y2 = this .args [5];
75
-
76
- for (let i = 0, d = steps - 1; i < steps; ++ i)
77
- {
78
- points .push (quadric (x0, y0, x1, y1, x2, y2, i / d));
79
- }
80
-
81
- break;
82
- }
83
- case "cubic":
69
+ p .set (x0, y0, z0, x1, y1, z1, x2, y2, z2)
70
+ .multLeft (c);
71
+
72
+ for (let i = 0, d = steps - 1; i < steps; ++ i)
84
73
  {
85
- const
86
- x0 = this .args [0],
87
- y0 = this .args [1],
88
- x1 = this .args [2],
89
- y1 = this .args [3],
90
- x2 = this .args [4],
91
- y2 = this .args [5],
92
- x3 = this .args [6],
93
- y3 = this .args [7];
94
-
95
- for (let i = 0, d = steps - 1; i < steps; ++ i)
96
- {
97
- points .push (cubic (x0, y0, x1, y1, x2, y2, x3, y3, i / d));
98
- }
99
-
100
- break;
74
+ const t = i / d;
75
+
76
+ points .push (p .multVecMatrix (new Vector3 (1, t, t * t)));
101
77
  }
102
- case "arc":
103
- {
104
- let
105
- ax = this .args [0],
106
- ay = this .args [1],
107
- rx = this .args [2],
108
- ry = this .args [3],
109
- xAxisRotation = this .args [4],
110
- largeArcFlag = this .args [5],
111
- sweepFlag = this .args [6],
112
- x = this .args [7],
113
- y = this .args [8];
78
+ };
79
+ })(),
80
+ cubic: (function ()
81
+ {
82
+ const
83
+ v = new Vector4 (0, 0, 0, 0),
84
+ c = new Matrix4 (1, 0, 0, 0, -3, 3, 0, 0, 3, -6, 3, 0, -1, 3, -3, 1),
85
+ p = new Matrix4 ();
114
86
 
115
- // https://ericeastwood.com/blog/25/curves-and-arcs-quadratic-cubic-elliptical-svg-implementations
116
- // See https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes.
87
+ return function (x0, y0, z0, x1, y1, z1, x2, y2, z2, x3, y3, z3, steps, points)
88
+ {
89
+ p .set (x0, y0, z0, 0, x1, y1, z1, 0, x2, y2, z2, 0, x3, y3, z3, 0)
90
+ .multLeft (c);
117
91
 
118
- // If the endpoints are identical, then this is equivalent to omitting the elliptical arc segment entirely.
119
- if (ax === x && ay === y)
120
- {
121
- points .push (new Vector2 (x, y));
122
- return;
123
- }
92
+ for (let i = 0, d = steps - 1; i < steps; ++ i)
93
+ {
94
+ const t = i / d;
124
95
 
125
- // In accordance to: http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters
96
+ p .multVecMatrix (v .set (1, t, t * t, t * t * t));
126
97
 
127
- rx = Math .abs (rx);
128
- ry = Math .abs (ry);
98
+ points .push (new Vector3 (v .x, v .y, v .z));
99
+ }
100
+ };
101
+ })(),
102
+ arc: function (ax, ay, rx, ry, xAxisRotation, largeArcFlag, sweepFlag, x, y, steps, points)
103
+ {
104
+ // https://ericeastwood.com/blog/25/curves-and-arcs-quadratic-cubic-elliptical-svg-implementations
105
+ // See https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes.
129
106
 
130
- // If rx = 0 or ry = 0 then this arc is treated as a straight line segment joining the endpoints.
131
- if (rx === 0 || ry === 0)
132
- {
133
- points .push (new Vector2 (ax, ay), new Vector2 (x, y));
134
- return;
135
- }
107
+ // If the endpoints are identical, then this is equivalent to omitting the elliptical arc segment entirely.
108
+ if (ax === x && ay === y)
109
+ {
110
+ points .push (new Vector3 (x, y, 0));
111
+ return;
112
+ }
136
113
 
137
- const
138
- rx2 = rx * rx,
139
- ry2 = ry * ry;
114
+ // In accordance to: http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters
140
115
 
141
- // In accordance to: http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters
116
+ rx = Math .abs (rx);
117
+ ry = Math .abs (ry);
142
118
 
143
- xAxisRotation = Algorithm .interval (xAxisRotation, 0, 2 * Math .PI);
119
+ // If rx = 0 or ry = 0 then this arc is treated as a straight line segment joining the endpoints.
120
+ if (rx === 0 || ry === 0)
121
+ {
122
+ points .push (new Vector3 (ax, ay, 0), new Vector3 (x, y, 0));
123
+ return;
124
+ }
144
125
 
145
- const
146
- sinRotation = Math .sin (xAxisRotation),
147
- cosRotation = Math .cos (xAxisRotation);
126
+ const
127
+ rx2 = rx * rx,
128
+ ry2 = ry * ry;
148
129
 
149
- // Following "Conversion from endpoint to center parameterization"
150
- // http://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter
130
+ // In accordance to: http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters
151
131
 
152
- // Step #1: Compute transformedPoint
153
- const d = new Vector2 (ax - x, ay - y) .divide (2);
132
+ xAxisRotation = interval (xAxisRotation, 0, 2 * Math .PI);
154
133
 
155
- const transformedPoint = new Vector2 ( cosRotation * d .x + sinRotation * d .y,
156
- -sinRotation * d .x + cosRotation * d .y);
134
+ const
135
+ sinRotation = Math .sin (xAxisRotation),
136
+ cosRotation = Math .cos (xAxisRotation);
157
137
 
158
- const transformedPoint2 = transformedPoint .copy () .multVec (transformedPoint);
138
+ // Following "Conversion from endpoint to center parameterization"
139
+ // http://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter
159
140
 
160
- // Ensure radii are large enough
161
- const radiiCheck = transformedPoint2 .x / rx2 + transformedPoint2 .y / ry2;
141
+ // Step #1: Compute transformedPoint
142
+ const d = new Vector2 (ax - x, ay - y) .divide (2);
162
143
 
163
- if (radiiCheck > 1)
164
- {
165
- rx = Math .sqrt (radiiCheck) * rx;
166
- ry = Math .sqrt (radiiCheck) * ry;
167
- }
144
+ const transformedPoint = new Vector2 ( cosRotation * d .x + sinRotation * d .y,
145
+ -sinRotation * d .x + cosRotation * d .y);
168
146
 
169
- // Step #2: Compute transformedCenter
170
- const cSquareNumerator = rx2 * ry2 - rx2 * transformedPoint2 .y - ry2 * transformedPoint2 .x;
171
- const cSquareRootDenom = rx2 * transformedPoint2 .y + ry2 * transformedPoint2 .x;
172
- let cRadicand = cSquareNumerator / cSquareRootDenom;
147
+ const transformedPoint2 = transformedPoint .copy () .multVec (transformedPoint);
173
148
 
174
- // Make sure this never drops below zero because of precision
175
- cRadicand = Math .max (0, cRadicand);
149
+ // Ensure radii are large enough
150
+ const radiiCheck = transformedPoint2 .x / rx2 + transformedPoint2 .y / ry2;
176
151
 
177
- const cCoef = (largeArcFlag !== sweepFlag ? 1 : -1) * Math .sqrt (cRadicand);
152
+ if (radiiCheck > 1)
153
+ {
154
+ rx = Math .sqrt (radiiCheck) * rx;
155
+ ry = Math .sqrt (radiiCheck) * ry;
156
+ }
178
157
 
179
- const transformedCenter = new Vector2 ( cCoef * rx * transformedPoint .y / ry,
180
- -cCoef * ry * transformedPoint .x / rx);
158
+ // Step #2: Compute transformedCenter
159
+ const cSquareNumerator = rx2 * ry2 - rx2 * transformedPoint2 .y - ry2 * transformedPoint2 .x;
160
+ const cSquareRootDenom = rx2 * transformedPoint2 .y + ry2 * transformedPoint2 .x;
161
+ let cRadicand = cSquareNumerator / cSquareRootDenom;
181
162
 
182
- // Step #3: Compute center
183
- const center = new Vector2 (cosRotation * transformedCenter .x - sinRotation * transformedCenter .y + ((ax + x) / 2),
184
- sinRotation * transformedCenter .x + cosRotation * transformedCenter .y + ((ay + y) / 2));
163
+ // Make sure this never drops below zero because of precision
164
+ cRadicand = Math .max (0, cRadicand);
185
165
 
186
- // Step #4: Compute start/sweep angles
187
- const startVector = new Vector2 ((transformedPoint .x - transformedCenter .x) / rx,
188
- (transformedPoint .y - transformedCenter .y) / ry);
166
+ const cCoef = (largeArcFlag !== sweepFlag ? 1 : -1) * Math .sqrt (cRadicand);
189
167
 
190
- const endVector = new Vector2 ((-transformedPoint .x - transformedCenter .x) / rx,
191
- (-transformedPoint .y - transformedCenter .y) / ry);
168
+ const transformedCenter = new Vector2 ( cCoef * rx * transformedPoint .y / ry,
169
+ -cCoef * ry * transformedPoint .x / rx);
192
170
 
193
- const get_angle = (x) => { return x > 0 ? x : 2 * Math .PI + x; }; // transform angle to range [0, 2pi]
194
- const startAngle = get_angle (Math .atan2 (startVector .y, startVector .x));
195
- const endAngle = get_angle (Math .atan2 (endVector .y, endVector .x));
171
+ // Step #3: Compute center
172
+ const center = new Vector2 (cosRotation * transformedCenter .x - sinRotation * transformedCenter .y + ((ax + x) / 2),
173
+ sinRotation * transformedCenter .x + cosRotation * transformedCenter .y + ((ay + y) / 2));
196
174
 
197
- let sweepAngle = endAngle - startAngle;
175
+ // Step #4: Compute start/sweep angles
176
+ const startVector = new Vector2 ((transformedPoint .x - transformedCenter .x) / rx,
177
+ (transformedPoint .y - transformedCenter .y) / ry);
198
178
 
199
- if (largeArcFlag)
200
- {
201
- // sweepAngle must be positive
202
- if (sweepAngle < 0)
203
- sweepAngle += 2 * Math .PI;
204
- }
205
- else
206
- {
207
- // sweepAngle must be negative
208
- if (sweepAngle > 0)
209
- sweepAngle -= 2 * Math .PI;
210
- }
179
+ const endVector = new Vector2 ((-transformedPoint .x - transformedCenter .x) / rx,
180
+ (-transformedPoint .y - transformedCenter .y) / ry);
211
181
 
212
- if (sweepFlag && sweepAngle < 0)
213
- sweepAngle += 2 *Math .PI;
182
+ const get_angle = (x) => { return x > 0 ? x : 2 * Math .PI + x; }; // transform angle to range [0, 2pi]
183
+ const startAngle = get_angle (Math .atan2 (startVector .y, startVector .x));
184
+ const endAngle = get_angle (Math .atan2 (endVector .y, endVector .x));
214
185
 
215
- else if (!sweepFlag && sweepAngle > 0)
216
- sweepAngle -= 2 * Math .PI;
186
+ let sweepAngle = endAngle - startAngle;
217
187
 
218
- // Interpolate:
188
+ if (largeArcFlag)
189
+ {
190
+ // sweepAngle must be positive
191
+ if (sweepAngle < 0)
192
+ sweepAngle += 2 * Math .PI;
193
+ }
194
+ else
195
+ {
196
+ // sweepAngle must be negative
197
+ if (sweepAngle > 0)
198
+ sweepAngle -= 2 * Math .PI;
199
+ }
219
200
 
220
- const bezier_steps = Math .max (4, Math .abs (sweepAngle) * steps / (2 * Math .PI));
221
- const bezier_steps_1 = bezier_steps - 1;
201
+ if (sweepFlag && sweepAngle < 0)
202
+ sweepAngle += 2 *Math .PI;
222
203
 
223
- points .push (new Vector2 (ax, ay));
204
+ else if (!sweepFlag && sweepAngle > 0)
205
+ sweepAngle -= 2 * Math .PI;
224
206
 
225
- for (let i = 1; i < bezier_steps_1; ++ i)
226
- {
227
- const t = i / bezier_steps_1;
207
+ // Interpolate:
228
208
 
229
- // From http://www.w3.org/TR/SVG/implnote.html#ArcParameterizationAlternatives
230
- const angle = startAngle + (sweepAngle * t);
231
- const x = rx * Math .cos (angle);
232
- const y = ry * Math .sin (angle);
209
+ const bezier_steps = Math .max (4, Math .abs (sweepAngle) * steps / (2 * Math .PI));
210
+ const bezier_steps_1 = bezier_steps - 1;
233
211
 
234
- const point = new Vector2 (cosRotation * x - sinRotation * y + center .x,
235
- sinRotation * x + cosRotation * y + center .y);
212
+ points .push (new Vector3 (ax, ay, 0));
236
213
 
237
- points .push (point);
238
- }
214
+ for (let i = 1; i < bezier_steps_1; ++ i)
215
+ {
216
+ const t = i / bezier_steps_1;
239
217
 
240
- points .push (new Vector2 (x, y));
241
- break;
242
- }
218
+ // From http://www.w3.org/TR/SVG/implnote.html#ArcParameterizationAlternatives
219
+ const angle = startAngle + (sweepAngle * t);
220
+ const x = rx * Math .cos (angle);
221
+ const y = ry * Math .sin (angle);
222
+
223
+ points .push (new Vector3 (cosRotation * x - sinRotation * y + center .x,
224
+ sinRotation * x + cosRotation * y + center .y,
225
+ 0));
243
226
  }
244
227
 
245
- return points;
228
+ points .push (new Vector3 (x, y, 0));
246
229
  }
247
230
  };
248
231
 
249
- function quadric (x0, y0, x1, y1, x2, y2, t)
250
- {
251
- const
252
- ax0 = lerp (x0, x1, t),
253
- ay0 = lerp (y0, y1, t),
254
- ax1 = lerp (x1, x2, t),
255
- ay1 = lerp (y1, y2, t),
256
- bx0 = lerp (ax0, ax1, t),
257
- by0 = lerp (ay0, ay1, t);
258
-
259
- return new Vector2 (bx0, by0);
260
- }
261
-
262
- function cubic (x0, y0, x1, y1, x2, y2, x3, y3, t)
263
- {
264
- const
265
- ax0 = lerp (x0, x1, t),
266
- ay0 = lerp (y0, y1, t),
267
- ax1 = lerp (x1, x2, t),
268
- ay1 = lerp (y1, y2, t),
269
- ax2 = lerp (x2, x3, t),
270
- ay2 = lerp (y2, y3, t),
271
- bx0 = lerp (ax0, ax1, t),
272
- by0 = lerp (ay0, ay1, t),
273
- bx1 = lerp (ax1, ax2, t),
274
- by1 = lerp (ay1, ay2, t),
275
- cx0 = lerp (bx0, bx1, t),
276
- cy0 = lerp (by0, by1, t);
277
-
278
- return new Vector2 (cx0, cy0);
279
- }
280
-
281
232
  export default Bezier;
@@ -102,7 +102,6 @@ Box2 .prototype =
102
102
  setExtents: function (min, max)
103
103
  {
104
104
  const
105
- m = this .matrix,
106
105
  sx = (max .x - min .x) / 2,
107
106
  sy = (max .y - min .y) / 2,
108
107
  cx = (max .x + min .x) / 2,
@@ -110,7 +110,6 @@ Box3 .prototype =
110
110
  setExtents: function (min, max)
111
111
  {
112
112
  const
113
- m = this .matrix,
114
113
  sx = (max .x - min .x) / 2,
115
114
  sy = (max .y - min .y) / 2,
116
115
  sz = (max .z - min .z) / 2,
@@ -120,7 +120,7 @@ Cylinder3 .prototype =
120
120
  pos = line .point,
121
121
  dir = line .direction;
122
122
 
123
- const
123
+ const
124
124
  A = dir [0] * dir [0] + dir [2] * dir [2],
125
125
  B = 2 * (pos [0] * dir [0] + pos [2] * dir [2]),
126
126
  C = pos [0] * pos [0] + pos [2] * pos [2] - 1;
@@ -119,10 +119,8 @@ Line2 .prototype =
119
119
  return function (line, point)
120
120
  {
121
121
  const
122
- p1 = this .point,
123
- p2 = line .point,
124
- d1 = this .direction,
125
- d2 = line .direction;
122
+ { point: p1, direction: d1 } = this,
123
+ { point: p2, direction: d2 } = line;
126
124
 
127
125
  const theta = d1 .dot (d2); // angle between both lines
128
126
 
@@ -108,10 +108,8 @@ Line3 .prototype =
108
108
  return function (line, point)
109
109
  {
110
110
  const
111
- p1 = this .point,
112
- p2 = line .point,
113
- d1 = this .direction,
114
- d2 = line .direction;
111
+ { point: p1, direction: d1 } = this,
112
+ { point: p2, direction: d2 } = line;
115
113
 
116
114
  let t = d1 .dot (d2);
117
115
 
@@ -137,9 +137,7 @@ Plane3 .prototype =
137
137
  },
138
138
  intersectsLine: function (line, intersection)
139
139
  {
140
- const
141
- point = line .point,
142
- direction = line .direction;
140
+ const { point, direction } = line;
143
141
 
144
142
  // Check if the line is parallel to the plane.
145
143
  const theta = direction .dot (this .normal);
@@ -66,18 +66,14 @@ Sphere3 .prototype =
66
66
  // https://github.com/Alexpux/Coin3D/blob/master/src/base/SbSphere.cpp
67
67
 
68
68
  const
69
- linepos = line .point,
70
- linedir = line .direction;
69
+ { point, direction } = line,
70
+ { center, radius } = this;
71
71
 
72
72
  const
73
- scenter = this .center,
74
- r = this .radius;
75
-
76
- const
77
- b = 2 * (linepos .dot (linedir) - scenter .dot (linedir)),
78
- c = (linepos .x * linepos .x + linepos .y * linepos .y + linepos .z * linepos .z) +
79
- (scenter .x * scenter .x + scenter .y * scenter .y + scenter .z * scenter .z) -
80
- 2 * linepos .dot (scenter) - r * r;
73
+ b = 2 * (point .dot (direction) - center .dot (direction)),
74
+ c = (point .x * point .x + point .y * point .y + point .z * point .z) +
75
+ (center .x * center .x + center .y * center .y + center .z * center .z) -
76
+ 2 * point .dot (center) - radius * radius;
81
77
 
82
78
  const core = b * b - 4 * c;
83
79
 
@@ -94,8 +90,8 @@ Sphere3 .prototype =
94
90
  t2 = tmp;
95
91
  }
96
92
 
97
- enterPoint .assign (linedir) .multiply (t1) .add (linepos);
98
- exitPoint .assign (linedir) .multiply (t2) .add (linepos);
93
+ enterPoint .assign (direction) .multiply (t1) .add (point);
94
+ exitPoint .assign (direction) .multiply (t2) .add (point);
99
95
 
100
96
  return true;
101
97
  }
@@ -100,9 +100,17 @@ const Triangle3 = {
100
100
  triangles .push (index);
101
101
  }
102
102
 
103
+ // Required in case of a combine, otherwise an empty array is returned.
104
+
105
+ function combineCallback (coords, data, weight)
106
+ {
107
+ return data [0];
108
+ }
109
+
103
110
  const tessy = new libtess .GluTesselator ();
104
111
 
105
112
  tessy .gluTessCallback (libtess .gluEnum .GLU_TESS_VERTEX_DATA, vertexCallback);
113
+ tessy .gluTessCallback (libtess .gluEnum .GLU_TESS_COMBINE, combineCallback);
106
114
  tessy .gluTessProperty (libtess .gluEnum .GLU_TESS_WINDING_RULE, libtess .windingRule .GLU_TESS_WINDING_ODD);
107
115
 
108
116
  return function (polygon, triangles)