sunrize 1.7.63 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/package.json +4 -4
  2. package/src/Application/ActionKeys.js +3 -3
  3. package/src/Application/Application.js +5 -1
  4. package/src/Application/Dashboard.js +87 -6
  5. package/src/Application/Document.js +167 -24
  6. package/src/Application/Hierarchy.js +268 -0
  7. package/src/Application/Selection.js +6 -6
  8. package/src/Application/Tabs.js +1 -0
  9. package/src/Components/Grouping/StaticGroup.js +1 -1
  10. package/src/Components/Grouping/Switch.js +34 -0
  11. package/src/Components/Navigation/Collision.js +70 -0
  12. package/src/Components/Navigation/LOD.js +34 -0
  13. package/src/Editors/Library.js +1 -1
  14. package/src/Editors/OutlineEditor.js +6 -2
  15. package/src/Editors/OutlineRouteGraph.js +4 -4
  16. package/src/Editors/OutlineView.js +210 -63
  17. package/src/Tools/Core/X3DNodeTool.js +2 -0
  18. package/src/Tools/EnvironmentalSensor/X3DEnvironmentalSensorNodeTool.x3d +1 -0
  19. package/src/Tools/Geometry2D/Arc2DTool.js +1 -0
  20. package/src/Tools/Geometry2D/ArcClose2DTool.js +1 -0
  21. package/src/Tools/Geometry2D/Circle2DTool.js +1 -0
  22. package/src/Tools/Geometry2D/Disk2DTool.js +2 -0
  23. package/src/Tools/Geometry2D/Rectangle2DTool.js +1 -0
  24. package/src/Tools/Geometry3D/BoxTool.js +1 -0
  25. package/src/Tools/Geometry3D/ConeTool.js +1 -0
  26. package/src/Tools/Geometry3D/CylinderTool.js +1 -0
  27. package/src/Tools/Geometry3D/SphereTool.js +1 -0
  28. package/src/Tools/Grouping/X3DBoundedObjectTool.x3d +28 -12
  29. package/src/Tools/Grouping/X3DTransformNodeTool.x3d +30 -12
  30. package/src/Tools/Lighting/X3DLightNodeTool.x3d +1 -0
  31. package/src/Tools/Navigation/X3DViewpointNodeTool.x3d +1 -0
  32. package/src/Tools/SnapTool/SnapSource.js +4 -2
  33. package/src/Tools/SnapTool/SnapTool.x3d +1 -1
  34. package/src/Tools/SnapTool/X3DSnapNodeTool.js +8 -6
  35. package/src/Tools/Sound/ListenerPointSourceTool.x3d +1 -0
  36. package/src/Tools/Sound/SoundTool.x3d +5 -0
  37. package/src/Tools/Sound/SpatialSoundTool.x3d +2 -1
  38. package/src/Tools/TextureProjection/X3DTextureProjectorNodeTool.x3d +1 -0
  39. package/src/Undo/Editor.js +1 -1
  40. package/src/Undo/UndoManager.js +4 -4
  41. package/src/X3D.js +1 -1
  42. package/src/assets/themes/default-template.css +6 -0
  43. package/src/assets/themes/default.css +6 -0
