!1981 开发优化:斜层板内缩实现

pull/1978/MERGE
ChenX 2 years ago
parent f09bbf8e88
commit c6f3359a1b

@ -1,4 +1,4 @@
import { Box3, MathUtils, Matrix4, Vector3 } from "three";
import { MathUtils, Matrix4, Vector3 } from "three";
import { app } from "../ApplicationServices/Application";
import { CylinderHole } from "../DatabaseServices/3DSolid/CylinderHole";
import { Board } from "../DatabaseServices/Entity/Board";
@ -76,22 +76,27 @@ 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 center = sizeBox.getCenter(new Vector3);
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));
sizeBox.expandByScalar(1e3);
for (let i = 0; i < this.currentBoard.LayerNails.length; i++)
let frontBox = sizeBox.clone();
frontBox.max.y = center.y;
let backBox = sizeBox.clone();
backBox.min.y = center.y;
for (let nailId of this.currentBoard.LayerNails)
{
let nail = this.currentBoard.LayerNails[i].Object as CylinderHole;
if (!nailId || nailId.IsErase) continue;
let nail = nailId.Object as CylinderHole;
if (IntersectBox2(nail.BoundingBox, frontBox))
{
nail.Position = nail.Position.add(new Vector3(0, this.data.frontDist, 0));
nail.Move(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));
nail.Move(new Vector3(0, -this.data.backDist, 0));
}
}
};

Loading…
Cancel
Save