zincjs 1.13.0 → 1.13.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.13.0",
3
+ "version": "1.13.2",
4
4
  "description": "ZincJS (Web-based-Zinc-Visualisation)",
5
5
  "main": "build/zinc.js",
6
6
  "directories": {
@@ -92,10 +92,18 @@ Object.assign( JSONLoader.prototype, {
92
92
  }
93
93
 
94
94
  if (scope && scope.parse) {
95
- var object = scope.parse( json, texturePath );
96
- onLoad( object.geometry, object.materials );
97
- }
98
-
95
+ try {
96
+ var object = scope.parse( json, texturePath );
97
+ onLoad( object.geometry, object.materials );
98
+ } catch (e) {
99
+ console.error("The loader has encountered aon loading the geometry");
100
+ console.error(e);
101
+ if (onError) {
102
+ onError({responseURL: url});
103
+ return;
104
+ }
105
+ }
106
+ }
99
107
  }, onProgress, onError );
100
108
 
101
109
  },
@@ -19,6 +19,7 @@ const TextureSlides = function (textureIn) {
19
19
  this.morph = new THREE.Group();
20
20
  this.group = this.morph;
21
21
  this.morph.userData = this;
22
+ let edgesLine = undefined;
22
23
  let flipY = true;
23
24
 
24
25
  /**
@@ -59,7 +60,7 @@ const TextureSlides = function (textureIn) {
59
60
  mesh.position.z = 0;
60
61
  switch (settings.direction) {
61
62
  case "x":
62
- const rotation = flipY ? -Math.PI / 2 : Math.PI / 2;
63
+ const rotation = -Math.PI / 2;
63
64
  mesh.rotation.y = rotation;
64
65
  uniforms.direction.value = 1;
65
66
  uniforms.slide.value.set(settings.value, 0, 0);
@@ -225,30 +226,32 @@ const TextureSlides = function (textureIn) {
225
226
 
226
227
  //Expand the boundingbox with slide settings
227
228
  const expandBoxWithSettings = (box, settings, vector) => {
228
- switch (settings.direction.value) {
229
- case 1:
230
- vector.copy(settings.slide.value);
231
- box.expandByPoint(vector);
232
- vector.setY(1.0);
233
- vector.setZ(1.0);
234
- box.expandByPoint(vector);
235
- break;
236
- case 2:
237
- vector.copy(settings.slide.value);
238
- box.expandByPoint(vector);
239
- vector.setX(1.0);
240
- vector.setZ(1.0);
241
- box.expandByPoint(vector);
242
- break;
243
- case 3:
244
- vector.copy(settings.slide.value);
245
- box.expandByPoint(vector);
246
- vector.setX(1.0);
247
- vector.setY(1.0);
248
- box.expandByPoint(vector);
249
- break;
250
- default:
251
- break;
229
+ if (settings) {
230
+ switch (settings.direction.value) {
231
+ case 1:
232
+ vector.copy(settings.slide.value);
233
+ box.expandByPoint(vector);
234
+ vector.setY(1.0);
235
+ vector.setZ(1.0);
236
+ box.expandByPoint(vector);
237
+ break;
238
+ case 2:
239
+ vector.copy(settings.slide.value);
240
+ box.expandByPoint(vector);
241
+ vector.setX(1.0);
242
+ vector.setZ(1.0);
243
+ box.expandByPoint(vector);
244
+ break;
245
+ case 3:
246
+ vector.copy(settings.slide.value);
247
+ box.expandByPoint(vector);
248
+ vector.setX(1.0);
249
+ vector.setY(1.0);
250
+ box.expandByPoint(vector);
251
+ break;
252
+ default:
253
+ break;
254
+ }
252
255
  }
253
256
  }
254
257
 
@@ -303,9 +306,13 @@ const TextureSlides = function (textureIn) {
303
306
  this.boundingBoxUpdateRequired = true;
304
307
  }
305
308
 
309
+ this.setRenderOrder = (order) => {
310
+ //multiilayers
311
+ this.morph.renderOrder = order;
312
+ }
313
+
306
314
  this.initialise = (textureData, finishCallback) => {
307
315
  if (textureData) {
308
-
309
316
  const locations = textureData.locations;
310
317
  if (locations && locations.length > 0) {
311
318
  this.applyTransformation(locations[0].orientation,
@@ -320,6 +327,25 @@ const TextureSlides = function (textureIn) {
320
327
  }
321
328
  }
322
329
  }
330
+
331
+ this.showEdges = (color) => {
332
+ if (!edgesLine) {
333
+ const geometry = new THREE.BoxGeometry( 1, 1, 1 );
334
+ geometry.translate(0.5, 0.5, 0.5);
335
+ const edges = new THREE.EdgesGeometry( geometry );
336
+ edgesLine = new THREE.LineSegments(edges, new THREE.LineBasicMaterial( { color } ) );
337
+ this.group.add( edgesLine );
338
+ } else {
339
+ edgesLine.material.color = color;
340
+ }
341
+ edgesLine.visible = true;
342
+ }
343
+
344
+ this.hideEdges = () => {
345
+ if (edgesLine) {
346
+ edgesLine.visible = false;
347
+ }
348
+ }
323
349
  }
324
350
 
325
351
  TextureSlides.prototype = Object.create((require('./texturePrimitive').TexturePrimitive).prototype);
package/src/scene.js CHANGED
@@ -820,7 +820,7 @@ exports.Scene = function (containerIn, rendererIn) {
820
820
  const newVec1 = new THREE.Vector3();
821
821
  const newVec2 = new THREE.Vector3();
822
822
  newVec1.subVectors(target, eyePosition).normalize();
823
- newVec2.subVectors(target, center).normalize();
823
+ newVec2.subVectors(target, _v3).normalize();
824
824
  const newVec3 = new THREE.Vector3();
825
825
  newVec3.crossVectors(newVec1, newVec2);
826
826
  const angle = newVec1.angleTo(newVec2);
@@ -858,7 +858,7 @@ exports.Scene = function (containerIn, rendererIn) {
858
858
  }
859
859
 
860
860
  /**
861
- * Transition the camera into viewing the zinc object with a
861
+ * Transition the camera into viewing the zinc object wiexports.Scene.alignBoundingBoxToCameraViewth a
862
862
  * smooth transition within the providied transitionTime.
863
863
  *
864
864
  * @param {ZincObject} zincObject - the bounding box to target
@@ -888,13 +888,13 @@ exports.Scene = function (containerIn, rendererIn) {
888
888
  const newVec1 = new THREE.Vector3();
889
889
  const newVec2 = new THREE.Vector3();
890
890
  newVec1.subVectors(eyePosition, target);
891
- newVec2.addVectors(center, newVec1);
891
+ newVec2.addVectors(_v3, newVec1);
892
892
  viewport.eyePosition[0] = newVec2.x;
893
893
  viewport.eyePosition[1] = newVec2.y;
894
894
  viewport.eyePosition[2] = newVec2.z;
895
- viewport.targetPosition[0] = center.x;
896
- viewport.targetPosition[1] = center.y;
897
- viewport.targetPosition[2] = center.z;
895
+ viewport.targetPosition[0] = _v3.x;
896
+ viewport.targetPosition[1] = _v3.y;
897
+ viewport.targetPosition[2] = _v3.z;
898
898
  this.getZincCameraControls().setCurrentCameraSettings(viewport);
899
899
  markerCluster.markerUpdateRequired = true;
900
900
  }
@@ -60,7 +60,7 @@ exports.SceneLoader = function (sceneIn) {
60
60
  return xhr => {
61
61
  this.toBeDownloaded = this.toBeDownloaded - 1;
62
62
  errorDownload = true;
63
- console.error(`There is an issue with external resource: ${xhr?.responseURL}.`);
63
+ console.error(`There is an issue with external resource ${xhr?.responseURL ? ": " + xhr?.responseURL: ""}.`);
64
64
  const payload = {
65
65
  type: "Error",
66
66
  xhr
@@ -122,7 +122,7 @@ exports.SceneLoader = function (sceneIn) {
122
122
  if (finishCallback != undefined && (typeof finishCallback == 'function'))
123
123
  finishCallback();
124
124
  } else {
125
- this.onError();
125
+ (this.onError(finishCallback))({responseURL: url});
126
126
  }
127
127
  }
128
128
  }
@@ -9,6 +9,7 @@ precision highp int;
9
9
  precision highp sampler2DArray;
10
10
 
11
11
  uniform sampler2DArray diffuse;
12
+ uniform bool discardAlpha;
12
13
  in vec3 vUw;
13
14
 
14
15
  out vec4 outColor;
@@ -18,7 +19,9 @@ void main() {
18
19
  vec4 color = texture( diffuse, vUw );
19
20
 
20
21
  // lighten a bit
21
- outColor = vec4( color.rgb + .2, 1.0 );
22
+ if (discardAlpha && color.a == 0.0) discard;
23
+
24
+ outColor = vec4( color.rgba );
22
25
 
23
26
  }
24
27
  `;
@@ -58,6 +61,7 @@ const getUniforms = function() {
58
61
  slide: { value: new THREE.Vector3( 0, 0, 1 ) },
59
62
  direction: {value: 1},
60
63
  flipY: { value: true},
64
+ discardAlpha: {value: true},
61
65
  };
62
66
  }
63
67
 
@@ -78,8 +78,9 @@ const TextureArray = function () {
78
78
  if (options) {
79
79
  if (options.vs && options.fs) {
80
80
  let transparent = true;
81
- if (options.transparent)
81
+ if ("transparent" in options) {
82
82
  transparent = options.transparent;
83
+ }
83
84
  let side = THREE.FrontSide;
84
85
  if (options.side)
85
86
  side = options.side;