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.
- package/.vscode/settings.json +7 -7
- package/dist/assets/components/Annotation.js +13 -13
- package/dist/assets/components/Annotation.min.js +1 -1
- package/dist/assets/components/CADGeometry.js +13 -13
- package/dist/assets/components/CADGeometry.min.js +1 -1
- package/dist/assets/components/CubeMapTexturing.js +25 -25
- package/dist/assets/components/CubeMapTexturing.min.js +1 -1
- package/dist/assets/components/DIS.js +13 -13
- package/dist/assets/components/DIS.min.js +1 -1
- package/dist/assets/components/EventUtilities.js +9 -9
- package/dist/assets/components/EventUtilities.min.js +1 -1
- package/dist/assets/components/Geometry2D.js +19 -19
- package/dist/assets/components/Geometry2D.min.js +1 -1
- package/dist/assets/components/Geospatial.js +33 -33
- package/dist/assets/components/Geospatial.min.js +1 -1
- package/dist/assets/components/HAnim.js +18 -18
- package/dist/assets/components/HAnim.min.js +1 -1
- package/dist/assets/components/KeyDeviceSensor.js +8 -8
- package/dist/assets/components/KeyDeviceSensor.min.js +1 -1
- package/dist/assets/components/Layout.js +27 -27
- package/dist/assets/components/Layout.min.js +1 -1
- package/dist/assets/components/NURBS.js +24 -24
- package/dist/assets/components/NURBS.min.js +1 -1
- package/dist/assets/components/ParticleSystems.js +23 -23
- package/dist/assets/components/ParticleSystems.min.js +1 -1
- package/dist/assets/components/Picking.js +19 -19
- package/dist/assets/components/Picking.min.js +1 -1
- package/dist/assets/components/RigidBodyPhysics.js +18 -18
- package/dist/assets/components/RigidBodyPhysics.min.js +1 -1
- package/dist/assets/components/Scripting.js +28 -28
- package/dist/assets/components/Scripting.min.js +1 -1
- package/dist/assets/components/Text.js +39 -48
- package/dist/assets/components/Text.min.js +1 -1
- package/dist/assets/components/TextureProjector.js +14 -14
- package/dist/assets/components/TextureProjector.min.js +1 -1
- package/dist/assets/components/Texturing3D.js +32 -32
- package/dist/assets/components/Texturing3D.min.js +1 -1
- package/dist/assets/components/VolumeRendering.js +19 -19
- package/dist/assets/components/VolumeRendering.min.js +1 -1
- package/dist/assets/components/X_ITE.js +9 -9
- package/dist/assets/components/X_ITE.min.js +1 -1
- package/dist/x_ite.css +1 -1
- package/dist/x_ite.js +690 -936
- package/dist/x_ite.min.js +1 -1
- package/dist/x_ite.zip +0 -0
- package/docs/_config.yml +2 -2
- package/docs/_includes/scripts.html +2 -2
- package/docs/_posts/components/CADGeometry/IndexedQuadSet.md +1 -1
- package/docs/_posts/components/CADGeometry/QuadSet.md +1 -1
- package/docs/_posts/components/Geometry3D/ElevationGrid.md +1 -1
- package/docs/_posts/components/Geometry3D/Extrusion.md +1 -1
- package/docs/_posts/components/Geometry3D/IndexedFaceSet.md +1 -1
- package/docs/_posts/components/Geospatial/GeoElevationGrid.md +1 -1
- package/docs/_posts/components/NURBS/NurbsSweptSurface.md +1 -1
- package/docs/_posts/components/NURBS/NurbsSwungSurface.md +1 -1
- package/docs/_posts/components/Rendering/IndexedTriangleFanSet.md +1 -1
- package/docs/_posts/components/Rendering/IndexedTriangleSet.md +1 -1
- package/docs/_posts/components/Rendering/IndexedTriangleStripSet.md +1 -1
- package/docs/_posts/components/Rendering/TriangleFanSet.md +1 -1
- package/docs/_posts/components/Rendering/TriangleSet.md +1 -1
- package/docs/_posts/components/Rendering/TriangleStripSet.md +1 -1
- package/docs/_posts/components/Shape/Material.md +1 -1
- package/docs/_posts/getting-started.md +1 -1
- package/docs/_posts/laboratory/x3d-file-converter.md +178 -0
- package/docs/_tabs/playground.html +80 -133
- package/docs/assets/css/style.scss +2 -42
- package/docs/laboratory/3d-l-system-generator.html +1 -1
- package/docs/laboratory/gltf-sample-viewer.html +1 -1
- package/docs/laboratory/online-dicom-and-nrrd-file-viewer.html +1 -1
- package/docs/laboratory/real-time-earth-quake-information.html +1 -1
- package/docs/laboratory/x3d-visual-blend-mode-editor.html +1 -1
- package/package.json +1 -1
- package/src/standard/Math/Algorithms/Bezier.js +133 -182
- package/src/standard/Math/Geometry/Box2.js +0 -1
- package/src/standard/Math/Geometry/Box3.js +0 -1
- package/src/standard/Math/Geometry/Cylinder3.js +1 -1
- package/src/standard/Math/Geometry/Line2.js +2 -4
- package/src/standard/Math/Geometry/Line3.js +2 -4
- package/src/standard/Math/Geometry/Plane3.js +1 -3
- package/src/standard/Math/Geometry/Sphere3.js +8 -12
- package/src/standard/Math/Geometry/Triangle3.js +8 -0
- package/src/standard/Math/Geometry/ViewVolume.js +17 -27
- package/src/standard/Math/Numbers/Color3.js +4 -7
- package/src/standard/Math/Numbers/Complex.js +8 -9
- package/src/standard/Math/Numbers/Matrix2.js +31 -42
- package/src/standard/Math/Numbers/Matrix3.js +54 -97
- package/src/standard/Math/Numbers/Matrix4.js +49 -160
- package/src/standard/Math/Numbers/Quaternion.js +20 -24
- package/src/standard/Math/Numbers/Rotation4.js +1 -2
- package/src/standard/Math/Numbers/Vector2.js +4 -12
- package/src/standard/Math/Numbers/Vector3.js +6 -18
- package/src/standard/Math/Numbers/Vector4.js +4 -20
- package/src/standard/Time/StopWatch.js +9 -14
- package/src/tests.js +11 -0
- package/src/x_ite/Browser/Core/BrowserTimings.js +10 -10
- package/src/x_ite/Browser/Core/X3DCoreContext.js +4 -6
- package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolator.js +94 -88
- package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolator1.js +2 -3
- package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolatorTemplate.js +17 -14
- package/src/x_ite/Browser/Text/PolygonText.js +15 -24
- package/src/x_ite/Browser/VERSION.js +1 -1
- package/src/x_ite/Components/Core/X3DNode.js +12 -0
- package/src/x_ite/Components/Core/X3DPrototypeInstance.js +18 -0
- package/src/x_ite/Components/Interpolation/SquadOrientationInterpolator.js +8 -7
- package/src/x_ite/Configuration/UnitInfo.js +2 -0
- package/src/x_ite/Execution/X3DExportedNode.js +4 -0
- package/src/x_ite/Execution/X3DImportedNode.js +14 -0
- package/src/x_ite/Execution/X3DScene.js +4 -0
- package/src/x_ite/Fields/SFString.js +4 -6
- package/src/x_ite/InputOutput/FileLoader.js +1 -1
- package/src/x_ite/InputOutput/Generator.js +35 -55
- package/src/x_ite/Parser/GLTF2Parser.js +4 -4
- package/src/x_ite/Parser/SVGParser.js +24 -47
- package/src/x_ite/Parser/X3DParser.js +1 -1
- package/src/x_ite/Prototype/X3DExternProtoDeclaration.js +4 -0
- package/src/x_ite/Prototype/X3DProtoDeclaration.js +4 -0
- 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: X3D Visual Blend Mode Editor
|
|
|
3
3
|
layout: wide
|
|
4
4
|
collection: tabs
|
|
5
5
|
categories: [Laboratory]
|
|
6
|
-
tags: [X3D,
|
|
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
|
@@ -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
|
|
55
|
+
const { interval } = Algorithm;
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
{
|
|
55
|
-
this .args = arguments;
|
|
56
|
-
}
|
|
57
|
+
// https://pomax.github.io/bezierinfo/
|
|
57
58
|
|
|
58
|
-
Bezier
|
|
59
|
+
const Bezier =
|
|
59
60
|
{
|
|
60
|
-
|
|
61
|
+
quadric: (function ()
|
|
61
62
|
{
|
|
62
|
-
const
|
|
63
|
+
const
|
|
64
|
+
c = new Matrix3 (1, 0, 0, -2, 2, 0, 1, -2, 1),
|
|
65
|
+
p = new Matrix3 ();
|
|
63
66
|
|
|
64
|
-
|
|
67
|
+
return function (x0, y0, z0, x1, y1, z1, x2, y2, z2, steps, points)
|
|
65
68
|
{
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
87
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
116
|
-
|
|
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
|
-
|
|
119
|
-
|
|
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
|
-
|
|
96
|
+
p .multVecMatrix (v .set (1, t, t * t, t * t * t));
|
|
126
97
|
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
138
|
-
rx2 = rx * rx,
|
|
139
|
-
ry2 = ry * ry;
|
|
114
|
+
// In accordance to: http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters
|
|
140
115
|
|
|
141
|
-
|
|
116
|
+
rx = Math .abs (rx);
|
|
117
|
+
ry = Math .abs (ry);
|
|
142
118
|
|
|
143
|
-
|
|
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
|
-
|
|
146
|
-
|
|
147
|
-
|
|
126
|
+
const
|
|
127
|
+
rx2 = rx * rx,
|
|
128
|
+
ry2 = ry * ry;
|
|
148
129
|
|
|
149
|
-
|
|
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
|
-
|
|
153
|
-
const d = new Vector2 (ax - x, ay - y) .divide (2);
|
|
132
|
+
xAxisRotation = interval (xAxisRotation, 0, 2 * Math .PI);
|
|
154
133
|
|
|
155
|
-
|
|
156
|
-
|
|
134
|
+
const
|
|
135
|
+
sinRotation = Math .sin (xAxisRotation),
|
|
136
|
+
cosRotation = Math .cos (xAxisRotation);
|
|
157
137
|
|
|
158
|
-
|
|
138
|
+
// Following "Conversion from endpoint to center parameterization"
|
|
139
|
+
// http://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter
|
|
159
140
|
|
|
160
|
-
|
|
161
|
-
|
|
141
|
+
// Step #1: Compute transformedPoint
|
|
142
|
+
const d = new Vector2 (ax - x, ay - y) .divide (2);
|
|
162
143
|
|
|
163
|
-
|
|
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
|
-
|
|
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
|
-
|
|
175
|
-
|
|
149
|
+
// Ensure radii are large enough
|
|
150
|
+
const radiiCheck = transformedPoint2 .x / rx2 + transformedPoint2 .y / ry2;
|
|
176
151
|
|
|
177
|
-
|
|
152
|
+
if (radiiCheck > 1)
|
|
153
|
+
{
|
|
154
|
+
rx = Math .sqrt (radiiCheck) * rx;
|
|
155
|
+
ry = Math .sqrt (radiiCheck) * ry;
|
|
156
|
+
}
|
|
178
157
|
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
|
|
183
|
-
|
|
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
|
-
|
|
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
|
-
|
|
191
|
-
|
|
168
|
+
const transformedCenter = new Vector2 ( cCoef * rx * transformedPoint .y / ry,
|
|
169
|
+
-cCoef * ry * transformedPoint .x / rx);
|
|
192
170
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
213
|
-
|
|
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
|
-
|
|
216
|
-
sweepAngle -= 2 * Math .PI;
|
|
186
|
+
let sweepAngle = endAngle - startAngle;
|
|
217
187
|
|
|
218
|
-
|
|
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
|
-
|
|
221
|
-
|
|
201
|
+
if (sweepFlag && sweepAngle < 0)
|
|
202
|
+
sweepAngle += 2 *Math .PI;
|
|
222
203
|
|
|
223
|
-
|
|
204
|
+
else if (!sweepFlag && sweepAngle > 0)
|
|
205
|
+
sweepAngle -= 2 * Math .PI;
|
|
224
206
|
|
|
225
|
-
|
|
226
|
-
{
|
|
227
|
-
const t = i / bezier_steps_1;
|
|
207
|
+
// Interpolate:
|
|
228
208
|
|
|
229
|
-
|
|
230
|
-
|
|
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
|
-
|
|
235
|
-
sinRotation * x + cosRotation * y + center .y);
|
|
212
|
+
points .push (new Vector3 (ax, ay, 0));
|
|
236
213
|
|
|
237
|
-
|
|
238
|
-
|
|
214
|
+
for (let i = 1; i < bezier_steps_1; ++ i)
|
|
215
|
+
{
|
|
216
|
+
const t = i / bezier_steps_1;
|
|
239
217
|
|
|
240
|
-
|
|
241
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -119,10 +119,8 @@ Line2 .prototype =
|
|
|
119
119
|
return function (line, point)
|
|
120
120
|
{
|
|
121
121
|
const
|
|
122
|
-
p1 = this
|
|
123
|
-
p2 = line
|
|
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
|
|
112
|
-
p2 = line
|
|
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
|
-
|
|
70
|
-
|
|
69
|
+
{ point, direction } = line,
|
|
70
|
+
{ center, radius } = this;
|
|
71
71
|
|
|
72
72
|
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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 (
|
|
98
|
-
exitPoint .assign (
|
|
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)
|