diff --git a/src/Editor/GripDragServices.ts b/src/Editor/GripDragServices.ts index 9819c004b..9682df283 100644 --- a/src/Editor/GripDragServices.ts +++ b/src/Editor/GripDragServices.ts @@ -1,4 +1,4 @@ -import { Object3D, Points, Vector3 } from 'three'; +import { BufferGeometry, Line as TLine, Points, Vector3 } from 'three'; import { end } from 'xaop'; import { app } from '../ApplicationServices/Application'; import { ColorMaterial } from '../Common/ColorPalette'; @@ -7,7 +7,9 @@ import { MouseKey } from '../Common/KeyEnum'; import { GetEntity } from '../Common/Utils'; import { Entity } from '../DatabaseServices/Entity/Entity'; import { Line } from '../DatabaseServices/Entity/Line'; +import { BufferGeometryUtils } from '../Geometry/BufferGeometryUtils'; import { isParallelTo, isPerpendicularityTo, SnapPoint } from '../Geometry/GeUtils'; +import { PointShapeUtils } from '../Geometry/PointShapeUtils'; import { DrawMode } from '../GraphicsSystem/PreViewer'; import { CommandWrap } from './CommandMachine'; import { Editor, EditorService } from './Editor'; @@ -23,7 +25,7 @@ export class GripDragServices implements EditorService //最后捕捉的点的位置(在WCS中) lastSnapPoint: Vector3; private mouseCtrl: MouseControls; - SnapSize = 15; + private _SnapSize = 15; constructor(private ed: Editor) { this.mouseCtrl = ed.MouseCtrl; @@ -35,6 +37,20 @@ export class GripDragServices implements EditorService }); } + get SnapSize() { return this._SnapSize; } + set SnapSize(size: number) + { + if (size !== this._SnapSize) + { + this._SnapSize = size; + if (this.previewCrossLine) + { + let geo = this.previewCrossLine.geometry as BufferGeometry; + BufferGeometryUtils.UpdatePts(geo, PointShapeUtils.CrossLinePts(this._SnapSize)); + } + } + } + get IsReady() { return this.lastSnapPoint && this.ed.InputState === InputState.None; @@ -222,7 +238,7 @@ export class GripDragServices implements EditorService /** * 前视图中的光标对象 */ - previewCrossLine: Object3D = undefined; + previewCrossLine: TLine = undefined; /** * 在前视图中绘制捕捉光标 diff --git a/src/Editor/UserConfig.ts b/src/Editor/UserConfig.ts index 298261574..3e10b3b4e 100644 --- a/src/Editor/UserConfig.ts +++ b/src/Editor/UserConfig.ts @@ -49,7 +49,7 @@ export class UserConfig implements IConfigStore @observable SystemConfig: ISystemConfig = { maxHightightCount: 1000, snapSize: 15, - aaType: AAType.FXAA + aaType: AAType.SMAA }; constructor() { diff --git a/src/Geometry/PointShapeUtils.ts b/src/Geometry/PointShapeUtils.ts index c5c7323cc..aa23426d4 100644 --- a/src/Geometry/PointShapeUtils.ts +++ b/src/Geometry/PointShapeUtils.ts @@ -3,7 +3,7 @@ import { Vector3 } from "three"; export class PointShapeUtils { //方形点表 - static SquarePts(size) + static SquarePts(size: number) { return [ new Vector3(-size, -size), @@ -14,7 +14,7 @@ export class PointShapeUtils ]; } //方形外圈十字直线点表 - static OutsideLinePts(squareSize, lineLength) + static OutsideLinePts(squareSize: number, lineLength: number) { return [ //-X diff --git a/src/UI/Components/Modal/OptionModal/ConfigDialog.tsx b/src/UI/Components/Modal/OptionModal/ConfigDialog.tsx index 4dcfea508..b80ca86b4 100644 --- a/src/UI/Components/Modal/OptionModal/ConfigDialog.tsx +++ b/src/UI/Components/Modal/OptionModal/ConfigDialog.tsx @@ -50,6 +50,7 @@ export class ConfigStore extends Singleton app.Viewer.AAType = userConfig.SystemConfig.aaType; app.Editor.SelectCtrl.MaxHightightCount = userConfig.SystemConfig.maxHightightCount; app.Editor.SnapDragServices.SnapSize = userConfig.SystemConfig.snapSize; + app.Editor.GetPointServices.snapServices.SnapSize = userConfig.SystemConfig.snapSize; await userConfigStore.SaveConfig(BoardModalType.UserConfig, userConfig); }; } diff --git a/src/UI/Store/UserConfigStore.ts b/src/UI/Store/UserConfigStore.ts index 44b738004..baf26a7cf 100644 --- a/src/UI/Store/UserConfigStore.ts +++ b/src/UI/Store/UserConfigStore.ts @@ -134,6 +134,7 @@ export class UserConfigStore extends Singleton app.Viewer.AAType = userConfig.SystemConfig.aaType; app.Editor.SelectCtrl.MaxHightightCount = userConfig.SystemConfig.maxHightightCount; app.Editor.SnapDragServices.SnapSize = userConfig.SystemConfig.snapSize; + app.Editor.GetPointServices.snapServices.SnapSize = userConfig.SystemConfig.snapSize; } else {