修正内存泄漏,提供增量加载.
This commit is contained in:
parent
fcf2a1eb73
commit
c1e9aac48b
2
dist/CameraUpdate.js
vendored
2
dist/CameraUpdate.js
vendored
@ -112,7 +112,7 @@ var CameraUpdate = /** @class */ (function () {
|
||||
this.Update();
|
||||
};
|
||||
CameraUpdate.prototype.ZoomExtensBox3 = function (box3) {
|
||||
if (!box3)
|
||||
if (!box3 || box3.isEmpty())
|
||||
return;
|
||||
this.Camera.updateMatrixWorld(false);
|
||||
//变换到相机坐标系
|
||||
|
2
dist/CameraUpdate.js.map
vendored
2
dist/CameraUpdate.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/Utils.d.ts
vendored
2
dist/Utils.d.ts
vendored
@ -1,2 +1,2 @@
|
||||
import { Viewer } from ".";
|
||||
export declare function LoadBoard(view: Viewer, data: any[]): void;
|
||||
export declare function LoadBoard(view: Viewer, data: any[], clear?: boolean): void;
|
||||
|
22
dist/Utils.js
vendored
22
dist/Utils.js
vendored
@ -1,13 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var _1 = require(".");
|
||||
function LoadBoard(view, data) {
|
||||
view.m_Scene.children.forEach(function (obj) {
|
||||
var geo = obj["geometry"];
|
||||
if (geo)
|
||||
geo.dispose();
|
||||
});
|
||||
view.m_Scene.children.length = 0;
|
||||
function dispose(m) {
|
||||
//@ts-ignore
|
||||
if (m.geometry)
|
||||
//@ts-ignore
|
||||
m.geometry.dispose();
|
||||
m.children.forEach(function (o) { return dispose(o); });
|
||||
}
|
||||
function LoadBoard(view, data, clear) {
|
||||
if (clear === void 0) { clear = true; }
|
||||
if (clear) {
|
||||
dispose(view.m_Scene);
|
||||
view.m_Scene.children.length = 0;
|
||||
}
|
||||
if (data.length === 0)
|
||||
return;
|
||||
//加板
|
||||
var _a = _1.createTemplateBoard(data), meshs = _a.meshs, edgesa = _a.edgesa;
|
||||
//加标注
|
||||
|
2
dist/Utils.js.map
vendored
2
dist/Utils.js.map
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":";;AAAA,sBAA2E;AAG3E,mBAA0B,IAAY,EAAE,IAAW;IAE/C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAA,GAAG;QAE7B,IAAI,GAAG,GAAG,GAAG,CAAC,UAAU,CAAa,CAAC;QACtC,IAAI,GAAG;YAAE,GAAG,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAA;IACF,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IAEjC,IAAI;IACA,IAAA,iCAA6C,EAA3C,gBAAK,EAAE,kBAAM,CAA+B;IAClD,KAAK;IACL,IAAI,IAAI,GAAG,gBAAa,CAAC,KAAK,CAAC,CAAC;IAEhC,CAAA,KAAA,IAAI,CAAC,OAAO,CAAA,CAAC,GAAG,WAAI,KAAK,EAAE;IAC3B,CAAA,KAAA,IAAI,CAAC,OAAO,CAAA,CAAC,GAAG,WAAI,MAAM,EAAE;IAC5B,CAAA,KAAA,IAAI,CAAC,OAAO,CAAA,CAAC,GAAG,WAAI,IAAI,EAAE;IAE1B,IAAI,CAAC,WAAW,EAAE,CAAC;IACnB,IAAI,CAAC,OAAO,EAAE,CAAC;IACf,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;;AACnB,CAAC;AArBD,8BAqBC"}
|
||||
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":";;AACA,sBAA+D;AAE/D,iBAAiB,CAAW;IAExB,YAAY;IACZ,IAAI,CAAC,CAAC,QAAQ;QACV,YAAY;QACZ,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;IAEzB,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,OAAO,CAAC,CAAC,CAAC,EAAV,CAAU,CAAC,CAAC;AACxC,CAAC;AAED,mBAA0B,IAAY,EAAE,IAAW,EAAE,KAAqB;IAArB,sBAAA,EAAA,YAAqB;IAEtE,IAAI,KAAK,EACT;QACI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;KACpC;IAED,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAC9B,IAAI;IACA,IAAA,iCAA6C,EAA3C,gBAAK,EAAE,kBAAM,CAA+B;IAClD,KAAK;IACL,IAAI,IAAI,GAAG,gBAAa,CAAC,KAAK,CAAC,CAAC;IAEhC,CAAA,KAAA,IAAI,CAAC,OAAO,CAAA,CAAC,GAAG,WAAI,KAAK,EAAE;IAC3B,CAAA,KAAA,IAAI,CAAC,OAAO,CAAA,CAAC,GAAG,WAAI,MAAM,EAAE;IAC5B,CAAA,KAAA,IAAI,CAAC,OAAO,CAAA,CAAC,GAAG,WAAI,IAAI,EAAE;IAE1B,IAAI,CAAC,WAAW,EAAE,CAAC;IACnB,IAAI,CAAC,OAAO,EAAE,CAAC;IACf,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;;AACnB,CAAC;AArBD,8BAqBC"}
|
4
dist/createBoard.js
vendored
4
dist/createBoard.js
vendored
@ -65,8 +65,8 @@ function getVec(data) {
|
||||
exports.getVec = getVec;
|
||||
//创建板件 暂时这么写
|
||||
function createBoard(boardData) {
|
||||
var pts = new Array();
|
||||
var buls = new Array();
|
||||
var pts = [];
|
||||
var buls = [];
|
||||
var boardPts = boardData["Pts"];
|
||||
var boardBuls = boardData["Buls"];
|
||||
var boardHeight = boardData["H"];
|
||||
|
2
dist/createBoard.js.map
vendored
2
dist/createBoard.js.map
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cadview",
|
||||
"version": "1.1.7",
|
||||
"version": "1.1.8",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
@ -134,7 +134,7 @@ export class CameraUpdate
|
||||
}
|
||||
ZoomExtensBox3(box3: THREE.Box3)
|
||||
{
|
||||
if (!box3) return;
|
||||
if (!box3 || box3.isEmpty()) return;
|
||||
this.Camera.updateMatrixWorld(false);
|
||||
//变换到相机坐标系
|
||||
box3.applyMatrix4(this.Camera.matrixWorldInverse);
|
||||
|
28
src/Utils.ts
28
src/Utils.ts
@ -1,15 +1,25 @@
|
||||
import { Viewer, createTemplateBoard, createEdge, DrawDimension } from ".";
|
||||
import { Geometry } from "three";
|
||||
import { Object3D } from "three";
|
||||
import { createTemplateBoard, DrawDimension, Viewer } from ".";
|
||||
|
||||
export function LoadBoard(view: Viewer, data: any[])
|
||||
function dispose(m: Object3D)
|
||||
{
|
||||
view.m_Scene.children.forEach(obj =>
|
||||
{
|
||||
let geo = obj["geometry"] as Geometry;
|
||||
if (geo) geo.dispose();
|
||||
})
|
||||
view.m_Scene.children.length = 0;
|
||||
//@ts-ignore
|
||||
if (m.geometry)
|
||||
//@ts-ignore
|
||||
m.geometry.dispose();
|
||||
|
||||
m.children.forEach(o => dispose(o));
|
||||
}
|
||||
|
||||
export function LoadBoard(view: Viewer, data: any[], clear: boolean = true)
|
||||
{
|
||||
if (clear)
|
||||
{
|
||||
dispose(view.m_Scene);
|
||||
view.m_Scene.children.length = 0;
|
||||
}
|
||||
|
||||
if (data.length === 0) return;
|
||||
//加板
|
||||
let { meshs, edgesa } = createTemplateBoard(data);
|
||||
//加标注
|
||||
|
@ -80,8 +80,8 @@ export function getVec(data: object): THREE.Vector3
|
||||
//创建板件 暂时这么写
|
||||
export function createBoard(boardData: object)
|
||||
{
|
||||
let pts: THREE.Vector2[] = new Array();
|
||||
let buls: number[] = new Array();
|
||||
let pts: THREE.Vector2[] = [];
|
||||
let buls: number[] = [];
|
||||
let boardPts = boardData["Pts"];
|
||||
let boardBuls = boardData["Buls"];
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user