sunrize 1.6.15 → 1.7.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.
@@ -178,8 +178,9 @@ module .exports = class OutlineView extends Interface
178
178
 
179
179
  expandScene (parent, scene)
180
180
  {
181
- parent .data ("expanded", true);
182
- parent .data ("full-expanded", false);
181
+ parent
182
+ .data ("expanded", true)
183
+ .data ("full-expanded", false);
183
184
 
184
185
  if (scene instanceof X3D .X3DScene)
185
186
  scene .units .addInterest ("updateScene", this, parent, scene);
@@ -223,7 +224,6 @@ module .exports = class OutlineView extends Interface
223
224
  .off ("keypress.jstree dblclick.jstree")
224
225
  .on ("before_open.jstree", this .nodeBeforeOpen .bind (this))
225
226
  .on ("close_node.jstree", this .nodeCloseNode .bind (this))
226
- .on ("select_node.jstree", this .selectNode .bind (this))
227
227
  .appendTo (parent)
228
228
  .hide ();
229
229
 
@@ -231,7 +231,8 @@ module .exports = class OutlineView extends Interface
231
231
  .removeAttr ("tabindex")
232
232
  .find (".jstree-anchor")
233
233
  .removeAttr ("href")
234
- .removeAttr ("tabindex");
234
+ .removeAttr ("tabindex")
235
+ .on ("click", this .selectNone .bind (this));
235
236
 
236
237
  child .find (".externproto, .proto, .node, .imported-node, .exported-node")
237
238
  .on ("dblclick", this .activateNode .bind (this));
@@ -261,6 +262,9 @@ module .exports = class OutlineView extends Interface
261
262
  .on ("dragstart", this .onDragStartNode .bind (this));
262
263
  }
263
264
 
265
+ child .find (".externproto .name, .externproto .icon, .proto .name, .proto .icon, .node .name, .node .icon")
266
+ .on ("click", this .selectNode .bind (this));
267
+
264
268
  child .find (".node .name")
265
269
  .on ("mouseenter", this .updateNodeTitle .bind (this));
266
270
 
@@ -279,6 +283,9 @@ module .exports = class OutlineView extends Interface
279
283
  child .find (".reload-node")
280
284
  .on ("click", this .reloadNode .bind (this));
281
285
 
286
+ child .find (".show-preview")
287
+ .on ("click", this .showPreview .bind (this));
288
+
282
289
  // Expand children.
283
290
 
284
291
  const
@@ -590,8 +597,9 @@ module .exports = class OutlineView extends Interface
590
597
 
591
598
  expandNode (parent, node, full)
