@woosh/meep-engine 2.131.35 → 2.131.36

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 (116) hide show
  1. package/build/bundle-worker-image-decoder.js +1 -1
  2. package/package.json +1 -1
  3. package/src/core/binary/BinaryBuffer.d.ts +14 -0
  4. package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
  5. package/src/core/binary/BinaryBuffer.js +27 -0
  6. package/src/core/binary/allocator/OffsetAllocator.d.ts +5 -0
  7. package/src/core/binary/allocator/OffsetAllocator.d.ts.map +1 -1
  8. package/src/core/binary/allocator/OffsetAllocator.js +6 -0
  9. package/src/core/geom/3d/aabb/AABB3.d.ts +14 -0
  10. package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
  11. package/src/core/geom/3d/aabb/AABB3.js +24 -0
  12. package/src/core/math/hash/computeHashFloatArray.d.ts +3 -2
  13. package/src/core/math/hash/computeHashFloatArray.d.ts.map +1 -1
  14. package/src/core/math/hash/computeHashFloatArray.js +2 -1
  15. package/src/core/process/undo/ActionProcessor.d.ts.map +1 -1
  16. package/src/core/process/undo/ActionProcessor.js +3 -1
  17. package/src/engine/animation/curve/actionProcessorOperations/applyActionChange.d.ts +34 -0
  18. package/src/engine/animation/curve/actionProcessorOperations/applyActionChange.d.ts.map +1 -0
  19. package/src/engine/animation/curve/actionProcessorOperations/applyActionChange.js +61 -0
  20. package/src/engine/animation/curve/actionProcessorOperations/curveActions.d.ts +107 -0
  21. package/src/engine/animation/curve/actionProcessorOperations/curveActions.d.ts.map +1 -0
  22. package/src/engine/animation/curve/actionProcessorOperations/curveActions.js +202 -0
  23. package/src/engine/animation/curve/compression/prototypeCurveCompression.js +24 -3
  24. package/src/engine/animation/curve/draw/buildReadOnlyDisplay.d.ts +3 -0
  25. package/src/engine/animation/curve/draw/buildReadOnlyDisplay.d.ts.map +1 -0
  26. package/src/engine/animation/curve/draw/buildReadOnlyDisplay.js +14 -0
  27. package/src/engine/animation/curve/draw/build_tangent_editor.d.ts +6 -1
  28. package/src/engine/animation/curve/draw/build_tangent_editor.d.ts.map +1 -1
  29. package/src/engine/animation/curve/draw/build_tangent_editor.js +220 -51
  30. package/src/engine/animation/curve/draw/displayMousePos.d.ts +7 -0
  31. package/src/engine/animation/curve/draw/displayMousePos.d.ts.map +1 -0
  32. package/src/engine/animation/curve/draw/displayMousePos.js +41 -0
  33. package/src/engine/animation/curve/draw/isInjectedKeyframeInBounds.d.ts +26 -0
  34. package/src/engine/animation/curve/draw/isInjectedKeyframeInBounds.d.ts.map +1 -0
  35. package/src/engine/animation/curve/draw/isInjectedKeyframeInBounds.js +93 -0
  36. package/src/engine/animation/curve/draw/position_canvas_to_curve.d.ts +12 -0
  37. package/src/engine/animation/curve/draw/position_canvas_to_curve.d.ts.map +1 -0
  38. package/src/engine/animation/curve/draw/position_canvas_to_curve.js +24 -0
  39. package/src/engine/animation/curve/draw/position_curve_to_canvas.d.ts +12 -0
  40. package/src/engine/animation/curve/draw/position_curve_to_canvas.d.ts.map +1 -0
  41. package/src/engine/animation/curve/draw/position_curve_to_canvas.js +25 -0
  42. package/src/engine/animation/curve/editor/CurveEditorView.d.ts +22 -0
  43. package/src/engine/animation/curve/editor/CurveEditorView.d.ts.map +1 -0
  44. package/src/engine/animation/curve/editor/CurveEditorView.js +337 -0
  45. package/src/engine/animation/curve/editor/DragHandler.d.ts +17 -0
  46. package/src/engine/animation/curve/editor/DragHandler.d.ts.map +1 -0
  47. package/src/engine/animation/curve/editor/DragHandler.js +35 -0
  48. package/src/engine/animation/curve/editor/KeyframeStateManager.d.ts +33 -0
  49. package/src/engine/animation/curve/editor/KeyframeStateManager.d.ts.map +1 -0
  50. package/src/engine/animation/curve/editor/KeyframeStateManager.js +39 -0
  51. package/src/engine/animation/curve/editor/OperationRouter.d.ts +18 -0
  52. package/src/engine/animation/curve/editor/OperationRouter.d.ts.map +1 -0
  53. package/src/engine/animation/curve/editor/OperationRouter.js +44 -0
  54. package/src/engine/animation/curve/editor/canvas2dDrawWorldAxisLabels.d.ts +14 -0
  55. package/src/engine/animation/curve/editor/canvas2dDrawWorldAxisLabels.d.ts.map +1 -0
  56. package/src/engine/animation/curve/editor/canvas2dDrawWorldAxisLabels.js +63 -0
  57. package/src/engine/animation/curve/editor/canvas2dDrawWorldGrid.d.ts +28 -0
  58. package/src/engine/animation/curve/editor/canvas2dDrawWorldGrid.d.ts.map +1 -0
  59. package/src/engine/animation/curve/editor/canvas2dDrawWorldGrid.js +70 -0
  60. package/src/engine/animation/curve/editor/canvas2dPlotCurveLine.d.ts +13 -0
  61. package/src/engine/animation/curve/editor/canvas2dPlotCurveLine.d.ts.map +1 -0
  62. package/src/engine/animation/curve/editor/canvas2dPlotCurveLine.js +116 -0
  63. package/src/engine/animation/curve/editor/canvas2dPlotCurvePoints.d.ts +11 -0
  64. package/src/engine/animation/curve/editor/canvas2dPlotCurvePoints.d.ts.map +1 -0
  65. package/src/engine/animation/curve/editor/canvas2dPlotCurvePoints.js +69 -0
  66. package/src/engine/animation/curve/editor/createCurveUploader.d.ts +8 -0
  67. package/src/engine/animation/curve/editor/createCurveUploader.d.ts.map +1 -0
  68. package/src/engine/animation/curve/editor/createCurveUploader.js +25 -0
  69. package/src/engine/animation/curve/editor/createKeyCoordinateLabelView.d.ts +3 -0
  70. package/src/engine/animation/curve/editor/createKeyCoordinateLabelView.d.ts.map +1 -0
  71. package/src/engine/animation/curve/editor/createKeyCoordinateLabelView.js +15 -0
  72. package/src/engine/animation/curve/editor/createKeyframeDraggableAspect.d.ts +24 -0
  73. package/src/engine/animation/curve/editor/createKeyframeDraggableAspect.d.ts.map +1 -0
  74. package/src/engine/animation/curve/editor/createKeyframeDraggableAspect.js +142 -0
  75. package/src/engine/animation/curve/editor/createKeyframeMarker.d.ts +2 -0
  76. package/src/engine/animation/curve/editor/createKeyframeMarker.d.ts.map +1 -0
  77. package/src/engine/animation/curve/editor/createKeyframeMarker.js +42 -0
  78. package/src/engine/animation/curve/editor/createPanTool.d.ts +11 -0
  79. package/src/engine/animation/curve/editor/createPanTool.d.ts.map +1 -0
  80. package/src/engine/animation/curve/editor/createPanTool.js +41 -0
  81. package/src/engine/animation/curve/editor/createSelectionBoxTool.d.ts +14 -0
  82. package/src/engine/animation/curve/editor/createSelectionBoxTool.d.ts.map +1 -0
  83. package/src/engine/animation/curve/editor/createSelectionBoxTool.js +93 -0
  84. package/src/engine/animation/curve/editor/deleteKeyframeAndResetVars.d.ts +8 -0
  85. package/src/engine/animation/curve/editor/deleteKeyframeAndResetVars.d.ts.map +1 -0
  86. package/src/engine/animation/curve/editor/deleteKeyframeAndResetVars.js +24 -0
  87. package/src/engine/animation/curve/editor/determineUnitSpacing.d.ts +8 -0
  88. package/src/engine/animation/curve/editor/determineUnitSpacing.d.ts.map +1 -0
  89. package/src/engine/animation/curve/editor/determineUnitSpacing.js +33 -0
  90. package/src/engine/animation/curve/editor/formatTruncDecimal.d.ts +7 -0
  91. package/src/engine/animation/curve/editor/formatTruncDecimal.d.ts.map +1 -0
  92. package/src/engine/animation/curve/editor/formatTruncDecimal.js +14 -0
  93. package/src/engine/animation/curve/editor/inputEventHandlers.d.ts +32 -0
  94. package/src/engine/animation/curve/editor/inputEventHandlers.d.ts.map +1 -0
  95. package/src/engine/animation/curve/editor/inputEventHandlers.js +125 -0
  96. package/src/engine/animation/curve/editor/uiContext.d.ts +10 -0
  97. package/src/engine/animation/curve/editor/uiContext.d.ts.map +1 -0
  98. package/src/engine/animation/curve/editor/uiContext.js +18 -0
  99. package/src/engine/animation/curve/editor/updateAxisRange.d.ts +11 -0
  100. package/src/engine/animation/curve/editor/updateAxisRange.d.ts.map +1 -0
  101. package/src/engine/animation/curve/editor/updateAxisRange.js +23 -0
  102. package/src/engine/animation/curve/editor/updateKeyframePosition.d.ts +9 -0
  103. package/src/engine/animation/curve/editor/updateKeyframePosition.d.ts.map +1 -0
  104. package/src/engine/animation/curve/editor/updateKeyframePosition.js +38 -0
  105. package/src/engine/animation/curve/editor/updateMarkerPosition.d.ts +2 -0
  106. package/src/engine/animation/curve/editor/updateMarkerPosition.d.ts.map +1 -0
  107. package/src/engine/animation/curve/editor/updateMarkerPosition.js +12 -0
  108. package/src/engine/animation/curve/editor/updateMarkerVisual.d.ts +9 -0
  109. package/src/engine/animation/curve/editor/updateMarkerVisual.d.ts.map +1 -0
  110. package/src/engine/animation/curve/editor/updateMarkerVisual.js +53 -0
  111. package/src/engine/animation/curve/editor/uploadViaElement.d.ts +7 -0
  112. package/src/engine/animation/curve/editor/uploadViaElement.d.ts.map +1 -0
  113. package/src/engine/animation/curve/editor/uploadViaElement.js +35 -0
  114. package/src/engine/animation/curve/draw/build_curve_editor.d.ts +0 -9
  115. package/src/engine/animation/curve/draw/build_curve_editor.d.ts.map +0 -1
  116. package/src/engine/animation/curve/draw/build_curve_editor.js +0 -362