@@ -0,0 +1,268 @@
1
+ const
2
+ X3D = require ("../X3D"),
3
+ Interface = require ("./Interface"),
4
+ Traverse = require ("x3d-traverse") (X3D);
5
+
6
+ module .exports = new class Hierarchy extends Interface
7
+ {
8
+ #target = null;
9
+ #nodes = [ ];
10
+ #hierarchies = [ ];
11
+
12
+ constructor ()
13
+ {
14
+ super ("Sunrize.Hierarchy.");
15
+
16
+ this .setup ();
17
+ }
18
+
19
+ configure ()
20
+ {
21
+ this .executionContext ?.sceneGraph_changed .removeInterest ("update", this);
22
+
23
+ this .executionContext = this .browser .currentScene;
24
+
25
+ this .executionContext .sceneGraph_changed .addInterest ("update", this);
26
+ }
27
+
28
+ update ()
29
+ {
30
+ const
31
+ target = this .#target,
32
+ nodes = this .#nodes;
33
+
34
+ this .target (target ?.isLive () ? target : null);
35
+ nodes .forEach (node => this .add (node));
36
+ }
37
+
38
+ #targetTypes = new Set ([
39
+ X3D .X3DConstants .X3DShapeNode,
40
+ X3D .X3DConstants .Inline,
41
+ ]);
42
+
43
+ target (node)
44
+ {
45
+ node = node ?.valueOf () ?? null;
46
+
47
+ this .#target = node;
48
+ this .#nodes = [ ];
49
+
50
+ if (!node)
51
+ {
52
+ this .#hierarchies = [ ];
53
+ }
54
+ else if (!node .getType () .includes (X3D .X3DConstants .X3DShapeNode))
55
+ {
56
+ this .#hierarchies = [ ];
57
+
58
+ let flags = Traverse .NONE;
59
+
60
+ flags |= Traverse .PROTO_DECLARATIONS;
61
+ flags |= Traverse .PROTO_DECLARATION_BODY;
62
+ flags |= Traverse .ROOT_NODES;
63
+
64
+ for (const object of Traverse .traverse (node, flags))
65
+ {
66
+ if (!(object instanceof X3D .SFNode))
67
+ continue;
68
+
69
+ const node = object .getValue () .valueOf ();
70
+
71
+ if (!node .getType () .some (type => this .#targetTypes .has (type)))
72
+ continue;
73
+
74
+ const target = node .getGeometry ?.() ?.valueOf () ?? node;
75
+
76
+ for (const hierarchy of this .#find (target))
77
+ this .#hierarchies .push (hierarchy);
78
+ }
79
+
80
+ if (!this .#hierarchies .length)
81
+ this .#hierarchies = this .#find (node);
82
+ }
83
+ else
84
+ {
85
+ const target = node .getType () .includes (X3D .X3DConstants .X3DShapeNode)
86
+ ? node .getGeometry () ?.valueOf () ?? node
87
+ : node;
88
+
89
+ this .#hierarchies = this .#find (target);
90
+ }
91
+
92
+ this .#processInterests ();
93
+ }
94
+
95
+ set (node)
96
+ {
97
+ node = node ?.valueOf () ?? null;
98
+
99
+ if (!this .#has (node))
100
+ return;
101
+
102
+ this .#nodes = [node];
103
+
104
+ this .#processInterests ();
105
+ }
106
+
107
+ add (node)
108
+ {
109
+ node = node ?.valueOf () ?? null;
110
+
111
+ if (!this .#has (node))
112
+ return;
113
+
114
+ if (this .#nodes .includes (node))
115
+ return;
116
+
117
+ this .#nodes .push (node);
118
+
119
+ this .#processInterests ();
120
+ }
121
+
122
+ remove (node)
123
+ {
124
+ node = node ?.valueOf () ?? null;
125
+
126
+ this .#nodes = this .#nodes .filter (n => n !== node);
127
+
128
+ this .#processInterests ();
129
+ }
130
+
131
+ clear ()
132
+ {
133
+ this .#target = null;
134
+ this .#nodes = [ ];
135
+ this .#hierarchies = [ ];
136
+
137
+ this .#processInterests ();
138
+ }
139
+
140
+ #find (target)
141
+ {
142
+ if (!target)
143
+ return [ ];
144
+
145
+ // Find target node.
146
+
147
+ let flags = Traverse .NONE;
148
+
149
+ flags |= Traverse .PROTO_DECLARATIONS;
150
+ flags |= Traverse .PROTO_DECLARATION_BODY;
151
+ flags |= Traverse .ROOT_NODES;
152
+
153
+ return Array .from (this .executionContext .find (target, flags),
154
+ hierarchy => hierarchy .filter (object => object instanceof X3D .SFNode)
155
+ .map (node => node .getValue () .valueOf ()));
156
+ }
157
+
158
+ #has (node)
159
+ {
160
+ return this .#hierarchies .some (hierarchy => hierarchy .includes (node));
161
+ }
162
+
163
+ #indices (node)
164
+ {
165
+ return this .#hierarchies .map (hierarchy => hierarchy .indexOf (node));
166
+ }
167
+
168
+ up ()
169
+ {
170
+ this .#nodes = this .#nodes .flatMap (node => this .#indices (node) .map (index =>
171
+ {
172
+ return index - 1 >= 0 ? index - 1 : index;
173
+ })
174
+ .map ((index, i) => this .#hierarchies [i] [index])
175
+ .filter (node => node));
176
+
177
+ this .#nodes = Array .from (new Set (this .#nodes));
178
+
179
+ // Combine to most highest node.
180
+
181
+ const indices = Array .from (this .#hierarchies, hierarchy => hierarchy .length);
182
+
183
+ for (const node of this .#nodes)
184
+ {
185
+ for (const [i, index] of this .#indices (node) .entries ())
186
+ {
187
+ if (index < 0)
188
+ continue;
189
+
190
+ indices [i] = Math .min (indices [i], index);
191
+ }
192
+ }
193
+
194
+ this .#nodes = indices .map ((index, i) => this .#hierarchies [i] [index]) .filter (node => node);
195
+ this .#nodes = Array .from (new Set (this .#nodes));
196
+
197
+ // Propagate change.
198
+
199
+ this .#processInterests ();
200
+
201
+ return this .#nodes;
202
+ }
203
+
204
+ down ()
205
+ {
206
+ this .#nodes = this .#nodes .flatMap (node => this .#indices (node) .map ((index, i) =>
207
+ {
208
+ return index >= 0 && index + 1 < this .#hierarchies [i] .length ? index + 1 : index;
209
+ })
210
+ .map ((index, i) => this .#hierarchies [i] [index])
211
+ .filter (node => node));
212
+
213
+ this .#nodes = Array .from (new Set (this .#nodes));
214
+
215
+ // Combine to most lowest node.
216
+
217
+ const indices = Array .from (this .#hierarchies, () => -1);
218
+
219
+ for (const node of this .#nodes)
220
+ {
221
+ for (const [i, index] of this .#indices (node) .entries ())
222
+ {
223
+ if (index < 0)
224
+ continue;
225
+
226
+ indices [i] = Math .max (indices [i], index);
227
+ }
228
+ }
229
+
230
+ this .#nodes = indices .map ((index, i) => this .#hierarchies [i] [index]) .filter (node => node);
231
+ this .#nodes = Array .from (new Set (this .#nodes));
232
+
233
+ // Propagate change.
234
+
235
+ this .#processInterests ();
236
+
237
+ return this .#nodes;
238
+ }
239
+
240
+ canUp ()
241
+ {
242
+ return this .#nodes .some (node => this .#indices (node) .some (index => index > 0));
243
+ }
244
+
245
+ canDown ()
246
+ {
247
+ return this .#nodes .some (node => this .#indices (node)
248
+ .some ((index, i) => index >= 0 && index < this .#hierarchies [i] .length - 1));
249
+ }
250
+
251
+ #interest = new Map ();
252
+
253
+ addInterest (key, callback)
254
+ {
255
+ this .#interest .set (key, callback);
256
+ }
257
+
258
+ removeInterest (key)
259
+ {
260
+ this .#interest .delete (key);
261
+ }
262
+
263
+ #processInterests ()
264
+ {
265
+ for (const callback of this .#interest .values ())
266
+ callback (this .nodes);
267
+ }
268
+ }
@@ -37,7 +37,7 @@ module .exports = new class Selection extends Interface
37
37
  // this .nodes = this .nodes .map (n => n .isLive ()); // Leave tool working.
38
38
 
39
39
  if (length !== this .nodes .length)
40
- this .processInterests ();
40
+ this .#processInterests ();
41
41
  }
42
42
 
43
43
  has (node)
@@ -51,7 +51,7 @@ module .exports = new class Selection extends Interface
51
51
  clear ()
52
52
  {
53
53
  this .#clear ();
54
- this .processInterests ();
54
+ this .#processInterests ();
55
55
  }
56
56
 
57
57
  set (node)
@@ -61,7 +61,7 @@ module .exports = new class Selection extends Interface
61
61
 
62
62
  this .#clear (node);
63
63
  this .#add (node);
64
- this .processInterests ();
64
+ this .#processInterests ();
65
65
  }
66
66
 
67
67
  add (node)
@@ -70,7 +70,7 @@ module .exports = new class Selection extends Interface
70
70
  return;
71
71
 
72
72
  this .#add (node);
73
- this .processInterests ();
73
+ this .#processInterests ();
74
74
  }
75
75
 
76
76
  remove (node)
@@ -79,7 +79,7 @@ module .exports = new class Selection extends Interface
79
79
  return;
80
80
 
81
81
  this .#remove (node);
82
- this .processInterests ();
82
+ this .#processInterests ();
83
83
  }
84
84
 
85
85
  #clear (exclude)
@@ -132,7 +132,7 @@ module .exports = new class Selection extends Interface
132
132
  this .#interest .delete (key);
133
133
  }
134
134
 
135
- processInterests ()
135
+ #processInterests ()
136
136
  {
137
137
  for (const callback of this .#interest .values ())
138
138
  callback (this .nodes);
@@ -105,6 +105,7 @@ module .exports = new class Tabs
105
105
  this .forwardToActiveTab ("activate-snap-target");
106
106
  this .forwardToActiveTab ("activate-snap-source");
107
107
  this .forwardToActiveTab ("center-snap-target-in-selection");
108
+ this .forwardToActiveTab ("center-snap-source-in-selection");
108
109
  this .forwardToActiveTab ("move-selection-to-snap-target");
109
110
  this .forwardToActiveTab ("move-selection-center-to-snap-target");
110
111
 
@@ -1,4 +1,4 @@
1
- "use strict"
1
+ "use strict";
2
2
 
3
3
  const X3D = require ("../../X3D");
4
4
 
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ const X3D = require ("../../X3D");
4
+
5
+ function Switch (executionContext)
6
+ {
7
+ X3D .Switch .call (this, executionContext);
8
+
9
+ this .editChild = null;
10
+ }
11
+
12
+ Object .assign (Object .setPrototypeOf (Switch .prototype, X3D .Switch .prototype),
13
+ {
14
+ getEditChild ()
15
+ {
16
+ return this .editChild;
17
+ },
18
+ setEditChild (childNode)
19
+ {
20
+ this .editChild = childNode;
21
+
22
+ this .set_children__ ();
23
+
24
+ this .getBrowser () .addBrowserEvent ();
25
+ },
26
+ setChild (childNode)
27
+ {
28
+ X3D .Switch .prototype .setChild .call (this, this .editChild ?.getTool () ?? this .editChild ?? childNode);
29
+ },
30
+ });
31
+
32
+ Object .assign (Switch, X3D .Switch);
33
+
34
+ module .exports = Switch;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ const X3D = require ("../../X3D");
4
+
5
+ function Collision (executionContext)
6
+ {
7
+ X3D .Collision .call (this, executionContext);
8
+
9
+ this .proxyDisplay = false;
10
+ }
11
+
12
+ Object .assign (Object .setPrototypeOf (Collision .prototype, X3D .Collision .prototype),
13
+ {
14
+ getProxyDisplay ()
15
+ {
16
+ return this .proxyDisplay;
17
+ },
18
+ setProxyDisplay (proxyDisplay)
19
+ {
20
+ this .proxyDisplay = proxyDisplay;
21
+
22
+ this .set_collisionObjects__ ();
23
+ },
24
+ set_proxy__ ()
25
+ {
26
+ this .pointingObjects .delete (this .proxyNode);
27
+ this .visibleObjects .delete (this .proxyNode);
28
+
29
+ X3D .Collision .prototype .set_proxy__ .call (this);
30
+ },
31
+ set_pointingObjects__ ()
32
+ {
33
+ if (this .proxyNode)
34
+ {
35
+ if (this .proxyDisplay)
36
+ this .pointingObjects .add (this .proxyNode);
37
+ else
38
+ this .pointingObjects .delete (this .proxyNode);
39
+ }
40
+
41
+ X3D .Collision .prototype .set_pointingObjects__ .call (this);
42
+
43
+ this .getBrowser () .addBrowserEvent ();
44
+ },
45
+ set_collisionObjects__ ()
46
+ {
47
+ this .set_pointingObjects__ ();
48
+ this .set_visibleObjects__ ();
49
+
50
+ X3D .Collision .prototype .set_collisionObjects__ .call (this);
51
+ },
52
+ set_visibleObjects__ ()
53
+ {
54
+ if (this .proxyNode)
55
+ {
56
+ if (this .proxyDisplay)
57
+ this .visibleObjects .add (this .proxyNode);
58
+ else
59
+ this .visibleObjects .delete (this .proxyNode);
60
+ }
61
+
62
+ X3D .Collision .prototype .set_visibleObjects__ .call (this);
63
+
64
+ this .getBrowser () .addBrowserEvent ();
65
+ },
66
+ });
67
+
68
+ Object .assign (Collision, X3D .Collision);
69
+
70
+ module .exports = Collision;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ const X3D = require ("../../X3D");
4
+
5
+ function LOD (executionContext)
6
+ {
7
+ X3D .LOD .call (this, executionContext);
8
+
9
+ this .editChild = null;
10
+ }
11
+
12
+ Object .assign (Object .setPrototypeOf (LOD .prototype, X3D .LOD .prototype),
13
+ {
14
+ getEditChild ()
15
+ {
16
+ return this .editChild;
17
+ },
18
+ setEditChild (childNode)
19
+ {
20
+ this .editChild = childNode;
21
+
22
+ this .set_children__ ();
23
+
24
+ this .getBrowser () .addBrowserEvent ();
25
+ },
26
+ setChild (childNode)
27
+ {
28
+ X3D .LOD .prototype .setChild .call (this, this .editChild ?.getTool () ?? this .editChild ?? childNode);
29
+ },
30
+ });
31
+
32
+ Object .assign (LOD, X3D .LOD);
33
+
34
+ module .exports = LOD;
@@ -263,6 +263,6 @@ module .exports = new class Library extends Dialog
263
263
  const outlineEditor = require ("../Application/Window") .sidebar .outlineEditor;
264
264
 
265
265
  outlineEditor .expandTo (node);
266
- outlineEditor .selectNodeElement ($(`.node[node-id=${node .getId ()}]`));
266
+ outlineEditor .selectNodeElement ($(`.node[node-id=${node .getId ()}]`), { target: true });
267
267
  }
268
268
  }
@@ -1199,7 +1199,11 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
1199
1199
 
1200
1200
  await this .browser .nextFrame ();
1201
1201
 
1202
- this .expandTo (node, true);
1202
+ this .expandTo (node, { expandObject: true });
1203
+
1204
+ const groupElement = this .sceneGraph .find (`.node[node-id=${node .getId ()}]`);
1205
+
1206
+ this .selectNodeElement (groupElement, { target: true });
1203
1207
  }
1204
1208
 
1205
1209
  removeParent (id, executionContextId, nodeId)
@@ -1467,7 +1471,7 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
1467
1471
 
1468
1472
  await this .browser .nextFrame ();
1469
1473
 
1470
- this .expandTo (childNode, true);
1474
+ this .expandTo (childNode, { expandObject: true });
1471
1475
  }
1472
1476
 
1473
1477
  protocolToMimeType = new Map ([
@@ -38,7 +38,7 @@ module .exports = class OutlineRouteGraph extends OutlineView
38
38
  for (const route of field .getInputRoutes ())
39
39
  {
40
40
  this .selectedRoutes .add (route);
41
- this .expandTo (route .getSourceNode (), true);
41
+ this .expandTo (route .getSourceNode (), { expandObject: true });
42
42
  }
43
43
 
44
44
  break;
@@ -48,7 +48,7 @@ module .exports = class OutlineRouteGraph extends OutlineView
48
48
  for (const route of field .getOutputRoutes ())
49
49
  {
50
50
  this .selectedRoutes .add (route);
51
- this .expandTo (route .getDestinationNode (), true);
51
+ this .expandTo (route .getDestinationNode (), { expandObject: true });
52
52
  }
53
53
 
54
54
  break;
@@ -78,7 +78,7 @@ module .exports = class OutlineRouteGraph extends OutlineView
78
78
  const route = this .getRoute (element, field .getInputRoutes ());
79
79
 
80
80
  this .selectedRoutes .add (route);
81
- this .expandTo (route .getSourceNode (), true);
81
+ this .expandTo (route .getSourceNode (), { expandObject: true });
82
82
  break;
83
83
  }
84
84
  case "output":
@@ -86,7 +86,7 @@ module .exports = class OutlineRouteGraph extends OutlineView
86
86
  const route = this .getRoute (element, field .getOutputRoutes ());
87
87
 
88
88
  this .selectedRoutes .add (route);
89
- this .expandTo (route .getDestinationNode (), true);
89
+ this .expandTo (route .getDestinationNode (), { expandObject: true });
90
90
  break;
91
91
  }
92
92
  }