变更:Gizmo在选择多个实体时,按照选中实体盒子的中心进行操作

pull/1771/head
ChenX 3 years ago
parent f01e42cb23
commit e693dbc662

@ -1,12 +1,10 @@
import hotkeys from 'hotkeys-js-ext';
import { Curve, MathUtils, Matrix4, Vector3 } from 'three';
import { MathUtils, Vector3 } from 'three';
import { end } from 'xaop';
import { app } from '../ApplicationServices/Application';
import { InputState } from '../Common/InputState';
import { KeyBoard, MouseKey } from '../Common/KeyEnum';
import { GetEntity } from '../Common/Utils';
import { Entity } from '../DatabaseServices/Entity/Entity';
import { GetBox, IsBetweenA2B } from '../Geometry/GeUtils';
import { IsBetweenA2B } from '../Geometry/GeUtils';
import { CursorMode } from '../GraphicsSystem/Cursor';
import { IViewer } from '../GraphicsSystem/IView';
import { Viewer } from '../GraphicsSystem/Viewer';
@ -98,24 +96,8 @@ export class SelectControls implements EditorService
if (this._Viewer.OutlinePass.selectedObjects.length > 0)
{
let obj = this._Viewer.OutlinePass.selectedObjects[0];
let ocs: Matrix4;
let ent = GetEntity(obj);
if (ent instanceof Curve)
{
ocs = ent.OCS;
let box = GetBox(obj);
if (!box.isEmpty())
ocs.setPosition(box.getCenter(new Vector3()));
}
else if (ent instanceof Entity)
ocs = ent.OCS;
else
ocs = obj.matrixWorld.clone();
this._Editor.TransCtrl._Ents = this.SelectSet.SelectEntityList;
this._Editor.TransCtrl.Matrix = ocs;
this._Editor.TransCtrl.UpdateMtxFromEntity();
this._Editor.TransCtrl.Enable = true;
}
else

@ -1,4 +1,4 @@
import { MathUtils, Matrix4, Vector3 } from 'three';
import { Box3, MathUtils, Matrix4, Vector3 } from 'three';
import { end } from 'xaop';
import { app } from '../../ApplicationServices/Application';
import { CommandNames } from '../../Common/CommandNames';
@ -918,20 +918,26 @@ export class TransformServicess implements EditorService
this._Editor.App.Viewer.PreViewer.UpdateScreen();
}
set Matrix(mtx: Matrix4)
{
this._Matrix.copy(mtx);
this.UpdateAxesMatrix();
}
UpdateMtxFromEntity()
{
let ent = this._Ents[0];
if (!ent) return;
if (ent instanceof Curve)
this._Matrix.copy(ent.OCSNoClone).setPosition(ent.BoundingBox.getCenter(new Vector3));
else if (ent instanceof Entity)
this._Matrix.copy(ent.OCSNoClone);
if (this._Ents.length === 0) return;
if (this._Ents.length === 1)
{
let ent = this._Ents[0];
if (ent instanceof Curve)
this._Matrix.copy(ent.OCSNoClone).setPosition(ent.BoundingBox.getCenter(new Vector3));
else if (ent instanceof Entity)
this._Matrix.copy(ent.OCSNoClone);
}
else
{
let box = new Box3;
for (let e of this._Ents)
box.union(e.BoundingBox);
this._Matrix.identity().setPosition(box.getCenter(new Vector3));
}
this.UpdateAxesMatrix();
}

Loading…
Cancel
Save