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.
Files changed (60) hide show
  1. package/README.md +27 -22
  2. package/build/zinc.js +2 -2
  3. package/build/zinc.js.map +1 -1
  4. package/package.json +4 -1
  5. package/src/controls.js +1332 -1241
  6. package/src/geometryCSG.js +111 -115
  7. package/src/glyphsetCSG.js +51 -55
  8. package/src/loaders/GLTFToZincJSLoader.js +31 -33
  9. package/src/loaders/JSONLoader.js +339 -449
  10. package/src/loaders/OBJLoader.js +654 -851
  11. package/src/loaders/STLLoader.js +271 -329
  12. package/src/loaders/niftiReader.js +90 -59
  13. package/src/loaders/primitivesLoader.js +55 -52
  14. package/src/minimap.js +63 -43
  15. package/src/primitives/geometry.js +40 -44
  16. package/src/primitives/glyph.js +16 -19
  17. package/src/primitives/glyphset.js +229 -185
  18. package/src/primitives/label.js +29 -31
  19. package/src/primitives/lines.js +20 -20
  20. package/src/primitives/lines2.js +33 -39
  21. package/src/primitives/lod.js +43 -43
  22. package/src/primitives/marker.js +31 -32
  23. package/src/primitives/markerCluster.js +32 -35
  24. package/src/primitives/pointset.js +86 -83
  25. package/src/primitives/texturePrimitive.js +9 -10
  26. package/src/primitives/textureSlides.js +84 -97
  27. package/src/primitives/textureVolume.js +46 -49
  28. package/src/primitives/tubeLines.js +108 -108
  29. package/src/primitives/zincObject.js +176 -184
  30. package/src/region.js +145 -155
  31. package/src/renderRequests.js +3 -3
  32. package/src/renderer.js +635 -620
  33. package/src/scene.js +479 -419
  34. package/src/sceneExporter.js +22 -17
  35. package/src/sceneLoader.js +542 -296
  36. package/src/shaders/rgbVolumeRender.js +11 -18
  37. package/src/shaders/textureArray.js +5 -12
  38. package/src/shaders/textureSlide.js +10 -17
  39. package/src/shaders/volumeRender.js +11 -18
  40. package/src/shaders/volumeRender_old.js +11 -18
  41. package/src/shaders/volumeTexture.js +7 -14
  42. package/src/textSprite.js +23 -19
  43. package/src/texture/texture.js +14 -15
  44. package/src/texture/textureArray.js +14 -16
  45. package/src/three/InstancedPoints.js +2 -9
  46. package/src/three/Loader.js +334 -315
  47. package/src/three/line/Line.js +165 -215
  48. package/src/three/line/LineSegments.js +40 -55
  49. package/src/three/line/LineSegments2.js +322 -366
  50. package/src/three/line/LineSegmentsGeometry.js +239 -280
  51. package/src/three-js-csg.js +260 -252
  52. package/src/tsl/glyphRenderMaterial.js +12 -3
  53. package/src/tsl/glyphTransform.js +51 -29
  54. package/src/tsl/textureSlides.js +23 -24
  55. package/src/utilities.js +309 -371
  56. package/src/videoHandler.js +76 -83
  57. package/src/workers/geometryCSG.worker.js +33 -36
  58. package/src/workers/geometryCSGInternal.js +39 -44
  59. package/src/zinc.js +4 -7
  60. package/vite.config.js +7 -7
@@ -1,17 +1,13 @@
1
1
  import * as THREE from 'three/webgpu';
2
- import {
3
- createBufferGeometry,
4
- getBoundingBox,
5
- removeVertexAtIndex
6
- } from '../utilities';
2
+ import { createBufferGeometry, getBoundingBox, removeVertexAtIndex } from '../utilities';
7
3
  import { LOD } from './lod';
8
4
  import { Marker } from './marker';
9
5
 
10
6
  let uniqueiId = 0;
11
7
 
12
8
  const getUniqueId = function () {
13
- return "pr" + uniqueiId++;
14
- }
9
+ return 'pr' + uniqueiId++;
10
+ };
15
11
 
16
12
  /**
17
13
  * Provides the base object for other primitive types.
@@ -21,7 +17,7 @@ const getUniqueId = function () {
21
17
  * @author Alan Wu
22
18
  * @return {ZincObject}
23
19
  */
