Explorar o código

fix: 修改连段修改为0时向量无法实时获取问题

bill hai 2 meses
pai
achega
fc4f173d28

+ 8 - 4
src/core/components/line/single-line.vue

@@ -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] });
     }
   },

+ 0 - 4
src/core/hook/use-expose.ts

@@ -27,7 +27,6 @@ import { useMouseShapesStatus } from "./use-mouse-status.ts";
 import { Mode } from "@/constant/mode.ts";
 import { ElMessageBox } from "element-plus";
 import { mergeFuns } from "@/utils/shared.ts";
-import { themeColor } from "@/constant";
 import { getImage, isSvgString } from "@/utils/resource.ts";
 import { useResourceHandler } from "./use-fetch.ts";
 import { useConfig } from "./use-config.ts";
@@ -38,7 +37,6 @@ import { useProportion } from "./use-proportion.ts";
 import { ShapeType } from "@/index.ts";
 import { useGetDXF } from "./use-dxf.ts";
 import { getIconStyle } from "../components/icon/index.ts";
-import { useGetShapeBelong } from "./use-component.ts";
 
 // 自动粘贴服务
 export const useAutoPaste = () => {
@@ -109,12 +107,10 @@ export const useShortcutKey = () => {
   const getChildren = useGetFormalChildren();
   const operMode = useOperMode();
   const eSelection = useExcludeSelection()
-  const getShapeBelong = useGetShapeBelong()
   useListener(
     "keydown",
     (ev) => {
       if (ev.target !== document.body) return;
-      console.log(operMode.value.mulSelection, ev.key, )
       if (ev.key === "z" && ev.ctrlKey) {
         ev.preventDefault();
         history.hasUndo.value && history.undo();

+ 1 - 1
src/example/fuse/views/overview/header.vue

@@ -132,7 +132,7 @@ const setViewToTableCover = async () => {
   draw.config.labelLineConfig.fontSize = 10;
 
   await nextTick();
-  draw.config.labelLineConfig.showOffset = padding;
+  draw.config.labelLineConfig.showOffset = padding - 5;
   draw.initViewport(padding);
   await nextTick();
 

+ 1 - 1
src/example/fuse/views/tabulation/index.vue

@@ -174,7 +174,7 @@ watch(cover, (cover, _, onCleanup) => {
           return coverScale.value;
         },
         set value(val) {
-          coverScale.value = val;
+          coverScale.value = Math.max(val || 0, 1);
         },
         props: { min: 1 },
       },