viral-viewer-2 3.1.1 → 3.1.3
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.
|
@@ -34104,17 +34104,16 @@ function workerFunction() {
|
|
|
34104
34104
|
dummyGeometry.computeVertexNormals();
|
|
34105
34105
|
if (event.data.Instances.length > 0) {
|
|
34106
34106
|
let geometry = new BufferGeometry();
|
|
34107
|
-
// In case number of polygon larger than expect, merge them to reduce polygon first, for optimize purpose
|
|
34108
|
-
if (dummyGeometry.attributes.position.count > maxPolygonPerObject) {
|
|
34109
|
-
|
|
34110
|
-
|
|
34111
|
-
|
|
34112
|
-
|
|
34113
|
-
|
|
34114
|
-
}
|
|
34115
|
-
|
|
34116
|
-
|
|
34117
|
-
}
|
|
34107
|
+
// // In case number of polygon larger than expect, merge them to reduce polygon first, for optimize purpose
|
|
34108
|
+
// if (dummyGeometry.attributes.position.count > maxPolygonPerObject) {
|
|
34109
|
+
// let modifier = new SimplifyModifier();
|
|
34110
|
+
// // const ratio = maxPolygonPerObject / dummyGeometry.attributes.position.count;
|
|
34111
|
+
// // const count = Math.floor(dummyGeometry.attributes.position.count * ratio); // number of polygon to remove
|
|
34112
|
+
// } else {
|
|
34113
|
+
// geometry = dummyGeometry;
|
|
34114
|
+
// }
|
|
34115
|
+
geometry = modifier.modify(dummyGeometry, maxPolygonPerObject);
|
|
34116
|
+
console.log(dummyGeometry.attributes.position.count, geometry.attributes.position.count);
|
|
34118
34117
|
const childMesh = new InstancedMesh(geometry, new MeshBasicMaterial(), event.data.Instances.length);
|
|
34119
34118
|
childMesh.castShadow = true;
|
|
34120
34119
|
childMesh.receiveShadow = true;
|
|
@@ -34143,23 +34142,29 @@ function workerFunction() {
|
|
|
34143
34142
|
matrix4.fromArray(numbers);
|
|
34144
34143
|
childMesh.setMatrixAt(index, matrix4);
|
|
34145
34144
|
//if number of polygon smaller than expect, generate edges
|
|
34146
|
-
if (geometry.attributes.position.count < maxPolygonForEdge) {
|
|
34147
|
-
|
|
34148
|
-
|
|
34149
|
-
|
|
34150
|
-
|
|
34151
|
-
|
|
34152
|
-
|
|
34153
|
-
|
|
34154
|
-
|
|
34155
|
-
|
|
34156
|
-
|
|
34157
|
-
|
|
34158
|
-
|
|
34159
|
-
|
|
34160
|
-
|
|
34161
|
-
|
|
34162
|
-
|
|
34145
|
+
// if (geometry.attributes.position.count < maxPolygonForEdge) {
|
|
34146
|
+
// const edges = new EdgesGeometry(geometry, 90);
|
|
34147
|
+
// const positions = edges.attributes.position.array;
|
|
34148
|
+
// const indices = [];
|
|
34149
|
+
// for (let i = 0; i < positions.length / 3; i += 2) {
|
|
34150
|
+
// indices.push(i, i + 1);
|
|
34151
|
+
// }
|
|
34152
|
+
// const bufferGeometry = new BufferGeometry();
|
|
34153
|
+
// // Set the position attribute
|
|
34154
|
+
// bufferGeometry.setAttribute(
|
|
34155
|
+
// "position",
|
|
34156
|
+
// new BufferAttribute(new Float32Array(positions), 3)
|
|
34157
|
+
// );
|
|
34158
|
+
// // Set the index attribute
|
|
34159
|
+
// bufferGeometry.setIndex(indices);
|
|
34160
|
+
// const line = new LineSegments(
|
|
34161
|
+
// bufferGeometry,
|
|
34162
|
+
// new LineBasicMaterial({ color: "#666", linewidth: 0.5 })
|
|
34163
|
+
// );
|
|
34164
|
+
// line.applyMatrix4(matrix4);
|
|
34165
|
+
// line.updateMatrix();
|
|
34166
|
+
// childMesh.add(line);
|
|
34167
|
+
// }
|
|
34163
34168
|
}
|
|
34164
34169
|
// childMesh.instanceMatrix.needsUpdate = true;
|
|
34165
34170
|
childMesh.updateMatrix();
|