|
@@ -92,6 +92,7 @@ import {
|
|
|
useMouseShapeStatus,
|
|
|
} from "@/core/hook/use-mouse-status.ts";
|
|
|
import { themeColor } from "@/constant";
|
|
|
+import { Vector2 } from "three";
|
|
|
|
|
|
const mode = useMode();
|
|
|
|
|
@@ -129,6 +130,7 @@ d.strokeWidth.label = "粗细";
|
|
|
d.stroke.label = "颜色";
|
|
|
|
|
|
let isStartChange = false;
|
|
|
+let setLineVector: Vector2;
|
|
|
describes.length = {
|
|
|
type: "inputNum",
|
|
|
label: "线段长度",
|
|
@@ -139,6 +141,7 @@ describes.length = {
|
|
|
set value(val) {
|
|
|
if (!isStartChange) {
|
|
|
emit("updateBefore", [props.line.a, props.line.b]);
|
|
|
+ setLineVector = lineVector(points.value);
|
|
|
}
|
|
|
isStartChange = true;
|
|
|
const aCount = props.data.lines.filter(
|
|
@@ -151,16 +154,17 @@ describes.length = {
|
|
|
if (aCount === bCount || (aCount > 1 && bCount > 1)) {
|
|
|
// 两端伸展
|
|
|
const center = lineCenter(points.value);
|
|
|
- const l1 = getVectorLine(lineVector([center, points.value[0]]), center, val / 2);
|
|
|
- const l2 = getVectorLine(lineVector([center, points.value[1]]), center, val / 2);
|
|
|
+ const l1 = getVectorLine(setLineVector.clone().multiplyScalar(-1), center, val / 2);
|
|
|
+ const l2 = getVectorLine(setLineVector, center, val / 2);
|
|
|
emit("updatePoint", { ...points.value[0], ...l1[1] });
|
|
|
emit("updatePoint", { ...points.value[1], ...l2[1] });
|
|
|
} else {
|
|
|
// 单端伸展
|
|
|
const changeNdx = aCount > 1 ? 1 : 0;
|
|
|
const start = points.value[aCount > 1 ? 0 : 1];
|
|
|
- const end = points.value[changeNdx];
|
|
|
- const line = getVectorLine(lineVector([start, end]), start, val);
|
|
|
+ const lineVec =
|
|
|
+ aCount > 1 ? setLineVector : setLineVector.clone().multiplyScalar(-1);
|
|
|
+ const line = getVectorLine(lineVec, start, val);
|
|
|
emit("updatePoint", { ...points.value[changeNdx], ...line[1] });
|
|
|
}
|
|
|
},
|