From ecdfb7b76b1138d643aae3ae59fff3aeb4d58c75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=AF=97=E6=B4=A5?= <2723065175@qq.com> Date: Mon, 4 Jul 2022 02:05:31 +0000 Subject: [PATCH] =?UTF-8?q?!1957=20=E4=BF=AE=E5=A4=8D:=E6=96=9C=E5=B1=82?= =?UTF-8?q?=E6=9D=BF=E5=8A=9F=E8=83=BD=E7=9A=84=E5=89=8D/=E5=90=8E?= =?UTF-8?q?=E7=BC=A9,=E5=B1=82=E6=9D=BF=E9=92=89=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/RotateLayerBoard.ts | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Add-on/RotateLayerBoard.ts b/src/Add-on/RotateLayerBoard.ts index b2aa7cac2..6a40ed1d8 100644 --- a/src/Add-on/RotateLayerBoard.ts +++ b/src/Add-on/RotateLayerBoard.ts @@ -1,9 +1,10 @@ -import { MathUtils, Matrix4, Vector3 } from "three"; +import { Box3, MathUtils, Matrix4, Vector3 } from "three"; import { app } from "../ApplicationServices/Application"; import { CylinderHole } from "../DatabaseServices/3DSolid/CylinderHole"; import { Board } from "../DatabaseServices/Entity/Board"; import { Command } from "../Editor/CommandMachine"; import { PromptStatus } from "../Editor/PromptResult"; +import { IntersectBox2 } from "../Geometry/Box"; import { equalv3, isParallelTo, MoveMatrix } from "../Geometry/GeUtils"; import { ModalState } from "../UI/Components/Modal/ModalInterface"; import { ERotateType, RotateLayerBoardModal, RotateLayerBoardStore } from "../UI/Components/RotateLayerBoard"; @@ -72,6 +73,29 @@ export class RotateLayerBoard implements Command } } + private CurtailNails = () => + { + let sizeBox = this.currentBoard.BoundingBox; + let size = sizeBox.getSize(new Vector3); + let v = new Vector3(1, 1, 1); + + let frontBox = new Box3(sizeBox.min.clone().sub(v), sizeBox.max.clone().sub(new Vector3(-1, size.y / 2, -1))); + let backBox = new Box3(sizeBox.min.clone().add(new Vector3(-1, size.y / 2, -1)), sizeBox.max.clone().add(v)); + + for (let i = 0; i < this.currentBoard.LayerNails.length; i++) + { + let nail = this.currentBoard.LayerNails[i].Object as CylinderHole; + if (IntersectBox2(nail.BoundingBox, frontBox)) + { + nail.Position = nail.Position.add(new Vector3(0, this.data.frontDist, 0)); + } + else if (IntersectBox2(nail.BoundingBox, backBox)) + { + nail.Position = nail.Position.add(new Vector3(0, -this.data.backDist, 0)); + } + } + }; + private RotateLayerBrByAngle() { let deg = this.data.angle; @@ -102,7 +126,8 @@ export class RotateLayerBoard implements Command this.HandleLayerBoard(newTotalWidth - frontDist - backDist, oldBrData); //修正层板钉 - this.RotateNails(angle, newTotalWidth, oldBrData); + if (angle !== 0) + this.RotateNails(angle, newTotalWidth, oldBrData); } private RotateLayerBrByLength() { @@ -131,8 +156,10 @@ export class RotateLayerBoard implements Command /**获得斜层板 */ private HandleLayerBoard(newWidth: number, oldBrData: IOldBrData) { + this.CurtailNails(); this.currentBoard.Width = newWidth; this.currentBoard.ApplyMatrix(oldBrData.diffMat); + oldBrData.OCS.copyPosition(this.currentBoard.OCS); } /** * 重新计算层板钉