zincjs 1.16.1 → 1.16.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zincjs",
3
- "version": "1.16.1",
3
+ "version": "1.16.2",
4
4
  "description": "ZincJS (Web-based-Zinc-Visualisation)",
5
5
  "main": "build/zinc.js",
6
6
  "directories": {
@@ -2,7 +2,7 @@ const THREE = require('three');
2
2
  const resolveURL = require('../utilities').resolveURL;
3
3
  /**
4
4
  * Provides a base class object which stores textures and rendering object.
5
- *
5
+ *
6
6
  * @class
7
7
  * @author Alan Wu
8
8
  * @return {TexturePrimitive}
@@ -14,7 +14,7 @@ const TexturePrimitive = function (textureIn) {
14
14
 
15
15
  /**
16
16
  * Load texture data into this primitves.
17
- *
17
+ *
18
18
  * @param {Object} textureData - contains the informations about the textures.
19
19
  * @param {Function} finishCallback - User's function to be called once texture's
20
20
  * is loaded.
@@ -39,7 +39,7 @@ const TexturePrimitive = function (textureIn) {
39
39
  /**
40
40
  * Initialise a texture based on the provided textureData, this should be used
41
41
  * internally only.
42
- *
42
+ *
43
43
  * @param {Object} textureData - contains the informations about the textures.
44
44
  * @param {Function} finishCallback - User's function to be called once texture's
45
45
  * is loaded.
@@ -3,10 +3,10 @@ const shader = require("../shaders/textureSlide.js");
3
3
  /**
4
4
  * Provides a class which create a texture stacks in a block
5
5
  * with shaders allowing slices of texture to be displayed.
6
- *
6
+ *
7
7
  * @param {TextureArray} textureIn - An object of texture array
8
8
  * holding texture information.
9
- *
9
+ *
10
10
  * @class
11
11
  * @author Alan Wu
12
12
  * @return {TextureSlides}
@@ -29,13 +29,13 @@ const TextureSlides = function (textureIn) {
29
29
  direction the slide should be facing.
30
30
  @property {Number} value - Normalised value of the location on direction.
31
31
  @property {String} id - ID of the mesh, it is only available if the settings
32
- is returned from {@link TextureSlides.createSlide} or
32
+ is returned from {@link TextureSlides.createSlide} or
33
33
  {@link TextureSlides.getTextureSettings}.
34
34
  */
35
35
  /**
36
36
  * Create the slides required for visualisation based on the slide settings.
37
37
  * The slides themselves are {THREE.PlanGeometry} objects.
38
- *
38
+ *
39
39
  * @param {SLIDE_SETTINGS} slideSettings - An array to each slide settings.
40
40
  */
41
41
  this.createSlides = slideSettings => {
@@ -114,7 +114,7 @@ const TextureSlides = function (textureIn) {
114
114
  uniforms.diffuse.value = this.texture.impl;
115
115
  uniforms.depth.value = this.texture.size.depth;
116
116
  uniforms.flipY.value = flipY;
117
-
117
+
118
118
  const options = {
119
119
  fs: shader.fs,
120
120
  vs: shader.vs,
@@ -259,7 +259,7 @@ const TextureSlides = function (textureIn) {
259
259
  * Get the bounding box of this slides.
260
260
  * It uses the max and min of the slides position and the
261
261
  * transformation to calculate the position of the box.
262
- *
262
+ *
263
263
  * @return {THREE.Box3}.
264
264
  */
265
265
  this.getBoundingBox = () => {
@@ -10,7 +10,7 @@ const PrimitivesLoader = require('./loaders/primitivesLoader').PrimitivesLoader;
10
10
  /**
11
11
  * A helper class to help with reading / importing primitives and
12
12
  * settings into a {@link Scene}.
13
- *
13
+ *
14
14
  * @class
15
15
  * @param {Object} containerIn - Container to create the renderer on.
16
16
  * @author Alan Wu
@@ -27,7 +27,7 @@ exports.SceneLoader = function (sceneIn) {
27
27
  * This function returns a three component array, which contains
28
28
  * [totalsize, totalLoaded and errorDownload] of all the downloads happening
29
29
  * in this scene.
30
- * @returns {Array}
30
+ * @returns {Array}
31
31
  */
32
32
  this.getDownloadProgress = () => {
33
33
  let totalSize = 0;
@@ -134,7 +134,7 @@ exports.SceneLoader = function (sceneIn) {
134
134
  /**
135
135
  * Load a legacy model(s) format with the provided URLs and parameters. This only loads the geometry
136
136
  * without any of the metadata. Therefore, extra parameters should be provided.
137
- *
137
+ *
138
138
  * @deprecated
139
139
  */
140
140
  this.loadModelsURL = (region, urls, colours, opacities, timeEnabled, morphColour, finishCallback) => {
@@ -160,10 +160,10 @@ exports.SceneLoader = function (sceneIn) {
160
160
  }
161
161
 
162
162
  /**
163
- * Load a legacy file format containing the viewport and its meta file from an external
163
+ * Load a legacy file format containing the viewport and its meta file from an external
164
164
  * location provided by the url. Use the new metadata format with
165
165
  * {@link Zinc.SceneLoader.#loadMetadataURL} instead.
166
- *
166
+ *
167
167
  * @param {String} URL - address to the file containing viewport and model information.
168
168
  * @deprecated
169
169
  */
@@ -223,11 +223,11 @@ exports.SceneLoader = function (sceneIn) {
223
223
  if (finishCallback != undefined && (typeof finishCallback == 'function'))
224
224
  finishCallback(newLines);
225
225
  };
226
- }
226
+ }
227
227
 
228
228
  /**
229
229
  * Load lines into this scene object.
230
- *
230
+ *
231
231
  * @param {Boolean} timeEnabled - Indicate if morphing is enabled.
232
232
  * @param {Boolean} morphColour - Indicate if color morphing is enabled.
233
233
  * @param {STRING} groupName - name to assign the pointset's groupname to.
@@ -251,7 +251,7 @@ exports.SceneLoader = function (sceneIn) {
251
251
  (linesloader(region, localTimeEnabled, localMorphColour, groupName, anatomicalId,
252
252
  renderOrder, options.lod, tubeLines, finishCallback))( object.geometry, object.materials );
253
253
  } else {
254
- primitivesLoader.load(url, linesloader(region, localTimeEnabled, localMorphColour, groupName,
254
+ primitivesLoader.load(url, linesloader(region, localTimeEnabled, localMorphColour, groupName,
255
255
  anatomicalId, renderOrder, options.lod, tubeLines, finishCallback), this.onProgress(url), this.onError(finishCallback),
256
256
  options.loaderOptions);
257
257
  }
@@ -326,8 +326,8 @@ exports.SceneLoader = function (sceneIn) {
326
326
 
327
327
  /**
328
328
  * Read a STL file into this scene, the geometry will be presented as
329
- * {@link Zinc.Geometry}.
330
- *
329
+ * {@link Zinc.Geometry}.
330
+ *
331
331
  * @param {STRING} url - location to the STL file.
332
332
  * @param {STRING} groupName - name to assign the geometry's groupname to.
333
333
  * @param {Function} finishCallback - Callback function which will be called
@@ -345,8 +345,8 @@ exports.SceneLoader = function (sceneIn) {
345
345
 
346
346
  /**
347
347
  * Read a OBJ file into this scene, the geometry will be presented as
348
- * {@link Zinc.Geometry}.
349
- *
348
+ * {@link Zinc.Geometry}.
349
+ *
350
350
  * @param {STRING} url - location to the STL file.
351
351
  * @param {STRING} groupName - name to assign the geometry's groupname to.
352
352
  * @param {Function} finishCallback - Callback function which will be called
@@ -363,10 +363,10 @@ exports.SceneLoader = function (sceneIn) {
363
363
  }
364
364
 
365
365
  /**
366
- * Load a geometry into this scene, this is a subsequent called from
366
+ * Load a geometry into this scene, this is a subsequent called from
367
367
  * {@link Zinc.Scene#loadMetadataURL}, although it can be used to read
368
368
  * in geometry into the scene externally.
369
- *
369
+ *
370
370
  * @param {String} url - regular json model file providing geometry.
371
371
  * @param {Boolean} timeEnabled - Indicate if geometry morphing is enabled.
372
372
  * @param {Boolean} morphColour - Indicate if color morphing is enabled.
@@ -432,14 +432,14 @@ exports.SceneLoader = function (sceneIn) {
432
432
  if (zincCameraControls) {
433
433
  zincCameraControls.calculateMaxAllowedDistance(scene);
434
434
  }
435
- }
435
+ }
436
436
  }
437
437
  };
438
438
  };
439
439
 
440
440
  /**
441
441
  * Load a pointset into this scene object.
442
- *
442
+ *
443
443
  * @param {Boolean} timeEnabled - Indicate if morphing is enabled.
444
444
  * @param {Boolean} morphColour - Indicate if color morphing is enabled.
445
445
  * @param {STRING} groupName - name to assign the pointset's groupname to.
@@ -487,6 +487,8 @@ exports.SceneLoader = function (sceneIn) {
487
487
  if (newTexture) {
488
488
  newTexture.groupName = groupName;
489
489
  let myCallback = () => {
490
+ //Add zincObject after it has sort out all the required download
491
+ region.addZincObject(newTexture);
490
492
  --this.toBeDownloaded;
491
493
  if (finishCallback != undefined && (typeof finishCallback == 'function'))
492
494
  finishCallback(newTexture);
@@ -495,7 +497,6 @@ exports.SceneLoader = function (sceneIn) {
495
497
  newTexture.load(textureData, myCallback, isInline);
496
498
  newTexture.setAnatomicalId(anatomicalId);
497
499
  newTexture.setRenderOrder(renderOrder);
498
- region.addZincObject(newTexture);
499
500
  }
500
501
  }
501
502
  };
@@ -513,7 +514,7 @@ exports.SceneLoader = function (sceneIn) {
513
514
 
514
515
  /**
515
516
  * Load a texture into this scene object.
516
- *
517
+ *
517
518
  * @param {STRING} groupName - name to assign the pointset's groupname to.
518
519
  * @param {Function} finishCallback - Callback function which will be called
519
520
  * once the glyphset is succssfully load in.
@@ -533,8 +534,8 @@ exports.SceneLoader = function (sceneIn) {
533
534
 
534
535
  /**
535
536
  * Load a glyphset into this scene object.
536
- *
537
- * @param {String} metaurl - Provide informations such as transformations, colours
537
+ *
538
+ * @param {String} metaurl - Provide informations such as transformations, colours
538
539
  * and others for each of the glyph in the glyphsset.
539
540
  * @param {String} glyphurl - regular json model file providing geometry of the glyph.
540
541
  * @param {String} groupName - name to assign the glyphset's groupname to.
@@ -556,7 +557,7 @@ exports.SceneLoader = function (sceneIn) {
556
557
 
557
558
  /**
558
559
  * Add a user provided {THREE.Geometry} into the scene as zinc geometry.
559
- *
560
+ *
560
561
  * @param {Three.Geometry} geometry - The threejs geometry to be added as {@link Zinc.Geometry}.
561
562
  * @param {THREE.Color} color - Colour to be assigned to this geometry, overrided if materialIn is provided.
562
563
  * @param {Number} opacity - Opacity to be set for this geometry, overrided if materialIn is provided.
@@ -565,7 +566,7 @@ exports.SceneLoader = function (sceneIn) {
565
566
  * @param {Boolean} external - Set this to true if morph geometry is present, overrided if materialIn is provided.
566
567
  * @param {Function} finishCallback - Callback once the geometry has been added succssfully.
567
568
  * @param {THREE.Material} materialIn - Material to be set for this geometry if it is present.
568
- *
569
+ *
569
570
  * @returns {Zinc.Geometry}
570
571
  */
571
572
  const addZincGeometry = (
@@ -621,7 +622,7 @@ exports.SceneLoader = function (sceneIn) {
621
622
  if (materials && materials[0]) {
622
623
  material = materials[0];
623
624
  }
624
- const zincGeometry = addZincGeometry(region, geometry, colour, opacity,
625
+ const zincGeometry = addZincGeometry(region, geometry, colour, opacity,
625
626
  localTimeEnabled, localMorphColour, undefined, material, groupName, renderOrder, anatomicalId);
626
627
  if (options.lod && options.lod.levels) {
627
628
  for (const [key, value] of Object.entries(options.lod.levels)) {
@@ -639,7 +640,7 @@ exports.SceneLoader = function (sceneIn) {
639
640
  //Turn ISO 8601 duration string into an array.
640
641
  const parseDuration = (durationString) => {
641
642
  const regex = /P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;
642
- const [, years, months, weeks, days, hours, mins, secs] =
643
+ const [, years, months, weeks, days, hours, mins, secs] =
643
644
  durationString.match(regex);
644
645
  return {years: years,months: months, weeks: weeks, days: days,
645
646
  hours: hours, mins: mins, secs: secs };
@@ -708,7 +709,7 @@ exports.SceneLoader = function (sceneIn) {
708
709
  lod: lod,
709
710
  renderOrder: order
710
711
  };
711
-
712
+
712
713
  switch (item.Type) {
713
714
  case "Surfaces":
714
715
  loadSurfaceURL(region, newURL, item.MorphVertices, item.MorphColours, groupName, finishCallback, options);
@@ -776,7 +777,7 @@ exports.SceneLoader = function (sceneIn) {
776
777
 
777
778
  /**
778
779
  * Load GLTF into this scene object.
779
- *
780
+ *
780
781
  * @param {String} url - URL to the GLTF file
781
782
  * @param {Function} finishCallback - Callback function which will be called
782
783
  * once the glyphset is succssfully load in.
@@ -879,7 +880,7 @@ exports.SceneLoader = function (sceneIn) {
879
880
  }
880
881
 
881
882
  let getNumberOfObjectsInRegions = (regionJson) => {
882
- let counts = regionJson.Primitives ?
883
+ let counts = regionJson.Primitives ?
883
884
  getNumberOfDownloadsInArray(regionJson.Primitives, false) : 0;
884
885
  if (regionJson.Children) {
885
886
  Object.values(regionJson.Children).forEach(childRegion => {
@@ -936,7 +937,7 @@ exports.SceneLoader = function (sceneIn) {
936
937
  /**
937
938
  * Load a metadata file from the provided URL into this scene. Once
938
939
  * succssful scene proceeds to read each items into scene for visualisations.
939
- *
940
+ *
940
941
  * @param {String} url - Location of the metadata file
941
942
  * @param {Function} finishCallback - Callback function which will be called
942
943
  * @param {options} Optional settings, it can be used to ignore some regions/groups