sunrize 2.4.0 → 2.4.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sunrize",
3
3
  "productName": "Sunrize X3D Editor",
4
- "version": "2.4.0",
4
+ "version": "2.4.1",
5
5
  "description": "Sunrize — A Multi-Platform X3D Editor",
6
6
  "main": "src/main.js",
7
7
  "bin": {
@@ -118,7 +118,7 @@
118
118
  "string-similarity": "^4.0.4",
119
119
  "tweakpane": "^4.0.5",
120
120
  "update-electron-app": "^3.3.0",
121
- "x_ite": "^16.4.2",
121
+ "x_ite": "^16.4.3",
122
122
  "x_ite-off-parser": "^1.3.0",
123
123
  "x_ite-sog-parser": "^2.1.0",
124
124
  "x_ite-spz-parser": "^2.1.0",
@@ -416,7 +416,6 @@ module .exports = class AnimationEditor extends Interface
416
416
 
417
417
  this .setSelection (require ("../Application/Selection"));
418
418
  this .zoomFit ();
419
- this .resizeTimeline ();
420
419
  this .requestDrawTimeline ();
421
420
 
422
421
  this .browser .nextFrame () .then (() => this .setCurrentFrame (0));
@@ -2859,190 +2858,190 @@ module .exports = class AnimationEditor extends Interface
2859
2858
  context .scale (contentScale, contentScale);
2860
2859
  context .clearRect (0, 0, tracksWidth, tracksHeight);
2861
2860
 
2862
- if (!this .animation)
2863
- return;
2864
-
2865
- const
2866
- left = this .getLeft (),
2867
- width = this .getWidth (),
2868
- translation = this .getTranslation (),
2869
- scale = this .getScale (),
2870
- trackOffsets = this .memberList .getTrackOffsets (),
2871
- firstFrame = Math .max (0, Math .floor (-translation / scale)),
2872
- lastFrame = Math .min (this .getDuration (), Math .ceil ((width - translation) / scale)) + 1;
2873
-
2874
- const [frameStep, frameFactor] = this .getFrameParams ();
2875
-
2876
- const
2877
- blue = this .#style .getPropertyValue ("--system-blue"),
2878
- indigo = this .#style .getPropertyValue ("--system-indigo"),
2879
- orange = this .#style .getPropertyValue ("--system-orange"),
2880
- brown = this .#style .getPropertyValue ("--system-brown"),
2881
- red = this .#style .getPropertyValue ("--system-red"),
2882
- range = this .#style .getPropertyValue ("--selection-range"),
2883
- tint1 = this .#style .getPropertyValue ("--tint-color1"),
2884
- tint2 = this .#style .getPropertyValue ("--tint-color2");
2861
+ if (this .animation)
2862
+ {
2863
+ const
2864
+ left = this .getLeft (),
2865
+ width = this .getWidth (),
2866
+ translation = this .getTranslation (),
2867
+ scale = this .getScale (),
2868
+ trackOffsets = this .memberList .getTrackOffsets (),
2869
+ firstFrame = Math .max (0, Math .floor (-translation / scale)),
2870
+ lastFrame = Math .min (this .getDuration (), Math .ceil ((width - translation) / scale)) + 1;
2885
2871
 
2886
- // Draw selection range.
2872
+ const [frameStep, frameFactor] = this .getFrameParams ();
2887
2873
 
2888
- context .save ();
2889
- context .clip (this .timelineClip);
2874
+ const
2875
+ blue = this .#style .getPropertyValue ("--system-blue"),
2876
+ indigo = this .#style .getPropertyValue ("--system-indigo"),
2877
+ orange = this .#style .getPropertyValue ("--system-orange"),
2878
+ brown = this .#style .getPropertyValue ("--system-brown"),
2879
+ red = this .#style .getPropertyValue ("--system-red"),
2880
+ range = this .#style .getPropertyValue ("--selection-range"),
2881
+ tint1 = this .#style .getPropertyValue ("--tint-color1"),
2882
+ tint2 = this .#style .getPropertyValue ("--tint-color2");
2890
2883
 
2891
- const selectionRange = this .getSelectionRange ();
2884
+ // Draw selection range.
2892
2885
 
2893
- if (selectionRange [0] !== selectionRange [1])
2894
- {
2895
- const minFrame = X3D .Algorithm .clamp (selectionRange [0], firstFrame, lastFrame - 1);
2896
- const maxFrame = X3D .Algorithm .clamp (selectionRange [1], firstFrame, lastFrame - 1);
2897
- const x0 = left + minFrame * scale + translation;
2898
- const x1 = left + maxFrame * scale + translation;
2886
+ context .save ();
2887
+ context .clip (this .timelineClip);
2899
2888
 
2900
- context .fillStyle = range;
2889
+ const selectionRange = this .getSelectionRange ();
2901
2890
 
2902
- context .fillRect (Math .min (x0, x1) - 1, 0, Math .abs (x1 - x0) + 3, tracksHeight);
2903
- }
2891
+ if (selectionRange [0] !== selectionRange [1])
2892
+ {
2893
+ const minFrame = X3D .Algorithm .clamp (selectionRange [0], firstFrame, lastFrame - 1);
2894
+ const maxFrame = X3D .Algorithm .clamp (selectionRange [1], firstFrame, lastFrame - 1);
2895
+ const x0 = left + minFrame * scale + translation;
2896
+ const x1 = left + maxFrame * scale + translation;
2904
2897
 
2905
- context .restore ();
2898
+ context .fillStyle = range;
2906
2899
 
2907
- // Draw all tracks.
2900
+ context .fillRect (Math .min (x0, x1) - 1, 0, Math .abs (x1 - x0) + 3, tracksHeight);
2901
+ }
2908
2902
 
2909
- for (const [i, { item, top, bottom, height }] of trackOffsets .entries ())
2910
- {
2911
- // Track
2903
+ context .restore ();
2912
2904
 
2913
- const odd = item .data ("i") % 2;
2905
+ // Draw all tracks.
2914
2906
 
2915
- if (odd || i === 0)
2907
+ for (const [i, { item, top, bottom, height }] of trackOffsets .entries ())
2916
2908
  {
2917
- // Draw a line below last field.
2909
+ // Track
2918
2910
 
2919
- if (trackOffsets [i + 1] ?.item .hasClass ("node") ?? true)
2911
+ const odd = item .data ("i") % 2;
2912
+
2913
+ if (odd || i === 0)
2920
2914
  {
2921
- context .fillStyle = tint2;
2915
+ // Draw a line below last field.
2922
2916
 
2923
- context .fillRect (0, bottom - 1, tracksWidth, 1);
2924
- }
2925
- }
2926
- else if (item .hasClass ("field"))
2927
- {
2928
- // Draw a bar.
2917
+ if (trackOffsets [i + 1] ?.item .hasClass ("node") ?? true)
2918
+ {
2919
+ context .fillStyle = tint2;
2929
2920
 
2930
- context .fillStyle = tint1;
2921
+ context .fillRect (0, bottom - 1, tracksWidth, 1);
2922
+ }
2923
+ }
2924
+ else if (item .hasClass ("field"))
2925
+ {
2926
+ // Draw a bar.
2931
2927
 
2932
- context .fillRect (0, top, tracksWidth, height);
2933
- }
2928
+ context .fillStyle = tint1;
2934
2929
 
2935
- // Highlight track on hover.
2930
+ context .fillRect (0, top, tracksWidth, height);
2931
+ }
2936
2932
 
2937
- const hover = this .pointer .y > top && this .pointer .y < bottom;
2933
+ // Highlight track on hover.
2938
2934
 
2939
- if (hover)
2940
- item .addClass ("hover-track");
2941
- else
2942
- item .removeClass ("hover-track");
2935
+ const hover = this .pointer .y > top && this .pointer .y < bottom;
2943
2936
 
2944
- if (item .is (".hover, .hover-tracks") || hover)
2945
- {
2946
- context .fillStyle = tint2;
2937
+ if (hover)
2938
+ item .addClass ("hover-track");
2939
+ else
2940
+ item .removeClass ("hover-track");
2947
2941
 
2948
- context .fillRect (0, top, tracksWidth, height);
2949
- }
2942
+ if (item .is (".hover, .hover-tracks") || hover)
2943
+ {
2944
+ context .fillStyle = tint2;
2950
2945
 
2951
- // Frames
2946
+ context .fillRect (0, top, tracksWidth, height);
2947
+ }
2952
2948
 
2953
- context .save ();
2954
- context .clip (this .timelineClip);
2949
+ // Frames
2955
2950
 
2956
- // Draw vertical lines.
2951
+ context .save ();
2952
+ context .clip (this .timelineClip);
2957
2953
 
2958
- context .strokeStyle = item .hasClass ("main") ? indigo : blue;
2959
- context .lineWidth = item .is (".main, .node") ? 3 : 1;
2954
+ // Draw vertical lines.
2960
2955
 
2961
- for (let frame = firstFrame - (firstFrame % frameStep); frame < lastFrame; frame += frameStep)
2962
- {
2963
- const s = frame % frameFactor; // size (large or small)
2964
- const y = Math .floor (top + height * (s ? 0.75 : 0.5));
2965
- const x = Math .floor (left + this .getPointerFromFrame (frame));
2956
+ context .strokeStyle = item .hasClass ("main") ? indigo : blue;
2957
+ context .lineWidth = item .is (".main, .node") ? 3 : 1;
2966
2958
 
2967
- context .beginPath ();
2968
- context .moveTo (x + 0.5, y - this .TRACK_PADDING);
2969
- context .lineTo (x + 0.5, bottom - this .TRACK_PADDING);
2970
- context .stroke ();
2971
- }
2959
+ for (let frame = firstFrame - (firstFrame % frameStep); frame < lastFrame; frame += frameStep)
2960
+ {
2961
+ const s = frame % frameFactor; // size (large or small)
2962
+ const y = Math .floor (top + height * (s ? 0.75 : 0.5));
2963
+ const x = Math .floor (left + this .getPointerFromFrame (frame));
2964
+
2965
+ context .beginPath ();
2966
+ context .moveTo (x + 0.5, y - this .TRACK_PADDING);
2967
+ context .lineTo (x + 0.5, bottom - this .TRACK_PADDING);
2968
+ context .stroke ();
2969
+ }
2972
2970
 
2973
- // Draw keyframes.
2971
+ // Draw keyframes.
2974
2972
 
2975
- switch (item .attr ("type"))
2976
- {
2977
- case "main":
2973
+ switch (item .attr ("type"))
2978
2974
  {
2979
- for (const field of this .fields .keys ())
2980
- this .drawKeyframes (context, field, firstFrame, lastFrame, bottom - this .TRACK_PADDING, brown);
2975
+ case "main":
2976
+ {
2977
+ for (const field of this .fields .keys ())
2978
+ this .drawKeyframes (context, field, firstFrame, lastFrame, bottom - this .TRACK_PADDING, brown);
2981
2979
 
2982
- break;
2983
- }
2984
- case "node":
2985
- {
2986
- const node = item .data ("node");
2980
+ break;
2981
+ }
2982
+ case "node":
2983
+ {
2984
+ const node = item .data ("node");
2987
2985
 
2988
- for (const field of node .getFields ())
2989
- this .drawKeyframes (context, field, firstFrame, lastFrame, bottom - this .TRACK_PADDING, brown);
2986
+ for (const field of node .getFields ())
2987
+ this .drawKeyframes (context, field, firstFrame, lastFrame, bottom - this .TRACK_PADDING, brown);
2990
2988
 
2991
- break;
2992
- }
2993
- case "field":
2994
- {
2995
- this .drawKeyframes (context, item .data ("field"), firstFrame, lastFrame, bottom - this .TRACK_PADDING, orange);
2996
- break;
2989
+ break;
2990
+ }
2991
+ case "field":
2992
+ {
2993
+ this .drawKeyframes (context, item .data ("field"), firstFrame, lastFrame, bottom - this .TRACK_PADDING, orange);
2994
+ break;
2995
+ }
2997
2996
  }
2998
- }
2999
2997
 
3000
- // Draw selected keyframes.
2998
+ // Draw selected keyframes.
3001
2999
 
3002
- switch (item .attr ("type"))
3003
- {
3004
- case "main":
3000
+ switch (item .attr ("type"))
3005
3001
  {
3006
- const fields = new Set (this .fields .keys ());
3002
+ case "main":
3003
+ {
3004
+ const fields = new Set (this .fields .keys ());
3007
3005
 
3008
- this .drawSelectedKeyframes (context, fields, bottom - this .TRACK_PADDING, red);
3009
- break;
3010
- }
3011
- case "node":
3012
- {
3013
- const
3014
- node = item .data ("node"),
3015
- fields = new Set (node .getFields ());
3006
+ this .drawSelectedKeyframes (context, fields, bottom - this .TRACK_PADDING, red);
3007
+ break;
3008
+ }
3009
+ case "node":
3010
+ {
3011
+ const
3012
+ node = item .data ("node"),
3013
+ fields = new Set (node .getFields ());
3016
3014
 
3017
- this .drawSelectedKeyframes (context, fields, bottom - this .TRACK_PADDING, red);
3018
- break;
3019
- }
3020
- case "field":
3021
- {
3022
- const fields = new Set ([item .data ("field")]);
3015
+ this .drawSelectedKeyframes (context, fields, bottom - this .TRACK_PADDING, red);
3016
+ break;
3017
+ }
3018
+ case "field":
3019
+ {
3020
+ const fields = new Set ([item .data ("field")]);
3023
3021
 
3024
- this .drawSelectedKeyframes (context, fields, bottom - this .TRACK_PADDING, red);
3025
- break;
3022
+ this .drawSelectedKeyframes (context, fields, bottom - this .TRACK_PADDING, red);
3023
+ break;
3024
+ }
3026
3025
  }
3027
- }
3028
3026
 
3029
- context .restore ();
3030
- }
3027
+ context .restore ();
3028
+ }
3031
3029
 
