!170 捕捉功能重构与实现

pull/170/MERGE
ChenX 6 years ago
parent cf0557d353
commit aa13bb1929

@ -1,6 +1,6 @@
import { app } from '../ApplicationServices/Application';
import { Command } from '../Editor/CommandMachine';
import { Jig } from '../Editor/Jig';
import { JigUtils } from '../Editor/JigUtils';
import { PromptStatus } from '../Editor/PromptResult';
import { MoveMatrix } from '../Geometry/GeUtils';
@ -20,7 +20,7 @@ export class Command_Copy implements Command
let ptLast = ptBase.clone();
let orgEns = ssRes.SelectSet.SelectEntityList;
let jigEns = orgEns.map(e => Jig.Draw(e));
let jigEns = orgEns.map(e => JigUtils.Draw(e));
while (true)
{
@ -46,6 +46,6 @@ export class Command_Copy implements Command
break;
}
Jig.End();
JigUtils.End();
}
}

@ -1,7 +1,7 @@
import { app } from '../ApplicationServices/Application';
import { Arc } from '../DatabaseServices/Arc';
import { Command } from '../Editor/CommandMachine';
import { Jig } from '../Editor/Jig';
import { JigUtils } from '../Editor/JigUtils';
import { PromptStatus } from '../Editor/PromptResult';
import { equalv3 } from '../Geometry/GeUtils';
@ -30,7 +30,7 @@ export class DrawArc implements Command
}
}
Jig.Draw(arc);
JigUtils.Draw(arc);
let ptRes3 = await app.m_Editor.GetPoint({
Msg: "请输入第三个点:",
Callback: updateArc
@ -41,6 +41,6 @@ export class DrawArc implements Command
updateArc(ptRes3.Value);
app.m_Database.ModelSpace.Append(arc);
}
Jig.End();
JigUtils.End();
}
}

