diff --git a/src/Add-on/Entsel.ts b/src/Add-on/Entsel.ts index db3f06df0..154f4214f 100644 --- a/src/Add-on/Entsel.ts +++ b/src/Add-on/Entsel.ts @@ -23,7 +23,7 @@ export class Entsel implements Command vcs.add(new Vector3(0, -20, 0)); dyn.SetPostion(vcs); - dyn.updatePrompt(res.Value.constructor.name); + dyn.updatePrompt(res.Entity.constructor.name); } else dyn.Visible = false; @@ -31,11 +31,11 @@ export class Entsel implements Command }); if (en.Status == PromptStatus.OK) { - en.Value.ColorIndex = 1; + en.Entity.ColorIndex = 1; app.m_Viewer.m_bNeedUpdate = true; } dyn.Destroy(); console.log('en: ', en); } -} \ No newline at end of file +} diff --git a/src/Add-on/ssget.ts b/src/Add-on/ssget.ts new file mode 100644 index 000000000..6a92334e8 --- /dev/null +++ b/src/Add-on/ssget.ts @@ -0,0 +1,15 @@ +import { Command } from "../Editor/CommandMachine"; +import { app } from "../ApplicationServices/Application"; + + +export class Command_Ssget implements Command +{ + constructor() + { + + } + async exec() + { + let ss = app.m_Editor.GetSelection(); + } +} diff --git a/src/Common/InputState.ts b/src/Common/InputState.ts index 1c87031c1..1ece9fb19 100644 --- a/src/Common/InputState.ts +++ b/src/Common/InputState.ts @@ -3,12 +3,22 @@ import { Vector3 } from 'three'; import { PromptEntityResult } from '../Editor/PromptResult'; + +/** + * 控制器的状态,按位表示. + * + * @export + * @enum {number} + */ export enum InputState { None = 0, - Select = 1, - GetPoint = 2, - Entsel = 4, + SelectIng = 1,//用户正在选择,不一定执行ssget,有可能用户在没有任何命令在选择实体 + Select = 2, //选择服务中,用户执行了ssget + GetPoint = 4, + Entsel = 8, + + All = ~(~0 << 8) } @@ -42,4 +52,9 @@ export interface GetDistendPrompt extends GetAnyPrompt export interface GetEntityPrompt extends GetAnyPrompt { Callback?: (res: PromptEntityResult) => void; -} \ No newline at end of file +} + +export interface SsgetPrompt extends GetAnyPrompt +{ + +} diff --git a/src/Editor/CameraControls.ts b/src/Editor/CameraControls.ts index bd39d6b0f..c0c74bda2 100644 --- a/src/Editor/CameraControls.ts +++ b/src/Editor/CameraControls.ts @@ -185,8 +185,9 @@ export class CameraControls onMouseMove = (event: MouseEvent) => { event.preventDefault(); - let changeVec: THREE.Vector3 = new THREE.Vector3(); - changeVec.set(event.movementX, event.movementY, 0); + this.m_EndClickPoint.set(event.offsetX, event.offsetY, 0); + let changeVec = this.m_EndClickPoint.clone().sub(this.m_StartClickPoint); + this.m_StartClickPoint.copy(this.m_EndClickPoint); if ( (this.m_LeftUseRotate || (this.m_KeyDown.get(KeyBoard.Control)) diff --git a/src/Editor/CommandMachine.ts b/src/Editor/CommandMachine.ts index 4d2443a10..3ffffb9ef 100644 --- a/src/Editor/CommandMachine.ts +++ b/src/Editor/CommandMachine.ts @@ -19,7 +19,7 @@ export class CommandMachine { app.m_Database.hm.StartCmd(cmdName); } - app.m_Editor.m_SelectCtrl.EndSelect(); + app.m_Editor.m_SelectCtrl.RestState(); let ss = app.m_Editor.m_SelectCtrl.SelectSet; //命令执行... diff --git a/src/Editor/CommandRegister.ts b/src/Editor/CommandRegister.ts index 97187fbf5..c3607f974 100644 --- a/src/Editor/CommandRegister.ts +++ b/src/Editor/CommandRegister.ts @@ -33,6 +33,7 @@ import { Command_Trim } from '../Add-on/Trim'; import { Redo, Undo } from '../Add-on/Undo'; import { ViewToFront, ViewToTop } from '../Add-on/ViewChange'; import { commandMachine } from './CommandMachine'; +import { Command_Ssget } from '../Add-on/ssget'; // import { RevTarget, SaveTarget } from '../Add-on/RenderTarget'; export function registerCommand() @@ -105,6 +106,7 @@ export function registerCommand() commandMachine.RegisterCommand("tr", new Command_Trim()); + commandMachine.RegisterCommand("ss", new Command_Ssget()); // commandMachine.RegisterCommand("st", new SaveTarget()) // commandMachine.RegisterCommand("rt", new RevTarget()) diff --git a/src/Editor/Editor.ts b/src/Editor/Editor.ts index 718a04d26..89eaafabd 100644 --- a/src/Editor/Editor.ts +++ b/src/Editor/Editor.ts @@ -1,5 +1,5 @@ -import { Vector3 } from 'three'; import * as THREE from 'three'; +import { Vector3 } from 'three'; import * as xaop from 'xaop'; import { app, ApplicationService } from '../ApplicationServices/Application'; @@ -10,9 +10,10 @@ import { GetEntityServices } from './GetEntityServices'; import { GetDistanceServices, GetPointServices } from './GetPointServices'; import { KeyBoardControls } from './KeyBoardControls'; import { MouseControls } from './MouseControls'; -import { PromptDistendResult, PromptEntityResult, PromptPointResult } from './PromptResult'; +import { PromptDistendResult, PromptEntityResult, PromptPointResult, PromptSsgetResult } from './PromptResult'; import { SelectControls } from './SelectControls'; import { SnapDragServices } from './SnapDragServices'; +import { SsgetServiecs } from './SsgetServices'; import { TransformServicess } from './TranstrolControl/TransformServices'; import { UCSServices } from './UCSServices'; @@ -29,9 +30,11 @@ export class Editor m_CommandStore: CommandStore; m_GetpointServices: GetPointServices; m_GetDistanceServices: GetDistanceServices; + m_GetEntitytServices: GetEntityServices; m_SnapDragServices: SnapDragServices; transCtrl: TransformServicess; ucsServices: UCSServices; + m_SsgetServices: SsgetServiecs; //用户坐标系 private m_UCSMatrix = new THREE.Matrix4(); constructor(app: ApplicationService) @@ -46,6 +49,9 @@ export class Editor this.m_SnapDragServices = new SnapDragServices(this); + this.m_GetEntitytServices = new GetEntityServices(this); + this.m_SsgetServices = new SsgetServiecs(this); + xaop.end(this.m_MouseCtrl, this.m_MouseCtrl.onMouseMove, () => { app.m_Viewer.m_PreViewer.SerCursorPostion(this.m_MouseCtrl.m_CurMousePointVCS); @@ -96,11 +102,11 @@ export class Editor GetEntity(prompt?: GetEntityPrompt): Promise { - return GetEntityServices.Services.Doit(prompt); + return this.m_GetEntitytServices.Start(prompt); } - GetSelection(): Array + async GetSelection(): Promise { - return [] + return this.m_SsgetServices.Start(); } SelectWindow(p1: THREE.Vector3, p2: THREE.Vector3): Array { diff --git a/src/Editor/GetEntityServices.ts b/src/Editor/GetEntityServices.ts index 07bf62f40..346654d0f 100644 --- a/src/Editor/GetEntityServices.ts +++ b/src/Editor/GetEntityServices.ts @@ -1,41 +1,44 @@ import { end } from 'xaop'; -import { app } from '../ApplicationServices/Application'; import { GetEntityPrompt, InputState } from '../Common/InputState'; -import { MouseKey } from '../Common/KeyEnum'; +import { KeyBoard, MouseKey } from '../Common/KeyEnum'; import { Entity } from '../DatabaseServices/Entity'; import { DynamicInputManage } from '../UI/DynamicPrompt/DynamicInputManage'; import { PromptBlock } from '../UI/DynamicPrompt/PromptBlock'; +import { Editor, EditorService } from './Editor'; import { MouseControls } from './MouseControls'; import { PointPick } from './PointPick'; import { PromptEntityResult, PromptStatus } from './PromptResult'; +import { Viewer } from '../GraphicsSystem/Viewer'; -export class GetEntityServices +export class GetEntityServices implements EditorService { - private static services: GetEntityServices; - static get Services() + m_Editor: Editor; + private m_Viewer: Viewer; + constructor(ed: Editor) { - if (!this.services) this.services = new GetEntityServices(); - return this.services; + this.m_Editor = ed; + this.m_Viewer = ed.m_App.m_Viewer; } - + IsReady: boolean = false; private m_promisResolve: (PromptEntityResult) => void; private removeCalls: Function[] = []; - Doit(prompt?: GetEntityPrompt): Promise + + + Start(prompt?: GetEntityPrompt): Promise { + this.IsReady = true; + prompt = prompt || {}; - app.m_Editor.m_InputState = InputState.Entsel; + this.m_Editor.m_InputState &= InputState.Entsel; + //光标变换 - app.m_Viewer.m_PreViewer.ToEntsel(); - app.m_Viewer.m_PreViewer.UpdateScreen(); + this.m_Viewer.m_PreViewer.ToEntsel(); + this.m_Viewer.m_PreViewer.UpdateScreen(); - let mouseCtrl = app.m_Editor.m_MouseCtrl; - //鼠标点击 - this.removeCalls.push( - end(mouseCtrl, mouseCtrl.onMouseDown, (e) => { this.HandleMouseDown(e) }) - ) + let mouseCtrl = this.m_Editor.m_MouseCtrl; //鼠标移动 if (prompt.Callback) { @@ -46,6 +49,22 @@ export class GetEntityServices ) ) } + this.removeCalls.push( + end(this.m_Editor.m_KeyCtrl, this.m_Editor.m_KeyCtrl.OnKeyDown, (e: KeyboardEvent) => + { + switch (e.keyCode as KeyBoard) + { + case KeyBoard.Escape: + { + this.Canel(); + } + case KeyBoard.Space: + { + this.Retun({ Status: PromptStatus.None }) + } + } + }), + ) //动态提示. this.InitDynPrompt(prompt, mouseCtrl); @@ -56,6 +75,29 @@ export class GetEntityServices }); } + Canel() + { + this.Retun({ Status: PromptStatus.Cancel }); + } + + async Doit(e: MouseEvent) + { + switch (e.button as MouseKey) + { + case MouseKey.Left: + { + this.Retun(this.HandleMouseMove()); + break; + } + case MouseKey.Right: + { + this.Retun({ Status: PromptStatus.None }) + break; + } + } + return false; + } + private InitDynPrompt(prompt: GetEntityPrompt, mouseCtrl: MouseControls) { let dyn = new PromptBlock(DynamicInputManage.GetManage()); @@ -67,32 +109,26 @@ export class GetEntityServices })); dyn.SetPostion(mouseCtrl.m_CurMousePointVCS); } - - HandleMouseDown(e: MouseEvent) - { - if (e.button == MouseKey.Left) - { - this._retun(this.HandleMouseMove()); - } - } - HandleMouseMove(): PromptEntityResult + private HandleMouseMove(): PromptEntityResult { - let en = PointPick(app.m_Editor.m_MouseCtrl.m_CurMousePointVCS, app.m_Viewer)[0]; + let en = PointPick(this.m_Editor.m_MouseCtrl.m_CurMousePointVCS, this.m_Viewer)[0]; let ret = new PromptEntityResult(); if (en && en.userData && en.userData instanceof Entity) - ret.Value = en.userData; - ret.Point = app.m_Editor.m_MouseCtrl.m_CurMousePointWCS.clone(); - ret.Status = ret.Value ? PromptStatus.OK : PromptStatus.None; + ret.Entity = en.userData; + ret.Point = this.m_Editor.m_MouseCtrl.m_CurMousePointWCS.clone(); + ret.Status = PromptStatus.OK; return ret; } - - RestState() + //还原状态 + private RestState() { - app.m_Editor.m_InputState = InputState.None; - app.m_Viewer.m_PreViewer.ToSelect(); + this.IsReady = false; + + this.m_Editor.m_InputState &= ~InputState.None; + this.m_Viewer.m_PreViewer.ToSelect(); this.removeCalls.forEach(f => f()); } - private _retun(result: PromptEntityResult) + private Retun(result: PromptEntityResult) { this.RestState(); this.m_promisResolve(result); diff --git a/src/Editor/GetPointServices.ts b/src/Editor/GetPointServices.ts index dda06dab2..66cd4bd77 100644 --- a/src/Editor/GetPointServices.ts +++ b/src/Editor/GetPointServices.ts @@ -31,7 +31,7 @@ export class GetPointServices implements EditorService return false; } - private promisResolve: (PromptPointResult) => void;//promis回调 + private promisResolve: (res: PromptPointResult) => void;//promis回调 protected removeCalls: Function[] = []; //结束回调 public snapServices = new SnapServices(); diff --git a/src/Editor/MouseControls.ts b/src/Editor/MouseControls.ts index e795bbc0e..a9fbf0a61 100644 --- a/src/Editor/MouseControls.ts +++ b/src/Editor/MouseControls.ts @@ -31,7 +31,7 @@ export class MouseControls } onMouseDown = async (e: MouseEvent) => { - for (let s of [app.m_Editor.m_SnapDragServices, app.m_Editor.m_GetpointServices, app.m_Editor.transCtrl, app.m_Editor.m_SelectCtrl]) + for (let s of [app.m_Editor.m_SnapDragServices, app.m_Editor.m_GetEntitytServices, app.m_Editor.m_GetpointServices, app.m_Editor.transCtrl, app.m_Editor.m_SelectCtrl]) { if (s.IsReady) { diff --git a/src/Editor/PromptResult.ts b/src/Editor/PromptResult.ts index 9b2527629..a2888c34a 100644 --- a/src/Editor/PromptResult.ts +++ b/src/Editor/PromptResult.ts @@ -2,6 +2,7 @@ import * as THREE from 'three'; import { Vector3 } from 'three'; import { Entity } from '../DatabaseServices/Entity'; +import { SelectSet } from './SelectSet'; export enum PromptStatus @@ -17,7 +18,7 @@ export class PromptResult { Status: PromptStatus = PromptStatus.None; - StringResult: string; + StringResult?: string; } export class PromptPointResult extends PromptResult @@ -60,7 +61,12 @@ export class PromptDistendResult extends PromptResult export class PromptEntityResult extends PromptResult { //选择到的图形 - Value: Entity; + Entity?: Entity; //点取的点 - Point: Vector3; + Point?: Vector3; +} + +export class PromptSsgetResult extends PromptResult +{ + SelectSet?: SelectSet; } diff --git a/src/Editor/SelectControls.ts b/src/Editor/SelectControls.ts index d5fd4593c..b6f1e3cea 100644 --- a/src/Editor/SelectControls.ts +++ b/src/Editor/SelectControls.ts @@ -18,9 +18,9 @@ export class SelectControls implements EditorService { get IsReady() { - return this.m_Editor.m_InputState <= 1; + return this.m_Editor.m_InputState <= InputState.Select; } - async Doit(e: MouseEvent) + async Doit(e: MouseEvent) { this.onMouseDown(e); return true; @@ -78,60 +78,66 @@ export class SelectControls implements EditorService } onMouseDown(e: MouseEvent) { - if (e.button === MouseKey.Left) + if (e.button === MouseKey.Right) { - if (this.m_Editor.m_InputState <= 1) + this.RestState(); + return; + } + //左键 并且准备好时. + if (e.button !== MouseKey.Left || !this.IsReady) + return; + + this.LeftClick(); + } + + //左键点击 + LeftClick() + { + let pt = this.m_Editor.m_MouseCtrl.m_CurMousePointVCS; + let isRemove = app.m_Editor.m_KeyCtrl.KeyIsDown(KeyBoard.Shift); + //如果还没选择 那么 + if ((this.m_Editor.m_InputState & InputState.SelectIng) === InputState.None) + { + let selectObj = PointPick(pt, this.m_Viewer); + if (selectObj.length > 0) { - let pt = this.m_Editor.m_MouseCtrl.m_CurMousePointVCS; - let isRemove = app.m_Editor.m_KeyCtrl.KeyIsDown(KeyBoard.Shift); - - //如果还没选择 那么 - if (this.m_Editor.m_InputState === InputState.None) - { - let selectObj = PointPick(pt, this.m_Viewer); - if (selectObj.length > 0) - { - let selectData = new SelectPick(this.m_Viewer, pt.clone()); - selectData.m_SelectList.push(selectObj[0]); - if (isRemove) - this.m_SelectSet.RemoveSelect(selectData); - else - this.m_SelectSet.AddSelect(selectData); - this.UpdateView(); - return; - } - this.m_Editor.m_InputState = InputState.Select; - app.m_Viewer.m_PreViewer.ToGetpoint(); - this.m_SelectCss.SetStart(pt.x, pt.y) - this.m_SelectCss.SetEnd(pt.x, pt.y) - this.m_SelectCss.Show(); - } + let selectData = new SelectPick(this.m_Viewer, pt.clone()); + selectData.m_SelectList.push(selectObj[0]); + if (isRemove) + this.m_SelectSet.RemoveSelect(selectData); else - { - this.m_Editor.m_InputState = InputState.None; - app.m_Viewer.m_PreViewer.ToSelect(); - let selectBox = new SelectBox(this.m_Viewer, this.m_SelectCss.start, this.m_SelectCss.end); - - selectBox.m_SelectType = this.m_SelectCss.end.x > this.m_SelectCss.start.x ? SelectType.W : SelectType.C; - - selectBox.Select(); - - if (selectBox.m_SelectList.length > 0) - { - if (isRemove) - this.m_SelectSet.RemoveSelect(selectBox); - else - this.m_SelectSet.AddSelect(selectBox); - this.UpdateView(); - } - this.m_SelectCss.Hide() - } + this.m_SelectSet.AddSelect(selectData); + this.UpdateView(); + return; } + this.m_Editor.m_InputState = InputState.SelectIng; + app.m_Viewer.m_PreViewer.ToGetpoint(); + this.m_SelectCss.SetStart(pt.x, pt.y); + this.m_SelectCss.SetEnd(pt.x, pt.y); + this.m_SelectCss.Show(); + } + else + { + let selectBox = new SelectBox(this.m_Viewer, this.m_SelectCss.start, this.m_SelectCss.end); + selectBox.m_SelectType = this.m_SelectCss.end.x > this.m_SelectCss.start.x ? SelectType.W : SelectType.C; + selectBox.Select(); + if (selectBox.m_SelectList.length > 0) + { + if (isRemove) + this.m_SelectSet.RemoveSelect(selectBox); + else + this.m_SelectSet.AddSelect(selectBox); + this.UpdateView(); + } + this.RestState(); + + this.EndSelectEvent(); } } + onMouseMove() { - if (this.m_Editor.m_InputState === InputState.Select) + if (this.m_Editor.m_InputState === InputState.SelectIng) { let pt = this.m_Editor.m_MouseCtrl.m_CurMousePointVCS; this.m_SelectCss.SetEnd(pt.x, pt.y) @@ -145,7 +151,7 @@ export class SelectControls implements EditorService this.Cancel(); } } - EndSelect() + RestState() { this.m_SelectCss.Hide(); app.m_Viewer.m_PreViewer.ToSelect(); @@ -153,8 +159,20 @@ export class SelectControls implements EditorService } Cancel() { - this.EndSelect(); + this.RestState(); this.m_SelectSet = new SelectSet(); this.UpdateView(); + + this.CanenEvent(); + } + + + EndSelectEvent() + { + + } + CanenEvent() + { + } } diff --git a/src/Editor/SelectPick.ts b/src/Editor/SelectPick.ts index 70ebab07e..103018424 100644 --- a/src/Editor/SelectPick.ts +++ b/src/Editor/SelectPick.ts @@ -12,9 +12,9 @@ import { Vector3 } from 'three'; export class SelectPick extends SelectSetBase { m_PickPoint: Vector3; - constructor(view: Viewer, pt: Vector3) + constructor(view: Viewer, ptVcs: Vector3) { super(view); - this.m_PickPoint = pt.clone(); + this.m_PickPoint = ptVcs.clone(); } } diff --git a/src/Editor/SsgetServices.ts b/src/Editor/SsgetServices.ts new file mode 100644 index 000000000..15c3b2abe --- /dev/null +++ b/src/Editor/SsgetServices.ts @@ -0,0 +1,125 @@ +import { begin, end } from 'xaop'; + +import { InputState, SsgetPrompt } from '../Common/InputState'; +import { KeyBoard, MouseKey } from '../Common/KeyEnum'; +import { RenderType } from '../GraphicsSystem/Enum'; +import { Editor } from './Editor'; +import { PromptSsgetResult, PromptStatus } from './PromptResult'; +import { SelectPick } from './SelectPick'; + +/** + * 提供选择状态的服务. ed.Ssget + * + * @class SsgetServiecs + */ +export class SsgetServiecs +{ + + + m_Editor: Editor; + constructor(ed: Editor) + { + this.m_Editor = ed; + } + + private promisResolve: (res: PromptSsgetResult) => void;//promis回调 + Start(prompt?: SsgetPrompt): Promise + { + this.m_Editor.m_InputState &= InputState.Select; + + return new Promise( + async (res, rej) => + { + this.promisResolve = res; + + while (true) + { + let enRes = await this.m_Editor.GetEntity(); + + if (enRes.Status === PromptStatus.Cancel) //取消.(esc) + { + this.CanelRetun(); + //取消选择 + break; + } + else if (enRes.Status === PromptStatus.None)//结束 (右键),或者(空格). + { + //结束并且确认选择 + this.Return({ Status: PromptStatus.OK, SelectSet: this.m_Editor.m_SelectCtrl.SelectSet }); + break; + } + else if (enRes.Status === PromptStatus.OK)//点击选择 (左键) + { + if (enRes.Entity)//选到了实体 + { + let ssEnt = new SelectPick(this.m_Editor.m_App.m_Viewer, this.m_Editor.m_MouseCtrl.m_CurMousePointVCS); + ssEnt.m_SelectList.push(enRes.Entity.Draw(RenderType.Wireframe)); + + if (this.m_Editor.m_KeyCtrl.KeyIsDown(KeyBoard.Shift)) + this.m_Editor.m_SelectCtrl.SelectSet.RemoveSelect(ssEnt); + else + this.m_Editor.m_SelectCtrl.SelectSet.AddSelect(ssEnt); + + this.m_Editor.m_SelectCtrl.UpdateView(); + } + else//没有选择到实体,触发框选 + { + this.m_Editor.m_SelectCtrl.LeftClick(); + //等待用户选到 + let isOk = await this.AwaitSelect(); + if (!isOk) + { + this.CanelRetun(); + break; + } + } + } + } + } + ); + } + + + //返回取消状态 + private CanelRetun() + { + this.Return({ Status: PromptStatus.Cancel }); + } + + protected Return(res: PromptSsgetResult) + { + if (!this.promisResolve) return; + this.promisResolve(res); + } + + + private m_AwaitRemoveCalls: Function[] = []; + private m_AwaitRes: (state: boolean) => void; + async AwaitSelect(): Promise + { + return new Promise((res, rej) => + { + this.m_AwaitRes = res; + this.m_AwaitRemoveCalls.push( + end(this.m_Editor.m_SelectCtrl, this.m_Editor.m_SelectCtrl.EndSelectEvent, () => + { + this._AwaitSelctReturn(true); + }), + end(this.m_Editor.m_SelectCtrl, this.m_Editor.m_SelectCtrl.CanenEvent, () => + { + this._AwaitSelctReturn(false); + }), + ) + }); + } + private _AwaitSelctReturn(state: boolean) + { + if (!this.m_AwaitRes) return; + this.m_AwaitRemoveCalls.forEach(f => f()); + this.m_AwaitRemoveCalls.length = 0; + this.m_AwaitRes(state); + this.m_AwaitRes = undefined; + } +} + + diff --git a/src/GraphicsSystem/Viewer.ts b/src/GraphicsSystem/Viewer.ts index 97295d01a..c2a431264 100644 --- a/src/GraphicsSystem/Viewer.ts +++ b/src/GraphicsSystem/Viewer.ts @@ -54,6 +54,7 @@ export class Viewer constructor(canvasContainer: HTMLElement) { this.m_DomEl = canvasContainer; + this.m_DomEl.oncontextmenu = () => false;//禁止用户选中画布. TODO: 加入右键工具栏. this.m_GripScene = new GripScene(this.m_Scene); this.m_PreViewer = new PreViewer(canvasContainer); @@ -141,12 +142,12 @@ export class Viewer if (this._Height % 2 == 1) this._Height -= 1; - this.m_PreViewer.OnSize(this.Width, this.Height); - this.m_Render.setSize(this.Width, this.Height); - this.m_Composer.setSize(this.Width, this.Height); - this.m_CameraCtrl.SetSize(this.Width, this.Height); + this.m_PreViewer.OnSize(this._Width, this._Height); + this.m_Render.setSize(this._Width, this._Height); + this.m_Composer.setSize(this._Width, this._Height); + this.m_CameraCtrl.SetSize(this._Width, this._Height); - this.m_effectFXAA.uniforms['resolution'].value.set(1 / this.Width, 1 / this.Height); + this.m_effectFXAA.uniforms['resolution'].value.set(1 / this._Width, 1 / this._Height); this.m_CameraCtrl.Update(); this.m_bNeedUpdate = true; diff --git a/src/UI/DynamicPrompt/DynamicInputManage.ts b/src/UI/DynamicPrompt/DynamicInputManage.ts index 8bdb43d0f..84cc3ae70 100644 --- a/src/UI/DynamicPrompt/DynamicInputManage.ts +++ b/src/UI/DynamicPrompt/DynamicInputManage.ts @@ -52,13 +52,11 @@ export class DynamicInputManage //当用户尝试改变坐标时,可以触发这个更新动态输入 Focus() { - let dyn = this.inputCollection[this.focusIndex]; - if (!dyn) - { - dyn = this.inputCollection[0]; + if (this.focusIndex >= this.inputCollection.length || this.focusIndex < 0) this.focusIndex = 0; - } - dyn.Focus(); + let dyn = this.inputCollection[this.focusIndex]; + if (dyn) + dyn.Focus(); } set FocusIndex(v: number) { diff --git a/src/index.tsx b/src/index.tsx index 32bcabbd8..0e310be1f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -21,4 +21,4 @@ document.onselectstart = () => false window.onload = function () { new WebCAD("app"); -}; \ No newline at end of file +};