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
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
const X3D = require ("../../X3D");
|
|
2
|
+
|
|
3
|
+
Object .assign (X3D .X3DGeometryNode .prototype,
|
|
4
|
+
{
|
|
5
|
+
toIndexedLineSet (executionContext = this .getExecutionContext (), options = { })
|
|
6
|
+
{
|
|
7
|
+
const geometry = executionContext .createNode ("IndexedLineSet", false);
|
|
8
|
+
|
|
9
|
+
// Coordinate
|
|
10
|
+
|
|
11
|
+
const
|
|
12
|
+
vertexArray = this .getVertices (),
|
|
13
|
+
numVertices = vertexArray .length;
|
|
14
|
+
|
|
15
|
+
geometry ._coord = executionContext .createNode (options .double ? "CoordinateDouble" : "Coordinate", false);
|
|
16
|
+
|
|
17
|
+
if (numVertices)
|
|
18
|
+
{
|
|
19
|
+
if (options .polyline)
|
|
20
|
+
{
|
|
21
|
+
const
|
|
22
|
+
SFVec3 = options .double ? X3D .SFVec3d : X3D .SFVec3f,
|
|
23
|
+
first = new SFVec3 (vertexArray .at (0), vertexArray .at (1), 0),
|
|
24
|
+
last = new SFVec3 (vertexArray .at (-4), vertexArray .at (-3), 0);
|
|
25
|
+
|
|
26
|
+
for (let i = 0, length = numVertices / 8; i < length; ++ i)
|
|
27
|
+
geometry ._coordIndex .push (i);
|
|
28
|
+
|
|
29
|
+
if (last .equals (first))
|
|
30
|
+
geometry ._coordIndex .push (0, -1);
|
|
31
|
+
else
|
|
32
|
+
geometry ._coordIndex .push (geometry ._coordIndex .at (-1) + 1, -1);
|
|
33
|
+
|
|
34
|
+
for (let i = 0; i < numVertices; i += 8)
|
|
35
|
+
geometry ._coord .point .push (new SFVec3 (vertexArray [i], vertexArray [i + 1], 0));
|
|
36
|
+
|
|
37
|
+
if (!last .equals (first))
|
|
38
|
+
geometry ._coord .point .push (last);
|
|
39
|
+
}
|
|
40
|
+
else
|
|
41
|
+
{
|
|
42
|
+
const [coordIndex, points] = this .mergePoints (vertexArray);
|
|
43
|
+
|
|
44
|
+
geometry ._coordIndex = coordIndex .flatMap ((index, i) => i % 2 === 1 ? [index, -1] : index);
|
|
45
|
+
geometry ._coord .point = points .filter ((point, i) => i % 4 < 3);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Setup
|
|
50
|
+
|
|
51
|
+
geometry ._coord .getValue () ?.setup ();
|
|
52
|
+
geometry .setup ();
|
|
53
|
+
|
|
54
|
+
return geometry;
|
|
55
|
+
},
|
|
56
|
+
toIndexedFaceSet (executionContext = this .getExecutionContext (), options = { })
|
|
57
|
+
{
|
|
58
|
+
const geometry = executionContext .createNode ("IndexedFaceSet", false);
|
|
59
|
+
|
|
60
|
+
// Coordinate
|
|
61
|
+
|
|
62
|
+
const [coordIndex, points] = this .mergePoints (this .getVertices ());
|
|
63
|
+
|
|
64
|
+
geometry ._coordIndex = coordIndex .flatMap ((index, i) => i % 3 === 2 ? [index, -1] : index);
|
|
65
|
+
geometry ._coord = executionContext .createNode (options .double ? "CoordinateDouble" : "Coordinate", false);
|
|
66
|
+
geometry ._coord .point = points .filter ((p, i) => i % 4 < 3);
|
|
67
|
+
|
|
68
|
+
// Tangent
|
|
69
|
+
|
|
70
|
+
if (options .fogCoord)
|
|
71
|
+
{
|
|
72
|
+
geometry ._fogCoord = executionContext .createNode ("FogCoordinate", false);
|
|
73
|
+
geometry ._fogCoord .depth = this .getFogDepths ();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Color
|
|
77
|
+
|
|
78
|
+
if (options .color)
|
|
79
|
+
{
|
|
80
|
+
const [colorIndex, colors] = this .mergePoints (this .getColors ());
|
|
81
|
+
|
|
82
|
+
geometry ._colorIndex = colorIndex .flatMap ((index, i) => i % 3 === 2 ? [index, -1] : index);
|
|
83
|
+
|
|
84
|
+
if (geometry ._colorIndex .equals (geometry ._coordIndex))
|
|
85
|
+
geometry ._colorIndex = [ ];
|
|
86
|
+
|
|
87
|
+
if (colors .some ((p, i)=> i === 3 && p !== 1))
|
|
88
|
+
{
|
|
89
|
+
geometry ._color = executionContext .createNode ("ColorRGBA", false);
|
|
90
|
+
geometry ._color .color = colors;
|
|
91
|
+
}
|
|
92
|
+
else
|
|
93
|
+
{
|
|
94
|
+
geometry ._color = executionContext .createNode ("Color", false);
|
|
95
|
+
geometry ._color .color = colors .filter ((p, i) => i % 4 < 3);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// TextureCoordinate
|
|
100
|
+
|
|
101
|
+
if (options .texCoord)
|
|
102
|
+
{
|
|
103
|
+
const [texCoordIndex, texCoords] = this .mergePoints (this .getTexCoords ());
|
|
104
|
+
|
|
105
|
+
geometry ._texCoordIndex = texCoordIndex .flatMap ((index, i) => i % 3 === 2 ? [index, -1] : index);
|
|
106
|
+
|
|
107
|
+
if (geometry ._texCoordIndex .equals (geometry ._coordIndex))
|
|
108
|
+
geometry ._texCoordIndex = [ ];
|
|
109
|
+
|
|
110
|
+
if (texCoords .some ((p, i)=> (i === 2 && p !== 0) || (i === 3 && p !== 1)))
|
|
111
|
+
{
|
|
112
|
+
geometry ._texCoord = executionContext .createNode ("TextureCoordinate3D", false);
|
|
113
|
+
geometry ._texCoord .point = texCoords;
|
|
114
|
+
}
|
|
115
|
+
else
|
|
116
|
+
{
|
|
117
|
+
geometry ._texCoord = executionContext .createNode ("TextureCoordinate", false);
|
|
118
|
+
geometry ._texCoord .point = texCoords .filter ((p, i) => i % 4 < 2);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Tangent
|
|
123
|
+
|
|
124
|
+
if (options .tangent)
|
|
125
|
+
{
|
|
126
|
+
// TODO: Implement Tangent
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Normal
|
|
130
|
+
|
|
131
|
+
if (options .normal)
|
|
132
|
+
{
|
|
133
|
+
const [normalIndex, normals] = this .mergePoints (this .getNormals ());
|
|
134
|
+
|
|
135
|
+
geometry ._normalIndex = normalIndex .flatMap ((index, i) => i % 3 === 2 ? [index, -1] : index);
|
|
136
|
+
geometry ._normal = executionContext .createNode ("Normal", false);
|
|
137
|
+
geometry ._normal .point = normals;
|
|
138
|
+
|
|
139
|
+
if (geometry ._normalIndex .equals (geometry ._coordIndex))
|
|
140
|
+
geometry ._normalIndex = [ ];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Setup
|
|
144
|
+
|
|
145
|
+
geometry ._fogCoord .getValue () ?.setup ();
|
|
146
|
+
geometry ._color .getValue () ?.setup ();
|
|
147
|
+
geometry ._texCoord .getValue () ?.setup ();
|
|
148
|
+
geometry ._tangent .getValue () ?.setup ();
|
|
149
|
+
geometry ._normal .getValue () ?.setup ();
|
|
150
|
+
geometry ._coord .getValue () ?.setup ();
|
|
151
|
+
geometry .setup ();
|
|
152
|
+
|
|
153
|
+
return geometry;
|
|
154
|
+
},
|
|
155
|
+
mergePoints (array)
|
|
156
|
+
{
|
|
157
|
+
const
|
|
158
|
+
index = [ ],
|
|
159
|
+
points = [ ],
|
|
160
|
+
map = new Map (),
|
|
161
|
+
length = array .length;
|
|
162
|
+
|
|
163
|
+
for (let i = 0; i < length; i += 4)
|
|
164
|
+
{
|
|
165
|
+
const key = `${array [i]} ${array [i + 1]} ${array [i + 2]} ${array [i + 3]}`;
|
|
166
|
+
|
|
167
|
+
if (map .has (key))
|
|
168
|
+
{
|
|
169
|
+
index .push (map .get (key));
|
|
170
|
+
}
|
|
171
|
+
else
|
|
172
|
+
{
|
|
173
|
+
const next = points .length / 4;
|
|
174
|
+
|
|
175
|
+
map .set (key, next);
|
|
176
|
+
index .push (next);
|
|
177
|
+
points .push (array [i], array [i + 1], array [i + 2], array [i + 3]);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return [index, points];
|
|
182
|
+
},
|
|
183
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const X3D = require ("../../X3D");
|
|
2
|
+
|
|
3
|
+
Object .assign (X3D .Text .prototype,
|
|
4
|
+
{
|
|
5
|
+
toPrimitive (executionContext = this .getExecutionContext ())
|
|
6
|
+
{
|
|
7
|
+
const geometry = this .toIndexedFaceSet (executionContext,
|
|
8
|
+
{
|
|
9
|
+
texCoord: true,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
geometry ._metadata = this ._metadata;
|
|
13
|
+
geometry ._solid = this ._solid;
|
|
14
|
+
|
|
15
|
+
return geometry;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Geometry2D
|
|
2
|
+
require ("./Components/Geometry2D/Arc2D");
|
|
3
|
+
require ("./Components/Geometry2D/ArcClose2D");
|
|
4
|
+
require ("./Components/Geometry2D/Circle2D");
|
|
5
|
+
require ("./Components/Geometry2D/Disk2D");
|
|
6
|
+
require ("./Components/Geometry2D/Polyline2D");
|
|
7
|
+
require ("./Components/Geometry2D/Polypoint2D");
|
|
8
|
+
require ("./Components/Geometry2D/Rectangle2D");
|
|
9
|
+
require ("./Components/Geometry2D/TriangleSet2D");
|
|
10
|
+
|
|
11
|
+
// Geometry3D
|
|
12
|
+
require ("./Components/Geometry3D/Box");
|
|
13
|
+
require ("./Components/Geometry3D/Cone");
|
|
14
|
+
require ("./Components/Geometry3D/Cylinder");
|
|
15
|
+
require ("./Components/Geometry3D/ElevationGrid");
|
|
16
|
+
require ("./Components/Geometry3D/Extrusion");
|
|
17
|
+
require ("./Components/Geometry3D/IndexedFaceSet");
|
|
18
|
+
require ("./Components/Geometry3D/Sphere");
|
|
19
|
+
|
|
20
|
+
// NURBS
|
|
21
|
+
require ("./Components/NURBS/NurbsCurve");
|
|
22
|
+
require ("./Components/NURBS/NurbsSweptSurface");
|
|
23
|
+
require ("./Components/NURBS/NurbsSwungSurface");
|
|
24
|
+
require ("./Components/NURBS/X3DNurbsSurfaceGeometryNode");
|
|
25
|
+
|
|
26
|
+
// Rendering
|
|
27
|
+
require ("./Components/Rendering/IndexedLineSet");
|
|
28
|
+
require ("./Components/Rendering/LineSet");
|
|
29
|
+
require ("./Components/Rendering/X3DComposedGeometryNode");
|
|
30
|
+
require ("./Components/Rendering/X3DGeometryNode");
|
|
31
|
+
|
|
32
|
+
// Text
|
|
33
|
+
require ("./Components/Text/Text");
|