3032
- // Draw current frame cursor.
3030
+ // Draw current frame cursor.
3033
3031
 
3034
- context .save ();
3035
- context .clip (this .timelineClip);
3032
+ context .save ();
3033
+ context .clip (this .timelineClip);
3036
3034
 
3037
- const frame = this .getCurrentFrame ();
3038
- const x = Math .floor (left + this .getPointerFromFrame (frame));
3035
+ const frame = this .getCurrentFrame ();
3036
+ const x = Math .floor (left + this .getPointerFromFrame (frame));
3039
3037
 
3040
- context .fillStyle = blue;
3038
+ context .fillStyle = blue;
3041
3039
 
3042
- context .fillRect (x - 1, 0, 3, tracksHeight);
3040
+ context .fillRect (x - 1, 0, 3, tracksHeight);
3041
+ context .restore ();
3042
+ }
3043
3043
 
3044
3044
  context .restore ();
3045
- context .restore ();
3046
3045
  }
3047
3046
 
3048
3047
  #defaultIntegers = new X3D .MFInt32 ();
@@ -1124,11 +1124,11 @@ module .exports = class RouteGraph extends Interface
1124
1124
  if (node .getExecutionContext () !== executionContext)
1125
1125
  return;
1126
1126
 
1127
- this .setNode (node);
1128
-
1129
1127
  nodes .add (node);
