zincjs 3.0.0 → 3.0.1
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/README.md +27 -22
- package/build/zinc.js +2 -2
- package/build/zinc.js.map +1 -1
- package/package.json +4 -1
- package/src/controls.js +1332 -1241
- package/src/geometryCSG.js +111 -115
- package/src/glyphsetCSG.js +51 -55
- package/src/loaders/GLTFToZincJSLoader.js +31 -33
- package/src/loaders/JSONLoader.js +339 -449
- package/src/loaders/OBJLoader.js +654 -851
- package/src/loaders/STLLoader.js +271 -329
- package/src/loaders/niftiReader.js +90 -59
- package/src/loaders/primitivesLoader.js +55 -52
- package/src/minimap.js +63 -43
- package/src/primitives/geometry.js +40 -44
- package/src/primitives/glyph.js +16 -19
- package/src/primitives/glyphset.js +229 -185
- package/src/primitives/label.js +29 -31
- package/src/primitives/lines.js +20 -20
- package/src/primitives/lines2.js +33 -39
- package/src/primitives/lod.js +43 -43
- package/src/primitives/marker.js +31 -32
- package/src/primitives/markerCluster.js +32 -35
- package/src/primitives/pointset.js +86 -83
- package/src/primitives/texturePrimitive.js +9 -10
- package/src/primitives/textureSlides.js +84 -97
- package/src/primitives/textureVolume.js +46 -49
- package/src/primitives/tubeLines.js +108 -108
- package/src/primitives/zincObject.js +176 -184
- package/src/region.js +145 -155
- package/src/renderRequests.js +3 -3
- package/src/renderer.js +635 -620
- package/src/scene.js +479 -419
- package/src/sceneExporter.js +22 -17
- package/src/sceneLoader.js +542 -296
- package/src/shaders/rgbVolumeRender.js +11 -18
- package/src/shaders/textureArray.js +5 -12
- package/src/shaders/textureSlide.js +10 -17
- package/src/shaders/volumeRender.js +11 -18
- package/src/shaders/volumeRender_old.js +11 -18
- package/src/shaders/volumeTexture.js +7 -14
- package/src/textSprite.js +23 -19
- package/src/texture/texture.js +14 -15
- package/src/texture/textureArray.js +14 -16
- package/src/three/InstancedPoints.js +2 -9
- package/src/three/Loader.js +334 -315
- package/src/three/line/Line.js +165 -215
- package/src/three/line/LineSegments.js +40 -55
- package/src/three/line/LineSegments2.js +322 -366
- package/src/three/line/LineSegmentsGeometry.js +239 -280
- package/src/three-js-csg.js +260 -252
- package/src/tsl/glyphRenderMaterial.js +12 -3
- package/src/tsl/glyphTransform.js +51 -29
- package/src/tsl/textureSlides.js +23 -24
- package/src/utilities.js +309 -371
- package/src/videoHandler.js +76 -83
- package/src/workers/geometryCSG.worker.js +33 -36
- package/src/workers/geometryCSGInternal.js +39 -44
- package/src/zinc.js +4 -7
- package/vite.config.js +7 -7
package/src/region.js
CHANGED
|
@@ -7,8 +7,8 @@ import { updateWorldMatrixFromAncestors } from './utilities';
|
|
|
7
7
|
let uniqueiId = 0;
|
|
8
8
|
|
|
9
9
|
const getUniqueId = function () {
|
|
10
|
-
return
|
|
11
|
-
}
|
|
10
|
+
return 're' + uniqueiId++;
|
|
11
|
+
};
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Provides a hierachical structure to objects, Each region
|
|
@@ -24,7 +24,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
24
24
|
group.matrixAutoUpdate = false;
|
|
25
25
|
group.userData = this;
|
|
26
26
|
let children = [];
|
|
27
|
-
let name =
|
|
27
|
+
let name = '';
|
|
28
28
|
let zincObjects = [];
|
|
29
29
|
let scene = sceneIn;
|
|
30
30
|
const tMatrix = new THREE.Matrix4();
|
|
@@ -37,23 +37,23 @@ let Region = function (parentIn, sceneIn) {
|
|
|
37
37
|
//Ask the scene to draw the next frame, used by render on demand.
|
|
38
38
|
const requestRender = () => {
|
|
39
39
|
scene?.invalidate?.();
|
|
40
|
-
}
|
|
40
|
+
};
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* Hide all primitives belong to this region.
|
|
44
44
|
*/
|
|
45
45
|
this.hideAllPrimitives = () => {
|
|
46
|
-
children.forEach(child => child.hideAllPrimitives());
|
|
47
|
-
zincObjects.forEach(zincObject => zincObject.setVisibility(false));
|
|
48
|
-
}
|
|
46
|
+
children.forEach((child) => child.hideAllPrimitives());
|
|
47
|
+
zincObjects.forEach((zincObject) => zincObject.setVisibility(false));
|
|
48
|
+
};
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Show all primitives belong to this region.
|
|
52
52
|
*/
|
|
53
53
|
this.showAllPrimitives = () => {
|
|
54
|
-
children.forEach(child => child.showAllPrimitives());
|
|
55
|
-
zincObjects.forEach(zincObject => zincObject.setVisibility(true));
|
|
56
|
-
}
|
|
54
|
+
children.forEach((child) => child.showAllPrimitives());
|
|
55
|
+
zincObjects.forEach((zincObject) => zincObject.setVisibility(true));
|
|
56
|
+
};
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* Set the visibility and propagate it down the hierarchies
|
|
@@ -67,7 +67,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
67
67
|
group.visible = flag;
|
|
68
68
|
this.pickableUpdateRequired = true;
|
|
69
69
|
}
|
|
70
|
-
}
|
|
70
|
+
};
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* Get the visibility of the region and its children.
|
|
@@ -76,7 +76,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
76
76
|
*/
|
|
77
77
|
this.getVisibility = () => {
|
|
78
78
|
return group.visible;
|
|
79
|
-
}
|
|
79
|
+
};
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* Get the {THREE.Group} containing all child regions and their
|
|
@@ -86,7 +86,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
86
86
|
*/
|
|
87
87
|
this.getGroup = () => {
|
|
88
88
|
return group;
|
|
89
|
-
}
|
|
89
|
+
};
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* Set the transformation with a {THREE.Matrix4} matrix, this will affect
|
|
@@ -95,7 +95,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
95
95
|
* @param {THREE.Matrix4} transformation - The transformation matrix
|
|
96
96
|
* used for the transformation.
|
|
97
97
|
*/
|
|
98
|
-
this.setTransformation = transformation => {
|
|
98
|
+
this.setTransformation = (transformation) => {
|
|
99
99
|
requestRender();
|
|
100
100
|
tMatrix.set(...transformation);
|
|
101
101
|
group.matrix.copy(tMatrix);
|
|
@@ -107,7 +107,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
107
107
|
this.getAllObjects(true).forEach((zincObject) => {
|
|
108
108
|
zincObject.boundingBoxUpdateRequired = true;
|
|
109
109
|
});
|
|
110
|
-
}
|
|
110
|
+
};
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
113
|
* Set the name of this region.
|
|
@@ -116,10 +116,10 @@ let Region = function (parentIn, sceneIn) {
|
|
|
116
116
|
* and non-empty.
|
|
117
117
|
*/
|
|
118
118
|
this.setName = (nameIn) => {
|
|
119
|
-
if (nameIn && nameIn !==
|
|
119
|
+
if (nameIn && nameIn !== '') {
|
|
120
120
|
name = nameIn;
|
|
121
121
|
}
|
|
122
|
-
}
|
|
122
|
+
};
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* Get the name of this region.
|
|
@@ -128,7 +128,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
128
128
|
*/
|
|
129
129
|
this.getName = () => {
|
|
130
130
|
return name;
|
|
131
|
-
}
|
|
131
|
+
};
|
|
132
132
|
|
|
133
133
|
/**
|
|
134
134
|
* Get the parent region.
|
|
@@ -137,7 +137,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
137
137
|
*/
|
|
138
138
|
this.getParent = () => {
|
|
139
139
|
return parent;
|
|
140
|
-
}
|
|
140
|
+
};
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
* Get the {@link Scene} this region belongs to.
|
|
@@ -146,7 +146,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
146
146
|
*/
|
|
147
147
|
this.getScene = () => {
|
|
148
148
|
return scene;
|
|
149
|
-
}
|
|
149
|
+
};
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
152
|
* Get the array of each hierarachy from the root region to this region.
|
|
@@ -155,18 +155,18 @@ let Region = function (parentIn, sceneIn) {
|
|
|
155
155
|
*/
|
|
156
156
|
this.getFullSeparatedPath = () => {
|
|
157
157
|
const paths = [];
|
|
158
|
-
if (name !==
|
|
158
|
+
if (name !== '') {
|
|
159
159
|
paths.push(name);
|
|
160
160
|
for (let p = parent; p !== undefined;) {
|
|
161
161
|
const parentName = p.getName();
|
|
162
|
-
if (parentName !==
|
|
162
|
+
if (parentName !== '') {
|
|
163
163
|
paths.unshift(parentName);
|
|
164
164
|
}
|
|
165
165
|
p = p.getParent();
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
return paths;
|
|
169
|
-
}
|
|
169
|
+
};
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
172
|
* Get the full paths from the root region to this region.
|
|
@@ -177,13 +177,13 @@ let Region = function (parentIn, sceneIn) {
|
|
|
177
177
|
const paths = this.getFullSeparatedPath();
|
|
178
178
|
if (paths.length > 0) {
|
|
179
179
|
let fullPath = paths.shift();
|
|
180
|
-
paths.forEach(path => {
|
|
181
|
-
fullPath = fullPath.concat(
|
|
180
|
+
paths.forEach((path) => {
|
|
181
|
+
fullPath = fullPath.concat('/', path);
|
|
182
182
|
});
|
|
183
183
|
return fullPath;
|
|
184
184
|
}
|
|
185
|
-
return
|
|
186
|
-
}
|
|
185
|
+
return '';
|
|
186
|
+
};
|
|
187
187
|
|
|
188
188
|
/**
|
|
189
189
|
* Create a new child region with the provided name.
|
|
@@ -198,7 +198,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
198
198
|
children.push(childRegion);
|
|
199
199
|
group.add(childRegion.getGroup());
|
|
200
200
|
return childRegion;
|
|
201
|
-
}
|
|
201
|
+
};
|
|
202
202
|
|
|
203
203
|
/**
|
|
204
204
|
* Get the child region with matching childName.
|
|
@@ -206,16 +206,15 @@ let Region = function (parentIn, sceneIn) {
|
|
|
206
206
|
*
|
|
207
207
|
* @return {Region}
|
|
208
208
|
*/
|
|
209
|
-
this.getChildWithName = childName => {
|
|
209
|
+
this.getChildWithName = (childName) => {
|
|
210
210
|
if (childName) {
|
|
211
211
|
const lowerChildName = childName.toLowerCase();
|
|
212
212
|
for (let i = 0; i < children.length; i++) {
|
|
213
|
-
if (children[i].getName().toLowerCase() === lowerChildName)
|
|
214
|
-
return children[i];
|
|
213
|
+
if (children[i].getName().toLowerCase() === lowerChildName) return children[i];
|
|
215
214
|
}
|
|
216
215
|
}
|
|
217
216
|
return undefined;
|
|
218
|
-
}
|
|
217
|
+
};
|
|
219
218
|
|
|
220
219
|
/**
|
|
221
220
|
* Find a child region using the path array.
|
|
@@ -224,9 +223,9 @@ let Region = function (parentIn, sceneIn) {
|
|
|
224
223
|
*
|
|
225
224
|
* @return {Region}
|
|
226
225
|
*/
|
|
227
|
-
this.findChildFromSeparatedPath = pathArray => {
|
|
226
|
+
this.findChildFromSeparatedPath = (pathArray) => {
|
|
228
227
|
if (pathArray && pathArray.length > 0) {
|
|
229
|
-
if (pathArray[0] ===
|
|
228
|
+
if (pathArray[0] === '') {
|
|
230
229
|
pathArray.shift();
|
|
231
230
|
}
|
|
232
231
|
}
|
|
@@ -240,7 +239,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
240
239
|
}
|
|
241
240
|
}
|
|
242
241
|
return this;
|
|
243
|
-
}
|
|
242
|
+
};
|
|
244
243
|
|
|
245
244
|
/**
|
|
246
245
|
* Find the region using the provided relative path.
|
|
@@ -251,9 +250,9 @@ let Region = function (parentIn, sceneIn) {
|
|
|
251
250
|
* @return {Region}
|
|
252
251
|
*/
|
|
253
252
|
this.findChildFromPath = (path) => {
|
|
254
|
-
const pathArray = path.split(
|
|
253
|
+
const pathArray = path.split('/');
|
|
255
254
|
return this.findChildFromSeparatedPath(pathArray);
|
|
256
|
-
}
|
|
255
|
+
};
|
|
257
256
|
|
|
258
257
|
/**
|
|
259
258
|
* Create a new child using the path array. All required new regions
|
|
@@ -264,9 +263,9 @@ let Region = function (parentIn, sceneIn) {
|
|
|
264
263
|
*
|
|
265
264
|
* @return {Region}
|
|
266
265
|
*/
|
|
267
|
-
this.createChildFromSeparatedPath = pathArray => {
|
|
266
|
+
this.createChildFromSeparatedPath = (pathArray) => {
|
|
268
267
|
if (pathArray.length > 0) {
|
|
269
|
-
if (pathArray[0] ===
|
|
268
|
+
if (pathArray[0] === '') {
|
|
270
269
|
pathArray.shift();
|
|
271
270
|
}
|
|
272
271
|
}
|
|
@@ -279,7 +278,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
279
278
|
return childRegion.createChildFromSeparatedPath(pathArray);
|
|
280
279
|
}
|
|
281
280
|
return this;
|
|
282
|
-
}
|
|
281
|
+
};
|
|
283
282
|
|
|
284
283
|
/**
|
|
285
284
|
* Create a new child using the path. All required new regions
|
|
@@ -291,10 +290,9 @@ let Region = function (parentIn, sceneIn) {
|
|
|
291
290
|
* @return {Region}
|
|
292
291
|
*/
|
|
293
292
|
this.createChildFromPath = (path) => {
|
|
294
|
-
const pathArray = path.split(
|
|
293
|
+
const pathArray = path.split('/');
|
|
295
294
|
return this.createChildFromSeparatedPath(pathArray);
|
|
296
|
-
}
|
|
297
|
-
|
|
295
|
+
};
|
|
298
296
|
|
|
299
297
|
/**
|
|
300
298
|
* Return existing region if it exists, otherwise, create a new
|
|
@@ -311,7 +309,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
311
309
|
childRegion = this.createChildFromPath(path);
|
|
312
310
|
}
|
|
313
311
|
return childRegion;
|
|
314
|
-
}
|
|
312
|
+
};
|
|
315
313
|
|
|
316
314
|
/**
|
|
317
315
|
* Add a zinc object into this region, the morph will be added
|
|
@@ -320,7 +318,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
320
318
|
* @param {ZincObject} zincObject - Zinc object to be added into
|
|
321
319
|
* this region.
|
|
322
320
|
*/
|
|
323
|
-
this.addZincObject = zincObject => {
|
|
321
|
+
this.addZincObject = (zincObject) => {
|
|
324
322
|
requestRender();
|
|
325
323
|
if (zincObject) {
|
|
326
324
|
zincObject.setRegion(this);
|
|
@@ -331,8 +329,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
331
329
|
scene.triggerObjectAddedCallback(zincObject);
|
|
332
330
|
}
|
|
333
331
|
}
|
|
334
|
-
}
|
|
335
|
-
|
|
332
|
+
};
|
|
336
333
|
|
|
337
334
|
/**
|
|
338
335
|
* Remove a ZincObject from this region if it presents. This will eventually
|
|
@@ -340,7 +337,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
340
337
|
*
|
|
341
338
|
* @param {ZincObject} zincObject - object to be removed from this region.
|
|
342
339
|
*/
|
|
343
|
-
this.removeZincObject = zincObject => {
|
|
340
|
+
this.removeZincObject = (zincObject) => {
|
|
344
341
|
requestRender();
|
|
345
342
|
for (let i = 0; i < zincObjects.length; i++) {
|
|
346
343
|
if (zincObject === zincObjects[i]) {
|
|
@@ -354,7 +351,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
354
351
|
return;
|
|
355
352
|
}
|
|
356
353
|
}
|
|
357
|
-
}
|
|
354
|
+
};
|
|
358
355
|
|
|
359
356
|
/**
|
|
360
357
|
* Return true if pickable objects require an update.
|
|
@@ -369,12 +366,12 @@ let Region = function (parentIn, sceneIn) {
|
|
|
369
366
|
if (transverse) {
|
|
370
367
|
let flag = false;
|
|
371
368
|
for (let i = 0; i < children.length; i++) {
|
|
372
|
-
|
|
373
|
-
|
|
369
|
+
flag = children[i].checkPickableUpdateRequred(transverse);
|
|
370
|
+
if (flag) return true;
|
|
374
371
|
}
|
|
375
372
|
}
|
|
376
373
|
return false;
|
|
377
|
-
}
|
|
374
|
+
};
|
|
378
375
|
|
|
379
376
|
/**
|
|
380
377
|
* Clear the pickable update flag for this region and its descendants,
|
|
@@ -385,20 +382,20 @@ let Region = function (parentIn, sceneIn) {
|
|
|
385
382
|
this.clearPickableUpdateRequired = (transverse) => {
|
|
386
383
|
this.pickableUpdateRequired = false;
|
|
387
384
|
if (transverse) {
|
|
388
|
-
children.forEach(childRegion => {
|
|
385
|
+
children.forEach((childRegion) => {
|
|
389
386
|
childRegion.clearPickableUpdateRequired(transverse);
|
|
390
387
|
});
|
|
391
388
|
}
|
|
392
|
-
}
|
|
389
|
+
};
|
|
393
390
|
|
|
394
391
|
/**
|
|
395
392
|
* Get all pickable objects.
|
|
396
393
|
*/
|
|
397
|
-
this.getPickableThreeJSObjects = (objectsList,
|
|
394
|
+
this.getPickableThreeJSObjects = (objectsList, transverse) => {
|
|
398
395
|
if (!group.visible) {
|
|
399
396
|
this.clearPickableUpdateRequired(transverse);
|
|
400
397
|
} else {
|
|
401
|
-
zincObjects.forEach(zincObject => {
|
|
398
|
+
zincObjects.forEach((zincObject) => {
|
|
402
399
|
if (zincObject.isPickable && zincObject.getGroup() && zincObject.getGroup().visible) {
|
|
403
400
|
let marker = zincObject.marker;
|
|
404
401
|
if (marker && marker.isEnabled()) {
|
|
@@ -408,14 +405,14 @@ let Region = function (parentIn, sceneIn) {
|
|
|
408
405
|
}
|
|
409
406
|
});
|
|
410
407
|
if (transverse) {
|
|
411
|
-
children.forEach(childRegion => {
|
|
408
|
+
children.forEach((childRegion) => {
|
|
412
409
|
childRegion.getPickableThreeJSObjects(objectsList, transverse);
|
|
413
410
|
});
|
|
414
411
|
}
|
|
415
412
|
this.pickableUpdateRequired = false;
|
|
416
413
|
}
|
|
417
414
|
return objectsList;
|
|
418
|
-
}
|
|
415
|
+
};
|
|
419
416
|
|
|
420
417
|
/**
|
|
421
418
|
* Set the default duration value for all zinc objects
|
|
@@ -423,11 +420,11 @@ let Region = function (parentIn, sceneIn) {
|
|
|
423
420
|
*
|
|
424
421
|
* @param {Number} durationIn - duration of the scene.
|
|
425
422
|
*/
|
|
426
|
-
this.setDuration = durationIn => {
|
|
423
|
+
this.setDuration = (durationIn) => {
|
|
427
424
|
duration = durationIn;
|
|
428
|
-
zincObjects.forEach(zincObject => zincObject.setDuration(durationIn));
|
|
429
|
-
children.forEach(childRegion => childRegion.setDuration(durationIn));
|
|
430
|
-
}
|
|
425
|
+
zincObjects.forEach((zincObject) => zincObject.setDuration(durationIn));
|
|
426
|
+
children.forEach((childRegion) => childRegion.setDuration(durationIn));
|
|
427
|
+
};
|
|
431
428
|
|
|
432
429
|
/**
|
|
433
430
|
* Get the default duration value.
|
|
@@ -435,7 +432,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
435
432
|
*/
|
|
436
433
|
this.getDuration = () => {
|
|
437
434
|
return duration;
|
|
438
|
-
}
|
|
435
|
+
};
|
|
439
436
|
|
|
440
437
|
/**
|
|
441
438
|
* Get the bounding box of all the object in this and child regions only.
|
|
@@ -444,13 +441,13 @@ let Region = function (parentIn, sceneIn) {
|
|
|
444
441
|
*
|
|
445
442
|
* @returns {THREE.Box3}
|
|
446
443
|
*/
|
|
447
|
-
this.getBoundingBox = transverse => {
|
|
444
|
+
this.getBoundingBox = (transverse) => {
|
|
448
445
|
const boundingBox = new THREE.Box3();
|
|
449
446
|
if (this.accumulateBoundingBox(boundingBox, transverse)) {
|
|
450
447
|
return boundingBox;
|
|
451
448
|
}
|
|
452
449
|
return undefined;
|
|
453
|
-
}
|
|
450
|
+
};
|
|
454
451
|
|
|
455
452
|
/**
|
|
456
453
|
* Expand the target by the bounding box of this region.
|
|
@@ -469,12 +466,11 @@ let Region = function (parentIn, sceneIn) {
|
|
|
469
466
|
}
|
|
470
467
|
if (transverse) {
|
|
471
468
|
for (let i = 0; i < children.length; i++) {
|
|
472
|
-
if (children[i].accumulateBoundingBox(target, transverse))
|
|
473
|
-
found = true;
|
|
469
|
+
if (children[i].accumulateBoundingBox(target, transverse)) found = true;
|
|
474
470
|
}
|
|
475
471
|
}
|
|
476
472
|
return found;
|
|
477
|
-
}
|
|
473
|
+
};
|
|
478
474
|
|
|
479
475
|
/**
|
|
480
476
|
* Clear and dispose all objects belong to this region.
|
|
@@ -482,15 +478,15 @@ let Region = function (parentIn, sceneIn) {
|
|
|
482
478
|
* @param {Boolean} transverse - Clear and dispose child regions as well
|
|
483
479
|
* if this is set to true.
|
|
484
480
|
*/
|
|
485
|
-
this.clear = transverse => {
|
|
481
|
+
this.clear = (transverse) => {
|
|
486
482
|
requestRender();
|
|
487
483
|
if (transverse) {
|
|
488
|
-
children.forEach(childRegion => {
|
|
484
|
+
children.forEach((childRegion) => {
|
|
489
485
|
childRegion.clear(transverse);
|
|
490
486
|
group.remove(childRegion.getGroup());
|
|
491
487
|
});
|
|
492
488
|
}
|
|
493
|
-
zincObjects.forEach(zincObject => {
|
|
489
|
+
zincObjects.forEach((zincObject) => {
|
|
494
490
|
group.remove(zincObject.getGroup());
|
|
495
491
|
zincObject.dispose();
|
|
496
492
|
});
|
|
@@ -498,7 +494,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
498
494
|
children = [];
|
|
499
495
|
}
|
|
500
496
|
zincObjects = [];
|
|
501
|
-
}
|
|
497
|
+
};
|
|
502
498
|
|
|
503
499
|
/**
|
|
504
500
|
* Check if a zincObject is a member of this region.
|
|
@@ -516,13 +512,12 @@ let Region = function (parentIn, sceneIn) {
|
|
|
516
512
|
}
|
|
517
513
|
if (transverse) {
|
|
518
514
|
for (let i = 0; i < children.length; i++) {
|
|
519
|
-
if (children[i].objectIsInRegion(zincObject, transverse))
|
|
520
|
-
return true;
|
|
515
|
+
if (children[i].objectIsInRegion(zincObject, transverse)) return true;
|
|
521
516
|
}
|
|
522
517
|
}
|
|
523
518
|
|
|
524
519
|
return false;
|
|
525
|
-
}
|
|
520
|
+
};
|
|
526
521
|
|
|
527
522
|
/**
|
|
528
523
|
* A function which iterates through the list of geometries and call the callback
|
|
@@ -534,14 +529,12 @@ let Region = function (parentIn, sceneIn) {
|
|
|
534
529
|
* all child regions if this is set to be true.
|
|
535
530
|
*/
|
|
536
531
|
this.forEachGeometry = (callbackFunction, transverse) => {
|
|
537
|
-
zincObjects.forEach(zincObject => {
|
|
538
|
-
if (zincObject.isGeometry)
|
|
539
|
-
callbackFunction(zincObject);
|
|
532
|
+
zincObjects.forEach((zincObject) => {
|
|
533
|
+
if (zincObject.isGeometry) callbackFunction(zincObject);
|
|
540
534
|
});
|
|
541
535
|
if (transverse)
|
|
542
|
-
children.forEach(childRegion => childRegion.forEachGeometry(
|
|
543
|
-
|
|
544
|
-
}
|
|
536
|
+
children.forEach((childRegion) => childRegion.forEachGeometry(callbackFunction, transverse));
|
|
537
|
+
};
|
|
545
538
|
|
|
546
539
|
/**
|
|
547
540
|
* A function which iterates through the list of glyphsets and call the callback
|
|
@@ -553,14 +546,12 @@ let Region = function (parentIn, sceneIn) {
|
|
|
553
546
|
* all child regions if this is set to be true.
|
|
554
547
|
*/
|
|
555
548
|
this.forEachGlyphset = (callbackFunction, transverse) => {
|
|
556
|
-
zincObjects.forEach(zincObject => {
|
|
557
|
-
if (zincObject.isGlyphset)
|
|
558
|
-
callbackFunction(zincObject);
|
|
549
|
+
zincObjects.forEach((zincObject) => {
|
|
550
|
+
if (zincObject.isGlyphset) callbackFunction(zincObject);
|
|
559
551
|
});
|
|
560
552
|
if (transverse)
|
|
561
|
-
children.forEach(childRegion => childRegion.forEachGlyphset(
|
|
562
|
-
|
|
563
|
-
}
|
|
553
|
+
children.forEach((childRegion) => childRegion.forEachGlyphset(callbackFunction, transverse));
|
|
554
|
+
};
|
|
564
555
|
|
|
565
556
|
/**
|
|
566
557
|
* A function which iterates through the list of pointsets and call the callback
|
|
@@ -572,49 +563,44 @@ let Region = function (parentIn, sceneIn) {
|
|
|
572
563
|
* all child regions if this is set to be true.
|
|
573
564
|
*/
|
|
574
565
|
this.forEachPointset = (callbackFunction, transverse) => {
|
|
575
|
-
zincObjects.forEach(zincObject => {
|
|
576
|
-
if (zincObject.isPointset)
|
|
577
|
-
callbackFunction(zincObject);
|
|
566
|
+
zincObjects.forEach((zincObject) => {
|
|
567
|
+
if (zincObject.isPointset) callbackFunction(zincObject);
|
|
578
568
|
});
|
|
579
569
|
if (transverse)
|
|
580
|
-
children.forEach(childRegion => childRegion.forEachPointset(
|
|
581
|
-
|
|
582
|
-
}
|
|
570
|
+
children.forEach((childRegion) => childRegion.forEachPointset(callbackFunction, transverse));
|
|
571
|
+
};
|
|
583
572
|
|
|
584
573
|
/**
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
574
|
+
* A function which iterates through the list of lines and call the callback
|
|
575
|
+
* function with the lines as the argument.
|
|
576
|
+
*
|
|
577
|
+
* @param {Function} callbackFunction - Callback function with the lines
|
|
578
|
+
* as an argument.
|
|
590
579
|
* @param {Boolean} transverse - Also perform the same callback function for
|
|
591
580
|
* all child regions if this is set to be true.
|
|
592
|
-
|
|
581
|
+
*/
|
|
593
582
|
this.forEachLine = (callbackFunction, transverse) => {
|
|
594
|
-
zincObjects.forEach(zincObject => {
|
|
595
|
-
if (zincObject.isLines)
|
|
596
|
-
callbackFunction(zincObject);
|
|
583
|
+
zincObjects.forEach((zincObject) => {
|
|
584
|
+
if (zincObject.isLines) callbackFunction(zincObject);
|
|
597
585
|
});
|
|
598
586
|
if (transverse)
|
|
599
|
-
children.forEach(childRegion => childRegion.forEachLine(
|
|
600
|
-
|
|
601
|
-
}
|
|
587
|
+
children.forEach((childRegion) => childRegion.forEachLine(callbackFunction, transverse));
|
|
588
|
+
};
|
|
602
589
|
|
|
603
590
|
this.findObjectsWithAnatomicalId = (anatomicalId, transverse) => {
|
|
604
591
|
const objectsArray = [];
|
|
605
|
-
zincObjects.forEach(zincObject => {
|
|
606
|
-
if (zincObject.anatomicalId === anatomicalId)
|
|
607
|
-
objectsArray.push(zincObject);
|
|
592
|
+
zincObjects.forEach((zincObject) => {
|
|
593
|
+
if (zincObject.anatomicalId === anatomicalId) objectsArray.push(zincObject);
|
|
608
594
|
});
|
|
609
595
|
if (transverse) {
|
|
610
|
-
children.forEach(childRegion => {
|
|
596
|
+
children.forEach((childRegion) => {
|
|
611
597
|
let childObjects = childRegion.findObjectsWithAnatomicalId(anatomicalId, transverse);
|
|
612
598
|
objectsArray.push(...childObjects);
|
|
613
599
|
});
|
|
614
600
|
}
|
|
615
601
|
|
|
616
602
|
return objectsArray;
|
|
617
|
-
}
|
|
603
|
+
};
|
|
618
604
|
|
|
619
605
|
/**
|
|
620
606
|
* Find and return all zinc objects in this and child regions with
|
|
@@ -627,20 +613,21 @@ let Region = function (parentIn, sceneIn) {
|
|
|
627
613
|
*/
|
|
628
614
|
this.findObjectsWithGroupName = (groupName, transverse) => {
|
|
629
615
|
const objectsArray = [];
|
|
630
|
-
zincObjects.forEach(zincObject => {
|
|
631
|
-
const lowerObjectName = zincObject.groupName
|
|
616
|
+
zincObjects.forEach((zincObject) => {
|
|
617
|
+
const lowerObjectName = zincObject.groupName
|
|
618
|
+
? zincObject.groupName.toLowerCase()
|
|
619
|
+
: zincObject.groupName;
|
|
632
620
|
const lowerGroupName = groupName ? groupName.toLowerCase() : groupName;
|
|
633
|
-
if (lowerObjectName === lowerGroupName)
|
|
634
|
-
objectsArray.push(zincObject);
|
|
621
|
+
if (lowerObjectName === lowerGroupName) objectsArray.push(zincObject);
|
|
635
622
|
});
|
|
636
623
|
if (transverse) {
|
|
637
|
-
children.forEach(childRegion => {
|
|
624
|
+
children.forEach((childRegion) => {
|
|
638
625
|
let childObjects = childRegion.findObjectsWithGroupName(groupName, transverse);
|
|
639
626
|
objectsArray.push(...childObjects);
|
|
640
627
|
});
|
|
641
628
|
}
|
|
642
629
|
return objectsArray;
|
|
643
|
-
}
|
|
630
|
+
};
|
|
644
631
|
|
|
645
632
|
/**
|
|
646
633
|
* Find and return all geometries in this and child regions with
|
|
@@ -653,9 +640,9 @@ let Region = function (parentIn, sceneIn) {
|
|
|
653
640
|
*/
|
|
654
641
|
this.findGeometriesWithGroupName = (groupName, transverse) => {
|
|
655
642
|
const primitivesArray = this.findObjectsWithGroupName(groupName, transverse);
|
|
656
|
-
const geometriesArray = primitivesArray.filter(primitive => primitive.isGeometry);
|
|
643
|
+
const geometriesArray = primitivesArray.filter((primitive) => primitive.isGeometry);
|
|
657
644
|
return geometriesArray;
|
|
658
|
-
}
|
|
645
|
+
};
|
|
659
646
|
|
|
660
647
|
/**
|
|
661
648
|
* Find and return all pointsets in this and child regions with
|
|
@@ -668,9 +655,9 @@ let Region = function (parentIn, sceneIn) {
|
|
|
668
655
|
*/
|
|
669
656
|
this.findPointsetsWithGroupName = (groupName, transverse) => {
|
|
670
657
|
const primitivesArray = this.findObjectsWithGroupName(groupName, transverse);
|
|
671
|
-
const pointsetsArray = primitivesArray.filter(primitive => primitive.isPointset);
|
|
658
|
+
const pointsetsArray = primitivesArray.filter((primitive) => primitive.isPointset);
|
|
672
659
|
return pointsetsArray;
|
|
673
|
-
}
|
|
660
|
+
};
|
|
674
661
|
|
|
675
662
|
/**
|
|
676
663
|
* Find and return all glyphsets in this and child regions with
|
|
@@ -683,9 +670,9 @@ let Region = function (parentIn, sceneIn) {
|
|
|
683
670
|
*/
|
|
684
671
|
this.findGlyphsetsWithGroupName = (groupName, transverse) => {
|
|
685
672
|
const primitivesArray = this.findObjectsWithGroupName(groupName, transverse);
|
|
686
|
-
const glyphsetsArray = primitivesArray.filter(primitive => primitive.isGlyphset);
|
|
673
|
+
const glyphsetsArray = primitivesArray.filter((primitive) => primitive.isGlyphset);
|
|
687
674
|
return glyphsetsArray;
|
|
688
|
-
}
|
|
675
|
+
};
|
|
689
676
|
|
|
690
677
|
/**
|
|
691
678
|
* Find and return all lines in this and child regions with
|
|
@@ -698,9 +685,9 @@ let Region = function (parentIn, sceneIn) {
|
|
|
698
685
|
*/
|
|
699
686
|
this.findLinesWithGroupName = (groupName, transverse) => {
|
|
700
687
|
const primitivesArray = this.findObjectsWithGroupName(groupName, transverse);
|
|
701
|
-
const linesArray = primitivesArray.filter(primitive => primitive.isLines);
|
|
688
|
+
const linesArray = primitivesArray.filter((primitive) => primitive.isLines);
|
|
702
689
|
return linesArray;
|
|
703
|
-
}
|
|
690
|
+
};
|
|
704
691
|
|
|
705
692
|
/**
|
|
706
693
|
* Get all zinc objects in this region.
|
|
@@ -719,7 +706,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
719
706
|
}
|
|
720
707
|
}
|
|
721
708
|
return objectsArray;
|
|
722
|
-
}
|
|
709
|
+
};
|
|
723
710
|
|
|
724
711
|
/**
|
|
725
712
|
* Get all child regions.
|
|
@@ -728,16 +715,16 @@ let Region = function (parentIn, sceneIn) {
|
|
|
728
715
|
* this reigon when this is set to true.
|
|
729
716
|
* @returns {Array}
|
|
730
717
|
*/
|
|
731
|
-
|
|
718
|
+
this.getChildRegions = (transverse) => {
|
|
732
719
|
const objectsArray = [...children];
|
|
733
720
|
if (transverse) {
|
|
734
|
-
children.forEach(childRegion => {
|
|
721
|
+
children.forEach((childRegion) => {
|
|
735
722
|
const childObjects = childRegion.getChildRegions(transverse);
|
|
736
723
|
objectsArray.push(...childObjects);
|
|
737
724
|
});
|
|
738
725
|
}
|
|
739
726
|
return objectsArray;
|
|
740
|
-
}
|
|
727
|
+
};
|
|
741
728
|
|
|
742
729
|
/**
|
|
743
730
|
* Get the current time of the region.
|
|
@@ -751,12 +738,11 @@ let Region = function (parentIn, sceneIn) {
|
|
|
751
738
|
} else {
|
|
752
739
|
for (let i = 0; i < children.length; i++) {
|
|
753
740
|
const time = children[i].getCurrentTime();
|
|
754
|
-
if (time !== -1)
|
|
755
|
-
return time;
|
|
741
|
+
if (time !== -1) return time;
|
|
756
742
|
}
|
|
757
743
|
}
|
|
758
744
|
return -1;
|
|
759
|
-
}
|
|
745
|
+
};
|
|
760
746
|
|
|
761
747
|
/**
|
|
762
748
|
* Set the current time of all the objects of this region.
|
|
@@ -766,15 +752,15 @@ let Region = function (parentIn, sceneIn) {
|
|
|
766
752
|
* this is set to true.
|
|
767
753
|
*/
|
|
768
754
|
this.setMorphTime = (time, transverse) => {
|
|
769
|
-
zincObjects.forEach(zincObject => {
|
|
755
|
+
zincObjects.forEach((zincObject) => {
|
|
770
756
|
zincObject.setMorphTime(time);
|
|
771
757
|
});
|
|
772
758
|
if (transverse) {
|
|
773
|
-
children.forEach(childRegion => {
|
|
759
|
+
children.forEach((childRegion) => {
|
|
774
760
|
childRegion.setMorphTime(time, transverse);
|
|
775
761
|
});
|
|
776
762
|
}
|
|
777
|
-
}
|
|
763
|
+
};
|
|
778
764
|
|
|
779
765
|
/**
|
|
780
766
|
* Check if any object in this region is time varying.
|
|
@@ -794,7 +780,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
794
780
|
}
|
|
795
781
|
|
|
796
782
|
return false;
|
|
797
|
-
}
|
|
783
|
+
};
|
|
798
784
|
|
|
799
785
|
/**
|
|
800
786
|
* Update geometries and glyphsets based on the calculated time.
|
|
@@ -811,14 +797,13 @@ let Region = function (parentIn, sceneIn) {
|
|
|
811
797
|
children[i].renderObjects(delta, playAnimation, cameraControls, options, transverse);
|
|
812
798
|
}
|
|
813
799
|
}
|
|
814
|
-
}
|
|
800
|
+
};
|
|
815
801
|
|
|
816
802
|
this.renderGeometries = (playRate, delta, playAnimation, cameraControls, options, transverse) => {
|
|
817
803
|
this.renderObjects(playRate * delta, playAnimation, cameraControls, options, transverse);
|
|
818
804
|
//process markers visibility and size, as long as there are more than
|
|
819
805
|
//one entry in markersList is greater than 1, markers have been enabled.
|
|
820
|
-
if (options &&
|
|
821
|
-
options.markerCluster?.markerUpdateRequired) {
|
|
806
|
+
if (options && playAnimation === false && options.markerCluster?.markerUpdateRequired) {
|
|
822
807
|
/**
|
|
823
808
|
const markerDepths = Object.values(options.markersList)
|
|
824
809
|
.map((marker) => marker.ndc.z);
|
|
@@ -832,12 +817,12 @@ let Region = function (parentIn, sceneIn) {
|
|
|
832
817
|
*/
|
|
833
818
|
options.markerCluster.calculate();
|
|
834
819
|
}
|
|
835
|
-
}
|
|
820
|
+
};
|
|
836
821
|
|
|
837
822
|
/**
|
|
838
823
|
* Update geometries and glyphsets based on the calculated time.
|
|
839
824
|
*/
|
|
840
|
-
this.createPoints = (
|
|
825
|
+
this.createPoints = (groupName, coords, labels, colour) => {
|
|
841
826
|
let isNew = false;
|
|
842
827
|
const zincObjects = this.findObjectsWithGroupName(groupName, false);
|
|
843
828
|
const index = zincObjects.findIndex((zincObject) => zincObject.isPointset);
|
|
@@ -851,12 +836,12 @@ let Region = function (parentIn, sceneIn) {
|
|
|
851
836
|
this.pickableUpdateRequired = true;
|
|
852
837
|
}
|
|
853
838
|
return { zincObject: pointset, isNew };
|
|
854
|
-
}
|
|
839
|
+
};
|
|
855
840
|
|
|
856
841
|
/**
|
|
857
842
|
* Update geometries and glyphsets based on the calculated time.
|
|
858
843
|
*/
|
|
859
|
-
this.createLines = (
|
|
844
|
+
this.createLines = (groupName, coords, colour) => {
|
|
860
845
|
let isNew = false;
|
|
861
846
|
const zincObjects = this.findObjectsWithGroupName(groupName, false);
|
|
862
847
|
const index = zincObjects.findIndex((zincObject) => zincObject.isLines);
|
|
@@ -870,25 +855,30 @@ let Region = function (parentIn, sceneIn) {
|
|
|
870
855
|
this.pickableUpdateRequired = true;
|
|
871
856
|
}
|
|
872
857
|
return { zincObject: lines, isNew };
|
|
873
|
-
}
|
|
858
|
+
};
|
|
874
859
|
|
|
875
860
|
/**
|
|
876
861
|
* Add a new geometry
|
|
877
862
|
*/
|
|
878
863
|
this.createGeometryFromThreeJSGeometry = (
|
|
879
|
-
groupName,
|
|
864
|
+
groupName,
|
|
865
|
+
geometry,
|
|
866
|
+
colour,
|
|
867
|
+
opacity,
|
|
868
|
+
visibility,
|
|
869
|
+
renderOrder,
|
|
870
|
+
) => {
|
|
880
871
|
const zincGeometry = new Geometry();
|
|
881
872
|
const material = new THREE.MeshPhongMaterial({
|
|
882
|
-
color
|
|
883
|
-
transparent
|
|
884
|
-
opacity
|
|
885
|
-
side
|
|
873
|
+
color: colour,
|
|
874
|
+
transparent: true,
|
|
875
|
+
opacity: opacity,
|
|
876
|
+
side: THREE.DoubleSide,
|
|
877
|
+
});
|
|
878
|
+
zincGeometry.createMesh(geometry, material, {
|
|
879
|
+
localTimeEnabled: false,
|
|
880
|
+
localMorphColour: false,
|
|
886
881
|
});
|
|
887
|
-
zincGeometry.createMesh(
|
|
888
|
-
geometry,
|
|
889
|
-
material,
|
|
890
|
-
{localTimeEnabled: false, localMorphColour: false,},
|
|
891
|
-
);
|
|
892
882
|
if (zincGeometry.getMorph()) {
|
|
893
883
|
zincGeometry.setVisibility(false);
|
|
894
884
|
zincGeometry.setName(groupName);
|
|
@@ -897,7 +887,7 @@ let Region = function (parentIn, sceneIn) {
|
|
|
897
887
|
return zincGeometry;
|
|
898
888
|
}
|
|
899
889
|
return undefined;
|
|
900
|
-
}
|
|
901
|
-
}
|
|
890
|
+
};
|
|
891
|
+
};
|
|
902
892
|
|
|
903
893
|
export { Region };
|