sunrize 1.7.4 → 1.7.5
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 +8 -5
- package/src/Bits/X3DUOM.js +4 -3
- package/src/Editors/BrowserFrame.js +1 -0
- package/src/Editors/Library.js +91 -267
- package/src/Editors/LibraryPane.js +53 -0
- package/src/Editors/Materials.x3d +6582 -0
- package/src/Editors/MaterialsLibrary.js +96 -0
- package/src/Editors/NodesLibrary.js +182 -0
- package/src/Editors/OutlineEditor.js +24 -13
- package/src/Editors/OutlineView.js +9 -3
- package/src/Editors/Panel.js +22 -20
- package/src/Editors/Primitives.js +2 -2
- package/src/Editors/PrimitivesLibrary.js +60 -0
- package/src/Editors/ScriptEditor.js +1 -1
- package/src/Tools/Core/X3DNodeTool.js +1 -1
- package/src/Tools/Grouping/X3DTransformNodeTool.x3d +1 -1
- package/src/Undo/Editor.js +1 -18
- package/src/X3D.js +13 -1
- package/src/assets/X3DUOM.xml +43120 -0
- package/src/assets/themes/default-template.css +10 -1
- package/src/assets/themes/default.css +10 -1
- package/src/assets/x3duom-x_ite.xml +0 -1011
- package/src/assets/x3duom.xml +0 -43120
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const
|
|
4
|
+
$ = require ("jquery"),
|
|
5
|
+
X3D = require ("../X3D"),
|
|
6
|
+
LibraryPane = require ("./LibraryPane");
|
|
7
|
+
|
|
8
|
+
module .exports = class Materials extends LibraryPane
|
|
9
|
+
{
|
|
10
|
+
id = "MATERIALS";
|
|
11
|
+
description = "Materials";
|
|
12
|
+
|
|
13
|
+
#canvas;
|
|
14
|
+
#browser;
|
|
15
|
+
#scene;
|
|
16
|
+
#list;
|
|
17
|
+
|
|
18
|
+
async update ()
|
|
19
|
+
{
|
|
20
|
+
// Fill output.
|
|
21
|
+
|
|
22
|
+
if (this .#list)
|
|
23
|
+
{
|
|
24
|
+
this .output .append (this .#list);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Create list.
|
|
29
|
+
|
|
30
|
+
this .#list = $("<ul></ul>")
|
|
31
|
+
.appendTo (this .output)
|
|
32
|
+
.addClass ("library-list");
|
|
33
|
+
|
|
34
|
+
this .#canvas ??= $("<x3d-canvas preserveDrawingBuffer='true''></x3d-canvas>");
|
|
35
|
+
this .#browser ??= this .#canvas .prop ("browser");
|
|
36
|
+
this .#scene ??= await this .#browser .createX3DFromURL (new X3D .MFString (`file://${__dirname}/Materials.x3d`));
|
|
37
|
+
|
|
38
|
+
const
|
|
39
|
+
materials = this .#scene .getExportedNode ("Materials"),
|
|
40
|
+
viewpoint = this .#scene .getExportedNode ("Viewpoint"),
|
|
41
|
+
nodes = [ ];
|
|
42
|
+
|
|
43
|
+
for (const [g, group] of materials .children .entries ())
|
|
44
|
+
{
|
|
45
|
+
$("<li></li>")
|
|
46
|
+
.addClass ("component")
|
|
47
|
+
.text (group .getNodeName ())
|
|
48
|
+
.appendTo (this .#list);
|
|
49
|
+
|
|
50
|
+
for (const [c, node] of group .children .entries ())
|
|
51
|
+
{
|
|
52
|
+
const material = node .children [0] .appearance .material;
|
|
53
|
+
|
|
54
|
+
nodes .push ($("<li></li>")
|
|
55
|
+
.addClass (["node", "icon"])
|
|
56
|
+
.text (`${group .getNodeName ()} ${c + 1}`)
|
|
57
|
+
.attr ("group", g)
|
|
58
|
+
.attr ("child", c)
|
|
59
|
+
.appendTo (this .#list)
|
|
60
|
+
.on ("dblclick", () => this .importX3D (material .getNodeName (), material .toXMLString ())));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Create icons.
|
|
65
|
+
|
|
66
|
+
this .#canvas
|
|
67
|
+
.css ({ "position": "absolute", "visibility": "hidden" })
|
|
68
|
+
.prependTo (this .element);
|
|
69
|
+
|
|
70
|
+
await this .#browser .resize (25, 25);
|
|
71
|
+
await this .#browser .replaceWorld (this .#scene);
|
|
72
|
+
|
|
73
|
+
for (const element of Array .from (this .output .find (".node"), e => $(e)))
|
|
74
|
+
{
|
|
75
|
+
const
|
|
76
|
+
group = element .attr ("group"),
|
|
77
|
+
child = element .attr ("child"),
|
|
78
|
+
section = materials .children [group],
|
|
79
|
+
node = section .children [child];
|
|
80
|
+
|
|
81
|
+
materials .whichChoice = group;
|
|
82
|
+
section .whichChoice = child;
|
|
83
|
+
|
|
84
|
+
viewpoint .position .x = node .translation .x;
|
|
85
|
+
viewpoint .position .y = node .translation .y;
|
|
86
|
+
viewpoint .position .z = 2.65;
|
|
87
|
+
|
|
88
|
+
await this .#browser .nextFrame ();
|
|
89
|
+
|
|
90
|
+
element .css ("background-image", `url(${this .#canvas [0] .toDataURL ()})`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
this .#browser .dispose ();
|
|
94
|
+
this .#canvas .remove ();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const
|
|
4
|
+
$ = require ("jquery"),
|
|
5
|
+
X3D = require ("../X3D"),
|
|
6
|
+
LibraryPane = require ("./LibraryPane"),
|
|
7
|
+
Editor = require ("../Undo/Editor"),
|
|
8
|
+
UndoManager = require ("../Undo/UndoManager"),
|
|
9
|
+
_ = require ("../Application/GetText");
|
|
10
|
+
|
|
11
|
+
module .exports = class NodesLibrary extends LibraryPane
|
|
12
|
+
{
|
|
13
|
+
id = "NODES";
|
|
14
|
+
description = "Nodes";
|
|
15
|
+
|
|
16
|
+
#list;
|
|
17
|
+
|
|
18
|
+
open ()
|
|
19
|
+
{
|
|
20
|
+
this .#list ?.remove ();
|
|
21
|
+
this .#list = undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
update ()
|
|
25
|
+
{
|
|
26
|
+
// Fill output.
|
|
27
|
+
|
|
28
|
+
if (this .#list)
|
|
29
|
+
{
|
|
30
|
+
this .output .append (this .#list);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Create list.
|
|
35
|
+
|
|
36
|
+
this .#list = $("<ul></ul>")
|
|
37
|
+
.appendTo (this .output)
|
|
38
|
+
.addClass ("library-list");
|
|
39
|
+
|
|
40
|
+
// Get protos.
|
|
41
|
+
|
|
42
|
+
const protos = Array .from (this .getProtos () .values ())
|
|
43
|
+
.sort ((a, b) => a .name .localeCompare (b .name));
|
|
44
|
+
|
|
45
|
+
// Get supported nodes.
|
|
46
|
+
|
|
47
|
+
const nodes = [... this .browser .getConcreteNodes ()]
|
|
48
|
+
.sort ((a, b) => a .typeName .localeCompare (b .typeName))
|
|
49
|
+
.sort ((a, b) => a .componentInfo .name .localeCompare (b .componentInfo .name));
|
|
50
|
+
|
|
51
|
+
// Create list for proto elements
|
|
52
|
+
|
|
53
|
+
if (protos .length)
|
|
54
|
+
{
|
|
55
|
+
$("<li></li>")
|
|
56
|
+
.addClass ("component")
|
|
57
|
+
.attr ("name", "prototypes")
|
|
58
|
+
.text ("Prototypes")
|
|
59
|
+
.appendTo (this .#list);
|
|
60
|
+
|
|
61
|
+
for (const proto of protos)
|
|
62
|
+
{
|
|
63
|
+
$("<li></li>")
|
|
64
|
+
.addClass ("node")
|
|
65
|
+
.text (proto .name)
|
|
66
|
+
.appendTo (this .#list)
|
|
67
|
+
.on ("dblclick", () => this .createProto (proto));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Create list for nodes elements.
|
|
72
|
+
|
|
73
|
+
let componentName = "";
|
|
74
|
+
|
|
75
|
+
for (const node of nodes)
|
|
76
|
+
{
|
|
77
|
+
if (node .componentInfo .name !== componentName)
|
|
78
|
+
{
|
|
79
|
+
componentName = node .componentInfo .name;
|
|
80
|
+
|
|
81
|
+
$("<li></li>")
|
|
82
|
+
.addClass ("component")
|
|
83
|
+
.attr ("name", node .componentInfo .name)
|
|
84
|
+
.text (this .browser .getSupportedComponents () .get (node .componentInfo .name) .title)
|
|
85
|
+
.appendTo (this .#list);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
$("<li></li>")
|
|
89
|
+
.addClass ("node")
|
|
90
|
+
.text (node .typeName)
|
|
91
|
+
.attr ("componentName", node .componentInfo .name)
|
|
92
|
+
.appendTo (this .#list)
|
|
93
|
+
.on ("dblclick", () => this .createNode (node .typeName, node .componentInfo .name));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
getProtos (executionContext = this .executionContext, protos = new Map (), outerNode)
|
|
98
|
+
{
|
|
99
|
+
if (!executionContext)
|
|
100
|
+
return protos;
|
|
101
|
+
|
|
102
|
+
for (const proto of executionContext .protos)
|
|
103
|
+
{
|
|
104
|
+
if (proto === outerNode)
|
|
105
|
+
break;
|
|
106
|
+
|
|
107
|
+
if (protos .has (proto .name))
|
|
108
|
+
continue;
|
|
109
|
+
|
|
110
|
+
protos .set (proto .name, proto);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
for (const proto of executionContext .externprotos)
|
|
114
|
+
{
|
|
115
|
+
if (proto === outerNode)
|
|
116
|
+
break;
|
|
117
|
+
|
|
118
|
+
if (protos .has (proto .name))
|
|
119
|
+
continue;
|
|
120
|
+
|
|
121
|
+
protos .set (proto .name, proto);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (!(executionContext instanceof X3D .X3DScene))
|
|
125
|
+
this .getProtos (executionContext .getExecutionContext (), protos, executionContext .getOuterNode ());
|
|
126
|
+
|
|
127
|
+
return protos;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async createNode (typeName, componentName)
|
|
131
|
+
{
|
|
132
|
+
UndoManager .shared .beginUndo (_("Create Node %s"), typeName);
|
|
133
|
+
|
|
134
|
+
await Editor .addComponent (this .executionContext, componentName);
|
|
135
|
+
|
|
136
|
+
const node = this .executionContext .createNode (typeName);
|
|
137
|
+
|
|
138
|
+
this .addNode (node);
|
|
139
|
+
|
|
140
|
+
UndoManager .shared .endUndo ();
|
|
141
|
+
|
|
142
|
+
await this .expandToAndSelectNode (node .getValue ());
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async createProto (proto)
|
|
146
|
+
{
|
|
147
|
+
UndoManager .shared .beginUndo (_("Create Proto Instance %s"), proto .name);
|
|
148
|
+
|
|
149
|
+
const node = proto .createInstance (this .executionContext);
|
|
150
|
+
|
|
151
|
+
this .addNode (node);
|
|
152
|
+
|
|
153
|
+
UndoManager .shared .endUndo ();
|
|
154
|
+
|
|
155
|
+
await this .expandToAndSelectNode (node .getValue ());
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
addNode (node)
|
|
159
|
+
{
|
|
160
|
+
const field = this .field
|
|
161
|
+
?? $.try (() => this .node ?.getField (node .getValue () .getContainerField ()));
|
|
162
|
+
|
|
163
|
+
switch (field ?.getType ())
|
|
164
|
+
{
|
|
165
|
+
case X3D .X3DConstants .SFNode:
|
|
166
|
+
{
|
|
167
|
+
Editor .setFieldValue (this .executionContext, this .node, field, node);
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
case X3D .X3DConstants .MFNode:
|
|
171
|
+
{
|
|
172
|
+
Editor .insertValueIntoArray (this .executionContext, this .node, field, field .length, node);
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
default:
|
|
176
|
+
{
|
|
177
|
+
Editor .insertValueIntoArray (this .executionContext, this .executionContext, this .executionContext .rootNodes, this .executionContext .rootNodes .length, node);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
@@ -22,8 +22,9 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
22
22
|
element .on ("contextmenu", (event) => this .showContextMenu (event));
|
|
23
23
|
|
|
24
24
|
electron .ipcRenderer .on ("outline-editor", (event, key, ...args) => this [key] (...args));
|
|
25
|
-
|
|
26
|
-
electron .ipcRenderer .on ("
|
|
25
|
+
|
|
26
|
+
electron .ipcRenderer .on ("transform-to-zero", () => this .transformToZero ());
|
|
27
|
+
electron .ipcRenderer .on ("remove-empty-groups", () => this .removeEmptyGroups ());
|
|
27
28
|
|
|
28
29
|
this .setup ();
|
|
29
30
|
}
|
|
@@ -803,7 +804,7 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
803
804
|
UndoManager .shared .endUndo ();
|
|
804
805
|
}
|
|
805
806
|
|
|
806
|
-
copyNodes ()
|
|
807
|
+
copyNodes (deselect)
|
|
807
808
|
{
|
|
808
809
|
const
|
|
809
810
|
primary = $(".node.primary, .proto.primary, .externproto.primary"),
|
|
@@ -835,6 +836,9 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
835
836
|
navigator .clipboard .writeText (x3dSyntax);
|
|
836
837
|
|
|
837
838
|
undoManager .undo ();
|
|
839
|
+
|
|
840
|
+
if (deselect)
|
|
841
|
+
this .deselectAll ();
|
|
838
842
|
}
|
|
839
843
|
|
|
840
844
|
copyExternPrototype ()
|
|
@@ -926,11 +930,10 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
926
930
|
|
|
927
931
|
UndoManager .shared .endUndo ();
|
|
928
932
|
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
});
|
|
933
|
+
await this .browser .nextFrame ();
|
|
934
|
+
|
|
935
|
+
for (const node of nodes)
|
|
936
|
+
this .expandTo (node);
|
|
934
937
|
}
|
|
935
938
|
catch (error)
|
|
936
939
|
{
|
|
@@ -1135,7 +1138,9 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
1135
1138
|
|
|
1136
1139
|
UndoManager .shared .endUndo ();
|
|
1137
1140
|
|
|
1138
|
-
|
|
1141
|
+
await this .browser .nextFrame ();
|
|
1142
|
+
|
|
1143
|
+
this .expandTo (node, true);
|
|
1139
1144
|
}
|
|
1140
1145
|
|
|
1141
1146
|
removeParent (id, executionContextId, nodeId)
|
|
@@ -1398,8 +1403,12 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
1398
1403
|
|
|
1399
1404
|
UndoManager .shared .endUndo ();
|
|
1400
1405
|
|
|
1401
|
-
if (nodes .length
|
|
1402
|
-
|
|
1406
|
+
if (nodes .length < 2)
|
|
1407
|
+
return;
|
|
1408
|
+
|
|
1409
|
+
await this .browser .nextFrame ();
|
|
1410
|
+
|
|
1411
|
+
this .expandTo (childNode, true);
|
|
1403
1412
|
}
|
|
1404
1413
|
|
|
1405
1414
|
protocolToMimeType = new Map ([
|
|
@@ -1530,7 +1539,7 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
1530
1539
|
Editor .setFieldValue (node .getExecutionContext (), node, node ._bboxSize, new X3D .Vector3 (-1, -1, -1));
|
|
1531
1540
|
Editor .setFieldValue (node .getExecutionContext (), node, node ._bboxCenter, new X3D .Vector3 ());
|
|
1532
1541
|
|
|
1533
|
-
await
|
|
1542
|
+
await this .browser .nextFrame ();
|
|
1534
1543
|
|
|
1535
1544
|
const bbox = node .getBBox (new X3D .Box3 ());
|
|
1536
1545
|
|
|
@@ -1587,7 +1596,9 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
|
|
|
1587
1596
|
|
|
1588
1597
|
UndoManager .shared .endUndo ();
|
|
1589
1598
|
|
|
1590
|
-
|
|
1599
|
+
await this .browser .nextFrame ();
|
|
1600
|
+
|
|
1601
|
+
this .expandTo (inlineNode);
|
|
1591
1602
|
}
|
|
1592
1603
|
|
|
1593
1604
|
addNormalsToGeometry (id, executionContextId, nodeId)
|
|
@@ -457,7 +457,9 @@ module .exports = class OutlineView extends Interface
|
|
|
457
457
|
|
|
458
458
|
const nodes = Array .from (scene .rootNodes);
|
|
459
459
|
|
|
460
|
-
|
|
460
|
+
this .browser .nextFrame ()
|
|
461
|
+
.then (() => nodes .forEach (n => n .setNodeUserData (_changing, false)));
|
|
462
|
+
|
|
461
463
|
return;
|
|
462
464
|
}
|
|
463
465
|
|
|
@@ -1816,7 +1818,9 @@ module .exports = class OutlineView extends Interface
|
|
|
1816
1818
|
if (!field .getValue () || !field .getNodeUserData (_changing))
|
|
1817
1819
|
break;
|
|
1818
1820
|
|
|
1819
|
-
|
|
1821
|
+
this .browser .nextFrame ()
|
|
1822
|
+
.then (() => field .setNodeUserData (_changing, false));
|
|
1823
|
+
|
|
1820
1824
|
return;
|
|
1821
1825
|
}
|
|
1822
1826
|
case X3D .X3DConstants .MFNode:
|
|
@@ -1828,7 +1832,9 @@ module .exports = class OutlineView extends Interface
|
|
|
1828
1832
|
|
|
1829
1833
|
const nodes = Array .from (field);
|
|
1830
1834
|
|
|
1831
|
-
|
|
1835
|
+
this .browser .nextFrame ()
|
|
1836
|
+
.then (() => nodes .forEach (n => n .setNodeUserData (_changing, false)));
|
|
1837
|
+
|
|
1832
1838
|
return;
|
|
1833
1839
|
}
|
|
1834
1840
|
|
package/src/Editors/Panel.js
CHANGED
|
@@ -372,16 +372,16 @@ module .exports = new class Panel extends Interface
|
|
|
372
372
|
case X3D .X3DConstants .SFVec4f:
|
|
373
373
|
{
|
|
374
374
|
const
|
|
375
|
-
|
|
376
|
-
category
|
|
377
|
-
min
|
|
378
|
-
max
|
|
375
|
+
scene = this .browser .currentScene,
|
|
376
|
+
category = field .getUnit (),
|
|
377
|
+
min = fieldElement .attr ("minInclusive") ?? fieldElement .attr ("minExclusive"),
|
|
378
|
+
max = fieldElement .attr ("maxInclusive") ?? fieldElement .attr ("maxExclusive");
|
|
379
379
|
|
|
380
380
|
if (min !== undefined)
|
|
381
|
-
options .min =
|
|
381
|
+
options .min = scene .toUnit (category, parseFloat (min));
|
|
382
382
|
|
|
383
383
|
if (max !== undefined)
|
|
384
|
-
options .max =
|
|
384
|
+
options .max = scene .toUnit (category, parseFloat (max));
|
|
385
385
|
|
|
386
386
|
this .refresh (parameter, node, field);
|
|
387
387
|
|
|
@@ -470,6 +470,7 @@ module .exports = new class Panel extends Interface
|
|
|
470
470
|
refresh (parameter, node, field)
|
|
471
471
|
{
|
|
472
472
|
const
|
|
473
|
+
scene = this .browser .currentScene,
|
|
473
474
|
executionContext = node .getExecutionContext (),
|
|
474
475
|
category = field .getUnit (),
|
|
475
476
|
name = field .getName ();
|
|
@@ -483,7 +484,7 @@ module .exports = new class Panel extends Interface
|
|
|
483
484
|
case X3D .X3DConstants .SFString:
|
|
484
485
|
case X3D .X3DConstants .SFTime:
|
|
485
486
|
{
|
|
486
|
-
parameter [name] =
|
|
487
|
+
parameter [name] = scene .toUnit (category, field .getValue ());
|
|
487
488
|
break;
|
|
488
489
|
}
|
|
489
490
|
case X3D .X3DConstants .SFImage:
|
|
@@ -502,7 +503,7 @@ module .exports = new class Panel extends Interface
|
|
|
502
503
|
p .x = field .x;
|
|
503
504
|
p .y = field .y;
|
|
504
505
|
p .z = field .z;
|
|
505
|
-
p .w =
|
|
506
|
+
p .w = scene .toUnit ("angle", field .angle);
|
|
506
507
|
break;
|
|
507
508
|
}
|
|
508
509
|
case X3D .X3DConstants .SFColor:
|
|
@@ -522,7 +523,7 @@ module .exports = new class Panel extends Interface
|
|
|
522
523
|
const p = parameter [name] ??= { };
|
|
523
524
|
|
|
524
525
|
for (const key in field)
|
|
525
|
-
p [key] =
|
|
526
|
+
p [key] = scene .toUnit (category, field [key]);
|
|
526
527
|
|
|
527
528
|
break;
|
|
528
529
|
}
|
|
@@ -588,6 +589,7 @@ module .exports = new class Panel extends Interface
|
|
|
588
589
|
onchange (node, field, value)
|
|
589
590
|
{
|
|
590
591
|
const
|
|
592
|
+
scene = this .browser .currentScene,
|
|
591
593
|
executionContext = node .getExecutionContext (),
|
|
592
594
|
category = field .getUnit ();
|
|
593
595
|
|
|
@@ -618,7 +620,7 @@ module .exports = new class Panel extends Interface
|
|
|
618
620
|
case X3D .X3DConstants .SFInt32:
|
|
619
621
|
case X3D .X3DConstants .SFTime:
|
|
620
622
|
{
|
|
621
|
-
this .assign (executionContext, node, field,
|
|
623
|
+
this .assign (executionContext, node, field, scene .fromUnit (category, value));
|
|
622
624
|
break;
|
|
623
625
|
}
|
|
624
626
|
case X3D .X3DConstants .SFRotation:
|
|
@@ -626,7 +628,7 @@ module .exports = new class Panel extends Interface
|
|
|
626
628
|
value = new X3D .Rotation4 (value .x,
|
|
627
629
|
value .y,
|
|
628
630
|
value .z,
|
|
629
|
-
|
|
631
|
+
scene .fromUnit ("angle", value .w));
|
|
630
632
|
|
|
631
633
|
this .assign (executionContext, node, field, value);
|
|
632
634
|
break;
|
|
@@ -634,8 +636,8 @@ module .exports = new class Panel extends Interface
|
|
|
634
636
|
case X3D .X3DConstants .SFVec2d:
|
|
635
637
|
case X3D .X3DConstants .SFVec2f:
|
|
636
638
|
{
|
|
637
|
-
value = new X3D .Vector2 (
|
|
638
|
-
|
|
639
|
+
value = new X3D .Vector2 (scene .fromUnit (category, value .x),
|
|
640
|
+
scene .fromUnit (category, value .y));
|
|
639
641
|
|
|
640
642
|
this .assign (executionContext, node, field, value);
|
|
641
643
|
break;
|
|
@@ -643,9 +645,9 @@ module .exports = new class Panel extends Interface
|
|
|
643
645
|
case X3D .X3DConstants .SFVec3d:
|
|
644
646
|
case X3D .X3DConstants .SFVec3f:
|
|
645
647
|
{
|
|
646
|
-
value = new X3D .Vector3 (
|
|
647
|
-
|
|
648
|
-
|
|
648
|
+
value = new X3D .Vector3 (scene .fromUnit (category, value .x),
|
|
649
|
+
scene .fromUnit (category, value .y),
|
|
650
|
+
scene .fromUnit (category, value .z));
|
|
649
651
|
|
|
650
652
|
this .assign (executionContext, node, field, value);
|
|
651
653
|
break;
|
|
@@ -653,10 +655,10 @@ module .exports = new class Panel extends Interface
|
|
|
653
655
|
case X3D .X3DConstants .SFVec4d:
|
|
654
656
|
case X3D .X3DConstants .SFVec4f:
|
|
655
657
|
{
|
|
656
|
-
value = new X3D .Vector4 (
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
658
|
+
value = new X3D .Vector4 (scene .fromUnit (category, value .x),
|
|
659
|
+
scene .fromUnit (category, value .y),
|
|
660
|
+
scene .fromUnit (category, value .z),
|
|
661
|
+
scene .fromUnit (category, value .w));
|
|
660
662
|
|
|
661
663
|
this .assign (executionContext, node, field, value);
|
|
662
664
|
break;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const
|
|
4
|
+
$ = require ("jquery"),
|
|
5
|
+
LibraryPane = require ("./LibraryPane");
|
|
6
|
+
|
|
7
|
+
module .exports = class PrimitivesLibrary extends LibraryPane
|
|
8
|
+
{
|
|
9
|
+
id = "PRIMITIVES";
|
|
10
|
+
description = "Primitives";
|
|
11
|
+
|
|
12
|
+
#list;
|
|
13
|
+
|
|
14
|
+
update ()
|
|
15
|
+
{
|
|
16
|
+
// Fill output.
|
|
17
|
+
|
|
18
|
+
if (this .#list)
|
|
19
|
+
{
|
|
20
|
+
this .output .append (this .#list);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Create list.
|
|
25
|
+
|
|
26
|
+
this .#list = $("<ul></ul>")
|
|
27
|
+
.appendTo (this .output)
|
|
28
|
+
.addClass ("library-list");
|
|
29
|
+
|
|
30
|
+
// Get primitives.
|
|
31
|
+
|
|
32
|
+
const nodes = require ("./Primitives")
|
|
33
|
+
.sort ((a, b) => a .typeName .localeCompare (b .typeName))
|
|
34
|
+
.sort ((a, b) => a .componentInfo .name .localeCompare (b .componentInfo .name));
|
|
35
|
+
|
|
36
|
+
// Create list elements.
|
|
37
|
+
|
|
38
|
+
let componentName = "";
|
|
39
|
+
|
|
40
|
+
for (const node of nodes)
|
|
41
|
+
{
|
|
42
|
+
if (node .componentInfo .name !== componentName)
|
|
43
|
+
{
|
|
44
|
+
componentName = node .componentInfo .name;
|
|
45
|
+
|
|
46
|
+
$("<li></li>")
|
|
47
|
+
.addClass ("component")
|
|
48
|
+
.text (node .componentInfo .name)
|
|
49
|
+
.appendTo (this .#list);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
$("<li></li>")
|
|
53
|
+
.addClass ("node")
|
|
54
|
+
.text (node .typeName)
|
|
55
|
+
.attr ("x3dSyntax", node .x3dSyntax)
|
|
56
|
+
.appendTo (this .#list)
|
|
57
|
+
.on ("dblclick", () => this .importX3D (node .typeName, node .x3dSyntax));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
@@ -251,7 +251,7 @@ module .exports = class ScriptEditor extends Interface
|
|
|
251
251
|
if (!this .node .getType () .includes (X3D .X3DConstants .Script))
|
|
252
252
|
return;
|
|
253
253
|
|
|
254
|
-
this .#declarations ??= fs .readFileSync (
|
|
254
|
+
this .#declarations ??= fs .readFileSync (X3D .TYPE_SCRIPT_PATH, "utf8")
|
|
255
255
|
.replace (/^.*?(?:declare const X3D: X3D;)/s, "");
|
|
256
256
|
|
|
257
257
|
const fields = Array .from (this .node .getUserDefinedFields (), field =>
|
|
@@ -176,7 +176,7 @@ class X3DNodeTool extends X3DBaseTool
|
|
|
176
176
|
|
|
177
177
|
createTool (scene, protoName)
|
|
178
178
|
{
|
|
179
|
-
this .tool = scene .
|
|
179
|
+
this .tool = scene .createProto (protoName);
|
|
180
180
|
|
|
181
181
|
this .tool .getValue () .setPrivate (true);
|
|
182
182
|
|
package/src/Undo/Editor.js
CHANGED
|
@@ -18,17 +18,6 @@ module .exports = class Editor
|
|
|
18
18
|
*/
|
|
19
19
|
static Id = /(?:^[^\x30-\x39\x00-\x20\x22\x23\x27\x2b\x2c\x2d\x2e\x5b\x5c\x5d\x7b\x7d\x7f]{1}[^\x00-\x20\x22\x23\x27\x2c\x2e\x5b\x5c\x5d\x7b\x7d\x7f]*$|^$)/
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {X3DBrowser} browser
|
|
24
|
-
*/
|
|
25
|
-
static nextFrame (browser)
|
|
26
|
-
{
|
|
27
|
-
browser .addBrowserEvent ();
|
|
28
|
-
|
|
29
|
-
return new Promise (resolve => requestAnimationFrame (resolve));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
21
|
/**
|
|
33
22
|
*
|
|
34
23
|
* @param {X3DExecutionContext} executionContext source execution context
|
|
@@ -252,8 +241,6 @@ module .exports = class Editor
|
|
|
252
241
|
scene .setProfile (browser .getProfile ("Full"));
|
|
253
242
|
scene .updateComponent (browser .getComponent ("X_ITE"));
|
|
254
243
|
|
|
255
|
-
await browser .loadComponents (scene .getProfile (), scene .getComponents ());
|
|
256
|
-
|
|
257
244
|
try
|
|
258
245
|
{
|
|
259
246
|
const parser = new X3D .GoldenGate (tempScene);
|
|
@@ -829,7 +816,6 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
|
|
|
829
816
|
|
|
830
817
|
undoManager .beginUndo (_("Set Profile to »%s«"), profile ? profile .title : "Full");
|
|
831
818
|
|
|
832
|
-
browser .loadComponents (profile);
|
|
833
819
|
scene .setProfile (profile);
|
|
834
820
|
|
|
835
821
|
undoManager .registerUndo (() =>
|
|
@@ -854,8 +840,6 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
|
|
|
854
840
|
|
|
855
841
|
undoManager .beginUndo (_("Set Components of Scene"));
|
|
856
842
|
|
|
857
|
-
browser .loadComponents (... components .map (component => component .name));
|
|
858
|
-
|
|
859
843
|
for (const { name } of oldComponents)
|
|
860
844
|
scene .removeComponent (name);
|
|
861
845
|
|
|
@@ -876,7 +860,7 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
|
|
|
876
860
|
* @param {string|ComponentInfo} name
|
|
877
861
|
* @param {UndoManager} undoManager
|
|
878
862
|
*/
|
|
879
|
-
static
|
|
863
|
+
static addComponent (scene, name, undoManager = UndoManager .shared)
|
|
880
864
|
{
|
|
881
865
|
scene = this .getScene (scene);
|
|
882
866
|
name = name instanceof X3D .ComponentInfo ? name .name : name;
|
|
@@ -888,7 +872,6 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
|
|
|
888
872
|
|
|
889
873
|
undoManager .beginUndo (_("Add Component %s"), name);
|
|
890
874
|
|
|
891
|
-
await browser .loadComponents (name);
|
|
892
875
|
scene .addComponent (browser .getComponent (name));
|
|
893
876
|
|
|
894
877
|
undoManager .registerUndo (() =>
|