|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
import { BufferGeometry, Float32BufferAttribute, Line3, LineSegments, Matrix3, Matrix4, Mesh, Object3D, Vector3 } from "three";
|
|
|
|
|
import { Line2 } from "three/examples/jsm/lines/Line2";
|
|
|
|
|
import { LineMaterial } from "three/examples/jsm/lines/LineMaterial";
|
|
|
|
|
import { arrayLast } from "../../Common/ArrayExt";
|
|
|
|
|
import { ColorMaterial } from '../../Common/ColorPalette';
|
|
|
|
|
import { DisposeThreeObj } from '../../Common/Dispose';
|
|
|
|
|
import { Log } from "../../Common/Log";
|
|
|
|
@ -211,7 +210,7 @@ export class SweepSolid extends Entity
|
|
|
|
|
}
|
|
|
|
|
get BoundingBox()
|
|
|
|
|
{
|
|
|
|
|
return new Box3Ext().setFromPoints(this.GetEndPoints());
|
|
|
|
|
return new Box3Ext().setFromPoints(this.GetEndPoint());
|
|
|
|
|
}
|
|
|
|
|
get OBB(): OBB
|
|
|
|
|
{
|
|
|
|
@ -229,7 +228,7 @@ export class SweepSolid extends Entity
|
|
|
|
|
switch (snapMode)
|
|
|
|
|
{
|
|
|
|
|
case ObjectSnapMode.End:
|
|
|
|
|
return this.GetEndPoint2();
|
|
|
|
|
return this.GetEndPoint();
|
|
|
|
|
case ObjectSnapMode.Mid:
|
|
|
|
|
case ObjectSnapMode.Cen:
|
|
|
|
|
case ObjectSnapMode.Nea:
|
|
|
|
@ -264,27 +263,6 @@ export class SweepSolid extends Entity
|
|
|
|
|
p.applyMatrix4(this._Matrix);
|
|
|
|
|
return pts;
|
|
|
|
|
}
|
|
|
|
|
private GetEndPoints()
|
|
|
|
|
{
|
|
|
|
|
let pts = this._PathCurve.GetStretchPoints();
|
|
|
|
|
for (let p of pts)
|
|
|
|
|
p.applyMatrix4(this._Matrix);
|
|
|
|
|
let roMat = new Matrix4().extractRotation(this.OCS);
|
|
|
|
|
let z = this._PathCurve.GetFistDeriv(0).normalize().applyMatrix4(roMat);
|
|
|
|
|
let y = this.Normal;
|
|
|
|
|
let x = z.clone().cross(y);
|
|
|
|
|
let mat = new Matrix4().makeBasis(x, y, z);
|
|
|
|
|
mat.setPosition(this._PathCurve.StartPoint.applyMatrix4(this.OCS));
|
|
|
|
|
|
|
|
|
|
z = this._PathCurve.GetFistDeriv(this._PathCurve.EndParam).normalize().applyMatrix4(roMat);
|
|
|
|
|
x = z.clone().cross(y);
|
|
|
|
|
let mat2 = new Matrix4().makeBasis(x, y, z);
|
|
|
|
|
mat2.setPosition(arrayLast(pts));
|
|
|
|
|
|
|
|
|
|
let p2 = this._Contour.GetStretchPoints().map(p => p.applyMatrix4(mat));
|
|
|
|
|
let p3 = this._Contour.GetStretchPoints().map(p => p.applyMatrix4(mat2));
|
|
|
|
|
return [...pts, ...p2, ...p3];
|
|
|
|
|
}
|
|
|
|
|
private UpdateEndMtx(dir: Vector3, pos: Vector3)
|
|
|
|
|
{
|
|
|
|
|
let y = this.Normal;
|
|
|
|
@ -294,7 +272,7 @@ export class SweepSolid extends Entity
|
|
|
|
|
tempMatrix1.makeBasis(x, y, z);
|
|
|
|
|
tempMatrix1.setPosition(pos.applyMatrix4(this.OCS));
|
|
|
|
|
}
|
|
|
|
|
private GetEndPoint2()
|
|
|
|
|
private GetEndPoint()
|
|
|
|
|
{
|
|
|
|
|
let conPts = this._Contour.GetStretchPoints();
|
|
|
|
|
let cus: Curve[];
|
|
|
|
@ -303,6 +281,8 @@ export class SweepSolid extends Entity
|
|
|
|
|
else
|
|
|
|
|
cus = [this._PathCurve];
|
|
|
|
|
|
|
|
|
|
let roMat = new Matrix4().extractRotation(this.OCS);
|
|
|
|
|
|
|
|
|
|
const pts: Vector3[] = [];
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < cus.length; i++)
|
|
|
|
@ -329,14 +309,16 @@ export class SweepSolid extends Entity
|
|
|
|
|
|
|
|
|
|
if (l2)
|
|
|
|
|
{
|
|
|
|
|
let d2 = l2.GetFistDeriv(0).normalize();
|
|
|
|
|
let d2 = l2.GetFistDeriv(0).normalize().applyMatrix4(roMat);
|
|
|
|
|
d1.applyMatrix4(roMat);
|
|
|
|
|
d2.add(d1).normalize();
|
|
|
|
|
if (isParallelTo(d1, d2))
|
|
|
|
|
continue;
|
|
|
|
|
p.copy(l1.EndPoint);
|
|
|
|
|
//角平分线的平面;
|
|
|
|
|
let plane = new PlaneExt(d2, p);
|
|
|
|
|
let plane = new PlaneExt(d2, p.applyMatrix4(this.OCS));
|
|
|
|
|
let ps = conPts.map(p => p.clone().applyMatrix4(tempMatrix1));
|
|
|
|
|
pts.push(...ps.map(p => plane.intersectLine(new Line3(p, p.clone().add(d1)), new Vector3(), true)));
|
|
|
|
|
pts.push(...ps.map(p => plane.intersectLine(new Line3(p.clone().sub(d1.clone().multiplyScalar(-100)), p.clone().add(d1)), new Vector3(), true)));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|