zincjs 1.16.7 → 1.16.8

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.7",
3
+ "version": "1.16.8",
4
4
  "description": "ZincJS (Web-based-Zinc-Visualisation)",
5
5
  "main": "build/zinc.js",
6
6
  "directories": {
@@ -19,9 +19,9 @@ exports.Label = function (textIn, colourIn) {
19
19
  let size = 1.0;
20
20
  let fontWeight = 500;
21
21
  if (colourIn)
22
- sprite = new SpriteText(text, 0.015, colourIn.getStyle());
22
+ sprite = new SpriteText(text, 0.012, colourIn.getStyle());
23
23
  else
24
- sprite = new SpriteText(text, 0.015);
24
+ sprite = new SpriteText(text, 0.012);
25
25
  sprite.fontFace = "Asap";
26
26
  sprite.fontWeight = fontWeight;
27
27
  sprite.material.map.generateMipmaps = false;
@@ -98,7 +98,7 @@ exports.Label = function (textIn, colourIn) {
98
98
  * @param {Number} scaling - Scale to be set.
99
99
  */
100
100
  this.setSize = sizeIn => {
101
- if (sizeIn && sizeIn !== size) {
101
+ if (sizeIn > 0.0) {
102
102
  sprite.scale.x = originalScale[0] * sizeIn;
103
103
  sprite.scale.y = originalScale[1] * sizeIn;
104
104
  size = sizeIn;
@@ -170,7 +170,7 @@ const Pointset = function () {
170
170
  labelSize = size;
171
171
  for (let i = 0; i < labelSets.length; i++) {
172
172
  if (labelSets[i]) {
173
- labelSets[i].setSize(size);
173
+ labelSets[i].setSize(labelSize);
174
174
  }
175
175
  }
176
176
  }
@@ -21,6 +21,8 @@ const TextureSlides = function (textureIn) {
21
21
  this.morph.userData = this;
22
22
  let edgesLine = undefined;
23
23
  let flipY = true;
24
+ let brightness = 0.0;
25
+ let contrast = 1.0;
24
26
 
25
27
  /**
26
28
  @typedef SLIDE_SETTINGS
@@ -111,6 +113,8 @@ const TextureSlides = function (textureIn) {
111
113
  const geometry = new THREE.PlaneGeometry(1, 1);
112
114
  geometry.translate(0.5, 0.5, 0);
113
115
  const uniforms = shader.getUniforms();
116
+ uniforms.brightness.value = brightness;
117
+ uniforms.contrast.value = contrast;
114
118
  uniforms.diffuse.value = this.texture.impl;
115
119
  uniforms.depth.value = this.texture.size.depth;
116
120
  uniforms.flipY.value = flipY;
@@ -341,6 +345,40 @@ const TextureSlides = function (textureIn) {
341
345
  edgesLine.visible = true;
342
346
  }
343
347
 
348
+ this.getBrightness = () => {
349
+ return brightness;
350
+ }
351
+
352
+ this.setBrightness = (brightnessIn) => {
353
+ brightness = brightnessIn;
354
+ this.morph.children.forEach((mesh) => {
355
+ const material = mesh.material;
356
+ if (material.type === "ShaderMaterial") {
357
+ const uniforms = material.uniforms;
358
+ uniforms.brightness.value = brightness;
359
+ material.needsUpdate = true;
360
+ }
361
+ });
362
+ }
363
+
364
+ this.getContrast = () => {
365
+ return contrast;
366
+ }
367
+
368
+ this.setContrast = (contrastIn) => {
369
+ if (contrast >= 0 ) {
370
+ contrast = contrastIn;
371
+ this.morph.children.forEach((mesh) => {
372
+ const material = mesh.material;
373
+ if (material.type === "ShaderMaterial") {
374
+ const uniforms = material.uniforms;
375
+ uniforms.contrast.value = contrast;
376
+ material.needsUpdate = true;
377
+ }
378
+ });
379
+ }
380
+ }
381
+
344
382
  this.hideEdges = () => {
345
383
  if (edgesLine) {
346
384
  edgesLine.visible = false;
@@ -10,6 +10,8 @@ precision highp sampler2DArray;
10
10
 
11
11
  uniform sampler2DArray diffuse;
12
12
  uniform bool discardAlpha;
13
+ uniform float brightness;
14
+ uniform float contrast;
13
15
  in vec3 vUw;
14
16
 
15
17
  out vec4 outColor;
@@ -18,15 +20,17 @@ void main() {
18
20
 
19
21
  vec4 color = texture( diffuse, vUw );
20
22
 
21
- // lighten a bit
23
+ // discard if alpha is zero
22
24
  if (discardAlpha && color.a == 0.0) discard;
23
-
24
- outColor = vec4( color.rgba );
25
-
25
+ // Apply brightness
26
+ vec3 brightenedColor = color.rgb + vec3(brightness);
27
+ // Apply contrast
28
+ vec3 contrastedColor = (brightenedColor - vec3(0.5)) * contrast + vec3(0.5);
29
+ outColor = vec4(contrastedColor, color.a);
26
30
  }
27
31
  `;
28
32
 
29
- const vs =
33
+ const vs =
30
34
  `
31
35
  out vec3 vUw;
32
36
  uniform float depth;
@@ -46,7 +50,7 @@ void main() {
46
50
  if (direction == 3)
47
51
  slidePos = vec3(position.x, position.y, slide.z);
48
52
 
49
- if (flipY)
53
+ if (flipY)
50
54
  slidePos.y = 1.0 - slidePos.y;
51
55
 
52
56
  vUw.xyz = vec3(slidePos.x, slidePos.y, slidePos.z * depth);
@@ -56,12 +60,14 @@ void main() {
56
60
 
57
61
  const getUniforms = function() {
58
62
  return {
59
- diffuse: { value: undefined },
63
+ brightness: { value: 0},
64
+ contrast: { value: 1},
60
65
  depth: { value: 1 },
61
- slide: { value: new THREE.Vector3( 0, 0, 1 ) },
66
+ discardAlpha: {value: true},
67
+ diffuse: { value: undefined },
62
68
  direction: {value: 1},
63
69
  flipY: { value: true},
64
- discardAlpha: {value: true},
70
+ slide: { value: new THREE.Vector3( 0, 0, 1 ) },
65
71
  };
66
72
  }
67
73
 
@@ -3,7 +3,7 @@ const THREE = require('three');
3
3
  /**
4
4
  * Texture array object for holding array of images into
5
5
  * texures unit that can be used by other texture primitives.
6
- *
6
+ *
7
7
  * @class
8
8
  * @author Alan Wu
9
9
  * @return {TextureArray}
@@ -15,7 +15,7 @@ const TextureArray = function () {
15
15
 
16
16
  /**
17
17
  * Read images from an array containg src locations.
18
- *
18
+ *
19
19
  * @async
20
20
  * @param {Array} srcArrays - List of source location of the images.
21
21
  */
@@ -61,16 +61,16 @@ const TextureArray = function () {
61
61
  /**
62
62
  * Get and create the material containing shaders and the textures.
63
63
  * The texture must be read and ready before calling this function.
64
- *
64
+ *
65
65
  *
66
66
  * @param {Object} options - Customise the material with the options object.
67
- * @param {String} options.fs - string of the fragment shader used for
67
+ * @param {String} options.fs - string of the fragment shader used for
68
68
  * visualisation.
69
- * @param {String} options.vs - string of the vertex shader used for
69
+ * @param {String} options.vs - string of the vertex shader used for
70
70
  * visualisation.
71
71
  * @param {Object} options.uniforms - Containing the data to be passed into the shaders.
72
72
  * @param {String} options.glslVersion - Version of glsl used for compile this shader.
73
- *
73
+ *
74
74
  */
75
75
  this.getMaterial = (options) => {
76
76
  if (this.impl) {