sunrize 1.7.43 → 1.7.45

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 (38) hide show
  1. package/package.json +3 -3
  2. package/src/Application/Application.js +17 -5
  3. package/src/Application/Dashboard.js +5 -2
  4. package/src/Application/Document.js +1 -9
  5. package/src/Application/Tabs.js +2 -1
  6. package/src/Components/Geometry2D/Arc2D.js +16 -0
  7. package/src/Components/Geometry2D/ArcClose2D.js +14 -0
  8. package/src/Components/Geometry2D/Circle2D.js +23 -0
  9. package/src/Components/Geometry2D/Disk2D.js +53 -0
  10. package/src/Components/Geometry2D/Polyline2D.js +16 -0
  11. package/src/Components/Geometry2D/Polypoint2D.js +20 -0
  12. package/src/Components/Geometry2D/Rectangle2D.js +27 -0
  13. package/src/Components/Geometry2D/TriangleSet2D.js +33 -0
  14. package/src/Components/Geometry3D/Box.js +27 -0
  15. package/src/Components/Geometry3D/Cone.js +79 -0
  16. package/src/Components/Geometry3D/Cylinder.js +81 -0
  17. package/src/Components/Geometry3D/ElevationGrid.js +23 -0
  18. package/src/Components/Geometry3D/Extrusion.js +194 -0
  19. package/src/Components/Geometry3D/IndexedFaceSet.js +112 -0
  20. package/src/Components/Geometry3D/Sphere.js +27 -0
  21. package/src/Components/NURBS/NurbsCurve.js +17 -0
  22. package/src/Components/NURBS/NurbsSweptSurface.js +24 -0
  23. package/src/Components/NURBS/NurbsSwungSurface.js +24 -0
  24. package/src/Components/NURBS/X3DNurbsSurfaceGeometryNode.js +19 -0
  25. package/src/Components/Rendering/IndexedLineSet.js +24 -0
  26. package/src/Components/Rendering/LineSet.js +34 -0
  27. package/src/Components/Rendering/X3DComposedGeometryNode.js +44 -0
  28. package/src/Components/Rendering/X3DGeometryNode.js +183 -0
  29. package/src/Components/Text/Text.js +17 -0
  30. package/src/Components.js +33 -0
  31. package/src/Editors/Library.js +2 -0
  32. package/src/Editors/LibraryPane.js +6 -1
  33. package/src/Editors/NodesLibrary.js +41 -1
  34. package/src/Editors/OutlineEditor.js +118 -25
  35. package/src/Editors/OutlineView.js +53 -22
  36. package/src/Editors/PrimitivesLibrary.js +58 -2
  37. package/src/Tools/Geometry2D/Disk2DTool.js +16 -18
  38. package/src/Undo/Editor.js +207 -153