592
599
  {
593
- parent .data ("expanded", true);
594
- parent .data ("full-expanded", full);
600
+ parent
601
+ .data ("expanded", true)
602
+ .data ("full-expanded", full);
595
603
 
596
604
  // Generate tree.
597
605
 
@@ -708,7 +716,6 @@ module .exports = class OutlineView extends Interface
708
716
  .off ("keypress.jstree dblclick.jstree")
709
717
  .on ("before_open.jstree", this .fieldBeforeOpen .bind (this))
710
718
  .on ("close_node.jstree", this .fieldCloseNode .bind (this))
711
- .on ("select_node.jstree", this .selectField .bind (this))
712
719
  .appendTo (parent)
713
720
  .hide ();
714
721
 
@@ -716,7 +723,8 @@ module .exports = class OutlineView extends Interface
716
723
  .removeAttr ("tabindex")
717
724
  .find (".jstree-anchor")
718
725
  .removeAttr ("href")
719
- .removeAttr ("tabindex");
726
+ .removeAttr ("tabindex")
727
+ .on ("click", this .selectNone .bind (this));
720
728
 
721
729
  child .find ("li")
722
730
  .on ("dblclick", this .activateField .bind (this));
@@ -731,6 +739,9 @@ module .exports = class OutlineView extends Interface
731
739
  .wrapInner ("<div class=\"item no-select\"/>")
732
740
  .find (".item") .append ("<div class=\"route-curves-wrapper\"><canvas class=\"route-curves\"></canvas></div>");
733
741
 
742
+ child .find (".field .name, .field .icon, .special .name, .special .icon")
743
+ .on ("click", this .selectField .bind (this))
744
+
734
745
  child .find (".field .name, .special .name")
735
746
  .on ("mouseenter", this .updateFieldTitle .bind (this));
736
747
 
@@ -955,7 +966,7 @@ module .exports = class OutlineView extends Interface
955
966
 
956
967
  const icon = $("<img></img>")
957
968
  .addClass ("icon")
958
- .attr ("src", `../images/OutlineEditor/Node/${this .nodeIcons [type]}.svg`)
969
+ .attr ("src", `../images/OutlineEditor/Node/${this .nodeIcons .get (type)}.svg`)
959
970
  .appendTo (child);
960
971
 
961
972
  if (node)
@@ -968,7 +979,7 @@ module .exports = class OutlineView extends Interface
968
979
 
969
980
  $("<span></span>")
970
981
  .addClass ("node-type-name")
971
- .text (this .typeNames [node .getTypeName ()] || node .getTypeName ())
982
+ .text (this .typeNames .get (node .getTypeName ()) ?? node .getTypeName ())
972
983
  .appendTo (name);
973
984
 
974
985
  name .append (document .createTextNode (" "));
@@ -987,28 +998,28 @@ module .exports = class OutlineView extends Interface
987
998
  .text (cloneCount > 1 ? `[${cloneCount}]` : "")
988
999
  .appendTo (name);
989
1000
 
1001
+ // Buttons
1002
+
1003
+ const buttons = [ ];
1004
+
990
1005
  if (node .setHidden && !(node .getExecutionContext () .getOuterNode () instanceof X3D .X3DProtoDeclaration))
991
1006
  {
992
- name .append (document .createTextNode (" "));
993
-
994
- $("<span></span>")
1007
+ buttons .push ($("<span></span>")
1008
+ .attr ("order", "0")
995
1009
  .addClass (["toggle-visibility", "button", "material-symbols-outlined"])
996
1010
  .addClass (node .isHidden () ? "off" : "on")
997
1011
  .attr ("title", "Toggle visibility.")
998
- .text (node .isHidden () ? "visibility_off" : "visibility")
999
- .appendTo (name);
1012
+ .text (node .isHidden () ? "visibility_off" : "visibility"));
1000
1013
  }
1001
1014
 
1002
1015
  if (node .getType () .some (type => this .onDemandToolNodes .has (type)))
1003
1016
  {
1004
- name .append (document .createTextNode (" "));
1005
-
1006
- $("<span></span>")
1017
+ buttons .push ($("<span></span>")
1018
+ .attr ("order", "1")
1007
1019
  .addClass (["toggle-tool", "button", "material-symbols-outlined"])
1008
1020
  .addClass (node .valueOf () === node ? "off" : "on")
1009
1021
  .attr ("title", _("Toggle display tool."))
1010
- .text ("build_circle")
1011
- .appendTo (name);
1022
+ .text ("build_circle"));
1012
1023
  }
1013
1024
 
1014
1025
  for (const type of node .getType ())
@@ -1017,14 +1028,12 @@ module .exports = class OutlineView extends Interface
1017
1028
  {
1018
1029
  case X3D .X3DConstants .X3DLayerNode:
1019
1030
  {
1020
- name .append (document .createTextNode (" "));
1021
-
1022
- $("<span></span>")
1031
+ buttons .push ($("<span></span>")
1032
+ .attr ("order", "2")
1023
1033
  .addClass (["activate-layer", "button", "material-symbols-outlined"])
1024
1034
  .addClass (this .browser .getActiveLayer () === node ? "green" : "off")
1025
1035
  .attr ("title", _("Activate layer."))
1026
- .text ("check_circle")
1027
- .appendTo (name);
1036
+ .text ("check_circle"));
1028
1037
 
1029
1038
  continue;
1030
1039
  }
@@ -1032,14 +1041,12 @@ module .exports = class OutlineView extends Interface
1032
1041
  {
1033
1042
  node ._isBound .addFieldCallback (this .#updateNodeBoundSymbol, this .updateNodeBound .bind (this, node));
1034
1043
 
1035
- name .append (document .createTextNode (" "));
1036
-
1037
- $("<span></span>")
1044
+ buttons .push ($("<span></span>")
1045
+ .attr ("order", "3")
1038
1046
  .addClass (["bind-node", "button", "material-symbols-outlined"])
1039
1047
  .addClass (node ._isBound .getValue () ? "on" : "off")
1040
1048
  .attr ("title", _("Bind node."))
1041
- .text (node ._isBound .getValue () ? "radio_button_checked" : "radio_button_unchecked")
1042
- .appendTo (name);
1049
+ .text (node ._isBound .getValue () ? "radio_button_checked" : "radio_button_unchecked"));
1043
1050
 
1044
1051
  continue;
1045
1052
  }
@@ -1055,19 +1062,39 @@ module .exports = class OutlineView extends Interface
1055
1062
 
1056
1063
  node .getLoadState () .addFieldCallback (this .#updateNodeLoadStateSymbol, this .updateNodeLoadState .bind (this, node));
1057
1064
 
1058
- name .append (document .createTextNode (" "));
1059
-
1060
- $("<span></span>")
1065
+ buttons .push ($("<span></span>")
1066
+ .attr ("order", "4")
1061
1067
  .addClass (["reload-node", "button", "material-symbols-outlined", className])
1062
1068
  .attr ("title", "Load now.")
1063
- .text ("autorenew")
1064
- .appendTo (name);
1069
+ .text ("autorenew"));
1070
+
1071
+ continue;
1072
+ }
1073
+ case X3D .X3DConstants .AudioClip:
1074
+ case X3D .X3DConstants .BufferAudioSource:
1075
+ case X3D .X3DConstants .X3DMaterialNode:
1076
+ case X3D .X3DConstants .X3DSingleTextureNode:
1077
+ {
1078
+ buttons .push ($("<span></span>")
1079
+ .attr ("order", "5")
1080
+ .addClass (["show-preview", "button", "material-symbols-outlined", "off"])
1081
+ .css ("top", "2px")
1082
+ .attr ("title", _("Show preview."))
1083
+ .text ("preview"));
1065
1084
 
1066
1085
  continue;
1067
1086
  }
1068
1087
  }
1069
1088
  }
1070
1089
 
1090
+ buttons .sort ((a, b) => a .attr ("order") - b .attr ("order"))
1091
+
1092
+ for (const button of buttons)
1093
+ {
1094
+ name .append (document .createTextNode (" "));
1095
+ name .append (button);
1096
+ }
1097
+
1071
1098
  // Append empty tree to enable expander.
1072
1099
 
1073
1100
  if (!this .isInParents (parent, node))
@@ -1186,7 +1213,7 @@ module .exports = class OutlineView extends Interface
1186
1213
 
1187
1214
  const icon = $("<img></img>")
1188
1215
  .addClass ("icon")
1189
- .attr ("src", `../images/OutlineEditor/Node/${this .nodeIcons [type]}.svg`)
1216
+ .attr ("src", `../images/OutlineEditor/Node/${this .nodeIcons .get (type)}.svg`)
1190
1217
  .appendTo (child);
1191
1218
 
1192
1219
  // Name
@@ -1236,7 +1263,7 @@ module .exports = class OutlineView extends Interface
1236
1263
 
1237
1264
  const icon = $("<img></img>")
1238
1265
  .addClass ("icon")
1239
- .attr ("src", `../images/OutlineEditor/Node/${this .nodeIcons [type]}.svg`)
1266
+ .attr ("src", `../images/OutlineEditor/Node/${this .nodeIcons .get (type)}.svg`)
1240
1267
  .appendTo (child);
1241
1268
 
1242
1269
  // Name
@@ -1286,7 +1313,7 @@ module .exports = class OutlineView extends Interface
1286
1313
 
1287
1314
  const icon = $("<img></img>")
1288
1315
  .addClass ("icon")
1289
- .attr ("src", `../images/OutlineEditor/Node/${this .nodeIcons [type]}.svg`)
1316
+ .attr ("src", `../images/OutlineEditor/Node/${this .nodeIcons .get (type)}.svg`)
1290
1317
  .appendTo (child);
1291
1318
 
1292
1319
  // Name
@@ -1775,7 +1802,7 @@ module .exports = class OutlineView extends Interface
1775
1802
  if (!field .getValue () || !field .getNodeUserData (_changing))
1776
1803
  break;
1777
1804
 
1778
- requestAnimationFrame (() => field .setNodeUserData (_changing, false));
1805
+ requestAnimationFrame (() => field .setNodeUserData (_changing, false));
1779
1806
  return;
1780
1807
  }
