import { Vector2 } from 'three'; import { app } from '../ApplicationServices/Application'; import { Spline } from '../DatabaseServices/Spline'; import { Command } from '../Editor/CommandMachine'; import { PromptStatus } from '../Editor/PromptResult'; import { RenderType } from '../GraphicsSystem/Enum'; export class DrawSpline implements Command { async exec() { app.m_Editor.m_CommandStore.Prompt("请输入一个点:"); let ptRes = await app.m_Editor.GetPoint({ Msg: "请输入第一个点:" }); if (ptRes.Status != PromptStatus.OK) return; let p1 = ptRes.Value; let ptLast = new Vector2(p1.x, p1.y); let pts = [ptLast]; let spline = new Spline(pts); app.m_Database.ModelSpace.Append(spline); while (true) { ptLast = ptLast.clone(); pts.push(ptLast); app.m_Editor.m_CommandStore.Prompt("请输入点2:"); ptRes = await app.m_Editor.GetPoint({ Msg: "请输入点2:", BasePoint: p1, AllowDrawRubberBand: true, KeyWordList: [{ msg: "放弃", key: "U" }], Callback: (v) => { ptLast.set(v.x, v.y); spline.Points = pts; } }); if (ptRes.Status == PromptStatus.OK) { p1 = ptRes.Value; continue; } else { break; } } } }