|
|
|
@ -1238,60 +1238,94 @@ export class Polyline extends Curve
|
|
|
|
|
}
|
|
|
|
|
GetSnapPoints(): Array<THREE.Vector3>
|
|
|
|
|
{
|
|
|
|
|
return this.GetStretchPoints()
|
|
|
|
|
let plList: Vector3[] = [];
|
|
|
|
|
for (let i = 0; i < this.EndParam; i += 0.5)
|
|
|
|
|
{
|
|
|
|
|
let p = this.GetPointAtParam(i);
|
|
|
|
|
plList.push(p);
|
|
|
|
|
}
|
|
|
|
|
return plList;
|
|
|
|
|
}
|
|
|
|
|
GetStretchPoints(): Array<Vector3>
|
|
|
|
|
MoveSnapPoints(index: number, moveVec: Vector3)
|
|
|
|
|
{
|
|
|
|
|
let ptList = [];
|
|
|
|
|
for (let i = 0; i < this.m_LineData.length; i++)
|
|
|
|
|
if (index % 2 === 0)
|
|
|
|
|
this.MoveStretchPoints([index], moveVec);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
let endV = this.m_LineData[i];
|
|
|
|
|
if (i > 0)
|
|
|
|
|
let d = this.m_LineData[index - 1];
|
|
|
|
|
if (d.bul == 0)
|
|
|
|
|
{
|
|
|
|
|
let startV = this.m_LineData[i - 1];
|
|
|
|
|
ptList.push(getPtAtCurveParam(startV.pt, endV.pt, startV.bul, 0.5));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 以下代码保证了中心点不变
|
|
|
|
|
// let arcStartPoint = this.GetPointAtParam(index).add(vec);
|
|
|
|
|
// let arcMidP = this.GetPointAtParam(index + 0.5);
|
|
|
|
|
// let arcEndPoint = this.GetPointAtParam(nextIndex);
|
|
|
|
|
|
|
|
|
|
// let arc = new Arc().FromThreePoint(arcStartPoint, arcMidP, arcEndPoint);
|
|
|
|
|
// this.m_LineData[index].bul = Math.tan(arc.AllAngle * 0.25) * (equal(arc.StartPoint, arcStartPoint) ? -1 : 1);
|
|
|
|
|
}
|
|
|
|
|
ptList.push(Vec2DTo3D(endV.pt));
|
|
|
|
|
}
|
|
|
|
|
return ptList;
|
|
|
|
|
}
|
|
|
|
|
GetStretchPoints(): Array<Vector3>
|
|
|
|
|
{
|
|
|
|
|
let plList: Vector3[] = [];
|
|
|
|
|
for (let i = 0; i < this.m_LineData.length; i++)
|
|
|
|
|
{
|
|
|
|
|
let p = this.GetPointAtParam(i);
|
|
|
|
|
plList.push(p);
|
|
|
|
|
}
|
|
|
|
|
return plList;
|
|
|
|
|
}
|
|
|
|
|
MoveStretchPoints(indexList: Array<number>, vec: Vector3)
|
|
|
|
|
{
|
|
|
|
|
let moveVc = new Vector2(vec.x, vec.y);
|
|
|
|
|
let ptlist = this.GetStretchPoints();
|
|
|
|
|
|
|
|
|
|
if (indexList[0] % 2 === 0)
|
|
|
|
|
let ptCout = this.m_LineData.length;
|
|
|
|
|
|
|
|
|
|
for (let index of indexList)
|
|
|
|
|
{
|
|
|
|
|
let i = indexList[0] / 2;
|
|
|
|
|
if (i === 0)
|
|
|
|
|
let frontIndex = index - 1;
|
|
|
|
|
let nextIndex = index + 1;
|
|
|
|
|
if (this.m_ClosedMark)
|
|
|
|
|
{
|
|
|
|
|
if (this.IsClose)
|
|
|
|
|
{
|
|
|
|
|
this.m_LineData[this.EndParam].pt.add(moveVc);
|
|
|
|
|
}
|
|
|
|
|
frontIndex = FixIndex(frontIndex, ptCout);
|
|
|
|
|
nextIndex = FixIndex(nextIndex, ptCout);
|
|
|
|
|
}
|
|
|
|
|
//TODO:保持圆弧中点不变
|
|
|
|
|
this.m_LineData[i].pt.add(moveVc);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
let startV = this.m_LineData[(indexList[0] - 1) / 2];
|
|
|
|
|
let endV = this.m_LineData[(indexList[0] + 1) / 2];
|
|
|
|
|
let midPt = ptlist[indexList[0]].add(vec);
|
|
|
|
|
|
|
|
|
|
if (startV.bul !== 0)
|
|
|
|
|
const ChangeBul = (notChangeIndex: number, changeBulIndex: number) =>
|
|
|
|
|
{
|
|
|
|
|
// 起始点
|
|
|
|
|
let startPt = Vec2DTo3D(startV.pt);
|
|
|
|
|
// 终止点
|
|
|
|
|
let endPt = Vec2DTo3D(endV.pt);
|
|
|
|
|
startV.bul = Math.tan(getArcAngleBy3Pt(startPt, midPt, endPt) / 4);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
startV.pt = startV.pt.add(moveVc);
|
|
|
|
|
endV.pt = endV.pt.add(moveVc);
|
|
|
|
|
//需要修改的点的数据
|
|
|
|
|
let d = this.m_LineData[changeBulIndex];
|
|
|
|
|
if (d.bul == 0) return;
|
|
|
|
|
|
|
|
|
|
//该索引点下一个点或者上一个点,如果不在列表中,就需要更新凸度.
|
|
|
|
|
if (notChangeIndex === -1 || notChangeIndex === ptCout || indexList.indexOf(notChangeIndex) === -1)
|
|
|
|
|
{
|
|
|
|
|
let needChangeP = this.GetPointAtParam(index);
|
|
|
|
|
let notChangeP = this.GetPointAtParam(notChangeIndex);
|
|
|
|
|
|
|
|
|
|
//原先的弦长的一半
|
|
|
|
|
let OldChordLengthHalf = needChangeP.distanceTo(notChangeP) * 0.5;
|
|
|
|
|
|
|
|
|
|
//弓高
|
|
|
|
|
let arcH = OldChordLengthHalf * d.bul;
|
|
|
|
|
|
|
|
|
|
needChangeP.add(vec);
|
|
|
|
|
|
|
|
|
|
let newChordLengthHalf = (needChangeP.distanceTo(notChangeP) * 0.5);
|
|
|
|
|
|
|
|
|
|
d.bul = arcH / newChordLengthHalf;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChangeBul(frontIndex, frontIndex);
|
|
|
|
|
ChangeBul(nextIndex, index);
|
|
|
|
|
|
|
|
|
|
//修改顶点
|
|
|
|
|
this.m_LineData[index].pt.add(Vec3DTo2D(vec));
|
|
|
|
|
}
|
|
|
|
|
this.Update();
|
|
|
|
|
}
|
|
|
|
|