diff --git a/src/DatabaseServices/Board.ts b/src/DatabaseServices/Board.ts index 54916e9a8..23c9e7095 100644 --- a/src/DatabaseServices/Board.ts +++ b/src/DatabaseServices/Board.ts @@ -4,7 +4,7 @@ import { arrayRemoveIf } from '../Common/ArrayExt'; import { UpdateDraw } from '../Common/Status'; import { ObjectSnapMode } from '../Editor/ObjectSnapMode'; import { Box3Ext } from '../Geometry/Box'; -import { equaln, MoveMatrix, rotatePoint } from '../Geometry/GeUtils'; +import { equaln, MoveMatrix, rotatePoint, equalv3 } from '../Geometry/GeUtils'; import ThreeBSP from '../Geometry/ThreeCSG'; import { RenderType } from '../GraphicsSystem/RenderType'; import { BoardProcessOption, ComposingType, DrillType, LinesType, PXLFaceType } from '../UI/Store/BoardInterface'; @@ -542,7 +542,7 @@ export class Board extends Entity } gripShape.MoveGripPoints(indexList, vl); - this.UpdateModelShape(); + this.UpdateBoardShape(); this.UpdateBoardSize(); this.Update(UpdateDraw.Geometry); } @@ -636,7 +636,7 @@ export class Board extends Entity outlen += count; } - this.UpdateModelShape(); + this.UpdateBoardShape(); this.UpdateBoardSize(); this.Update(UpdateDraw.Geometry); } @@ -649,7 +649,7 @@ export class Board extends Entity /** * 更新造型形状和外轮廓形状,用布尔运算 */ - private UpdateModelShape() + private UpdateBoardShape() { let deleteModel: Set = new Set(); @@ -695,6 +695,22 @@ export class Board extends Entity } arrayRemoveIf(this.m_BoardModeling, m => deleteModel.has(m)); + + //源形状min应在0点 + let min = this.m_Shape.BoundingBox.min; + if (!equalv3(min, new Vector3())) + { + let matVec = MoveMatrix(min.clone().negate()); + this.m_Shape.ApplyMatrix(matVec); + this.m_BoardModeling.forEach(m => + { + m.shape.ApplyMatrix(matVec); + }) + + this.ApplyMatrix( + MoveMatrix(min.applyMatrix4(new Matrix4().extractRotation(this.OCS)))); + } + } InitDrawObject(renderType: RenderType = RenderType.Wireframe): Object3D {