From e03fd66f99e6da407f974d88074f96f119a18ed0 Mon Sep 17 00:00:00 2001 From: ChenX Date: Wed, 28 Mar 2018 17:17:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=9B=B4=E7=BA=BF=E7=9A=84?= =?UTF-8?q?=E6=8B=89=E4=BC=B8=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/Line/__snapshots__/line.test.ts.snap | 32 +++++++++++++++++++ __test__/Line/line.test.ts | 25 +++++++++++++++ src/DatabaseServices/Entity.ts | 8 +++++ 3 files changed, 65 insertions(+) diff --git a/__test__/Line/__snapshots__/line.test.ts.snap b/__test__/Line/__snapshots__/line.test.ts.snap index 23bbc813a..e1c8f30d1 100644 --- a/__test__/Line/__snapshots__/line.test.ts.snap +++ b/__test__/Line/__snapshots__/line.test.ts.snap @@ -1,5 +1,37 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`拉伸直线的夹点 1`] = ` +Vector3 { + "x": 0, + "y": 10, + "z": 0, +} +`; + +exports[`拉伸直线的夹点 2`] = ` +Vector3 { + "x": 10, + "y": 5, + "z": 0, +} +`; + +exports[`拉伸直线的夹点 3`] = ` +Vector3 { + "x": 0, + "y": 10, + "z": 0, +} +`; + +exports[`拉伸直线的夹点 4`] = ` +Vector3 { + "x": 15, + "y": 5, + "z": 0, +} +`; + exports[`最近点 1`] = ` Vector3 { "x": -2.5, diff --git a/__test__/Line/line.test.ts b/__test__/Line/line.test.ts index 2686c85c8..0e1c1c30e 100644 --- a/__test__/Line/line.test.ts +++ b/__test__/Line/line.test.ts @@ -128,3 +128,28 @@ test('最近点', () => expect(l.GetClosestPointTo(new Vector3(-5, 0, 0), false)/*?*/).toMatchSnapshot();//0,0,0. }); + + + +test('拉伸直线的夹点', () => +{ + + let line = new Line(new Vector3(0, 0, 0), new Vector3(10, 0, 0)); + + //测试拉伸一个参数 + line.MoveStretchPoints([0], new Vector3(0, 5, 0)); + + expect(line.StartPoint.toArray()).toMatchObject([0, 5, 0]); + + //测试同时拉伸2个点的情况下 + line.MoveStretchPoints([0, 1], new Vector3(0, 5, 0)); + + expect(line.StartPoint /*?*/).toMatchSnapshot(); + expect(line.EndPoint /*?*/).toMatchSnapshot(); + + + line.MoveStretchPoints([1], new Vector3(5, 0, 0)); + + expect(line.StartPoint).toMatchSnapshot(); + expect(line.EndPoint).toMatchSnapshot(); +}); diff --git a/src/DatabaseServices/Entity.ts b/src/DatabaseServices/Entity.ts index a6235c62b..6962aa457 100644 --- a/src/DatabaseServices/Entity.ts +++ b/src/DatabaseServices/Entity.ts @@ -204,6 +204,14 @@ export class Entity extends CADObject { return []; } + + /** + * 拉伸夹点,用于Stretch命令 + * + * @param {Array} indexList 拉伸点索引列表. + * @param {THREE.Vector3} vec 移动向量 + * @memberof Entity + */ MoveStretchPoints(indexList: Array, vec: THREE.Vector3) {