|
| 1 | +// Part of the Chili3d Project, under the AGPL-3.0 License. |
| 2 | +// See LICENSE file in the project root for full license information. |
| 3 | + |
| 4 | +import { command, EditableShapeNode, I18n, IEdge, IFace, IWire, Property, ShapeType, XYZ } from "chili-core"; |
| 5 | +import { IStep, SelectShapeStep } from "../../step"; |
| 6 | +import { CreateCommand } from "../createCommand"; |
| 7 | + |
| 8 | +@command({ |
| 9 | + key: "convert.curveProjection", |
| 10 | + icon: "icon-curveProjection", |
| 11 | +}) |
| 12 | +export class CurveProjectionCommand extends CreateCommand { |
| 13 | + @Property.define("common.dir") |
| 14 | + get dir() { |
| 15 | + return this.getPrivateValue("dir", "0,0,-1"); |
| 16 | + } |
| 17 | + |
| 18 | + set dir(value: string) { |
| 19 | + this.setProperty("dir", value); |
| 20 | + } |
| 21 | + |
| 22 | + protected override geometryNode() { |
| 23 | + let shape = this.stepDatas[0].shapes[0].shape as IEdge | IWire; |
| 24 | + let face = this.stepDatas[1].shapes[0].shape as IFace; |
| 25 | + const [x, y, z] = this.dir.split(",").map(Number); |
| 26 | + let dir = new XYZ(x, y, z).normalize() as XYZ; |
| 27 | + |
| 28 | + let curveProjection = this.application.shapeFactory.curveProjection(shape, face, dir); |
| 29 | + return new EditableShapeNode( |
| 30 | + this.document, |
| 31 | + I18n.translate("command.convert.curveProjection"), |
| 32 | + curveProjection.value, |
| 33 | + ); |
| 34 | + } |
| 35 | + |
| 36 | + protected override getSteps(): IStep[] { |
| 37 | + return [ |
| 38 | + new SelectShapeStep(ShapeType.Edge | ShapeType.Wire, "prompt.select.shape"), |
| 39 | + new SelectShapeStep(ShapeType.Face, "prompt.select.faces"), |
| 40 | + ]; |
| 41 | + } |
| 42 | +} |
0 commit comments