viral-viewer-2 2.6.8 → 2.6.9
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.
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ViralViewerWorker2 = void 0;
|
|
4
4
|
const types_1 = require("../../types");
|
|
5
5
|
const three_1 = require("three");
|
|
6
|
-
|
|
6
|
+
// import { workerCode } from "../worker-script/load-model-worker-2.script";
|
|
7
|
+
const threejs_types_1 = require("../worker-script/threejs.types");
|
|
7
8
|
const dictionary_model_1 = require("../../models/dictionary.model");
|
|
8
9
|
const worker_pool_1 = require("./base/worker-pool");
|
|
9
|
-
const simplify_modifier_1 = require("../../threejs-addon/simplify-modifier");
|
|
10
10
|
class ViralViewerWorker2 {
|
|
11
11
|
constructor(viralViewerApi, scriptUrl = "../worker-script/load-model-worker-2.script.js") {
|
|
12
12
|
this.viralViewerApi = viralViewerApi;
|
|
@@ -16,7 +16,7 @@ class ViralViewerWorker2 {
|
|
|
16
16
|
this.maxPolygonPerObject = 1000;
|
|
17
17
|
this.maxPolygonForEdge = 1000;
|
|
18
18
|
// Create a new Blob containing the worker code
|
|
19
|
-
const blob = new Blob([`(${
|
|
19
|
+
const blob = new Blob([`(${threejs_types_1.workerCode})()`]);
|
|
20
20
|
const workerPath = URL.createObjectURL(blob);
|
|
21
21
|
// Create a new Worker from the Blob
|
|
22
22
|
this.workerPool = new worker_pool_1.WorkerThreadPool(4, workerPath);
|
|
@@ -44,92 +44,91 @@ class ViralViewerWorker2 {
|
|
|
44
44
|
inputData.Indices = model.Indices;
|
|
45
45
|
inputData.Vertices = model.Vertices;
|
|
46
46
|
this.workerPool.Enqueue(inputData, (data) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
geometry
|
|
50
|
-
geometry.
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
console.log(data);
|
|
48
|
+
// let buffer = data.buffer;
|
|
49
|
+
// const geometry = new BufferGeometry();
|
|
50
|
+
// geometry.setAttribute("position", new BufferAttribute(buffer, 3));
|
|
51
|
+
// geometry.computeVertexNormals();
|
|
52
|
+
// const edges = new EdgesGeometry(geometry, 90);
|
|
53
|
+
// const line = new LineSegments(
|
|
54
|
+
// edges,
|
|
55
|
+
// new LineBasicMaterial({ color: "#202020", linewidth: 0.5 })
|
|
56
|
+
// );
|
|
57
|
+
// const childMesh = new Mesh(geometry, this.threejsMaterials.get(model.MaterialIndex));
|
|
58
|
+
// childMesh.add(line);
|
|
59
|
+
// childMesh.castShadow = true;
|
|
60
|
+
// childMesh.receiveShadow = true;
|
|
61
|
+
// if (this.mainModel)
|
|
62
|
+
// this.mainModel.add(childMesh);
|
|
63
|
+
// this.viralViewerApi.viralRenderer.render();
|
|
60
64
|
callbackOnSuccess();
|
|
61
65
|
});
|
|
62
66
|
}
|
|
63
67
|
loadNoneStructuralGeometry(model, callbackOnSuccess = () => { }) {
|
|
64
|
-
// model.Instances.forEach(instance => {
|
|
65
68
|
let inputData = new types_1.ViralViewerRevitGeometry();
|
|
66
69
|
inputData.Indices = model.Indices;
|
|
67
70
|
inputData.Vertices = model.Vertices;
|
|
68
|
-
// inputData.Transform = model.Instances[0];
|
|
69
71
|
this.workerPool.Enqueue(inputData, (data) => {
|
|
70
|
-
|
|
71
|
-
let
|
|
72
|
-
|
|
73
|
-
dummyGeometry
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
//
|
|
86
|
-
geometry.computeVertexNormals();
|
|
87
|
-
// const
|
|
88
|
-
//
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.mainModel.add(childMesh);
|
|
129
|
-
}
|
|
72
|
+
console.log(data);
|
|
73
|
+
// let buffer = data.buffer;
|
|
74
|
+
// let geometry = new BufferGeometry();
|
|
75
|
+
// const dummyGeometry = new BufferGeometry();
|
|
76
|
+
// dummyGeometry.setAttribute("position", new BufferAttribute(buffer, 3));
|
|
77
|
+
// // In case number of polygon larger than expect, merge them to reduce polygon first, for optimize purpose
|
|
78
|
+
// if (dummyGeometry.attributes.position.count > this.maxPolygonPerObject) {
|
|
79
|
+
// const modifier = new SimplifyModifier();
|
|
80
|
+
// const ratio = this.maxPolygonPerObject / dummyGeometry.attributes.position.count;
|
|
81
|
+
// const count = Math.floor(dummyGeometry.attributes.position.count * ratio); // number of polygon to remove
|
|
82
|
+
// geometry = modifier.modify(dummyGeometry, count);
|
|
83
|
+
// console.log(model.Name, dummyGeometry.attributes.position.count, geometry.attributes.position.count)
|
|
84
|
+
// }
|
|
85
|
+
// else {
|
|
86
|
+
// geometry = dummyGeometry;
|
|
87
|
+
// }
|
|
88
|
+
// geometry.computeVertexNormals();
|
|
89
|
+
// const childMesh = new InstancedMesh(geometry, this.threejsMaterials.get(model.MaterialIndex), model.Instances.length);
|
|
90
|
+
// childMesh.castShadow = true;
|
|
91
|
+
// childMesh.receiveShadow = true;
|
|
92
|
+
// for (let index = 0; index < model.Instances.length; index++) {
|
|
93
|
+
// const transform = model.Instances[index];
|
|
94
|
+
// let numbers = [
|
|
95
|
+
// transform.BasisX.X,
|
|
96
|
+
// -transform.BasisX.Z,
|
|
97
|
+
// -transform.BasisX.Y,
|
|
98
|
+
// 0,
|
|
99
|
+
// -transform.BasisZ.X,
|
|
100
|
+
// transform.BasisZ.Z,
|
|
101
|
+
// transform.BasisZ.Y,
|
|
102
|
+
// 0,
|
|
103
|
+
// -transform.BasisY.X,
|
|
104
|
+
// transform.BasisY.Z,
|
|
105
|
+
// transform.BasisY.Y,
|
|
106
|
+
// 0,
|
|
107
|
+
// -transform.Offset.X,
|
|
108
|
+
// transform.Offset.Z,
|
|
109
|
+
// transform.Offset.Y,
|
|
110
|
+
// 1,
|
|
111
|
+
// ];
|
|
112
|
+
// //transform first
|
|
113
|
+
// let matrix4 = new Matrix4();
|
|
114
|
+
// matrix4.fromArray(numbers);
|
|
115
|
+
// childMesh.setMatrixAt(index, matrix4);
|
|
116
|
+
// //if number of polygon smaller than expect, generate edges
|
|
117
|
+
// if (geometry.attributes.position.count < this.maxPolygonForEdge) {
|
|
118
|
+
// const edges = new EdgesGeometry(geometry, 90);
|
|
119
|
+
// const line = new LineSegments(
|
|
120
|
+
// edges,
|
|
121
|
+
// new LineBasicMaterial({ color: "#666", linewidth: 0.5 })
|
|
122
|
+
// );
|
|
123
|
+
// line.applyMatrix4(matrix4);
|
|
124
|
+
// childMesh.add(line);
|
|
125
|
+
// }
|
|
126
|
+
// }
|
|
127
|
+
// if (this.mainModel) {
|
|
128
|
+
// this.mainModel.add(childMesh);
|
|
129
|
+
// }
|
|
130
130
|
callbackOnSuccess();
|
|
131
131
|
});
|
|
132
|
-
// });
|
|
133
132
|
}
|
|
134
133
|
rgbToHex(r, g, b) {
|
|
135
134
|
return "#" + this.componentToHex(r) + this.componentToHex(g) + this.componentToHex(b);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viral-viewer-2.worker.js","sourceRoot":"","sources":["../../../src/components/worker/viral-viewer-2.worker.ts"],"names":[],"mappings":";;;AACA,uCAA4K;AAC5K,iCAAkL;AAClL,
|
|
1
|
+
{"version":3,"file":"viral-viewer-2.worker.js","sourceRoot":"","sources":["../../../src/components/worker/viral-viewer-2.worker.ts"],"names":[],"mappings":";;;AACA,uCAA4K;AAC5K,iCAAkL;AAClL,4EAA4E;AAC5E,kEAA4D;AAC5D,oEAA2D;AAC3D,oDAAsD;AAGtD,MAAa,kBAAkB;IAO3B,YAAmB,cAA8B,EAAE,YAAoB,gDAAgD;QAApG,mBAAc,GAAd,cAAc,CAAgB;QAL1C,cAAS,GAAqB,EAAE,CAAC;QACjC,cAAS,GAAgB,IAAI,CAAC;QAC9B,qBAAgB,GAA0C,IAAI,6BAAU,EAA6B,CAAC;QAC5F,wBAAmB,GAAG,IAAI,CAAC;QAC3B,sBAAiB,GAAG,IAAI,CAAC;QAGtC,+CAA+C;QAC/C,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,IAAI,0BAAU,KAAK,CAAC,CAAC,CAAC;QAC7C,MAAM,UAAU,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC7C,oCAAoC;QACpC,IAAI,CAAC,UAAU,GAAG,IAAI,8BAAgB,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC;IACM,OAAO,CAAC,SAA2B;QACtC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,IAAI,CAAC,SAAS,GAAG,IAAI,YAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,aAAa,CAAC;QACpC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YACnD,MAAM,QAAQ,GAAG,SA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S;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;AA1ID,gDA0IC"}
|
|
@@ -75475,118 +75475,72 @@ function workerFunction() {
|
|
|
75475
75475
|
}
|
|
75476
75476
|
return new BufferAttribute(array, itemSize, normalized);
|
|
75477
75477
|
}
|
|
75478
|
-
function
|
|
75478
|
+
function addMesh(indicates, vertices, transform = null, callback = (buffer) => { }) {
|
|
75479
75479
|
let verticePoints = [];
|
|
75480
|
-
|
|
75481
|
-
const index = indices[i];
|
|
75482
|
-
const point = vertices[index];
|
|
75483
|
-
verticePoints.push(-point.X);
|
|
75484
|
-
verticePoints.push(point.Z);
|
|
75485
|
-
verticePoints.push(point.Y);
|
|
75486
|
-
}
|
|
75487
|
-
const buffer = new Float32Array(verticePoints);
|
|
75488
|
-
let colorString = rgbToHex(material.Red, material.Green, material.Blue);
|
|
75489
|
-
callback(buffer, colorString, material.Opacity);
|
|
75490
|
-
}
|
|
75491
|
-
function addCustomMesh4(indices, vertices, material, instances, callback = (buffer, colorString, opacity) => { }) {
|
|
75492
|
-
let colorString = rgbToHex(material.Red, material.Green, material.Blue);
|
|
75493
|
-
let finalVerticePoints = [];
|
|
75494
|
-
for (let index = 0; index < instances.length; index++) {
|
|
75495
|
-
const instance = instances[index];
|
|
75496
|
-
let numbers = [
|
|
75497
|
-
instance.BasisX.X,
|
|
75498
|
-
-instance.BasisX.Z,
|
|
75499
|
-
-instance.BasisX.Y,
|
|
75500
|
-
0,
|
|
75501
|
-
-instance.BasisZ.X,
|
|
75502
|
-
instance.BasisZ.Z,
|
|
75503
|
-
instance.BasisZ.Y,
|
|
75504
|
-
0,
|
|
75505
|
-
-instance.BasisY.X,
|
|
75506
|
-
instance.BasisY.Z,
|
|
75507
|
-
instance.BasisY.Y,
|
|
75508
|
-
0,
|
|
75509
|
-
-instance.Offset.X,
|
|
75510
|
-
instance.Offset.Z,
|
|
75511
|
-
instance.Offset.Y,
|
|
75512
|
-
1,
|
|
75513
|
-
];
|
|
75514
|
-
let matrix4 = new Matrix4();
|
|
75515
|
-
matrix4.fromArray(numbers);
|
|
75516
|
-
let newVertices = [];
|
|
75517
|
-
for (let i = 0; i < vertices.length; i++) {
|
|
75518
|
-
const point = vertices[i];
|
|
75519
|
-
const point2 = new Vector3(-point.X, point.Z, point.Y);
|
|
75520
|
-
point2.applyMatrix4(matrix4);
|
|
75521
|
-
newVertices.push(point2);
|
|
75522
|
-
}
|
|
75523
|
-
let verticePoints = [];
|
|
75480
|
+
if (transform == null) {
|
|
75524
75481
|
for (let i = 0; i < indices.length; i++) {
|
|
75525
75482
|
const index = indices[i];
|
|
75526
|
-
const point =
|
|
75527
|
-
verticePoints.push(point.
|
|
75528
|
-
verticePoints.push(point.
|
|
75529
|
-
verticePoints.push(point.
|
|
75483
|
+
const point = vertices[index];
|
|
75484
|
+
verticePoints.push(-point.X);
|
|
75485
|
+
verticePoints.push(point.Z);
|
|
75486
|
+
verticePoints.push(point.Y);
|
|
75530
75487
|
}
|
|
75531
|
-
|
|
75488
|
+
const buffer = new Float32Array(verticePoints);
|
|
75489
|
+
callback(buffer);
|
|
75490
|
+
return;
|
|
75532
75491
|
}
|
|
75533
|
-
|
|
75534
|
-
|
|
75535
|
-
|
|
75536
|
-
|
|
75537
|
-
|
|
75538
|
-
|
|
75539
|
-
|
|
75492
|
+
let numbers = [
|
|
75493
|
+
transform.BasisX.X,
|
|
75494
|
+
-transform.BasisX.Z,
|
|
75495
|
+
-transform.BasisX.Y,
|
|
75496
|
+
0,
|
|
75497
|
+
-transform.BasisZ.X,
|
|
75498
|
+
transform.BasisZ.Z,
|
|
75499
|
+
transform.BasisZ.Y,
|
|
75500
|
+
0,
|
|
75501
|
+
-transform.BasisY.X,
|
|
75502
|
+
transform.BasisY.Z,
|
|
75503
|
+
transform.BasisY.Y,
|
|
75504
|
+
0,
|
|
75505
|
+
-transform.Offset.X,
|
|
75506
|
+
transform.Offset.Z,
|
|
75507
|
+
transform.Offset.Y,
|
|
75508
|
+
1,
|
|
75509
|
+
];
|
|
75510
|
+
//transform first
|
|
75511
|
+
let matrix4 = new Matrix4();
|
|
75512
|
+
matrix4.fromArray(numbers);
|
|
75513
|
+
let newVertices = [];
|
|
75514
|
+
for (let i = 0; i < vertices.length; i++) {
|
|
75515
|
+
const point = vertices[i];
|
|
75516
|
+
const point2 = new Vector3(-point.X, point.Z, point.Y);
|
|
75517
|
+
point2.applyMatrix4(matrix4);
|
|
75518
|
+
newVertices.push(point2);
|
|
75519
|
+
}
|
|
75520
|
+
for (let i = 0; i < indices.length; i++) {
|
|
75521
|
+
const index = indices[i];
|
|
75522
|
+
const point = newVertices[index];
|
|
75523
|
+
verticePoints.push(point.x);
|
|
75524
|
+
verticePoints.push(point.y);
|
|
75525
|
+
verticePoints.push(point.z);
|
|
75526
|
+
}
|
|
75527
|
+
const buffer = new Float32Array(verticePoints);
|
|
75528
|
+
callback(buffer);
|
|
75540
75529
|
}
|
|
75541
|
-
function
|
|
75542
|
-
|
|
75543
|
-
|
|
75530
|
+
function progressGeometries(json, callback = (buffer) => { }) {
|
|
75531
|
+
addMesh(json.Indices, json.Vertices, json.Transform, (buffer) => {
|
|
75532
|
+
const dummyGeometry = new BufferGeometry();
|
|
75533
|
+
dummyGeometry.setAttribute("position", new BufferAttribute(buffer, 3));
|
|
75534
|
+
let jsonData = dummyGeometry.toJSON();
|
|
75535
|
+
callback({ buffer: buffer, data: jsonData });
|
|
75544
75536
|
});
|
|
75545
75537
|
}
|
|
75546
|
-
function rgbToHex(r, g, b) {
|
|
75547
|
-
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
|
|
75548
|
-
}
|
|
75549
|
-
function componentToHex(c) {
|
|
75550
|
-
var hex = c.toString(16);
|
|
75551
|
-
return hex.length == 1 ? "0" + hex : hex;
|
|
75552
|
-
}
|
|
75553
75538
|
self.addEventListener("message", (event) => {
|
|
75554
|
-
|
|
75555
|
-
|
|
75556
|
-
|
|
75557
|
-
|
|
75558
|
-
|
|
75559
|
-
geometry.setAttribute("position", new BufferAttribute(buffer, 3));
|
|
75560
|
-
geometry.computeVertexNormals();
|
|
75561
|
-
console.log(geometry);
|
|
75562
|
-
self.postMessage({
|
|
75563
|
-
type: 1,
|
|
75564
|
-
buffer: buffer,
|
|
75565
|
-
materialColorString: colorString,
|
|
75566
|
-
materialOpacity: opacity,
|
|
75567
|
-
geometry: geometry
|
|
75568
|
-
});
|
|
75569
|
-
});
|
|
75570
|
-
break;
|
|
75571
|
-
case 2:
|
|
75572
|
-
console.log("receive none structural");
|
|
75573
|
-
progressNoneStructuralGeometries(event.data.materials, event.data.data, (buffer, colorString, opacity) => {
|
|
75574
|
-
const geometry = new BufferGeometry();
|
|
75575
|
-
geometry.setAttribute("position", new BufferAttribute(buffer, 3));
|
|
75576
|
-
geometry.computeVertexNormals();
|
|
75577
|
-
console.log(geometry);
|
|
75578
|
-
self.postMessage({
|
|
75579
|
-
type: 1,
|
|
75580
|
-
buffer: buffer,
|
|
75581
|
-
materialColorString: colorString,
|
|
75582
|
-
materialOpacity: opacity,
|
|
75583
|
-
geometry: geometry
|
|
75584
|
-
});
|
|
75585
|
-
});
|
|
75586
|
-
break;
|
|
75587
|
-
default:
|
|
75588
|
-
break;
|
|
75589
|
-
}
|
|
75539
|
+
progressGeometries(event.data, (buffer) => {
|
|
75540
|
+
self.postMessage({
|
|
75541
|
+
buffer: buffer,
|
|
75542
|
+
});
|
|
75543
|
+
});
|
|
75590
75544
|
}, false);
|
|
75591
75545
|
}
|
|
75592
75546
|
exports.workerCode = workerFunction;
|