优化异步更新和更新渲染

pull/799/MERGE
ChenX 5 years ago
parent c5043e1c8c
commit 4e1587a244

@ -1,4 +1,4 @@
import { Matrix4, Vector3 } from 'three'; import { Matrix4, Object3D, Vector3 } from 'three';
import { begin, end } from 'xaop'; import { begin, end } from 'xaop';
import { AutoCuttingReactor } from '../Add-on/BoardCutting/AutoCuttingReactor'; import { AutoCuttingReactor } from '../Add-on/BoardCutting/AutoCuttingReactor';
import { DrillingReactor } from '../Add-on/DrawDrilling/DrillingReactor'; import { DrillingReactor } from '../Add-on/DrawDrilling/DrillingReactor';
@ -19,10 +19,10 @@ import { SelectSetBase } from '../Editor/SelectBase';
import { ShowSnapMenu } from '../Editor/ShowSnapMenu'; import { ShowSnapMenu } from '../Editor/ShowSnapMenu';
import { Viewer } from '../GraphicsSystem/Viewer'; import { Viewer } from '../GraphicsSystem/Viewer';
import { CommandReactor } from '../Reactor/CommandReactor'; import { CommandReactor } from '../Reactor/CommandReactor';
import { SyncDataReactor } from '../Reactor/SyncDataReactor';
import { DownPanelStore } from '../UI/Store/DownPanelStore'; import { DownPanelStore } from '../UI/Store/DownPanelStore';
import { HostApplicationServices } from './HostApplicationServices'; import { HostApplicationServices } from './HostApplicationServices';
import { WebSocketClientServer } from './WebSocketClientServer'; import { WebSocketClientServer } from './WebSocketClientServer';
import { SyncDataReactor } from '../Reactor/SyncDataReactor';
export let app: ApplicationService; export let app: ApplicationService;
/** /**
@ -53,9 +53,34 @@ export class ApplicationService
this.Viewer = new Viewer(container); this.Viewer = new Viewer(container);
this.Viewer.RenderDatabase(this.Database); this.Viewer.RenderDatabase(this.Database);
end((new Entity()).AsyncUpdated, () => function Root(o: Object3D): Object3D
{ {
this.Viewer.UpdateRender(); while (o.parent)
{
o = o.parent;
}
return o;
}
end((new Entity()).AsyncUpdated, function ()
{
let e = this as Entity;
if (e instanceof Entity && e._drawObject)
{
let r = Root(e._drawObject);
if (r === app.Viewer.Scene)
{
app.Viewer.UpdateRender();
}
else if (r === app.Viewer.PreViewer.Scene)
{
app.Viewer.PreViewer.UpdateScreen();
}
}
else
{
//材质更新
app.Viewer.UpdateRender();
}
}); });
//性能测试 //性能测试

@ -348,7 +348,6 @@ export class AlignedDimension extends Entity
this.UpdateText(textPos as Vector3); this.UpdateText(textPos as Vector3);
obj.add(this._LeadOutLine, this._Text.DrawObject); obj.add(this._LeadOutLine, this._Text.DrawObject);
this.AsyncUpdated();
this.isDragLeadOutPt = false; this.isDragLeadOutPt = false;
} }

@ -235,7 +235,7 @@ export class Entity extends CADObject
this._CacheDrawObject.set(RenderType.Jig, jig); this._CacheDrawObject.set(RenderType.Jig, jig);
} }
protected _drawObject: Object3D; _drawObject: Object3D;
get DrawObject() get DrawObject()
{ {

@ -1,16 +1,16 @@
import React from "react"; import { Button, Card, Classes, Intent, NumericInput, Position, Slider, Tooltip } from "@blueprintjs/core";
import { Card, Classes, Button, Slider, NumericInput, Position, Intent, Tooltip } from "@blueprintjs/core";
import { app } from "../../../ApplicationServices/Application";
import { KeyBoard, KeyCode } from "../../../Common/KeyEnum";
import { safeEval } from "../../../Common/eval";
import { AlignedDimension } from "../../../DatabaseServices/Dimension/AlignedDimension";
import { observable } from "mobx"; import { observable } from "mobx";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import { PropertiesStore } from "./PropertiesStore"; import React from "react";
import { end, begin } from "xaop";
import { Object3D } from "three"; import { Object3D } from "three";
import { end } from "xaop";
import { app } from "../../../ApplicationServices/Application";
import { safeEval } from "../../../Common/eval";
import { KeyBoard, KeyCode } from "../../../Common/KeyEnum";
import { digitStrReg } from "../../../Common/Utils"; import { digitStrReg } from "../../../Common/Utils";
import { AlignedDimension } from "../../../DatabaseServices/Dimension/AlignedDimension";
import { CommandWrap } from "../../../Editor/CommandMachine"; import { CommandWrap } from "../../../Editor/CommandMachine";
import { PropertiesStore } from "./PropertiesStore";
export interface Properties_DimPanelProps export interface Properties_DimPanelProps
{ {
ents: AlignedDimension[]; ents: AlignedDimension[];
@ -40,13 +40,6 @@ export class Properties_DimPanel extends React.Component<Properties_DimPanelProp
{ {
this.outlineCheckDims = true; this.outlineCheckDims = true;
}), }),
begin((new AlignedDimension()).AsyncUpdated, () =>
{
for (let al of this.props.ents)
{
app.Viewer.GripScene.Update(al.DrawObject);
}
}),
end(app.Editor.KeyCtrl, app.Editor.KeyCtrl.OnKeyUp, (e: KeyboardEvent) => end(app.Editor.KeyCtrl, app.Editor.KeyCtrl.OnKeyUp, (e: KeyboardEvent) =>
{ {
if (app.Editor.KeyCtrl.KeyIsDown(KeyCode.ControlLeft)) if (app.Editor.KeyCtrl.KeyIsDown(KeyCode.ControlLeft))

Loading…
Cancel
Save