mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-07 17:04:58 +01:00
fix bezier curve
This commit is contained in:
parent
96f9621714
commit
bbdd0a00dc
3 changed files with 11 additions and 6 deletions
|
|
@ -1,4 +1,3 @@
|
|||
import {Ref} from './ref'
|
||||
import {SketchObject} from './sketch-object'
|
||||
import {Segment} from './segment'
|
||||
import {LUT} from '../../math/bezier-cubic'
|
||||
|
|
@ -6,8 +5,6 @@ import {ConvexHull2D} from '../../math/convex-hull'
|
|||
|
||||
import * as draw_utils from '../shapes/draw-utils'
|
||||
import * as math from '../../math/math';
|
||||
import {Arc} from "./arc";
|
||||
import {EndPoint} from "./point";
|
||||
|
||||
|
||||
export class BezierCurve extends SketchObject {
|
||||
|
|
@ -26,6 +23,10 @@ export class BezierCurve extends SketchObject {
|
|||
}
|
||||
}
|
||||
|
||||
stabilize(viewer) {
|
||||
this.children.forEach(c => c.stabilize(viewer));
|
||||
}
|
||||
|
||||
visitParams(callback) {
|
||||
this.a.visitParams(callback);
|
||||
this.b.visitParams(callback);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import {BezierCurve} from '../shapes/bezier-curve'
|
|||
import {Constraints} from '../parametric'
|
||||
import Vector from 'math/vector';
|
||||
import * as math from '../../math/math'
|
||||
import {AlgNumConstraint, ConstraintDefinitions} from "../constr/ANConstraints";
|
||||
|
||||
export class BezierCurveTool extends Tool {
|
||||
|
||||
|
|
@ -35,12 +36,16 @@ export class BezierCurveTool extends Tool {
|
|||
this.viewer.activeLayer.add(this.curve);
|
||||
this.viewer.refresh();
|
||||
} else {
|
||||
this.viewer.parametricManager.startTransaction();
|
||||
this.snapIfNeed(this.curve.b);
|
||||
if (this.otherCurveEndPoint != null) {
|
||||
this.viewer.parametricManager.add(new Constraints.Parallel(this.otherCurveEndPoint.parent, this.curve.a.parent));
|
||||
const smoothingConstr = new AlgNumConstraint(ConstraintDefinitions.Parallel, [this.otherCurveEndPoint.parent, this.curve.a.parent]);
|
||||
smoothingConstr.initConstants();
|
||||
this.viewer.parametricManager.add(smoothingConstr);
|
||||
}
|
||||
this.curve.stabilize(this.viewer);
|
||||
this.viewer.parametricManager.finishTransaction();
|
||||
this.viewer.toolManager.releaseControl();
|
||||
this.viewer.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {Tool} from './tool'
|
||||
import {EndPoint} from '../shapes/point'
|
||||
import {Segment} from '../shapes/segment'
|
||||
import {Constraints} from '../parametric'
|
||||
import {AlgNumConstraint, ConstraintDefinitions} from "../constr/ANConstraints";
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue