zincjs 2.3.1-beta.0 → 2.4.0
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": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "ZincJS (Web-based-Zinc-Visualisation)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/zinc.js",
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
"lodash": "^4.17.19",
|
|
70
70
|
"nifti-reader-js": "0.8.0",
|
|
71
71
|
"three": "^0.185.1",
|
|
72
|
-
"three-spritetext": "1.
|
|
72
|
+
"three-spritetext": "1.10.0"
|
|
73
73
|
}
|
|
74
74
|
}
|
package/src/primitives/label.js
CHANGED
|
@@ -20,10 +20,11 @@ const Label = function (textIn, colourIn) {
|
|
|
20
20
|
let colour = colourIn;
|
|
21
21
|
let size = 1.0;
|
|
22
22
|
let fontWeight = 500;
|
|
23
|
+
const textHeight = 0.012;
|
|
23
24
|
if (colourIn)
|
|
24
|
-
sprite = new SpriteText(text,
|
|
25
|
+
sprite = new SpriteText(text, textHeight, colourIn.getStyle());
|
|
25
26
|
else
|
|
26
|
-
sprite = new SpriteText(text,
|
|
27
|
+
sprite = new SpriteText(text, textHeight);
|
|
27
28
|
sprite.fontFace = "Asap";
|
|
28
29
|
sprite.fontSize = 90;
|
|
29
30
|
sprite.fontWeight = fontWeight;
|
|
@@ -34,7 +35,8 @@ const Label = function (textIn, colourIn) {
|
|
|
34
35
|
sprite.material.sizeAttenuation = false;
|
|
35
36
|
sprite.center.x = -0.05;
|
|
36
37
|
sprite.center.y = 0;
|
|
37
|
-
|
|
38
|
+
|
|
39
|
+
|
|
38
40
|
|
|
39
41
|
/**
|
|
40
42
|
* Get the current position in an array containing the x, y and z
|
|
@@ -105,8 +107,7 @@ const Label = function (textIn, colourIn) {
|
|
|
105
107
|
*/
|
|
106
108
|
this.setSize = sizeIn => {
|
|
107
109
|
if (sizeIn > 0.0) {
|
|
108
|
-
sprite.
|
|
109
|
-
sprite.scale.y = originalScale[1] * sizeIn;
|
|
110
|
+
sprite.textHeight = textHeight * sizeIn;
|
|
110
111
|
size = sizeIn;
|
|
111
112
|
}
|
|
112
113
|
}
|
|
@@ -130,8 +131,25 @@ const Label = function (textIn, colourIn) {
|
|
|
130
131
|
*/
|
|
131
132
|
this.setText = textIn => {
|
|
132
133
|
if (textIn && textIn !== sprite.text) {
|
|
134
|
+
//Force teh texture to update
|
|
135
|
+
const canvas = sprite._canvas;
|
|
136
|
+
if (sprite.material && sprite.material.map) {
|
|
137
|
+
sprite.material.map.dispose();
|
|
138
|
+
}
|
|
139
|
+
if (sprite._canvas) {
|
|
140
|
+
const ctx = sprite._canvas.getContext('2d');
|
|
141
|
+
if (ctx) {
|
|
142
|
+
ctx.clearRect(0, 0, sprite._canvas.width, sprite._canvas.height);
|
|
143
|
+
}
|
|
144
|
+
sprite._canvas.width = 1;
|
|
145
|
+
sprite._canvas.height = 1;
|
|
146
|
+
}
|
|
133
147
|
sprite.text = textIn;
|
|
148
|
+
sprite.textHeight = textHeight * size;
|
|
134
149
|
text = textIn;
|
|
150
|
+
if (sprite.material && sprite.material.map) {
|
|
151
|
+
sprite.material.map.needsUpdate = true;
|
|
152
|
+
}
|
|
135
153
|
}
|
|
136
154
|
}
|
|
137
155
|
|
package/src/primitives/marker.js
CHANGED
|
@@ -3,11 +3,9 @@ import myImage from '../assets/mapMarker.svg';
|
|
|
3
3
|
import { createNewSpriteText } from '../utilities';
|
|
4
4
|
import { ZincObject } from './zincObject';
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
texture.image = markerImage;
|
|
10
|
-
texture.needsUpdate = true;
|
|
6
|
+
const textureLoader = new THREE.TextureLoader();
|
|
7
|
+
const texture = textureLoader.load(myImage);
|
|
8
|
+
texture.colorSpace = THREE.SRGBColorSpace;
|
|
11
9
|
const size = [0.02, 0.03, 1];
|
|
12
10
|
const spriteMaterial = new THREE.SpriteMaterial({
|
|
13
11
|
map: texture,
|
|
@@ -197,6 +195,7 @@ const Marker = function(zincObject) {
|
|
|
197
195
|
}
|
|
198
196
|
if (!label && numberIn) {
|
|
199
197
|
label = createNewSpriteText(numberIn, 0.012, "black", "Asap", 120, 700);
|
|
198
|
+
label.renderOrder = 10001;
|
|
200
199
|
this.morph.add(label);
|
|
201
200
|
}
|
|
202
201
|
number = numberIn;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { ZincObject } from './zincObject';
|
|
3
|
-
const markerImage = new Image(128, 128);
|
|
4
3
|
import mapMarkerOrange from '../assets/mapMarkerOrange.svg';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
texture
|
|
4
|
+
import { createNewSpriteText } from '../utilities';
|
|
5
|
+
|
|
6
|
+
const textureLoader = new THREE.TextureLoader();
|
|
7
|
+
const texture = textureLoader.load(mapMarkerOrange);
|
|
8
|
+
texture.colorSpace = THREE.SRGBColorSpace;
|
|
9
9
|
const size = [0.02, 0.03, 1];
|
|
10
10
|
const spriteMaterial = new THREE.SpriteMaterial({
|
|
11
11
|
map: texture,
|
|
@@ -15,7 +15,6 @@ const spriteMaterial = new THREE.SpriteMaterial({
|
|
|
15
15
|
depthWrite: false,
|
|
16
16
|
sizeAttenuation: false
|
|
17
17
|
});
|
|
18
|
-
import { createNewSpriteText } from '../utilities';
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* A special graphics type with a tear drop shape.
|
|
@@ -46,9 +45,9 @@ const MarkerCluster = function(sceneIn) {
|
|
|
46
45
|
*
|
|
47
46
|
* @param {Number} size - size to be set.
|
|
48
47
|
*/
|
|
49
|
-
this.setSpriteSize =
|
|
48
|
+
this.setSpriteSize = sizeIn => {
|
|
50
49
|
sprite.scale.set(0.015, 0.02, 1);
|
|
51
|
-
sprite.scale.multiplyScalar(
|
|
50
|
+
sprite.scale.multiplyScalar(sizeIn);
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
this.clear = () => {
|
|
@@ -101,6 +100,7 @@ const MarkerCluster = function(sceneIn) {
|
|
|
101
100
|
sprite.label.material.dispose();
|
|
102
101
|
}
|
|
103
102
|
sprite.label = createNewSpriteText(number, 0.012, "black", "Asap", 120, 700);
|
|
103
|
+
sprite.label.renderOrder = 10001;
|
|
104
104
|
sprite.number = number;
|
|
105
105
|
sprite.group.add(sprite.label);
|
|
106
106
|
}
|
|
@@ -301,11 +301,11 @@ const Pointset = function () {
|
|
|
301
301
|
|
|
302
302
|
|
|
303
303
|
/**
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
304
|
+
* Turn size attenuation on/off based on the flag.
|
|
305
|
+
*
|
|
306
|
+
* @param {Boolean} flag - Determin either size attenuation
|
|
307
|
+
* should be on or off.
|
|
308
|
+
*/
|
|
309
309
|
this.render = (delta, playAnimation, cameraControls, options) => {
|
|
310
310
|
if (this.morph && cameraControls) {
|
|
311
311
|
this.morph.sizePerPixel = cameraControls.pixelHeight;
|
package/src/utilities.js
CHANGED
|
@@ -742,7 +742,7 @@ function createNewSpriteText(text, height, colour, font, pixel, weight) {
|
|
|
742
742
|
sprite.material.depthWrite = false;
|
|
743
743
|
sprite.material.depthTest = false;
|
|
744
744
|
sprite.center.set(0.5, -1.2);
|
|
745
|
-
sprite.renderOrder =
|
|
745
|
+
sprite.renderOrder = 10001;
|
|
746
746
|
return sprite;
|
|
747
747
|
}
|
|
748
748
|
|