viral-viewer-2 5.3.1 → 5.3.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.
- package/dist/components/worker/viral-viewer-4.worker.js +5 -1
- package/dist/components/worker/viral-viewer-4.worker.js.map +1 -1
- package/dist/components/worker-script/load-model-worker-3.script.js +1 -116
- package/dist/components/worker-script/load-model-worker-3.script.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ const three_1 = require("three");
|
|
|
5
5
|
const load_model_worker_3_script_1 = require("../worker-script/load-model-worker-3.script");
|
|
6
6
|
const worker_pool_1 = require("./base/worker-pool");
|
|
7
7
|
const log_1 = require("../../utils/log");
|
|
8
|
+
const viral_instanced_mesh_1 = require("../custom-objects/viral-instanced-mesh");
|
|
8
9
|
const threejs_1 = require("../../utils/threejs");
|
|
9
10
|
class ViralViewerWorker4 {
|
|
10
11
|
constructor(viralViewerApi) {
|
|
@@ -42,7 +43,10 @@ class ViralViewerWorker4 {
|
|
|
42
43
|
for (let j = 0; j < dummyMesh.children.length; j++) {
|
|
43
44
|
let element = dummyMesh.children[j];
|
|
44
45
|
if (element.userData.IsInstancedMesh) {
|
|
45
|
-
|
|
46
|
+
let instancedMesh = new viral_instanced_mesh_1.ViralInstancedMesh(element.geometry, element.material, element.count);
|
|
47
|
+
instancedMesh.instanceColor = element.instanceColor;
|
|
48
|
+
instancedMesh.instanceMatrix = element.instanceMatrix;
|
|
49
|
+
console.log(instancedMesh);
|
|
46
50
|
}
|
|
47
51
|
try {
|
|
48
52
|
this.viralViewerApi.viralBVH.applyThreeMeshBVH(element.geometry);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viral-viewer-4.worker.js","sourceRoot":"","sources":["../../../src/components/worker/viral-viewer-4.worker.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"viral-viewer-4.worker.js","sourceRoot":"","sources":["../../../src/components/worker/viral-viewer-4.worker.ts"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,CAAC,KAAK,EAAE;wBACrC,aAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;qBACtB;iBACF;gBACD,OAAO,CAAC,QAAQ,GAAG,EAAE,CAAC;gBACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBAC5D,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;oBACtD,OAAO,CAAC,QAAQ,CAAC,IAAI,CACnB,IAAI,CAAC,cAAc,CAAC,oBAAoB,CAAC,SAAS,CAAC,GAAG,CACpD,aAAa,CACb,CACH,CAAC;iBACH;gBACD,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aAC1D;YACD,IAAI,IAAI,CAAC,SAAS;gBAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAClD,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;YAC3C,iBAAiB,EAAE,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAlFD,gDAkFC"}
|
|
@@ -33993,121 +33993,6 @@ which can be placed in CurveUtils.
|
|
|
33993
33993
|
}
|
|
33994
33994
|
//#endregion
|
|
33995
33995
|
//#region Custom object
|
|
33996
|
-
class ViralInstancedMesh extends InstancedMesh {
|
|
33997
|
-
/**
|
|
33998
|
-
*
|
|
33999
|
-
* @param geometry geometry for instanced mesh
|
|
34000
|
-
* @param materials materials for instanced mesh, can be both 1 or array
|
|
34001
|
-
* @param count number of instance in mesh
|
|
34002
|
-
* @param _host share the same logic with parent, when we push temp mesh into scene, we must binding original viral instanced mesh to host to recall/ reprogress later
|
|
34003
|
-
*/
|
|
34004
|
-
constructor(geometry, materials, count, _host) {
|
|
34005
|
-
super(geometry, materials, count);
|
|
34006
|
-
this.tempInstancedMesh = null;
|
|
34007
|
-
this.host = null;
|
|
34008
|
-
this.overrideMeshes = [];
|
|
34009
|
-
if (_host)
|
|
34010
|
-
this.host = _host;
|
|
34011
|
-
//before change anything, keep original mesh
|
|
34012
|
-
}
|
|
34013
|
-
hideAts(indexs) {
|
|
34014
|
-
var _a;
|
|
34015
|
-
if (indexs.length > 0) {
|
|
34016
|
-
let numberRemain = this.count - indexs.length;
|
|
34017
|
-
this.tempInstancedMesh = new ViralInstancedMesh(this.geometry, this.material, numberRemain, this);
|
|
34018
|
-
this.tempInstancedMesh.instanceColor = this.instanceColor;
|
|
34019
|
-
this.tempInstancedMesh.instanceMatrix = this.instanceMatrix;
|
|
34020
|
-
if (this.instanceColor != null) {
|
|
34021
|
-
//get original instance color then remove later
|
|
34022
|
-
let instanceColorArray = Array.from(this.instanceColor.array);
|
|
34023
|
-
for (let index = 0; index < indexs.length; index++) {
|
|
34024
|
-
const removedIndex = indexs[index] * this.instanceColor.itemSize -
|
|
34025
|
-
index * this.instanceColor.itemSize;
|
|
34026
|
-
instanceColorArray.splice(removedIndex, this.instanceColor.itemSize);
|
|
34027
|
-
}
|
|
34028
|
-
this.tempInstancedMesh.instanceColor = new InstancedBufferAttribute(new Float32Array(instanceColorArray), this.instanceColor.itemSize);
|
|
34029
|
-
}
|
|
34030
|
-
if (this.instanceMatrix != null) {
|
|
34031
|
-
//get original instance matrix then remove later
|
|
34032
|
-
let instanceMatrixArray = Array.from(this.instanceMatrix.array);
|
|
34033
|
-
for (let index = 0; index < indexs.length; index++) {
|
|
34034
|
-
const removedIndex = indexs[index] * this.instanceMatrix.itemSize -
|
|
34035
|
-
index * this.instanceMatrix.itemSize;
|
|
34036
|
-
instanceMatrixArray.splice(removedIndex, this.instanceMatrix.itemSize);
|
|
34037
|
-
}
|
|
34038
|
-
this.tempInstancedMesh.instanceMatrix = new InstancedBufferAttribute(new Float32Array(instanceMatrixArray), this.instanceMatrix.itemSize);
|
|
34039
|
-
}
|
|
34040
|
-
//final, remove main from parent and add tempmesh
|
|
34041
|
-
(_a = this.parent) === null || _a === void 0 ? void 0 : _a.add(this.tempInstancedMesh);
|
|
34042
|
-
this.removeFromParent();
|
|
34043
|
-
}
|
|
34044
|
-
}
|
|
34045
|
-
isolateAts(indexs) {
|
|
34046
|
-
var _a;
|
|
34047
|
-
if (indexs.length > 0) {
|
|
34048
|
-
this.tempInstancedMesh = new ViralInstancedMesh(this.geometry, this.material, indexs.length, this);
|
|
34049
|
-
this.tempInstancedMesh.instanceColor = this.instanceColor;
|
|
34050
|
-
this.tempInstancedMesh.instanceMatrix = this.instanceMatrix;
|
|
34051
|
-
if (this.instanceColor != null) {
|
|
34052
|
-
let isolateInstanceColorArray = [];
|
|
34053
|
-
//get original instance color then remove later
|
|
34054
|
-
let instanceColorArray = Array.from(this.instanceColor.array);
|
|
34055
|
-
for (let index = 0; index < indexs.length; index++) {
|
|
34056
|
-
const startIndex = indexs[index] * this.instanceColor.itemSize;
|
|
34057
|
-
isolateInstanceColorArray = isolateInstanceColorArray.concat(instanceColorArray.slice(startIndex, startIndex + this.instanceColor.itemSize));
|
|
34058
|
-
}
|
|
34059
|
-
this.tempInstancedMesh.instanceColor = new InstancedBufferAttribute(new Float32Array(isolateInstanceColorArray), this.instanceColor.itemSize);
|
|
34060
|
-
}
|
|
34061
|
-
if (this.instanceMatrix != null) {
|
|
34062
|
-
let isolateInstanceMatrixArray = [];
|
|
34063
|
-
//get original instance matrix then remove later
|
|
34064
|
-
let instanceMatrixArray = Array.from(this.instanceMatrix.array);
|
|
34065
|
-
for (let index = 0; index < indexs.length; index++) {
|
|
34066
|
-
const startIndex = indexs[index] * this.instanceMatrix.itemSize;
|
|
34067
|
-
isolateInstanceMatrixArray = isolateInstanceMatrixArray.concat(instanceMatrixArray.slice(startIndex, startIndex + this.instanceMatrix.itemSize));
|
|
34068
|
-
}
|
|
34069
|
-
this.tempInstancedMesh.instanceMatrix = new InstancedBufferAttribute(new Float32Array(isolateInstanceMatrixArray), this.instanceMatrix.itemSize);
|
|
34070
|
-
}
|
|
34071
|
-
//final, remove main from parent and add tempmesh
|
|
34072
|
-
(_a = this.parent) === null || _a === void 0 ? void 0 : _a.add(this.tempInstancedMesh);
|
|
34073
|
-
this.removeFromParent();
|
|
34074
|
-
}
|
|
34075
|
-
}
|
|
34076
|
-
overrideMaterialAts(indexs, material) {
|
|
34077
|
-
var _a;
|
|
34078
|
-
for (let index = 0; index < indexs.length; index++) {
|
|
34079
|
-
const selectedIndex = indexs[index];
|
|
34080
|
-
let mesh = new Mesh(this.geometry, material);
|
|
34081
|
-
let matrix = new Matrix4();
|
|
34082
|
-
this.getMatrixAt(selectedIndex, matrix);
|
|
34083
|
-
mesh.applyMatrix4(matrix);
|
|
34084
|
-
(_a = this.parent) === null || _a === void 0 ? void 0 : _a.add(mesh);
|
|
34085
|
-
this.overrideMeshes.push(mesh);
|
|
34086
|
-
}
|
|
34087
|
-
this.hideAts(indexs);
|
|
34088
|
-
}
|
|
34089
|
-
reverseToOriginal() {
|
|
34090
|
-
var _a;
|
|
34091
|
-
if (this.overrideMeshes.length > 0) {
|
|
34092
|
-
for (let index = 0; index < this.overrideMeshes.length; index++) {
|
|
34093
|
-
const mesh = this.overrideMeshes[index];
|
|
34094
|
-
mesh.removeFromParent();
|
|
34095
|
-
mesh.geometry.dispose();
|
|
34096
|
-
mesh.material.dispose();
|
|
34097
|
-
}
|
|
34098
|
-
this.overrideMeshes = [];
|
|
34099
|
-
}
|
|
34100
|
-
if (this.tempInstancedMesh) {
|
|
34101
|
-
//reverse original
|
|
34102
|
-
(_a = this.tempInstancedMesh.parent) === null || _a === void 0 ? void 0 : _a.add(this);
|
|
34103
|
-
//then dispose temp
|
|
34104
|
-
this.tempInstancedMesh.removeFromParent();
|
|
34105
|
-
this.tempInstancedMesh.geometry.dispose();
|
|
34106
|
-
this.tempInstancedMesh.dispose();
|
|
34107
|
-
this.tempInstancedMesh = null;
|
|
34108
|
-
}
|
|
34109
|
-
}
|
|
34110
|
-
}
|
|
34111
33996
|
//#endregion
|
|
34112
33997
|
//#region My code
|
|
34113
33998
|
//////////////////
|
|
@@ -34205,7 +34090,7 @@ which can be placed in CurveUtils.
|
|
|
34205
34090
|
let geometries = solids.map((x) => x.geometry);
|
|
34206
34091
|
mergedGeometry = mergeGeometries(geometries, true);
|
|
34207
34092
|
// mergedGeometry.computeVertexNormals();
|
|
34208
|
-
const instancedMesh = new
|
|
34093
|
+
const instancedMesh = new InstancedMesh(mergedGeometry, [], data.Instances.length);
|
|
34209
34094
|
instancedMesh.userData.Instances = [];
|
|
34210
34095
|
instancedMesh.userData.MaterialIds = [];
|
|
34211
34096
|
// instancedMesh.receiveShadow = true;
|