优化:提高首次开图使用二维线框模式下的首次单选板件性能

pull/803/head
ChenX 5 years ago
parent 744c901cf4
commit f34f4e2f2b

@ -1,7 +1,7 @@
import { Intersection, Object3D, Raycaster, Vector3 } from "three";
import { begin, end } from "xaop";
import { app } from "../ApplicationServices/Application";
import { arrayLast } from "../Common/ArrayExt";
import { Sleep } from "../Common/Sleep";
import { FixedNotZero, GetEntity } from "../Common/Utils";
import { CommandHistoryRecord } from "../DatabaseServices/CommandHistoryRecord";
import { AlignedDimension } from "../DatabaseServices/Dimension/AlignedDimension";
@ -87,8 +87,9 @@ export class BoardMoveTool
app.Viewer.PreViewer.UpdateScreen();
}
private HitBoard(br: Board)
private async HitBoard(br: Board)
{
await Sleep(1);
let brOCS = br.OCS;
let brRot = brOCS.clone().setPosition(0, 0, 0);
let brOCSInv = br.OCSInv;
@ -96,10 +97,27 @@ export class BoardMoveTool
let brNormal2 = brNormal.clone().negate();
let brsObject: Object3D[] = [];
let start = performance.now();
let i = 0;
for (let obj of app.Viewer.Scene.children)
{
if (obj.visible)
{
i++;
if (i > 50)
{
let now = performance.now();
let r = now - start;
if (now - start > 15)
{
await Sleep(1);
start = now;
}
else
{
i -= (16 - r) * 3;
}
}
let ent = GetEntity(obj);
if (ent instanceof Board && ent !== br)
{

@ -9,6 +9,7 @@ import { IsDev } from '../Common/Deving';
import { Sleep } from '../Common/Sleep';
import { GetEntity } from '../Common/Utils';
import { Database } from '../DatabaseServices/Database';
import { Board } from '../DatabaseServices/Entity/Board';
import { Entity } from '../DatabaseServices/Entity/Entity';
import { GenerateRaycaster } from '../Editor/PointPick';
import { userConfig } from '../Editor/UserConfig';
@ -415,9 +416,12 @@ export class Viewer
let i = 0;
let down = DownPanelStore.GetInstance() as DownPanelStore;
down.progress = 0.1;
let brs: Board[] = [];
for (let index = 0; index < db.ModelSpace.Entitys.length; index++)
{
let en = db.ModelSpace.Entitys[index];
if (userConfig.RenderType === RenderType.Wireframe && en instanceof Board)
brs.push(en);
this._Scene.add(en.DrawObject);
i++;
if (i === 50)
@ -432,6 +436,18 @@ export class Viewer
for (let l of db.Lights.Entitys)
this._Scene.add(l.DrawObject);
this.UpdateRender();
//预构建板件
i = 0;
for (let br of brs)
{
br.GetDrawObjectFromRenderType(RenderType.Physical);
if (i === 30)
{
await Sleep(1);
i = 0;
}
}
};
//灯光
for (let l of db.Lights.Entitys)

Loading…
Cancel
Save