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.
- package/package.json +3 -3
- package/src/Application/Application.js +17 -5
- package/src/Application/Dashboard.js +5 -2
- package/src/Application/Document.js +1 -9
- package/src/Application/Tabs.js +2 -1
- 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/Library.js +2 -0
- package/src/Editors/LibraryPane.js +6 -1
- package/src/Editors/NodesLibrary.js +41 -1
- package/src/Editors/OutlineEditor.js +118 -25
- package/src/Editors/OutlineView.js +53 -22
- package/src/Editors/PrimitivesLibrary.js +58 -2
- package/src/Tools/Geometry2D/Disk2DTool.js +16 -18
- package/src/Undo/Editor.js +207 -153
|
@@ -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");
|
package/src/Editors/Library.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
module .exports = class
|
|
3
|
+
module .exports = class LibraryPane
|
|
4
4
|
{
|
|
5
5
|
#library;
|
|
6
6
|
|
|
@@ -9,6 +9,11 @@ module .exports = class LibraryPanel
|
|
|
9
9
|
this .#library = library;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
get config ()
|
|
13
|
+
{
|
|
14
|
+
return this .#library .config;
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
get browser ()
|
|
13
18
|
{
|
|
14
19
|
return this .#library .browser;
|
|
@@ -17,6 +17,14 @@ module .exports = class NodesLibrary extends LibraryPane
|
|
|
17
17
|
|
|
18
18
|
open ()
|
|
19
19
|
{
|
|
20
|
+
// Set default config values.
|
|
21
|
+
|
|
22
|
+
this .config .global .setDefaultValues ({
|
|
23
|
+
recentNodes: [ ],
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Clear output.
|
|
27
|
+
|
|
20
28
|
this .#list ?.remove ();
|
|
21
29
|
this .#list = undefined;
|
|
22
30
|
}
|
|
@@ -48,7 +56,32 @@ module .exports = class NodesLibrary extends LibraryPane
|
|
|
48
56
|
.sort ((a, b) => a .typeName .localeCompare (b .typeName))
|
|
49
57
|
.sort ((a, b) => a .componentInfo .name .localeCompare (b .componentInfo .name));
|
|
50
58
|
|
|
51
|
-
//
|
|
59
|
+
// Get recently used elements.
|
|
60
|
+
|
|
61
|
+
const recentNodes = this .config .global .recentNodes .map (typeName => this .browser .getConcreteNode (typeName));
|
|
62
|
+
|
|
63
|
+
// Create list for recently used elements.
|
|
64
|
+
|
|
65
|
+
if (recentNodes .length)
|
|
66
|
+
{
|
|
67
|
+
$("<li></li>")
|
|
68
|
+
.addClass ("component")
|
|
69
|
+
.attr ("name", "recent")
|
|
70
|
+
.text ("Recently Used Nodes")
|
|
71
|
+
.appendTo (this .#list);
|
|
72
|
+
|
|
73
|
+
for (const node of recentNodes)
|
|
74
|
+
{
|
|
75
|
+
$("<li></li>")
|
|
76
|
+
.addClass ("node")
|
|
77
|
+
.text (node .typeName)
|
|
78
|
+
.attr ("componentName", node .componentInfo .name)
|
|
79
|
+
.appendTo (this .#list)
|
|
80
|
+
.on ("dblclick", () => this .createNode (node .typeName, node .componentInfo .name));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Create list for proto elements.
|
|
52
85
|
|
|
53
86
|
if (protos .length)
|
|
54
87
|
{
|
|
@@ -129,6 +162,13 @@ module .exports = class NodesLibrary extends LibraryPane
|
|
|
129
162
|
|
|
130
163
|
async createNode (typeName, componentName)
|
|
131
164
|
{
|
|
165
|
+
const recentNodes = this .config .global .recentNodes .filter (name => name !== typeName);
|
|
166
|
+
|
|
167
|
+
recentNodes .unshift (typeName);
|
|
168
|
+
recentNodes .splice (10);
|
|
169
|
+
|
|
170
|
+
this .config .global .recentNodes = recentNodes;
|
|
171
|
+
|
|
132
172
|
UndoManager .shared .beginUndo (_("Create Node %s"), typeName);
|
|
133
173
|
|
|
134
174
|
await Editor .addComponent (this .executionContext, componentName);
|
|
@@ -248,7 +248,11 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
248
248
|
args: ["addUserDefinedField", element .attr ("id"), executionContext .getId (), node .getId ()],
|
|
249
249
|
},
|
|
250
250
|
{ type: "separator" },
|
|
251
|
-
|
|
251
|
+
];
|
|
252
|
+
|
|
253
|
+
if (node .getType () .includes (X3D .X3DConstants .X3DChildNode))
|
|
254
|
+
{
|
|
255
|
+
menu .push ({
|
|
252
256
|
label: _("Add Parent Group"),
|
|
253
257
|
submenu: [
|
|
254
258
|
{
|
|
@@ -358,8 +362,8 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
358
362
|
enabled: parentNodeElement .hasClass ("node"),
|
|
359
363
|
args: ["removeParent", element .attr ("id"), executionContext .getId (), node .getId ()],
|
|
360
364
|
},
|
|
361
|
-
{ type: "separator" }
|
|
362
|
-
|
|
365
|
+
{ type: "separator" });
|
|
366
|
+
}
|
|
363
367
|
|
|
364
368
|
for (const type of node .getType () .toReversed ())
|
|
365
369
|
{
|
|
@@ -386,6 +390,19 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
386
390
|
|
|
387
391
|
continue;
|
|
388
392
|
}
|
|
393
|
+
case X3D .X3DConstants .X3DGeometryNode:
|
|
394
|
+
{
|
|
395
|
+
if (!node .toPrimitive)
|
|
396
|
+
continue;
|
|
397
|
+
|
|
398
|
+
menu .push (
|
|
399
|
+
{
|
|
400
|
+
label: _("Convert Node to Next Lower Geometry Type"),
|
|
401
|
+
args: ["toPrimitive", element .attr ("id"), executionContext .getId (), node .getId ()],
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
389
406
|
case X3D .X3DConstants .ImageTexture:
|
|
390
407
|
{
|
|
391
408
|
if (node .checkLoadState () === X3D .X3DConstants .COMPLETE_STATE)
|
|
@@ -432,6 +449,11 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
432
449
|
}
|
|
433
450
|
case X3D .X3DConstants .X3DPrototypeInstance:
|
|
434
451
|
{
|
|
452
|
+
menu .push ({
|
|
453
|
+
label: _("Unwrap Inner Node"),
|
|
454
|
+
args: ["unwrapInnerNode", element .attr ("id"), executionContext .getId (), node .getId ()],
|
|
455
|
+
});
|
|
456
|
+
|
|
435
457
|
if (!$.try (() => node .getInnerNode () .getType () .includes (X3D .X3DConstants .X3DChildNode)))
|
|
436
458
|
continue;
|
|
437
459
|
|
|
@@ -1051,6 +1073,9 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
1051
1073
|
}
|
|
1052
1074
|
|
|
1053
1075
|
UndoManager .shared .endUndo ();
|
|
1076
|
+
|
|
1077
|
+
if (element .hasClass ("selected"))
|
|
1078
|
+
require ("../Application/Selection") .add (primitive);
|
|
1054
1079
|
}
|
|
1055
1080
|
|
|
1056
1081
|
async addParentGroup (id, executionContextId, nodeId, component, typeName, fieldName)
|
|
@@ -1682,39 +1707,29 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
1682
1707
|
case X3D .X3DConstants .IndexedFaceSet:
|
|
1683
1708
|
{
|
|
1684
1709
|
const
|
|
1685
|
-
polygons = node .triangulate (),
|
|
1686
1710
|
coordIndex = node ._coordIndex,
|
|
1687
1711
|
normalPerVertex = node ._normalPerVertex .getValue (),
|
|
1712
|
+
polygons = node .triangulate (),
|
|
1688
1713
|
normals = node .createNormals (polygons),
|
|
1689
|
-
normalIndex = new X3D .MFInt32 (),
|
|
1690
1714
|
normalNode = executionContext .createNode ("Normal") .getValue (),
|
|
1691
1715
|
vector = normalNode ._vector;
|
|
1692
1716
|
|
|
1693
1717
|
if (normalPerVertex)
|
|
1694
1718
|
{
|
|
1695
|
-
for (
|
|
1719
|
+
for (const [i, index] of coordIndex .entries ())
|
|
1696
1720
|
{
|
|
1697
|
-
const index = coordIndex [i];
|
|
1698
|
-
|
|
1699
1721
|
if (index < 0)
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
else
|
|
1704
|
-
{
|
|
1705
|
-
normalIndex .push (vector .length);
|
|
1706
|
-
vector .push (normals [i]);
|
|
1707
|
-
}
|
|
1722
|
+
continue;
|
|
1723
|
+
|
|
1724
|
+
vector [index] = normals [i];
|
|
1708
1725
|
}
|
|
1709
1726
|
}
|
|
1710
1727
|
else
|
|
1711
1728
|
{
|
|
1712
1729
|
let face = 0;
|
|
1713
1730
|
|
|
1714
|
-
for (
|
|
1731
|
+
for (const [i, index] of coordIndex .entries ())
|
|
1715
1732
|
{
|
|
1716
|
-
const index = coordIndex [i];
|
|
1717
|
-
|
|
1718
1733
|
if (index < 0)
|
|
1719
1734
|
{
|
|
1720
1735
|
vector .length = ++ face;
|
|
@@ -1726,8 +1741,7 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
1726
1741
|
}
|
|
1727
1742
|
}
|
|
1728
1743
|
|
|
1729
|
-
Editor .setFieldValue (executionContext, node, node .
|
|
1730
|
-
Editor .setFieldValue (executionContext, node, node ._normal, normalNode);
|
|
1744
|
+
Editor .setFieldValue (executionContext, node, node ._normal, normalNode);
|
|
1731
1745
|
break;
|
|
1732
1746
|
}
|
|
1733
1747
|
case X3D .X3DConstants .X3DComposedGeometryNode:
|
|
@@ -1809,6 +1823,85 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
1809
1823
|
UndoManager .shared .endUndo ();
|
|
1810
1824
|
}
|
|
1811
1825
|
|
|
1826
|
+
toPrimitive (id, executionContextId, nodeId)
|
|
1827
|
+
{
|
|
1828
|
+
const
|
|
1829
|
+
element = $(`#${id}`),
|
|
1830
|
+
executionContext = this .objects .get (executionContextId),
|
|
1831
|
+
parentFieldElement = element .closest (".field, .scene", this .sceneGraph),
|
|
1832
|
+
parentNodeElement = parentFieldElement .closest (".node, .proto, .scene", this .sceneGraph),
|
|
1833
|
+
parentNode = this .getNode (parentNodeElement),
|
|
1834
|
+
parentField = parentFieldElement .hasClass ("scene") ? parentNode .rootNodes : this .getField (parentFieldElement),
|
|
1835
|
+
node = this .objects .get (nodeId),
|
|
1836
|
+
primitive = node .toPrimitive (executionContext),
|
|
1837
|
+
index = parseInt (element .attr ("index"));
|
|
1838
|
+
|
|
1839
|
+
UndoManager .shared .beginUndo (_("Convert Node to Next Lower Primitive"));
|
|
1840
|
+
|
|
1841
|
+
if (node .getName ())
|
|
1842
|
+
Editor .updateNamedNode (executionContext, executionContext .getUniqueName (node .getName ()), primitive);
|
|
1843
|
+
|
|
1844
|
+
switch (parentField .getType ())
|
|
1845
|
+
{
|
|
1846
|
+
case X3D .X3DConstants .SFNode:
|
|
1847
|
+
{
|
|
1848
|
+
Editor .setFieldValue (executionContext, parentNode, parentField, primitive);
|
|
1849
|
+
break;
|
|
1850
|
+
}
|
|
1851
|
+
case X3D .X3DConstants .MFNode:
|
|
1852
|
+
{
|
|
1853
|
+
Editor .removeValueFromArray (executionContext, parentNode, parentField, index);
|
|
1854
|
+
Editor .insertValueIntoArray (executionContext, parentNode, parentField, index, primitive);
|
|
1855
|
+
break;
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
UndoManager .shared .endUndo ();
|
|
1860
|
+
|
|
1861
|
+
if (element .hasClass ("selected"))
|
|
1862
|
+
require ("../Application/Selection") .add (primitive);
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
async unwrapInnerNode (id, executionContextId, nodeId)
|
|
1866
|
+
{
|
|
1867
|
+
const
|
|
1868
|
+
element = $(`#${id}`),
|
|
1869
|
+
executionContext = this .objects .get (executionContextId),
|
|
1870
|
+
parentFieldElement = element .closest (".field, .scene", this .sceneGraph),
|
|
1871
|
+
parentNodeElement = parentFieldElement .closest (".node, .proto, .scene", this .sceneGraph),
|
|
1872
|
+
parentNode = this .getNode (parentNodeElement),
|
|
1873
|
+
parentField = parentFieldElement .hasClass ("scene") ? parentNode .rootNodes : this .getField (parentFieldElement),
|
|
1874
|
+
node = this .objects .get (nodeId),
|
|
1875
|
+
x3dSyntax = await Editor .exportX3D (this .executionContext, [node]),
|
|
1876
|
+
importedNodes = await Editor .importX3D (this .executionContext, x3dSyntax),
|
|
1877
|
+
innerNode = importedNodes [0],
|
|
1878
|
+
index = parseInt (element .attr ("index"));
|
|
1879
|
+
|
|
1880
|
+
this .executionContext .rootNodes .length -= importedNodes .length;
|
|
1881
|
+
|
|
1882
|
+
UndoManager .shared .beginUndo (_("Convert Node to Next Lower Primitive"));
|
|
1883
|
+
|
|
1884
|
+
switch (parentField .getType ())
|
|
1885
|
+
{
|
|
1886
|
+
case X3D .X3DConstants .SFNode:
|
|
1887
|
+
{
|
|
1888
|
+
Editor .setFieldValue (executionContext, parentNode, parentField, innerNode);
|
|
1889
|
+
break;
|
|
1890
|
+
}
|
|
1891
|
+
case X3D .X3DConstants .MFNode:
|
|
1892
|
+
{
|
|
1893
|
+
Editor .removeValueFromArray (executionContext, parentNode, parentField, index);
|
|
1894
|
+
Editor .insertValueIntoArray (executionContext, parentNode, parentField, index, innerNode);
|
|
1895
|
+
break;
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
UndoManager .shared .endUndo ();
|
|
1900
|
+
|
|
1901
|
+
if (element .hasClass ("selected"))
|
|
1902
|
+
require ("../Application/Selection") .add (innerNode);
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1812
1905
|
addPrototype (id, executionContextId)
|
|
1813
1906
|
{
|
|
1814
1907
|
require ("../Controls/AddPrototypePopover");
|
|
@@ -1909,7 +2002,7 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
1909
2002
|
|
|
1910
2003
|
const
|
|
1911
2004
|
target = $(event .target),
|
|
1912
|
-
element = target .closest (".node, .exported-node", this .sceneGraph),
|
|
2005
|
+
element = target .closest (".node, .imported-node, .exported-node", this .sceneGraph),
|
|
1913
2006
|
layerNode = this .getNode (element),
|
|
1914
2007
|
layerSet = this .browser .getWorld () .getLayerSet (),
|
|
1915
2008
|
index = layerSet ._layers .findIndex (node => node ?.getValue () .valueOf () === layerNode);
|
|
@@ -1927,7 +2020,7 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
1927
2020
|
{
|
|
1928
2021
|
const
|
|
1929
2022
|
target = $(event .target),
|
|
1930
|
-
element = target .closest (".node, .exported-node", this .sceneGraph),
|
|
2023
|
+
element = target .closest (".node, .imported-node, .exported-node", this .sceneGraph),
|
|
1931
2024
|
node = this .getNode (element);
|
|
1932
2025
|
|
|
1933
2026
|
event .preventDefault ();
|
|
@@ -1952,7 +2045,7 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
1952
2045
|
{
|
|
1953
2046
|
const
|
|
1954
2047
|
target = $(event .target),
|
|
1955
|
-
element = target .closest (".node, .exported-node", this .sceneGraph),
|
|
2048
|
+
element = target .closest (".node, .imported-node, .exported-node", this .sceneGraph),
|
|
1956
2049
|
node = this .getNode (element);
|
|
1957
2050
|
|
|
1958
2051
|
event .preventDefault ();
|
|
@@ -1965,7 +2058,7 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
1965
2058
|
{
|
|
1966
2059
|
const
|
|
1967
2060
|
target = $(event .target),
|
|
1968
|
-
element = target .closest (".node, .exported-node", this .sceneGraph),
|
|
2061
|
+
element = target .closest (".node, .imported-node, .exported-node", this .sceneGraph),
|
|
1969
2062
|
node = this .getNode (element);
|
|
1970
2063
|
|
|
1971
2064
|
event .preventDefault ();
|