viral-viewer-2 2.2.7 → 2.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/worker/viral-viewer-2.worker.js +2 -2
- package/dist/components/worker/viral-viewer-2.worker.js.map +1 -1
- package/dist/components/worker-script/threejs.types.d.ts +1 -0
- package/dist/components/worker-script/threejs.types.js +99 -335
- package/dist/components/worker-script/threejs.types.js.map +1 -1
- package/dist/viral-viewer-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ViralViewerWorker2 = void 0;
|
|
4
4
|
const three_1 = require("three");
|
|
5
|
-
const
|
|
5
|
+
const threejs_types_1 = require("../worker-script/threejs.types");
|
|
6
6
|
const dictionary_model_1 = require("../../models/dictionary.model");
|
|
7
7
|
const worker_pool_1 = require("./worker-pool");
|
|
8
8
|
class ViralViewerWorker2 {
|
|
@@ -12,7 +12,7 @@ class ViralViewerWorker2 {
|
|
|
12
12
|
this.mainModel = null;
|
|
13
13
|
this.threejsMaterials = new dictionary_model_1.Dictionary();
|
|
14
14
|
// Create a new Blob containing the worker code
|
|
15
|
-
const blob = new Blob([`(${
|
|
15
|
+
const blob = new Blob([`(${threejs_types_1.workerCode})()`]);
|
|
16
16
|
const workerPath = URL.createObjectURL(blob);
|
|
17
17
|
// Create a new Worker from the Blob
|
|
18
18
|
this.workerPool = new worker_pool_1.WorkerThreadPool(4, workerPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viral-viewer-2.worker.js","sourceRoot":"","sources":["../../../src/components/worker/viral-viewer-2.worker.ts"],"names":[],"mappings":";;;AAEA,iCAA0I;AAC1I,
|
|
1
|
+
{"version":3,"file":"viral-viewer-2.worker.js","sourceRoot":"","sources":["../../../src/components/worker/viral-viewer-2.worker.ts"],"names":[],"mappings":";;;AAEA,iCAA0I;AAC1I,kEAA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C/B,IAAI,IAAI,CAAC,SAAS;wBACd,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;oBAClC,iBAAiB,EAAE,CAAC;oBACpB,MAAM;gBACV;oBACI,MAAM;aACb;QACL,CAAC,CAAC,CAAA;IACN,CAAC;IACM,QAAQ,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;QAC3C,OAAO,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAC1F,CAAC;IACM,cAAc,CAAC,CAAS;QAC3B,IAAI,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACzB,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAC7C,CAAC;CACJ;AApGD,gDAoGC"}
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Matrix4 = exports.Vector3 = void 0;
|
|
12
|
+
exports.workerCode = exports.Matrix4 = exports.Vector3 = void 0;
|
|
13
13
|
class FlatMesh {
|
|
14
14
|
constructor(serializer, flatMesh) {
|
|
15
15
|
this.expressID = flatMesh.expressID;
|
|
@@ -72121,346 +72121,110 @@ function mergeBufferAttributes(attributes) {
|
|
|
72121
72121
|
}
|
|
72122
72122
|
return new BufferAttribute(array, itemSize, normalized);
|
|
72123
72123
|
}
|
|
72124
|
-
|
|
72125
|
-
|
|
72126
|
-
|
|
72127
|
-
|
|
72128
|
-
|
|
72129
|
-
|
|
72130
|
-
|
|
72131
|
-
|
|
72132
|
-
|
|
72133
|
-
|
|
72134
|
-
|
|
72135
|
-
|
|
72136
|
-
|
|
72137
|
-
|
|
72138
|
-
|
|
72139
|
-
|
|
72140
|
-
|
|
72141
|
-
|
|
72142
|
-
|
|
72143
|
-
|
|
72144
|
-
|
|
72145
|
-
|
|
72146
|
-
|
|
72147
|
-
|
|
72148
|
-
|
|
72149
|
-
|
|
72150
|
-
|
|
72151
|
-
|
|
72152
|
-
|
|
72153
|
-
|
|
72154
|
-
|
|
72155
|
-
|
|
72156
|
-
|
|
72157
|
-
|
|
72158
|
-
|
|
72159
|
-
|
|
72160
|
-
|
|
72161
|
-
|
|
72162
|
-
|
|
72163
|
-
|
|
72164
|
-
|
|
72165
|
-
|
|
72166
|
-
|
|
72167
|
-
|
|
72168
|
-
|
|
72169
|
-
|
|
72170
|
-
|
|
72171
|
-
|
|
72172
|
-
|
|
72173
|
-
|
|
72174
|
-
|
|
72175
|
-
|
|
72176
|
-
|
|
72177
|
-
|
|
72178
|
-
|
|
72179
|
-
|
|
72180
|
-
|
|
72181
|
-
|
|
72182
|
-
|
|
72183
|
-
|
|
72184
|
-
|
|
72185
|
-
|
|
72186
|
-
this.notifyLoadingEnded();
|
|
72187
|
-
const geometries = [];
|
|
72188
|
-
const materials = [];
|
|
72189
|
-
Object.keys(this.geometriesByMaterials).forEach((key) => {
|
|
72190
|
-
const geometriesByMaterial = this.geometriesByMaterials[key].geometries;
|
|
72191
|
-
const merged = mergeBufferGeometries(geometriesByMaterial);
|
|
72192
|
-
materials.push(this.geometriesByMaterials[key].material);
|
|
72193
|
-
geometries.push(merged);
|
|
72194
|
-
});
|
|
72195
|
-
const combinedGeometry = mergeBufferGeometries(geometries, true);
|
|
72196
|
-
this.cleanUpGeometryMemory(geometries);
|
|
72197
|
-
if (this.BVH)
|
|
72198
|
-
this.BVH.applyThreeMeshBVH(combinedGeometry);
|
|
72199
|
-
const model = new IFCModel(combinedGeometry, materials);
|
|
72200
|
-
this.state.models[this.currentModelID].mesh = model;
|
|
72201
|
-
return model;
|
|
72202
|
-
});
|
|
72203
|
-
}
|
|
72204
|
-
initializeLoadingState(modelID) {
|
|
72205
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72206
|
-
const shapes = yield this.state.api.GetLineIDsWithType(modelID, IFCPRODUCTDEFINITIONSHAPE);
|
|
72207
|
-
this.loadingState.total = shapes.size();
|
|
72208
|
-
this.loadingState.current = 0;
|
|
72209
|
-
this.loadingState.step = 0.1;
|
|
72210
|
-
});
|
|
72211
|
-
}
|
|
72212
|
-
notifyLoadingEnded() {
|
|
72213
|
-
this.notifyProgress(this.loadingState.total, this.loadingState.total);
|
|
72214
|
-
}
|
|
72215
|
-
updateLoadingState() {
|
|
72216
|
-
const realCurrentItem = Math.min(this.loadingState.current++, this.loadingState.total);
|
|
72217
|
-
if (realCurrentItem / this.loadingState.total >= this.loadingState.step) {
|
|
72218
|
-
const currentProgress = Math.ceil(this.loadingState.total * this.loadingState.step);
|
|
72219
|
-
this.notifyProgress(currentProgress, this.loadingState.total);
|
|
72220
|
-
this.loadingState.step += 0.1;
|
|
72221
|
-
}
|
|
72222
|
-
}
|
|
72223
|
-
addOptionalCategories(modelID) {
|
|
72224
|
-
const optionalTypes = [];
|
|
72225
|
-
for (let key in this.optionalCategories) {
|
|
72226
|
-
if (this.optionalCategories.hasOwnProperty(key)) {
|
|
72227
|
-
const category = parseInt(key);
|
|
72228
|
-
if (this.optionalCategories[category])
|
|
72229
|
-
optionalTypes.push(category);
|
|
72230
|
-
}
|
|
72231
|
-
}
|
|
72232
|
-
this.state.api.StreamAllMeshesWithTypes(this.currentWebIfcID, optionalTypes, (mesh) => {
|
|
72233
|
-
this.streamMesh(modelID, mesh);
|
|
72234
|
-
});
|
|
72235
|
-
}
|
|
72236
|
-
streamMesh(modelID, mesh) {
|
|
72237
|
-
const placedGeometries = mesh.geometries;
|
|
72238
|
-
const size = placedGeometries.size();
|
|
72239
|
-
for (let i = 0; i < size; i++) {
|
|
72240
|
-
const placedGeometry = placedGeometries.get(i);
|
|
72241
|
-
let itemMesh = this.getPlacedGeometry(modelID, mesh.expressID, placedGeometry);
|
|
72242
|
-
let geom = itemMesh.geometry.applyMatrix4(itemMesh.matrix);
|
|
72243
|
-
this.storeGeometryByMaterial(placedGeometry.color, geom);
|
|
72244
|
-
}
|
|
72245
|
-
}
|
|
72246
|
-
getPlacedGeometry(modelID, expressID, placedGeometry) {
|
|
72247
|
-
const geometry = this.getBufferGeometry(modelID, expressID, placedGeometry);
|
|
72248
|
-
const mesh = new Mesh(geometry);
|
|
72249
|
-
mesh.matrix = this.getMeshMatrix(placedGeometry.flatTransformation);
|
|
72250
|
-
mesh.matrixAutoUpdate = false;
|
|
72251
|
-
return mesh;
|
|
72252
|
-
}
|
|
72253
|
-
getBufferGeometry(modelID, expressID, placedGeometry) {
|
|
72254
|
-
const geometry = this.state.api.GetGeometry(modelID, placedGeometry.geometryExpressID);
|
|
72255
|
-
const verts = this.state.api.GetVertexArray(geometry.GetVertexData(), geometry.GetVertexDataSize());
|
|
72256
|
-
const indices = this.state.api.GetIndexArray(geometry.GetIndexData(), geometry.GetIndexDataSize());
|
|
72257
|
-
const buffer = this.ifcGeometryToBuffer(expressID, verts, indices);
|
|
72258
|
-
geometry.delete();
|
|
72259
|
-
return buffer;
|
|
72260
|
-
}
|
|
72261
|
-
storeGeometryByMaterial(color, geometry) {
|
|
72262
|
-
let colID = `${color.x}${color.y}${color.z}${color.w}`;
|
|
72263
|
-
if (this.geometriesByMaterials[colID]) {
|
|
72264
|
-
this.geometriesByMaterials[colID].geometries.push(geometry);
|
|
72265
|
-
return;
|
|
72266
|
-
}
|
|
72267
|
-
const col = new Color(color.x, color.y, color.z);
|
|
72268
|
-
const material = new MeshLambertMaterial({ color: col, side: DoubleSide });
|
|
72269
|
-
material.transparent = color.w !== 1;
|
|
72270
|
-
if (material.transparent)
|
|
72271
|
-
material.opacity = color.w;
|
|
72272
|
-
this.geometriesByMaterials[colID] = { material, geometries: [geometry] };
|
|
72273
|
-
}
|
|
72274
|
-
getMeshMatrix(matrix) {
|
|
72275
|
-
const mat = new Matrix4();
|
|
72276
|
-
mat.fromArray(matrix);
|
|
72277
|
-
return mat;
|
|
72278
|
-
}
|
|
72279
|
-
ifcGeometryToBuffer(expressID, vertexData, indexData) {
|
|
72280
|
-
const geometry = new BufferGeometry();
|
|
72281
|
-
const posFloats = new Float32Array(vertexData.length / 2);
|
|
72282
|
-
const normFloats = new Float32Array(vertexData.length / 2);
|
|
72283
|
-
const idAttribute = new Uint32Array(vertexData.length / 6);
|
|
72284
|
-
for (let i = 0; i < vertexData.length; i += 6) {
|
|
72285
|
-
posFloats[i / 2] = vertexData[i];
|
|
72286
|
-
posFloats[i / 2 + 1] = vertexData[i + 1];
|
|
72287
|
-
posFloats[i / 2 + 2] = vertexData[i + 2];
|
|
72288
|
-
normFloats[i / 2] = vertexData[i + 3];
|
|
72289
|
-
normFloats[i / 2 + 1] = vertexData[i + 4];
|
|
72290
|
-
normFloats[i / 2 + 2] = vertexData[i + 5];
|
|
72291
|
-
idAttribute[i / 6] = expressID;
|
|
72292
|
-
}
|
|
72293
|
-
geometry.setAttribute('position', new BufferAttribute(posFloats, 3));
|
|
72294
|
-
geometry.setAttribute('normal', new BufferAttribute(normFloats, 3));
|
|
72295
|
-
geometry.setAttribute('expressID', new BufferAttribute(idAttribute, 1));
|
|
72296
|
-
geometry.setIndex(new BufferAttribute(indexData, 1));
|
|
72297
|
-
return geometry;
|
|
72298
|
-
}
|
|
72299
|
-
cleanUpGeometryMemory(geometries) {
|
|
72300
|
-
geometries.forEach(geometry => geometry.dispose());
|
|
72301
|
-
Object.keys(this.geometriesByMaterials).forEach((materialID) => {
|
|
72302
|
-
const geometriesByMaterial = this.geometriesByMaterials[materialID];
|
|
72303
|
-
geometriesByMaterial.geometries.forEach(geometry => geometry.dispose());
|
|
72304
|
-
geometriesByMaterial.geometries = [];
|
|
72305
|
-
geometriesByMaterial.material = null;
|
|
72306
|
-
});
|
|
72307
|
-
this.geometriesByMaterials = {};
|
|
72308
|
-
}
|
|
72309
|
-
}
|
|
72310
|
-
var DBOperation;
|
|
72311
|
-
(function (DBOperation) {
|
|
72312
|
-
DBOperation[DBOperation["transferIfcModel"] = 0] = "transferIfcModel";
|
|
72313
|
-
DBOperation[DBOperation["transferIndividualItems"] = 1] = "transferIndividualItems";
|
|
72314
|
-
})(DBOperation || (DBOperation = {}));
|
|
72315
|
-
class IndexedDatabase {
|
|
72316
|
-
save(item, id) {
|
|
72317
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72318
|
-
const open = IndexedDatabase.openOrCreateDB(id);
|
|
72319
|
-
this.createSchema(open, id);
|
|
72320
|
-
return new Promise((resolve, reject) => {
|
|
72321
|
-
open.onsuccess = () => this.saveItem(item, open, id, resolve);
|
|
72322
|
-
});
|
|
72124
|
+
function workerFunction() {
|
|
72125
|
+
function addCustomMesh3(indices, vertices, material, callback = (buffer, colorString, opacity) => { }) {
|
|
72126
|
+
let verticePoints = [];
|
|
72127
|
+
for (let i = 0; i < indices.length; i++) {
|
|
72128
|
+
const index = indices[i];
|
|
72129
|
+
const point = vertices[index];
|
|
72130
|
+
verticePoints.push(-point.X);
|
|
72131
|
+
verticePoints.push(point.Z);
|
|
72132
|
+
verticePoints.push(point.Y);
|
|
72133
|
+
}
|
|
72134
|
+
const buffer = new Float32Array(verticePoints);
|
|
72135
|
+
let colorString = rgbToHex(material.Red, material.Green, material.Blue);
|
|
72136
|
+
callback(buffer, colorString, material.Opacity);
|
|
72137
|
+
}
|
|
72138
|
+
function addCustomMesh4(indices, vertices, material, instances, callback = (buffer, colorString, opacity) => { }) {
|
|
72139
|
+
let colorString = rgbToHex(material.Red, material.Green, material.Blue);
|
|
72140
|
+
let finalVerticePoints = [];
|
|
72141
|
+
for (let index = 0; index < instances.length; index++) {
|
|
72142
|
+
const instance = instances[index];
|
|
72143
|
+
let numbers = [
|
|
72144
|
+
instance.BasisX.X,
|
|
72145
|
+
-instance.BasisX.Z,
|
|
72146
|
+
-instance.BasisX.Y,
|
|
72147
|
+
0,
|
|
72148
|
+
-instance.BasisZ.X,
|
|
72149
|
+
instance.BasisZ.Z,
|
|
72150
|
+
instance.BasisZ.Y,
|
|
72151
|
+
0,
|
|
72152
|
+
-instance.BasisY.X,
|
|
72153
|
+
instance.BasisY.Z,
|
|
72154
|
+
instance.BasisY.Y,
|
|
72155
|
+
0,
|
|
72156
|
+
-instance.Offset.X,
|
|
72157
|
+
instance.Offset.Z,
|
|
72158
|
+
instance.Offset.Y,
|
|
72159
|
+
1,
|
|
72160
|
+
];
|
|
72161
|
+
let matrix4 = new Matrix4();
|
|
72162
|
+
matrix4.fromArray(numbers);
|
|
72163
|
+
let newVertices = [];
|
|
72164
|
+
for (let i = 0; i < vertices.length; i++) {
|
|
72165
|
+
const point = vertices[i];
|
|
72166
|
+
const point2 = new Vector3(-point.X, point.Z, point.Y);
|
|
72167
|
+
point2.applyMatrix4(matrix4);
|
|
72168
|
+
newVertices.push(point2);
|
|
72169
|
+
}
|
|
72170
|
+
let verticePoints = [];
|
|
72171
|
+
for (let i = 0; i < indices.length; i++) {
|
|
72172
|
+
const index = indices[i];
|
|
72173
|
+
const point = newVertices[index];
|
|
72174
|
+
verticePoints.push(point.x);
|
|
72175
|
+
verticePoints.push(point.y);
|
|
72176
|
+
verticePoints.push(point.z);
|
|
72177
|
+
}
|
|
72178
|
+
finalVerticePoints = finalVerticePoints.concat(verticePoints);
|
|
72179
|
+
}
|
|
72180
|
+
const buffer = new Float32Array(finalVerticePoints);
|
|
72181
|
+
callback(buffer, colorString, material.Opacity);
|
|
72182
|
+
}
|
|
72183
|
+
function progressStructuralGeometries(materials, json, callback = (buffer, colorString, opacity) => { }) {
|
|
72184
|
+
addCustomMesh3(json.Indices, json.Vertices, materials[json.MaterialIndex], (buffer, colorString, opacity) => {
|
|
72185
|
+
callback(buffer, colorString, opacity);
|
|
72323
72186
|
});
|
|
72324
72187
|
}
|
|
72325
|
-
|
|
72326
|
-
|
|
72327
|
-
|
|
72328
|
-
return new Promise((resolve, reject) => {
|
|
72329
|
-
open.onsuccess = () => this.loadItem(open, id, resolve);
|
|
72330
|
-
});
|
|
72188
|
+
function progressNoneStructuralGeometries(materials, json, callback = (buffer, colorString, opacity) => { }) {
|
|
72189
|
+
addCustomMesh4(json.Indices, json.Vertices, materials[json.MaterialIndex], json.Instances, (buffer, colorString, opacity) => {
|
|
72190
|
+
callback(buffer, colorString, opacity);
|
|
72331
72191
|
});
|
|
72332
72192
|
}
|
|
72333
|
-
|
|
72334
|
-
|
|
72335
|
-
const db = open.result;
|
|
72336
|
-
db.createObjectStore(id.toString(), { keyPath: "id" });
|
|
72337
|
-
};
|
|
72338
|
-
}
|
|
72339
|
-
saveItem(item, open, id, resolve) {
|
|
72340
|
-
const { db, tx, store } = IndexedDatabase.getDBItems(open, id);
|
|
72341
|
-
item.id = id;
|
|
72342
|
-
store.put(item);
|
|
72343
|
-
tx.oncomplete = () => IndexedDatabase.closeDB(db, tx, resolve);
|
|
72344
|
-
}
|
|
72345
|
-
loadItem(open, id, resolve) {
|
|
72346
|
-
const { db, tx, store } = IndexedDatabase.getDBItems(open, id);
|
|
72347
|
-
const item = store.get(id);
|
|
72348
|
-
const callback = () => {
|
|
72349
|
-
delete item.result.id;
|
|
72350
|
-
resolve(item.result);
|
|
72351
|
-
};
|
|
72352
|
-
tx.oncomplete = () => IndexedDatabase.closeDB(db, tx, callback);
|
|
72353
|
-
}
|
|
72354
|
-
static getDBItems(open, id) {
|
|
72355
|
-
const db = open.result;
|
|
72356
|
-
const tx = db.transaction(id.toString(), "readwrite");
|
|
72357
|
-
const store = tx.objectStore(id.toString());
|
|
72358
|
-
return { db, tx, store };
|
|
72193
|
+
function rgbToHex(r, g, b) {
|
|
72194
|
+
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
|
|
72359
72195
|
}
|
|
72360
|
-
|
|
72361
|
-
|
|
72196
|
+
function componentToHex(c) {
|
|
72197
|
+
var hex = c.toString(16);
|
|
72198
|
+
return hex.length == 1 ? "0" + hex : hex;
|
|
72362
72199
|
}
|
|
72363
|
-
|
|
72364
|
-
|
|
72365
|
-
|
|
72366
|
-
|
|
72367
|
-
|
|
72368
|
-
|
|
72369
|
-
|
|
72370
|
-
|
|
72371
|
-
|
|
72372
|
-
|
|
72373
|
-
|
|
72374
|
-
|
|
72375
|
-
|
|
72376
|
-
|
|
72377
|
-
|
|
72378
|
-
|
|
72379
|
-
|
|
72200
|
+
self.addEventListener("message", (event) => {
|
|
72201
|
+
switch (event.data.type) {
|
|
72202
|
+
case 1:
|
|
72203
|
+
console.log('receive structural');
|
|
72204
|
+
progressStructuralGeometries(event.data.materials, event.data.data, (buffer, colorString, opacity) => {
|
|
72205
|
+
self.postMessage({
|
|
72206
|
+
type: 1,
|
|
72207
|
+
buffer: buffer,
|
|
72208
|
+
materialColorString: colorString,
|
|
72209
|
+
materialOpacity: opacity,
|
|
72210
|
+
});
|
|
72211
|
+
});
|
|
72212
|
+
break;
|
|
72213
|
+
case 2:
|
|
72214
|
+
console.log('receive none structural');
|
|
72215
|
+
progressNoneStructuralGeometries(event.data.materials, event.data.data, (buffer, colorString, opacity) => {
|
|
72216
|
+
self.postMessage({
|
|
72217
|
+
type: 1,
|
|
72218
|
+
buffer: buffer,
|
|
72219
|
+
materialColorString: colorString,
|
|
72220
|
+
materialOpacity: opacity,
|
|
72221
|
+
});
|
|
72222
|
+
});
|
|
72223
|
+
break;
|
|
72224
|
+
default:
|
|
72225
|
+
break;
|
|
72380
72226
|
}
|
|
72381
|
-
}
|
|
72382
|
-
setupOptionalCategories(data) {
|
|
72383
|
-
this.initializeParser();
|
|
72384
|
-
if (this.parser === undefined)
|
|
72385
|
-
throw new Error(ErrorParserNotAvailable);
|
|
72386
|
-
this.parser.setupOptionalCategories(data.args.config);
|
|
72387
|
-
this.worker.post(data);
|
|
72388
|
-
}
|
|
72389
|
-
parse(data) {
|
|
72390
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72391
|
-
this.initializeParser();
|
|
72392
|
-
if (this.parser === undefined)
|
|
72393
|
-
throw new Error(ErrorParserNotAvailable);
|
|
72394
|
-
if (this.worker.state)
|
|
72395
|
-
this.worker.state.onProgress = (event) => this.onProgress(event, data);
|
|
72396
|
-
const serializedIfcModel = yield this.getResponse(data);
|
|
72397
|
-
yield this.IDB.save(serializedIfcModel, DBOperation.transferIfcModel);
|
|
72398
|
-
this.worker.post(data);
|
|
72399
|
-
});
|
|
72400
|
-
}
|
|
72401
|
-
onProgress(event, data) {
|
|
72402
|
-
this.worker.post(Object.assign(Object.assign({}, data), { onProgress: true, result: event }));
|
|
72403
|
-
}
|
|
72404
|
-
getResponse(data) {
|
|
72405
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72406
|
-
if (!this.parser)
|
|
72407
|
-
throw new Error(ErrorParserNotAvailable);
|
|
72408
|
-
const ifcModel = yield this.parser.parse(data.args.buffer, data.args.coordinationMatrix);
|
|
72409
|
-
const serializedIfcModel = this.serializer.serializeIfcModel(ifcModel);
|
|
72410
|
-
this.cleanUpGeometries(ifcModel);
|
|
72411
|
-
data.result = { modelID: ifcModel.modelID };
|
|
72412
|
-
return serializedIfcModel;
|
|
72413
|
-
});
|
|
72414
|
-
}
|
|
72415
|
-
cleanUpGeometries(model) {
|
|
72416
|
-
model.geometry.dispose();
|
|
72417
|
-
if (Array.isArray(model.material))
|
|
72418
|
-
model.material.forEach(mat => mat.dispose());
|
|
72419
|
-
else
|
|
72420
|
-
model.material.dispose();
|
|
72421
|
-
}
|
|
72422
|
-
}
|
|
72423
|
-
class IFCWorker {
|
|
72424
|
-
constructor() {
|
|
72425
|
-
this.serializer = new Serializer();
|
|
72426
|
-
this.IDB = new IndexedDatabase();
|
|
72427
|
-
this.workerState = new StateWorker(this);
|
|
72428
|
-
this.webIfc = new WebIfcWorker(this, this.serializer);
|
|
72429
|
-
this.properties = new PropertyWorker(this);
|
|
72430
|
-
this.parser = new ParserWorker(this, this.serializer, this.IDB);
|
|
72431
|
-
}
|
|
72432
|
-
initializeAPI(api) {
|
|
72433
|
-
this.state = {
|
|
72434
|
-
models: [],
|
|
72435
|
-
api,
|
|
72436
|
-
useJSON: false,
|
|
72437
|
-
worker: { active: false, path: '' }
|
|
72438
|
-
};
|
|
72439
|
-
}
|
|
72440
|
-
post(data) {
|
|
72441
|
-
self.postMessage(data);
|
|
72442
|
-
}
|
|
72443
|
-
postCallback(data, result, serializer) {
|
|
72444
|
-
data.result = serializer ? serializer(result) : result;
|
|
72445
|
-
this.post(data);
|
|
72446
|
-
}
|
|
72447
|
-
}
|
|
72448
|
-
const ifcWorker = new IFCWorker();
|
|
72449
|
-
self.onmessage = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
72450
|
-
const data = event.data;
|
|
72451
|
-
const { worker, action } = data;
|
|
72452
|
-
checkRequestIsValid(worker, action);
|
|
72453
|
-
const requestedWorker = ifcWorker[worker];
|
|
72454
|
-
requestedWorker[action](data);
|
|
72455
|
-
});
|
|
72456
|
-
function checkRequestIsValid(worker, action) {
|
|
72457
|
-
if (!ifcWorker[worker]) {
|
|
72458
|
-
throw new Error(`The worker ${worker} does not exist.`);
|
|
72459
|
-
}
|
|
72460
|
-
const requestedWorker = ifcWorker[worker];
|
|
72461
|
-
if (!requestedWorker[action]) {
|
|
72462
|
-
throw new Error(`The action ${action} does not exist in the worker ${worker}.`);
|
|
72463
|
-
}
|
|
72227
|
+
}, false);
|
|
72464
72228
|
}
|
|
72465
|
-
|
|
72229
|
+
exports.workerCode = workerFunction;
|
|
72466
72230
|
//# sourceMappingURL=threejs.types.js.map
|