zincjs 2.0.1 → 2.1.1
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 +10 -10
- package/build/zinc.js.map +1 -1
- package/package.json +2 -2
- package/src/controls.js +1 -2
- package/src/primitives/glyphset.js +19 -3
- package/src/primitives/texturePrimitive.js +2 -2
- package/src/primitives/textureSlides.js +1 -1
- package/src/primitives/zincObject.js +3 -4
- package/src/sceneLoader.js +12 -14
- package/src/utilities.js +1 -19
- package/src/zinc.js +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zincjs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "ZincJS (Web-based-Zinc-Visualisation)",
|
|
5
5
|
"main": "build/zinc.js",
|
|
6
6
|
"directories": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@vitest/coverage-v8": "^1.6.1",
|
|
49
49
|
"auto-changelog": "^2.4.0",
|
|
50
50
|
"chai": "^4.1.0",
|
|
51
|
-
"gl": "^
|
|
51
|
+
"gl": "^8.1.6",
|
|
52
52
|
"happy-dom": "^20.10.6",
|
|
53
53
|
"jsdoc": "^4.0.2",
|
|
54
54
|
"msw": "^2.14.6",
|
package/src/controls.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import { resolveURL } from './utilities';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Object with containg viewport information used in ZincJS.
|
|
@@ -851,7 +850,7 @@ const CameraControls = function ( object, domElement, renderer, scene ) {
|
|
|
851
850
|
* @param {requestCallback} finishCallback - The callback once the path is load.
|
|
852
851
|
*/
|
|
853
852
|
this.loadPathURL = (path_url, finishCallback) => {
|
|
854
|
-
const requestURL =
|
|
853
|
+
const requestURL = path_url;
|
|
855
854
|
fetch(requestURL)
|
|
856
855
|
.then((response) => {
|
|
857
856
|
if (!response.ok) {
|
|
@@ -27,6 +27,7 @@ const Glyphset = function () {
|
|
|
27
27
|
let numberOfVertices = 0;
|
|
28
28
|
let baseSize = [0, 0, 0];
|
|
29
29
|
let offset = [0, 0, 0];
|
|
30
|
+
let labelsOn = false;
|
|
30
31
|
let scaleFactors = [0, 0, 0];
|
|
31
32
|
let repeat_mode = "NONE";
|
|
32
33
|
this.ready = false;
|
|
@@ -407,13 +408,26 @@ const Glyphset = function () {
|
|
|
407
408
|
return undefined;
|
|
408
409
|
}
|
|
409
410
|
|
|
411
|
+
this.isLabelDisplayed = () => {
|
|
412
|
+
return labelsOn;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Check whether label can be shown
|
|
417
|
+
*/
|
|
418
|
+
this.canShowLabel = () => {
|
|
419
|
+
return (glyphList?.length && (labels?.length || this.groupName));
|
|
420
|
+
}
|
|
410
421
|
|
|
411
422
|
/**
|
|
412
423
|
* Display the label of the glyphs in the glyphset.
|
|
413
424
|
*/
|
|
414
425
|
this.showLabel = () => {
|
|
415
|
-
|
|
416
|
-
|
|
426
|
+
if (glyphList?.length) {
|
|
427
|
+
labelsOn = true;
|
|
428
|
+
for (let i = 0; i < glyphList.length; i++) {
|
|
429
|
+
glyphList[i].showLabel(this.morph.material ? this.morph.material.color : undefined);
|
|
430
|
+
}
|
|
417
431
|
}
|
|
418
432
|
}
|
|
419
433
|
|
|
@@ -424,6 +438,7 @@ const Glyphset = function () {
|
|
|
424
438
|
for (let i = 0; i < glyphList.length; i++) {
|
|
425
439
|
glyphList[i].hideLabel();
|
|
426
440
|
}
|
|
441
|
+
labelsOn = false;
|
|
427
442
|
}
|
|
428
443
|
|
|
429
444
|
/**
|
|
@@ -445,7 +460,8 @@ const Glyphset = function () {
|
|
|
445
460
|
glyphList[i] = glyph;
|
|
446
461
|
this.morph.add(glyph.getGroup());
|
|
447
462
|
}
|
|
448
|
-
if
|
|
463
|
+
//Only display labels if the label list is available
|
|
464
|
+
if (labels && displayLabels) {
|
|
449
465
|
this.showLabel();
|
|
450
466
|
}
|
|
451
467
|
//Update the transformation of the glyphs.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import { TextureArray } from '../texture/textureArray';
|
|
3
3
|
import { ZincObject } from './zincObject';
|
|
4
4
|
/**
|
|
@@ -32,7 +32,7 @@ const TexturePrimitive = function (textureIn) {
|
|
|
32
32
|
const texture = new TextureArray();
|
|
33
33
|
const imgArray = [];
|
|
34
34
|
textureData.images.source.forEach(img => {
|
|
35
|
-
imgArray.push(
|
|
35
|
+
imgArray.push(img);
|
|
36
36
|
});
|
|
37
37
|
const _this = this;
|
|
38
38
|
texture.loadFromImages(imgArray).then(() => {
|
|
@@ -188,7 +188,7 @@ const TextureSlides = function (textureIn) {
|
|
|
188
188
|
/**
|
|
189
189
|
* Get the array of slides, return them in an array
|
|
190
190
|
*
|
|
191
|
-
* @return {Array} - Return an array of {@link THREE.Object
|
|
191
|
+
* @return {Array} - Return an array of {@link THREE.Object}
|
|
192
192
|
*/
|
|
193
193
|
this.getSlides = () => {
|
|
194
194
|
if (this.morph) return [...this.morph.children];
|
|
@@ -2,8 +2,7 @@ import * as THREE from 'three';
|
|
|
2
2
|
import {
|
|
3
3
|
createBufferGeometry,
|
|
4
4
|
getBoundingBox,
|
|
5
|
-
removeVertexAtIndex
|
|
6
|
-
resolveURL
|
|
5
|
+
removeVertexAtIndex
|
|
7
6
|
} from '../utilities';
|
|
8
7
|
import { LOD } from './lod';
|
|
9
8
|
import { Marker } from './marker';
|
|
@@ -182,7 +181,7 @@ ZincObject.prototype.setMesh = function(mesh, localTimeEnabled, localMorphColour
|
|
|
182
181
|
if (this.animationClip && (this.animationClip[0] != undefined)) {
|
|
183
182
|
this.clipAction = this.mixer.clipAction(this.animationClip[0]).setDuration(
|
|
184
183
|
this.duration);
|
|
185
|
-
this.clipAction.loop = THREE.
|
|
184
|
+
this.clipAction.loop = THREE.LoopOnce;
|
|
186
185
|
this.clipAction.clampWhenFinished = true;
|
|
187
186
|
this.clipAction.play();
|
|
188
187
|
}
|
|
@@ -795,7 +794,7 @@ ZincObject.prototype.setPosition = function(x, y, z) {
|
|
|
795
794
|
}
|
|
796
795
|
|
|
797
796
|
ZincObject.prototype.loadAdditionalSources = function(primitivesLoader, sources) {
|
|
798
|
-
primitivesLoader.load(
|
|
797
|
+
primitivesLoader.load(filename, meshloader(region, colour, opacity, localTimeEnabled, localMorphColour, undefined, undefined,
|
|
799
798
|
undefined, undefined, finishCallback), this.onProgress(filename), this.onError(finishCallback));
|
|
800
799
|
}
|
|
801
800
|
|
package/src/sceneLoader.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Lines } from './primitives/lines';
|
|
|
9
9
|
import { Pointset } from './primitives/pointset';
|
|
10
10
|
import { TextureSlides } from './primitives/textureSlides';
|
|
11
11
|
import { TubeLines } from './primitives/tubeLines';
|
|
12
|
-
import { createNewURL, isRegionGroup
|
|
12
|
+
import { createNewURL, isRegionGroup } from './utilities';
|
|
13
13
|
import Zinc from './zinc';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -115,7 +115,7 @@ const SceneLoader = function (sceneIn) {
|
|
|
115
115
|
*/
|
|
116
116
|
this.loadViewURL = (url, finishCallback) => {
|
|
117
117
|
this.toBeDownloaded += 1;
|
|
118
|
-
const requestURL =
|
|
118
|
+
const requestURL = url;
|
|
119
119
|
fetch(requestURL)
|
|
120
120
|
.then((response) => {
|
|
121
121
|
if (!response.ok) {
|
|
@@ -161,7 +161,7 @@ const SceneLoader = function (sceneIn) {
|
|
|
161
161
|
let localMorphColour = 0;
|
|
162
162
|
if (morphColour != undefined && morphColour[i] != undefined)
|
|
163
163
|
localMorphColour = morphColour[i] ? true : false;
|
|
164
|
-
primitivesLoader.load(
|
|
164
|
+
primitivesLoader.load(filename, meshloader(region, colour, opacity, localTimeEnabled, localMorphColour, undefined, undefined,
|
|
165
165
|
undefined, undefined, finishCallback), this.onProgress(filename), this.onError(finishCallback));
|
|
166
166
|
}
|
|
167
167
|
}
|
|
@@ -175,7 +175,7 @@ const SceneLoader = function (sceneIn) {
|
|
|
175
175
|
* @deprecated
|
|
176
176
|
*/
|
|
177
177
|
this.loadFromViewURL = (targetRegion, jsonFilePrefix, finishCallback) => {
|
|
178
|
-
const requestURL =
|
|
178
|
+
const requestURL = jsonFilePrefix + "_view.json";
|
|
179
179
|
fetch(requestURL)
|
|
180
180
|
.then((response) => {
|
|
181
181
|
if (!response.ok) {
|
|
@@ -284,7 +284,7 @@ const SceneLoader = function (sceneIn) {
|
|
|
284
284
|
}
|
|
285
285
|
let isInline = (options && options.isInline) ? options.isInline : undefined;
|
|
286
286
|
let anatomicalId = (options && options.anatomicalId) ? options.anatomicalId : undefined;
|
|
287
|
-
let displayLabels =
|
|
287
|
+
let displayLabels = options?.displayLabels ? options.displayLabels : true;
|
|
288
288
|
let renderOrder = (options && "renderOrder" in options) ? options.renderOrder : undefined;
|
|
289
289
|
const newGlyphset = new Glyphset();
|
|
290
290
|
newGlyphset.setDuration(scene.getDuration());
|
|
@@ -299,7 +299,7 @@ const SceneLoader = function (sceneIn) {
|
|
|
299
299
|
newGlyphset.load(glyphsetData, glyphurl, myCallback, isInline, displayLabels);
|
|
300
300
|
}
|
|
301
301
|
else {
|
|
302
|
-
newGlyphset.load(glyphsetData,
|
|
302
|
+
newGlyphset.load(glyphsetData, glyphurl, myCallback, isInline, displayLabels);
|
|
303
303
|
}
|
|
304
304
|
newGlyphset.setAnatomicalId(anatomicalId);
|
|
305
305
|
newGlyphset.setRenderOrder(renderOrder);
|
|
@@ -349,7 +349,7 @@ const SceneLoader = function (sceneIn) {
|
|
|
349
349
|
|
|
350
350
|
xmlhttp.onreadystatechange = onLoadGlyphsetReady(region, xmlhttp, glyphurl,
|
|
351
351
|
groupName, finishCallback, options);
|
|
352
|
-
xmlhttp.open("GET",
|
|
352
|
+
xmlhttp.open("GET", metaurl, true);
|
|
353
353
|
xmlhttp.send();*/
|
|
354
354
|
}
|
|
355
355
|
}
|
|
@@ -401,7 +401,7 @@ const SceneLoader = function (sceneIn) {
|
|
|
401
401
|
const opacity = Zinc.defaultOpacity;
|
|
402
402
|
const loader = new STLLoader();
|
|
403
403
|
loader.crossOrigin = "Anonymous";
|
|
404
|
-
loader.load(
|
|
404
|
+
loader.load(url, meshloader(region, colour, opacity, false,
|
|
405
405
|
false, groupName, undefined, undefined, undefined, finishCallback));
|
|
406
406
|
}
|
|
407
407
|
|
|
@@ -420,7 +420,7 @@ const SceneLoader = function (sceneIn) {
|
|
|
420
420
|
const opacity = Zinc.defaultOpacity;
|
|
421
421
|
const loader = new OBJLoader();
|
|
422
422
|
loader.crossOrigin = "Anonymous";
|
|
423
|
-
loader.load(
|
|
423
|
+
loader.load(url, meshloader(region, colour, opacity, false,
|
|
424
424
|
false, groupName, undefined, undefined, undefined, finishCallback));
|
|
425
425
|
}
|
|
426
426
|
|
|
@@ -575,7 +575,7 @@ const SceneLoader = function (sceneIn) {
|
|
|
575
575
|
if (isInline) {
|
|
576
576
|
loadTexture(region, undefined, url, groupName, finishCallback, options);
|
|
577
577
|
} else {
|
|
578
|
-
const requestURL =
|
|
578
|
+
const requestURL = url;
|
|
579
579
|
fetch(requestURL)
|
|
580
580
|
.then((response) => {
|
|
581
581
|
if (!response.ok) {
|
|
@@ -760,9 +760,7 @@ const SceneLoader = function (sceneIn) {
|
|
|
760
760
|
} else {
|
|
761
761
|
newGeometryURL = item.Inline.GlyphGeometriesURL;
|
|
762
762
|
}
|
|
763
|
-
|
|
764
|
-
options.displayLabels = true;
|
|
765
|
-
}
|
|
763
|
+
options.displayLabels = item.displayLabels ? item.displayLabels : true;
|
|
766
764
|
options.loaderOptions.isGlyphsets = true;
|
|
767
765
|
this.loadGlyphsetURL(region, newURL, newGeometryURL, groupName, finishCallback, options);
|
|
768
766
|
break;
|
|
@@ -984,7 +982,7 @@ const SceneLoader = function (sceneIn) {
|
|
|
984
982
|
* for each glyphset and geometry that has been written in.
|
|
985
983
|
*/
|
|
986
984
|
this.loadMetadataURL = (targetRegion, url, finishCallback, allCompletedCallback, options) => {
|
|
987
|
-
const requestURL =
|
|
985
|
+
const requestURL = url;
|
|
988
986
|
fetch(requestURL)
|
|
989
987
|
.then((response) => {
|
|
990
988
|
if (!response.ok) {
|
package/src/utilities.js
CHANGED
|
@@ -2,25 +2,8 @@ import * as THREE from 'three';
|
|
|
2
2
|
import { Geometry as THREEGeometry } from './three/Geometry';
|
|
3
3
|
import SpriteTextModule from 'three-spritetext';
|
|
4
4
|
const SpriteText = SpriteTextModule.default || SpriteTextModule;
|
|
5
|
-
import Zinc from './zinc';
|
|
6
5
|
import discPNG from './assets/disc.png';
|
|
7
6
|
|
|
8
|
-
function resolveURL(url) {
|
|
9
|
-
let actualURL = url;
|
|
10
|
-
let prefix = Zinc.modelPrefix;
|
|
11
|
-
|
|
12
|
-
if (prefix) {
|
|
13
|
-
if (prefix[prefix.length -1] != '/')
|
|
14
|
-
prefix = prefix + '/';
|
|
15
|
-
const r = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
16
|
-
if (!r.test(url)) {
|
|
17
|
-
actualURL = prefix + url;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return actualURL;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
7
|
function createNewURL(target, reference) {
|
|
25
8
|
const getNewURL = (target, reference) => {
|
|
26
9
|
try {
|
|
@@ -87,7 +70,7 @@ function getBoundingBox(mesh, cachedBox, b1, v1, v2) {
|
|
|
87
70
|
//Convenient function
|
|
88
71
|
function loadExternalFile(url, data, callback, errorCallback) {
|
|
89
72
|
// Set up an asynchronous request
|
|
90
|
-
fetch(
|
|
73
|
+
fetch(url)
|
|
91
74
|
.then((response) => {
|
|
92
75
|
if (!response.ok) {
|
|
93
76
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
@@ -858,7 +841,6 @@ export {
|
|
|
858
841
|
mergeVertices,
|
|
859
842
|
PhongToToon,
|
|
860
843
|
removeVertexAtIndex,
|
|
861
|
-
resolveURL,
|
|
862
844
|
updateMorphColorAttribute,
|
|
863
845
|
toBufferGeometry,
|
|
864
846
|
};
|
package/src/zinc.js
CHANGED
|
@@ -40,7 +40,6 @@ const Zinc = function() {
|
|
|
40
40
|
this.Revision = version;
|
|
41
41
|
this.defaultMaterialColor = 0xFFFFFF;
|
|
42
42
|
this.defaultOpacity = 1.0;
|
|
43
|
-
this.modelPrefix = undefined;
|
|
44
43
|
// Assign hoisted modules to the instance
|
|
45
44
|
this.Geometry = Geometry;
|
|
46
45
|
this.Glyph = Glyph;
|
|
@@ -48,8 +47,8 @@ const Zinc = function() {
|
|
|
48
47
|
this.Pointset = Pointset;
|
|
49
48
|
this.Label = Label;
|
|
50
49
|
this.Lines = Lines;
|
|
51
|
-
this.TextureArray = TextureArray;
|
|
52
50
|
this.TextureSlides = TextureSlides;
|
|
51
|
+
this.TextureArray = TextureArray;
|
|
53
52
|
this.Renderer = Renderer;
|
|
54
53
|
this.Scene = Scene;
|
|
55
54
|
//this.GeometryCSG = GeometryCSG;
|