1130
1128
  columns .getOrInsert (index, [ ]) .push (node);
1131
1129
 
1130
+ this .setNode (node);
1131
+
1132
1132
  for (const field of node .getFields ())
1133
1133
  {
1134
1134
  for (const route of field .getInputRoutes ())
@@ -1325,10 +1325,10 @@ module .exports = class RouteGraph extends Interface
1325
1325
  for (const field of node .getFields ())
1326
1326
  {
1327
1327
  for (const route of field .getInputRoutes ())
1328
- this .clearRouteSelection (route);
1328
+ this .removeRouteSelection (route);
1329
1329
 
1330
1330
  for (const route of field .getOutputRoutes ())
1331
- this .clearRouteSelection (route);
1331
+ this .removeRouteSelection (route);
1332
1332
  }
1333
1333
  }
1334
1334
 
@@ -1872,20 +1872,24 @@ module .exports = class RouteGraph extends Interface
1872
1872
  }
1873
1873
 
1874
1874
  #pointer = new X3D .Vector2 ();
1875
+ #pointerState = false;
1875
1876
 
1876
1877
  mouseMove (event)
1877
1878
  {
1878
1879
  this .#pointer = this .getRelativePosition (event, false);
1879
1880
 
1880
- if (this .#input || this .#output)
1881
- this .updateCanvas ();
1882
- }
1881
+ const state = this .#input || this .#output || this .findRoute (event);
1883
1882
 
1884
- selectRoute (event, deleteRoute)
1885
- {
1886
- if (event .button !== 0)
1883
+ if (!(state || this .#pointerState))
1887
1884
  return;
1888
1885
 
1886
+ this .#pointerState = state;
1887
+
1888
+ this .updateCanvas ();
1889
+ }
1890
+
1891
+ findRoute (event)
1892
+ {
1889
1893
  const
1890
1894
  page = this .page,
1891
1895
  scale = page .scale,
@@ -1932,39 +1936,48 @@ module .exports = class RouteGraph extends Interface
1932
1936
  arrow = this .getRouteArrow (new X3D .Vector2 (x0, y0), new X3D .Vector2 (x3, y3), arrowRotation, scale);
1933
1937
 
1934
1938
  if (X3D .Triangle2 .isPointInTriangle (pointer, ... arrow))
1935
- {
1936
- if (deleteRoute)
1937
- {
1938
- Editor .deleteRoute (route .getExecutionContext (), route .sourceNode, route .sourceField, route .destinationNode, route .destinationField);
1939
-
1940
- this .removeRouteSelection (route);
1941
- }
1942
- else
1943
- {
1944
- if (event .shiftKey)
1945
- {
1946
- if (this .isRouteSelected (route))
1947
- this .removeRouteSelection (route);
1948
- else
1949
- this .addRouteSelection (route);
1950
- }
1951
- else
1952
- {
1953
- this .setRouteSelection (route);
1954
- }
1955
- }
1956
-
1957
- // Only select or delete one route.
1958
- return;
1959
- }
1939
+ return route;
1960
1940
  }
1961
1941
  }
1962
1942
  }
1963
1943
  }