@@ -0,0 +1,194 @@
1
+ const X3D = require ("../../X3D");
2
+
3
+ Object .assign (X3D .Extrusion .prototype,
4
+ {
5
+ toPrimitive (executionContext = this .getExecutionContext ())
6
+ {
7
+ const
8
+ geometry = executionContext .createNode ("IndexedFaceSet", false),
9
+ texCoord = executionContext .createNode ("TextureCoordinate", false),
10
+ coord = executionContext .createNode ("Coordinate", false);
11
+
12
+ geometry ._metadata = this ._metadata;
13
+ geometry ._solid = this ._solid;
14
+ geometry ._ccw = this ._ccw;
15
+ geometry ._convex = this ._convex;
16
+ geometry ._creaseAngle = this ._creaseAngle;
17
+
18
+ geometry ._texCoord = texCoord;
19
+ geometry ._coord = coord;
20
+
21
+ // Fill the geometry with points.
22
+
23
+ const points = this .createPoints ();
24
+
25
+ const
26
+ numSpines = this ._spine .length,
27
+ numCrossSections = this ._crossSection .length,
28
+ numSpines_1 = numSpines - 1,
29
+ numCrossSections_1 = numCrossSections - 1;
30
+
31
+ if (numSpines < 2 || numCrossSections < 2)
32
+ {
33
+ texCoord .setup ();
34
+ coord .setup ();
35
+ geometry .setup ();
36
+
37
+ return geometry;
38
+ }
39
+
40
+ const closedSpine = this .getClosed (this ._spine)
41
+ && this .getClosed (this ._orientation)
42
+ && this .getClosed (this ._scale);
43
+
44
+ const closedCrossSection = this .getClosed (this ._crossSection);
45
+
46
+ // Coordinates
47
+
48
+ for (let s = 0; s < numSpines_1; ++ s)
49
+ {
50
+ for (let c = 0; c < numCrossSections_1; ++ c)
51
+ {
52
+ /* 0---3
53
+ * |\ |
54
+ * | \ |
55
+ * |__\|
56
+ * 1 2
57
+ */
58
+
59
+ const
60
+ c1 = closedCrossSection ? (c + 1) % numCrossSections_1 : c + 1,
61
+ s1 = closedSpine ? (s + 1) % numSpines_1 : s + 1;
62
+
63
+ const
64
+ p0 = s * numCrossSections + c,
65
+ p1 = s * numCrossSections + c1,
66
+ p2 = s1 * numCrossSections + c1,
67
+ p3 = s1 * numCrossSections + c;
68
+
69
+ geometry ._coordIndex .push (p0, p1, p2, -1, p0, p2, p3, -1);
70
+ }
71
+ }
72
+
73
+ coord ._point = points .flatMap (point => [... point]);
74
+
75
+ // Texture coordinates
76
+
77
+ for (let s = 0; s < numSpines_1; ++ s)
78
+ {
79
+ for (let c = 0; c < numCrossSections_1; ++ c)
80
+ {
81
+ const
82
+ c1 = c + 1,
83
+ s1 = s + 1;
84
+
85
+ const
86
+ p0 = s * numCrossSections + c,
87
+ p1 = s * numCrossSections + c1,
88
+ p2 = s1 * numCrossSections + c1,
89
+ p3 = s1 * numCrossSections + c;
90
+
91
+ geometry ._texCoordIndex .push (p0, p1, p2, -1, p0, p2, p3, -1);
92
+ }
93
+ }
94
+
95
+ const texCoordPoints = [ ];
96
+
97
+ for (let s = 0; s < numSpines; ++ s)
98
+ {
99
+ for (let c = 0; c < numCrossSections; ++ c)
100
+ {
101
+ const
102
+ tx = c / numCrossSections_1,
103
+ ty = s / numSpines_1;
104
+
105
+ texCoordPoints .push (tx, ty);
106
+ }
107
+ }
108
+
109
+ texCoord ._point = texCoordPoints;
110
+
111
+ // Caps
112
+
113
+ let min = max = this ._crossSection [0];
114
+
115
+ for (let c = 1; c < numCrossSections; ++ c)
116
+ {
117
+ min = min .min (this ._crossSection [c]);
118
+ max = max .max (this ._crossSection [c]);
119
+ }
120
+
121
+ const
122
+ capSize = max .subtract (min),
123
+ capMax = Math .max (capSize .x, capSize .y),
124
+ numCapPoints = closedCrossSection ? numCrossSections_1 : numCrossSections;
125
+
126
+ // Begin Cap
127
+
128
+ if (this ._beginCap .getValue ())
129
+ {
130
+ // Coordinates
131
+
132
+ const numCoords = coord ._point .length;
133
+
134
+ for (let c = numCapPoints - 1; c >= 0; -- c)
135
+ coord ._point .push (coord ._point [c]);
136
+
137
+ for (let c = 0; c < numCapPoints; ++ c)
138
+ geometry ._coordIndex .push (numCoords + c);
139
+
140
+ geometry ._coordIndex .push (-1);
141
+
142
+ // Texture coordinates
143
+
144
+ const numTexCoords = texCoord ._point .length;
145
+
146
+ for (let c = numCapPoints - 1; c >= 0; -- c)
147
+ texCoord ._point .push (this ._crossSection [c] .subtract (min) .divide (capMax));
148
+
149
+ for (let c = 0; c < numCapPoints; ++ c)
150
+ geometry ._texCoordIndex .push (numTexCoords + c);
151
+
152
+ geometry ._texCoordIndex .push (-1);
153
+ }
154
+
155
+ // End Cap
156
+
157
+ if (this ._endCap .getValue ())
158
+ {
159
+ // Coordinates
160
+
161
+ const first = numSpines * numCrossSections - numCrossSections;
162
+
163
+ const numCoords = coord ._point .length;
164
+
165
+ for (let c = 0; c < numCapPoints; ++ c)
166
+ coord ._point .push (coord ._point [first + c]);
167
+
168
+ for (let c = 0; c < numCapPoints; ++ c)
169
+ geometry ._coordIndex .push (numCoords + c);
170
+
171
+ geometry ._coordIndex .push (-1);
172
+
173
+ // Texture coordinates
174
+
175
+ const numTexCoords = texCoord ._point .length;
176
+
177
+ for (let c = 0; c < numCapPoints; ++ c)
178
+ texCoord ._point .push (this ._crossSection [c] .subtract (min) .divide (capMax));
179
+
180
+ for (let c = 0; c < numCapPoints; ++ c)
181
+ geometry ._texCoordIndex .push (numTexCoords + c);
182
+
183
+ geometry ._texCoordIndex .push (-1);
184
+ }
185
+
186
+ // geometry ._optimize ();
187
+
188
+ texCoord .setup ();
189
+ coord .setup ();
190
+ geometry .setup ();
191
+
192
+ return geometry;
193
+ },
194
+ });
@@ -0,0 +1,112 @@
1
+ const X3D = require ("../../X3D");
2
+
3
+ Object .assign (X3D .IndexedFaceSet .prototype,
4
+ {
5
+ toPrimitive (executionContext = this .getExecutionContext ())
6
+ {
7
+ const geometry = executionContext .createNode ("IndexedLineSet", false);
8
+
9
+ geometry ._metadata = this ._metadata;
10
+ geometry ._colorPerVertex = this ._colorPerVertex;
11
+ geometry ._attrib = this ._attrib;
12
+ geometry ._fogCoord = this ._fogCoord;
13
+ geometry ._color = this ._color;
14
+ geometry ._coord = this ._coord;
15
+
16
+ if (this ._normalPerVertex .getValue ())
17
+ {
18
+ if (!this ._normalIndex .length || this ._normalIndex .equals (this ._coordIndex))
19
+ geometry ._normal = this ._normal;
20
+ }
21
+
22
+ // The coord index must end with -1!
23
+
24
+ const
25
+ lineIndex = new Set (),
26
+ colorIndex = geometry ._colorIndex,
27
+ coordIndex = geometry ._coordIndex,
28
+ length = this ._coordIndex .length;
29
+
30
+ let
31
+ line = false,
32
+ last = -1,
33
+ first = 0,
34
+ face = 0;
35
+
36
+ for (let i = 1; i < length; ++ i)
37
+ {
38
+ const
39
+ p = i - 1,
40
+ previous = this ._coordIndex [p];
41
+
42
+ let
43
+ index = this ._coordIndex [i],
44
+ c = i;
45
+
46
+ if (index === -1)
47
+ {
48
+ index = this ._coordIndex [first];
49
+ c = first;
50
+ }
51
+
52
+ const
53
+ minMax = `${Math .min (previous, index)} ${Math .max (previous, index)}`,
54
+ exists = lineIndex .has (minMax);
55
+
56
+ if (!exists)
57
+ lineIndex .add (minMax);
58
+
59
+ if ((previous === -1 || exists) && line)
60
+ {
61
+ if (this ._color .getValue ())
62
+ {
63
+ if (this ._colorPerVertex .getValue ())
64
+ colorIndex .push (-1);
65
+ else
66
+ colorIndex .push (this .getColorPerFaceIndex (face));
67
+ }
68
+
69
+ coordIndex .push (-1);
70
+
71
+ line = false;
72
+ }
73
+
74
+ if (previous === -1)
75
+ {
76
+ first = i;
77
+ face += 1;
78
+ last = -1;
79
+ continue;
80
+ }
81
+
82
+ if (exists)
83
+ continue;
84
+
85
+ if (last !== previous)
86
+ {
87
+ if (this ._color .getValue ())
88
+ {
89
+ if (this ._colorPerVertex .getValue ())
90
+ colorIndex .push (this .getColorPerVertexIndex (p));
91
+ }
92
+
93
+ coordIndex .push (previous);
94
+ }
95
+
96
+ if (this ._color .getValue ())
97
+ {
98
+ if (this ._colorPerVertex .getValue ())
99
+ colorIndex .push (this .getColorPerVertexIndex (c));
100
+ }
101
+
102
+ coordIndex .push (index);
103
+
104
+ last = index;
105
+ line = true;
106
+ }
107
+
108
+ geometry .setup ();
109
+
110
+ return geometry;
111
+ },
112
+ });
@@ -0,0 +1,27 @@
1
+ const X3D = require ("../../X3D");
2
+
3
+ Object .assign (X3D .Sphere .prototype,
4
+ {
5
+ toPrimitive (executionContext = this .getExecutionContext ())
6
+ {
7
+ const
8
+ browser = this .getBrowser (),
9
+ geometry = browser .getSphereOptions () .getGeometry () .copy (executionContext),
10
+ radius = this ._radius .getValue ();
11
+
12
+ geometry ._metadata = this ._metadata;
13
+ geometry ._solid = this ._solid;
14
+
15
+ geometry ._texCoord = geometry ._texCoord .getValue () .copy (executionContext);
16
+ geometry ._coord = geometry ._coord .getValue () .copy (executionContext);
17
+
18
+ for (const [i, point] of geometry ._coord .point .entries ())
19
+ geometry ._coord .point [i] = point .multiply (radius);
20
+
21
+ geometry ._texCoord .getValue () .setup ();
22
+ geometry ._coord .getValue () .setup ();
23
+ geometry .setup ();
24
+
25
+ return geometry;
26
+ },
27
+ });
@@ -0,0 +1,17 @@
1
+ const X3D = require ("../../X3D");
2
+
3
+ Object .assign (X3D .NurbsCurve .prototype,
4
+ {
5
+ toPrimitive (executionContext = this .getExecutionContext ())
6
+ {
7
+ const geometry = this .toIndexedLineSet (executionContext,
8
+ {
9
+ double: !!X3D .X3DCast (X3D .X3DConstants .CoordinateDouble, this ._controlPoint),
10
+ polyline: true,
11
+ });
12
+
13
+ geometry ._metadata = this ._metadata;
14
+
15
+ return geometry;
16
+ },
17
+ });
@@ -0,0 +1,24 @@
1
+ const X3D = require ("../../X3D");
2
+
3
+ Object .assign (X3D .NurbsSweptSurface .prototype,
4
+ {
5
+ traverse (type, renderObject)
6
+ {
7
+ this .getTrajectoryCurve () ?.traverse (type, renderObject);
8
+ },
9
+ toPrimitive (executionContext = this .getExecutionContext ())
10
+ {
11
+ const geometry = this .toIndexedFaceSet (executionContext,
12
+ {
13
+ double: true,
14
+ texCoord: true,
15
+ });
16
+
17
+ geometry ._metadata = this ._metadata;
18
+ geometry ._solid = this ._solid;
19
+ geometry ._ccw = this ._ccw;
20
+ geometry ._creaseAngle = Math .PI;
21
+
22
+ return geometry;
23
+ },
24
+ });
@@ -0,0 +1,24 @@
1
+ const X3D = require ("../../X3D");
2
+
3
+ Object .assign (X3D .NurbsSwungSurface .prototype,
4
+ {
5
+ traverse (type, renderObject)
6
+ {
7
+ this .getTrajectoryCurve () ?.traverse (type, renderObject);
8
+ },
9
+ toPrimitive (executionContext = this .getExecutionContext ())
10
+ {
11
+ const geometry = this .toIndexedFaceSet (executionContext,
12
+ {
13
+ double: true,
14
+ texCoord: true,
15
+ });
16
+
17
+ geometry ._metadata = this ._metadata;
18
+ geometry ._solid = this ._solid;
19
+ geometry ._ccw = this ._ccw;
20
+ geometry ._creaseAngle = Math .PI;
21
+
22
+ return geometry;
23
+ },
24
+ });
@@ -0,0 +1,19 @@
1
+ const X3D = require ("../../X3D");
2
+
3
+ Object .assign (X3D .X3DNurbsSurfaceGeometryNode .prototype,
4
+ {
5
+ toPrimitive (executionContext = this .getExecutionContext ())
6
+ {
7
+ const geometry = this .toIndexedFaceSet (executionContext,
8
+ {
9
+ double: !!X3D .X3DCast (X3D .X3DConstants .CoordinateDouble, this ._controlPoint),
10
+ texCoord: true,
11
+ });
12
+
13
+ geometry ._metadata = this ._metadata;
14
+ geometry ._solid = this ._solid;
15
+ geometry ._creaseAngle = Math .PI;
16
+
17
+ return geometry;
18
+ },
19
+ });
@@ -0,0 +1,24 @@
1
+ const X3D = require ("../../X3D");
2
+
3
+ Object .assign (X3D .IndexedLineSet .prototype,
4
+ {
5
+ toPrimitive (executionContext = this .getExecutionContext)
6
+ {
7
+ const geometry = executionContext .createNode ("PointSet", false);
8
+
9
+ geometry ._metadata = this ._metadata;
10
+ geometry ._attrib = this ._attrib;
11
+ geometry ._fogCoord = this ._fogCoord;
12
+
13
+ if (this ._colorPerVertex .getValue ())
14
+ geometry ._color = this ._color;
15
+
16
+ geometry ._tangent = this ._tangent;
17
+ geometry ._normal = this ._normal;
18
+ geometry ._coord = this ._coord;
19
+
20
+ geometry .setup ();
21
+
22
+ return geometry;
23
+ },
24
+ });
@@ -0,0 +1,34 @@
1
+ const X3D = require ("../../X3D");
2
+
3
+ Object .assign (X3D .LineSet .prototype,
4
+ {
5
+ toPrimitive (executionContext = this .getExecutionContext)
6
+ {
7
+ const geometry = executionContext .createNode ("IndexedLineSet", false);
8
+
9
+ geometry ._metadata = this ._metadata;
10
+ geometry ._attrib = this ._attrib;
11
+ geometry ._fogCoord = this ._fogCoord;
12
+ geometry ._color = this ._color;
13
+ geometry ._tangent = this ._tangent;
14
+ geometry ._normal = this ._normal;
15
+ geometry ._coord = this ._coord;
16
+
17
+ let index = 0;
18
+
19
+ for (const length of this ._vertexCount)
20
+ {
21
+ if (length < 2)
22
+ continue;
23
+
24
+ for (let i = 0; i < length; ++ i, ++ index)
25
+ geometry ._coordIndex .push (index);
26
+
27
+ geometry ._coordIndex .push (-1);
28
+ }
29
+
30
+ geometry .setup ();
31
+
32
+ return geometry;
33
+ },
34
+ });
@@ -0,0 +1,44 @@
1
+ const X3D = require ("../../X3D");
2
+
3
+ Object .assign (X3D .X3DComposedGeometryNode .prototype,
4
+ {
5
+ toPrimitive (executionContext = this .getExecutionContext)
6
+ {
7
+ const geometry = executionContext .createNode ("IndexedFaceSet", false);
8
+
9
+ geometry ._metadata = this ._metadata;
10
+ geometry ._solid = this ._solid;
11
+ geometry ._ccw = this ._ccw;
12
+ geometry ._creaseAngle = Math .PI;
13
+ geometry ._colorPerVertex = this ._colorPerVertex;
14
+ geometry ._normalPerVertex = this ._normalPerVertex;
15
+
16
+ geometry ._attrib = this ._attrib;
17
+ geometry ._fogCoord = this ._fogCoord;
18
+ geometry ._color = this ._color;
19
+ geometry ._tangent = this ._tangent;
20
+ geometry ._normal = this ._normal;
21
+ geometry ._coord = this ._coord;
22
+
23
+ let
24
+ verticesPerPolygon = this .getVerticesPerPolygon (),
25
+ numVertices = this .getNumVertices ();
26
+
27
+ // Set size to a multiple of vertexCount.
28
+ numVertices -= numVertices % verticesPerPolygon;
29
+
30
+ for (let i = 0; i < numVertices; ++ i)
31
+ {
32
+ const index = this .getPolygonIndex (i);
33
+
34
+ geometry ._coordIndex .push (index);
35
+
36
+ if (i % verticesPerPolygon === verticesPerPolygon - 1)
37
+ geometry ._coordIndex .push (-1);
38
+ }
39
+
40
+ geometry .setup ();
41
+
42
+ return geometry;
43
+ },
44
+ });