diff --git a/src/Add-on/ViewChange.ts b/src/Add-on/ViewChange.ts index b78a64284..86ffac8ad 100644 --- a/src/Add-on/ViewChange.ts +++ b/src/Add-on/ViewChange.ts @@ -41,7 +41,6 @@ export class ViewChange implements Command } }); - if (vres.Status === PromptStatus.OK) { let vs = vres.SelectSet.SelectEntityList as ViewportEntity[]; @@ -53,20 +52,19 @@ export class ViewChange implements Command app.Viewer.CameraCtrl.LookAt(this.viewDir); this.UcsLookAt(this.viewDir); - app.Viewer.ZoomAll(); - app.Editor.UpdateScreen(); + + if (app.Editor.SelectCtrl.SelectSet.SelectObjectCount) + app.Viewer.ZoomtoEntitys(app.Editor.SelectCtrl.SelectSet.SelectEntityList); + else + app.Viewer.ZoomAll(); } UcsLookAt(viewDir: Vector3) { if (this.useWCS) - { app.Editor.UCSMatrix = new Matrix4(); - } else - { app.Editor.SetUCSLookAt(viewDir); - } } private ChangeViewport(vs: ViewportEntity[]) { diff --git a/src/GraphicsSystem/CameraUpdate.ts b/src/GraphicsSystem/CameraUpdate.ts index 22f03b4d8..49c296908 100644 --- a/src/GraphicsSystem/CameraUpdate.ts +++ b/src/GraphicsSystem/CameraUpdate.ts @@ -7,6 +7,9 @@ const ViewScopeSize = 4e6; const ViewScopeMin = new Vector3(-ViewScopeSize, -ViewScopeSize * 0.7, -ViewScopeSize); const ViewScopeMax = ViewScopeMin.clone().negate(); +const ViewBoxMin = new Vector3(1, 1, 1); +const viewBoxMax = new Vector3(1e7, 1e7, 1e7); + export enum CameraType { OrthographicCamera = 1, @@ -165,8 +168,9 @@ export class CameraUpdate box3.getCenter(this._Target); //世界坐标系 this._Target.applyMatrix4(this.Camera.matrix); - //size + let size = box3.getSize(new Vector3()); + size.clamp(ViewBoxMin, viewBoxMax); //宽高比 let aspectRatio = size.x / size.y;