sunrize 1.7.44 → 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.
- package/package.json +3 -3
- package/src/Application/Document.js +1 -9
- package/src/Components/Geometry2D/Arc2D.js +16 -0
- package/src/Components/Geometry2D/ArcClose2D.js +14 -0
- package/src/Components/Geometry2D/Circle2D.js +23 -0
- package/src/Components/Geometry2D/Disk2D.js +53 -0
- package/src/Components/Geometry2D/Polyline2D.js +16 -0
- package/src/Components/Geometry2D/Polypoint2D.js +20 -0
- package/src/Components/Geometry2D/Rectangle2D.js +27 -0
- package/src/Components/Geometry2D/TriangleSet2D.js +33 -0
- package/src/Components/Geometry3D/Box.js +27 -0
- package/src/Components/Geometry3D/Cone.js +79 -0
- package/src/Components/Geometry3D/Cylinder.js +81 -0
- package/src/Components/Geometry3D/ElevationGrid.js +23 -0
- package/src/Components/Geometry3D/Extrusion.js +194 -0
- package/src/Components/Geometry3D/IndexedFaceSet.js +112 -0
- package/src/Components/Geometry3D/Sphere.js +27 -0
- package/src/Components/NURBS/NurbsCurve.js +17 -0
- package/src/Components/NURBS/NurbsSweptSurface.js +24 -0
- package/src/Components/NURBS/NurbsSwungSurface.js +24 -0
- package/src/Components/NURBS/X3DNurbsSurfaceGeometryNode.js +19 -0
- package/src/Components/Rendering/IndexedLineSet.js +24 -0
- package/src/Components/Rendering/LineSet.js +34 -0
- package/src/Components/Rendering/X3DComposedGeometryNode.js +44 -0
- package/src/Components/Rendering/X3DGeometryNode.js +183 -0
- package/src/Components/Text/Text.js +17 -0
- package/src/Components.js +33 -0
- package/src/Editors/OutlineEditor.js +114 -21
- package/src/Editors/OutlineView.js +3 -3
- package/src/Tools/Geometry2D/Disk2DTool.js +16 -18
- package/src/Undo/Editor.js +198 -144
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sunrize",
|
|
3
3
|
"productName": "Sunrize X3D Editor",
|
|
4
|
-
"version": "1.7.
|
|
4
|
+
"version": "1.7.45",
|
|
5
5
|
"description": "A Multi-Platform X3D Editor",
|
|
6
6
|
"main": "src/main.js",
|
|
7
7
|
"bin": {
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"dependencies": {
|
|
91
91
|
"capitalize": "^2.0.4",
|
|
92
92
|
"console": "^0.7.2",
|
|
93
|
-
"electron": "^
|
|
93
|
+
"electron": "^34.0.0",
|
|
94
94
|
"electron-prompt": "^1.7.0",
|
|
95
95
|
"electron-squirrel-startup": "^1.0.1",
|
|
96
96
|
"electron-tabs": "^1.0.4",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"string-similarity": "^4.0.4",
|
|
110
110
|
"tweakpane": "^3.1.10",
|
|
111
111
|
"update-electron-app": "^3.1.0",
|
|
112
|
-
"x_ite": "^11.0.
|
|
112
|
+
"x_ite": "^11.0.5",
|
|
113
113
|
"x3d-traverse": "^1.0.9"
|
|
114
114
|
}
|
|
115
115
|
}
|
|
@@ -177,15 +177,7 @@ module .exports = class Document extends Interface
|
|
|
177
177
|
|
|
178
178
|
this .browser .updateConcreteNode (require ("../Components/Grouping/StaticGroup"));
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
{
|
|
182
|
-
this .getTrajectoryCurve () ?.traverse (type, renderObject);
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
X3D .NurbsSwungSurface .prototype .traverse = function (type, renderObject)
|
|
186
|
-
{
|
|
187
|
-
this .getTrajectoryCurve () ?.traverse (type, renderObject);
|
|
188
|
-
};
|
|
180
|
+
require ("../Components");
|
|
189
181
|
|
|
190
182
|
// Restore
|
|
191
183
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const X3D = require ("../../X3D");
|
|
2
|
+
|
|
3
|
+
Object .assign (X3D .Arc2D .prototype,
|
|
4
|
+
{
|
|
5
|
+
toPrimitive (executionContext = this .getExecutionContext ())
|
|
6
|
+
{
|
|
7
|
+
const geometry = this .toIndexedLineSet (executionContext,
|
|
8
|
+
{
|
|
9
|
+
polyline: true,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
geometry ._metadata = this ._metadata;
|
|
13
|
+
|
|
14
|
+
return geometry;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const X3D = require ("../../X3D");
|
|
2
|
+
|
|
3
|
+
Object .assign (X3D .ArcClose2D .prototype,
|
|
4
|
+
{
|
|
5
|
+
toPrimitive (executionContext = this .getExecutionContext ())
|
|
6
|
+
{
|
|
7
|
+
const geometry = this .toIndexedFaceSet (executionContext, { texCoord: true });
|
|
8
|
+
|
|
9
|
+
geometry ._metadata = this ._metadata;
|
|
10
|
+
geometry ._solid = this ._solid;
|
|
11
|
+
|
|
12
|
+
return geometry;
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const X3D = require ("../../X3D");
|
|
2
|
+
|
|
3
|
+
Object .assign (X3D .Circle2D .prototype,
|
|
4
|
+
{
|
|
5
|
+
toPrimitive (executionContext = this .getExecutionContext ())
|
|
6
|
+
{
|
|
7
|
+
const
|
|
8
|
+
browser = this .getBrowser (),
|
|
9
|
+
geometry = browser .getCircle2DOptions () .getGeometry () .copy (executionContext),
|
|
10
|
+
radius = this ._radius .getValue ();
|
|
11
|
+
|
|
12
|
+
geometry ._metadata = this ._metadata;
|
|
13
|
+
geometry ._coord = geometry ._coord .getValue () .copy (executionContext);
|
|
14
|
+
|
|
15
|
+
for (const [i, point] of geometry ._coord .point .entries ())
|
|
16
|
+
geometry ._coord .point [i] = point .multiply (radius);
|
|
17
|
+
|
|
18
|
+
geometry ._coord .getValue () .setup ();
|
|
19
|
+
geometry .setup ();
|
|
20
|
+
|
|
21
|
+
return geometry;
|
|
22
|
+
},
|
|
23
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const X3D = require ("../../X3D");
|
|
2
|
+
|
|
3
|
+
Object .assign (X3D .Disk2D .prototype,
|
|
4
|
+
{
|
|
5
|
+
toPrimitive (executionContext = this .getExecutionContext ())
|
|
6
|
+
{
|
|
7
|
+
const
|
|
8
|
+
innerRadius = Math .min (Math .abs (this ._innerRadius .getValue ()), Math .abs (this ._outerRadius .getValue ())),
|
|
9
|
+
outerRadius = Math .max (Math .abs (this ._innerRadius .getValue ()), Math .abs (this ._outerRadius .getValue ()));
|
|
10
|
+
|
|
11
|
+
if (innerRadius === outerRadius)
|
|
12
|
+
{
|
|
13
|
+
// Point
|
|
14
|
+
|
|
15
|
+
if (outerRadius === 0)
|
|
16
|
+
{
|
|
17
|
+
const geometry = executionContext .createNode ("PointSet", false);
|
|
18
|
+
|
|
19
|
+
geometry ._coord = executionContext .createNode ("Coordinate", false);
|
|
20
|
+
|
|
21
|
+
geometry ._coord .point .push (new X3D .SFVec3f ());
|
|
22
|
+
|
|
23
|
+
geometry ._coord .getValue () .setup ();
|
|
24
|
+
geometry .setup ();
|
|
25
|
+
|
|
26
|
+
return geometry;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Circle
|
|
30
|
+
|
|
31
|
+
const
|
|
32
|
+
browser = this .getBrowser (),
|
|
33
|
+
geometry = browser .getCircle2DOptions () .getGeometry () .copy (executionContext);
|
|
34
|
+
|
|
35
|
+
geometry ._coord = geometry ._coord .getValue () .copy (executionContext);
|
|
36
|
+
|
|
37
|
+
for (const [i, point] of geometry ._coord .point .entries ())
|
|
38
|
+
geometry ._coord .point [i] = point .multiply (outerRadius);
|
|
39
|
+
|
|
40
|
+
geometry ._coord .getValue () .setup ();
|
|
41
|
+
geometry .setup ();
|
|
42
|
+
|
|
43
|
+
return geometry;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const geometry = this .toIndexedFaceSet (executionContext, { texCoord: true });
|
|
47
|
+
|
|
48
|
+
geometry ._metadata = this ._metadata;
|
|
49
|
+
geometry ._solid = this ._solid;
|
|
50
|
+
|
|
51
|
+
return geometry;
|
|
52
|
+
},
|
|
53
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const X3D = require ("../../X3D");
|
|
2
|
+
|
|
3
|
+
Object .assign (X3D .Polyline2D .prototype,
|
|
4
|
+
{
|
|
5
|
+
toPrimitive (executionContext = this .getExecutionContext ())
|
|
6
|
+
{
|
|
7
|
+
const geometry = this .toIndexedLineSet (executionContext,
|
|
8
|
+
{
|
|
9
|
+
polyline: true,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
geometry ._metadata = this ._metadata;
|
|
13
|
+
|
|
14
|
+
return geometry;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const X3D = require ("../../X3D");
|
|
2
|
+
|
|
3
|
+
Object .assign (X3D .Polypoint2D .prototype,
|
|
4
|
+
{
|
|
5
|
+
toPrimitive (executionContext = this .getExecutionContext ())
|
|
6
|
+
{
|
|
7
|
+
const geometry = executionContext .createNode ("PointSet", false);
|
|
8
|
+
|
|
9
|
+
geometry ._metadata = this ._metadata;
|
|
10
|
+
geometry ._coord = executionContext .createNode ("Coordinate", false);
|
|
11
|
+
|
|
12
|
+
for (const point of this ._point)
|
|
13
|
+
geometry ._coord .point .push (new X3D .SFVec3f (... point, 0));
|
|
14
|
+
|
|
15
|
+
geometry ._coord .getValue () .setup ();
|
|
16
|
+
geometry .setup ();
|
|
17
|
+
|
|
18
|
+
return geometry;
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const X3D = require ("../../X3D");
|
|
2
|
+
|
|
3
|
+
Object .assign (X3D .Rectangle2D .prototype,
|
|
4
|
+
{
|
|
5
|
+
toPrimitive (executionContext = this .getExecutionContext ())
|
|
6
|
+
{
|
|
7
|
+
const
|
|
8
|
+
browser = this .getBrowser (),
|
|
9
|
+
geometry = browser .getRectangle2DOptions () .getGeometry () .copy (executionContext),
|
|
10
|
+
size1_2 = new X3D .SFVec3f (... this ._size .divide (2), 1);
|
|
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 .multVec (size1_2);
|
|
20
|
+
|
|
21
|
+
geometry ._texCoord .getValue () .setup ();
|
|
22
|
+
geometry ._coord .getValue () .setup ();
|
|
23
|
+
geometry .setup ();
|
|
24
|
+
|
|
25
|
+
return geometry;
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const X3D = require ("../../X3D");
|
|
2
|
+
|
|
3
|
+
Object .assign (X3D .TriangleSet2D .prototype,
|
|
4
|
+
{
|
|
5
|
+
toPrimitive (executionContext = this .getExecutionContext ())
|
|
6
|
+
{
|
|
7
|
+
const
|
|
8
|
+
texCoords = this .getTexCoords (),
|
|
9
|
+
vertices = this .getVertices (),
|
|
10
|
+
geometry = executionContext .createNode ("IndexedFaceSet", false);
|
|
11
|
+
|
|
12
|
+
geometry ._metadata = this ._metadata;
|
|
13
|
+
geometry ._solid = this ._solid;
|
|
14
|
+
|
|
15
|
+
geometry ._texCoord = executionContext .createNode ("TextureCoordinate", false);
|
|
16
|
+
geometry ._coord = executionContext .createNode ("Coordinate", false);
|
|
17
|
+
|
|
18
|
+
for (let i = 0, length = vertices .length / 12; i < length; ++ i)
|
|
19
|
+
geometry ._coordIndex .push (i * 3, i * 3 + 1, i * 3 + 2, -1);
|
|
20
|
+
|
|
21
|
+
for (let i = 0, length = vertices .length; i < length; i += 4)
|
|
22
|
+
{
|
|
23
|
+
geometry ._texCoord .point .push (new X3D .SFVec2f (texCoords [i], texCoords [i + 1]));
|
|
24
|
+
geometry ._coord .point .push (new X3D .SFVec3f (vertices [i], vertices [i + 1], 0));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
geometry ._texCoord .getValue () .setup ();
|
|
28
|
+
geometry ._coord .getValue () .setup ();
|
|
29
|
+
geometry .setup ();
|
|
30
|
+
|
|
31
|
+
return geometry;
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const X3D = require ("../../X3D");
|
|
2
|
+
|
|
3
|
+
Object .assign (X3D .Box .prototype,
|
|
4
|
+
{
|
|
5
|
+
toPrimitive (executionContext = this .getExecutionContext ())
|
|
6
|
+
{
|
|
7
|
+
const
|
|
8
|
+
browser = this .getBrowser (),
|
|
9
|
+
geometry = browser .getBoxOptions () .getGeometry () .copy (executionContext),
|
|
10
|
+
size1_2 = this ._size .divide (2);
|
|
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 .multVec (size1_2);
|
|
20
|
+
|
|
21
|
+
geometry ._texCoord .getValue () .setup ();
|
|
22
|
+
geometry ._coord .getValue () .setup ();
|
|
23
|
+
geometry .setup ();
|
|
24
|
+
|
|
25
|
+
return geometry;
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const X3D = require ("../../X3D");
|
|
2
|
+
|
|
3
|
+
Object .assign (X3D .Cone .prototype,
|
|
4
|
+
{
|
|
5
|
+
toPrimitive (executionContext = this .getExecutionContext ())
|
|
6
|
+
{
|
|
7
|
+
const
|
|
8
|
+
browser = this .getBrowser (),
|
|
9
|
+
geometry = browser .getConeOptions () .getSideGeometry () .copy (executionContext),
|
|
10
|
+
radius = this ._bottomRadius .getValue (),
|
|
11
|
+
height1_2 = this ._height .getValue () / 2;
|
|
12
|
+
|
|
13
|
+
geometry ._metadata = this ._metadata;
|
|
14
|
+
geometry ._coordIndex = [ ];
|
|
15
|
+
geometry ._normalIndex = [ ];
|
|
16
|
+
geometry ._solid = this ._solid;
|
|
17
|
+
geometry ._creaseAngle = Math .PI;
|
|
18
|
+
|
|
19
|
+
geometry ._texCoord = geometry ._texCoord .getValue () .copy (executionContext);
|
|
20
|
+
geometry ._normal = null;
|
|
21
|
+
geometry ._coord = geometry ._coord .getValue () .copy (executionContext);
|
|
22
|
+
|
|
23
|
+
for (const point of geometry ._coord .point)
|
|
24
|
+
{
|
|
25
|
+
point .x *= radius;
|
|
26
|
+
point .y *= height1_2;
|
|
27
|
+
point .z *= radius;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (this ._side .getValue ())
|
|
31
|
+
{
|
|
32
|
+
const last = geometry ._coord .point .length - 1;
|
|
33
|
+
|
|
34
|
+
for (const index of browser .getConeOptions () .getSideGeometry () ._coordIndex)
|
|
35
|
+
{
|
|
36
|
+
if (index < 0 || index !== last)
|
|
37
|
+
{
|
|
38
|
+
geometry ._coordIndex .push (index);
|
|
39
|
+
}
|
|
40
|
+
else
|
|
41
|
+
{
|
|
42
|
+
geometry ._coordIndex .push (geometry ._coord .point .length);
|
|
43
|
+
geometry ._coord .point .push (geometry ._coord .point [index]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else
|
|
48
|
+
{
|
|
49
|
+
geometry ._texCoordIndex .length = 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (this ._bottom .getValue ())
|
|
53
|
+
{
|
|
54
|
+
for (const index of browser .getConeOptions () .getBottomGeometry () ._texCoordIndex)
|
|
55
|
+
geometry ._texCoordIndex .push (index);
|
|
56
|
+
|
|
57
|
+
for (const index of browser .getConeOptions () .getBottomGeometry () ._coordIndex)
|
|
58
|
+
{
|
|
59
|
+
if (index < 0)
|
|
60
|
+
{
|
|
61
|
+
geometry ._coordIndex .push (-1);
|
|
62
|
+
}
|
|
63
|
+
else
|
|
64
|
+
{
|
|
65
|
+
geometry ._coordIndex .push (geometry ._coord .point .length);
|
|
66
|
+
geometry ._coord .point .push (geometry ._coord .point [index]);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// geometry .optimize ();
|
|
72
|
+
|
|
73
|
+
geometry ._texCoord .getValue () .setup ();
|
|
74
|
+
geometry ._coord .getValue () .setup ();
|
|
75
|
+
geometry .setup ();
|
|
76
|
+
|
|
77
|
+
return geometry;
|
|
78
|
+
},
|
|
79
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const X3D = require ("../../X3D");
|
|
2
|
+
|
|
3
|
+
Object .assign (X3D .Cylinder .prototype,
|
|
4
|
+
{
|
|
5
|
+
toPrimitive (executionContext = this .getExecutionContext ())
|
|
6
|
+
{
|
|
7
|
+
const
|
|
8
|
+
browser = this .getBrowser (),
|
|
9
|
+
geometry = browser .getCylinderOptions () .getSideGeometry () .copy (executionContext),
|
|
10
|
+
radius = this ._radius .getValue (),
|
|
11
|
+
height1_2 = this ._height .getValue () / 2;
|
|
12
|
+
|
|
13
|
+
geometry ._metadata = this ._metadata;
|
|
14
|
+
geometry ._normalIndex = [ ];
|
|
15
|
+
geometry ._solid = this ._solid;
|
|
16
|
+
geometry ._creaseAngle = Math .PI;
|
|
17
|
+
|
|
18
|
+
geometry ._texCoord = geometry ._texCoord .getValue () .copy (executionContext);
|
|
19
|
+
geometry ._normal = null;
|
|
20
|
+
geometry ._coord = geometry ._coord .getValue () .copy (executionContext);
|
|
21
|
+
|
|
22
|
+
for (const point of geometry ._coord .point)
|
|
23
|
+
{
|
|
24
|
+
point .x *= radius;
|
|
25
|
+
point .y *= height1_2;
|
|
26
|
+
point .z *= radius;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!this ._side .getValue ())
|
|
30
|
+
{
|
|
31
|
+
geometry ._texCoordIndex .length = 0;
|
|
32
|
+
geometry ._coordIndex .length = 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (this ._top .getValue ())
|
|
36
|
+
{
|
|
37
|
+
for (const index of browser .getCylinderOptions () .getTopGeometry () ._texCoordIndex)
|
|
38
|
+
geometry ._texCoordIndex .push (index);
|
|
39
|
+
|
|
40
|
+
for (const index of browser .getCylinderOptions () .getTopGeometry () ._coordIndex)
|
|
41
|
+
{
|
|
42
|
+
if (index < 0)
|
|
43
|
+
{
|
|
44
|
+
geometry ._coordIndex .push (-1);
|
|
45
|
+
}
|
|
46
|
+
else
|
|
47
|
+
{
|
|
48
|
+
geometry ._coordIndex .push (geometry ._coord .point .length);
|
|
49
|
+
geometry ._coord .point .push (geometry ._coord .point [index]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (this ._bottom .getValue ())
|
|
55
|
+
{
|
|
56
|
+
for (const index of browser .getCylinderOptions () .getBottomGeometry () ._texCoordIndex)
|
|
57
|
+
geometry ._texCoordIndex .push (index);
|
|
58
|
+
|
|
59
|
+
for (const index of browser .getCylinderOptions () .getBottomGeometry () ._coordIndex)
|
|
60
|
+
{
|
|
61
|
+
if (index < 0)
|
|
62
|
+
{
|
|
63
|
+
geometry ._coordIndex .push (-1);
|
|
64
|
+
}
|
|
65
|
+
else
|
|
66
|
+
{
|
|
67
|
+
geometry ._coordIndex .push (geometry ._coord .point .length);
|
|
68
|
+
geometry ._coord .point .push (geometry ._coord .point [index]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// geometry .optimize ();
|
|
74
|
+
|
|
75
|
+
geometry ._texCoord .getValue () .setup ();
|
|
76
|
+
geometry ._coord .getValue () .setup ();
|
|
77
|
+
geometry .setup ();
|
|
78
|
+
|
|
79
|
+
return geometry;
|
|
80
|
+
},
|
|
81
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const X3D = require ("../../X3D");
|
|
2
|
+
|
|
3
|
+
Object .assign (X3D .ElevationGrid .prototype,
|
|
4
|
+
{
|
|
5
|
+
toPrimitive (executionContext = this .getExecutionContext ())
|
|
6
|
+
{
|
|
7
|
+
const geometry = this .toIndexedFaceSet (executionContext,
|
|
8
|
+
{
|
|
9
|
+
fogCoord: !!this ._fogCoord .getValue (),
|
|
10
|
+
color: !!this ._color .getValue (),
|
|
11
|
+
texCoord: true,
|
|
12
|
+
tangent: !!this ._tangent .getValue (),
|
|
13
|
+
normal: !!this ._normal .getValue (),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
geometry ._metadata = this ._metadata;
|
|
17
|
+
geometry ._solid = this ._solid;
|
|
18
|
+
geometry ._ccw = this ._ccw;
|
|
19
|
+
geometry ._creaseAngle = this ._creaseAngle;
|
|
20
|
+
|
|
21
|
+
return geometry;
|
|
22
|
+
},
|
|
23
|
+
});
|
|
@@ -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
|
+
});
|