1964
1944
 
1945
+ selectRoute (event)
1946
+ {
1947
+ if (event .button !== 0)
1948
+ return;
1949
+
1950
+ const route = this .findRoute (event);
1951
+
1952
+ if (!route)
1953
+ return;
1954
+
1955
+ if (event .shiftKey)
1956
+ {
1957
+ if (this .isRouteSelected (route))
1958
+ this .removeRouteSelection (route);
1959
+ else
1960
+ this .addRouteSelection (route);
1961
+ }
1962
+ else
1963
+ {
1964
+ this .setRouteSelection (route);
1965
+ }
1966
+ }
1967
+
1965
1968
  deleteRoute (event)
1966
1969
  {
1967
- this .selectRoute (event, true);
1970
+ if (event .button !== 0)
1971
+ return;
1972
+
1973
+ const route = this .findRoute (event);
1974
+
1975
+ if (!route)
1976
+ return;
1977
+
1978
+ this .removeRouteSelection (route);
1979
+
1980
+ Editor .deleteRoute (route .getExecutionContext (), route .sourceNode, route .sourceField, route .destinationNode, route .destinationField);
1968
1981
  }
1969
1982
 
1970
1983
  selectAllRoutes ()
@@ -1996,7 +2009,7 @@ module .exports = class RouteGraph extends Interface
1996
2009
  {
1997
2010
  UndoManager .shared .beginUndo (_("Delete Selected Routes"));
1998
2011
 
1999
- for (const route of this .#selectedRoutes)
2012
+ for (const route of Array .from (this .#selectedRoutes))
2000
2013
  {
2001
2014
  Editor .deleteRoute (route .getExecutionContext (), route .sourceNode, route .sourceField, route .destinationNode, route .destinationField);
2002
2015
  }
@@ -37,11 +37,15 @@ class GridTool extends X3DGridNodeTool
37
37
 
38
38
  getSnapPositionWithNormal (position, direction)
39
39
  {
40
+ const snapDistance = Math .abs (this .tool .snapDistance);
41
+
40
42
  for (let i = 0; i < 3; ++ i)
41
43
  {
42
- const translation = this .getSnapPositionWithNormalForAxis (i, position, direction);
44
+ const
45
+ translation = this .getSnapPositionWithNormalForAxis (i, position, direction),
46
+ distance = translation .distance (position);
43
47
 
44
- if (translation .distance (position) < Math .abs (this .tool .snapDistance))
48
+ if (distance > snapDistance / 1000 && distance < snapDistance)
45
49
  return translation;
46
50
  }
47
51
 
@@ -364,7 +364,7 @@ class X3DGridNodeTool extends X3DActiveLayerNodeTool
364
364
  delta = after - before,
365
365
  ratio = after / before;
366
366
 
367
- // We must procced with the original current matrix and a snapping scale of [1 1 1], for correct grouped event handling.
367
+ // We must proceed with the original current matrix and a snapping scale of [1 1 1], for correct grouped event handling.
368
368
 
369
369
  if (Math .abs (delta) < MIN_DELTA || Math .abs (ratio) < MIN_RATIO || isNaN (ratio) || Math .abs (ratio) === Infinity)
370
370
  return currentMatrix;
@@ -1874,7 +1874,7 @@ html[platform=darwin] #route-graph .ui-tabs > .ui-tabs-nav li {
1874
1874
  .tree-view {
1875
1875
  overflow: scroll;
1876
1876
  box-sizing: border-box;
1877
- padding: 5px 10px;
1877
+ padding: 4px 10px;
1878
1878
  width: 100%;
1879
1879
  height: 100%;
1880
1880
  }