1781
1808
  case X3D .X3DConstants .MFNode:
@@ -1807,29 +1834,30 @@ module .exports = class OutlineView extends Interface
1807
1834
 
1808
1835
  expandField (parent, node, field, type, full)
1809
1836
  {
1810
- parent .data ("expanded", true)
1811
- parent .data ("full-expanded", full)
1837
+ parent
1838
+ .data ("expanded", true)
1839
+ .data ("full-expanded", full);
1812
1840
 
1813
1841
  if (full)
1814
- parent .find (".access-type") .addClass ("hidden")
1842
+ parent .find (".access-type") .addClass ("hidden");
1815
1843
  else
1816
- parent .find (".access-type") .removeClass ("hidden")
1844
+ parent .find (".access-type") .removeClass ("hidden");
1817
1845
 
1818
1846
  switch (field .getType ())
1819
1847
  {
1820
1848
  case X3D .X3DConstants .SFNode:
1821
1849
  {
1822
- field .addFieldCallback (this .#fieldSymbol, this .updateField .bind (this, parent, node, field, type, full))
1850
+ field .addFieldCallback (this .#fieldSymbol, this .updateField .bind (this, parent, node, field, type, full));
1823
1851
 
1824
- this .expandSFNode (parent, node, field, type, full)
1825
- break
1852
+ this .expandSFNode (parent, node, field, type, full);
1853
+ break;
1826
1854
  }
1827
1855
  case X3D .X3DConstants .MFNode:
1828
1856
  {
1829
- field .addFieldCallback (this .#fieldSymbol, this .updateField .bind (this, parent, node, field, type, full))
1857
+ field .addFieldCallback (this .#fieldSymbol, this .updateField .bind (this, parent, node, field, type, full));
1830
1858
 
1831
- this .expandMFNode (parent, node, field, type, full)
1832
- break
1859
+ this .expandMFNode (parent, node, field, type, full);
1860
+ break;
1833
1861
  }
1834
1862
  case X3D .X3DConstants .SFBool:
1835
1863
  case X3D .X3DConstants .SFColor:
@@ -1852,8 +1880,8 @@ module .exports = class OutlineView extends Interface
1852
1880
  case X3D .X3DConstants .SFVec4d:
1853
1881
  case X3D .X3DConstants .SFVec4f:
1854
1882
  {
1855
- this .expandSingleField (parent, node, field, type, full)
1856
- break
1883
+ this .expandSingleField (parent, node, field, type, full);
1884
+ break;
1857
1885
  }
1858
1886
  case X3D .X3DConstants .MFBool:
1859
1887
  case X3D .X3DConstants .MFColor:
@@ -1876,17 +1904,17 @@ module .exports = class OutlineView extends Interface
1876
1904
  case X3D .X3DConstants .MFVec4d:
1877
1905
  case X3D .X3DConstants .MFVec4f:
1878
1906
  {
1879
- this .expandArrayField (parent, node, field, type, full)
1880
- break
1907
+ this .expandArrayField (parent, node, field, type, full);
1908
+ break;
1881
1909
  }
1882
1910
  default:
1883
1911
  {
1884
- break
1912
+ break;
1885
1913
  }
1886
1914
  }
1887
1915
 
1888
1916
  if (full)
1889
- field .addRouteCallback (this .#routesFullSymbol, this .updateField .bind (this, parent, node, field, type, full))
1917
+ field .addRouteCallback (this .#routesFullSymbol, this .updateField .bind (this, parent, node, field, type, full));
1890
1918
  }
1891
1919
 
1892
1920
  expandMFNode (parent, node, field, type, full)
@@ -1894,18 +1922,18 @@ module .exports = class OutlineView extends Interface
1894
1922
  // Generate tree.
1895
1923
 
1896
1924
  const child = $("<div></div>")
1897
- .addClass ("subtree")
1925
+ .addClass ("subtree");
1898
1926
 
1899
1927
  const ul = $("<ul></ul>")
1900
- .appendTo (child)
1928
+ .appendTo (child);
1901
1929
 
1902
1930
  if (full)
1903
- ul .append (this .createRouteElements (node, field))
1931
+ ul .append (this .createRouteElements (node, field));
1904
1932
 
1905
- let index = 0
1933
+ let index = 0;
1906
1934
 
1907
1935
  for (const node of field)
1908
- ul .append (this .createNodeElement ("node", parent, node ? node .getValue () : null, index ++))
1936
+ ul .append (this .createNodeElement ("node", parent, node ?.getValue (), index ++));
1909
1937
 
1910
1938
  // Make jsTree.
1911
1939
 
@@ -1914,76 +1942,82 @@ module .exports = class OutlineView extends Interface
1914
1942
  .off ("keypress.jstree dblclick.jstree")
1915
1943
  .on ("before_open.jstree", this .nodeBeforeOpen .bind (this))
1916
1944
  .on ("close_node.jstree", this .nodeCloseNode .bind (this))
1917
- .on ("select_node.jstree", this .selectNode .bind (this))
1918
1945
  .appendTo (parent)
1919
- .hide ()
1946
+ .hide ();
1920
1947
 
1921
1948
  child
1922
1949
  .removeAttr ("tabindex")
1923
1950
  .find (".jstree-anchor")
1924
1951
  .removeAttr ("href")
1925
1952
  .removeAttr ("tabindex")
1953
+ .on ("click", this .selectNone .bind (this));
1926
1954
 
1927
1955
  child .find (".node")
1928
- .on ("dblclick", this .activateNode .bind (this))
1956
+ .on ("dblclick", this .activateNode .bind (this));
1929
1957
 
1930
1958
  child .find (".jstree-ocl")
1931
1959
  .addClass ("material-icons")
1932
1960
  .text ("arrow_right")
1933
1961
  .on ("click", this .selectExpander .bind (this))
1934
- .on ("dblclick", this .activateExpander .bind (this))
1962
+ .on ("dblclick", this .activateExpander .bind (this));
1935
1963
 
1936
1964
  child .find (".jstree-node")
1937
1965
  .wrapInner ("<div class=\"item no-select\"/>")
1938
- .find (".item") .append ("<div class=\"route-curves-wrapper\"><canvas class=\"route-curves\"></canvas></div>")
1966
+ .find (".item") .append ("<div class=\"route-curves-wrapper\"><canvas class=\"route-curves\"></canvas></div>");
1939
1967
 
1940
1968
  if (this .isEditable (parent))
1941
1969
  {
1942
1970
  child .find (".node:not([node-id=NULL]) > .item")
1943
1971
  .attr ("draggable", "true")
1944
- .on ("dragstart", this .onDragStartNode .bind (this))
1972
+ .on ("dragstart", this .onDragStartNode .bind (this));
1945
1973
  }
1946
1974
 
1975
+ child .find (".node .name, .node .icon")
1976
+ .on ("click", this .selectNode .bind (this));
1977
+
1947
1978
  child .find (".node .name")
1948
1979
  .on ("mouseenter", this .updateNodeTitle .bind (this));
1949
1980
 
1950
1981
  child .find (".toggle-visibility")
1951
- .on ("click", this .toggleVisibility .bind (this))
1982
+ .on ("click", this .toggleVisibility .bind (this));
1952
1983
 
1953
1984
  child .find (".toggle-tool")
1954
- .on ("click", this .toggleTool .bind (this))
1985
+ .on ("click", this .toggleTool .bind (this));
1955
1986
 
1956
1987
  child .find (".activate-layer")
1957
1988
  .on ("click", this .activateLayer .bind (this));
1958
1989
 
1959
1990
  child .find (".bind-node")
1960
- .on ("click", this .bindNode .bind (this))
1991
+ .on ("click", this .bindNode .bind (this));
1961
1992
 
1962
1993
  child .find (".reload-node")
1963
- .on ("click", this .reloadNode .bind (this))
1994
+ .on ("click", this .reloadNode .bind (this));
1995
+
1996
+ child .find (".show-preview")
1997
+ .on ("click", this .showPreview .bind (this));
1964
1998
 
1965
1999
  child .find ("area.input-selector")
1966
2000
  .on ("mouseenter", this .hoverInSingleConnector .bind (this, "input"))
1967
2001
  .on ("mouseleave", this .hoverOutSingleConnector .bind (this, "input"))
1968
- .on ("click", this .selectSingleConnector .bind (this, "input"))
2002
+ .on ("click", this .selectSingleConnector .bind (this, "input"));
1969
2003
 
1970
2004
  child .find ("area.output-selector")
1971
2005
  .on ("mouseenter", this .hoverInSingleConnector .bind (this, "output"))
1972
2006
  .on ("mouseleave", this .hoverOutSingleConnector .bind (this, "output"))
1973
- .on ("click", this .selectSingleConnector .bind (this, "output"))
2007
+ .on ("click", this .selectSingleConnector .bind (this, "output"));
1974
2008
 
1975
2009
  child .find ("area.input-routes-selector")
1976
- .on ("click", this .selectSingleRoute .bind (this, "input"))
2010
+ .on ("click", this .selectSingleRoute .bind (this, "input"));
1977
2011
 
1978
2012
  child .find ("area.output-routes-selector")
1979
- .on ("click", this .selectSingleRoute .bind (this, "output"))
2013
+ .on ("click", this .selectSingleRoute .bind (this, "output"));
1980
2014
 
1981
2015
  // Expand children.
1982
2016
 
1983
- const elements = child .find (".node")
2017
+ const elements = child .find (".node");
1984
2018
 
1985
- child .show ()
1986
- this .expandMFNodeComplete (elements, field)
2019
+ child .show ();
2020
+ this .expandMFNodeComplete (elements, field);
1987
2021
  }
1988
2022
 
1989
2023
  expandMFNodeComplete (elements, field)
@@ -2031,7 +2065,6 @@ module .exports = class OutlineView extends Interface
2031
2065
  .off ("keypress.jstree dblclick.jstree")
2032
2066
  .on ("before_open.jstree", this .nodeBeforeOpen .bind (this))
2033
2067
  .on ("close_node.jstree", this .nodeCloseNode .bind (this))
2034
- .on ("select_node.jstree", this .selectNode .bind (this))
2035
2068
  .appendTo (parent)
2036
2069
  .hide ();
2037
2070
 
@@ -2039,7 +2072,8 @@ module .exports = class OutlineView extends Interface
2039
2072
  .removeAttr ("tabindex")
2040
2073
  .find (".jstree-anchor")
2041
2074
  .removeAttr ("href")
2042
- .removeAttr ("tabindex");
2075
+ .removeAttr ("tabindex")
2076
+ .on ("click", this .selectNone .bind (this));
2043
2077
 
2044
2078
  child .find (".node")
2045
2079
  .on ("dblclick", this .activateNode .bind (this));
@@ -2061,6 +2095,9 @@ module .exports = class OutlineView extends Interface
2061
2095
  .on ("dragstart", this .onDragStartNode .bind (this));
2062
2096
  }
2063
2097
 
2098
+ child .find (".node .name, .node .icon")
2099
+ .on ("click", this .selectNode .bind (this));
2100
+
2064
2101
  child .find (".node .name")
2065
2102
  .on ("mouseenter", this .updateNodeTitle .bind (this));
2066
2103
 
@@ -2079,6 +2116,9 @@ module .exports = class OutlineView extends Interface
2079
2116
  child .find (".reload-node")
2080
2117
  .on ("click", this .reloadNode .bind (this));
2081
2118
 
2119
+ child .find (".show-preview")
2120
+ .on ("click", this .showPreview .bind (this));
2121
+
2082
2122
  child .find ("area.input-selector")
2083
2123
  .on ("mouseenter", this .hoverInSingleConnector .bind (this, "input"))
2084
2124
  .on ("mouseleave", this .hoverOutSingleConnector .bind (this, "input"))
@@ -2126,18 +2166,18 @@ module .exports = class OutlineView extends Interface
2126
2166
  this .requestUpdateRouteGraph ();
2127
2167
  }
2128
2168
 
2129
- nodeIcons = {
2130
- "proto": "Prototype",
2131
- "externproto": "ExternProto",
2132
- "node": "X3DBaseNode",
2133
- "imported-node": "ImportedNode",
2134
- "exported-node": "ExportedNode",
2135
- };
2169
+ nodeIcons = new Map ([
2170
+ ["proto", "Prototype"],
2171
+ ["externproto", "ExternProto"],
2172
+ ["node", "X3DBaseNode"],
2173
+ ["imported-node", "ImportedNode"],
2174
+ ["exported-node", "ExportedNode"],
2175
+ ]);
2136
2176
 
2137
- typeNames = {
2138
- "X3DExternProtoDeclaration": "EXTERNPROTO",
2139
- "X3DProtoDeclaration": "PROTO",
2140
- };
2177
+ typeNames = new Map ([
2178
+ ["X3DExternProtoDeclaration", "EXTERNPROTO"],
2179
+ ["X3DProtoDeclaration", "PROTO",]
2180
+ ]);
2141
2181
 
2142
2182
  expandSingleField (parent, node, field, type, full)
2143
2183
  {
@@ -2168,7 +2208,6 @@ module .exports = class OutlineView extends Interface
2168
2208
  child
2169
2209
  .jstree ()
2170
2210
  .off ("keypress.jstree dblclick.jstree")
2171
- .on ("select_node.jstree", this .selectField .bind (this))
2172
2211
  .appendTo (parent)
2173
2212
  .hide ();
2174
2213
 
@@ -2291,7 +2330,6 @@ module .exports = class OutlineView extends Interface
2291
2330
  child
2292
2331
  .jstree ()
2293
2332
  .off ("keypress.jstree dblclick.jstree")
2294
- .on ("select_node.jstree", this .selectField .bind (this))
2295
2333
  .appendTo (parent)
2296
2334
  .hide ()
2297
2335
 
@@ -2737,15 +2775,16 @@ module .exports = class OutlineView extends Interface
2737
2775
 
2738
2776
  closeNode (element)
2739
2777
  {
2740
- element .find (".jstree-ocl") .text ("arrow_right");
2741
- element .data ("expanded", false);
2742
- element .data ("full-expanded", false);
2778
+ element
2779
+ .data ("expanded", false)
2780
+ .data ("full-expanded", false);
2781
+
2782
+ element.find (".jstree-ocl") .text ("arrow_right");
2743
2783
 
2744
2784
  // Collapse children.
2745
2785
 
2746
- const child = element .find ("> .subtree");
2786
+ element .find ("> .subtree") .hide ();
2747
2787
 
2748
- child .hide ();
2749
2788
  this .afterClose (element);
2750
2789
  }
2751
2790
 
@@ -2803,6 +2842,8 @@ module .exports = class OutlineView extends Interface
2803
2842
  node .getLoadState () .removeFieldCallback (this .#updateNodeSymbol);
2804
2843
  });
2805
2844
 
2845
+ element .find (".node [data-hasqtip]") .qtip ?.("hide") .qtip ("destroy", true);
2846
+
2806
2847
  element .find (".node:not([node-id=NULL]), .exported-node")
2807
2848
  .addBack (".node:not([node-id=NULL]), .exported-node") .each ((i, e) =>
2808
2849
  {
@@ -2907,7 +2948,7 @@ module .exports = class OutlineView extends Interface
2907
2948
  const elements = this .sceneGraph .find ("> .root-nodes > ul > li[node-id]");
2908
2949
 
2909
2950
  for (const element of elements)
2910
- this .selectNodeElement ($(element), true);
2951
+ this .selectNodeElement ($(element));
2911
2952
  }
2912
2953
 
2913
2954
  deselectAll ()
@@ -2921,17 +2962,89 @@ module .exports = class OutlineView extends Interface
2921
2962
  selection .clear ();
2922
2963
  }
2923
2964
 
2924
- toggleVisibility (event)
2965
+ showPreview (event)
2925
2966
  {
2967
+ const
2968
+ icon = $(event .currentTarget) ,
2969
+ item = icon .closest (".item", this .sceneGraph),
2970
+ element = icon .closest (".node", this .sceneGraph),
2971
+ node = this .objects .get (parseInt (element .attr ("node-id"))),
2972
+ on = !!item .attr ("data-hasqtip");
2973
+
2926
2974
  event .preventDefault ();
2927
2975
  event .stopImmediatePropagation ();
2928
2976
 
2977
+ $("[data-hasqtip]") .qtip ?.("hide") .qtip ("destroy", true);
2978
+ $(".show-preview.on") .removeClass ("on") .addClass ("off");
2979
+
2980
+ if (on)
2981
+ return;
2982
+
2983
+ icon .removeClass ("off") .addClass ("on");
2984
+
2985
+ // Handle NULL node element.
2986
+ if (!node)
2987
+ return;
2988
+
2989
+ for (const type of node .getType () .toReversed ())
2990
+ {
2991
+ switch (type)
2992
+ {
2993
+ case X3D .X3DConstants .AudioClip:
2994
+ case X3D .X3DConstants .BufferAudioSource:
2995
+ {
2996
+ require ("../Controls/AudioPreviewPopover");
2997
+
2998
+ item .audioPreviewPopover (node);
2999
+ break;
3000
+ }
3001
+ case X3D .X3DConstants .GeneratedCubeMapTexture:
3002
+ {
3003
+ break;
3004
+ }
3005
+ case X3D .X3DConstants .MovieTexture:
3006
+ {
3007
+ if (!(node .getMediaElement () instanceof HTMLVideoElement))
3008
+ continue;
3009
+
3010
+ require ("../Controls/VideoPreviewPopover");
3011
+
3012
+ item .videoPreviewPopover (node);
3013
+ break;
3014
+ }
3015
+ case X3D .X3DConstants .X3DMaterialNode:
3016
+ {
3017
+ require ("../Controls/MaterialPreviewPopover");
3018
+
3019
+ item .materialPreviewPopover (node);
3020
+ break;
3021
+ }
3022
+ case X3D .X3DConstants .X3DSingleTextureNode:
3023
+ {
3024
+ require ("../Controls/TexturePreviewPopover");
3025
+
3026
+ item .texturePreviewPopover (node);
3027
+ break;
3028
+ }
3029
+ default:
3030
+ continue;
3031
+ }
3032
+
3033
+ break;
3034
+ }
3035
+ }
3036
+
3037
+ toggleVisibility (event)
3038
+ {
2929
3039
  const
2930
3040
  target = $(event .target),
2931
3041
  element = target .closest (".node", this .sceneGraph),
2932
3042
  node = this .getNode (element),
2933
3043
  hidden = !node .isHidden ();
2934
3044
 
3045
+ event .preventDefault ();
3046
+ event .stopImmediatePropagation ();
3047
+
2935
3048
  node .setHidden (hidden);
2936
3049
 
2937
3050
  this .sceneGraph .find (`.node[node-id=${node .getId ()}]`)
@@ -2943,15 +3056,15 @@ module .exports = class OutlineView extends Interface
2943
3056
 
2944
3057
  toggleTool (event)
2945
3058
  {
2946
- event .preventDefault ();
2947
- event .stopImmediatePropagation ();
2948
-
2949
3059
  const
2950
3060
  target = $(event .target),
2951
3061
  element = target .closest (".node", this .sceneGraph),
2952
3062
  node = this .getNode (element),
2953
3063
  tool = node .getTool ();
2954
3064
 
3065
+ event .preventDefault ();
3066
+ event .stopImmediatePropagation ();
3067
+
2955
3068
  if (tool)
2956
3069
  {
2957
3070
  tool .removeTool ("createOnDemand");
@@ -2973,31 +3086,38 @@ module .exports = class OutlineView extends Interface
2973
3086
 
2974
3087
  bindNode (event)
2975
3088
  {
2976
- event .preventDefault ();
2977
- event .stopImmediatePropagation ();
2978
-
2979
3089
  const
2980
3090
  target = $(event .target),
2981
3091
  element = target .closest (".node", this .sceneGraph),
2982
3092
  node = this .getNode (element);
2983
3093
 
3094
+ event .preventDefault ();
3095
+ event .stopImmediatePropagation ();
3096
+
2984
3097
  node ._set_bind = true;
2985
3098
  }
2986
3099
 
2987
3100
  reloadNode (event)
2988
3101
  {
2989
- event .preventDefault ();
2990
- event .stopImmediatePropagation ();
2991
-
2992
3102
  const
2993
3103
  target = $(event .target),
2994
3104
  element = target .closest (".node, .externproto", this .sceneGraph),
3105
+ item = target .closest (".item"),
2995
3106
  node = this .getNode (element);
2996
3107
 
3108
+ event .preventDefault ();
3109
+ event .stopImmediatePropagation ();
3110
+
2997
3111
  if (node ._load .getValue ())
3112
+ {
2998
3113
  node .loadNow () .catch (Function .prototype);
3114
+ item .data ("preview") ?.loadNow () .catch (Function .prototype);
3115
+ }
2999
3116
  else
3117
+ {
3000
3118
  node .unloadNow ();
3119
+ item .data ("preview") ?.unloadNow ();
3120
+ }
3001
3121
  }
3002
3122
 
3003
3123
  hideUnselectedObjects ()
@@ -3076,16 +3196,28 @@ module .exports = class OutlineView extends Interface
3076
3196
  })
3077
3197
  }
3078
3198
 
3079
- selectNode (event, selected)
3199
+ selectNone (event)
3080
3200
  {
3081
- // Click on node.
3201
+ event .preventDefault ();
3202
+ event .stopImmediatePropagation ();
3203
+
3204
+ // Hide color editor.
3205
+ $(document) .trigger ("click");
3206
+ }
3207
+
3208
+ selectNode (event)
3209
+ {
3210
+ event .preventDefault ();
3211
+ event .stopImmediatePropagation ();
3082
3212
 
3083
- selected .instance .deselect_node (selected .node);
3213
+ $(document) .trigger ("click");
3214
+
3215
+ // Click on node.
3084
3216
 
3085
3217
  this .clearConnectors ();
3086
3218
 
3087
3219
  const
3088
- element = $("#" + selected .node .id),
3220
+ element = $(event .currentTarget) .closest (".node, .externproto, .proto"),
3089
3221
  add = window .event .shiftKey || window .event .metaKey;
3090
3222
 
3091
3223
  if (element .hasClass ("node"))
@@ -3171,17 +3303,20 @@ module .exports = class OutlineView extends Interface
3171
3303
  element .addClass (["primary", "manually"]);
3172
3304
  }
3173
3305
 
3174
- selectField (event, selected)
3306
+ selectField (event)
3175
3307
  {
3176
- // Click on field.
3308
+ event .preventDefault ();
3309
+ event .stopImmediatePropagation ();
3177
3310
 
3178
- selected .instance .deselect_node (selected .node);
3311
+ $(document) .trigger ("click");
3312
+
3313
+ // Click on field.
3179
3314
 
3180
3315
  this .clearConnectors ();
3181
3316
 
3182
3317
  // Make primary selection from user defined field.
3183
3318
 
3184
- const element = $(`#${selected .node .id}`);
3319
+ const element = $(event .currentTarget) .closest (".field, .special");
3185
3320
 
3186
3321
  if (!element .hasClass ("field"))
3187
3322
  return;
@@ -3189,10 +3324,20 @@ module .exports = class OutlineView extends Interface
3189
3324
  this .selectPrimaryElement (element);
3190
3325
  }
3191
3326
 
3192
- selectExpander ()
3327
+ selectExpander (event)
3193
3328
  {
3194
3329
  // Click on expander.
3195
3330
 
3331
+ const element = $(event .currentTarget) .closest (".jstree-node");
3332
+
3333
+ event .preventDefault ();
3334
+ event .stopImmediatePropagation ();
3335
+
3336
+ if (element .jstree ("is_closed", element))
3337
+ element .jstree ("open_node", element);
3338
+ else
3339
+ element .jstree ("close_node", element);
3340
+
3196
3341
  this .treeView .trigger ("focus");
3197
3342
  }
3198
3343