@ -8,7 +8,7 @@ import { MoveMatrix } from '../../Geometry/GeUtils';
import { BoardModal, BoardModalType } from '../../UI/Components/Board/BoardModal';
import { ModalPosition } from '../../UI/Components/Modal/ModalsManage';
import { SideBoardStore } from '../../UI/Store/BoardStore';
import { Jig } from '../../Editor/Jig';
import { JigUtils } from '../../Editor/JigUtils';
export class DrawLeftRight implements Command
@ -27,8 +27,8 @@ export class DrawLeftRight implements Command
let thickness = data.thickness;
let spacing = data.spaceSize;
let leftBoard = Jig.Draw(Board.CreateBoard(lenght, width, thickness, BoardType.Vertical));
let rightBoard = Jig.Draw(Board.CreateBoard(lenght, width, thickness, BoardType.Vertical));
let leftBoard = JigUtils.Draw(Board.CreateBoard(lenght, width, thickness, BoardType.Vertical));
let rightBoard = JigUtils.Draw(Board.CreateBoard(lenght, width, thickness, BoardType.Vertical));
rightBoard.ApplyMatrix(MoveMatrix(new Vector3(spacing - thickness)));
let ptRes = await app.m_Editor.GetPoint({
@ -41,7 +41,7 @@ export class DrawLeftRight implements Command
}
});
Jig.End();
JigUtils.End();
if (ptRes.Status === PromptStatus.OK)
{

@ -3,7 +3,7 @@ import { app } from '../../ApplicationServices/Application';
import { Singleton } from '../../Common/Singleton';
import { Board } from '../../DatabaseServices/Board';
import { Command } from '../../Editor/CommandMachine';
import { Jig } from '../../Editor/Jig';
import { JigUtils } from '../../Editor/JigUtils';
import { PromptStatus } from '../../Editor/PromptResult';
import { MoveMatrix } from '../../Geometry/GeUtils';
import { BoardModal, BoardModalType } from '../../UI/Components/Board/BoardModal';
@ -20,7 +20,7 @@ export class DrawSingleBoard implements Command
app.m_Editor.m_ModalManage.Callback = async () =>
{
const opt = store.m_Option;
let board = Jig.Draw(Board.CreateBoard(opt.height, opt.width, opt.thickness, opt.type));
let board = JigUtils.Draw(Board.CreateBoard(opt.height, opt.width, opt.thickness, opt.type));
board.BoardProcessOption = store.m_BoardProcessOption;
let rx = Math.degToRad(opt.rotateX);
let ry = Math.degToRad(opt.rotateY);
@ -37,7 +37,7 @@ export class DrawSingleBoard implements Command
}
});
Jig.End();
JigUtils.End();
if (ptRes.Status === PromptStatus.OK)
{

@ -3,7 +3,7 @@ import { app } from '../ApplicationServices/Application';
import { Arc } from '../DatabaseServices/Arc';
import { Circle } from '../DatabaseServices/Circle';
import { Command } from '../Editor/CommandMachine';
import { Jig } from '../Editor/Jig';
import { JigUtils } from '../Editor/JigUtils';
import { PromptStatus } from '../Editor/PromptResult';
import { midPoint } from '../Geometry/GeUtils';
export class DrawCircle implements Command
@ -51,7 +51,7 @@ export class DrawCircle implements Command
let cir = new Circle();
cir.ApplyMatrix(app.m_Editor.UCSMatrix);
cir.Center = val;
Jig.Draw(cir);
JigUtils.Draw(cir);
let disRes = await app.m_Editor.GetDistance({
Msg: "指定圆的半径:",
BasePoint: val,
@ -62,7 +62,7 @@ export class DrawCircle implements Command
cir.Radius = disRes.Value;
app.m_Database.ModelSpace.Append(cir);
}
Jig.Destroy();
JigUtils.Destroy();
}
async DrawCicleUseTwoPoint()
{
@ -70,7 +70,7 @@ export class DrawCircle implements Command
if (ptRes1.Status != PromptStatus.OK)
return;
let cir = new Circle();
Jig.Draw(cir);
JigUtils.Draw(cir);
let ptRes2 = await app.m_Editor.GetPoint({
Msg: "指定圆直径的第二个端点:",
BasePoint: ptRes1.Value,
@ -87,7 +87,7 @@ export class DrawCircle implements Command
cir.Center = midPoint(ptRes2.Value, ptRes1.Value);
app.m_Database.ModelSpace.Append(cir);
}
Jig.Destroy();
JigUtils.Destroy();
}
async DrawCicleUseThreePoint()
{
@ -103,7 +103,7 @@ export class DrawCircle implements Command
});
if (ptRes2.Status != PromptStatus.OK)
return;
Jig.Draw(cir);
JigUtils.Draw(cir);
let ptRes3 = await app.m_Editor.GetPoint({
Msg: "指定圆上第三个点:",
BasePoint: ptRes2.Value,
@ -122,7 +122,7 @@ export class DrawCircle implements Command
cir.Center = ar.Center;
app.m_Database.ModelSpace.Append(cir);
}
Jig.Destroy();
JigUtils.Destroy();
}
async DrawCicleUseCutoffPointAndRadious()
{

@ -2,7 +2,7 @@ import { Command } from "../Editor/CommandMachine";
import { app } from "../ApplicationServices/Application";
import { PromptStatus } from "../Editor/PromptResult";
import { Cylineder } from "../DatabaseServices/3DSolid/Cylineder";
import { Jig } from "../Editor/Jig";
import { JigUtils } from "../Editor/JigUtils";
export class DrawCylineder implements Command
{
@ -12,7 +12,7 @@ export class DrawCylineder implements Command
if (ptRes.Status === PromptStatus.Cancel)
return;
let cylineder = Jig.Draw(new Cylineder());
let cylineder = JigUtils.Draw(new Cylineder());
cylineder.Center = ptRes.Value;
let disRes = await app.m_Editor.GetDistance({
@ -30,7 +30,7 @@ export class DrawCylineder implements Command
Callback: (v) => cylineder.Height = v,
});
Jig.End();
JigUtils.End();
if (disRes.Status === PromptStatus.OK)
{
cylineder.Height = disRes.Value;

@ -3,7 +3,7 @@ import { AlignedDimension } from '../../DatabaseServices/Dimension/AlignedDimens
import { LinearDimension } from '../../DatabaseServices/Dimension/LinearDimension';
import { Command } from '../../Editor/CommandMachine';
import { PromptStatus } from '../../Editor/PromptResult';
import { Jig } from '../../Editor/Jig';
import { JigUtils } from '../../Editor/JigUtils';
export enum DimensionType
{
@ -47,7 +47,7 @@ export class DrawAlignedDimension implements Command
alDim = new LinearDimension(startPt, endPt, linePt, startPt.distanceTo(endPt) + '');
}
Jig.Draw(alDim);
JigUtils.Draw(alDim);
app.m_Editor.Prompt("指定尺寸线位置:");
ptRes = await app.m_Editor.GetPoint({

@ -1,10 +1,9 @@
import { Matrix4, Vector3 } from "three";
import { app } from "../ApplicationServices/Application";
import { Ellipse } from "../DatabaseServices/Ellipse";
import { Command } from "../Editor/CommandMachine";
import { JigUtils } from "../Editor/JigUtils";
import { PromptStatus } from "../Editor/PromptResult";
import { Ellipse } from "../DatabaseServices/Ellipse";
import { RenderType } from "../GraphicsSystem/Enum";
import { Jig } from "../Editor/Jig";
import { Vector3, Matrix4 } from "three";
/**
*
*
@ -39,7 +38,7 @@ export class DrawEllipse implements Command
let ellipse = new Ellipse(new Vector3(), disVec.length(), 0, Math.atan2(disVec.y, disVec.x));
ellipse.ApplyMatrix(ucs);
ellipse.Center = ptRes.Value;
Jig.Draw(ellipse);
JigUtils.Draw(ellipse);
//椭圆Y轴
let radYRes = await app.m_Editor.GetDistance({
@ -53,6 +52,6 @@ export class DrawEllipse implements Command
ellipse.RadY = radYRes.Value;
app.m_Database.ModelSpace.Append(ellipse);
}
Jig.Destroy();
JigUtils.Destroy();
}
}

@ -1,8 +1,14 @@
import * as THREE from 'three';
import { Vector3 } from 'three';
import { app } from '../ApplicationServices/Application';
import { Arc } from '../DatabaseServices/Arc';
import { Circle } from '../DatabaseServices/Circle';
import { Line } from '../DatabaseServices/Line';
import { Command } from '../Editor/CommandMachine';
import { JigUtils } from '../Editor/JigUtils';
import { ObjectSnapMode } from '../Editor/ObjectSnapMode';
import { PromptStatus } from '../Editor/PromptResult';
import { SelectPick } from '../Editor/SelectPick';
export class DrawLine implements Command
{
@ -13,27 +19,61 @@ export class DrawLine implements Command
return;
let ptLast = ptRes.Value;
let isTan = ptRes.SnaoMode === ObjectSnapMode.Tan;
let cir: Circle | Arc;
if (isTan)
{
let pick = new SelectPick(app.m_Viewer, app.m_Viewer.WorldToScreen(ptRes.Value));
pick.Select(app.m_Viewer.VisibleObjects, { filterTypes: [Circle, Arc] });
let cirs = pick.SelectEntityList as Circle[];
for (let e of cirs)
{
if (e.PtOnCurve(ptRes.Value))
cir = e;
}
}
let drawLines: Line[] = [];
while (true)
{
let line = new Line(ptLast);
let ucsMatrix = app.m_Editor.UCSMatrix;
line.ApplyMatrix(ucsMatrix);
let isFirstAndTan = (isTan && drawLines.length === 0 && cir);
if (isFirstAndTan)
JigUtils.Draw(line);
let updateEndPt = (p: Vector3) =>
{
if (isFirstAndTan)
{
let tanP = cir.GetObjectSnapPoints(ObjectSnapMode.Tan, ptLast, p)[0];
if (tanP)
{
line.StartPoint = tanP;
ptLast.copy(tanP);
}
}
line.EndPoint = p;
}
ptRes = await app.m_Editor.GetPoint({
Msg: "请输入点2:",
BasePoint: ptLast,
BasePoint: isFirstAndTan ? undefined : ptLast,
AllowDrawRubberBand: true,
AllowNone: true,
KeyWordList: [
{ msg: "放弃", key: "U" },
{ msg: "闭合", key: "C" },
]
],
Callback: updateEndPt,
});
if (ptRes.Status === PromptStatus.OK)
{
let ucsMatrix = app.m_Editor.UCSMatrix;
let line = new Line();
line.ApplyMatrix(ucsMatrix);
line.StartPoint = ptLast;
line.EndPoint = ptRes.Value;
updateEndPt(ptRes.Value);
app.m_Database.ModelSpace.Append(line);
drawLines.push(line);

@ -4,7 +4,7 @@ import { getCirAngleByChordAndTangent, Vec2DTo3D, Vec3DTo2D } from '../Common/Cu
import { GetPointPrompt } from '../Common/InputState';
import { Polyline } from '../DatabaseServices/Polyline';
import { PromptStatus } from '../Editor/PromptResult';
import { Jig } from '../Editor/Jig';
import { JigUtils } from '../Editor/JigUtils';
enum PolylineModel
{
@ -23,7 +23,7 @@ export class DrawPolyline
pl.ApplyMatrix(app.m_Editor.UCSMatrix);
app.m_Database.ModelSpace.Append(pl);
let plJig = Jig.Draw(pl);
let plJig = JigUtils.Draw(pl);
let Callback = (p: Vector3) =>
this.UpdatePoint(plJig, p)
@ -96,7 +96,7 @@ export class DrawPolyline
else
break;
}
Jig.End();
JigUtils.End();
if (pl.NumberOfVertices < 2)
{
app.m_Database.ModelSpace.Remove(pl);

@ -5,7 +5,7 @@ import { Vec3DTo2D } from '../Common/CurveUtils';
import { Polyline } from '../DatabaseServices/Polyline';
import { Command } from '../Editor/CommandMachine';
import { PromptStatus } from '../Editor/PromptResult';
import { Jig } from '../Editor/Jig';
import { JigUtils } from '../Editor/JigUtils';
export class DrawRect implements Command
{
async exec()
@ -21,7 +21,7 @@ export class DrawRect implements Command
rec.CloseMark = true;
rec.ApplyMatrix(app.m_Editor.UCSMatrix);
Jig.Draw(rec);
JigUtils.Draw(rec);
let box = new Box3();
let updateRect = (p1, p2) =>
@ -52,6 +52,6 @@ export class DrawRect implements Command
app.m_Database.ModelSpace.Append(rec);
}
Jig.End();
JigUtils.End();
}
}

@ -10,7 +10,7 @@ import { SelectPick } from '../Editor/SelectPick';
import { SelectSet } from '../Editor/SelectSet';
import { IntersectOption } from '../GraphicsSystem/IntersectWith';
import { Arc } from '../DatabaseServices/Arc';
import { Jig } from '../Editor/Jig';
import { JigUtils } from '../Editor/JigUtils';
/**
*
@ -62,7 +62,7 @@ export class Command_Extend implements Command
DynmicExtend(entss: PromptSsgetResult, exRefCus: Curve[]): any
{
Jig.End();
JigUtils.End();
this.Extend(entss.SelectSet, exRefCus, true);
app.m_Editor.UpdateScreen();
}
@ -150,10 +150,7 @@ export class Command_Extend implements Command
//是否处于预览模式
if (bDynmic)
{
cu = cu.Clone();
Jig.Draw(cu);
}
JigUtils.Draw(cu);
//因为参数是从小到大排序,如果是前延伸时,取最大的就可以了 [-2,-1,-0.5]
if (bIsFrontExtend)
cu.Extend(inParams[inParams.length - 1]);

@ -11,7 +11,7 @@ import { Curve } from '../DatabaseServices/Curve';
import { Line } from '../DatabaseServices/Line';
import { Polyline } from '../DatabaseServices/Polyline';
import { Command } from '../Editor/CommandMachine';
import { Jig } from '../Editor/Jig';
import { JigUtils } from '../Editor/JigUtils';
import { PromptEntityResult, PromptStatus } from '../Editor/PromptResult';
import { angle, equalv3, isParallelTo, midPoint } from '../Geometry/GeUtils';
import { IntersectOption } from '../GraphicsSystem/IntersectWith';
@ -115,7 +115,7 @@ export class CommandFillet implements Command
let jigCallBack = (res2: PromptEntityResult) =>
{
enRes2 = res2;
Jig.End();
JigUtils.End();
if (lastCu && lastCu !== enRes1.Entity)
lastCu.RestoreJigMaterial();
if (!res2.Entity)
@ -130,7 +130,7 @@ export class CommandFillet implements Command
let fres = this.Fillet(enRes1, res2);
for (let v in fres)
if (fres[v])
Jig.Draw(fres[v])
JigUtils.Draw(fres[v])
app.m_Editor.UpdateScreen();
lastCu = res2.Entity as Curve;
@ -283,8 +283,8 @@ export class CommandFillet implements Command
//测试绘制
offCu1.ColorIndex = 6;
offCu2.ColorIndex = 6;
Jig.Draw(offCu1.Clone());
Jig.Draw(offCu2.Clone());
JigUtils.Draw(offCu1.Clone());
JigUtils.Draw(offCu2.Clone());
let center = offCu1.IntersectWith(offCu2, IntersectOption.OnBothOperands)
.sort((p1, p2) =>
@ -604,8 +604,8 @@ export class CommandFillet implements Command
arcO1.ColorIndex = 6;
arcO2.ColorIndex = 6;
Jig.Draw(arcO1);
Jig.Draw(arcO2);
JigUtils.Draw(arcO1);
JigUtils.Draw(arcO2);
//求交
let intPts = arcO1.IntersectWith(arcO2, IntersectOption.ExtendBoth);
@ -683,8 +683,8 @@ export class CommandFillet implements Command
lineO.ColorIndex = 6;
arcO.ColorIndex = 6;
Jig.Draw(lineO);
Jig.Draw(arcO);
JigUtils.Draw(lineO);
JigUtils.Draw(arcO);
//求交
let intPts = lineO.IntersectWith(arcO, IntersectOption.ExtendBoth);
@ -974,7 +974,7 @@ export class CommandFillet implements Command
if (e && e.Entity === lastPl)
return;
Jig.End();
JigUtils.End();
if (lastPl && lastPl !== enRes.Entity)
lastPl.RestoreJigMaterial();
@ -987,7 +987,7 @@ export class CommandFillet implements Command
let fres = this.FilletPolyLineAllAngular(e);
if (fres && fres.cu1)
Jig.Draw(fres.cu1);
JigUtils.Draw(fres.cu1);
lastPl = e.Entity as Polyline;
lastPl.UpdateJigMaterial();

@ -3,7 +3,7 @@ import { app } from '../ApplicationServices/Application';
import { Command } from '../Editor/CommandMachine';
import { PromptStatus } from '../Editor/PromptResult';
import { MoveMatrix } from '../Geometry/GeUtils';
import { Jig } from '../Editor/Jig';
import { JigUtils } from '../Editor/JigUtils';
export class Command_Move implements Command
{
@ -18,7 +18,7 @@ export class Command_Move implements Command
let ens = ssRes.SelectSet.SelectEntityList;
let ensClone = ens.map(e => Jig.Draw(e));
let ensClone = ens.map(e => JigUtils.Draw(e));
let ptBase = ptRes.Value;
let ptLast = ptBase.clone();
@ -35,7 +35,7 @@ export class Command_Move implements Command
AllowDrawRubberBand: true
});
Jig.End();
JigUtils.End();
if (ptRes.Status === PromptStatus.OK)
{
let moveM = MoveMatrix(ptRes.Value.clone().sub(ptBase));

@ -3,7 +3,7 @@ import { app } from '../ApplicationServices/Application';
import { GetPointAtCurveDir } from '../Common/CurveUtils';
import { Curve } from '../DatabaseServices/Curve';
import { Command } from '../Editor/CommandMachine';
import { Jig } from '../Editor/Jig';
import { JigUtils } from '../Editor/JigUtils';
import { PromptStatus } from '../Editor/PromptResult';
import { RenderType } from '../GraphicsSystem/Enum';
@ -53,7 +53,7 @@ export class Command_Offset implements Command
else
state = await this.GetOffsetDir(cu);
Jig.End();
JigUtils.End();
if (state.Status === PromptStatus.OK)
this.DrawOffset(cu, state.offsetDist);
else if (state.Status === PromptStatus.None)
@ -89,9 +89,9 @@ export class Command_Offset implements Command
let dir = GetPointAtCurveDir(cu, p) ? 1 : -1;
if (dir !== oldDir)
{
Jig.Destroy();
JigUtils.Destroy();
let offCus = cu.GetOffsetCurves(this.offsetDis * dir);
offCus.forEach(c => { Jig.Draw(c) });
offCus.forEach(c => { JigUtils.Draw(c) });
oldDir = dir;
}
}
@ -128,8 +128,8 @@ export class Command_Offset implements Command
},
Callback: (dis: number) =>
{
Jig.Destroy();
cu.GetOffsetCurves(dis).forEach(c => Jig.Draw(c));
JigUtils.Destroy();
cu.GetOffsetCurves(dis).forEach(c => JigUtils.Draw(c));
}
});

@ -2,7 +2,7 @@ import { Box3, Vector3 } from "three";
import { app } from "../ApplicationServices/Application";
import { matrixScale } from "../Common/Matrix4Utils";
import { Command } from "../Editor/CommandMachine";
import { Jig } from "../Editor/Jig";
import { JigUtils } from "../Editor/JigUtils";
import { PromptStatus } from "../Editor/PromptResult";
export class Command_Scale implements Command
@ -23,7 +23,7 @@ export class Command_Scale implements Command
let jigEns = allEns.map(e =>
{
allBox.union(e.BoundingBox);
return Jig.Draw(e)
return JigUtils.Draw(e)
});
let maxSize = Math.max(...allBox.getSize(new Vector3()).toArray()) / 2;
@ -32,7 +32,7 @@ export class Command_Scale implements Command
Msg: "请输入缩放比例:",
Callback: (sc) =>
{
Jig.Restore();
JigUtils.Restore();
let scMat = matrixScale(sc, ptRes.Value);
for (let en of jigEns)
{
@ -42,7 +42,7 @@ export class Command_Scale implements Command
CalcDistance: (pBase, p) => p.distanceTo(pBase) / maxSize
});
Jig.End();
JigUtils.End();
if (scaleRes.Status != PromptStatus.OK)
return;

@ -2,7 +2,7 @@ import * as THREE from 'three';
import { app } from '../ApplicationServices/Application';
import { Entity } from '../DatabaseServices/Entity';
import { Command } from '../Editor/CommandMachine';
import { Jig } from '../Editor/Jig';
import { JigUtils } from '../Editor/JigUtils';
import { PromptStatus } from '../Editor/PromptResult';
import { SelectBox, SelectType } from '../Editor/SelectBox';
import { SelectPick } from '../Editor/SelectPick';
@ -29,11 +29,11 @@ export class Stretch implements Command
let data = this.parse(ss);
let dataClone: StretchData =
{
moveEntityList: data.moveEntityList.map(e => Jig.Draw(e)),
moveEntityList: data.moveEntityList.map(e => JigUtils.Draw(e)),
stretchEntityMap: data.stretchEntityMap.map(v =>
{
return {
Ent: Jig.Draw(v.Ent),
Ent: JigUtils.Draw(v.Ent),
Indexs: v.Indexs
}
})
@ -48,7 +48,7 @@ export class Stretch implements Command
Msg: "指定第二个点:",//或 <使用第一个点作为位移>
Callback: (p) =>
{
Jig.Restore();
JigUtils.Restore();
let v = p.clone().sub(lastP);
this.s(dataClone, v);
curP.copy(p);
@ -58,7 +58,7 @@ export class Stretch implements Command
if (p2.Status === PromptStatus.OK)
this.s(data, p2.Value.sub(lastP));
Jig.End();
JigUtils.End();
}
/**

@ -0,0 +1,31 @@
import { Command } from "../Editor/CommandMachine";
import { app } from "../ApplicationServices/Application";
import { Circle } from "../DatabaseServices/Circle";
import { Arc } from "../DatabaseServices/Arc";
import { CircleInternalTangentLines, CircleOuterTangentLines } from "../Common/CurveUtils";
export class DrawTangentLine implements Command
{
async exec()
{
let ss = await app.m_Editor.GetSelection({
Msg: "请选择圆或者圆弧:",
Filter: {
filterTypes: [Circle, Arc]
}
});
let cirs = ss.SelectSet.SelectEntityList as Circle[];
for (let i = 0; i < cirs.length; i++)
{
for (let j = i + 1; j < cirs.length; j++)
{
let ls = CircleInternalTangentLines(cirs[i], cirs[j]).concat(CircleOuterTangentLines(cirs[i], cirs[j]));
for (let l of ls)
app.m_Database.ModelSpace.Append(l);
}
}
}
}

@ -8,7 +8,7 @@ import { Curve } from '../DatabaseServices/Curve';
import { Line } from '../DatabaseServices/Line';
import { Polyline } from '../DatabaseServices/Polyline';
import { Command } from '../Editor/CommandMachine';
import { Jig } from '../Editor/Jig';
import { JigUtils } from '../Editor/JigUtils';
import { PromptSsgetResult, PromptStatus } from '../Editor/PromptResult';
import { SelectBox, SelectType } from '../Editor/SelectBox';
import { IntersectOption } from '../GraphicsSystem/IntersectWith';
@ -43,7 +43,7 @@ export class Command_Trim implements Command
SelectType: SelectType.C,
Callback: (res) =>
{
Jig.End();
JigUtils.End();
for (let c of lastCurves)
c.RestoreJigMaterial();
@ -54,7 +54,7 @@ export class Command_Trim implements Command
{
c.UpdateJigMaterial();
for (let c of cus)
Jig.Draw(c);
JigUtils.Draw(c);
}
app.m_Editor.UpdateScreen();
}

@ -11,7 +11,7 @@ import { Command } from '../Editor/CommandMachine';
import { PromptStatus } from '../Editor/PromptResult';
import { PromptBlock } from '../UI/DynamicPrompt/PromptBlock';
import { DynamicInputManage } from '../UI/DynamicPrompt/DynamicInputManage';
import { Jig } from '../Editor/Jig';
import { JigUtils } from '../Editor/JigUtils';
export class Command_ClosePt implements Command
@ -30,9 +30,9 @@ export class Command_ClosePt implements Command
let closeCir = new Circle(new Vector3(), 5);
let derLine = new Line();
Jig.Draw(line);
Jig.Draw(closeCir);
Jig.Draw(derLine);
JigUtils.Draw(line);
JigUtils.Draw(closeCir);
JigUtils.Draw(derLine);
let extend = false;
while (true)

@ -84,6 +84,7 @@ export class ApplicationService
xaop.begin(commandMachine, commandMachine.ExecCommand, () =>
{
this.m_Viewer.m_GripScene.visible = false;
this.m_Editor.m_SnapDragServices.HideDrawLine();
})
xaop.begin(commandMachine, commandMachine.CommandEnd, () =>
{

@ -371,3 +371,126 @@ export function ConverCircleToPolyline(cir: Circle): Polyline
pl.Join(arcs[1]);
return pl;
}
export function getTanPtsOnArcOrCircle(cu: Arc | Circle, lastPoint?: Vector3)
{
if (lastPoint)
{
//ref:wykobi
let ocsInv = cu.OCSInv;
let v = lastPoint.clone().applyMatrix4(ocsInv);
let lengthSq = v.lengthSq();
let radiusSq = cu.Radius ** 2;
if (lengthSq >= radiusSq)
{
let ratio = 1 / lengthSq;
let deltaDist = Math.sqrt(lengthSq - radiusSq);
let pts = [
new Vector3(
cu.Radius * (cu.Radius * v.x - v.y * deltaDist) * ratio,
cu.Radius * (cu.Radius * v.y + v.x * deltaDist) * ratio,
),
new Vector3(
cu.Radius * (cu.Radius * v.x + v.y * deltaDist) * ratio,
cu.Radius * (cu.Radius * v.y - v.x * deltaDist) * ratio,
),
];
for (let p of pts)
p.applyMatrix4(cu.OCS);
return pts;
}
}
}
export function CircleInternalTangentLines(cir0: Circle, cir1: Circle): Line[]
{
let c0 = cir0.Center;
let c1 = cir1.Center;
let dist = c0.distanceTo(c1);
if (dist - (cir0.Radius + cir1.Radius) < 0)
return [];
else if (equaln(dist - (cir0.Radius + cir1.Radius), 0))
return [];
else
{
let m = cir0.Radius / cir1.Radius;
let h0 = (m * dist) / (m + 1);
let h1 = dist / (m + 1);
let i = new Vector3(
(h1 * c0.x + h0 * c1.x) / dist,
(h1 * c0.y + h0 * c1.y) / dist
);
let [c0p0, c0p1] = getTanPtsOnArcOrCircle(cir0, i);
let [c1p0, c1p1] = getTanPtsOnArcOrCircle(cir1, i);
return [
new Line(c0p0, c1p0),
new Line(c0p1, c1p1),
];
}
}
export function CircleOuterTangentLines(circle0: Circle, circle1: Circle): Line[]
{
let c0 = circle0.Center;
let c1 = circle1.Center;
let dist = c0.distanceTo(c1);
let rd = Math.abs(circle0.Radius - circle1.Radius);
if (dist < rd)
return [];
else if (equaln(Math.abs(dist - rd), 0))
return [];
else if (equaln(circle0.Radius, circle1.Radius))
{
let cp = circle0.GetClosestPointTo(circle1.Center, true);
let derv = circle0.GetFistDeriv(cp).multiplyScalar(circle0.Radius);
let dervn = derv.clone().negate();
let c0p0 = c0.clone().add(derv);
let c0p1 = c0.clone().add(dervn);
let c1p0 = c1.clone().add(derv);
let c1p1 = c1.clone().add(dervn);
return [
new Line(c0p0, c1p0),
new Line(c0p1, c1p1),
];
}
else
{
let p: Vector3;
if (circle0.Radius > circle1.Radius)
p = new Vector3(
c1.x * circle0.Radius - c0.x * circle1.Radius,
c1.y * circle0.Radius - c0.y * circle1.Radius
);
else
p = new Vector3(
c0.x * circle1.Radius - c1.x * circle0.Radius,
c0.y * circle1.Radius - c1.y * circle0.Radius
);
let diff = Math.abs(circle0.Radius - circle1.Radius);
p.x /= diff;
p.y /= diff;
let [c0p0, c0p1] = getTanPtsOnArcOrCircle(circle0, p);
let [c1p0, c1p1] = getTanPtsOnArcOrCircle(circle1, p);
return [
new Line(c0p0, c1p0),
new Line(c0p1, c1p1),
];
}
}

@ -18,7 +18,7 @@ export enum InputState
GetDist = 8,
Entsel = 16,
GetKeyWord = 32,
All = ~(~0 << 32)
All = ~(~0 << 6)
}

@ -136,9 +136,9 @@ export class SweepSolid extends Solid3D
}
}
GetSnapPoints()
GetGripPoints()
{
let pts = this.m_PathCurve.GetSnapPoints();
let pts = this.m_PathCurve.GetGripPoints();
pts.forEach(p => p.applyMatrix4(this.OCS));
return pts;
}
@ -148,9 +148,9 @@ export class SweepSolid extends Solid3D
pts.forEach(p => p.applyMatrix4(this.OCS));
return pts;
}
MoveSnapPoints(indexList: number[], vec: Vector3)
MoveGripPoints(indexList: number[], vec: Vector3)
{
this.m_PathCurve.MoveSnapPoints(indexList, vec);
this.m_PathCurve.MoveGripPoints(indexList, vec);
this.Update();
}
MoveStretchPoints(indexList: number[], vec: Vector3)

@ -1,9 +1,11 @@
import * as THREE from 'three';
import { Box3, Matrix4, Object3D, ShapeGeometry, Vector2, Vector3, Shape } from 'three';
import { Box3, Matrix4, Object3D, Shape, ShapeGeometry, Vector2, Vector3 } from 'three';
import { ColorMaterial } from '../Common/ColorPalette';
import { Vec2DTo3D, getCircleCenter } from '../Common/CurveUtils';
import { getCircleCenter, getTanPtsOnArcOrCircle, Vec2DTo3D } from '../Common/CurveUtils';
import { matrixSetVector } from '../Common/Matrix4Utils';
import { angle, angleTo2Pi, equalv3, equaln, midPoint, polar, MoveMatrix } from '../Geometry/GeUtils';
import { Status } from '../Common/Status';
import { ObjectSnapMode } from '../Editor/ObjectSnapMode';
import { angle, angleTo2Pi, equaln, equalv3, midPoint, MoveMatrix, polar } from '../Geometry/GeUtils';
import { RenderType } from '../GraphicsSystem/Enum';
import { IntersectArcAndArc, IntersectCircleAndArc, IntersectLineAndArc, IntersectOption, IntersectPolylineAndCurve, reverseIntersectOption } from '../GraphicsSystem/IntersectWith';
import { Factory } from './CADFactory';
@ -12,7 +14,6 @@ import { Circle } from './Circle';
import { Curve } from './Curve';
import { Line } from './Line';
import { Polyline } from './Polyline';
import { Status } from '../Common/Status';
/**
*
* ACAD,,.
@ -251,6 +252,29 @@ export class Arc extends Curve
return ptAllAn / allAn;
}
/**
* Gets param at angle2
* @param an
* @param [isStart] true:false
* @returns
*/
GetParamAtAngle2(an: number, isStart = true)
{
//如果以pt为终点,那么所有的角度为
let ptAllAn = this.ComputeAnlge(an);
let allAn = this.AllAngle;
//减去圆弧角度,剩余角度的一半
let surplusAngleHalf = Math.PI - allAn / 2;
if (isStart)//返回负数
{
return ((ptAllAn - allAn) - (surplusAngleHalf * 2)) / allAn;
}
else//返回正数
return ptAllAn / allAn;
}
GetAngleAtPoint(pt: Vector3)
{
let ptTmp = pt.clone().applyMatrix4(this.OCSInv);
@ -553,7 +577,8 @@ export class Arc extends Curve
private UpdateGeometry(geo: THREE.Geometry)
{
let shape = this.Shape;
geo.setFromPoints(shape.getPoints(60));
let pts = shape.getPoints(60);
geo.setFromPoints(pts);
geo.verticesNeedUpdate = true;
}
@ -569,7 +594,44 @@ export class Arc extends Curve
let geo = obj["geometry"] as ShapeGeometry;
this.UpdateGeometry(geo);
}
GetSnapPoints(): Array<THREE.Vector3>
GetObjectSnapPoints(
snapMode: ObjectSnapMode,
pickPoint: Vector3,
lastPoint: Vector3
): Vector3[]
{
switch (snapMode)
{
case ObjectSnapMode.End:
return [this.StartPoint, this.EndPoint];
case ObjectSnapMode.Mid:
return [this.GetPointAtParam(0.5)];
case ObjectSnapMode.Nea:
return [this.GetClosestPointTo(pickPoint, false)].filter(p => this.PtOnCurve(p));
case ObjectSnapMode.Ext:
return [this.GetClosestPointTo(pickPoint, true)];
case ObjectSnapMode.Cen:
return [this.Center];
case ObjectSnapMode.Per:
if (lastPoint)
{
if (equaln(lastPoint.distanceToSquared(this.Center), 0, 1e-10))
return [];
let l = new Line(this.Center, lastPoint);
return l.IntersectWith(this, IntersectOption.ExtendBoth).filter(p => this.PtOnCurve(p));
}
case ObjectSnapMode.Tan:
let pts = getTanPtsOnArcOrCircle(this, lastPoint);
if (pts)
return pts.filter(p => this.PtOnCurve(p));
default:
break;
}
return [];
}
GetGripPoints(): Array<THREE.Vector3>
{
return [
this.StartPoint,
@ -578,12 +640,12 @@ export class Arc extends Curve
this.Center.clone(),
];
}
MoveSnapPoints(indexList: Array<number>, vec: Vector3)
MoveGripPoints(indexList: Array<number>, vec: Vector3)
{
if (indexList.length > 0)
{
this.WriteAllObjectRecord();
let ptsArr = this.GetSnapPoints();
let ptsArr = this.GetGripPoints();
let index = indexList[0];
let p = ptsArr[index];
if (p)

@ -408,10 +408,10 @@ export class Board extends Entity
this.Update();
return this;
}
GetSnapPoints(): Array<THREE.Vector3>
GetGripPoints(): Array<THREE.Vector3>
{
let cu = this.m_Shape.Outline.Curve;
let pts = cu.GetSnapPoints();
let pts = cu.GetGripPoints();
let vec = new Vector3(0, 0, -this.m_Thickness);
pts = pts.concat(pts.map(p => p.clone().add(vec)));
@ -423,11 +423,11 @@ export class Board extends Entity
let pts = cu.GetStretchPoints();
return pts.map(p => p.applyMatrix4(this.OCS));
}
MoveSnapPoints(indexList: Array<number>, vec: Vector3)
MoveGripPoints(indexList: Array<number>, vec: Vector3)
{
this.WriteAllObjectRecord();
let pts = this.m_Shape.Outline.Curve.GetSnapPoints();
let pts = this.m_Shape.Outline.Curve.GetGripPoints();
indexList = indexList.map(i =>
{
if (i > pts.length - 1)
@ -451,7 +451,7 @@ export class Board extends Entity
vl.copy(derv);
}
cur.MoveSnapPoints(indexList.slice(0, indexList.length / 2), vl);
cur.MoveGripPoints(indexList.slice(0, indexList.length / 2), vl);
this.Update();
}

@ -12,6 +12,8 @@ import { CADFile } from './CADFile';
import { Curve } from './Curve';
import { Line } from './Line';
import { Polyline } from './Polyline';
import { ObjectSnapMode } from '../Editor/ObjectSnapMode';
import { getTanPtsOnArcOrCircle } from '../Common/CurveUtils';
@Factory
export class Circle extends Curve
@ -239,7 +241,7 @@ export class Circle extends Curve
this.UpdateGeometry(geo);
}
GetSnapPoints(): Array<THREE.Vector3>
GetGripPoints(): Array<THREE.Vector3>
{
let pts = [
new Vector3(),
@ -253,10 +255,39 @@ export class Circle extends Curve
pts.forEach(p => p.applyMatrix4(ocs));
return pts;
}
MoveSnapPoints(indexList: Array<number>, vec: Vector3)
GetObjectSnapPoints(
snapMode: ObjectSnapMode,
pickPoint: Vector3,
lastPoint: Vector3
): Vector3[]
{
switch (snapMode)
{
case ObjectSnapMode.Nea:
return [this.GetClosestPointTo(pickPoint, false)];
case ObjectSnapMode.Cen:
return [this.Center];
case ObjectSnapMode.Per:
if (lastPoint)
{
if (equaln(lastPoint.distanceToSquared(this.Center), 0, 1e-10))
return [];
let l = new Line(this.Center, lastPoint);
return l.IntersectWith(this, IntersectOption.ExtendBoth);
}
case ObjectSnapMode.Tan:
let pts = getTanPtsOnArcOrCircle(this, lastPoint);
if (pts)
return pts;
default:
break;
}
return [];
}
MoveGripPoints(indexList: Array<number>, vec: Vector3)
{
let pts = this.GetSnapPoints();
let pts = this.GetGripPoints();
if (indexList.length > 0)
{
let index = indexList[0];

@ -161,7 +161,7 @@ export class AlignedDimension extends Dimension
this.updateTwoArrows(objs[4], objs[5], pts[0], pts[1]);
}
GetSnapPoints(): Array<THREE.Vector3>
GetGripPoints(): Array<THREE.Vector3>
{
return [this.StartPoint, this.EndPoint, ...this.GetDimPts(), this.TextPosition];
}

@ -336,7 +336,7 @@ export class LineAngularDimension extends Dimension
this.updateDimLine(l2, lineEndPt, extEpt);
}
GetSnapPoints(): Array<THREE.Vector3>
GetGripPoints(): Array<THREE.Vector3>
{
let {
arcStartPt,

@ -1,9 +1,7 @@
import { Command } from "../../Editor/CommandMachine";
import { AlignedDimension } from "./AlignedDimension";
import { Vector3 } from "three";
import { app } from "../../ApplicationServices/Application";
import { LinearDimension } from "./LinearDimension";
import { Text } from "../Text/Text";
import { Command } from "../../Editor/CommandMachine";
import { AlignedDimension } from "./AlignedDimension";
export class Command_DimTest implements Command
{
@ -16,7 +14,7 @@ export class Command_DimTest implements Command
export()
{
let dim = new AlignedDimension(new Vector3(), new Vector3(5), new Vector3(1, 3), "123");
dim.GetSnapPoints()
dim.GetGripPoints()
app.m_Database.ModelSpace.Append(dim);
let cus = dim.Explode();
cus.forEach(cu =>

@ -103,9 +103,9 @@ export class Ellipse extends Curve
}
GetStretchPoints(): Array<Vector3>
{
return this.GetSnapPoints();
return this.GetGripPoints();
}
GetSnapPoints(): Array<Vector3>
GetGripPoints(): Array<Vector3>
{
let tmpMat4 = new THREE.Matrix4().makeRotationZ(this.Angle);
let pts = [
@ -121,7 +121,7 @@ export class Ellipse extends Curve
{
this.ApplyMatrix(MoveMatrix(vec));
}
MoveSnapPoints(indexList: Array<number>, vec: Vector3)
MoveGripPoints(indexList: Array<number>, vec: Vector3)
{
let pts = this.GetStretchPoints();

@ -1,4 +1,3 @@
import * as THREE from 'three';
import { Box3, Geometry, Matrix4, Object3D, Vector3 } from 'three';
import { DisposeThreeObj } from '../Common/Dispose';
import { matrixIsCoplane } from '../Common/Matrix4Utils';
@ -9,6 +8,7 @@ import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADObject } from './CADObject';
import { ObjectId } from './ObjectId';
import { ObjectSnapMode } from '../Editor/ObjectSnapMode';
/**
* Entity ,.
@ -20,7 +20,7 @@ import { ObjectId } from './ObjectId';
@Factory
export class Entity extends CADObject
{
protected m_DrawEntity = new Map<RenderType, THREE.Object3D>();
protected m_DrawEntity = new Map<RenderType, Object3D>();
//材质id
protected m_MaterialId: ObjectId;
protected m_Color: number = 7;
@ -125,10 +125,10 @@ export class Entity extends CADObject
* ,,.
*
* @param {RenderType} [renderType=RenderType.Wireframe]
* @returns {THREE.Object3D}
* @returns {Object3D}
* @memberof Entity
*/
Draw(renderType: RenderType = RenderType.Wireframe): THREE.Object3D
Draw(renderType: RenderType = RenderType.Wireframe): Object3D
{
if (this.m_DrawEntity.has(renderType))
{
@ -152,7 +152,7 @@ export class Entity extends CADObject
}
}
private UpdateBoundingSphere(drawObj: THREE.Object3D)
private UpdateBoundingSphere(drawObj: Object3D)
{
//@ts-ignore
let geo = drawObj.geometry as Geometry;
@ -273,17 +273,33 @@ export class Entity extends CADObject
return this;
}
GetSnapPoints(): Array<THREE.Vector3>
GetGripPoints(): Array<Vector3>
{
return [];
}
MoveSnapPoints(indexList: number[], vec: Vector3)
MoveGripPoints(indexList: number[], vec: Vector3)
{
}
GetStretchPoints(): Array<THREE.Vector3>
/**
*
* @param snapMode ()
* @param pickPoint const
* @param lastPoint const
* @returns object snap points
*/
GetObjectSnapPoints(
snapMode: ObjectSnapMode,
pickPoint: Vector3,
lastPoint: Vector3
): Vector3[]
{
return [];
}
GetStretchPoints(): Array<Vector3>
{
return [];
}
@ -292,10 +308,10 @@ export class Entity extends CADObject
* ,Stretch
*
* @param {Array<number>} indexList .
* @param {THREE.Vector3} vec
* @param {Vector3} vec
* @memberof Entity
*/
MoveStretchPoints(indexList: Array<number>, vec: THREE.Vector3)
MoveStretchPoints(indexList: Array<number>, vec: Vector3)
{
}

@ -14,6 +14,7 @@ import { CADFile } from './CADFile';
import { Circle } from './Circle';
import { Curve } from './Curve';
import { Polyline } from './Polyline';
import { ObjectSnapMode } from '../Editor/ObjectSnapMode';
@Factory
export class Line extends Curve
@ -51,11 +52,40 @@ export class Line extends Curve
BufferGeometryUtils.UpdatePts(lineObj.geometry as BufferGeometry, [this.m_StartPoint, this.m_EndPoint]);
}
GetSnapPoints(): Array<THREE.Vector3>
GetObjectSnapPoints(
snapMode: ObjectSnapMode,
pickPoint: Vector3,
lastPoint: Vector3
): Vector3[]
{
switch (snapMode)
{
case ObjectSnapMode.End:
return [this.StartPoint, this.EndPoint];
case ObjectSnapMode.Mid:
return [this.GetPointAtParam(0.5)];
case ObjectSnapMode.Nea:
return [this.GetClosestPointTo(pickPoint, false)];
case ObjectSnapMode.Ext:
return [this.GetClosestPointTo(pickPoint, true)];
case ObjectSnapMode.Per:
if (lastPoint)
{
let { closestPt, param } = this.GetClosestAtPoint(lastPoint, true);
if (this.ParamOnCurve(param))
return [closestPt];
}
default:
break;
}
return [];
}
GetGripPoints(): Array<THREE.Vector3>
{
return [this.StartPoint, this.GetPointAtParam(0.5), this.EndPoint];
}
MoveSnapPoints(indexList: Array<number>, vec: Vector3)
MoveGripPoints(indexList: Array<number>, vec: Vector3)
{
this.WriteAllObjectRecord();
for (let index of indexList)

@ -1,4 +1,5 @@
import { AdditiveBlending, BufferGeometry, Float32BufferAttribute, Object3D, Points, PointsMaterial, TextureLoader, Vector3 } from "three";
import { ObjectSnapMode } from "../Editor/ObjectSnapMode";
import { MoveMatrix } from "../Geometry/GeUtils";
import { RenderType } from "../GraphicsSystem/Enum";
import { Factory } from "./CADFactory";
@ -47,11 +48,23 @@ export class Point extends Entity
geometry.addAttribute("position", new Float32BufferAttribute([0, 0, 0], 3));
return new Points(geometry, LoadPointMaterial());
}
GetSnapPoints(): Array<Vector3>
GetObjectSnapPoints(
snapMode: ObjectSnapMode,
pickPoint: Vector3,
lastPoint: Vector3
): Vector3[]
{
if (snapMode === ObjectSnapMode.End)
return [this.Position];
return [];
}
GetGripPoints(): Array<Vector3>
{
return [this.Position];
}
MoveSnapPoints(indexList: number[], vec: Vector3)
MoveGripPoints(indexList: number[], vec: Vector3)
{
if (indexList.length === 1)
{
@ -62,7 +75,7 @@ export class Point extends Entity
GetStretchPoints(): Array<Vector3>
{
return this.GetSnapPoints();
return this.GetGripPoints();
}
/**
@ -74,6 +87,6 @@ export class Point extends Entity
*/
MoveStretchPoints(indexList: Array<number>, vec: Vector3)
{
this.MoveSnapPoints(indexList, vec);
this.MoveGripPoints(indexList, vec);
}
}

@ -17,6 +17,7 @@ import { CADFile } from './CADFile';
import { Curve, ExtendType } from './Curve';
import { Line } from './Line';
import { IsPointInPolyLine } from './PointInPolyline';
import { ObjectSnapMode } from '../Editor/ObjectSnapMode';
export interface PolylineProps
{
@ -987,8 +988,80 @@ export class Polyline extends Curve
updateGeometry(plObj, geo);
}
}
GetSnapPoints(): Array<THREE.Vector3>
GetObjectSnapPoints(
snapMode: ObjectSnapMode,
pickPoint: Vector3,
lastPoint: Vector3
): Vector3[]
{
switch (snapMode)
{
case ObjectSnapMode.End:
return this.GetStretchPoints();
case ObjectSnapMode.Mid:
let midPts = [];
let enParam = this.EndParam;
for (let i = 0.5; i < enParam; i++)
{
let p = this.GetPointAtParam(i);
p && midPts.push(p);
}
return midPts;
case ObjectSnapMode.Nea:
{
let cp = this.GetClosestPointTo(pickPoint, false);
if (cp)
return [cp];
break;
}
case ObjectSnapMode.Ext:
{
let cp = this.GetClosestPointTo(pickPoint, true);
if (cp)
return [cp];
break;
}
case ObjectSnapMode.Cen:
let cenPts: Vector3[] = [];
for (let i = 0; i < this.m_LineData.length; i++)
{
let data = this.m_LineData[i];
if (!equaln(data.bul, 0))
{
let cu = this.GetCurveAtIndex(i) as Arc;
cenPts.push(cu.Center);
}
}
return cenPts;
case ObjectSnapMode.Per:
if (lastPoint)
{
let cp = this.GetClosestPointTo(pickPoint, false);
let cparam = this.GetParamAtPoint(cp);
let cu = this.GetCurveAtParam(cparam);
if (cu)
{
let closestPt = cu.GetClosestPointTo(lastPoint, true);
if (closestPt && this.PtOnCurve(closestPt))
return [closestPt];
}
}
case ObjectSnapMode.Tan:
if (lastPoint)
{
let clostPt = this.GetClosestPointTo(pickPoint, false);
let par = this.GetParamAtPoint(clostPt);
let cu = this.GetCurveAtParam(par)
if (cu instanceof Arc)
return cu.GetObjectSnapPoints(snapMode, pickPoint, lastPoint);
return [];
}
default:
break;
}
return [];
}
GetGripPoints(): Array<THREE.Vector3>
{
let ptList: Vector3[] = [];
if (this.m_LineData.length < 2)
@ -1003,7 +1076,7 @@ export class Polyline extends Curve
}
return ptList;
}
MoveSnapPoints(indexList: number[], moveVec: Vector3)
MoveGripPoints(indexList: number[], moveVec: Vector3)
{
this.WriteAllObjectRecord();
@ -1024,13 +1097,13 @@ export class Polyline extends Curve
if (frontIndex >= 0 && this.GetBuilgeAt(frontIndex))
{
let arc = this.GetCurveAtIndex(frontIndex) as Arc;
arc.MoveSnapPoints([2], moveVec);
arc.MoveGripPoints([2], moveVec);
this.m_LineData[frontIndex].bul = arc.Bul;
}
if (this.GetBuilgeAt(cuIndex))
{
let arc = this.GetCurveAtIndex(cuIndex) as Arc;
arc.MoveSnapPoints([0], moveVec);
arc.MoveGripPoints([0], moveVec);
this.m_LineData[cuIndex].bul = arc.Bul;
}
this.m_LineData[cuIndex].pt.add(moveVLoc);
@ -1048,7 +1121,7 @@ export class Polyline extends Curve
else
{
let arc = this.GetCurveAtIndex(ptIndex) as Arc;
arc.MoveSnapPoints([1], moveVec);
arc.MoveGripPoints([1], moveVec);
this.m_LineData[ptIndex].bul = arc.Bul;
}
}

@ -80,13 +80,13 @@ export class Region extends Entity
this.WriteAllObjectRecord();
this.m_ShapeManager.ApplyMatrix(m);
}
GetSnapPoints(): Array<THREE.Vector3>
GetGripPoints(): Array<THREE.Vector3>
{
let pts = []
this.m_ShapeManager.ShapeList.forEach(s => pts.push(...s.Outline.Curve.GetStretchPoints()))
return pts;
}
MoveSnapPoints(indexList: number[], moveVec: Vector3)
MoveGripPoints(indexList: number[], moveVec: Vector3)
{
this.WriteAllObjectRecord();
let moveVLoc = moveVec.clone().applyMatrix4(new Matrix4().extractRotation(this.OCSInv));

@ -62,15 +62,15 @@ export class Spline extends Curve
{
return this.m_PointList.length - 1;
}
GetSnapPoints()
GetGripPoints()
{
return this.m_PointList.map(p => p.clone().applyMatrix4(this.OCS));
}
GetStretchPoints()
{
return this.GetSnapPoints();
return this.GetGripPoints();
}
MoveSnapPoints(indexList: Array<number>, vec: Vector3)
MoveGripPoints(indexList: Array<number>, vec: Vector3)
{
this.WriteAllObjectRecord();
for (let index of indexList)

@ -104,7 +104,7 @@ export class Text extends Entity
let geo = this.CreateText(this.TextString).geometry as Geometry;
updateGeometry(text, geo);
}
GetSnapPoints(): Array<THREE.Vector3>
GetGripPoints(): Array<THREE.Vector3>
{
return [this.TextPosition];
}

@ -1,5 +1,5 @@
import { app } from '../ApplicationServices/Application';
import { Jig } from './Jig';
import { JigUtils } from './JigUtils';
export interface Command
{
exec: Function;//函数可以返回true,实现放弃命令的任何操作.
@ -75,7 +75,7 @@ export class CommandMachine
app.m_Database.hm.Undo();
this.m_CommandIng = false;
app.m_Viewer.m_GripScene.UpdateAll();
Jig.End();
JigUtils.End();
app.m_Editor.UpdateScreen();
}

@ -86,6 +86,7 @@ import { DrawDrilling } from '../Add-on/DrawDrilling/DrawDrilling';
import { DrawSpecialShapedBoardByContour } from '../Add-on/DrawBoard/DrawSpecialShapedBoardByContour';
import { DrawSpecialShapedBoard } from '../Add-on/DrawBoard/DrawSpecialShapedBoard';
import { DrawTangentLine } from '../Add-on/Tangent';
export function registerCommand()
{
commandMachine.RegisterCommand("b", new DrawBox())
@ -175,6 +176,8 @@ export function registerCommand()
commandMachine.RegisterCommand("dl", new TestDrawDirectionalLight());
commandMachine.RegisterCommand("tan", new DrawTangentLine());
commandMachine.RegisterCommand("oo", new OffsetX());
commandMachine.RegisterCommand("div", new CMD_Divide());
commandMachine.RegisterCommand("pt", new CMD_DrawPoint());

@ -7,7 +7,7 @@ import { Point } from "../../DatabaseServices/Point";
import { Polyline, PolylineProps } from "../../DatabaseServices/Polyline";
import { Spline } from "../../DatabaseServices/Spline";
import { equaln, equalv3 } from "../../Geometry/GeUtils";
import { Jig } from "../Jig";
import { JigUtils } from "../JigUtils";
import { PromptStatus } from "../PromptResult";
import { log } from "../../Common/Utils";
@ -82,7 +82,7 @@ export class DBClickPolyline
break;
case "E": //编辑顶点
execStatus = await this.EditorVertex();
Jig.Destroy();
JigUtils.Destroy();
break;
case "D": //非曲线化
totalRecCount++;
@ -125,7 +125,7 @@ export class DBClickPolyline
//顶点位置
let vertex: IVertex = {
index: 0,
point: Jig.Draw(new Point(this.entity.StartPoint))
point: JigUtils.Draw(new Point(this.entity.StartPoint))
};
//存储前后顶点索引

@ -15,6 +15,7 @@ import { EditorService } from './Editor';
import { HandleKeyword, InitKeyWord } from './InitKeyword';
import { PromptPointResult, PromptStatus } from './PromptResult';
import { SnapServices } from './SnapServices';
import { ObjectSnapMode } from './ObjectSnapMode';
/**
* ,Editor.
@ -29,7 +30,7 @@ export class GetPointServices implements EditorService
{
if (e.button == MouseKey.Left)
{
this._return(this.curPoint);
this._return(this.curPoint, this.curPointIsSnap ? this.snapServices.SnapMode : undefined);
}
return false;
}
@ -120,7 +121,10 @@ export class GetPointServices implements EditorService
this.removeCalls.push(xaop.end(app.m_Editor.m_KeyCtrl, app.m_Editor.m_KeyCtrl.OnKeyDown, (e: KeyboardEvent) =>
{
if (e.keyCode == KeyBoard.Escape)
{
this.Cancel();
return true;
}
}));
}
@ -276,14 +280,14 @@ export class GetPointServices implements EditorService
//当存在轴线捕捉的时,并且不存在基点时,切换成轴线输入模式.
if (!prompt.BasePoint)
{
if (this.snapServices.m_AxisPts.length === 2)
if (this.snapServices.SnapMode === ObjectSnapMode.Axis)
{
if (dynPrompt instanceof GetPointPromptBlock)
{
dynPrompt.Destroy();
dynPrompt = new GetPoint2PromptBlock(DynamicInputManage.GetManage());
dynPrompt.BasePoint = this.snapServices.m_AxisPts[0];
dynPrompt.UpdatePrompt("线:");
dynPrompt.BasePoint = this.snapServices.AxisSnapBasePoint;
dynPrompt.UpdatePrompt("轴:");
}
}
else
@ -346,7 +350,7 @@ export class GetPointServices implements EditorService
}
//调用promis的回调.
protected _return(v: THREE.Vector3 | string)
protected _return(v: THREE.Vector3 | string, snapMode?: ObjectSnapMode)
{
let retValue = new PromptPointResult();
if (v instanceof THREE.Vector3)
@ -354,6 +358,8 @@ export class GetPointServices implements EditorService
retValue.Status = PromptStatus.OK;
retValue.Value = v;
retValue.SnaoMode = snapMode;
this.lastPoint = v;
}
else

@ -2,54 +2,37 @@ import { app } from "../ApplicationServices/Application";
import { Entity } from "../DatabaseServices/Entity";
import { RenderType } from "../GraphicsSystem/Enum";
import { CADFile } from "../DatabaseServices/CADFile";
/**
* ,.
*
* # Example:
* //1.开始拽拖:->
* //得到临时对象,如果en是已经存在的对象,那么将会被临时修改材质
* let jigEnt = Jig.Draw(en);
* //2.拽拖中:-> ....拽拖代码.更新jigEnt,你可以临时调用Jig.Destroy();
* //3.结束拽拖:
* Jig.End();
* @export
* @class Jig
*/
export class Jig
{
//临时图形,如果需要,将被销毁.
private static m_JigEnts: Entity[] = [];
private m_JigEnts: Entity[] = [];
//图纸数据缓存,用于还原
private static m_EntityCacheData: { Ent: Entity, File: CADFile }[] = [];
private static m_OrgEntitys: Entity[] = [];
static End()
private m_EntityCacheData: {
Ent: Entity;
File: CADFile;
}[] = [];
private m_OrgEntitys: Entity[] = [];
End()
{
this.Destroy();
this.RestoreOriginEntity();
}
/**
*
*
* @static
* @memberof Jig
*/
static RestoreOriginEntity()
RestoreOriginEntity()
{
this.m_OrgEntitys.forEach(e => e.RestoreJigMaterial());
this.m_EntityCacheData.length = 0;
}
/**
* .
* :,,,便.
* @static
* @param {Entity} enOrg
* @memberof Jig
*/
static Draw<T extends Entity>(enOrg: T): T
Draw<T extends Entity>(enOrg: T): T
{
let enNew: T;
if (enOrg.Id)
@ -57,40 +40,34 @@ export class Jig
enNew = enOrg.Clone();
this.m_OrgEntitys.push(enOrg);
enOrg.UpdateJigMaterial();
let f = new CADFile();
enNew.WriteFile(f);
this.m_EntityCacheData.push({ Ent: enNew, File: f });
}
else
enNew = enOrg;
this.m_JigEnts.push(enNew);
let obj = enNew.Draw(RenderType.Wireframe);
app.m_Viewer.Scene.add(obj);
return enNew;
}
/**
* .
* @static
* @memberof Jig
*/
static Restore()
Restore()
{
this.m_EntityCacheData.forEach((v) =>
{
v.File.Reset();
v.Ent.ReadFile(v.File);
})
});
}
/**
* ,,.
* @static
* @memberof Jig
*/
static Destroy()
Destroy()
{
this.m_JigEnts.forEach(e =>
{

@ -0,0 +1,68 @@
import { Entity } from "../DatabaseServices/Entity";
import { Jig } from "./Jig";
let jig = new Jig();
/**
* ,.
*
* # Example:
* //1.开始拽拖:->
* //得到临时对象,如果en是已经存在的对象,那么将会被临时修改材质
* let jigEnt = Jig.Draw(en);
* //2.拽拖中:-> ....拽拖代码.更新jigEnt,你可以临时调用Jig.Destroy();
* //3.结束拽拖:
* Jig.End();
* @export
* @class Jig
*/
export class JigUtils
{
static End()
{
jig.End();
}
/**
*
*
* @static
* @memberof Jig
*/
static RestoreOriginEntity()
{
jig.RestoreOriginEntity();
}
/**
* .
* :,,,便.
* @static
* @param {Entity} enOrg
* @memberof Jig
*/
static Draw<T extends Entity>(enOrg: T): T
{
return jig.Draw(enOrg);
}
/**
* .
* @static
* @memberof Jig
*/
static Restore()
{
jig.Restore();
}
/**
* ,,.
* @static
* @memberof Jig
*/
static Destroy()
{
jig.Destroy();
}
}

@ -0,0 +1,24 @@
/**
* OSMODE
*/
export enum ObjectSnapMode
{
None = 0, //无
End = 1, //端点
Mid = 2, //中点
Cen = 4, //圆心
Node = 8,//节点
Qua = 16,//象限点
Int = 32,//交点
Ins = 64,//插入点
Per = 128,//垂足
Tan = 256,//切点
Nea = 512,//最近点
NotEntitySnap = 1024,//清除所有对象捕捉
App = 2048,//外观交点
Ext = 4096,//延伸
Par = 8192,//平行
Axis = 16384,//极轴
All = ~(~0 << 15) - 1024,
}

@ -2,6 +2,7 @@ import * as THREE from 'three';
import { Vector3 } from 'three';
import { Entity } from '../DatabaseServices/Entity';
import { SelectSet } from './SelectSet';
import { ObjectSnapMode } from './ObjectSnapMode';
export enum PromptStatus
{
@ -34,6 +35,7 @@ export class PromptResult
export class PromptPointResult extends PromptResult
{
SnaoMode: ObjectSnapMode;
private _value: THREE.Vector3
/**
*

@ -8,11 +8,12 @@ import { MouseKey } from '../Common/KeyEnum';
import { Entity } from '../DatabaseServices/Entity';
import { commandMachine } from './CommandMachine';
import { Editor, EditorService } from './Editor';
import { Jig } from './Jig';
import { JigUtils } from './JigUtils';
import { MouseControls } from './MouseControls';
import { PromptStatus } from './PromptResult';
import { DrawMode } from '../GraphicsSystem/PreViewer';
import { SnapPoint } from '../Geometry/GeUtils';
import { Line } from '../DatabaseServices/Line';
/**
*
@ -53,13 +54,17 @@ export class SnapDragServices implements EditorService
app.m_Editor.Prompt("拽拖开始:");
commandMachine.CommandStart("drag");
let oldSelect = app.m_Viewer.m_OutlinePass.selectedObjects;
app.m_Viewer.m_OutlinePass.selectedObjects = [];
app.m_Viewer.Render();
let snapIndexMap: { ent: Entity, indexArr: number[] }[] = [];
for (let ptsObj of app.m_Viewer.m_GripScene.children)
{
if (ptsObj instanceof THREE.Points)
{
let en = ptsObj.userData.userData as Entity;
let pts = en.GetSnapPoints();
let pts = en.GetGripPoints();
let arr: number[] = [];
for (let i = 0; i < pts.length; i++)
@ -77,22 +82,35 @@ export class SnapDragServices implements EditorService
}
let snapIndexMapClone = snapIndexMap.map(v =>
{
return { ent: Jig.Draw(v.ent), indexArr: v.indexArr };
return { ent: JigUtils.Draw(v.ent), indexArr: v.indexArr };
});
const DragTo = (p: Vector3, snapIndexMap = snapIndexMapClone) =>
{
Jig.Restore();
JigUtils.Restore();
for (let data of snapIndexMap)
{
let entDrawP = data.ent.GetSnapPoints()[data.indexArr[0]];
let entDrawP = data.ent.GetGripPoints()[data.indexArr[0]];
let vec = p.clone().sub(entDrawP);
data.ent.MoveSnapPoints(data.indexArr, vec);
data.ent.MoveGripPoints(data.indexArr, vec);
}
}
let baseP = this.lastSnapPoint.clone();
if (snapIndexMap.length === 1 && snapIndexMap[0].ent instanceof Line)
{
if (snapIndexMap[0].indexArr.length === 1)
{
let i = snapIndexMap[0].indexArr[0];
if (i === 0)
baseP = snapIndexMap[0].ent.EndPoint;
else if (i === 2)
baseP = snapIndexMap[0].ent.StartPoint;
}
}
let ptRes = await app.m_Editor.GetPoint({
Msg: "指定下一个点:",
BasePoint: this.lastSnapPoint.clone(),
BasePoint: baseP,
AllowDrawRubberBand: true,
Callback: DragTo
});
@ -100,8 +118,9 @@ export class SnapDragServices implements EditorService
if (ptRes.Status === PromptStatus.OK)
DragTo(ptRes.Value, snapIndexMap);
Jig.End();
JigUtils.End();
app.m_Viewer.m_OutlinePass.selectedObjects = oldSelect;
this.UpdateSnapPoint();
this.UpdateSnapDraw();
@ -141,7 +160,7 @@ export class SnapDragServices implements EditorService
if (ptsObj instanceof THREE.Points)
{
let en = ptsObj.userData.userData as Entity;
let pts = en.GetSnapPoints();
let pts = en.GetGripPoints();
for (let i = 0; i < pts.length; i++)
{
let ptW = pts[i];
@ -193,7 +212,7 @@ export class SnapDragServices implements EditorService
/**
*
*/
private HideDrawLine()
HideDrawLine()
{
if (this.previewCrossLine && this.previewCrossLine.visible)
{

File diff suppressed because it is too large Load Diff

@ -8,7 +8,7 @@ import { MoveMatrix } from '../../Geometry/GeUtils';
import { PreViewer } from '../../GraphicsSystem/PreViewer';
import { commandMachine } from '../CommandMachine';
import { Editor, EditorService } from '../Editor';
import { Jig } from '../Jig';
import { JigUtils } from '../JigUtils';
import { PointPick } from '../PointPick';
import { PromptStatus } from '../PromptResult';
import { MatrixToPreViewMat } from '../UCSServices';
@ -86,7 +86,7 @@ export class TransformServicess implements EditorService
app.m_Database.hm.StartCmd("_move");
app.m_Viewer.m_GripScene.visible = false;
let jigEns = this.m_Ents.map(e => Jig.Draw(e));
let jigEns = this.m_Ents.map(e => JigUtils.Draw(e));
let base = new THREE.Vector3().setFromMatrixColumn(this.m_Matrix, 3);
let ptRes = await this.m_Editor.GetPoint({
@ -95,7 +95,7 @@ export class TransformServicess implements EditorService
AllowDrawRubberBand: true,
Callback: (newP) =>
{
Jig.Restore();
JigUtils.Restore();
let m = MoveMatrix(newP.clone().sub(base));
for (let e of jigEns)
e.ApplyMatrix(m);

@ -30,7 +30,7 @@ export class BoardGetFace
}
IsRect(cu: Curve)
{
let pts = cu.GetSnapPoints();
let pts = cu.GetGripPoints();
if (equalv3(pts[0], arrayLast(pts)))
pts.pop();

@ -44,8 +44,67 @@ export class PointShapeUtils
];
}
static TrianglePts(size: number)
{
return [
new Vector3(size, -size),
new Vector3(0, size),
new Vector3(-size, -size),
new Vector3(size, -size),
];
}
static CirclePts(size: number)
{
let pts = [];
let a = Math.PI * 2 / 8;
for (let i = 0; i < 9; i++)
pts.push(new Vector3(Math.sin(a * i) * size, Math.cos(a * i) * size));
return pts;
}
static BiasCrossPts(size)
{
return [new Vector3(-size, size), new Vector3(size, -size), new Vector3(-size, -size), new Vector3(size, size)];
}
static BiasCrossLinePts(size)
{
return [new Vector3(-size, size), new Vector3(size, -size), new Vector3(), new Vector3(-size, -size), new Vector3(size, size)];
}
static SandClockPts(size: number)
{
return [
new Vector3(size, size),
new Vector3(-size, size),
new Vector3(size, -size),
new Vector3(-size, -size),
new Vector3(size, size),
];
}
static TangentPts(size: number)
{
let pts = [
new Vector3(-size, size),
new Vector3(size, size),
new Vector3(size / 2, size),
];
let a = Math.PI * 2 / 8;
for (let i = 0; i < 9; i++)
pts.push(new Vector3(Math.sin(a * i + Math.PI / 2) * size, Math.cos(a * i + Math.PI / 2) * size));
return pts;
}
static PerPts(size: number)
{
return [
new Vector3(-size, size),
new Vector3(-size, -size),
new Vector3(size, -size),
new Vector3(0, -size),
new Vector3(0, 0),
new Vector3(-size, 0),
];
}
}

@ -27,7 +27,7 @@ export class GripScene extends THREE.Object3D
}
if (obj.userData instanceof Entity)
{
let pts = obj.userData.GetSnapPoints();
let pts = obj.userData.GetGripPoints();
let geom = new THREE.Geometry();
geom.setFromPoints(pts);
@ -73,7 +73,7 @@ export class GripScene extends THREE.Object3D
{
let en = obj.userData as Entity;
let geo = <THREE.Geometry>pts.geometry;
geo.setFromPoints(en.GetSnapPoints())
geo.setFromPoints(en.GetGripPoints())
geo.verticesNeedUpdate = true;
}
else

@ -124,23 +124,24 @@ export class PreViewer
//#region -------------------------坐标系转换-------------------------
//世界坐标系转视图坐标系
WorldToViewPoint(pWcs: THREE.Vector3)
WorldToViewPoint(pWcs: Vector3)
{
return this.ScreenPointToViewerPoint(app.m_Viewer.WorldToScreen(pWcs));
}
//屏幕坐标系赚视图坐标系
ScreenPointToViewerPoint(p: THREE.Vector3)
ScreenPointToViewerPoint(p: Vector3)
{
p.x = p.x - this.m_Width * 0.5;
p.y = this.m_Height * 0.5 - p.y;
return p;
}
//视图坐标系转屏幕坐标系
ViewerPointToScreenPoint(p: THREE.Vector3)
ViewerPointToScreenPoint(p: Vector3): Vector3
{
p.x = p.x + this.m_Width * 0.5;
p.y = this.m_Height * 0.5 - p.y;
return p;
}
//#endregion

@ -1,10 +1,10 @@
import * as THREE from 'three';
import { Vector3 } from 'three';
import { EffectComposer, Object3D, OutlinePass, RenderPass, Scene, Vector2, Vector3, WebGLRenderer } from 'three';
import * as xaop from 'xaop';
import { end } from 'xaop';
import { Database } from '../DatabaseServices/Database';
import { Entity } from '../DatabaseServices/Entity';
import { GenerateRaycaster } from '../Editor/PointPick';
import { CheckFilter } from '../Editor/SelectFilter';
import { cZeroVec, GetBox, GetBoxArr } from '../Geometry/GeUtils';
import { PlaneExt } from '../Geometry/Plane';
import { CameraUpdate } from './CameraUpdate';
@ -29,19 +29,19 @@ export class Viewer
//相机类
m_CameraCtrl: CameraUpdate = new CameraUpdate();
//变换控制
m_LookTarget: THREE.Vector3 = new THREE.Vector3();
m_LookTarget: Vector3 = new Vector3();
//渲染器//暂时只用这个类型
m_Render: THREE.WebGLRenderer;
m_Render: WebGLRenderer;
//前置渲染
m_PreViewer: PreViewer;
m_bUsePass = true;
m_RenderPass: THREE.RenderPass;
m_OutlinePass: THREE.OutlinePass;
m_Composer: THREE.EffectComposer;
m_RenderPass: RenderPass;
m_OutlinePass: OutlinePass;
m_Composer: EffectComposer;
private m_Scene: THREE.Scene = new THREE.Scene();
private m_Scene: Scene = new Scene();
m_GripScene: GripScene;
m_DomEl: HTMLElement;
@ -81,7 +81,7 @@ export class Viewer
//初始化render
initRender(canvasContainer: HTMLElement)
{
this.m_Render = new THREE.WebGLRenderer(
this.m_Render = new WebGLRenderer(
{
antialias: true,//antialias:true/false是否开启反锯齿
precision: "highp",//precision:highp/mediump/lowp着色精度选择
@ -105,7 +105,7 @@ export class Viewer
this.m_Render.setPixelRatio(window.devicePixelRatio);
//以下参数为三维渲染时需要开启的参数.
// this.m_Render.toneMapping = THREE.ReinhardToneMapping;
// this.m_Render.toneMapping = ReinhardToneMapping;
//设置设备像素比。 这通常用于HiDPI设备以防止模糊输出画布。
// this.m_Render.physicallyCorrectLights = true;
//this.m_Render.toneMappingExposure = Math.pow(1, 5.0); // to allow for very bright scenes.
@ -113,12 +113,12 @@ export class Viewer
//设置它的背景色为黑色
this.m_Render.setClearColor(0x000000, 1);
this.m_Composer = new THREE.EffectComposer(this.m_Render);
this.m_Composer = new EffectComposer(this.m_Render);
this.m_RenderPass = new THREE.RenderPass(this.m_Scene, this.m_CameraCtrl.Camera);
this.m_RenderPass = new RenderPass(this.m_Scene, this.m_CameraCtrl.Camera);
this.m_Composer.addPass(this.m_RenderPass);
this.m_OutlinePass = new THREE.OutlinePass(new THREE.Vector2(100, 100), this.m_Scene, this.m_CameraCtrl.Camera);
this.m_OutlinePass = new OutlinePass(new Vector2(100, 100), this.m_Scene, this.m_CameraCtrl.Camera);
this.m_OutlinePass.hiddenEdgeColor = this.m_OutlinePass.visibleEdgeColor;
this.m_OutlinePass.renderToScreen = true;
@ -164,10 +164,10 @@ export class Viewer
this.m_Render.render(this.Scene, this.Camera);
}
ScreenToWorld(pt: THREE.Vector3, planVec?: THREE.Vector3, constant?: number | Vector3)
ScreenToWorld(pt: Vector3, planVec?: Vector3, constant?: number | Vector3)
{
//变换和求交点
let plan = new PlaneExt(planVec || new THREE.Vector3(0, 0, 1), constant);
let plan = new PlaneExt(planVec || new Vector3(0, 0, 1), constant);
let raycaster = GenerateRaycaster(pt, this);
plan.intersectRay(raycaster.ray, pt, true);
return pt;
@ -191,26 +191,23 @@ export class Viewer
*/
UpdateLockTarget()
{
let renderList = this.m_Render.renderLists.get(this.m_Scene, this.m_CameraCtrl.Camera);
let objectList = renderList.transparent.map(o => o.object)
.concat(renderList.opaque.map(o => o.object));
let box = GetBoxArr(objectList);
let box = GetBoxArr(this.VisibleObjects);
if (!box.isEmpty())
this.m_LookTarget = box.getCenter(new Vector3());
else
this.m_LookTarget = cZeroVec;
}
Rotate(mouseMove: THREE.Vector3)
Rotate(mouseMove: Vector3)
{
this.m_CameraCtrl.Rotate(mouseMove, this.m_LookTarget);
this.m_bNeedUpdate = true;
}
Pan(mouseMove: THREE.Vector3)
Pan(mouseMove: Vector3)
{
this.m_CameraCtrl.Pan(mouseMove);
this.m_bNeedUpdate = true;
}
Zoom(scale: number, center?: THREE.Vector3)
Zoom(scale: number, center?: Vector3)
{
this.m_CameraCtrl.Zoom(scale, center);
this.m_bNeedUpdate = true;
@ -223,20 +220,38 @@ export class Viewer
ViewToTop()
{
this.m_CameraCtrl.LookAt(new THREE.Vector3(0, 0, -1));
this.m_CameraCtrl.LookAt(new Vector3(0, 0, -1));
this.m_bNeedUpdate = true;
}
ViewToFront()
{
this.m_CameraCtrl.LookAt(new THREE.Vector3(0, 1, 0));
this.m_CameraCtrl.LookAt(new Vector3(0, 1, 0));
this.m_bNeedUpdate = true;
}
ViewToSwiso()
{
this.m_CameraCtrl.LookAt(new THREE.Vector3(1, 1, -1));
this.m_CameraCtrl.LookAt(new Vector3(1, 1, -1));
this.m_bNeedUpdate = true;
}
/**
* (Threejs).
* OutlinePass,,.
*/
get VisibleObjects(): Object3D[]
{
let renderList = this.m_Render.renderLists.get(this.m_Scene, this.m_CameraCtrl.Camera);
return renderList.transparent.map(o => o.object)
.concat(renderList.opaque.map(o => o.object));
}
get VisibleEntitys(): Entity[]
{
let enObjs = this.VisibleObjects.filter(o => CheckFilter(o, { filterTypes: [Entity] }));
return enObjs.map(o => o.userData as Entity);
}
//TODO: 假设我现在只渲染一个数据层. 不渲染多个.
renderDatabase(db: Database)
{

@ -8,7 +8,7 @@ import { CheckObjectType } from "../../../Common/CheckoutVaildValue";
import { DataAdapter } from "../../../Common/DataAdapter";
import { Board } from "../../../DatabaseServices/Board";
import { commandMachine } from "../../../Editor/CommandMachine";
import { Jig } from "../../../Editor/Jig";
import { JigUtils } from "../../../Editor/JigUtils";
import { PromptStatus } from "../../../Editor/PromptResult";
import { MoveMatrix } from "../../../Geometry/GeUtils";
import { BoardConfigOption, BoardProcessOption } from '../../Store/BoardInterface';
@ -46,7 +46,7 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
app.m_Viewer.m_CameraCtrl.LookAt(br.Normal.negate());
app.m_Editor.UCSMatrix = new Matrix4().extractRotation(br.OCS);
let cu = Jig.Draw(br.Shape.Outline.Curve.Clone().ApplyMatrix(br.OCS));
let cu = JigUtils.Draw(br.Shape.Outline.Curve.Clone().ApplyMatrix(br.OCS));
let ptRes = await app.m_Editor.GetPoint({
Msg: "点取位置",
Callback: v =>
@ -55,7 +55,7 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
cu.ApplyMatrix(MoveMatrix(vec));
}
})
Jig.End();
JigUtils.End();
if (ptRes.Status === PromptStatus.OK)
app.m_Database.ModelSpace.Append(cu);

@ -9,7 +9,7 @@ import { Curve } from '../../../DatabaseServices/Curve';
import { Line } from '../../../DatabaseServices/Line';
import { Polyline } from '../../../DatabaseServices/Polyline';
import { Text } from '../../../DatabaseServices/Text/Text';
import { Jig } from '../../../Editor/Jig';
import { JigUtils } from '../../../Editor/JigUtils';
import { calcEdgeSealing } from '../../../GraphicsSystem/CalcEdgeSealing';
@observer
@ -32,16 +32,16 @@ export class EdgeSealingComponent extends React.Component<{ br: Board }, {}>
app.m_Editor.UCSMatrix = new Matrix4().extractRotation(br.OCS);
app.m_Editor.UpdateScreen();
Jig.Destroy();
JigUtils.Destroy();
for (let i = 0; i < this.cuList.length; i++)
{
let cu = this.cuList[i];
let p = cu.GetPointAtParam(cu.EndParam / 2);
Jig.Draw(new Text(p, (i + 1).toString()).ApplyMatrix(br.OCS));
JigUtils.Draw(new Text(p, (i + 1).toString()).ApplyMatrix(br.OCS));
//显示对应设置的边
let refCu = cu.Clone();
refCu.ColorIndex = i + 1
Jig.Draw(refCu.ApplyMatrix(br.OCS));
JigUtils.Draw(refCu.ApplyMatrix(br.OCS));
}
}
//曲线列表分段
@ -140,7 +140,7 @@ export class EdgeSealingComponent extends React.Component<{ br: Board }, {}>
offsetCus.forEach((cu, i) =>
{
cu.ApplyMatrix(this.props.br.OCS);
Jig.Draw(cu);
JigUtils.Draw(cu);
})
app.m_Editor.UpdateScreen();
}
@ -199,7 +199,7 @@ export class EdgeSealingComponent extends React.Component<{ br: Board }, {}>
style={{ marginRight: 10 }} />
<Button
text="取消"
onClick={() => Jig.Destroy()}
onClick={() => JigUtils.Destroy()}
intent={Intent.DANGER}
className={Classes.POPOVER_DISMISS} />
</div>

@ -4,8 +4,8 @@ import { app } from '../../../ApplicationServices/Application';
import { KeyBoard } from '../../../Common/KeyEnum';
import { Sleep } from '../../../Common/Utils';
import { commandMachine } from '../../../Editor/CommandMachine';
import { JigUtils } from '../../../Editor/JigUtils';
import './ModalStyle/Modal.less';
import { Jig } from '../../../Editor/Jig';
export enum ModalPosition
{
@ -208,7 +208,7 @@ export class ModalManage
this.m_IsModal = false;
this.events.forEach(f => f());
this.events.length = 0;
Jig.Destroy();
JigUtils.Destroy();
}
EndCmd()
{

Loading…
Cancel
Save