@@ -0,0 +1,93 @@
1
+ import Vector2 from "../../../../core/geom/Vector2.js";
2
+ import AABB2 from "../../../../core/geom/2d/aabb/AABB2.js";
3
+ import {position_canvas_to_curve} from "../draw/position_canvas_to_curve.js";
4
+ import {applyActionSelection} from "../actionProcessorOperations/applyActionChange.js";
5
+ import {DragHandler} from "./DragHandler.js";
6
+
7
+ /**
8
+ *
9
+ * @param {KeyframeStateManager} keyframeStateManager
10
+ * @param {CanvasView} graph
11
+ * @param {AABB2} frame
12
+ * @param {Vector2} margin
13
+ * @param {function} fnUpdate
14
+ * @param {ActionProcessor} actionProcessor
15
+ * @param {keyframesContext} actionCTX
16
+ * @returns {DragHandler}
17
+ */
18
+ export function createSelectionBoxTool({
19
+ keyframeStateManager,
20
+ graph,
21
+ frame,
22
+ margin,
23
+ fnUpdate,
24
+ actionProcessor,
25
+ actionCTX
26
+ }) {
27
+ const anchorPos = new Vector2();
28
+ const targetPos = new Vector2();
29
+ const selectionBox = new AABB2();
30
+
31
+ const prevKeyframeList = keyframeStateManager.prevKeyframeList;
32
+ const curKeyframeList = keyframeStateManager.curKeyframeList;
33
+ const selectedKeyframes = keyframeStateManager.selectedKeyframes;
34
+ const keyframeViews = keyframeStateManager.keyframeViews;
35
+
36
+ /**
37
+ *
38
+ * @param {AABB2} box
39
+ */
40
+ function drawSelectionBox(box = new AABB2) {
41
+ fnUpdate();
42
+ const ctx = graph.context2d;
43
+ ctx.fillStyle = 'none';
44
+ ctx.lineWidth = 1;
45
+ ctx.strokeStyle = '#FFFF00';
46
+ ctx.beginPath();
47
+ ctx.rect(box.x0, box.y0, box.width, box.height);
48
+ ctx.stroke();
49
+ }
50
+
51
+ return new DragHandler({
52
+ dragStart(position) {
53
+ // console.log("start drag")
54
+ anchorPos.copy(position);
55
+ targetPos.copy(position);
56
+ selectionBox.set(0, 0, 0, 0);
57
+ },
58
+ drag(position,delta) {
59
+ // console.log("dragging")
60
+ targetPos.copy(position);
61
+
62
+ const x0 = Math.min(targetPos.x, anchorPos.x);
63
+ const x1 = Math.max(targetPos.x, anchorPos.x);
64
+ const y0 = Math.min(targetPos.y, anchorPos.y);
65
+ const y1 = Math.max(targetPos.y, anchorPos.y);
66
+
67
+ selectionBox.set(x0, y0, x1, y1);
68
+ drawSelectionBox(selectionBox);
69
+ },
70
+ dragEnd() {
71
+ // console.log("end drag")
72
+ prevKeyframeList.copy(selectedKeyframes);
73
+ const startRange = position_canvas_to_curve(graph.size, frame, margin, selectionBox.x0, selectionBox.y0);
74
+ const endRange = position_canvas_to_curve(graph.size, frame, margin, selectionBox.x1, selectionBox.y1);
75
+ keyframeViews.forEach((marker_view, key) => {
76
+ if (key.time >= startRange.x && key.time <= endRange.x
77
+ && key.value >= endRange.y && key.value <= startRange.y) {
78
+
79
+ if (!curKeyframeList.find(kf => kf === key)) {
80
+ curKeyframeList.add(key);
81
+ }
82
+ }
83
+ })
84
+ if (!curKeyframeList.isEmpty()) {
85
+ applyActionSelection('Selection', keyframeStateManager, actionProcessor, actionCTX);
86
+ }
87
+ else{
88
+ //Clears the drawn selection box
89
+ fnUpdate();
90
+ }
91
+ }
92
+ });
93
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ *
3
+ * @param {ActionProcessor} actionProcessor
4
+ * @param {keyframesContext} actionProcessorCTX
5
+ * @param {KeyframeStateManager} keyframeStateManager
6
+ */
7
+ export function deleteKeyframeAndResetVars(actionProcessor: ActionProcessor, actionProcessorCTX: keyframesContext, keyframeStateManager: KeyframeStateManager): void;
8
+ //# sourceMappingURL=deleteKeyframeAndResetVars.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deleteKeyframeAndResetVars.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/deleteKeyframeAndResetVars.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,qKAaC"}
@@ -0,0 +1,24 @@
1
+ import List from "../../../../core/collection/list/List.js";
2
+
3
+ import {applyActionRemove} from "../actionProcessorOperations/applyActionChange.js";
4
+
5
+ /**
6
+ *
7
+ * @param {ActionProcessor} actionProcessor
8
+ * @param {keyframesContext} actionProcessorCTX
9
+ * @param {KeyframeStateManager} keyframeStateManager
10
+ */
11
+ export function deleteKeyframeAndResetVars(actionProcessor, actionProcessorCTX, keyframeStateManager) {
12
+ const activeKf = keyframeStateManager.observedActiveKeyframe.get();
13
+
14
+ const kfToDelete = new List(keyframeStateManager.selectedKeyframes.data);
15
+ if (activeKf !== keyframeStateManager.NULL_KEYFRAME && !kfToDelete.contains(activeKf))
16
+ kfToDelete.add(activeKf)
17
+
18
+ keyframeStateManager.prevKeyframeList.copy(keyframeStateManager.selectedKeyframes);
19
+ keyframeStateManager.curKeyframeList.reset();
20
+
21
+ if (kfToDelete.length > 0) {
22
+ applyActionRemove(keyframeStateManager, kfToDelete, actionProcessor, actionProcessorCTX);
23
+ }
24
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ *
3
+ * @param {number} width
4
+ * @param {number} scale
5
+ * @returns {number}
6
+ */
7
+ export function determineUnitSpacing(width: number, scale: number): number;
8
+ //# sourceMappingURL=determineUnitSpacing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"determineUnitSpacing.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/determineUnitSpacing.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,4CAJW,MAAM,SACN,MAAM,GACJ,MAAM,CA4BlB"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ *
3
+ * @param {number} width
4
+ * @param {number} scale
5
+ * @returns {number}
6
+ */
7
+ export function determineUnitSpacing(width, scale) {
8
+ const baseTicks = 10;
9
+ const axisLength = width * scale;
10
+
11
+ const basePixelPerUnit = axisLength / baseTicks;
12
+ const targetPixelSpacing = 32;
13
+
14
+ const niceDivisionPattern = [1, 2, 5];
15
+
16
+ let chosenDivision = 1;
17
+ let lastDiff = Infinity;
18
+ for (const patternValue of niceDivisionPattern) {
19
+ const idealChoice = targetPixelSpacing / basePixelPerUnit
20
+ //Note: patternValue × 10^n ≈ idealChoice
21
+ const idealScale = idealChoice / patternValue;
22
+ const n = Math.round(Math.log10(idealScale))
23
+ const chosenPattern = patternValue * Math.pow(10,n)
24
+ const diff = (Math.abs(basePixelPerUnit * chosenPattern - targetPixelSpacing))
25
+
26
+ if ((diff < lastDiff)) {
27
+ lastDiff = diff;
28
+ chosenDivision = chosenPattern;
29
+ }
30
+ }
31
+
32
+ return basePixelPerUnit * chosenDivision;
33
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ *
3
+ * @param {number} num
4
+ * @returns {string}
5
+ */
6
+ export function formatTruncDecimal(num: number): string;
7
+ //# sourceMappingURL=formatTruncDecimal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatTruncDecimal.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/formatTruncDecimal.js"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,wCAHW,MAAM,GACJ,MAAM,CAIlB"}
@@ -0,0 +1,14 @@
1
+
2
+ const formatter = new Intl.NumberFormat("en-US", {
3
+ maximumFractionDigits: 3,
4
+ roundingMode: "trunc",
5
+ })
6
+
7
+ /**
8
+ *
9
+ * @param {number} num
10
+ * @returns {string}
11
+ */
12
+ export function formatTruncDecimal(num) {
13
+ return formatter.format(num);
14
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ *
3
+ * @param {KeyboardEvent} event
4
+ * @param {KeyboardDevice} keyboard
5
+ * @param {AnimationCurve} curve
6
+ * @param {KeyframeStateManager} keyframeStateManager
7
+ * @param {ActionProcessor} actionProcessor
8
+ * @param {keyframesContext}actionProcessorCTX
9
+ */
10
+ export function handleKeyDownEvents(event: KeyboardEvent, keyboard: KeyboardDevice, curve: AnimationCurve, keyframeStateManager: KeyframeStateManager, actionProcessor: ActionProcessor, actionProcessorCTX: keyframesContext): void;
11
+ /**
12
+ *
13
+ * @param {MouseEvent} e
14
+ * @param {CanvasView} graph
15
+ * @param {KeyboardDevice} keyboardElement
16
+ * @param {ActionProcessor} actionProcessor
17
+ * @param {keyframesContext} actionProcessorCTX
18
+ * @param {KeyframeStateManager} keyframeStateManager
19
+ */
20
+ export function handleMouseDownEvents(e: MouseEvent, graph: CanvasView, keyboardElement: KeyboardDevice, actionProcessor: ActionProcessor, actionProcessorCTX: keyframesContext, keyframeStateManager: KeyframeStateManager): void;
21
+ export function handleMouseDoubleClickEvents(e: any, vContainer: any, graph: any, frame: any, margin: any, curve: any, validEditableBounds: any, actionProcessor: any, actionProcessorCTX: any): void;
22
+ /**
23
+ *
24
+ * @param {KeyboardDevice} keyboardElement
25
+ * @param {Keyframe} keyframe
26
+ * @param {ActionProcessor} actionProcessor
27
+ * @param {keyframesContext} actionProcessorCTX
28
+ * @param {KeyframeStateManager} keyframeStateManager
29
+ */
30
+ export function handleKeyframeSelectedByDevice(keyboardElement: KeyboardDevice, keyframe: Keyframe, actionProcessor: ActionProcessor, actionProcessorCTX: keyframesContext, keyframeStateManager: KeyframeStateManager): void;
31
+ import { Keyframe } from "../Keyframe.js";
32
+ //# sourceMappingURL=inputEventHandlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputEventHandlers.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/inputEventHandlers.js"],"names":[],"mappings":"AAmBA;;;;;;;;GAQG;AACH,2CAPW,aAAa,6KAqCvB;AAED;;;;;;;;GAQG;AACH,yCAPW,UAAU,gLAYpB;AAED,sMAUC;AAED;;;;;;;GAOG;AACH,0FALW,QAAQ,4HAiClB;yBAxHsB,gBAAgB"}
@@ -0,0 +1,125 @@
1
+ import {deleteKeyframeAndResetVars} from "./deleteKeyframeAndResetVars.js";
2
+ import {applyActionSelection, applyGlobalKeyframeDeselection} from "../actionProcessorOperations/applyActionChange.js";
3
+ import Vector2 from "../../../../core/geom/Vector2.js";
4
+ import {readPositionFromMouseEvent} from "../../../input/devices/PointerDevice.js";
5
+ import {Keyframe} from "../Keyframe.js";
6
+ import {AddKeyframeAction} from "../actionProcessorOperations/curveActions.js";
7
+ import {isInjectedKeyframeInBounds} from "../draw/isInjectedKeyframeInBounds.js";
8
+ import {downloadAsFile} from "../../../../core/binary/downloadAsFile.js";
9
+
10
+ const keyType = {
11
+ deleteKey: 'delete',
12
+ alignTangentKey: 'a',
13
+ holdSelectionKey: 'shift',
14
+ controlKey: 'ctrl',
15
+ undoSecondaryKey: 'z',
16
+ redoSecondaryKey: 'y',
17
+ saveSecondaryKey: 's',
18
+ }
19
+
20
+ /**
21
+ *
22
+ * @param {KeyboardEvent} event
23
+ * @param {KeyboardDevice} keyboard
24
+ * @param {AnimationCurve} curve
25
+ * @param {KeyframeStateManager} keyframeStateManager
26
+ * @param {ActionProcessor} actionProcessor
27
+ * @param {keyframesContext}actionProcessorCTX
28
+ */
29
+ export function handleKeyDownEvents(event, keyboard, curve, keyframeStateManager, actionProcessor, actionProcessorCTX) {
30
+ const {keys} = keyboard;
31
+
32
+ if (keys[keyType.deleteKey].is_down) {
33
+ deleteKeyframeAndResetVars(actionProcessor, actionProcessorCTX, keyframeStateManager);
34
+ }
35
+
36
+ if (keys[keyType.alignTangentKey].is_down
37
+ && keyframeStateManager.observedActiveKeyframe.get() !== keyframeStateManager.NULL_KEYFRAME) {
38
+ keyframeStateManager.tangentAlignmentEnabled.invert();
39
+ }
40
+
41
+ if (keys[keyType.controlKey].is_down) {
42
+ if (keys[keyType.undoSecondaryKey].is_down) {
43
+ keyframeStateManager.observedActiveKeyframe.set(keyframeStateManager.NULL_KEYFRAME);
44
+ actionProcessor.undo();
45
+ }
46
+
47
+ if (keys[keyType.redoSecondaryKey].is_down) {
48
+ keyframeStateManager.observedActiveKeyframe.set(keyframeStateManager.NULL_KEYFRAME);
49
+ actionProcessor.redo();
50
+ }
51
+
52
+ if (keys[keyType.saveSecondaryKey].is_down) {
53
+ event.preventDefault(); // prevent browser save dialog
54
+ const data = JSON.stringify(curve)
55
+ downloadAsFile(data, "curve.json")
56
+ // console.log(`${data}`)
57
+ }
58
+ }
59
+ }
60
+
61
+ /**
62
+ *
63
+ * @param {MouseEvent} e
64
+ * @param {CanvasView} graph
65
+ * @param {KeyboardDevice} keyboardElement
66
+ * @param {ActionProcessor} actionProcessor
67
+ * @param {keyframesContext} actionProcessorCTX
68
+ * @param {KeyframeStateManager} keyframeStateManager
69
+ */
70
+ export function handleMouseDownEvents(e, graph, keyboardElement, actionProcessor, actionProcessorCTX, keyframeStateManager) {
71
+ const isClickedOnGraph = e.target === graph.el;
72
+ const isSelectionKeyHeld = keyboardElement.keys[keyType.holdSelectionKey].is_down;
73
+
74
+ applyGlobalKeyframeDeselection(isClickedOnGraph, isSelectionKeyHeld, actionProcessor, actionProcessorCTX, keyframeStateManager);
75
+ }
76
+
77
+ export function handleMouseDoubleClickEvents(e, vContainer, graph, frame, margin, curve, validEditableBounds, actionProcessor, actionProcessorCTX) {
78
+ const mousePosition = new Vector2();
79
+ readPositionFromMouseEvent(mousePosition, e, vContainer.el);
80
+
81
+ const newKeyframe = new Keyframe();
82
+
83
+ if (isInjectedKeyframeInBounds(graph, frame, margin, curve, validEditableBounds, mousePosition, newKeyframe)) {
84
+ actionProcessor.mark('add keyframe');
85
+ actionProcessor.do(new AddKeyframeAction(newKeyframe, actionProcessorCTX))
86
+ }
87
+ }
88
+
89
+ /**
90
+ *
91
+ * @param {KeyboardDevice} keyboardElement
92
+ * @param {Keyframe} keyframe
93
+ * @param {ActionProcessor} actionProcessor
94
+ * @param {keyframesContext} actionProcessorCTX
95
+ * @param {KeyframeStateManager} keyframeStateManager
96
+ */
97
+ export function handleKeyframeSelectedByDevice(keyboardElement, keyframe, actionProcessor, actionProcessorCTX, keyframeStateManager) {
98
+ const isSelectionKeyHeld = keyboardElement.keys[keyType.holdSelectionKey].is_down;
99
+ const isKeyframeNotInSelection = !keyframeStateManager.curKeyframeList.find(kf => kf === keyframe);
100
+ const isActiveKeyframeNotInSelection = !keyframeStateManager.curKeyframeList.find(kf => kf === keyframeStateManager.observedActiveKeyframe.get());
101
+
102
+ keyframeStateManager.prevKeyframeList.copy(keyframeStateManager.selectedKeyframes);
103
+ keyframeStateManager.curKeyframeList.copy(keyframeStateManager.selectedKeyframes);
104
+
105
+ if (isSelectionKeyHeld) {
106
+ if (isKeyframeNotInSelection) {
107
+ if (isActiveKeyframeNotInSelection)
108
+ keyframeStateManager.curKeyframeList.add(keyframeStateManager.observedActiveKeyframe.get());
109
+
110
+ keyframeStateManager.curKeyframeList.add(keyframe);
111
+ applyActionSelection('Selection', keyframeStateManager, actionProcessor, actionProcessorCTX);
112
+ } else {
113
+ keyframeStateManager.curKeyframeList.removeIf(k => k === keyframe);
114
+ applyActionSelection('Deselection', keyframeStateManager, actionProcessor, actionProcessorCTX);
115
+ }
116
+ } else {
117
+ keyframeStateManager.tangentAlignmentEnabled.setFalse();
118
+ keyframeStateManager.observedActiveKeyframe.set(keyframe);
119
+
120
+ if (isKeyframeNotInSelection) {
121
+ keyframeStateManager.curKeyframeList.reset();
122
+ applyActionSelection('Deselection', keyframeStateManager, actionProcessor, actionProcessorCTX);
123
+ }
124
+ }
125
+ }
@@ -0,0 +1,10 @@
1
+ export class UIContext {
2
+ constructor(curve: any, size: any, margin: any);
3
+ curve: any;
4
+ margin: any;
5
+ graph: CanvasView;
6
+ frame: AABB2;
7
+ }
8
+ import { CanvasView } from "../../../../view/elements/CanvasView.js";
9
+ import AABB2 from "../../../../core/geom/2d/aabb/AABB2.js";
10
+ //# sourceMappingURL=uiContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uiContext.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/uiContext.js"],"names":[],"mappings":"AAGA;IAEI,gDAWC;IATG,WAAkB;IAElB,YAAoB;IAEpB,kBAA6B;IAG7B,aAAwB;CAG/B;2BAjBwB,yCAAyC;kBAChD,wCAAwC"}
@@ -0,0 +1,18 @@
1
+ import {CanvasView} from "../../../../view/elements/CanvasView.js";
2
+ import AABB2 from "../../../../core/geom/2d/aabb/AABB2.js";
3
+
4
+ export class UIContext{
5
+
6
+ constructor(curve, size, margin){
7
+
8
+ this.curve = curve
9
+
10
+ this.margin = margin
11
+
12
+ this.graph = new CanvasView();
13
+ this.graph.size.copy(size)
14
+
15
+ this.frame = new AABB2();
16
+
17
+ }
18
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Modify the axis start and end value based on given scaling
3
+ * @param {number} axisLength
4
+ * @param {number} cursorToGraphPos
5
+ * @param {number} axisStart
6
+ * @param {number} axisEnd
7
+ * @param {number} scaling
8
+ * @returns {(number|*)[]}
9
+ */
10
+ export function updateAxisRange(axisLength: number, cursorToGraphPos: number, axisStart: number, axisEnd: number, scaling: number): (number | any)[];
11
+ //# sourceMappingURL=updateAxisRange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateAxisRange.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/updateAxisRange.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,4CAPW,MAAM,oBACN,MAAM,aACN,MAAM,WACN,MAAM,WACN,MAAM,GACJ,CAAC,MAAM,MAAE,CAAC,EAAE,CAaxB"}
@@ -0,0 +1,23 @@
1
+
2
+
3
+ /**
4
+ * Modify the axis start and end value based on given scaling
5
+ * @param {number} axisLength
6
+ * @param {number} cursorToGraphPos
7
+ * @param {number} axisStart
8
+ * @param {number} axisEnd
9
+ * @param {number} scaling
10
+ * @returns {(number|*)[]}
11
+ */
12
+ export function updateAxisRange(axisLength,cursorToGraphPos, axisStart, axisEnd, scaling){
13
+
14
+ let axisRange = axisEnd - axisStart;
15
+ const ratioCursorToGraphX = cursorToGraphPos / axisLength;
16
+ const axisCentre = axisStart + (ratioCursorToGraphX * axisRange);
17
+
18
+ axisRange = (axisEnd - axisStart) / scaling;
19
+ axisStart = axisCentre - (ratioCursorToGraphX * axisRange);
20
+ axisEnd = axisCentre + (1 - ratioCursorToGraphX) * axisRange;
21
+
22
+ return [axisStart, axisEnd];
23
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ *
3
+ * @param {Keyframe} selectedKeyframe
4
+ * @param {Vector2} deltaPosition
5
+ * @param {AnimationCurve} curve
6
+ */
7
+ export function updateKeyframePosition(selectedKeyframe: Keyframe, deltaPosition: Vector2, curve: AnimationCurve): void;
8
+ import Vector2 from "../../../../core/geom/Vector2.js";
9
+ //# sourceMappingURL=updateKeyframePosition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateKeyframePosition.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/updateKeyframePosition.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,yDAJW,QAAQ,iBACR,OAAO,+BAOjB;oBAZmB,kCAAkC"}
@@ -0,0 +1,38 @@
1
+ import Vector2 from "../../../../core/geom/Vector2.js";
2
+
3
+ /**
4
+ *
5
+ * @param {Keyframe} selectedKeyframe
6
+ * @param {Vector2} deltaPosition
7
+ * @param {AnimationCurve} curve
8
+ */
9
+ export function updateKeyframePosition(selectedKeyframe, deltaPosition, curve) {
10
+ selectedKeyframe.time += deltaPosition.x;
11
+ selectedKeyframe.value += deltaPosition.y;
12
+ updateKeyFrameIndexes(curve, selectedKeyframe);
13
+ }
14
+
15
+ /**
16
+ *
17
+ * @param {AnimationCurve} curve
18
+ * @param {Keyframe} keyframe
19
+ */
20
+ function updateKeyFrameIndexes(curve, keyframe) {
21
+ let keyframeIndex = curve.keys.indexOf(keyframe);
22
+
23
+ if (keyframeIndex < (curve.keys.length - 1) && keyframe.time > curve.keys[keyframeIndex + 1].time) {
24
+ const nextIndex = keyframeIndex + 1;
25
+ const next = curve.keys[nextIndex];
26
+
27
+ curve.keys[nextIndex] = keyframe;
28
+ curve.keys[keyframeIndex] = next;
29
+
30
+ } else if (keyframeIndex > 0 && keyframe.time < curve.keys[keyframeIndex - 1].time) {
31
+ const prevIndex = keyframeIndex - 1;
32
+ const prev = curve.keys[prevIndex];
33
+
34
+ curve.keys[prevIndex] = keyframe;
35
+ curve.keys[keyframeIndex] = prev;
36
+
37
+ }
38
+ }
@@ -0,0 +1,2 @@
1
+ export function updateMarkerPosition(graph: any, frame: any, margin: any, keyframe: any, vContainerMarker: any): void;
2
+ //# sourceMappingURL=updateMarkerPosition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateMarkerPosition.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/updateMarkerPosition.js"],"names":[],"mappings":"AAEA,sHASC"}
@@ -0,0 +1,12 @@
1
+ import {position_curve_to_canvas} from "../draw/position_curve_to_canvas.js";
2
+
3
+ export function updateMarkerPosition(graph, frame, margin, keyframe, vContainerMarker) {
4
+ const canvasCoordinates = position_curve_to_canvas(
5
+ graph.size,
6
+ frame,
7
+ margin,
8
+ keyframe.time,
9
+ keyframe.value
10
+ );
11
+ vContainerMarker.position.copy(canvasCoordinates);
12
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ *
3
+ * @param {KeyframeStateManager} keyframeStateManager
4
+ * @param {Keyframe} keyframe
5
+ * @param {EmptyView} vTangentEditor
6
+ * @param {View} marker
7
+ */
8
+ export function updateMarkerVisual(keyframeStateManager: KeyframeStateManager, keyframe: Keyframe, vTangentEditor: EmptyView, marker: View): void;
9
+ //# sourceMappingURL=updateMarkerVisual.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateMarkerVisual.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/updateMarkerVisual.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,yFAJW,QAAQ,iDAalB"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ *
3
+ * @param {KeyframeStateManager} keyframeStateManager
4
+ * @param {Keyframe} keyframe
5
+ * @param {EmptyView} vTangentEditor
6
+ * @param {View} marker
7
+ */
8
+ export function updateMarkerVisual(keyframeStateManager, keyframe, vTangentEditor, marker) {
9
+ const markerView = keyframeStateManager.keyframeViews.get(keyframe);
10
+ const markerColour = getKeyframeMarkerColour(keyframeStateManager, keyframe);
11
+
12
+ updateTangentMarker(keyframeStateManager, keyframe, markerView, vTangentEditor)
13
+
14
+ marker.css({
15
+ background: markerColour
16
+ });
17
+ }
18
+
19
+ /**
20
+ * Acquire the pre-defined colour for marker(keyframe) based on the keyframe selection state
21
+ * @param {KeyframeStateManager} keyframeStateManager
22
+ * @param {Keyframe} keyframe
23
+ * @returns {string}
24
+ */
25
+ function getKeyframeMarkerColour(keyframeStateManager, keyframe) {
26
+ const activeKeyframe = keyframeStateManager.observedActiveKeyframe;
27
+ const selectedKeyframes = keyframeStateManager.selectedKeyframes;
28
+
29
+ if (activeKeyframe.get() === keyframe) {
30
+ return '#FFFFFF'
31
+ } else if (selectedKeyframes.find(kf => kf === keyframe)) {
32
+ return '#B700FFFF'
33
+ } else {
34
+ return '#00ff00'
35
+ }
36
+ }
37
+
38
+ function updateTangentMarker(keyframeStateManager, keyframe, markerView, vTangentEditor) {
39
+ const activeKeyframe = keyframeStateManager.observedActiveKeyframe;
40
+ const selectedKeyframes = keyframeStateManager.selectedKeyframes;
41
+
42
+ if (activeKeyframe.get() === keyframe) {
43
+ if (!markerView.hasChild(vTangentEditor))
44
+ markerView.addChild(vTangentEditor);
45
+ } else if (selectedKeyframes.find(kf => kf === keyframe)) { //Todo remove if covered by else condition
46
+ if (markerView.hasChild(vTangentEditor))
47
+ markerView.removeChild(vTangentEditor);
48
+ } else {
49
+ if (markerView.hasChild(vTangentEditor))
50
+ markerView.removeChild(vTangentEditor);
51
+ }
52
+ }
53
+
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Attaches drag & drop to an element
3
+ * @param {HTMLElement} el
4
+ * @param {(data: any) => void} data
5
+ */
6
+ export function uploadViaElement(el: HTMLElement, data: (data: any) => void): void;
7
+ //# sourceMappingURL=uploadViaElement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploadViaElement.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/uploadViaElement.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,qCAHW,WAAW,eACJ,GAAG,KAAK,IAAI,QA6B7B"}
@@ -0,0 +1,35 @@
1
+ import {DragEvents} from "../../../input/devices/events/DragEvents.js";
2
+
3
+ /**
4
+ * Attaches drag & drop to an element
5
+ * @param {HTMLElement} el
6
+ * @param {(data: any) => void} data
7
+ */
8
+ export function uploadViaElement(el, data) {
9
+ if (!el) throw new Error("Element is required");
10
+
11
+ el.addEventListener(DragEvents.DragOver, (e) => {
12
+ // console.log("dragging over element");
13
+ e.preventDefault(); // prevent browser from opening file
14
+ });
15
+
16
+ el.addEventListener(DragEvents.Drop, (e) => {
17
+ e.preventDefault();
18
+
19
+ const file = e.dataTransfer.files[0];
20
+ if (!file) return;
21
+
22
+ const reader = new FileReader();
23
+ reader.readAsText(file);
24
+ reader.onload = () => {
25
+ try {
26
+ const text = String(reader.result).replace(/^\uFEFF/, '').trim();
27
+ data(text);
28
+ // console.log("Imported data: ", text);
29
+
30
+ } catch (err) {
31
+ console.error("Error reading file: ", err);
32
+ }
33
+ };
34
+ });
35
+ }
@@ -1,9 +0,0 @@
1
- /**
2
- *
3
- * @param {AnimationCurve} curve
4
- * @param {Vector2} [size]
5
- * @param {Vector2} [margin] How much space to leave empty around the plotted bounds
6
- * @returns {View}
7
- */
8
- export function build_curve_editor({ curve, size, margin }: AnimationCurve): View;
9
- //# sourceMappingURL=build_curve_editor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build_curve_editor.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/draw/build_curve_editor.js"],"names":[],"mappings":"AAiEA;;;;;;GAMG;AACH,kFAiSC"}