@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.
- 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 +14 -0
- package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/AABB3.js +24 -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/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
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
import Signal from "../../../../core/events/signal/Signal.js";
|
|
2
|
-
import AABB2 from "../../../../core/geom/2d/aabb/AABB2.js";
|
|
3
|
-
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
4
|
-
import ObservedValue from "../../../../core/model/ObservedValue.js";
|
|
5
|
-
import { number_pretty_print } from "../../../../core/primitives/numbers/number_pretty_print.js";
|
|
6
|
-
import LabelView from "../../../../view/common/LabelView.js";
|
|
7
|
-
import { CSS_ABSOLUTE_POSITIONING } from "../../../../view/CSS_ABSOLUTE_POSITIONING.js";
|
|
8
|
-
import { CanvasView } from "../../../../view/elements/CanvasView.js";
|
|
9
|
-
import EmptyView from "../../../../view/elements/EmptyView.js";
|
|
10
|
-
import { canvas2d_plot_data_line } from "../../../graphics/canvas/canvas2d_plot_data_line.js";
|
|
11
|
-
import { MouseEvents } from "../../../input/devices/events/MouseEvents.js";
|
|
12
|
-
import { readPositionFromMouseEvent } from "../../../input/devices/PointerDevice.js";
|
|
13
|
-
import { DraggableAspect } from "../../../ui/DraggableAspect.js";
|
|
14
|
-
import { animation_curve_compute_aabb } from "../animation_curve_compute_aabb.js";
|
|
15
|
-
import { sample_animation_curve_to_float_array } from "../compression/sample_animation_curve_to_float_array.js";
|
|
16
|
-
import { Keyframe } from "../Keyframe.js";
|
|
17
|
-
import { build_tangent_editor } from "./build_tangent_editor.js";
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* @param {Vector2} size
|
|
22
|
-
* @param {AABB2} frame
|
|
23
|
-
* @param {Vector2} margin
|
|
24
|
-
* @param {number} x
|
|
25
|
-
* @param {number} y
|
|
26
|
-
* @return {Vector2}
|
|
27
|
-
*/
|
|
28
|
-
function position_curve_to_canvas(size, frame, margin, x, y) {
|
|
29
|
-
const width = size.x;
|
|
30
|
-
const height = size.y;
|
|
31
|
-
|
|
32
|
-
const curve_width = frame.getWidth();
|
|
33
|
-
const curve_width_multiplier = curve_width > 0 ? 1 / curve_width : 0;
|
|
34
|
-
const u = (x - frame.x0) * curve_width_multiplier;
|
|
35
|
-
|
|
36
|
-
const curve_height = frame.getHeight();
|
|
37
|
-
const curve_height_multiplier = curve_height > 0 ? 1 / curve_height : 0;
|
|
38
|
-
const v = 1 - (y - frame.y0) * curve_height_multiplier;
|
|
39
|
-
|
|
40
|
-
return new Vector2(margin.x + (u * (width - margin.x * 2)), margin.y + v * (height - margin.y * 2));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* @param {Vector2} size
|
|
46
|
-
* @param {AABB2} frame
|
|
47
|
-
* @param {Vector2} margin
|
|
48
|
-
* @param {number} x
|
|
49
|
-
* @param {number} y
|
|
50
|
-
* @return {Vector2}
|
|
51
|
-
*/
|
|
52
|
-
function position_canvas_to_curve(size, frame, margin, x, y) {
|
|
53
|
-
|
|
54
|
-
const width = size.x;
|
|
55
|
-
const height = size.y;
|
|
56
|
-
|
|
57
|
-
const u = (x - margin.x) / (width - margin.x * 2);
|
|
58
|
-
const v = 1 - (y - margin.y) / (height - margin.y * 2);
|
|
59
|
-
|
|
60
|
-
return new Vector2(
|
|
61
|
-
u * frame.getWidth() + frame.x0,
|
|
62
|
-
v * frame.getHeight() + frame.y0
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
*
|
|
68
|
-
* @param {AnimationCurve} curve
|
|
69
|
-
* @param {Vector2} [size]
|
|
70
|
-
* @param {Vector2} [margin] How much space to leave empty around the plotted bounds
|
|
71
|
-
* @returns {View}
|
|
72
|
-
*/
|
|
73
|
-
export function build_curve_editor({
|
|
74
|
-
curve,
|
|
75
|
-
size = new Vector2(300, 300),
|
|
76
|
-
margin = new Vector2(36, 36)
|
|
77
|
-
}) {
|
|
78
|
-
|
|
79
|
-
const vContainer = new EmptyView({
|
|
80
|
-
css: {
|
|
81
|
-
pointerEvents: "auto"
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const graph = new CanvasView();
|
|
86
|
-
graph.size.copy(size);
|
|
87
|
-
|
|
88
|
-
const frame = new AABB2();
|
|
89
|
-
|
|
90
|
-
const frame_updated = new Signal();
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
* @type {ObservedValue<Keyframe>}
|
|
95
|
-
*/
|
|
96
|
-
const active_keyframe = new ObservedValue(null);
|
|
97
|
-
|
|
98
|
-
const vCoordinate = new LabelView("", {
|
|
99
|
-
css: {
|
|
100
|
-
...CSS_ABSOLUTE_POSITIONING,
|
|
101
|
-
zIndex: 1000,
|
|
102
|
-
background: `rgba(0, 0, 0, 0.4)`,
|
|
103
|
-
padding: '4px 6px',
|
|
104
|
-
color: 'white',
|
|
105
|
-
font: '12px Tahoma, monospaced'
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
function handle_curve_update() {
|
|
110
|
-
animation_curve_compute_aabb(frame, curve);
|
|
111
|
-
|
|
112
|
-
frame_updated.send0();
|
|
113
|
-
|
|
114
|
-
update_graph();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
function update_graph() {
|
|
119
|
-
const width = graph.size.x;
|
|
120
|
-
const data = new Float32Array(width);
|
|
121
|
-
|
|
122
|
-
sample_animation_curve_to_float_array(data, 0, curve, data.length);
|
|
123
|
-
|
|
124
|
-
canvas2d_plot_data_line({
|
|
125
|
-
data,
|
|
126
|
-
ctx: graph.context2d,
|
|
127
|
-
width: width,
|
|
128
|
-
height: graph.size.y,
|
|
129
|
-
margin: margin,
|
|
130
|
-
range_y: [frame.y0, frame.y1],
|
|
131
|
-
range_x: [frame.x0, frame.x1],
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const keyframe_views = new Map();
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
*
|
|
139
|
-
* @param {Keyframe} keyframe
|
|
140
|
-
*/
|
|
141
|
-
function add_keyframe(keyframe) {
|
|
142
|
-
const vContainerMarker = new EmptyView({
|
|
143
|
-
css: {
|
|
144
|
-
position: "absolute",
|
|
145
|
-
top: 0,
|
|
146
|
-
left: 0,
|
|
147
|
-
pointerEvents: "none"
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
const marker_size = 8;
|
|
152
|
-
const marker = new EmptyView({
|
|
153
|
-
css: {
|
|
154
|
-
width: `${marker_size}px`,
|
|
155
|
-
height: `${marker_size}px`,
|
|
156
|
-
background: "#00ff00",
|
|
157
|
-
border: "none",
|
|
158
|
-
position: "absolute",
|
|
159
|
-
top: `-${marker_size / 2}px`,
|
|
160
|
-
left: `-${marker_size / 2}px`,
|
|
161
|
-
pointerEvents: "auto",
|
|
162
|
-
borderRadius: `${marker_size}px`
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
// add extra element for mouse event capture to make it easier to click on the marker
|
|
167
|
-
const marker_hit_pad_size = 24;
|
|
168
|
-
marker.addChild(new EmptyView({
|
|
169
|
-
css: {
|
|
170
|
-
opacity: 0,
|
|
171
|
-
width: `${marker_hit_pad_size}px`,
|
|
172
|
-
height: `${marker_hit_pad_size}px`,
|
|
173
|
-
borderRadius: `${marker_hit_pad_size}px`,
|
|
174
|
-
// background: 'rgba(255,0,0,0.2)',
|
|
175
|
-
position: "absolute",
|
|
176
|
-
top: `-${(marker_hit_pad_size - marker_size) / 2}px`,
|
|
177
|
-
left: `-${(marker_hit_pad_size - marker_size) / 2}px`
|
|
178
|
-
}
|
|
179
|
-
}))
|
|
180
|
-
|
|
181
|
-
function updatePosition() {
|
|
182
|
-
const canvas_coordinates = position_curve_to_canvas(
|
|
183
|
-
graph.size,
|
|
184
|
-
frame,
|
|
185
|
-
margin,
|
|
186
|
-
keyframe.time,
|
|
187
|
-
keyframe.value
|
|
188
|
-
);
|
|
189
|
-
vContainerMarker.position.copy(canvas_coordinates);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function updateActiveState() {
|
|
193
|
-
if (active_keyframe.get() === keyframe) {
|
|
194
|
-
marker.css({
|
|
195
|
-
background: '#FFFFFF'
|
|
196
|
-
});
|
|
197
|
-
} else {
|
|
198
|
-
marker.css({
|
|
199
|
-
background: '#00ff00'
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
updatePosition();
|
|
205
|
-
|
|
206
|
-
const marker_el = marker.el;
|
|
207
|
-
|
|
208
|
-
const previous = new Vector2();
|
|
209
|
-
const draggable = new DraggableAspect({
|
|
210
|
-
el: marker_el,
|
|
211
|
-
drag(position) {
|
|
212
|
-
const delta = new Vector2();
|
|
213
|
-
delta.subVectors(position, previous);
|
|
214
|
-
|
|
215
|
-
const keyframe_coord = position_canvas_to_curve(
|
|
216
|
-
graph.size,
|
|
217
|
-
frame,
|
|
218
|
-
margin,
|
|
219
|
-
position.x,
|
|
220
|
-
position.y
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
// console.log(keyframe_coord);
|
|
224
|
-
|
|
225
|
-
keyframe.time = keyframe_coord.x;
|
|
226
|
-
keyframe.value = keyframe_coord.y;
|
|
227
|
-
|
|
228
|
-
vCoordinate.updateText(`${number_pretty_print(keyframe_coord.x)}, ${number_pretty_print(keyframe_coord.y)}`);
|
|
229
|
-
vCoordinate.position.set(
|
|
230
|
-
position.x,
|
|
231
|
-
position.y - 24
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
let keyframe_index = curve.keys.indexOf(keyframe);
|
|
235
|
-
|
|
236
|
-
if (keyframe_index < (curve.keys.length - 1) && keyframe.time > curve.keys[keyframe_index + 1].time) {
|
|
237
|
-
const next_index = keyframe_index + 1;
|
|
238
|
-
const next = curve.keys[next_index];
|
|
239
|
-
|
|
240
|
-
curve.keys[next_index] = keyframe;
|
|
241
|
-
curve.keys[keyframe_index] = next;
|
|
242
|
-
|
|
243
|
-
keyframe_index = next_index;
|
|
244
|
-
} else if (keyframe_index > 0 && keyframe.time < curve.keys[keyframe_index - 1].time) {
|
|
245
|
-
const prev_index = keyframe_index - 1;
|
|
246
|
-
const prev = curve.keys[prev_index];
|
|
247
|
-
|
|
248
|
-
curve.keys[prev_index] = keyframe;
|
|
249
|
-
curve.keys[keyframe_index] = prev;
|
|
250
|
-
|
|
251
|
-
keyframe_index = prev_index;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
curve.alignTangents(keyframe_index);
|
|
255
|
-
curve.smoothTangents(keyframe_index, 1);
|
|
256
|
-
|
|
257
|
-
if (keyframe_index > 0) {
|
|
258
|
-
curve.alignTangents(keyframe_index - 1);
|
|
259
|
-
curve.smoothTangents(keyframe_index - 1, 1);
|
|
260
|
-
}
|
|
261
|
-
if (keyframe_index < curve.keys.length - 1) {
|
|
262
|
-
curve.alignTangents(keyframe_index + 1);
|
|
263
|
-
curve.smoothTangents(keyframe_index + 1, 1);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
updatePosition();
|
|
267
|
-
update_graph();
|
|
268
|
-
|
|
269
|
-
previous.copy(position);
|
|
270
|
-
},
|
|
271
|
-
dragStart(position) {
|
|
272
|
-
previous.copy(position);
|
|
273
|
-
|
|
274
|
-
active_keyframe.set(keyframe);
|
|
275
|
-
|
|
276
|
-
vContainer.addChild(vCoordinate);
|
|
277
|
-
},
|
|
278
|
-
dragEnd() {
|
|
279
|
-
handle_curve_update();
|
|
280
|
-
|
|
281
|
-
vContainer.removeChild(vCoordinate);
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
draggable.getPointer().on.tap.add(
|
|
286
|
-
/**
|
|
287
|
-
*
|
|
288
|
-
* @param position
|
|
289
|
-
* @param {MouseEvent} event
|
|
290
|
-
*/
|
|
291
|
-
(position, event) => {
|
|
292
|
-
// make active
|
|
293
|
-
active_keyframe.set(keyframe);
|
|
294
|
-
|
|
295
|
-
if (event.ctrlKey) {
|
|
296
|
-
// remove
|
|
297
|
-
curve.remove(keyframe);
|
|
298
|
-
remove_keyframe(keyframe);
|
|
299
|
-
update_graph();
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
marker.on.linked.add(draggable.start, draggable);
|
|
304
|
-
marker.on.unlinked.add(draggable.stop, draggable);
|
|
305
|
-
|
|
306
|
-
marker.bindSignal(frame_updated, updatePosition);
|
|
307
|
-
marker.bindSignal(active_keyframe.onChanged, updateActiveState);
|
|
308
|
-
|
|
309
|
-
const vTangentEditor = build_tangent_editor({
|
|
310
|
-
keyframe: keyframe,
|
|
311
|
-
size: graph.size,
|
|
312
|
-
ctx: graph.context2d,
|
|
313
|
-
frame,
|
|
314
|
-
margin
|
|
315
|
-
});
|
|
316
|
-
vContainerMarker.addChild(vTangentEditor);
|
|
317
|
-
|
|
318
|
-
vContainerMarker.addChild(marker);
|
|
319
|
-
|
|
320
|
-
keyframe_views.set(keyframe, vContainerMarker);
|
|
321
|
-
|
|
322
|
-
vContainer.addChild(vContainerMarker);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
function remove_keyframe(keyframe) {
|
|
326
|
-
const marker_view = keyframe_views.get(keyframe);
|
|
327
|
-
|
|
328
|
-
vContainer.removeChild(marker_view);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
graph.on.linked.add(() => {
|
|
332
|
-
curve.keys.forEach(add_keyframe);
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
graph.on.unlinked.add(() => {
|
|
336
|
-
curve.keys.forEach(remove_keyframe);
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
vContainer.el.addEventListener(MouseEvents.DoubleClick, (e) => {
|
|
340
|
-
|
|
341
|
-
const mouse_position = new Vector2();
|
|
342
|
-
|
|
343
|
-
readPositionFromMouseEvent(mouse_position, e, vContainer.el);
|
|
344
|
-
|
|
345
|
-
const curve_position = position_canvas_to_curve(graph.size, frame, margin, mouse_position.x, mouse_position.y);
|
|
346
|
-
|
|
347
|
-
const key = Keyframe.from(curve_position.x, curve_position.y);
|
|
348
|
-
const key_index = curve.add(key);
|
|
349
|
-
|
|
350
|
-
curve.alignTangents(key_index);
|
|
351
|
-
curve.smoothTangents(key_index, 1);
|
|
352
|
-
|
|
353
|
-
add_keyframe(key);
|
|
354
|
-
update_graph();
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
graph.on.linked.add(handle_curve_update);
|
|
358
|
-
|
|
359
|
-
vContainer.addChild(graph);
|
|
360
|
-
|
|
361
|
-
return vContainer;
|
|
362
|
-
}
|