24
- const ZincObject = function() {
20
+ const ZincObject = function () {
25
21
  this.isZincObject = true;
26
22
  this.geometry = undefined;
27
23
  // THREE.Mesh
@@ -29,19 +25,19 @@ const ZincObject = function() {
29
25
  this.group = new THREE.Group();
30
26
  this._lod = new LOD(this);
31
27
  /**
32
- * Groupname given to this geometry.
33
- */
28
+ * Groupname given to this geometry.
29
+ */
34
30
  this.groupName = undefined;
35
31
  this.timeEnabled = false;
36
32
  this.morphColour = false;
37
33
  this.inbuildTime = 0;
38
34
  this.mixer = undefined;
39
35
  this.animationGroup = undefined;
40
- /**
41
- * Total duration of the animation, this value interacts with the
42
- * {@link Renderer#playRate} to produce the actual duration of the
43
- * animation. Actual time in second = duration / playRate.
44
- */
36
+ /**
37
+ * Total duration of the animation, this value interacts with the
38
+ * {@link Renderer#playRate} to produce the actual duration of the
39
+ * animation. Actual time in second = duration / playRate.
40
+ */
45
41
  this.duration = 6000;
46
42
  this.clipAction = undefined;
47
43
  this.userData = {};
@@ -54,7 +50,7 @@ const ZincObject = function() {
54
50
  this.anatomicalId = undefined;
55
51
  this.region = undefined;
56
52
  this.animationClip = undefined;
57
- this.markerMode = "inherited";
53
+ this.markerMode = 'inherited';
58
54
  this.uuid = getUniqueId();
59
55
  this._v1 = new THREE.Vector3();
60
56
  this._v2 = new THREE.Vector3();
@@ -69,93 +65,93 @@ const ZincObject = function() {
69
65
  this.origColour = undefined;
70
66
  this.origVertexColors = false;
71
67
  this.isPickable = true;
72
- }
68
+ };
73
69
 
74
70
  /**
75
71
  * Set the duration of the animation of this object.
76
72
  *
77
73
  * @param {Number} durationIn - Duration of the animation.
78
74
  */
79
- ZincObject.prototype.setDuration = function(durationIn) {
75
+ ZincObject.prototype.setDuration = function (durationIn) {
80
76
  this.duration = durationIn;
81
77
  if (this.clipAction) {
82
78
  this.clipAction.setDuration(this.duration);
83
79
  }
84
- }
80
+ };
85
81
 
86
82
  /**
87
83
  * Get the duration of the animation of this object.
88
84
  *
89
85
  * @return {Number}
90
86
  */
91
- ZincObject.prototype.getDuration = function() {
87
+ ZincObject.prototype.getDuration = function () {
92
88
  return this.duration;
93
- }
89
+ };
94
90
 
95
91
  /**
96
92
  * Set the region this object belongs to.
97
93
  *
98
94
  * @param {Region} region
99
95
  */
100
- ZincObject.prototype.setRegion = function(region) {
96
+ ZincObject.prototype.setRegion = function (region) {
101
97
  this.region = region;
102
- }
98
+ };
103
99
 
104
100
  /**
105
101
  * Get the region this object belongs to.
106
102
  *
107
103
  * @return {Region}
108
104
  */
109
- ZincObject.prototype.getRegion = function() {
105
+ ZincObject.prototype.getRegion = function () {
110
106
  return this.region;
111
- }
107
+ };
112
108
 
113
109
  /**
114
110
  * Get the threejs object3D.
115
111
  *
116
112
  * @return {Object}
117
113
  */
118
- /**
114
+ /**
119
115
  * Request the scene to draw the next frame, this is used when render on
120
116
  * demand is enabled. See {@link Renderer#setRenderOnDemand}.
121
117
  */
122
- ZincObject.prototype.requestRender = function() {
118
+ ZincObject.prototype.requestRender = function () {
123
119
  this.region?.getScene?.()?.invalidate?.();
124
- }
120
+ };
125
121
 
126
- ZincObject.prototype.getMorph = function() {
127
- const morph = this._lod.getCurrentMorph();
122
+ ZincObject.prototype.getMorph = function () {
123
+ const morph = this._lod.getCurrentMorph();
128
124
  return morph ? morph : this.morph;
129
- }
125
+ };
130
126
 
131
127
  /**
132
128
  * Get the threejs object3D.
133
129
  *
134
130
  * @return {Object}
135
131
  */
136
- ZincObject.prototype.getGroup = function() {
132
+ ZincObject.prototype.getGroup = function () {
137
133
  return this.group;
138
- }
134
+ };
139
135
 
140
136
  /**
141
137
  * Set the internal threejs object3D.
142
138
  */
143
- ZincObject.prototype.setMorph = function(mesh) {
139
+ ZincObject.prototype.setMorph = function (mesh) {
144
140
  this.morph = mesh;
145
141
  this.group.add(this.morph);
146
142
  //this is the base level object
147
- const distance = this._lod.calculateDistance("far");
143
+ const distance = this._lod.calculateDistance('far');
148
144
  this._lod.addLevel(mesh, distance);
149
145
  this._lod.setMaterial(mesh.material);
150
- }
146
+ };
151
147
 
152
148
  /**
153
149
  * Handle transparent mesh, create a clone for backside rendering if it is
154
150
  * transparent.
155
151
  */
156
- ZincObject.prototype.checkTransparentMesh = function() {
152
+ ZincObject.prototype.checkTransparentMesh = function () {
157
153
  return;
158
- }
154
+ };
159
155
 
160
156
  /**
161
157
  * Set the mesh function for zincObject.
@@ -166,7 +162,7 @@ ZincObject.prototype.checkTransparentMesh = function() {
166
162
  * @param {Boolean} localMorphColour - A flag to indicate either the colour is
167
163
  * time dependent.
168
164
  */
169
- ZincObject.prototype.setMesh = function(mesh, localTimeEnabled, localMorphColour) {
165
+ ZincObject.prototype.setMesh = function (mesh, localTimeEnabled, localMorphColour) {
170
166
  this.requestRender();
171
167
  //Note: we assume all layers are consistent with time frame
172
168
  //Thus adding them to the same animation group should work.
@@ -179,16 +175,18 @@ ZincObject.prototype.setMesh = function(mesh, localTimeEnabled, localMorphColour
179
175
  if (geometry && geometry.morphAttributes) {
180
176
  let morphAttribute = geometry.morphAttributes.position;
181
177
  if (!morphAttribute) {
182
- morphAttribute = geometry.morphAttributes.color ?
183
- geometry.morphAttributes.color :
184
- geometry.morphAttributes.normal;
178
+ morphAttribute = geometry.morphAttributes.color
179
+ ? geometry.morphAttributes.color
180
+ : geometry.morphAttributes.normal;
185
181
  }
186
182
  if (morphAttribute) {
187
183
  this.animationClip = THREE.AnimationClip.CreateClipsFromMorphTargetSequences(
188
- morphAttribute, 10, true);
189
- if (this.animationClip && (this.animationClip[0] != undefined)) {
190
- this.clipAction = this.mixer.clipAction(this.animationClip[0]).setDuration(
191
- this.duration);
184
+ morphAttribute,
185
+ 10,
186
+ true,
187
+ );
188
+ if (this.animationClip && this.animationClip[0] != undefined) {
189
+ this.clipAction = this.mixer.clipAction(this.animationClip[0]).setDuration(this.duration);
192
190
  this.clipAction.loop = THREE.LoopRepeat;
193
191
  this.clipAction.clampWhenFinished = true;
194
192
  this.clipAction.play();
@@ -209,8 +207,8 @@ ZincObject.prototype.setMesh = function(mesh, localTimeEnabled, localMorphColour
209
207
  this.setFrustumCulled(false);
210
208
  } else {
211
209
  if (this.morphColour) {
212
- geometry.setAttribute('morphTarget0', geometry.getAttribute( 'position' ) );
213
- geometry.setAttribute('morphTarget1', geometry.getAttribute( 'position' ) );
210
+ geometry.setAttribute('morphTarget0', geometry.getAttribute('position'));
211
+ geometry.setAttribute('morphTarget1', geometry.getAttribute('position'));
214
212
  }
215
213
  }
216
214
  if (this.morphColour) {
@@ -222,38 +220,38 @@ ZincObject.prototype.setMesh = function(mesh, localTimeEnabled, localMorphColour
222
220
  this.initiateMorphColor();
223
221
  }
224
222
  this.boundingBoxUpdateRequired = true;
225
- }
223
+ };
226
224
 
227
225
  /**
228
226
  * Set isPickable for this ZincObject.
229
227
  *
230
228
  * @param {String} isPickable - Boolean to enable object pick.
231
229
  */
232
- ZincObject.prototype.setIsPickable = function(isPickable) {
230
+ ZincObject.prototype.setIsPickable = function (isPickable) {
233
231
  if (this.isPickable !== isPickable) {
234
232
  this.isPickable = isPickable;
235
233
  if (this.region) this.region.pickableUpdateRequired = true;
236
234
  }
237
- }
235
+ };
238
236
 
239
237
  /**
240
238
  * Set the anatomicalId for this ZincObject.
241
239
  *
242
240
  * @param {String} anatomicalId - Id to be set.
243
241
  */
244
- ZincObject.prototype.setAnatomicalId = function(anatomicalId) {
242
+ ZincObject.prototype.setAnatomicalId = function (anatomicalId) {
245
243
  this.anatomicalId = anatomicalId;
246
- }
244
+ };
247
245
 
248
246
  /**
249
247
  * Set the name for this ZincObject.
250
248
  *
251
249
  * @param {String} groupNameIn - Name to be set.
252
250
  */
253
- ZincObject.prototype.setName = function(groupNameIn) {
251
+ ZincObject.prototype.setName = function (groupNameIn) {
254
252
  this.groupName = groupNameIn;
255
253
  this._lod.setName(groupNameIn);
256
- }
254
+ };
257
255
 
258
256
  /**
259
257
  * Get the local time of this geometry, it returns a value between
@@ -261,21 +259,21 @@ ZincObject.prototype.setName = function(groupNameIn) {
261
259
  *
262
260
  * @return {Number}
263
261
  */
264
- ZincObject.prototype.getCurrentTime = function() {
262
+ ZincObject.prototype.getCurrentTime = function () {
265
263
  if (this.clipAction) {
266
264
  const ratio = this.clipAction.time / this.clipAction._clip.duration;
267
265
  return this.duration * ratio;
268
266
  } else {
269
267
  return this.inbuildTime;
270
268
  }
271
- }
269
+ };
272
270
 
273
271
  /**
274
272
  * Set the local time of this geometry.
275
273
  *
276
274
  * @param {Number} time - Can be any value between 0 to duration.
277
275
  */
278
- ZincObject.prototype.setMorphTime = function(time) {
276
+ ZincObject.prototype.setMorphTime = function (time) {
279
277
  this.requestRender();
280
278
  let timeChanged = false;
281
279
  if (this.clipAction) {
@@ -287,62 +285,56 @@ ZincObject.prototype.setMorphTime = function(time) {
287
285
  timeChanged = true;
288
286
  }
289
287
  if (timeChanged && this.isTimeVarying()) {
290
- this.mixer.update( 0.0 );
288
+ this.mixer.update(0.0);
291
289
  }
292
290
  } else {
293
291
  let newTime = time;
294
- if (time > this.duration)
295
- newTime = this.duration;
296
- else if (0 > time)
297
- newTime = 0;
298
- else
299
- newTime = time;
292
+ if (time > this.duration) newTime = this.duration;
293
+ else if (0 > time) newTime = 0;
294
+ else newTime = time;
300
295
  if (newTime != this.inbuildTime) {
301
296
  this.inbuildTime = newTime;
302
297
  timeChanged = true;
303
298
  }
304
299
  }
305
300
  if (timeChanged) {
306
- if (this.hasMorphPositions())
307
- this.boundingBoxUpdateRequired = true;
301
+ if (this.hasMorphPositions()) this.boundingBoxUpdateRequired = true;
308
302
  this._lod.updateMorphColorAttribute(true);
309
- if (this.timeEnabled)
310
- this.markerUpdateRequired = true;
303
+ if (this.timeEnabled) this.markerUpdateRequired = true;
311
304
  }
312
- }
305
+ };
313
306
 
314
307
  /**
315
308
  * Check if the geometry is time varying.
316
309
  *
317
310
  * @return {Boolean}
318
311
  */
319
- ZincObject.prototype.isTimeVarying = function() {
320
- if (this.timeEnabled || this.morphColour)
321
- return true;
312
+ ZincObject.prototype.isTimeVarying = function () {
313
+ if (this.timeEnabled || this.morphColour) return true;
322
314
  return false;
323
- }
315
+ };
324
316
 
325
317
  /**
326
318
  * Get the visibility of this Geometry.
327
319
  *
328
320
  */
329
- ZincObject.prototype.getVisibility = function() {
321
+ ZincObject.prototype.getVisibility = function () {
330
322
  return this.visible;
331
- }
323
+ };
332
324
 
333
325
  /**
334
326
  * Set the visibility of this Geometry.
335
327
  *
336
328
  * @param {Boolean} visible - a boolean flag indicate the visibility to be set
337
329
  */
338
- ZincObject.prototype.setVisibility = function(visible) {
330
+ ZincObject.prototype.setVisibility = function (visible) {
339
331
  this.requestRender();
340
332
  if (visible !== this.visible) {
341
333
  this.visible = visible;
342
334
  this.group.visible = visible;
343
335
  if (this.region) this.region.pickableUpdateRequired = true;
344
336
  }
345
- }
337
+ };
346
338
 
347
339
  /**
348
340
  * Set the opacity of this Geometry. This function will also set the isTransparent
@@ -351,16 +343,15 @@ ZincObject.prototype.setVisibility = function(visible) {
351
343
  * @param {Number} alpah - Alpha value to set for this geometry,
352
344
  * can be any value between from 0 to 1.0.
353
345
  */
354
- ZincObject.prototype.setAlpha = function(alpha) {
346
+ ZincObject.prototype.setAlpha = function (alpha) {
355
347
  this.requestRender();
356
348
  const material = this._lod._material;
357
349
  let isTransparent = false;
358
- if (alpha < 1.0)
359
- isTransparent = true;
350
+ if (alpha < 1.0) isTransparent = true;
360
351
  material.opacity = alpha;
361
352
  material.transparent = isTransparent;
362
353
  this.checkTransparentMesh();
363
- }
354
+ };
364
355
 
365
356
  /**
366
357
  * The rendering will be culled if it is outside of the frustrum
@@ -369,11 +360,11 @@ ZincObject.prototype.setAlpha = function(alpha) {
369
360
  *
370
361
  * @param {Boolean} flag - Set frustrum culling on/off based on this flag.
371
362
  */
372
- ZincObject.prototype.setFrustumCulled = function(flag) {
363
+ ZincObject.prototype.setFrustumCulled = function (flag) {
373
364
  this.requestRender();
374
365
  //multilayers - set for all layers
375
366
  this._lod.setFrustumCulled(flag);
376
- }
367
+ };
377
368
 
378
369
  /**
379
370
  * Set rather a zinc object should be displayed using per vertex colour or
@@ -381,40 +372,38 @@ ZincObject.prototype.setFrustumCulled = function(flag) {
381
372
  *
382
373
  * @param {Boolean} vertexColors - Set display with vertex color on/off.
383
374
  */
384
- ZincObject.prototype.setVertexColors = function(vertexColors) {
375
+ ZincObject.prototype.setVertexColors = function (vertexColors) {
385
376
  this.requestRender();
386
377
  //multilayers - set for all
387
378
  this._lod.setVertexColors(vertexColors);
388
-
389
- }
379
+ };
390
380
 
391
381
  /**
392
382
  * Get the colour of the mesh.
393
383
  *
394
384
  * @return {THREE.Color}
395
385
  */
396
- ZincObject.prototype.getColour = function() {
397
- if (this._lod._material)
398
- return this._lod._material.color;
399
- return undefined;
400
- }
386
+ ZincObject.prototype.getColour = function () {
387
+ if (this._lod._material) return this._lod._material.color;
388
+ return undefined;
389
+ };
401
390
 
402
391
  /**
403
392
  * Set the colour of the mesh.
404
393
  *
405
394
  * @param {THREE.Color} colour - Colour to be set for this geometry.
406
395
  */
407
- ZincObject.prototype.setColour = function(colour) {
396
+ ZincObject.prototype.setColour = function (colour) {
408
397
  this.requestRender();
409
398
  this._lod.setColour(colour);
410
- }
399
+ };
411
400
 
412
401
  /**
413
402
  * Set the colour of the mesh.
414
403
  *
415
404
  * @param {THREE.Color} colour - Colour to be set for this geometry.
416
405
  */
417
- ZincObject.prototype.setGreyScale = function(flag) {
406
+ ZincObject.prototype.setGreyScale = function (flag) {
418
407
  this.requestRender();
419
408
  if (flag) {
420
409
  if (!this.origColour) {
@@ -422,7 +411,7 @@ ZincObject.prototype.setGreyScale = function(flag) {
422
411
  this.origColour = this._lod._material.color;
423
412
  this.origVertexColors = this._lod._material.vertexColors;
424
413
  this._lod.setVertexColors(false);
425
- this._lod.setColour(new THREE.Color().setHex( 0xBBBBBB ));
414
+ this._lod.setColour(new THREE.Color().setHex(0xbbbbbb));
426
415
  return true;
427
416
  }
428
417
  }
@@ -435,40 +424,40 @@ ZincObject.prototype.setGreyScale = function(flag) {
435
424
  }
436
425
  }
437
426
  return false;
438
- }
427
+ };
439
428
 
440
429
  /**
441
430
  * Get the colour of the mesh in hex string form.
442
431
  *
443
432
  * @return {String}
444
433
  */
445
- ZincObject.prototype.getColourHex = function() {
434
+ ZincObject.prototype.getColourHex = function () {
446
435
  if (!this.morphColour) {
447
436
  if (this._lod._material && this._lod._material.color)
448
437
  return this._lod._material.color.getHexString();
449
438
  }
450
439
  return undefined;
451
- }
440
+ };
452
441
 
453
442
  /**
454
443
  * Set the colour of the mesh using hex in string form.
455
444
  *
456
445
  * @param {String} hex - The colour value in hex form.
457
446
  */
458
- ZincObject.prototype.setColourHex = function(hex) {
447
+ ZincObject.prototype.setColourHex = function (hex) {
459
448
  this.requestRender();
460
449
  this._lod._material.color.setHex(hex);
461
450
  if (this._lod._secondaryMaterial) {
462
451
  this._lod._secondaryMaterial.color.setHex(hex);
463
452
  }
464
- }
453
+ };
465
454
 
466
455
  /**
467
456
  * Set the emissive rgb of the mesh using rgb.
468
457
  *
469
458
  * @param {String} colour - The colour value in rgb form.
470
459
  */
471
- ZincObject.prototype.setEmissiveRGB = function(colour) {
460
+ ZincObject.prototype.setEmissiveRGB = function (colour) {
472
461
  this.requestRender();
473
462
  if (this._lod._material && this._lod._material.emissive) {
474
463
  this._lod._material.emissive.setRGB(...colour);
@@ -476,25 +465,24 @@ ZincObject.prototype.setEmissiveRGB = function(colour) {
476
465
  if (this._lod._secondaryMaterial) {
477
466
  this._lod._secondaryMaterial.emissive.setRGB(...colour);
478
467
  }
479
- }
480
-
468
+ };
481
469
 
482
470
  /**
483
471
  * Set the material of the geometry.
484
472
  *
485
473
  * @param {THREE.Material} material - Material to be set for this geometry.
486
474
  */
487
- ZincObject.prototype.setMaterial = function(material) {
475
+ ZincObject.prototype.setMaterial = function (material) {
488
476
  this.requestRender();
489
477
  this._lod.setMaterial(material);
490
- }
478
+ };
491
479
 
492
480
  /**
493
481
  * Get the index of the closest vertex to centroid.
494
482
  *
495
483
  * @return {Number} - integer index in the array
496
484
  */
497
- ZincObject.prototype.getClosestVertexIndex = function() {
485
+ ZincObject.prototype.getClosestVertexIndex = function () {
498
486
  let closestIndex = -1;
499
487
  const morph = this.getMorph();
500
488
  if (morph && morph.geometry) {
@@ -507,7 +495,7 @@ ZincObject.prototype.getClosestVertexIndex = function() {
507
495
  for (let i = 0; i < position.count; i++) {
508
496
  this._v2.fromArray(position.array, i * 3);
509
497
  currentDistance = this._v2.distanceToSquared(this._v1);
510
- if ((distance == -1) || (distance > currentDistance)) {
498
+ if (distance == -1 || distance > currentDistance) {
511
499
  distance = currentDistance;
512
500
  closestIndex = i;
513
501
  }
@@ -515,14 +503,14 @@ ZincObject.prototype.getClosestVertexIndex = function() {
515
503
  }
516
504
  }
517
505
  return closestIndex;
518
- }
506
+ };
519
507
 
520
508
  /**
521
509
  * Get the closest vertex to centroid.
522
510
  *
523
511
  * @return {THREE.Vector3}
524
512
  */
525
- ZincObject.prototype.getClosestVertex = function(applyMatrixWorld) {
513
+ ZincObject.prototype.getClosestVertex = function (applyMatrixWorld) {
526
514
  let position = new THREE.Vector3();
527
515
  if (this.closestVertexIndex == -1) {
528
516
  this.closestVertexIndex = this.getClosestVertexIndex();
@@ -536,8 +524,7 @@ ZincObject.prototype.getClosestVertex = function(applyMatrixWorld) {
536
524
  for (let i = 0; i < influences.length; i++) {
537
525
  if (influences[i] > 0) {
538
526
  found = true;
539
- this._v1.fromArray(
540
- attributes.position[i].array, this.closestVertexIndex * 3);
527
+ this._v1.fromArray(attributes.position[i].array, this.closestVertexIndex * 3);
541
528
  position.add(this._v1.multiplyScalar(influences[i]));
542
529
  }
543
530
  }
@@ -545,8 +532,7 @@ ZincObject.prototype.getClosestVertex = function(applyMatrixWorld) {
545
532
  return applyMatrixWorld ? position.applyMatrix4(morph.matrixWorld) : position;
546
533
  }
547
534
  } else {
548
- position.fromArray(morph.geometry.attributes.position.array,
549
- this.closestVertexIndex * 3);
535
+ position.fromArray(morph.geometry.attributes.position.array, this.closestVertexIndex * 3);
550
536
  return applyMatrixWorld ? position.applyMatrix4(morph.matrixWorld) : position;
551
537
  }
552
538
  }
@@ -554,14 +540,14 @@ ZincObject.prototype.getClosestVertex = function(applyMatrixWorld) {
554
540
  this.getBoundingBox();
555
541
  position.copy(this.center);
556
542
  return position;
557
- }
543
+ };
558
544
 
559
545
  /**
560
546
  * Get the bounding box of this geometry.
561
547
  *
562
548
  * @return {THREE.Box3}.
563
549
  */
564
- ZincObject.prototype.getBoundingBox = function() {
550
+ ZincObject.prototype.getBoundingBox = function () {
565
551
  if (this.visible) {
566
552
  let morph = this._lod.getCurrentMorph();
567
553
  if (morph && morph.visible) {
@@ -575,12 +561,12 @@ ZincObject.prototype.getBoundingBox = function() {
575
561
  }
576
562
  }
577
563
  return undefined;
578
- }
564
+ };
579
565
 
580
566
  /**
581
567
  * Clear this geometry and free the memory.
582
568
  */
583
- ZincObject.prototype.dispose = function() {
569
+ ZincObject.prototype.dispose = function () {
584
570
  //multilayyers
585
571
  this._lod.dispose();
586
572
  if (this.marker) {
@@ -593,7 +579,7 @@ ZincObject.prototype.dispose = function() {
593
579
  this.group = undefined;
594
580
  this.clipAction = undefined;
595
581
  this.groupName = undefined;
596
- }
582
+ };
597
583
 
598
584
  /**
599
585
  * Check if marker is enabled based on the objects settings with
@@ -601,14 +587,16 @@ ZincObject.prototype.dispose = function() {
601
587
  *
602
588
  * @return {Boolean}
603
589
  */
604
- ZincObject.prototype.markerIsRequired = function(options) {
605
- if (this.visible &&
606
- (this.markerMode === "on" || (options && options.displayMarkers &&
607
- (this.markerMode === "inherited")))) {
608
- return true;
590
+ ZincObject.prototype.markerIsRequired = function (options) {
591
+ if (
592
+ this.visible &&
593
+ (this.markerMode === 'on' ||
594
+ (options && options.displayMarkers && this.markerMode === 'inherited'))
595
+ ) {
596
+ return true;
609
597
  }
610
598
  return false;
611
- }
599
+ };
612
600
 
613
601
  //geometry -> whether its morph targets move the vertices
614
602
  const morphPositionsCache = new WeakMap();
@@ -619,14 +607,12 @@ const morphPositionsCache = new WeakMap();
619
607
  *
620
608
  * @return {Boolean}
621
609
  */
622
- ZincObject.prototype.hasMorphPositions = function() {
610
+ ZincObject.prototype.hasMorphPositions = function () {
623
611
  const geometry = this.getMorph()?.geometry;
624
612
  const morphPositions = geometry?.morphAttributes?.position;
625
- if (!morphPositions || morphPositions.length === 0)
626
- return false;
613
+ if (!morphPositions || morphPositions.length === 0) return false;
627
614
  const cached = morphPositionsCache.get(geometry);
628
- if (cached && cached.morphPositions === morphPositions)
629
- return cached.result;
615
+ if (cached && cached.morphPositions === morphPositions) return cached.result;
630
616
  //Colour only morphs use placeholder targets identical to the base
631
617
  //positions, these never move the vertices.
632
618
  const basePositions = geometry.getAttribute('position')?.array;
@@ -646,15 +632,13 @@ ZincObject.prototype.hasMorphPositions = function() {
646
632
  }
647
633
  morphPositionsCache.set(geometry, { morphPositions, result });
648
634
  return result;
649
- }
635
+ };
650
636
 
651
637
  /**
652
638
  * Update the marker's position and size based on current viewport.
653
639
  */
654
- ZincObject.prototype.updateMarker = function(playAnimation, options) {
655
- if ((playAnimation == false) &&
656
- (this.markerIsRequired(options)))
657
- {
640
+ ZincObject.prototype.updateMarker = function (playAnimation, options) {
641
+ if (playAnimation == false && this.markerIsRequired(options)) {
658
642
  let ndcToBeUpdated = options.ndcToBeUpdated;
659
643
  if (this.groupName) {
660
644
  if (!this.marker) {
@@ -670,9 +654,8 @@ ZincObject.prototype.updateMarker = function(playAnimation, options) {
670
654
  }
671
655
  }
672
656
  if (!this.marker.isEnabled()) {
673
- if (options.markersList &&
674
- (!(this.marker.uuid in options.markersList))) {
675
- ndcToBeUpdated = true;
657
+ if (options.markersList && !(this.marker.uuid in options.markersList)) {
658
+ ndcToBeUpdated = true;
676
659
  options.markersList[this.marker.uuid] = this.marker;
677
660
  }
678
661
  this.marker.enable();
@@ -695,41 +678,40 @@ ZincObject.prototype.updateMarker = function(playAnimation, options) {
695
678
  if (this.marker && this.marker.isEnabled()) {
696
679
  this.marker.disable();
697
680
  this.group.remove(this.marker.morph);
698
- if (options?.markersList &&
699
- (this.marker.uuid in options.markersList)) {
681
+ if (options?.markersList && this.marker.uuid in options.markersList) {
700
682
  options.markerCluster.markerUpdateRequired = true;
701
683
  delete options.markersList[this.marker.uuid];
702
684
  }
703
685
  }
704
686
  this.markerUpdateRequired = true;
705
687
  }
706
- }
688
+ };
707
689
 
708
- ZincObject.prototype.processMarkerVisual = function(min, max) {
690
+ ZincObject.prototype.processMarkerVisual = function (min, max) {
709
691
  if (this.marker && this.marker.isEnabled()) {
710
692
  this.marker.updateVisual(min, max);
711
693
  }
712
- }
694
+ };
713
695
 
714
- ZincObject.prototype.initiateMorphColor = function() {
696
+ ZincObject.prototype.initiateMorphColor = function () {
715
697
  //Multilayers - set all
716
698
  if (this.morphColour == 1) {
717
699
  this._lod.updateMorphColorAttribute(false);
718
700
  }
719
- }
701
+ };
720
702
 
721
- ZincObject.prototype.setRenderOrder = function(renderOrder) {
703
+ ZincObject.prototype.setRenderOrder = function (renderOrder) {
722
704
  this.requestRender();
723
705
  //multiilayers
724
706
  this._lod.setRenderOrder(renderOrder);
725
- }
707
+ };
726
708
 
727
709
  /**
728
710
  * Get the windows coordinates.
729
711
  *
730
712
  * @return {Object} - position and rather the closest vertex is on screen.
731
713
  */
732
- ZincObject.prototype.getClosestVertexDOMElementCoords = function(scene) {
714
+ ZincObject.prototype.getClosestVertexDOMElementCoords = function (scene) {
733
715
  if (scene && scene.camera) {
734
716
  let inView = true;
735
717
  const position = this.getClosestVertex(true);
@@ -739,11 +721,11 @@ ZincObject.prototype.getClosestVertexDOMElementCoords = function(scene) {
739
721
  inView = false;
740
722
  }
741
723
  scene.getZincCameraControls().getRelativeCoordsFromNDC(position.x, position.y, position);
742
- return {position, inView};
724
+ return { position, inView };
743
725
  } else {
744
726
  return undefined;
745
727
  }
746
- }
728
+ };
747
729
 
748
730
  /**
749
731
  * Set marker mode for this zinc object which determine rather the
@@ -757,13 +739,13 @@ ZincObject.prototype.getClosestVertexDOMElementCoords = function(scene) {
757
739
  *
758
740
  * @return {Boolean}
759
741
  */
760
- ZincObject.prototype.setMarkerMode = function(mode, options) {
742
+ ZincObject.prototype.setMarkerMode = function (mode, options) {
761
743
  this.requestRender();
762
744
  if (mode !== this.markerMode) {
763
- if (mode === "on" || mode === "off") {
745
+ if (mode === 'on' || mode === 'off') {
764
746
  this.markerMode = mode;
765
747
  } else {
766
- this.markerMode = "inherited";
748
+ this.markerMode = 'inherited';
767
749
  }
768
750
  if (this.region) {
769
751
  this.region.pickableUpdateRequired = true;
@@ -773,48 +755,44 @@ ZincObject.prototype.getClosestVertexDOMElementCoords = function(scene) {
773
755
  this.markerNumber = options.number;
774
756
  this.markerImgURL = options.imgURL;
775
757
  }
776
- }
758
+ };
777
759
 
778
760
  //Update the geometry and colours depending on the morph.
779
- ZincObject.prototype.render = function(delta, playAnimation,
780
- cameraControls, options) {
761
+ ZincObject.prototype.render = function (delta, playAnimation, cameraControls, options) {
781
762
  if (this.visible && !(this.timeEnabled && playAnimation)) {
782
763
  this._lod.update(cameraControls, this.center);
783
764
  }
784
765
  if (playAnimation == true) {
785
- if ((this.clipAction) && this.isTimeVarying()) {
786
- this.mixer.update( delta );
787
- }
788
- else {
766
+ if (this.clipAction && this.isTimeVarying()) {
767
+ this.mixer.update(delta);
768
+ } else {
789
769
  let targetTime = this.inbuildTime + delta;
790
- if (targetTime > this.duration)
791
- targetTime = targetTime - this.duration;
770
+ if (targetTime > this.duration) targetTime = targetTime - this.duration;
792
771
  this.inbuildTime = targetTime;
793
772
  }
794
773
  //multilayers
795
774
  if (this.visible && delta != 0) {
796
775
  //Only vertices morphing can change the bounding box
797
- if (this.hasMorphPositions())
798
- this.boundingBoxUpdateRequired = true;
776
+ if (this.hasMorphPositions()) this.boundingBoxUpdateRequired = true;
799
777
  if (this.morphColour == 1) {
800
778
  this._lod.updateMorphColorAttribute(true);
801
779
  }
802
780
  }
803
781
  }
804
782
  this.updateMarker(playAnimation, options);
805
- }
783
+ };
806
784
 
807
785
  /**
808
786
  * Add lod from an url into the lod object.
809
787
  */
810
- ZincObject.prototype.addLOD = function(loader, level, url, index, preload) {
788
+ ZincObject.prototype.addLOD = function (loader, level, url, index, preload) {
811
789
  this._lod.addLevelFromURL(loader, level, url, index, preload);
812
- }
790
+ };
813
791
 
814
792
  /**
815
793
  * Add lod from an url into the lod object.
816
794
  */
817
- ZincObject.prototype.addVertices = function(coords) {
795
+ ZincObject.prototype.addVertices = function (coords) {
818
796
  this.requestRender();
819
797
  let mesh = this.getMorph();
820
798
  let geometry = undefined;
@@ -823,9 +801,9 @@ ZincObject.prototype.addVertices = function(coords) {
823
801
  this.drawRange = coords.length;
824
802
  } else {
825
803
  if (this.drawRange > -1) {
826
- const positionAttribute = mesh.geometry.getAttribute( 'position' );
827
- coords.forEach(coord => {
828
- positionAttribute.setXYZ(this.drawRange, coord[0], coord[1], coord[2])
804
+ const positionAttribute = mesh.geometry.getAttribute('position');
805
+ coords.forEach((coord) => {
806
+ positionAttribute.setXYZ(this.drawRange, coord[0], coord[1], coord[2]);
829
807
  ++this.drawRange;
830
808
  });
831
809
  positionAttribute.needsUpdate = true;
@@ -837,12 +815,12 @@ ZincObject.prototype.addVertices = function(coords) {
837
815
  }
838
816
  }
839
817
  return geometry;
840
- }
818
+ };
841
819
 
842
820
  /**
843
821
  * Add lod from an url into the lod object.
844
822
  */
845
- ZincObject.prototype.deleteVertices = function(index) {
823
+ ZincObject.prototype.deleteVertices = function (index) {
846
824
  this.requestRender();
847
825
  let mesh = this.getMorph();
848
826
  if (mesh?.geometry && this.drawRange >= index) {
@@ -856,12 +834,12 @@ ZincObject.prototype.deleteVertices = function(index) {
856
834
  }
857
835
  }
858
836
  return false;
859
- }
837
+ };
860
838
 
861
839
  /**
862
840
  * Set the objects position.
863
841
  */
864
- ZincObject.prototype.setPosition = function(x, y, z) {
842
+ ZincObject.prototype.setPosition = function (x, y, z) {
865
843
  this.requestRender();
866
844
  const group = this.getGroup();
867
845
  if (group) {
@@ -871,17 +849,32 @@ ZincObject.prototype.setPosition = function(x, y, z) {
871
849
  group.updateWorldMatrix(true, true);
872
850
  this.boundingBoxUpdateRequired = true;
873
851
  }
874
- }
875
-
876
- ZincObject.prototype.loadAdditionalSources = function(primitivesLoader, sources) {
877
- primitivesLoader.load(filename, meshloader(region, colour, opacity, localTimeEnabled, localMorphColour, undefined, undefined,
878
- undefined, undefined, finishCallback), this.onProgress(filename), this.onError(finishCallback));
879
- }
852
+ };
853
+
854
+ ZincObject.prototype.loadAdditionalSources = function (primitivesLoader, sources) {
855
+ primitivesLoader.load(
856
+ filename,
857
+ meshloader(
858
+ region,
859
+ colour,
860
+ opacity,
861
+ localTimeEnabled,
862
+ localMorphColour,
863
+ undefined,
864
+ undefined,
865
+ undefined,
866
+ undefined,
867
+ finishCallback,
868
+ ),
869
+ this.onProgress(filename),
870
+ this.onError(finishCallback),
871
+ );
872
+ };
880
873
 
881
874
  /**
882
875
  * Set the objects scale.
883
876
  */
884
- ZincObject.prototype.setScaleAll = function(scale) {
877
+ ZincObject.prototype.setScaleAll = function (scale) {
885
878
  this.requestRender();
886
879
  const group = this.getGroup();
887
880
  if (group) {
@@ -889,7 +882,6 @@ ZincObject.prototype.setScaleAll = function(scale) {
889
882
  group.updateMatrix();
890
883
  this.boundingBoxUpdateRequired = true;
891
884
  }
892
- }
885
+ };
893
886
 
894
887
  export { ZincObject };
895
-