tweaked curve point dragging thresholds

master
Jake Wilkinson 2025-11-24 14:24:11 +08:00
parent 21ffc99bbb
commit a6d901d3f0
2 changed files with 111 additions and 114 deletions

View File

@ -671,10 +671,10 @@ export class CurveEditor {
return;
}
}
}
}
// If no handle was hit, then check points
for (let curve of this.curves) {
// If no handle was hit, then check points
for (let curve of this.curves) {
for (let key of ['startPoint', 'endPoint']) {
const p = curve[key];
if (Math.hypot(p.x - mouse.x, p.y - mouse.y) < 10 / this.scale) {
@ -682,7 +682,7 @@ for (let curve of this.curves) {
return;
}
}
}
}
});
@ -774,7 +774,7 @@ for (let curve of this.curves) {
const curves = this.curveSets[motorID];
if (!curves) return;
const tolerance = 2; // pixels/frames tolerance for matching existing points
const tolerance = 4; // pixels/frames tolerance for matching existing points
for (let i = 0; i < curves.length; i++) {
const curve = curves[i];
@ -787,7 +787,7 @@ for (let curve of this.curves) {
curve.startPoint.y = yEditor;
if (curve.startPointHandle) curve.startPointHandle.y = yEditor;
} else {
// remove point by merging with previous
// 🚫 don't allow deleting the very first control point
if (i > 0) {
const prev = curves[i - 1];
const merged = {
@ -797,8 +797,6 @@ for (let curve of this.curves) {
endPoint: curve.endPoint
};
curves.splice(i - 1, 2, merged);
} else {
curves.splice(i, 1); // drop if it's the very first
}
}
this.curveSets[motorID] = curves;
@ -814,7 +812,7 @@ for (let curve of this.curves) {
curve.endPoint.y = yEditor;
if (curve.endPointHandle) curve.endPointHandle.y = yEditor;
} else {
// remove point by merging with next
// 🚫 don't allow deleting the very last control point
if (i < curves.length - 1) {
const next = curves[i + 1];
const merged = {
@ -824,8 +822,6 @@ for (let curve of this.curves) {
endPoint: next.endPoint
};
curves.splice(i, 2, merged);
} else {
curves.splice(i, 1); // drop if it's the very last
}
}
this.curveSets[motorID] = curves;
@ -869,7 +865,8 @@ for (let curve of this.curves) {
return;
}
}
}
}
adjustAllCurvesToDuration(newTime) {

View File

@ -43,7 +43,7 @@ export class SerialManager {
}
const message = [HEADER1, HEADER2, commandCode, lengthHigh, lengthLow, ...payload, checksum];
//console.log(new Uint8Array(message));
console.log(new Uint8Array(message));
await this.writer.write(new Uint8Array(message));
}