zincjs 2.3.1-beta.1 → 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/build/zinc.js +2 -2
- package/build/zinc.js.map +1 -1
- package/package.json +2 -2
- package/src/primitives/label.js +23 -5
- package/src/primitives/pointset.js +5 -5
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
|
|
|
@@ -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;
|