@woosh/meep-engine 2.131.35 → 2.131.37
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/build/bundle-worker-image-decoder.js +1 -1
- package/package.json +1 -1
- package/src/core/binary/BinaryBuffer.d.ts +14 -0
- package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
- package/src/core/binary/BinaryBuffer.js +27 -0
- package/src/core/binary/allocator/OffsetAllocator.d.ts +5 -0
- package/src/core/binary/allocator/OffsetAllocator.d.ts.map +1 -1
- package/src/core/binary/allocator/OffsetAllocator.js +6 -0
- package/src/core/geom/3d/aabb/AABB3.d.ts +17 -2
- package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/AABB3.js +29 -2
- package/src/core/geom/normalize_angle_rad.d.ts.map +1 -1
- package/src/core/geom/normalize_angle_rad.js +3 -0
- package/src/core/math/hash/computeHashFloatArray.d.ts +3 -2
- package/src/core/math/hash/computeHashFloatArray.d.ts.map +1 -1
- package/src/core/math/hash/computeHashFloatArray.js +2 -1
- package/src/core/process/undo/ActionProcessor.d.ts.map +1 -1
- package/src/core/process/undo/ActionProcessor.js +3 -1
- package/src/engine/animation/curve/actionProcessorOperations/applyActionChange.d.ts +34 -0
- package/src/engine/animation/curve/actionProcessorOperations/applyActionChange.d.ts.map +1 -0
- package/src/engine/animation/curve/actionProcessorOperations/applyActionChange.js +61 -0
- package/src/engine/animation/curve/actionProcessorOperations/curveActions.d.ts +107 -0
- package/src/engine/animation/curve/actionProcessorOperations/curveActions.d.ts.map +1 -0
- package/src/engine/animation/curve/actionProcessorOperations/curveActions.js +202 -0
- package/src/engine/animation/curve/compression/prototypeCurveCompression.js +24 -3
- package/src/engine/animation/curve/draw/buildReadOnlyDisplay.d.ts +3 -0
- package/src/engine/animation/curve/draw/buildReadOnlyDisplay.d.ts.map +1 -0
- package/src/engine/animation/curve/draw/buildReadOnlyDisplay.js +14 -0
- package/src/engine/animation/curve/draw/build_tangent_editor.d.ts +6 -1
- package/src/engine/animation/curve/draw/build_tangent_editor.d.ts.map +1 -1
- package/src/engine/animation/curve/draw/build_tangent_editor.js +220 -51
- package/src/engine/animation/curve/draw/displayMousePos.d.ts +7 -0
- package/src/engine/animation/curve/draw/displayMousePos.d.ts.map +1 -0
- package/src/engine/animation/curve/draw/displayMousePos.js +41 -0
- package/src/engine/animation/curve/draw/isInjectedKeyframeInBounds.d.ts +26 -0
- package/src/engine/animation/curve/draw/isInjectedKeyframeInBounds.d.ts.map +1 -0
- package/src/engine/animation/curve/draw/isInjectedKeyframeInBounds.js +93 -0
- package/src/engine/animation/curve/draw/position_canvas_to_curve.d.ts +12 -0
- package/src/engine/animation/curve/draw/position_canvas_to_curve.d.ts.map +1 -0
- package/src/engine/animation/curve/draw/position_canvas_to_curve.js +24 -0
- package/src/engine/animation/curve/draw/position_curve_to_canvas.d.ts +12 -0
- package/src/engine/animation/curve/draw/position_curve_to_canvas.d.ts.map +1 -0
- package/src/engine/animation/curve/draw/position_curve_to_canvas.js +25 -0
- package/src/engine/animation/curve/editor/CurveEditorView.d.ts +22 -0
- package/src/engine/animation/curve/editor/CurveEditorView.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/CurveEditorView.js +337 -0
- package/src/engine/animation/curve/editor/DragHandler.d.ts +17 -0
- package/src/engine/animation/curve/editor/DragHandler.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/DragHandler.js +35 -0
- package/src/engine/animation/curve/editor/KeyframeStateManager.d.ts +33 -0
- package/src/engine/animation/curve/editor/KeyframeStateManager.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/KeyframeStateManager.js +39 -0
- package/src/engine/animation/curve/editor/OperationRouter.d.ts +18 -0
- package/src/engine/animation/curve/editor/OperationRouter.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/OperationRouter.js +44 -0
- package/src/engine/animation/curve/editor/canvas2dDrawWorldAxisLabels.d.ts +14 -0
- package/src/engine/animation/curve/editor/canvas2dDrawWorldAxisLabels.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/canvas2dDrawWorldAxisLabels.js +63 -0
- package/src/engine/animation/curve/editor/canvas2dDrawWorldGrid.d.ts +28 -0
- package/src/engine/animation/curve/editor/canvas2dDrawWorldGrid.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/canvas2dDrawWorldGrid.js +70 -0
- package/src/engine/animation/curve/editor/canvas2dPlotCurveLine.d.ts +13 -0
- package/src/engine/animation/curve/editor/canvas2dPlotCurveLine.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/canvas2dPlotCurveLine.js +116 -0
- package/src/engine/animation/curve/editor/canvas2dPlotCurvePoints.d.ts +11 -0
- package/src/engine/animation/curve/editor/canvas2dPlotCurvePoints.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/canvas2dPlotCurvePoints.js +69 -0
- package/src/engine/animation/curve/editor/createCurveUploader.d.ts +8 -0
- package/src/engine/animation/curve/editor/createCurveUploader.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/createCurveUploader.js +25 -0
- package/src/engine/animation/curve/editor/createKeyCoordinateLabelView.d.ts +3 -0
- package/src/engine/animation/curve/editor/createKeyCoordinateLabelView.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/createKeyCoordinateLabelView.js +15 -0
- package/src/engine/animation/curve/editor/createKeyframeDraggableAspect.d.ts +24 -0
- package/src/engine/animation/curve/editor/createKeyframeDraggableAspect.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/createKeyframeDraggableAspect.js +142 -0
- package/src/engine/animation/curve/editor/createKeyframeMarker.d.ts +2 -0
- package/src/engine/animation/curve/editor/createKeyframeMarker.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/createKeyframeMarker.js +42 -0
- package/src/engine/animation/curve/editor/createPanTool.d.ts +11 -0
- package/src/engine/animation/curve/editor/createPanTool.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/createPanTool.js +41 -0
- package/src/engine/animation/curve/editor/createSelectionBoxTool.d.ts +14 -0
- package/src/engine/animation/curve/editor/createSelectionBoxTool.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/createSelectionBoxTool.js +93 -0
- package/src/engine/animation/curve/editor/deleteKeyframeAndResetVars.d.ts +8 -0
- package/src/engine/animation/curve/editor/deleteKeyframeAndResetVars.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/deleteKeyframeAndResetVars.js +24 -0
- package/src/engine/animation/curve/editor/determineUnitSpacing.d.ts +8 -0
- package/src/engine/animation/curve/editor/determineUnitSpacing.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/determineUnitSpacing.js +33 -0
- package/src/engine/animation/curve/editor/formatTruncDecimal.d.ts +7 -0
- package/src/engine/animation/curve/editor/formatTruncDecimal.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/formatTruncDecimal.js +14 -0
- package/src/engine/animation/curve/editor/inputEventHandlers.d.ts +32 -0
- package/src/engine/animation/curve/editor/inputEventHandlers.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/inputEventHandlers.js +125 -0
- package/src/engine/animation/curve/editor/uiContext.d.ts +10 -0
- package/src/engine/animation/curve/editor/uiContext.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/uiContext.js +18 -0
- package/src/engine/animation/curve/editor/updateAxisRange.d.ts +11 -0
- package/src/engine/animation/curve/editor/updateAxisRange.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/updateAxisRange.js +23 -0
- package/src/engine/animation/curve/editor/updateKeyframePosition.d.ts +9 -0
- package/src/engine/animation/curve/editor/updateKeyframePosition.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/updateKeyframePosition.js +38 -0
- package/src/engine/animation/curve/editor/updateMarkerPosition.d.ts +2 -0
- package/src/engine/animation/curve/editor/updateMarkerPosition.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/updateMarkerPosition.js +12 -0
- package/src/engine/animation/curve/editor/updateMarkerVisual.d.ts +9 -0
- package/src/engine/animation/curve/editor/updateMarkerVisual.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/updateMarkerVisual.js +53 -0
- package/src/engine/animation/curve/editor/uploadViaElement.d.ts +7 -0
- package/src/engine/animation/curve/editor/uploadViaElement.d.ts.map +1 -0
- package/src/engine/animation/curve/editor/uploadViaElement.js +35 -0
- package/src/engine/physics/gjk/NOTES.md +2 -0
- package/src/engine/animation/curve/draw/build_curve_editor.d.ts +0 -9
- package/src/engine/animation/curve/draw/build_curve_editor.d.ts.map +0 -1
- package/src/engine/animation/curve/draw/build_curve_editor.js +0 -362
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param ctx
|
|
4
|
+
* @param {number} width
|
|
5
|
+
* @param {number} height
|
|
6
|
+
* @param {string} [color] CSS color specification
|
|
7
|
+
* @param {number} spacingX distance between grid lines for x-axis
|
|
8
|
+
* @param {number} spacingY distance between grid lines for y-axis
|
|
9
|
+
* @param {number} offsetX
|
|
10
|
+
* @param {number} offsetY
|
|
11
|
+
* @param {number[]} valueRangeX
|
|
12
|
+
* @param {number[]} valueRangeY
|
|
13
|
+
* @param {number} thickness
|
|
14
|
+
*/
|
|
15
|
+
export function canvas2dDrawWorldGrid({
|
|
16
|
+
ctx,
|
|
17
|
+
width,
|
|
18
|
+
height,
|
|
19
|
+
color = 'red',
|
|
20
|
+
spacingX = 10,
|
|
21
|
+
spacingY = 10,
|
|
22
|
+
offsetX = 0,
|
|
23
|
+
offsetY = 0,
|
|
24
|
+
valueRangeX = [0,10],
|
|
25
|
+
valueRangeY = [0,10],
|
|
26
|
+
thickness = 1
|
|
27
|
+
}) {
|
|
28
|
+
ctx.fillStyle = 'none';
|
|
29
|
+
ctx.lineWidth = thickness;
|
|
30
|
+
ctx.strokeStyle = color;
|
|
31
|
+
|
|
32
|
+
const [xMin, xMax] = valueRangeX;
|
|
33
|
+
const [yMin, yMax] = valueRangeY;
|
|
34
|
+
|
|
35
|
+
const plotWidth = width - offsetX * 2;
|
|
36
|
+
const plotHeight = height - offsetY * 2;
|
|
37
|
+
|
|
38
|
+
const xPixelPerUnit = plotWidth / (xMax - xMin);
|
|
39
|
+
const xStepPerGrid = spacingX / xPixelPerUnit; // convert pixel spacing → world spacing
|
|
40
|
+
|
|
41
|
+
const yPixelPerUnit = plotHeight / (yMax - yMin);
|
|
42
|
+
const yStepPerGrid = spacingY / yPixelPerUnit; // convert pixel spacing → world spacing
|
|
43
|
+
|
|
44
|
+
// find first visible grid line
|
|
45
|
+
const firstX = Math.ceil(xMin / xStepPerGrid) * xStepPerGrid;
|
|
46
|
+
const firstY = Math.ceil(yMin / yStepPerGrid) * yStepPerGrid;
|
|
47
|
+
|
|
48
|
+
ctx.beginPath();
|
|
49
|
+
|
|
50
|
+
ctx.moveTo(offsetX, 0);
|
|
51
|
+
ctx.lineTo(offsetX, height);
|
|
52
|
+
ctx.moveTo(0, height - offsetY);
|
|
53
|
+
ctx.lineTo(width, height - offsetY);
|
|
54
|
+
|
|
55
|
+
for (let x = firstX; x <= xMax; x += xStepPerGrid)
|
|
56
|
+
{
|
|
57
|
+
const xScreen = offsetX + (x - xMin) * xPixelPerUnit;
|
|
58
|
+
ctx.moveTo(xScreen, 0);
|
|
59
|
+
ctx.lineTo(xScreen, offsetX + plotHeight);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
for (let y = firstY; y <= yMax; y += yStepPerGrid)
|
|
63
|
+
{
|
|
64
|
+
const yScreen = offsetY + (yMax - y) * yPixelPerUnit;
|
|
65
|
+
ctx.moveTo(offsetX, yScreen);
|
|
66
|
+
ctx.lineTo(width, yScreen);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
ctx.stroke();
|
|
70
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
4
|
+
* @param {AnimationCurve} curve
|
|
5
|
+
* @param {Vector2} [margin]
|
|
6
|
+
* @param {number} width
|
|
7
|
+
* @param {number} height
|
|
8
|
+
* @param {number[]} [range_y]
|
|
9
|
+
* @param {number[]} range_x
|
|
10
|
+
* @param {number} spacing
|
|
11
|
+
*/
|
|
12
|
+
export function canvas2dPlotCurveLine({ ctx, curve, margin, width, height, range_y, range_x, spacing }: CanvasRenderingContext2D): void;
|
|
13
|
+
//# sourceMappingURL=canvas2dPlotCurveLine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvas2dPlotCurveLine.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/canvas2dPlotCurveLine.js"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,wGATW,wBAAwB,QA4GlC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
2
|
+
import {canvas2dPlotCurvePoints} from "./canvas2dPlotCurvePoints.js";
|
|
3
|
+
import {canvas2dDrawWorldAxisLabels} from "./canvas2dDrawWorldAxisLabels.js";
|
|
4
|
+
import {canvas2dDrawWorldGrid} from "./canvas2dDrawWorldGrid.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
9
|
+
* @param {AnimationCurve} curve
|
|
10
|
+
* @param {Vector2} [margin]
|
|
11
|
+
* @param {number} width
|
|
12
|
+
* @param {number} height
|
|
13
|
+
* @param {number[]} [range_y]
|
|
14
|
+
* @param {number[]} range_x
|
|
15
|
+
* @param {number} spacing
|
|
16
|
+
*/
|
|
17
|
+
export function canvas2dPlotCurveLine({
|
|
18
|
+
ctx,
|
|
19
|
+
curve,
|
|
20
|
+
margin = Vector2.zero,
|
|
21
|
+
width,
|
|
22
|
+
height,
|
|
23
|
+
range_y,
|
|
24
|
+
range_x,
|
|
25
|
+
spacing= 32
|
|
26
|
+
}) {
|
|
27
|
+
|
|
28
|
+
ctx.fillStyle = '#222222';
|
|
29
|
+
ctx.fillRect(0, 0, width, height);
|
|
30
|
+
|
|
31
|
+
const dataX0 = range_x[0];
|
|
32
|
+
const dataX1 = range_x[1];
|
|
33
|
+
const dataY0 = range_y[0];
|
|
34
|
+
const dataY1 = range_y[1];
|
|
35
|
+
|
|
36
|
+
canvas2dDrawWorldGrid({
|
|
37
|
+
ctx,
|
|
38
|
+
width,
|
|
39
|
+
height,
|
|
40
|
+
color: '#262626',
|
|
41
|
+
spacingX: spacing * 0.25,
|
|
42
|
+
spacingY: spacing * 0.25,
|
|
43
|
+
offsetX: margin.x,
|
|
44
|
+
offsetY: margin.y,
|
|
45
|
+
valueRangeX: range_x,
|
|
46
|
+
valueRangeY: range_y
|
|
47
|
+
})
|
|
48
|
+
canvas2dDrawWorldGrid({
|
|
49
|
+
ctx,
|
|
50
|
+
width,
|
|
51
|
+
height,
|
|
52
|
+
color: '#303030',
|
|
53
|
+
spacingX: spacing,
|
|
54
|
+
spacingY: spacing,
|
|
55
|
+
offsetX: margin.x,
|
|
56
|
+
offsetY: margin.y,
|
|
57
|
+
valueRangeX: range_x,
|
|
58
|
+
valueRangeY: range_y
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
const plotWidth = width - margin.x * 2;
|
|
62
|
+
|
|
63
|
+
const xPixelPerUnit = plotWidth / (dataX1 - dataX0);
|
|
64
|
+
const xStepPerGrid = spacing / xPixelPerUnit; // convert pixel spacing → world spacing
|
|
65
|
+
|
|
66
|
+
const xLabelSkip = 2; // draw every 2nd grid line
|
|
67
|
+
const xStepPerLabel = xStepPerGrid * xLabelSkip;
|
|
68
|
+
|
|
69
|
+
const xFirstLabel = Math.ceil(dataX0 / xStepPerLabel) * xStepPerLabel;
|
|
70
|
+
const xFirstLabelPixel = (xFirstLabel - dataX0) * xPixelPerUnit;
|
|
71
|
+
canvas2dDrawWorldAxisLabels({
|
|
72
|
+
ctx,
|
|
73
|
+
position_x0: margin.x + xFirstLabelPixel,
|
|
74
|
+
position_x1: width - margin.x,
|
|
75
|
+
position_y0: height - 4,
|
|
76
|
+
position_y1: height - 4,
|
|
77
|
+
spacing: spacing * xLabelSkip, // pixels between labels
|
|
78
|
+
value_0: xFirstLabel, // world value for first label
|
|
79
|
+
value_1: dataX1,
|
|
80
|
+
valueStep: xStepPerLabel, // world units per label
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const plotHeight = height - margin.y * 2;
|
|
84
|
+
|
|
85
|
+
const yPixelPerUnit = plotHeight / (dataY1 - dataY0);
|
|
86
|
+
const yStepPerGrid = spacing / yPixelPerUnit; // convert pixel spacing → world spacing
|
|
87
|
+
|
|
88
|
+
const yLabelSkip = 2; // draw every 2nd grid line
|
|
89
|
+
const yStepPerLabel = yStepPerGrid * yLabelSkip;
|
|
90
|
+
|
|
91
|
+
const yFirstLabel = Math.ceil(dataY0 / yStepPerLabel) * yStepPerLabel;
|
|
92
|
+
const yFirstLabelPixel = (dataY1 - yFirstLabel) * yPixelPerUnit;
|
|
93
|
+
canvas2dDrawWorldAxisLabels({
|
|
94
|
+
ctx,
|
|
95
|
+
position_x0: 4,
|
|
96
|
+
position_x1: 4,
|
|
97
|
+
position_y0: margin.y + yFirstLabelPixel,
|
|
98
|
+
position_y1: margin.y,
|
|
99
|
+
spacing: spacing * yLabelSkip, // pixels between labels
|
|
100
|
+
value_0: yFirstLabel, // world value for first label
|
|
101
|
+
value_1: dataY1,
|
|
102
|
+
valueStep: yStepPerLabel, // world units per label
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
ctx.fillStyle = 'none';
|
|
106
|
+
ctx.strokeStyle = '#00ff00';
|
|
107
|
+
ctx.lineWidth = 1;
|
|
108
|
+
canvas2dPlotCurvePoints({
|
|
109
|
+
ctx,
|
|
110
|
+
curve,
|
|
111
|
+
dimension: new Vector2(width, height),
|
|
112
|
+
offset: new Vector2(margin.x, margin.y),
|
|
113
|
+
rangeX: range_x,
|
|
114
|
+
rangeY: range_y
|
|
115
|
+
});
|
|
116
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
4
|
+
* @param {AnimationCurve} curve
|
|
5
|
+
* @param {Vector2} dimension
|
|
6
|
+
* @param {Vector2} offset
|
|
7
|
+
* @param {number[]} rangeX
|
|
8
|
+
* @param {number[]} rangeY
|
|
9
|
+
*/
|
|
10
|
+
export function canvas2dPlotCurvePoints({ ctx, curve, dimension, offset, rangeX, rangeY }: CanvasRenderingContext2D): void;
|
|
11
|
+
//# sourceMappingURL=canvas2dPlotCurvePoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvas2dPlotCurvePoints.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/canvas2dPlotCurvePoints.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,2FAPW,wBAAwB,QAgElC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {Vector2} from "three";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
6
|
+
* @param {AnimationCurve} curve
|
|
7
|
+
* @param {Vector2} dimension
|
|
8
|
+
* @param {Vector2} offset
|
|
9
|
+
* @param {number[]} rangeX
|
|
10
|
+
* @param {number[]} rangeY
|
|
11
|
+
*/
|
|
12
|
+
export function canvas2dPlotCurvePoints({
|
|
13
|
+
ctx,
|
|
14
|
+
curve,
|
|
15
|
+
dimension,
|
|
16
|
+
offset,
|
|
17
|
+
rangeX= [0, 1],
|
|
18
|
+
rangeY= [0, 1]
|
|
19
|
+
}) {
|
|
20
|
+
const keyframes = curve.keys;
|
|
21
|
+
// No data
|
|
22
|
+
if (keyframes.length === 0)
|
|
23
|
+
return;
|
|
24
|
+
|
|
25
|
+
const [minX, maxX] = rangeX;
|
|
26
|
+
const [minY, maxY] = rangeY;
|
|
27
|
+
|
|
28
|
+
const firstKeyTime = keyframes[0].time;
|
|
29
|
+
const lastKeyTime = keyframes[keyframes.length - 1].time;
|
|
30
|
+
|
|
31
|
+
const axisSize = new Vector2(
|
|
32
|
+
dimension.x - offset.x * 2,
|
|
33
|
+
dimension.y - offset.y * 2
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const timeRange = maxX - minX
|
|
37
|
+
const valueRange = maxY - minY
|
|
38
|
+
|
|
39
|
+
const inverseTimeRange = timeRange !== 0 ? 1 / timeRange : 0;
|
|
40
|
+
const inverseValueRange = valueRange !== 0 ? 1 / valueRange : 0;
|
|
41
|
+
|
|
42
|
+
const pixelCountX = Math.max(axisSize.x - 1 , 1);
|
|
43
|
+
const timeStep = timeRange * (1 / pixelCountX)
|
|
44
|
+
|
|
45
|
+
ctx.beginPath();
|
|
46
|
+
let started = false
|
|
47
|
+
const offScreenMargin = 50
|
|
48
|
+
for (let i = 0; i < dimension.x; i++) {
|
|
49
|
+
const t = minX + (i * timeStep) - (offset.x * timeStep);
|
|
50
|
+
if (t < firstKeyTime || t > lastKeyTime)
|
|
51
|
+
continue;
|
|
52
|
+
|
|
53
|
+
const value = curve.evaluate(t);
|
|
54
|
+
|
|
55
|
+
const normY = (value - minY) * inverseValueRange
|
|
56
|
+
const normX = (t - minX) * inverseTimeRange
|
|
57
|
+
|
|
58
|
+
const y = (1 - normY) * axisSize.y + offset.y
|
|
59
|
+
const x = normX * axisSize.x + offset.x
|
|
60
|
+
|
|
61
|
+
if (x >= -offScreenMargin && !started) {
|
|
62
|
+
ctx.moveTo(x, y);
|
|
63
|
+
started = true
|
|
64
|
+
}
|
|
65
|
+
else
|
|
66
|
+
ctx.lineTo(x,y);
|
|
67
|
+
}
|
|
68
|
+
ctx.stroke()
|
|
69
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create upload to get curve data and trigger a signal
|
|
3
|
+
* @param {HTMLElement} el
|
|
4
|
+
* @returns {Signal}
|
|
5
|
+
*/
|
|
6
|
+
export function createCurveUploader(el: HTMLElement): Signal;
|
|
7
|
+
import Signal from "../../../../core/events/signal/Signal.js";
|
|
8
|
+
//# sourceMappingURL=createCurveUploader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createCurveUploader.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/createCurveUploader.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wCAHW,WAAW,GACT,MAAM,CAiBlB;mBAxBkB,0CAA0C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Signal from "../../../../core/events/signal/Signal.js";
|
|
2
|
+
import {uploadViaElement} from "./uploadViaElement.js";
|
|
3
|
+
import {AnimationCurve} from "../AnimationCurve.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Create upload to get curve data and trigger a signal
|
|
7
|
+
* @param {HTMLElement} el
|
|
8
|
+
* @returns {Signal}
|
|
9
|
+
*/
|
|
10
|
+
export function createCurveUploader(el) {
|
|
11
|
+
const onCurveChange = new Signal();
|
|
12
|
+
|
|
13
|
+
let curve = new AnimationCurve();
|
|
14
|
+
uploadViaElement(el, (text) => {
|
|
15
|
+
try {
|
|
16
|
+
const importedCurve = JSON.parse(text);
|
|
17
|
+
curve.fromJSON(importedCurve);
|
|
18
|
+
onCurveChange.send1(curve);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
console.error("Invalid JSON curve file:", err);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return onCurveChange;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createKeyCoordinateLabelView.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/createKeyCoordinateLabelView.js"],"names":[],"mappings":"AAGA,0DAWC;sBAdqB,sCAAsC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import LabelView from "../../../../view/common/LabelView.js";
|
|
2
|
+
import {CSS_ABSOLUTE_POSITIONING} from "../../../../view/CSS_ABSOLUTE_POSITIONING.js";
|
|
3
|
+
|
|
4
|
+
export function createKeyCoordinateLabelView() {
|
|
5
|
+
return new LabelView("", {
|
|
6
|
+
css: {
|
|
7
|
+
...CSS_ABSOLUTE_POSITIONING,
|
|
8
|
+
zIndex: 1000,
|
|
9
|
+
background: `rgba(0, 0, 0, 0.4)`,
|
|
10
|
+
padding: '4px 6px',
|
|
11
|
+
color: 'white',
|
|
12
|
+
font: '12px Tahoma, monospaced'
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {element} markerElement
|
|
4
|
+
* @param {CanvasView} graph
|
|
5
|
+
* @param {AABB2} frame
|
|
6
|
+
* @param {Vector2} margin
|
|
7
|
+
* @param {AABB2} validEditableBounds
|
|
8
|
+
* @param {AnimationCurve} curve
|
|
9
|
+
* @param {function} fnUpdateGraph
|
|
10
|
+
* @param {Keyframe} keyframe
|
|
11
|
+
* @param {List} selectedKeyframes
|
|
12
|
+
* @param {ObservedValue} activeKeyframe
|
|
13
|
+
* @param {LabelView} keyCoordinateDisplay
|
|
14
|
+
* @param {function} fnUpdateMarkerPosition
|
|
15
|
+
* @param {Signal} frameUpdated
|
|
16
|
+
* @param {Signal} keyframeChange
|
|
17
|
+
* @param {EmptyView} vContainer
|
|
18
|
+
* @param {ActionProcessor} actionProcessor
|
|
19
|
+
* @param {keyframesContext} actionProcessorCTX
|
|
20
|
+
* @returns {DraggableAspect}
|
|
21
|
+
*/
|
|
22
|
+
export function createKeyframeDraggableAspect({ markerElement, graph, frame, margin, validEditableBounds, curve, fnUpdateGraph, keyframe, selectedKeyframes, activeKeyframe, keyCoordinateDisplay, fnUpdateMarkerPosition, frameUpdated, keyframeChange, vContainer, actionProcessor, actionProcessorCTX }: element): DraggableAspect;
|
|
23
|
+
import { DraggableAspect } from "../../../ui/DraggableAspect.js";
|
|
24
|
+
//# sourceMappingURL=createKeyframeDraggableAspect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createKeyframeDraggableAspect.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/createKeyframeDraggableAspect.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,sTAFa,eAAe,CA0F3B;gCApH6B,gCAAgC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {AnimationCurve} from "../AnimationCurve.js";
|
|
2
|
+
import {DraggableAspect} from "../../../ui/DraggableAspect.js";
|
|
3
|
+
import {position_canvas_to_curve} from "../draw/position_canvas_to_curve.js";
|
|
4
|
+
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
5
|
+
import {updateKeyframePosition} from "./updateKeyframePosition.js";
|
|
6
|
+
import {number_pretty_print} from "../../../../core/primitives/numbers/number_pretty_print.js";
|
|
7
|
+
import {applyActionMove} from "../actionProcessorOperations/applyActionChange.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param {element} markerElement
|
|
12
|
+
* @param {CanvasView} graph
|
|
13
|
+
* @param {AABB2} frame
|
|
14
|
+
* @param {Vector2} margin
|
|
15
|
+
* @param {AABB2} validEditableBounds
|
|
16
|
+
* @param {AnimationCurve} curve
|
|
17
|
+
* @param {function} fnUpdateGraph
|
|
18
|
+
* @param {Keyframe} keyframe
|
|
19
|
+
* @param {List} selectedKeyframes
|
|
20
|
+
* @param {ObservedValue} activeKeyframe
|
|
21
|
+
* @param {LabelView} keyCoordinateDisplay
|
|
22
|
+
* @param {function} fnUpdateMarkerPosition
|
|
23
|
+
* @param {Signal} frameUpdated
|
|
24
|
+
* @param {Signal} keyframeChange
|
|
25
|
+
* @param {EmptyView} vContainer
|
|
26
|
+
* @param {ActionProcessor} actionProcessor
|
|
27
|
+
* @param {keyframesContext} actionProcessorCTX
|
|
28
|
+
* @returns {DraggableAspect}
|
|
29
|
+
*/
|
|
30
|
+
export function createKeyframeDraggableAspect({
|
|
31
|
+
markerElement,
|
|
32
|
+
graph,
|
|
33
|
+
frame,
|
|
34
|
+
margin,
|
|
35
|
+
validEditableBounds,
|
|
36
|
+
curve,
|
|
37
|
+
fnUpdateGraph, keyframe,
|
|
38
|
+
selectedKeyframes,
|
|
39
|
+
activeKeyframe,
|
|
40
|
+
keyCoordinateDisplay,
|
|
41
|
+
fnUpdateMarkerPosition,
|
|
42
|
+
frameUpdated,
|
|
43
|
+
keyframeChange,
|
|
44
|
+
vContainer,
|
|
45
|
+
actionProcessor,
|
|
46
|
+
actionProcessorCTX
|
|
47
|
+
}) {
|
|
48
|
+
const curveSet = {
|
|
49
|
+
curveStartIndices: new AnimationCurve(),
|
|
50
|
+
curveStartValues: new AnimationCurve(),
|
|
51
|
+
curveEndIndices: new AnimationCurve(),
|
|
52
|
+
curveEndValue: new AnimationCurve(),
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return new DraggableAspect({
|
|
56
|
+
el: markerElement,
|
|
57
|
+
drag(position) {
|
|
58
|
+
const moveKeyframeToCoord = position_canvas_to_curve(
|
|
59
|
+
graph.size,
|
|
60
|
+
frame,
|
|
61
|
+
margin,
|
|
62
|
+
position.x,
|
|
63
|
+
position.y
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
if (isMovingOutOfBounds(moveKeyframeToCoord, keyframe, validEditableBounds, selectedKeyframes)) {
|
|
67
|
+
const deltaPosition = new Vector2(
|
|
68
|
+
moveKeyframeToCoord.x - keyframe.time,
|
|
69
|
+
moveKeyframeToCoord.y - keyframe.value
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
selectedKeyframes.forEach((selKf) => {
|
|
73
|
+
if (activeKeyframe.get() !== selKf) {
|
|
74
|
+
updateKeyframePosition(selKf, deltaPosition, curve);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
updateKeyframePosition(keyframe, deltaPosition, curve);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
keyCoordinateDisplay.updateText(`${number_pretty_print(moveKeyframeToCoord.x)}, ${number_pretty_print(moveKeyframeToCoord.y)}`);
|
|
82
|
+
keyCoordinateDisplay.position.set(
|
|
83
|
+
position.x,
|
|
84
|
+
position.y - 24
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
fnUpdateMarkerPosition();
|
|
88
|
+
frameUpdated.send0();
|
|
89
|
+
fnUpdateGraph();
|
|
90
|
+
|
|
91
|
+
keyframeChange.send0();
|
|
92
|
+
},
|
|
93
|
+
dragStart() {
|
|
94
|
+
activeKeyframe.set(keyframe);
|
|
95
|
+
|
|
96
|
+
curveSet.curveStartIndices.clear()
|
|
97
|
+
curveSet.curveStartIndices.addMany(curve.keys)
|
|
98
|
+
curveSet.curveStartValues.copy(curve); //deep copy
|
|
99
|
+
|
|
100
|
+
vContainer.addChild(keyCoordinateDisplay);
|
|
101
|
+
},
|
|
102
|
+
dragEnd() {
|
|
103
|
+
curveSet.curveEndIndices.clear()
|
|
104
|
+
curveSet.curveEndIndices.addMany(curve.keys)
|
|
105
|
+
curveSet.curveEndValue.copy(curve); //deep copy
|
|
106
|
+
|
|
107
|
+
vContainer.removeChild(keyCoordinateDisplay);
|
|
108
|
+
|
|
109
|
+
//Reset back before action processor
|
|
110
|
+
for (let i = 0; i < curve.length; i++) {
|
|
111
|
+
curve.keys[i] = curveSet.curveStartIndices.keys[i];
|
|
112
|
+
curve.keys[i].copy(curveSet.curveStartValues.keys[i]);
|
|
113
|
+
}
|
|
114
|
+
applyActionMove('move keyframe(s)', curveSet, actionProcessor, actionProcessorCTX);
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Check if new keyframe position is in the valid bounds
|
|
122
|
+
* @param {Vector2} newCoord
|
|
123
|
+
* @param {Keyframe} keyframe
|
|
124
|
+
* @param {AABB2} validBounds
|
|
125
|
+
* @param {List} selectedKeyframes
|
|
126
|
+
* @returns {boolean}
|
|
127
|
+
*/
|
|
128
|
+
function isMovingOutOfBounds(newCoord, keyframe, validBounds, selectedKeyframes) {
|
|
129
|
+
const transitionVector = newCoord.clone()._sub(keyframe.time, keyframe.value);
|
|
130
|
+
|
|
131
|
+
const isSelectionOutOfBound = (kf) => {
|
|
132
|
+
const adjustedCord = transitionVector.clone()._add(kf.time, kf.value);
|
|
133
|
+
return (!validBounds.containsPoint(adjustedCord.x, adjustedCord.y))
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
if (!validBounds.containsPoint(newCoord.x, newCoord.y)
|
|
137
|
+
|| selectedKeyframes.some(isSelectionOutOfBound)) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
//all checks passed
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createKeyframeMarker.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/createKeyframeMarker.js"],"names":[],"mappings":"AAEA,6CAQC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import EmptyView from "../../../../view/elements/EmptyView.js";
|
|
2
|
+
|
|
3
|
+
export function createKeyframeMarker(){
|
|
4
|
+
const markerSize = 8;
|
|
5
|
+
const markerHitPadSize = 24;
|
|
6
|
+
|
|
7
|
+
const markerView = createKeyframeMarkerView(markerSize)
|
|
8
|
+
const markerHitboxView = createKeyframeMarkerHitboxView(markerHitPadSize, markerSize)
|
|
9
|
+
|
|
10
|
+
return markerView.addChild(markerHitboxView)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function createKeyframeMarkerView(markerSize) {
|
|
14
|
+
return new EmptyView({
|
|
15
|
+
css: {
|
|
16
|
+
width: `${markerSize}px`,
|
|
17
|
+
height: `${markerSize}px`,
|
|
18
|
+
background: "#00ff00",
|
|
19
|
+
border: "none",
|
|
20
|
+
position: "absolute",
|
|
21
|
+
top: `-${markerSize / 2}px`,
|
|
22
|
+
left: `-${markerSize / 2}px`,
|
|
23
|
+
pointerEvents: "auto",
|
|
24
|
+
borderRadius: `${markerSize}px`
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function createKeyframeMarkerHitboxView(markerHitPadSize, markerSize) {
|
|
30
|
+
return new EmptyView({
|
|
31
|
+
css: {
|
|
32
|
+
opacity: 100,
|
|
33
|
+
width: `${markerHitPadSize}px`,
|
|
34
|
+
height: `${markerHitPadSize}px`,
|
|
35
|
+
borderRadius: `${markerHitPadSize}px`,
|
|
36
|
+
// background: 'rgba(255,0,0,0.2)',
|
|
37
|
+
position: "absolute",
|
|
38
|
+
top: `-${(markerHitPadSize - markerSize) / 2}px`,
|
|
39
|
+
left: `-${(markerHitPadSize - markerSize) / 2}px`
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {CanvasView} graph
|
|
4
|
+
* @param {AABB2} frame
|
|
5
|
+
* @param {Vector2} margin
|
|
6
|
+
* @param {function} fnUpdate
|
|
7
|
+
* @returns {DragHandler}
|
|
8
|
+
*/
|
|
9
|
+
export function createPanTool({ graph, frame, margin, fnUpdate, }: CanvasView): DragHandler;
|
|
10
|
+
import { DragHandler } from "./DragHandler.js";
|
|
11
|
+
//# sourceMappingURL=createPanTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPanTool.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/createPanTool.js"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,gFAFa,WAAW,CA6BvB;4BAtCyB,kBAAkB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
2
|
+
import AABB2 from "../../../../core/geom/2d/aabb/AABB2.js";
|
|
3
|
+
import {DragHandler} from "./DragHandler.js";
|
|
4
|
+
import {position_canvas_to_curve} from "../draw/position_canvas_to_curve.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {CanvasView} graph
|
|
9
|
+
* @param {AABB2} frame
|
|
10
|
+
* @param {Vector2} margin
|
|
11
|
+
* @param {function} fnUpdate
|
|
12
|
+
* @returns {DragHandler}
|
|
13
|
+
*/
|
|
14
|
+
export function createPanTool({
|
|
15
|
+
graph,
|
|
16
|
+
frame,
|
|
17
|
+
margin,
|
|
18
|
+
fnUpdate,
|
|
19
|
+
}) {
|
|
20
|
+
|
|
21
|
+
return new DragHandler({
|
|
22
|
+
dragStart(position) {
|
|
23
|
+
// console.log("start pan");
|
|
24
|
+
},
|
|
25
|
+
drag(position,delta) {
|
|
26
|
+
// console.log("panning");
|
|
27
|
+
const newPosition = position.clone();
|
|
28
|
+
const lastPosition = position.clone().add(delta);
|
|
29
|
+
|
|
30
|
+
const newCord = position_canvas_to_curve(graph.size, frame, margin, newPosition.x, newPosition.y);
|
|
31
|
+
const lastCord = position_canvas_to_curve(graph.size, frame, margin, lastPosition.x, lastPosition.y);
|
|
32
|
+
const deltaCord = newCord.clone().sub(lastCord);
|
|
33
|
+
|
|
34
|
+
frame.move(deltaCord.x,deltaCord.y);
|
|
35
|
+
fnUpdate();
|
|
36
|
+
},
|
|
37
|
+
dragEnd() {
|
|
38
|
+
// console.log("end pan");
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {KeyframeStateManager} keyframeStateManager
|
|
4
|
+
* @param {CanvasView} graph
|
|
5
|
+
* @param {AABB2} frame
|
|
6
|
+
* @param {Vector2} margin
|
|
7
|
+
* @param {function} fnUpdate
|
|
8
|
+
* @param {ActionProcessor} actionProcessor
|
|
9
|
+
* @param {keyframesContext} actionCTX
|
|
10
|
+
* @returns {DragHandler}
|
|
11
|
+
*/
|
|
12
|
+
export function createSelectionBoxTool({ keyframeStateManager, graph, frame, margin, fnUpdate, actionProcessor, actionCTX }: KeyframeStateManager): DragHandler;
|
|
13
|
+
import { DragHandler } from "./DragHandler.js";
|
|
14
|
+
//# sourceMappingURL=createSelectionBoxTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSelectionBoxTool.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/editor/createSelectionBoxTool.js"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,oJAFa,WAAW,CA6EvB;4BAxFyB,kBAAkB"}
|